Skip to content

Commit

Permalink
Merge branch 'Netflix:master' into wr-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
IMFTool authored Oct 28, 2023
2 parents 900c972 + d3005a2 commit 2a1ee5e
Show file tree
Hide file tree
Showing 25 changed files with 8,503 additions and 613 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Photon

Photon is a Java implementation of the Interoperable Master Format (IMF) standard. IMF is a SMPTE standard whose core constraints are defined in the specification st2067-2:2013. Photon offers tools for parsing, interpreting and validating constituent files that make an Interoperable Master Package (IMP). These include AssetMap (st429-9:2014), PackingList (st429-8:2007), Composition Playlist (st2067-3:2013), and the essence containing IMF track file (st2067-5:2013) which follows the Material eXchange Format (MXF) format (st377-1:2011). Specifically, Photon parses and completely reads an MXF file containing a single audio or video essence as defined by the IMF Essence Component specification (st2067-5:2013) and serializes the metadata into the IMF Composition Playlist structure.
Photon is a Java implementation of the [Interoperable Master Format (IMF)](https://www.imfug.com/explainer/imf-explainer-en/#what-is-imf) standard. IMF core constraints are defined by [SMPTE](https://www.smpte.org/who-we-are) specification [st2067-2:2013](https://ieeexplore.ieee.org/document/7291584) (paywall). Photon offers tools for parsing, interpreting and validating constituent files that make an Interoperable Master Package (IMP). These include AssetMap (st429-9:2014), PackingList (st429-8:2007), Composition Playlist (st2067-3:2013), and the essence containing IMF track file (st2067-5:2013) which follows the Material eXchange Format (MXF) format (st377-1:2011). Specifically, Photon parses and completely reads an MXF file containing a single audio or video essence as defined by the IMF Essence Component specification (st2067-5:2013) and serializes the metadata into the IMF Composition Playlist structure.

The goal of the Photon is to provide a simple standardized interface to completely validate an IMP.

Expand Down
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ dependencies {
jaxb "org.glassfish.jaxb:jaxb-xjc:2.2.11"

compileOnly "com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}"
implementation "org.apache.logging.log4j:log4j-core:2.17.2"
implementation "org.apache.logging.log4j:log4j-api:2.17.2"
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.2'
compileOnly "org.slf4j:slf4j-api:latest.release"

/**
* Following includes the RegXMLLib dependency from Maven Central.
Expand All @@ -106,6 +104,7 @@ dependencies {
/*compile "com.sandflow:regxmllib:${revRegXMLSNAPSHOT}"*/
testImplementation "org.mockito:mockito-core:3.3+"
testImplementation "org.testng:testng:7.5+"
testImplementation "org.slf4j:slf4j-simple:latest.release"
}

test {
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/netflix/imflibrary/IMPDelivery.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import com.netflix.imflibrary.st0429_9.AssetMap;
import com.netflix.imflibrary.st0429_9.BasicMapProfileV2FileSet;
import com.netflix.imflibrary.st0429_9.BasicMapProfileV2MappedFileSet;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import javax.annotation.concurrent.Immutable;
Expand All @@ -33,7 +33,11 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

/**
* This class represents the concept of an IMF delivery as defined in Section 8 of st2067-2:2015. Informally, an IMF delivery
Expand All @@ -42,7 +46,7 @@
@Immutable
public final class IMPDelivery
{
private static final Logger logger = LogManager.getLogger(IMPDelivery.class);
private static final Logger logger = LoggerFactory.getLogger(IMPDelivery.class);

private final AssetMap assetMap;
private final List<InteroperableMasterPackage> interoperableMasterPackages = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import com.netflix.imflibrary.utils.FileByteRangeProvider;
import com.netflix.imflibrary.utils.ResourceByteRangeProvider;
import com.netflix.imflibrary.utils.Utilities;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import javax.annotation.Nullable;
Expand All @@ -55,7 +55,7 @@
*/
public class IMPValidator {

private static final Logger logger = LogManager.getLogger(IMPValidator.class);
private static final Logger logger = LoggerFactory.getLogger(IMPValidator.class);

/**
* A stateless method that determines if the Asset type of the payload is an IMF AssetMap, Packinglist or Composition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@

import com.netflix.imflibrary.IMFErrorLogger;
import com.netflix.imflibrary.IMFErrorLoggerImpl;
import com.netflix.imflibrary.KLVPacket;
import com.netflix.imflibrary.exceptions.IMFException;
import com.netflix.imflibrary.exceptions.MXFException;
import com.netflix.imflibrary.st0377.HeaderPartition;
import com.netflix.imflibrary.st0377.header.InterchangeObject;
import com.netflix.imflibrary.utils.ErrorLogger;
import com.netflix.imflibrary.utils.FileByteRangeProvider;
import com.netflix.imflibrary.utils.RegXMLLibHelper;
import com.netflix.imflibrary.utils.ResourceByteRangeProvider;
import com.netflix.imflibrary.writerTools.CompositionPlaylistBuilder_2013;
import com.netflix.imflibrary.writerTools.IMFCPLObjectFieldsFactory;
import com.netflix.imflibrary.writerTools.utils.IMFUUIDGenerator;
import com.netflix.imflibrary.writerTools.utils.IMFUtils;
import com.sandflow.smpte.klv.Triplet;
import com.netflix.imflibrary.KLVPacket;
import com.netflix.imflibrary.exceptions.IMFException;
import com.netflix.imflibrary.exceptions.MXFException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smpte_ra.schemas._2067_2._2013.ObjectFactory;
import org.smpte_ra.schemas._2067_3._2013.TrackFileResourceType;
import org.smpte_ra.schemas._2067_3._2013.BaseResourceType;
import org.smpte_ra.schemas._2067_3._2013.CompositionTimecodeType;
import org.smpte_ra.schemas._2067_3._2013.ContentKindType;
Expand All @@ -40,19 +46,12 @@
import org.smpte_ra.schemas._2067_3._2013.LocaleType;
import org.smpte_ra.schemas._2067_3._2013.SegmentType;
import org.smpte_ra.schemas._2067_3._2013.SequenceType;
import org.smpte_ra.schemas._2067_3._2013.TrackFileResourceType;
import org.smpte_ra.schemas._433._2008.dcmltypes.UserTextType;
import com.netflix.imflibrary.st0377.header.InterchangeObject;
import com.netflix.imflibrary.utils.FileByteRangeProvider;
import com.netflix.imflibrary.utils.ResourceByteRangeProvider;
import com.netflix.imflibrary.writerTools.IMFCPLObjectFieldsFactory;
import com.netflix.imflibrary.utils.RegXMLLibHelper;
import com.netflix.imflibrary.writerTools.utils.IMFUUIDGenerator;
import com.netflix.imflibrary.writerTools.utils.IMFUtils;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Node;


import javax.annotation.concurrent.Immutable;
import javax.xml.bind.JAXBElement;
import javax.xml.parsers.DocumentBuilder;
Expand All @@ -65,10 +64,8 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
Expand All @@ -80,7 +77,7 @@
@Immutable
public final class IMFTrackFileCPLBuilder {

private static final Logger logger = LogManager.getLogger(IMFTrackFileReader.class);
private static final Logger logger = LoggerFactory.getLogger(IMFTrackFileReader.class);
private final IMFTrackFileReader imfTrackFileReader;
private final RegXMLLibHelper regXMLLibHelper;
private final File workingDirectory;
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/com/netflix/imflibrary/app/IMFTrackFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

package com.netflix.imflibrary.app;

import com.netflix.imflibrary.*;
import com.netflix.imflibrary.IMFConstraints;
import com.netflix.imflibrary.IMFErrorLogger;
import com.netflix.imflibrary.IMFErrorLoggerImpl;
import com.netflix.imflibrary.KLVPacket;
import com.netflix.imflibrary.MXFOperationalPattern1A;
import com.netflix.imflibrary.exceptions.IMFException;
import com.netflix.imflibrary.exceptions.MXFException;
import com.netflix.imflibrary.st0377.HeaderPartition;
Expand All @@ -39,8 +43,8 @@
import com.netflix.imflibrary.utils.FileDataProvider;
import com.netflix.imflibrary.utils.ResourceByteRangeProvider;
import com.netflix.imflibrary.utils.Utilities;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;

import javax.annotation.Nonnull;
Expand All @@ -56,7 +60,12 @@
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;

/**
* A simple application to exercise the core logic of Photon for reading and validating IMF Track files.
Expand All @@ -73,7 +82,7 @@ final class IMFTrackFileReader
private volatile List<IndexTableSegment> indexTableSegments = null;


private static final Logger logger = LogManager.getLogger(IMFTrackFileReader.class);
private static final Logger logger = LoggerFactory.getLogger(IMFTrackFileReader.class);

/**
* Lazily creates a model instance corresponding to a st2067-5 compliant MXF file
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/netflix/imflibrary/app/IMPAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@
import com.netflix.imflibrary.utils.ErrorLogger;
import com.netflix.imflibrary.utils.FileByteRangeProvider;
import com.netflix.imflibrary.utils.ResourceByteRangeProvider;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -54,7 +52,7 @@
public class IMPAnalyzer {

private static final String CONFORMANCE_LOGGER_PREFIX = "Virtual Track Conformance";
private static final Logger logger = LogManager.getLogger(IMPAnalyzer.class);
private static final Logger logger = LoggerFactory.getLogger(IMPAnalyzer.class);

private static UUID getTrackFileId(PayloadRecord payloadRecord, IMFErrorLogger imfErrorLogger) throws
IOException {
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/com/netflix/imflibrary/app/IMPFixer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
import com.netflix.imflibrary.st2067_2.ApplicationCompositionFactory;
import com.netflix.imflibrary.st2067_2.CoreConstraints;
import com.netflix.imflibrary.st2067_2.IMFEssenceComponentVirtualTrack;
import com.netflix.imflibrary.utils.*;
import com.netflix.imflibrary.utils.ByteArrayDataProvider;
import com.netflix.imflibrary.utils.ErrorLogger;
import com.netflix.imflibrary.utils.FileByteRangeProvider;
import com.netflix.imflibrary.utils.ResourceByteRangeProvider;
import com.netflix.imflibrary.writerTools.CompositionPlaylistBuilder_2016;
import com.netflix.imflibrary.writerTools.IMPBuilder;
import com.netflix.imflibrary.writerTools.utils.IMFUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import javax.annotation.Nullable;
Expand All @@ -35,7 +38,13 @@
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;

Expand All @@ -45,7 +54,7 @@
public class IMPFixer {

private static final String CONFORMANCE_LOGGER_PREFIX = "Virtual Track Conformance";
private static final Logger logger = LogManager.getLogger(IMPFixer.class);
private static final Logger logger = LoggerFactory.getLogger(IMPFixer.class);

private static UUID getTrackFileId(PayloadRecord headerPartitionPayloadRecord) throws
IOException {
Expand Down
40 changes: 4 additions & 36 deletions src/main/java/com/netflix/imflibrary/st0377/HeaderPartition.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,7 @@
import com.netflix.imflibrary.RESTfulInterfaces.IMPValidator;
import com.netflix.imflibrary.RESTfulInterfaces.PayloadRecord;
import com.netflix.imflibrary.exceptions.MXFException;
import com.netflix.imflibrary.st0377.header.AudioChannelLabelSubDescriptor;
import com.netflix.imflibrary.st0377.header.CDCIPictureEssenceDescriptor;
import com.netflix.imflibrary.st0377.header.ContentStorage;
import com.netflix.imflibrary.st0377.header.DMFramework;
import com.netflix.imflibrary.st0377.header.DescriptiveMarkerSegment;
import com.netflix.imflibrary.st0377.header.EssenceContainerData;
import com.netflix.imflibrary.st0377.header.GenericDescriptor;
import com.netflix.imflibrary.st0377.header.GenericPackage;
import com.netflix.imflibrary.st0377.header.GenericPictureEssenceDescriptor;
import com.netflix.imflibrary.st0377.header.GenericStreamTextBasedSet;
import com.netflix.imflibrary.st0377.header.GenericTrack;
import com.netflix.imflibrary.st0377.header.GroupOfSoundFieldGroupLabelSubDescriptor;
import com.netflix.imflibrary.st0377.header.InterchangeObject;
import com.netflix.imflibrary.st0377.header.JPEG2000PictureSubDescriptor;
import com.netflix.imflibrary.st0377.header.ACESPictureSubDescriptor;
import com.netflix.imflibrary.st0377.header.StaticTrack;
import com.netflix.imflibrary.st0377.header.TargetFrameSubDescriptor;
import com.netflix.imflibrary.st0377.header.MaterialPackage;
import com.netflix.imflibrary.st0377.header.PHDRMetaDataTrackSubDescriptor;
import com.netflix.imflibrary.st0377.header.Preface;
import com.netflix.imflibrary.st0377.header.RGBAPictureEssenceDescriptor;
import com.netflix.imflibrary.st0377.header.Sequence;
import com.netflix.imflibrary.st0377.header.SoundFieldGroupLabelSubDescriptor;
import com.netflix.imflibrary.st0377.header.SourceClip;
import com.netflix.imflibrary.st0377.header.SourcePackage;
import com.netflix.imflibrary.st0377.header.StructuralComponent;
import com.netflix.imflibrary.st0377.header.StructuralMetadata;
import com.netflix.imflibrary.st0377.header.TextBasedDMFramework;
import com.netflix.imflibrary.st0377.header.TextBasedObject;
import com.netflix.imflibrary.st0377.header.TimeTextResourceSubDescriptor;
import com.netflix.imflibrary.st0377.header.TimedTextDescriptor;
import com.netflix.imflibrary.st0377.header.TimelineTrack;
import com.netflix.imflibrary.st0377.header.WaveAudioEssenceDescriptor;
import com.netflix.imflibrary.st0377.header.*;
import com.netflix.imflibrary.st2067_2.AudioContentKind;
import com.netflix.imflibrary.st2067_2.Composition;
import com.netflix.imflibrary.st2067_201.IABEssenceDescriptor;
Expand All @@ -68,8 +36,8 @@
import com.netflix.imflibrary.utils.ErrorLogger;
import com.netflix.imflibrary.utils.FileByteRangeProvider;
import com.netflix.imflibrary.utils.ResourceByteRangeProvider;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -108,7 +76,7 @@ public final class HeaderPartition
private final Map<MXFUID, InterchangeObject.InterchangeObjectBO> uidToBOs = new LinkedHashMap<>();
private final IMFErrorLogger imfErrorLogger;

private static final Logger logger = LogManager.getLogger(HeaderPartition.class);
private static final Logger logger = LoggerFactory.getLogger(HeaderPartition.class);

/**
* Instantiates a new MXF Header partition.
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/com/netflix/imflibrary/st0429_8/PackingList.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import com.netflix.imflibrary.utils.ResourceByteRangeProvider;
import com.netflix.imflibrary.utils.UUIDHelper;
import com.netflix.imflibrary.writerTools.utils.ValidationEventHandlerImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smpte_ra.schemas._429_8._2007.pkl.PackingListType;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
Expand All @@ -55,7 +55,16 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

/**
* This class represents a thin, immutable wrapper around the XML type 'PackingListType' which is defined in Section 7,
Expand All @@ -65,7 +74,7 @@
@Immutable
public final class PackingList
{
private static final Logger logger = LogManager.getLogger(PackingList.class);
private static final Logger logger = LoggerFactory.getLogger(PackingList.class);
private final IMFErrorLogger imfErrorLogger;
private static final String xmldsig_core_schema_path = "org/w3/_2000_09/xmldsig/xmldsig-core-schema.xsd";
public static final List<String> supportedPKLNamespaces = Collections.unmodifiableList(new ArrayList<String>(){{ add("http://www.smpte-ra.org/schemas/429-8/2007/PKL");
Expand Down
Loading

0 comments on commit 2a1ee5e

Please sign in to comment.