in source/controlplaneapi/runtime/chalicelib/__init__.py [0:0]
def get_plugin_state_definition_branch_list(plugins_list, expected_class, plugin_definitions, is_dependent_plugins, shortened_profile):
branch_list = []
is_audio_media_type = False
for plugin in plugins_list:
plugin_name = plugin["Name"]
plugin_definition = get_plugin_state_definition(plugin, expected_class, plugin_definitions[plugin_name], shortened_profile)
plugin_supported_media_type = plugin_definitions[plugin_name]["SupportedMediaType"]
if "DependentPlugins" in plugin:
print(f"DependentPlugins state machine generation for plugin '{plugin_name}' in progress..")
d_plugins_branch_list = get_plugin_state_definition_branch_list(plugin["DependentPlugins"], None, plugin_definitions, True, shortened_profile)[0]
random_string = "_" + "".join(random.choices(string.ascii_letters + string.digits, k = 5))
if plugin_supported_media_type == "Video":
child_branch = {
"StartAt": f"{plugin_name}DependentPluginsTask{random_string}",
"States": {
f"{plugin_name}DependentPluginsTask{random_string}": {
"Type": "Parallel",
"Branches": d_plugins_branch_list,
"Next": f"{plugin_name}CollectDependentPluginsResult{random_string}"
},
f"{plugin_name}CollectDependentPluginsResult{random_string}": {
"Type": "Pass",
"Parameters": {
"Event.$": "$[0].Event",
"Input.$": "$[0].Input"
},
"Next": f"{plugin_name}{random_string}"
},
f"{plugin_name}{random_string}": plugin_definition
}
}
elif plugin_supported_media_type == "Audio":
is_audio_media_type = True
map_parameters = {
"Event.$": "$.Event",
"Input.$": "$.Input",
"TrackNumber.$": "$$.Map.Item.Value"
}
plugin_definition["Parameters"]["Payload"]["TrackNumber.$"] = "$.TrackNumber"
child_branch = {
"StartAt": f"{plugin_name}MapTask{random_string}",
"States": {
f"{plugin_name}MapTask{random_string}": {
"Type": "Map",
"ItemsPath": "$.Event.AudioTracks",
"Parameters": map_parameters,
"Iterator": {
"StartAt": f"{plugin_name}DependentPluginsTask{random_string}",
"States": {
f"{plugin_name}DependentPluginsTask{random_string}": {
"Type": "Parallel",
"Branches": d_plugins_branch_list,
"Next": f"{plugin_name}CollectDependentPluginsResult{random_string}"
},
f"{plugin_name}CollectDependentPluginsResult{random_string}": {
"Type": "Pass",
"Parameters": {
"Event.$": "$[0].Event",
"Input.$": "$[0].Input",
"TrackNumber.$": "$[0].TrackNumber"
},
"Next": f"{plugin_name}{random_string}"
},
f"{plugin_name}{random_string}": plugin_definition
}
},
"End": True
}
}
}
else:
random_string = "_" + "".join(random.choices(string.ascii_letters + string.digits, k = 5))
if is_dependent_plugins:
if plugin_supported_media_type == "Video":
child_branch = {
"StartAt": f"{plugin_name}{random_string}",
"States": {
f"{plugin_name}{random_string}": plugin_definition
}
}
elif plugin_supported_media_type == "Audio":
is_audio_media_type = True
plugin_definition["Parameters"]["Payload"]["TrackNumber.$"] = "$.TrackNumber"
child_branch = {
"StartAt": f"{plugin_name}{random_string}",
"States": {
f"{plugin_name}{random_string}": plugin_definition
}
}
else:
if plugin_supported_media_type == "Video":
child_branch = {
"StartAt": f"{plugin_name}{random_string}",
"States": {
f"{plugin_name}{random_string}": plugin_definition
}
}
elif plugin_supported_media_type == "Audio":
is_audio_media_type = True
map_parameters = {
"Event.$": "$.Event",
"Input.$": "$.Input",
"TrackNumber.$": "$$.Map.Item.Value"
}
plugin_definition["Parameters"]["Payload"]["TrackNumber.$"] = "$.TrackNumber"
child_branch = {
"StartAt": f"{plugin_name}MapTask{random_string}",
"States": {
f"{plugin_name}MapTask{random_string}": {
"Type": "Map",
"ItemsPath": "$.Event.AudioTracks",
"Parameters": map_parameters,
"Iterator": {
"StartAt": f"{plugin_name}{random_string}",
"States": {
f"{plugin_name}{random_string}": plugin_definition
}
},
"End": True
}
}
}
branch_list.append(child_branch)
return (branch_list, is_audio_media_type)