Skip to content

Commit 477f975

Browse files
authored
Use CPL as input file and support multiple ASSETMAP files (#16)
Author: @valnoel
2 parents d5d3c66 + 5ce835c commit 477f975

File tree

4 files changed

+371
-71
lines changed

4 files changed

+371
-71
lines changed

libavformat/imf.h

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct IMFBaseResource {
6060
*/
6161
typedef struct IMFTrackFileResource {
6262
IMFBaseResource base;
63-
unsigned char track_file_uuid[16]; /**< TrackFileResourceType/TrackFileId */
63+
UUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */
6464
} IMFTrackFileResource;
6565

6666
/**
@@ -85,7 +85,7 @@ typedef struct IMFMarkerResource {
8585
* IMF Composition Playlist Virtual Track
8686
*/
8787
typedef struct IMFBaseVirtualTrack {
88-
unsigned char id_uuid[16]; /**< TrackId associated with the Virtual Track */
88+
UUID id_uuid; /**< TrackId associated with the Virtual Track */
8989
} IMFBaseVirtualTrack;
9090

9191
/**
@@ -110,7 +110,7 @@ typedef struct IMFMarkerVirtualTrack {
110110
* IMF Composition Playlist
111111
*/
112112
typedef struct IMFCPL {
113-
uint8_t id_uuid[16]; /**< CompositionPlaylist/Id element */
113+
UUID id_uuid; /**< CompositionPlaylist/Id element */
114114
xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element */
115115
AVRational edit_rate; /**< CompositionPlaylist/EditRate element */
116116
IMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track */
@@ -119,22 +119,6 @@ typedef struct IMFCPL {
119119
IMFTrackFileVirtualTrack *main_audio_tracks; /**< Main Audio Virtual Tracks */
120120
} IMFCPL;
121121

122-
/**
123-
* IMF Asset locator
124-
*/
125-
typedef struct IMFAssetLocator {
126-
UUID uuid;
127-
const char *absolute_uri;
128-
} IMFAssetLocator;
129-
130-
/**
131-
* IMF Asset Map
132-
*/
133-
typedef struct IMFAssetMap {
134-
uint8_t asset_count;
135-
IMFAssetLocator **assets;
136-
} IMFAssetMap;
137-
138122
/**
139123
* Parse an IMF CompositionPlaylist element into the IMFCPL data structure.
140124
* @param[in] doc An XML document from which the CPL is read.
@@ -168,25 +152,4 @@ IMFCPL *imf_cpl_alloc(void);
168152
*/
169153
void imf_cpl_free(IMFCPL *cpl);
170154

171-
/**
172-
* Parse a ASSETMAP XML file to extract the UUID-URI mapping of assets.
173-
* @param s the current format context, if any (can be NULL).
174-
* @param doc the XML document to be parsed.
175-
* @param asset_map pointer on the IMFAssetMap pointer to fill.
176-
* @param base_url the url of the asset map XML file, if any (can be NULL).
177-
* @return a negative value in case of error, 0 otherwise.
178-
*/
179-
int parse_imf_asset_map_from_xml_dom(AVFormatContext *s, xmlDocPtr doc, IMFAssetMap **asset_map, const char *base_url);
180-
181-
/**
182-
* Allocate a IMFAssetMap pointer and return it.
183-
* @return the allocated IMFAssetMap pointer.
184-
*/
185-
IMFAssetMap *imf_asset_map_alloc(void);
186-
187-
/**
188-
* Free a IMFAssetMap pointer.
189-
*/
190-
void imf_asset_map_free(IMFAssetMap *asset_map);
191-
192155
#endif

libavformat/imf_internal.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@
4040

4141
#define UUID_FORMAT "urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
4242

43+
/**
44+
* IMF Asset locator
45+
*/
46+
typedef struct IMFAssetLocator {
47+
UUID uuid;
48+
const char *absolute_uri;
49+
} IMFAssetLocator;
50+
51+
/**
52+
* IMF Asset locator map
53+
* Results from the parsing of one or more ASSETMAP XML files
54+
*/
55+
typedef struct IMFAssetLocatorMap {
56+
uint8_t asset_count;
57+
IMFAssetLocator **assets;
58+
} IMFAssetLocatorMap;
59+
4360
int xml_read_ulong(xmlNodePtr element, unsigned long *number);
4461

4562
int xml_read_rational(xmlNodePtr element, AVRational *rational);
@@ -48,4 +65,25 @@ int xml_read_UUID(xmlNodePtr element, uint8_t uuid[16]);
4865

4966
xmlNodePtr xml_get_child_element_by_name(xmlNodePtr parent, const char *name_utf8);
5067

68+
/**
69+
* Parse a ASSETMAP XML file to extract the UUID-URI mapping of assets.
70+
* @param s the current format context, if any (can be NULL).
71+
* @param doc the XML document to be parsed.
72+
* @param asset_map pointer on the IMFAssetLocatorMap pointer to fill.
73+
* @param base_url the url of the asset map XML file, if any (can be NULL).
74+
* @return a negative value in case of error, 0 otherwise.
75+
*/
76+
int parse_imf_asset_map_from_xml_dom(AVFormatContext *s, xmlDocPtr doc, IMFAssetLocatorMap **asset_map, const char *base_url);
77+
78+
/**
79+
* Allocate a IMFAssetLocatorMap pointer and return it.
80+
* @return the allocated IMFAssetLocatorMap pointer.
81+
*/
82+
IMFAssetLocatorMap *imf_asset_locator_map_alloc(void);
83+
84+
/**
85+
* Free a IMFAssetLocatorMap pointer.
86+
*/
87+
void imf_asset_locator_map_free(IMFAssetLocatorMap *asset_map);
88+
5189
#endif

0 commit comments

Comments
 (0)