MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / parse_assetmap

Function parse_assetmap

libavformat/imfdec.c:296–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296static int parse_assetmap(AVFormatContext *s, const char *url)
297{
298 IMFContext *c = s->priv_data;
299 AVIOContext *in = NULL;
300 struct AVBPrint buf;
301 AVDictionary *opts = NULL;
302 xmlDoc *doc = NULL;
303 const char *base_url;
304 char *tmp_str = NULL;
305 int ret;
306
307 av_log(s, AV_LOG_DEBUG, "Asset Map URL: %s\n", url);
308
309 av_dict_copy(&opts, c->avio_opts, 0);
310 ret = s->io_open(s, &in, url, AVIO_FLAG_READ, &opts);
311 av_dict_free(&opts);
312 if (ret < 0)
313 return ret;
314
315 av_bprint_init(&buf, 0, INT_MAX); // xmlReadMemory uses integer length
316
317 ret = avio_read_to_bprint(in, &buf, SIZE_MAX);
318 if (ret < 0 || !avio_feof(in)) {
319 av_log(s, AV_LOG_ERROR, "Unable to read to asset map '%s'\n", url);
320 if (ret == 0)
321 ret = AVERROR_INVALIDDATA;
322 goto clean_up;
323 }
324
325 LIBXML_TEST_VERSION
326
327 tmp_str = av_strdup(url);
328 if (!tmp_str) {
329 ret = AVERROR(ENOMEM);
330 goto clean_up;
331 }
332 base_url = av_dirname(tmp_str);
333
334 doc = xmlReadMemory(buf.str, buf.len, url, NULL, 0);
335
336 ret = parse_imf_asset_map_from_xml_dom(s, doc, &c->asset_locator_map, base_url);
337 if (!ret)
338 av_log(s, AV_LOG_DEBUG, "Found %d assets from %s\n",
339 c->asset_locator_map.asset_count, url);
340
341 xmlFreeDoc(doc);
342
343clean_up:
344 if (tmp_str)
345 av_freep(&tmp_str);
346 ff_format_io_close(s, &in);
347 av_bprint_finalize(&buf, NULL);
348 return ret;
349}
350
351static IMFAssetLocator *find_asset_map_locator(IMFAssetLocatorMap *asset_map, AVUUID uuid)
352{

Callers 1

imf_read_headerFunction · 0.85

Calls 12

av_logFunction · 0.85
av_dict_copyFunction · 0.85
av_dict_freeFunction · 0.85
av_bprint_initFunction · 0.85
avio_read_to_bprintFunction · 0.85
avio_feofFunction · 0.85
av_strdupFunction · 0.85
av_dirnameFunction · 0.85
av_freepFunction · 0.85
ff_format_io_closeFunction · 0.85
av_bprint_finalizeFunction · 0.85

Tested by

no test coverage detected