| 623 | } |
| 624 | |
| 625 | static int imf_read_header(AVFormatContext *s) |
| 626 | { |
| 627 | IMFContext *c = s->priv_data; |
| 628 | char *asset_map_path; |
| 629 | char *tmp_str; |
| 630 | AVDictionaryEntry* tcr; |
| 631 | char tc_buf[AV_TIMECODE_STR_SIZE]; |
| 632 | int ret = 0; |
| 633 | |
| 634 | c->interrupt_callback = &s->interrupt_callback; |
| 635 | tmp_str = av_strdup(s->url); |
| 636 | if (!tmp_str) |
| 637 | return AVERROR(ENOMEM); |
| 638 | c->base_url = av_strdup(av_dirname(tmp_str)); |
| 639 | av_freep(&tmp_str); |
| 640 | if (!c->base_url) |
| 641 | return AVERROR(ENOMEM); |
| 642 | |
| 643 | if ((ret = ffio_copy_url_options(s->pb, &c->avio_opts)) < 0) |
| 644 | return ret; |
| 645 | |
| 646 | av_log(s, AV_LOG_DEBUG, "start parsing IMF CPL: %s\n", s->url); |
| 647 | |
| 648 | if ((ret = ff_imf_parse_cpl(s, s->pb, &c->cpl)) < 0) |
| 649 | return ret; |
| 650 | |
| 651 | tcr = av_dict_get(s->metadata, "timecode", NULL, 0); |
| 652 | if (!tcr && c->cpl->tc) { |
| 653 | ret = av_dict_set(&s->metadata, "timecode", |
| 654 | av_timecode_make_string(c->cpl->tc, tc_buf, 0), 0); |
| 655 | if (ret) |
| 656 | return ret; |
| 657 | av_log(s, AV_LOG_INFO, "Setting timecode to IMF CPL timecode %s\n", tc_buf); |
| 658 | } |
| 659 | |
| 660 | av_log(s, |
| 661 | AV_LOG_DEBUG, |
| 662 | "parsed IMF CPL: " AV_PRI_URN_UUID "\n", |
| 663 | AV_UUID_ARG(c->cpl->id_uuid)); |
| 664 | |
| 665 | if (!c->asset_map_paths) { |
| 666 | c->asset_map_paths = av_append_path_component(c->base_url, "ASSETMAP.xml"); |
| 667 | if (!c->asset_map_paths) { |
| 668 | ret = AVERROR(ENOMEM); |
| 669 | return ret; |
| 670 | } |
| 671 | av_log(s, AV_LOG_DEBUG, "No asset maps provided, using the default ASSETMAP.xml\n"); |
| 672 | } |
| 673 | |
| 674 | /* Parse each asset map XML file */ |
| 675 | imf_asset_locator_map_init(&c->asset_locator_map); |
| 676 | asset_map_path = av_strtok(c->asset_map_paths, ",", &tmp_str); |
| 677 | while (asset_map_path != NULL) { |
| 678 | av_log(s, AV_LOG_DEBUG, "start parsing IMF Asset Map: %s\n", asset_map_path); |
| 679 | |
| 680 | if ((ret = parse_assetmap(s, asset_map_path))) |
| 681 | return ret; |
| 682 |
nothing calls this directly
no test coverage detected