|
26 | 26 | */ |
27 | 27 |
|
28 | 28 | /** |
29 | | - * Public header file for the processing of Interoperable Master Format (IMF) packages. |
30 | | - * |
| 29 | + * Public header file for the processing of Interoperable Master Format (IMF) |
| 30 | + * packages. |
| 31 | + * |
31 | 32 | * @author Pierre-Anthony Lemieux |
32 | 33 | * @author Valentin Noel |
33 | 34 | * @file |
|
42 | 43 | #include "libavutil/rational.h" |
43 | 44 | #include <libxml/tree.h> |
44 | 45 |
|
45 | | -#define IMF_UUID_FORMAT "urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" |
| 46 | +#define FF_UUID_FORMAT \ |
| 47 | + "urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \ |
| 48 | + "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" |
46 | 49 |
|
47 | 50 | /** |
48 | 51 | * UUID as defined in IETF RFC 422 |
49 | 52 | */ |
50 | | -typedef uint8_t UUID[16]; |
| 53 | +typedef uint8_t FFUUID[16]; |
51 | 54 |
|
52 | 55 | /** |
53 | 56 | * IMF Composition Playlist Base Resource |
54 | 57 | */ |
55 | | -typedef struct IMFBaseResource { |
56 | | - AVRational edit_rate; /**< BaseResourceType/EditRate */ |
57 | | - unsigned long entry_point; /**< BaseResourceType/EntryPoint */ |
58 | | - unsigned long duration; /**< BaseResourceType/Duration */ |
59 | | - unsigned long repeat_count; /**< BaseResourceType/RepeatCount */ |
60 | | -} IMFBaseResource; |
| 58 | +typedef struct FFIMFBaseResource { |
| 59 | + AVRational edit_rate; /**< BaseResourceType/EditRate */ |
| 60 | + uint32_t entry_point; /**< BaseResourceType/EntryPoint */ |
| 61 | + uint32_t duration; /**< BaseResourceType/Duration */ |
| 62 | + uint32_t repeat_count; /**< BaseResourceType/RepeatCount */ |
| 63 | +} FFIMFBaseResource; |
61 | 64 |
|
62 | 65 | /** |
63 | 66 | * IMF Composition Playlist Track File Resource |
64 | 67 | */ |
65 | | -typedef struct IMFTrackFileResource { |
66 | | - IMFBaseResource base; |
67 | | - UUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */ |
68 | | -} IMFTrackFileResource; |
| 68 | +typedef struct FFIMFTrackFileResource { |
| 69 | + FFIMFBaseResource base; |
| 70 | + FFUUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */ |
| 71 | +} FFIMFTrackFileResource; |
69 | 72 |
|
70 | 73 | /** |
71 | 74 | * IMF Marker |
72 | 75 | */ |
73 | | -typedef struct IMFMarker { |
| 76 | +typedef struct FFIMFMarker { |
74 | 77 | xmlChar *label_utf8; /**< Marker/Label */ |
75 | 78 | xmlChar *scope_utf8; /**< Marker/Label/\@scope */ |
76 | | - unsigned long offset; /**< Marker/Offset */ |
77 | | -} IMFMarker; |
| 79 | + uint32_t offset; /**< Marker/Offset */ |
| 80 | +} FFIMFMarker; |
78 | 81 |
|
79 | 82 | /** |
80 | 83 | * IMF Composition Playlist Marker Resource |
81 | 84 | */ |
82 | | -typedef struct IMFMarkerResource { |
83 | | - IMFBaseResource base; |
84 | | - unsigned long marker_count; /**< Number of Marker elements */ |
85 | | - IMFMarker *markers; /**< Marker elements */ |
86 | | -} IMFMarkerResource; |
| 85 | +typedef struct FFIMFMarkerResource { |
| 86 | + FFIMFBaseResource base; |
| 87 | + uint32_t marker_count; /**< Number of Marker elements */ |
| 88 | + FFIMFMarker *markers; /**< Marker elements */ |
| 89 | +} FFIMFMarkerResource; |
87 | 90 |
|
88 | 91 | /** |
89 | 92 | * IMF Composition Playlist Virtual Track |
90 | 93 | */ |
91 | | -typedef struct IMFBaseVirtualTrack { |
92 | | - UUID id_uuid; /**< TrackId associated with the Virtual Track */ |
93 | | -} IMFBaseVirtualTrack; |
| 94 | +typedef struct FFIMFBaseVirtualTrack { |
| 95 | + FFUUID id_uuid; /**< TrackId associated with the Virtual Track */ |
| 96 | +} FFIMFBaseVirtualTrack; |
94 | 97 |
|
95 | 98 | /** |
96 | 99 | * IMF Composition Playlist Virtual Track that consists of Track File Resources |
97 | 100 | */ |
98 | | -typedef struct IMFTrackFileVirtualTrack { |
99 | | - IMFBaseVirtualTrack base; |
100 | | - unsigned long resource_count; /**< Number of Resource elements present in the Virtual Track */ |
101 | | - IMFTrackFileResource *resources; /**< Resource elements of the Virtual Track */ |
102 | | -} IMFTrackFileVirtualTrack; |
| 101 | +typedef struct FFIMFTrackFileVirtualTrack { |
| 102 | + FFIMFBaseVirtualTrack base; |
| 103 | + uint32_t resource_count; /**< Number of Resource elements present in the Virtual Track */ |
| 104 | + FFIMFTrackFileResource *resources; /**< Resource elements of the Virtual Track */ |
| 105 | + uint32_t resources_alloc_sz; /**< Size of the resources buffer */ |
| 106 | +} FFIMFTrackFileVirtualTrack; |
103 | 107 |
|
104 | 108 | /** |
105 | 109 | * IMF Composition Playlist Virtual Track that consists of Marker Resources |
106 | 110 | */ |
107 | | -typedef struct IMFMarkerVirtualTrack { |
108 | | - IMFBaseVirtualTrack base; |
109 | | - unsigned long resource_count; /**< Number of Resource elements present in the Virtual Track */ |
110 | | - IMFMarkerResource *resources; /**< Resource elements of the Virtual Track */ |
111 | | -} IMFMarkerVirtualTrack; |
| 111 | +typedef struct FFIMFMarkerVirtualTrack { |
| 112 | + FFIMFBaseVirtualTrack base; |
| 113 | + uint32_t resource_count; /**< Number of Resource elements present in the Virtual Track */ |
| 114 | + FFIMFMarkerResource *resources; /**< Resource elements of the Virtual Track */ |
| 115 | +} FFIMFMarkerVirtualTrack; |
112 | 116 |
|
113 | 117 | /** |
114 | 118 | * IMF Composition Playlist |
115 | 119 | */ |
116 | | -typedef struct IMFCPL { |
117 | | - UUID id_uuid; /**< CompositionPlaylist/Id element */ |
118 | | - xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element */ |
119 | | - AVRational edit_rate; /**< CompositionPlaylist/EditRate element */ |
120 | | - IMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track */ |
121 | | - IMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual Track */ |
122 | | - unsigned long main_audio_track_count; /**< Number of Main Audio Virtual Tracks */ |
123 | | - IMFTrackFileVirtualTrack *main_audio_tracks; /**< Main Audio Virtual Tracks */ |
124 | | -} IMFCPL; |
| 120 | +typedef struct FFIMFCPL { |
| 121 | + FFUUID id_uuid; /**< CompositionPlaylist/Id element */ |
| 122 | + xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element */ |
| 123 | + AVRational edit_rate; /**< CompositionPlaylist/EditRate element */ |
| 124 | + FFIMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track */ |
| 125 | + FFIMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual Track */ |
| 126 | + uint32_t main_audio_track_count; /**< Number of Main Audio Virtual Tracks */ |
| 127 | + FFIMFTrackFileVirtualTrack *main_audio_tracks; /**< Main Audio Virtual Tracks */ |
| 128 | +} FFIMFCPL; |
125 | 129 |
|
126 | 130 | /** |
127 | | - * Parse an IMF CompositionPlaylist element into the IMFCPL data structure. |
| 131 | + * Parse an IMF CompositionPlaylist element into the FFIMFCPL data structure. |
128 | 132 | * @param[in] doc An XML document from which the CPL is read. |
129 | | - * @param[out] cpl Pointer to a memory area (allocated by the client), where the function writes a pointer to the newly constructed |
130 | | - * IMFCPL structure (or NULL if the CPL could not be parsed). The client is responsible for freeing the IMFCPL structure using |
131 | | - * imf_cpl_free(). |
| 133 | + * @param[out] cpl Pointer to a memory area (allocated by the client), where the |
| 134 | + * function writes a pointer to the newly constructed FFIMFCPL structure (or |
| 135 | + * NULL if the CPL could not be parsed). The client is responsible for freeing |
| 136 | + * the FFIMFCPL structure using ff_imf_cpl_free(). |
132 | 137 | * @return A non-zero value in case of an error. |
133 | 138 | */ |
134 | | -int parse_imf_cpl_from_xml_dom(xmlDocPtr doc, IMFCPL **cpl); |
| 139 | +int ff_parse_imf_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl); |
135 | 140 |
|
136 | 141 | /** |
137 | | - * Parse an IMF Composition Playlist document into the IMFCPL data structure. |
| 142 | + * Parse an IMF Composition Playlist document into the FFIMFCPL data structure. |
138 | 143 | * @param[in] in The context from which the CPL is read. |
139 | | - * @param[out] cpl Pointer to a memory area (allocated by the client), where the function writes a pointer to the newly constructed |
140 | | - * IMFCPL structure (or NULL if the CPL could not be parsed). The client is responsible for freeing the IMFCPL structure using |
141 | | - * imf_cpl_free(). |
| 144 | + * @param[out] cpl Pointer to a memory area (allocated by the client), where the |
| 145 | + * function writes a pointer to the newly constructed FFIMFCPL structure (or |
| 146 | + * NULL if the CPL could not be parsed). The client is responsible for freeing |
| 147 | + * the FFIMFCPL structure using ff_imf_cpl_free(). |
142 | 148 | * @return A non-zero value in case of an error. |
143 | 149 | */ |
144 | | -int parse_imf_cpl(AVIOContext *in, IMFCPL **cpl); |
| 150 | +int ff_parse_imf_cpl(AVIOContext *in, FFIMFCPL **cpl); |
145 | 151 |
|
146 | 152 | /** |
147 | | - * Allocates and initializes an IMFCPL data structure. |
148 | | - * @return A pointer to the newly constructed IMFCPL structure (or NULL if the structure could not be constructed). The client is |
149 | | - * responsible for freeing the IMFCPL structure using imf_cpl_free(). |
| 153 | + * Allocates and initializes an FFIMFCPL data structure. |
| 154 | + * @return A pointer to the newly constructed FFIMFCPL structure (or NULL if the |
| 155 | + * structure could not be constructed). The client is responsible for freeing |
| 156 | + * the FFIMFCPL structure using ff_imf_cpl_free(). |
150 | 157 | */ |
151 | | -IMFCPL *imf_cpl_alloc(void); |
| 158 | +FFIMFCPL *ff_imf_cpl_alloc(void); |
152 | 159 |
|
153 | 160 | /** |
154 | | - * Deletes an IMFCPL data structure previously instantiated with imf_cpl_alloc(). |
155 | | - * @param[in] cpl The IMFCPL structure to delete. |
| 161 | + * Deletes an FFIMFCPL data structure previously instantiated with ff_imf_cpl_alloc(). |
| 162 | + * @param[in] cpl The FFIMFCPL structure to delete. |
156 | 163 | */ |
157 | | -void imf_cpl_free(IMFCPL *cpl); |
| 164 | +void ff_imf_cpl_free(FFIMFCPL *cpl); |
158 | 165 |
|
159 | 166 | /** |
160 | | - * Reads an unsigned long from an XML element |
| 167 | + * Reads an unsigned 32-bit integer from an XML element |
161 | 168 | * @return 0 on success, < 0 AVERROR code on error. |
162 | 169 | */ |
163 | | -int imf_xml_read_ulong(xmlNodePtr element, unsigned long *number); |
| 170 | +int ff_xml_read_uint32(xmlNodePtr element, uint32_t *number); |
164 | 171 |
|
165 | 172 | /** |
166 | 173 | * Reads an AVRational from an XML element |
167 | 174 | * @return 0 on success, < 0 AVERROR code on error. |
168 | 175 | */ |
169 | | -int imf_xml_read_rational(xmlNodePtr element, AVRational *rational); |
| 176 | +int ff_xml_read_rational(xmlNodePtr element, AVRational *rational); |
170 | 177 |
|
171 | 178 | /** |
172 | 179 | * Reads a UUID from an XML element |
173 | 180 | * @return 0 on success, < 0 AVERROR code on error. |
174 | 181 | */ |
175 | | -int imf_xml_read_UUID(xmlNodePtr element, uint8_t uuid[16]); |
| 182 | +int ff_xml_read_uuid(xmlNodePtr element, uint8_t uuid[16]); |
176 | 183 |
|
177 | 184 | /** |
178 | 185 | * Returns the first child element with the specified local name |
179 | 186 | * @return A pointer to the child element, or NULL if no such child element exists. |
180 | 187 | */ |
181 | | -xmlNodePtr imf_xml_get_child_element_by_name(xmlNodePtr parent, const char *name_utf8); |
| 188 | +xmlNodePtr ff_xml_get_child_element_by_name(xmlNodePtr parent, const char *name_utf8); |
182 | 189 |
|
183 | 190 | #endif |
0 commit comments