1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * This file is part of FFmpeg. 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 5cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 6cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 7cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 8cabdff1aSopenharmony_ci * 9cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 10cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 11cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12cabdff1aSopenharmony_ci * Lesser General Public License for more details. 13cabdff1aSopenharmony_ci * 14cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 15cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 16cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17cabdff1aSopenharmony_ci */ 18cabdff1aSopenharmony_ci 19cabdff1aSopenharmony_ci/* 20cabdff1aSopenharmony_ci * 21cabdff1aSopenharmony_ci * Copyright (c) Sandflow Consulting LLC 22cabdff1aSopenharmony_ci * 23cabdff1aSopenharmony_ci * Redistribution and use in source and binary forms, with or without 24cabdff1aSopenharmony_ci * modification, are permitted provided that the following conditions are met: 25cabdff1aSopenharmony_ci * 26cabdff1aSopenharmony_ci * * Redistributions of source code must retain the above copyright notice, this 27cabdff1aSopenharmony_ci * list of conditions and the following disclaimer. 28cabdff1aSopenharmony_ci * * Redistributions in binary form must reproduce the above copyright notice, 29cabdff1aSopenharmony_ci * this list of conditions and the following disclaimer in the documentation 30cabdff1aSopenharmony_ci * and/or other materials provided with the distribution. 31cabdff1aSopenharmony_ci * 32cabdff1aSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33cabdff1aSopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34cabdff1aSopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35cabdff1aSopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 36cabdff1aSopenharmony_ci * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 37cabdff1aSopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38cabdff1aSopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39cabdff1aSopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 40cabdff1aSopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 41cabdff1aSopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42cabdff1aSopenharmony_ci * POSSIBILITY OF SUCH DAMAGE. 43cabdff1aSopenharmony_ci */ 44cabdff1aSopenharmony_ci 45cabdff1aSopenharmony_ci/** 46cabdff1aSopenharmony_ci * Public header file for the processing of Interoperable Master Format (IMF) 47cabdff1aSopenharmony_ci * packages. 48cabdff1aSopenharmony_ci * 49cabdff1aSopenharmony_ci * @author Pierre-Anthony Lemieux 50cabdff1aSopenharmony_ci * @author Valentin Noel 51cabdff1aSopenharmony_ci * @file 52cabdff1aSopenharmony_ci * @ingroup lavu_imf 53cabdff1aSopenharmony_ci */ 54cabdff1aSopenharmony_ci 55cabdff1aSopenharmony_ci#ifndef AVFORMAT_IMF_H 56cabdff1aSopenharmony_ci#define AVFORMAT_IMF_H 57cabdff1aSopenharmony_ci 58cabdff1aSopenharmony_ci#include "avformat.h" 59cabdff1aSopenharmony_ci#include "libavformat/avio.h" 60cabdff1aSopenharmony_ci#include "libavutil/rational.h" 61cabdff1aSopenharmony_ci#include "libavutil/uuid.h" 62cabdff1aSopenharmony_ci#include <libxml/tree.h> 63cabdff1aSopenharmony_ci 64cabdff1aSopenharmony_ci/** 65cabdff1aSopenharmony_ci * IMF Composition Playlist Base Resource 66cabdff1aSopenharmony_ci */ 67cabdff1aSopenharmony_citypedef struct FFIMFBaseResource { 68cabdff1aSopenharmony_ci AVRational edit_rate; /**< BaseResourceType/EditRate */ 69cabdff1aSopenharmony_ci uint32_t entry_point; /**< BaseResourceType/EntryPoint */ 70cabdff1aSopenharmony_ci uint32_t duration; /**< BaseResourceType/Duration */ 71cabdff1aSopenharmony_ci uint32_t repeat_count; /**< BaseResourceType/RepeatCount */ 72cabdff1aSopenharmony_ci} FFIMFBaseResource; 73cabdff1aSopenharmony_ci 74cabdff1aSopenharmony_ci/** 75cabdff1aSopenharmony_ci * IMF Composition Playlist Track File Resource 76cabdff1aSopenharmony_ci */ 77cabdff1aSopenharmony_citypedef struct FFIMFTrackFileResource { 78cabdff1aSopenharmony_ci FFIMFBaseResource base; 79cabdff1aSopenharmony_ci AVUUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */ 80cabdff1aSopenharmony_ci} FFIMFTrackFileResource; 81cabdff1aSopenharmony_ci 82cabdff1aSopenharmony_ci/** 83cabdff1aSopenharmony_ci * IMF Marker 84cabdff1aSopenharmony_ci */ 85cabdff1aSopenharmony_citypedef struct FFIMFMarker { 86cabdff1aSopenharmony_ci xmlChar *label_utf8; /**< Marker/Label */ 87cabdff1aSopenharmony_ci xmlChar *scope_utf8; /**< Marker/Label/\@scope */ 88cabdff1aSopenharmony_ci uint32_t offset; /**< Marker/Offset */ 89cabdff1aSopenharmony_ci} FFIMFMarker; 90cabdff1aSopenharmony_ci 91cabdff1aSopenharmony_ci/** 92cabdff1aSopenharmony_ci * IMF Composition Playlist Marker Resource 93cabdff1aSopenharmony_ci */ 94cabdff1aSopenharmony_citypedef struct FFIMFMarkerResource { 95cabdff1aSopenharmony_ci FFIMFBaseResource base; 96cabdff1aSopenharmony_ci uint32_t marker_count; /**< Number of Marker elements */ 97cabdff1aSopenharmony_ci FFIMFMarker *markers; /**< Marker elements */ 98cabdff1aSopenharmony_ci} FFIMFMarkerResource; 99cabdff1aSopenharmony_ci 100cabdff1aSopenharmony_ci/** 101cabdff1aSopenharmony_ci * IMF Composition Playlist Virtual Track 102cabdff1aSopenharmony_ci */ 103cabdff1aSopenharmony_citypedef struct FFIMFBaseVirtualTrack { 104cabdff1aSopenharmony_ci AVUUID id_uuid; /**< TrackId associated with the Virtual Track */ 105cabdff1aSopenharmony_ci} FFIMFBaseVirtualTrack; 106cabdff1aSopenharmony_ci 107cabdff1aSopenharmony_ci/** 108cabdff1aSopenharmony_ci * IMF Composition Playlist Virtual Track that consists of Track File Resources 109cabdff1aSopenharmony_ci */ 110cabdff1aSopenharmony_citypedef struct FFIMFTrackFileVirtualTrack { 111cabdff1aSopenharmony_ci FFIMFBaseVirtualTrack base; 112cabdff1aSopenharmony_ci uint32_t resource_count; /**< Number of Resource elements present in the Virtual Track */ 113cabdff1aSopenharmony_ci FFIMFTrackFileResource *resources; /**< Resource elements of the Virtual Track */ 114cabdff1aSopenharmony_ci unsigned int resources_alloc_sz; /**< Size of the resources buffer */ 115cabdff1aSopenharmony_ci} FFIMFTrackFileVirtualTrack; 116cabdff1aSopenharmony_ci 117cabdff1aSopenharmony_ci/** 118cabdff1aSopenharmony_ci * IMF Composition Playlist Virtual Track that consists of Marker Resources 119cabdff1aSopenharmony_ci */ 120cabdff1aSopenharmony_citypedef struct FFIMFMarkerVirtualTrack { 121cabdff1aSopenharmony_ci FFIMFBaseVirtualTrack base; 122cabdff1aSopenharmony_ci uint32_t resource_count; /**< Number of Resource elements present in the Virtual Track */ 123cabdff1aSopenharmony_ci FFIMFMarkerResource *resources; /**< Resource elements of the Virtual Track */ 124cabdff1aSopenharmony_ci} FFIMFMarkerVirtualTrack; 125cabdff1aSopenharmony_ci 126cabdff1aSopenharmony_ci/** 127cabdff1aSopenharmony_ci * IMF Composition Playlist 128cabdff1aSopenharmony_ci */ 129cabdff1aSopenharmony_citypedef struct FFIMFCPL { 130cabdff1aSopenharmony_ci AVUUID id_uuid; /**< CompositionPlaylist/Id element */ 131cabdff1aSopenharmony_ci xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element */ 132cabdff1aSopenharmony_ci AVRational edit_rate; /**< CompositionPlaylist/EditRate element */ 133cabdff1aSopenharmony_ci FFIMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track */ 134cabdff1aSopenharmony_ci FFIMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual Track */ 135cabdff1aSopenharmony_ci uint32_t main_audio_track_count; /**< Number of Main Audio Virtual Tracks */ 136cabdff1aSopenharmony_ci FFIMFTrackFileVirtualTrack *main_audio_tracks; /**< Main Audio Virtual Tracks */ 137cabdff1aSopenharmony_ci} FFIMFCPL; 138cabdff1aSopenharmony_ci 139cabdff1aSopenharmony_ci/** 140cabdff1aSopenharmony_ci * Parse an IMF CompositionPlaylist element into the FFIMFCPL data structure. 141cabdff1aSopenharmony_ci * @param[in] doc An XML document from which the CPL is read. 142cabdff1aSopenharmony_ci * @param[out] cpl Pointer to a memory area (allocated by the client), where the 143cabdff1aSopenharmony_ci * function writes a pointer to the newly constructed FFIMFCPL structure (or 144cabdff1aSopenharmony_ci * NULL if the CPL could not be parsed). The client is responsible for freeing 145cabdff1aSopenharmony_ci * the FFIMFCPL structure using ff_imf_cpl_free(). 146cabdff1aSopenharmony_ci * @return A non-zero value in case of an error. 147cabdff1aSopenharmony_ci */ 148cabdff1aSopenharmony_ciint ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl); 149cabdff1aSopenharmony_ci 150cabdff1aSopenharmony_ci/** 151cabdff1aSopenharmony_ci * Parse an IMF Composition Playlist document into the FFIMFCPL data structure. 152cabdff1aSopenharmony_ci * @param[in] in The context from which the CPL is read. 153cabdff1aSopenharmony_ci * @param[out] cpl Pointer to a memory area (allocated by the client), where the 154cabdff1aSopenharmony_ci * function writes a pointer to the newly constructed FFIMFCPL structure (or 155cabdff1aSopenharmony_ci * NULL if the CPL could not be parsed). The client is responsible for freeing 156cabdff1aSopenharmony_ci * the FFIMFCPL structure using ff_imf_cpl_free(). 157cabdff1aSopenharmony_ci * @return A non-zero value in case of an error. 158cabdff1aSopenharmony_ci */ 159cabdff1aSopenharmony_ciint ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl); 160cabdff1aSopenharmony_ci 161cabdff1aSopenharmony_ci/** 162cabdff1aSopenharmony_ci * Allocates and initializes an FFIMFCPL data structure. 163cabdff1aSopenharmony_ci * @return A pointer to the newly constructed FFIMFCPL structure (or NULL if the 164cabdff1aSopenharmony_ci * structure could not be constructed). The client is responsible for freeing 165cabdff1aSopenharmony_ci * the FFIMFCPL structure using ff_imf_cpl_free(). 166cabdff1aSopenharmony_ci */ 167cabdff1aSopenharmony_ciFFIMFCPL *ff_imf_cpl_alloc(void); 168cabdff1aSopenharmony_ci 169cabdff1aSopenharmony_ci/** 170cabdff1aSopenharmony_ci * Deletes an FFIMFCPL data structure previously instantiated with ff_imf_cpl_alloc(). 171cabdff1aSopenharmony_ci * @param[in] cpl The FFIMFCPL structure to delete. 172cabdff1aSopenharmony_ci */ 173cabdff1aSopenharmony_civoid ff_imf_cpl_free(FFIMFCPL *cpl); 174cabdff1aSopenharmony_ci 175cabdff1aSopenharmony_ci/** 176cabdff1aSopenharmony_ci * Reads an unsigned 32-bit integer from an XML element 177cabdff1aSopenharmony_ci * @return 0 on success, < 0 AVERROR code on error. 178cabdff1aSopenharmony_ci */ 179cabdff1aSopenharmony_ciint ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number); 180cabdff1aSopenharmony_ci 181cabdff1aSopenharmony_ci/** 182cabdff1aSopenharmony_ci * Reads an AVRational from an XML element 183cabdff1aSopenharmony_ci * @return 0 on success, < 0 AVERROR code on error. 184cabdff1aSopenharmony_ci */ 185cabdff1aSopenharmony_ciint ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational); 186cabdff1aSopenharmony_ci 187cabdff1aSopenharmony_ci/** 188cabdff1aSopenharmony_ci * Reads a UUID from an XML element 189cabdff1aSopenharmony_ci * @return 0 on success, < 0 AVERROR code on error. 190cabdff1aSopenharmony_ci */ 191cabdff1aSopenharmony_ciint ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid); 192cabdff1aSopenharmony_ci 193cabdff1aSopenharmony_ci/** 194cabdff1aSopenharmony_ci * Returns the first child element with the specified local name 195cabdff1aSopenharmony_ci * @return A pointer to the child element, or NULL if no such child element exists. 196cabdff1aSopenharmony_ci */ 197cabdff1aSopenharmony_cixmlNodePtr ff_imf_xml_get_child_element_by_name(xmlNodePtr parent, const char *name_utf8); 198cabdff1aSopenharmony_ci 199cabdff1aSopenharmony_ci#endif 200