Skip to content

Commit

Permalink
Merge pull request #193 from Netflix/feature/OutputProfileListValidation
Browse files Browse the repository at this point in the history
Support for PresetMacroType added
  • Loading branch information
svenkatrav authored May 10, 2017
2 parents cc86ff7 + bed92d4 commit f4707d5
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the org.smpte_ra.schemas._2067_101._2014.pixel_decoder package.
* generated in the org.smpte_ra.schemas._2067_101._2014.pixelDecoder package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
Expand All @@ -30,7 +30,7 @@ public class ObjectFactory {


/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.smpte_ra.schemas._2067_101._2014.pixel_decoder
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.smpte_ra.schemas._2067_101._2014.pixelDecoder
*
*/
public ObjectFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the org.smpte_ra.schemas._2067_101._2014.pixel_encoder package.
* generated in the org.smpte_ra.schemas._2067_101._2014.pixelEncoder package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
Expand All @@ -30,7 +30,7 @@ public class ObjectFactory {


/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.smpte_ra.schemas._2067_101._2014.pixel_encoder
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.smpte_ra.schemas._2067_101._2014.pixelEncoder
*
*/
public ObjectFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.netflix.imflibrary.st2067_100.handle.VirtualTrackHandle;
import com.netflix.imflibrary.st2067_100.macro.Macro;
import com.netflix.imflibrary.st2067_100.macro.Sequence;
import com.netflix.imflibrary.st2067_100.macro.preset.PresetMacro;
import com.netflix.imflibrary.st2067_2.ApplicationComposition;
import com.netflix.imflibrary.st2067_2.Composition;
import com.netflix.imflibrary.st2067_2.IMFEssenceComponentVirtualTrack;
Expand Down Expand Up @@ -127,6 +128,11 @@ public OutputProfileList(String id,
for (Map.Entry<String, Macro> entry : this.macroMap.entrySet()) {
Macro macro = entry.getValue();
if (macro != null) {
if(macro instanceof PresetMacro && this.macroMap.size() != 1) {
imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger
.IMFErrors.ErrorLevels.NON_FATAL,
String.format("OPL with id %s contains Preset Macro with other macro types", id));
}
for (Sequence input : macro.getInputs()) {
if(input.getHandle().startsWith("cpl/")) {
handleMap.put(input.getHandle(), new VirtualTrackHandle(input.getHandle(), null));
Expand Down Expand Up @@ -362,7 +368,7 @@ private void populateMacroHandles(Map<String, Handle> handleMap) {
for (Map.Entry<String, Macro> entry : this.macroMap.entrySet()) {
Macro macro = entry.getValue();
/* Check for all the input dependencies for the macro */
if (macro != null && !handleMap.containsKey(macro.getOutputs().get(0).getHandle())) {
if (macro != null && !macro.getOutputs().isEmpty() && !handleMap.containsKey(macro.getOutputs().get(0).getHandle())) {
boolean bDependencyMet = true;
for (Sequence input : macro.getInputs()) {
Handle handleType = handleMap.get(input.getHandle());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
package com.netflix.imflibrary.st2067_100;

import com.netflix.imflibrary.IMFErrorLogger;
import com.netflix.imflibrary.st2067_100.macro.AudioRoutingMixing.AudioRoutingMixingMacro;
import com.netflix.imflibrary.st2067_100.macro.AudioRoutingMixing.InputEntity;
import com.netflix.imflibrary.st2067_100.macro.AudioRoutingMixing.OutputAudioChannel;
import com.netflix.imflibrary.st2067_100.macro.audioRoutingMixing.AudioRoutingMixingMacro;
import com.netflix.imflibrary.st2067_100.macro.audioRoutingMixing.InputEntity;
import com.netflix.imflibrary.st2067_100.macro.audioRoutingMixing.OutputAudioChannel;
import com.netflix.imflibrary.st2067_100.macro.ColorEncoding;
import com.netflix.imflibrary.st2067_100.macro.Macro;
import com.netflix.imflibrary.st2067_100.macro.crop.CropInputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.crop.CropMacro;
import com.netflix.imflibrary.st2067_100.macro.crop.CropOutputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.crop.MXFRectangle;
import com.netflix.imflibrary.st2067_100.macro.crop.RectanglePadding;
import com.netflix.imflibrary.st2067_100.macro.pixel_decoder.PixelDecoderInputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.pixel_decoder.PixelDecoderMacro;
import com.netflix.imflibrary.st2067_100.macro.pixel_decoder.PixelDecoderOutputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.pixel_encoder.PixelEncoderInputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.pixel_encoder.PixelEncoderMacro;
import com.netflix.imflibrary.st2067_100.macro.pixel_encoder.PixelEncoderOutputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.pixelDecoder.PixelDecoderInputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.pixelDecoder.PixelDecoderMacro;
import com.netflix.imflibrary.st2067_100.macro.pixelDecoder.PixelDecoderOutputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.pixelEncoder.PixelEncoderInputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.pixelEncoder.PixelEncoderMacro;
import com.netflix.imflibrary.st2067_100.macro.pixelEncoder.PixelEncoderOutputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.preset.PresetMacro;
import com.netflix.imflibrary.st2067_100.macro.scale.Lanczos;
import com.netflix.imflibrary.st2067_100.macro.scale.ScaleAlgorithm;
import com.netflix.imflibrary.st2067_100.macro.scale.ScaleInputImageSequence;
import com.netflix.imflibrary.st2067_100.macro.scale.ScaleMacro;
import com.netflix.imflibrary.st2067_100.macro.scale.ScaleOutputImageSequence;
import jdk.nashorn.internal.ir.annotations.Immutable;
import org.smpte_ra.schemas._2067_100._2014.OutputProfileListType.AliasList.Alias;
import org.smpte_ra.schemas._2067_100._2014.PresetMacroType;
import org.smpte_ra.schemas._2067_101._2014.crop_macro.ImageCropMacroType;
import org.smpte_ra.schemas._2067_101._2014.pixel_decoder.PixelDecoderType;
import org.smpte_ra.schemas._2067_101._2014.pixel_encoder.PixelEncoderType;
Expand Down Expand Up @@ -75,7 +77,8 @@ private OutputProfileList createNormalizedOutputProfileList () {
aliasMap.put(alias.getValue(), alias.getHandle());
}

OutputProfileList normalizedOutputProfileList = new OutputProfileList( outputProfileListType.getId(), outputProfileListType.getAnnotation().getValue(),
OutputProfileList normalizedOutputProfileList = new OutputProfileList( outputProfileListType.getId(),
outputProfileListType.getAnnotation() != null ? outputProfileListType.getAnnotation().getValue() : null,
outputProfileListType.getCompositionPlaylistId(), aliasMap, macroMap);

this.imfErrorLogger.addAllErrors(normalizedOutputProfileList.getErrors());
Expand All @@ -99,6 +102,9 @@ else if(macroType instanceof PixelEncoderType) {
else if(macroType instanceof AudioRoutingMixingMacroType) {
return createAudioRoutingMixingMacro((AudioRoutingMixingMacroType) macroType);
}
else if(macroType instanceof PresetMacroType) {
return createPresetMacro((PresetMacroType) macroType);
}
else {
this.imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
String.format("Unknown macro type with %s in OPL", macroType.getName()));
Expand All @@ -120,7 +126,8 @@ private CropMacro createCropMacro(ImageCropMacroType imageCropMacroType) {
inputImageSequence.getInset().getTop().intValue(),
inputImageSequence.getInset().getBottom().intValue());

CropInputImageSequence input = new CropInputImageSequence(inputImageSequence.getAnnotation().getValue(), inputImageSequence.getHandle(), mxfRectangleEnum, inset);
CropInputImageSequence input = new CropInputImageSequence(inputImageSequence.getAnnotation() != null ? inputImageSequence.getAnnotation().getValue() : null,
inputImageSequence.getHandle(), mxfRectangleEnum, inset);

if(imageCropMacroType.getOutputImageSequence() == null) {
this.imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
Expand All @@ -134,11 +141,13 @@ private CropMacro createCropMacro(ImageCropMacroType imageCropMacroType) {


ColorEncoding colorEncodingEnum = ColorEncoding.fromValue(outputImageSequence.getFillColor().getClass().getName());
CropOutputImageSequence output = new CropOutputImageSequence( outputImageSequence.getAnnotation().getValue(),
CropOutputImageSequence output = new CropOutputImageSequence( outputImageSequence.getAnnotation() != null ? outputImageSequence.getAnnotation().getValue() : null,
"macros/" + imageCropMacroType.getName() + "/outputs/images",
padding, colorEncodingEnum);

return new CropMacro( imageCropMacroType.getName(), imageCropMacroType.getAnnotation().getValue(), input, output);
return new CropMacro( imageCropMacroType.getName(),
imageCropMacroType.getAnnotation() != null ? imageCropMacroType.getAnnotation().getValue() : null,
input, output);
}

private ScaleMacro createScaleMacro(ImageScaleMacroType imageScaleMacroType) {
Expand All @@ -147,7 +156,8 @@ private ScaleMacro createScaleMacro(ImageScaleMacroType imageScaleMacroType) {
String.format("Missing InputImageSequence in %s macro", imageScaleMacroType.getName()));
}
ImageScaleMacroType.InputImageSequence inputImageSequence = imageScaleMacroType.getInputImageSequence();
ScaleInputImageSequence input = new ScaleInputImageSequence(inputImageSequence.getAnnotation().getValue(), inputImageSequence.getHandle());
ScaleInputImageSequence input = new ScaleInputImageSequence(inputImageSequence.getAnnotation() != null ? inputImageSequence.getAnnotation().getValue() : null,
inputImageSequence.getHandle());

if(imageScaleMacroType.getOutputImageSequence() == null) {
this.imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
Expand All @@ -162,11 +172,13 @@ private ScaleMacro createScaleMacro(ImageScaleMacroType imageScaleMacroType) {
this.imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
String.format("Unsupported scaling algorithm in %s macro", imageScaleMacroType.getName()));
}
ScaleOutputImageSequence output = new ScaleOutputImageSequence( outputImageSequence.getAnnotation().getValue(),
ScaleOutputImageSequence output = new ScaleOutputImageSequence( outputImageSequence.getAnnotation() != null ? outputImageSequence.getAnnotation().getValue() : null,
"macros/" + imageScaleMacroType.getName() + "/outputs/images",
outputImageSequence.getWidth().intValue(), outputImageSequence.getHeight().intValue(), outputImageSequence.getBoundaryCondition(), scaleAlgorithmType);

return new ScaleMacro( imageScaleMacroType.getName(), imageScaleMacroType.getAnnotation().getValue(), input, output);
return new ScaleMacro( imageScaleMacroType.getName(),
imageScaleMacroType.getAnnotation() != null ? imageScaleMacroType.getAnnotation().getValue() : null,
input, output);
}


Expand All @@ -176,17 +188,20 @@ private PixelDecoderMacro createPixelDecoderMacro(PixelDecoderType pixelDecoderT
String.format("Missing InputImageSequence in %s macro", pixelDecoderType.getName()));
}
PixelDecoderType.InputImageSequence inputImageSequence = pixelDecoderType.getInputImageSequence();
PixelDecoderInputImageSequence input = new PixelDecoderInputImageSequence(inputImageSequence.getAnnotation().getValue(), inputImageSequence.getHandle());
PixelDecoderInputImageSequence input = new PixelDecoderInputImageSequence(inputImageSequence.getAnnotation() != null ? inputImageSequence.getAnnotation().getValue() : null,
inputImageSequence.getHandle());

if(pixelDecoderType.getOutputReferenceImageSequence() == null) {
this.imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
String.format("Missing OutputImageSequence in %s macro", pixelDecoderType.getName()));
}
PixelDecoderType.OutputReferenceImageSequence outputImageSequence = pixelDecoderType.getOutputReferenceImageSequence();
PixelDecoderOutputImageSequence output = new PixelDecoderOutputImageSequence( outputImageSequence.getAnnotation().getValue(),
PixelDecoderOutputImageSequence output = new PixelDecoderOutputImageSequence( outputImageSequence.getAnnotation() != null ? outputImageSequence.getAnnotation().getValue() : null,
"macros/" + pixelDecoderType.getName() + "/outputs/images");

return new PixelDecoderMacro(pixelDecoderType.getName(), pixelDecoderType.getAnnotation().getValue(), input, output);
return new PixelDecoderMacro(pixelDecoderType.getName(),
pixelDecoderType.getAnnotation() != null ? pixelDecoderType.getAnnotation().getValue() : null,
input, output);
}

private PixelEncoderMacro createPixelEncoderMacro(PixelEncoderType pixelEncoderType) {
Expand All @@ -195,17 +210,20 @@ private PixelEncoderMacro createPixelEncoderMacro(PixelEncoderType pixelEncoderT
String.format("Missing InputImageSequence in %s macro", pixelEncoderType.getName()));
}
PixelEncoderType.InputReferenceImageSequence inputImageSequence = pixelEncoderType.getInputReferenceImageSequence();
PixelEncoderInputImageSequence input = new PixelEncoderInputImageSequence(inputImageSequence.getAnnotation().getValue(), inputImageSequence.getHandle());
PixelEncoderInputImageSequence input = new PixelEncoderInputImageSequence(inputImageSequence.getAnnotation() != null ? inputImageSequence.getAnnotation().getValue() : null,
inputImageSequence.getHandle());

if(pixelEncoderType.getOutputImageSequence() == null) {
this.imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
String.format("Missing OutputImageSequence in %s macro", pixelEncoderType.getName()));
}
PixelEncoderType.OutputImageSequence outputImageSequence = pixelEncoderType.getOutputImageSequence();
PixelEncoderOutputImageSequence output = new PixelEncoderOutputImageSequence( outputImageSequence.getAnnotation().getValue(),
PixelEncoderOutputImageSequence output = new PixelEncoderOutputImageSequence( outputImageSequence.getAnnotation() != null ? outputImageSequence.getAnnotation().getValue() : null,
"macros/" + pixelEncoderType.getName() + "/outputs/images");

return new PixelEncoderMacro(pixelEncoderType.getName(), pixelEncoderType.getAnnotation().getValue(), input, output);
return new PixelEncoderMacro(pixelEncoderType.getName(),
pixelEncoderType.getAnnotation() != null ? pixelEncoderType.getAnnotation().getValue() : null,
input, output);
}

private AudioRoutingMixingMacro createAudioRoutingMixingMacro(AudioRoutingMixingMacroType audioRoutingMixingMacroType) {
Expand All @@ -218,10 +236,18 @@ private AudioRoutingMixingMacro createAudioRoutingMixingMacro(AudioRoutingMixing
List<OutputAudioChannel> outputAudioChannels = new ArrayList<>();
for(OutputAudioChannelType outputAudioChannelType: outputEntityList.getOutputAudioChannel()) {
List<InputEntity> inputEntityList = outputAudioChannelType.getInputEntityList().getInputEntity().stream().map(e -> new InputEntity( "", e.getHandle(), e.getGain())).collect(Collectors.toList());
outputAudioChannels.add(new OutputAudioChannel( outputAudioChannelType.getAnnotation().getValue(),
outputAudioChannels.add(new OutputAudioChannel( outputAudioChannelType.getAnnotation() != null ? outputAudioChannelType.getAnnotation().getValue() : null,
"macros/" + audioRoutingMixingMacroType.getName() + "/outputs/" + outputAudioChannelType.getHandle(), inputEntityList));
}

return new AudioRoutingMixingMacro(audioRoutingMixingMacroType.getName(), audioRoutingMixingMacroType.getAnnotation().getValue(), outputAudioChannels);
return new AudioRoutingMixingMacro(audioRoutingMixingMacroType.getName(),
audioRoutingMixingMacroType.getAnnotation() != null ? audioRoutingMixingMacroType.getAnnotation().getValue() : null,
outputAudioChannels);
}

private PresetMacro createPresetMacro(PresetMacroType presetMacroType) {
return new PresetMacro(presetMacroType.getName(),
presetMacroType.getAnnotation() != null ? presetMacroType.getAnnotation().getValue() : null,
presetMacroType.getPreset());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.AudioRoutingMixing;
package com.netflix.imflibrary.st2067_100.macro.audioRoutingMixing;

import com.netflix.imflibrary.st2067_100.macro.Macro;
import com.netflix.imflibrary.st2067_100.macro.Sequence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.AudioRoutingMixing;
package com.netflix.imflibrary.st2067_100.macro.audioRoutingMixing;

import com.netflix.imflibrary.st2067_100.macro.Sequence;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.AudioRoutingMixing;
package com.netflix.imflibrary.st2067_100.macro.audioRoutingMixing;

import com.netflix.imflibrary.st2067_100.macro.Sequence;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.pixel_decoder;
package com.netflix.imflibrary.st2067_100.macro.pixelDecoder;

import com.netflix.imflibrary.st2067_100.macro.Sequence;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.pixel_decoder;
package com.netflix.imflibrary.st2067_100.macro.pixelDecoder;

import com.netflix.imflibrary.st2067_100.macro.Macro;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.pixel_decoder;
package com.netflix.imflibrary.st2067_100.macro.pixelDecoder;

import com.netflix.imflibrary.st2067_100.macro.Sequence;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.pixel_encoder;
package com.netflix.imflibrary.st2067_100.macro.pixelEncoder;

import com.netflix.imflibrary.st2067_100.macro.Sequence;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.pixel_encoder;
package com.netflix.imflibrary.st2067_100.macro.pixelEncoder;

import com.netflix.imflibrary.st2067_100.macro.Macro;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package com.netflix.imflibrary.st2067_100.macro.pixel_encoder;
package com.netflix.imflibrary.st2067_100.macro.pixelEncoder;

import com.netflix.imflibrary.st2067_100.macro.Sequence;

Expand Down
Loading

0 comments on commit f4707d5

Please sign in to comment.