" <Id>urn:uuid:8e097bb0-cff7-4969-a692-bad47bfb528f</Id>"
" </EssenceDescriptor>"
"</EssenceDescriptorList>"
+ "<CompositionTimecode>"
+ "<TimecodeDropFrame>false</TimecodeDropFrame>"
+ "<TimecodeRate>24</TimecodeRate>"
+ "<TimecodeStartAddress>02:10:01.23</TimecodeStartAddress>"
+ "</CompositionTimecode>"
"<EditRate>24000 1001</EditRate>"
"<SegmentList>"
"<Segment>"
"</SegmentList>"
"</CompositionPlaylist>";
-const char *cpl_bad_doc = "<Composition></Composition>";
+ const char *cpl_bad_resource_doc =
+ "<CompositionPlaylist xmlns=\"http://www.smpte-ra.org/schemas/2067-3/2016\""
+ " xmlns:cc=\"http://www.smpte-ra.org/schemas/2067-2/2016\""
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ "<Id>urn:uuid:8713c020-2489-45f5-a9f7-87be539e20b5</Id>"
+ "<IssueDate>2021-07-13T17:06:22Z</IssueDate>"
+ "<Creator language=\"en\">FFMPEG</Creator>"
+ "<ContentTitle>FFMPEG sample content</ContentTitle>"
+ "<EssenceDescriptorList>"
+ " <EssenceDescriptor>"
+ " <Id>urn:uuid:8e097bb0-cff7-4969-a692-bad47bfb528f</Id>"
+ " </EssenceDescriptor>"
+ "</EssenceDescriptorList>"
+ "<CompositionTimecode>"
+ "<TimecodeDropFrame>false</TimecodeDropFrame>"
+ "<TimecodeRate>24</TimecodeRate>"
+ "<TimecodeStartAddress>02:10:01.23</TimecodeStartAddress>"
+ "</CompositionTimecode>"
+ "<EditRate>24000 1001</EditRate>"
+ "<SegmentList>"
+ "<Segment>"
+ "<Id>urn:uuid:81fed4e5-9722-400a-b9d1-7f2bd21df4b6</Id>"
+ "<SequenceList>"
+ "<cc:MainImageSequence>"
+ "<Id>urn:uuid:6ae100b0-92d1-41be-9321-85e0933dfc42</Id>"
+ "<TrackId>urn:uuid:e8ef9653-565c-479c-8039-82d4547973c5</TrackId>"
+ "<ResourceList>"
+ "<Resource xsi:type=\"TrackFileResourceType\">"
+ "<Id>urn:uuid:7d418acb-07a3-4e57-984c-b8ea2f7de4ec</Id>"
+ "<IntrinsicDuration>24</IntrinsicDuration>"
+ "<SourceEncoding>urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751</SourceEncoding>"
+ "</Resource>"
+ "</ResourceList>"
+ "</cc:MainImageSequence>"
+ "</SequenceList>"
+ "</Segment>"
+ "</SegmentList>"
+ "</CompositionPlaylist>";
+
+const char *cpl_bad_empty_doc = "<Composition></Composition>";
const char *asset_map_doc =
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
{
xmlDocPtr doc;
FFIMFCPL *cpl;
+ char tc_buf[AV_TIMECODE_STR_SIZE];
int ret;
doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0);
return 1;
}
- ret = ff_imf_parse_cpl_from_xml_dom(doc, &cpl);
+ ret = ff_imf_parse_cpl_from_xml_dom(NULL, doc, &cpl);
xmlFreeDoc(doc);
if (ret) {
printf("CPL parsing failed.\n");
printf("%s\n", cpl->content_title_utf8);
printf(AV_PRI_URN_UUID "\n", AV_UUID_ARG(cpl->id_uuid));
printf("%i %i\n", cpl->edit_rate.num, cpl->edit_rate.den);
+ printf("%s\n", av_timecode_make_string(cpl->tc, tc_buf, 0));
printf("Marker resource count: %" PRIu32 "\n", cpl->main_markers_track->resource_count);
for (uint32_t i = 0; i < cpl->main_markers_track->resource_count; i++) {
return 0;
}
-static int test_bad_cpl_parsing(void)
-{
+static int test_cpl_from_doc(FFIMFCPL **cpl, const char* cpl_doc, int should_pass) {
xmlDocPtr doc;
- FFIMFCPL *cpl;
int ret;
- doc = xmlReadMemory(cpl_bad_doc, strlen(cpl_bad_doc), NULL, NULL, 0);
+ doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0);
if (doc == NULL) {
printf("XML parsing failed.\n");
- return 1;
+ return should_pass;
}
- ret = ff_imf_parse_cpl_from_xml_dom(doc, &cpl);
+ ret = ff_imf_parse_cpl_from_xml_dom(NULL, doc, cpl);
xmlFreeDoc(doc);
if (ret) {
printf("CPL parsing failed.\n");
- return ret;
+ if (*cpl) {
+ printf("Improper cleanup after failed CPL parsing\n");
+ return 1;
+ }
+ return should_pass;
}
- return 0;
+ ff_imf_cpl_free(*cpl);
+ *cpl = NULL;
+
+ return !should_pass;
}
static int check_asset_locator_attributes(IMFAssetLocator *asset, IMFAssetLocator *expected_asset)
int main(int argc, char *argv[])
{
+ FFIMFCPL *cpl;
int ret = 0;
if (test_cpl_parsing() != 0)
ret = 1;
printf("#### The following should fail ####\n");
- if (test_bad_cpl_parsing() == 0)
+ if (test_cpl_from_doc(&cpl, cpl_bad_empty_doc, 0) != 0)
ret = 1;
printf("#### End failing test ####\n");
+ printf("#### The following should emit errors ####\n");
+ if (test_cpl_from_doc(&cpl, cpl_bad_resource_doc, 1) != 0)
+ ret = 1;
+ printf("#### End emission of errors ####\n");
+
return ret;
}