in src/main/java/com/netflix/imflibrary/st2067_100/OutputProfileList.java [363:421]
private void populateMacroHandles(Map<String, Handle> handleMap) {
/**
* Add handles for OPL macros
*/
for( int iteration = 0; iteration < this.macroMap.size(); iteration++) {
boolean bAllDependencyMet = true;
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 && !macro.getOutputs().isEmpty() && !handleMap.containsKey(getHandle(macro.getOutputs().get(0).getHandle()))) {
boolean bDependencyMet = true;
for (Sequence input : macro.getInputs()) {
Handle handleType = handleMap.get(getHandle(input.getHandle()));
if (handleType == null) {
bDependencyMet = false;
}
}
bAllDependencyMet &= bDependencyMet;
/* If input dependencies are met create output handles */
if (bDependencyMet) {
for (Sequence output : macro.getOutputs()) {
String outputHandle = getHandle(output.getHandle());
handleMap.put(outputHandle, new MacroHandle(outputHandle, macro));
}
}
}
}
if(bAllDependencyMet) {
break;
}
}
/**
* Verify that input dependencies for all the macros are resolved
*/
for(Map.Entry<String, Macro> entry: this.macroMap.entrySet()) {
Macro macro = entry.getValue();
for(Sequence input: macro.getInputs()) {
Handle handleType = handleMap.get(getHandle(input.getHandle()));
if (handleType == null) {
imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
String.format("Invalid handle %s in %s macro", input.getHandle(), macro.getName()));
}
}
}
/**
* Validate alias handles
*/
for(String handle: this.aliasMap.values()) {
Handle handleType = handleMap.get(handle);
// Ignore input aliases as they are not needed for dependency resolution
// Ignore cpl/virtual track aliases too. All track IDs are not available for OPL and hence cannot validate.
if (handleType == null && !handle.contains("/inputs/") && !handle.startsWith("cpl/virtual-tracks/")) {
imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_OPL_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
String.format("Invalid handle %s in alias", handle));
}
}
}