@@ -251,6 +251,7 @@ public static Map<String, List<ErrorLogger.ErrorObject>> analyzePackage(File roo
251
251
}
252
252
packingListErrorLogger .addAllErrors (packingList .getErrors ());
253
253
Map <UUID , PayloadRecord > trackFileIDToHeaderPartitionPayLoadMap = new HashMap <>();
254
+ int xmlFileCount = 0 ;
254
255
for (PackingList .Asset asset : packingList .getAssets ()) {
255
256
if (asset .getType ().equals (PackingList .Asset .APPLICATION_MXF_TYPE )) {
256
257
URI path = assetMap .getPath (asset .getUUID ());
@@ -302,11 +303,18 @@ public static Map<String, List<ErrorLogger.ErrorObject>> analyzePackage(File roo
302
303
finally {
303
304
errorMap .put (assetFile .getName (), trackFileErrorLogger .getErrors ());
304
305
}
306
+ } else if (asset .getType ().equals (PackingList .Asset .TEXT_XML_TYPE )) {
307
+ xmlFileCount ++;
305
308
}
306
309
}
307
310
308
- List <ApplicationComposition > applicationCompositionList = analyzeApplicationCompositions ( rootFile , assetMap , packingList , headerPartitionPayloadRecords , packingListErrorLogger , errorMap , trackFileIDToHeaderPartitionPayLoadMap );
311
+ // issue a warning if the PKL does not contain any assets of type text/xml to help troubleshoot non-compliant mime-types for CPL/OPL
312
+ if ( xmlFileCount == 0 ) {
313
+ packingListErrorLogger .addError (IMFErrorLogger .IMFErrors .ErrorCodes .IMF_PKL_ERROR ,
314
+ IMFErrorLogger .IMFErrors .ErrorLevels .WARNING , String .format ("Packing List does not contain any assets of type \" %s\" (i.e. PKL does not contain any CPL/OPL files)." , PackingList .Asset .TEXT_XML_TYPE ));
315
+ }
309
316
317
+ List <ApplicationComposition > applicationCompositionList = analyzeApplicationCompositions ( rootFile , assetMap , packingList , headerPartitionPayloadRecords , packingListErrorLogger , errorMap , trackFileIDToHeaderPartitionPayLoadMap );
310
318
analyzeOutputProfileLists ( rootFile , assetMap , packingList , applicationCompositionList , packingListErrorLogger , errorMap );
311
319
312
320
} catch (IMFException e ) {
@@ -366,14 +374,14 @@ public static List<OutputProfileList> analyzeOutputProfileLists(File rootFile,
366
374
for (PackingList .Asset asset : packingList .getAssets ()) {
367
375
if (asset .getType ().equals (PackingList .Asset .TEXT_XML_TYPE )) {
368
376
URI path = assetMap .getPath (asset .getUUID ());
369
- if ( path == null ) {
377
+ if ( path == null ) {
370
378
packingListErrorLogger .addError (IMFErrorLogger .IMFErrors .ErrorCodes .IMF_PKL_ERROR ,
371
379
IMFErrorLogger .IMFErrors .ErrorLevels .FATAL , String .format ("Failed to get path for Asset with ID = %s" , asset .getUUID ().toString ()));
372
380
continue ;
373
381
}
374
382
File assetFile = new File (rootFile , assetMap .getPath (asset .getUUID ()).toString ());
375
383
376
- if (!assetFile .exists ()) {
384
+ if (!assetFile .exists ()) {
377
385
packingListErrorLogger .addError (IMFErrorLogger .IMFErrors .ErrorCodes .IMF_PKL_ERROR ,
378
386
IMFErrorLogger .IMFErrors .ErrorLevels .FATAL , String .format ("Cannot find asset with path %s ID = %s" , assetFile .getAbsolutePath (), asset .getUUID ().toString ()));
379
387
continue ;
@@ -384,18 +392,19 @@ public static List<OutputProfileList> analyzeOutputProfileLists(File rootFile,
384
392
IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl ();
385
393
try {
386
394
OutputProfileList outputProfileListType = OutputProfileList .getOutputProfileListType (resourceByteRangeProvider , imfErrorLogger );
387
- if (outputProfileListType == null ) {
395
+ if (outputProfileListType == null ) {
388
396
continue ;
389
397
}
390
398
391
- if (!outputProfileListType .getId ().equals (asset .getUUID ())) {
399
+ if (!outputProfileListType .getId ().equals (asset .getUUID ())) {
392
400
// ST 2067-2:2016 7.3.1: The value of the Id element shall be extracted from the asset as specified in Table 19 for the OPL asset
393
401
imfErrorLogger .addError (IMFErrorLogger .IMFErrors .ErrorCodes .IMF_CPL_ERROR ,
394
402
IMFErrorLogger .IMFErrors .ErrorLevels .NON_FATAL , String .format ("UUID %s in the OPL is not same as UUID %s of the OPL in the AssetMap" , outputProfileListType .getId ().toString (), asset .getUUID ().toString ()));
395
- } outputProfileListTypeList .add (outputProfileListType );
403
+ }
404
+ outputProfileListTypeList .add (outputProfileListType );
396
405
397
406
Optional <ApplicationComposition > optional = applicationCompositionList .stream ().filter (e -> e .getUUID ().equals (outputProfileListType .getCompositionPlaylistId ())).findAny ();
398
- if (!optional .isPresent ()) {
407
+ if (!optional .isPresent ()) {
399
408
imfErrorLogger .addError (IMFErrorLogger .IMFErrors .ErrorCodes .IMF_OPL_ERROR ,
400
409
IMFErrorLogger .IMFErrors .ErrorLevels .WARNING , String .format ("Failed to get application composition with ID = %s for OutputProfileList with ID %s" ,
401
410
outputProfileListType .getCompositionPlaylistId ().toString (), outputProfileListType .getId ().toString ()));
@@ -428,14 +437,14 @@ public static List<ApplicationComposition> analyzeApplicationCompositions( File
428
437
for (PackingList .Asset asset : packingList .getAssets ()) {
429
438
if (asset .getType ().equals (PackingList .Asset .TEXT_XML_TYPE )) {
430
439
URI path = assetMap .getPath (asset .getUUID ());
431
- if ( path == null ) {
440
+ if ( path == null ) {
432
441
packingListErrorLogger .addError (IMFErrorLogger .IMFErrors .ErrorCodes .IMF_PKL_ERROR ,
433
442
IMFErrorLogger .IMFErrors .ErrorLevels .FATAL , String .format ("Failed to get path for Asset with ID = %s" , asset .getUUID ().toString ()));
434
443
continue ;
435
444
}
436
445
File assetFile = new File (rootFile , assetMap .getPath (asset .getUUID ()).toString ());
437
446
438
- if (!assetFile .exists ()) {
447
+ if (!assetFile .exists ()) {
439
448
packingListErrorLogger .addError (IMFErrorLogger .IMFErrors .ErrorCodes .IMF_PKL_ERROR ,
440
449
IMFErrorLogger .IMFErrors .ErrorLevels .FATAL , String .format ("Cannot find asset with path %s ID = %s" , assetFile .getAbsolutePath (), asset .getUUID ().toString ()));
441
450
continue ;
@@ -450,10 +459,10 @@ public static List<ApplicationComposition> analyzeApplicationCompositions( File
450
459
451
460
try {
452
461
ApplicationComposition applicationComposition = ApplicationCompositionFactory .getApplicationComposition (resourceByteRangeProvider , compositionErrorLogger );
453
- if (applicationComposition == null ) {
462
+ if (applicationComposition == null ) {
454
463
continue ;
455
464
}
456
- if (!applicationComposition .getUUID ().equals (asset .getUUID ())) {
465
+ if (!applicationComposition .getUUID ().equals (asset .getUUID ())) {
457
466
// ST 2067-2:2016 7.3.1: The value of the Id element shall be extracted from the asset as specified in Table 19 for the CPL asset
458
467
compositionErrorLogger .addError (IMFErrorLogger .IMFErrors .ErrorCodes .IMF_CPL_ERROR ,
459
468
IMFErrorLogger .IMFErrors .ErrorLevels .NON_FATAL , String .format ("UUID %s in the CPL is not same as UUID %s of the CPL in the AssetMap" , applicationComposition .getUUID ().toString (), asset .getUUID ().toString ()));
@@ -490,7 +499,7 @@ public static List<ApplicationComposition> analyzeApplicationCompositions( File
490
499
.stream ()
491
500
.map (IMFEssenceComponentVirtualTrack ::getTrackResourceIds )
492
501
.flatMap (Set ::stream )
493
- .map ( e -> trackFileIDToHeaderPartitionPayLoadMap .get (e ))
502
+ .map (e -> trackFileIDToHeaderPartitionPayLoadMap .get (e ))
494
503
.collect (Collectors .toList ());
495
504
compositionConformanceErrorLogger .addAllErrors (IMPValidator .areAllVirtualTracksInCPLConformed (cplPayloadRecord , cplHeaderPartitionPayloads ));
496
505
}
0 commit comments