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