internal static MediaGraphMotionDetectionProcessor DeserializeMediaGraphMotionDetectionProcessor(JsonElement element)
        {
            Optional <MediaGraphMotionDetectionSensitivity> sensitivity = default;
            Optional <bool>             outputMotionRegion     = default;
            Optional <string>           eventAggregationWindow = default;
            string                      type   = default;
            string                      name   = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sensitivity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sensitivity = new MediaGraphMotionDetectionSensitivity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("outputMotionRegion"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    outputMotionRegion = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("eventAggregationWindow"))
                {
                    eventAggregationWindow = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphMotionDetectionProcessor(type, name, inputs, Optional.ToNullable(sensitivity), Optional.ToNullable(outputMotionRegion), eventAggregationWindow.Value));
        }
Exemplo n.º 2
0
        internal static MediaGraphAssetSink DeserializeMediaGraphAssetSink(JsonElement element)
        {
            string                      assetNamePattern              = default;
            Optional <string>           segmentLength                 = default;
            string                      localMediaCachePath           = default;
            string                      localMediaCacheMaximumSizeMiB = default;
            string                      type   = default;
            string                      name   = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("assetNamePattern"))
                {
                    assetNamePattern = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("segmentLength"))
                {
                    segmentLength = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("localMediaCachePath"))
                {
                    localMediaCachePath = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("localMediaCacheMaximumSizeMiB"))
                {
                    localMediaCacheMaximumSizeMiB = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphAssetSink(type, name, inputs, assetNamePattern, segmentLength.Value, localMediaCachePath, localMediaCacheMaximumSizeMiB));
        }
        internal static MediaGraphSignalGateProcessor DeserializeMediaGraphSignalGateProcessor(JsonElement element)
        {
            Optional <string>           activationEvaluationWindow = default;
            Optional <string>           activationSignalOffset     = default;
            Optional <string>           minimumActivationTime      = default;
            Optional <string>           maximumActivationTime      = default;
            string                      type   = default;
            string                      name   = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("activationEvaluationWindow"))
                {
                    activationEvaluationWindow = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("activationSignalOffset"))
                {
                    activationSignalOffset = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("minimumActivationTime"))
                {
                    minimumActivationTime = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("maximumActivationTime"))
                {
                    maximumActivationTime = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphSignalGateProcessor(type, name, inputs, activationEvaluationWindow.Value, activationSignalOffset.Value, minimumActivationTime.Value, maximumActivationTime.Value));
        }
        internal static MediaGraphCognitiveServicesVisionExtension DeserializeMediaGraphCognitiveServicesVisionExtension(JsonElement element)
        {
            MediaGraphEndpoint endpoint = default;
            MediaGraphImage    image    = default;
            Optional <MediaGraphSamplingOptions> samplingOptions = default;
            string type = default;
            string name = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("endpoint"))
                {
                    endpoint = MediaGraphEndpoint.DeserializeMediaGraphEndpoint(property.Value);
                    continue;
                }
                if (property.NameEquals("image"))
                {
                    image = MediaGraphImage.DeserializeMediaGraphImage(property.Value);
                    continue;
                }
                if (property.NameEquals("samplingOptions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    samplingOptions = MediaGraphSamplingOptions.DeserializeMediaGraphSamplingOptions(property.Value);
                    continue;
                }
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphCognitiveServicesVisionExtension(type, name, inputs, endpoint, image, samplingOptions.Value));
        }
Exemplo n.º 5
0
        internal static MediaGraphFileSink DeserializeMediaGraphFileSink(JsonElement element)
        {
            string baseDirectoryPath = default;
            string fileNamePattern   = default;
            string maximumSizeMiB    = default;
            string type = default;
            string name = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("baseDirectoryPath"))
                {
                    baseDirectoryPath = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("fileNamePattern"))
                {
                    fileNamePattern = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("maximumSizeMiB"))
                {
                    maximumSizeMiB = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphFileSink(type, name, inputs, baseDirectoryPath, fileNamePattern, maximumSizeMiB));
        }
        internal static MediaGraphProcessor DeserializeMediaGraphProcessor(JsonElement element)
        {
            if (element.TryGetProperty("@type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Media.MediaGraphCognitiveServicesVisionExtension": return(MediaGraphCognitiveServicesVisionExtension.DeserializeMediaGraphCognitiveServicesVisionExtension(element));

                case "#Microsoft.Media.MediaGraphExtensionProcessorBase": return(MediaGraphExtensionProcessorBase.DeserializeMediaGraphExtensionProcessorBase(element));

                case "#Microsoft.Media.MediaGraphGrpcExtension": return(MediaGraphGrpcExtension.DeserializeMediaGraphGrpcExtension(element));

                case "#Microsoft.Media.MediaGraphHttpExtension": return(MediaGraphHttpExtension.DeserializeMediaGraphHttpExtension(element));

                case "#Microsoft.Media.MediaGraphMotionDetectionProcessor": return(MediaGraphMotionDetectionProcessor.DeserializeMediaGraphMotionDetectionProcessor(element));

                case "#Microsoft.Media.MediaGraphSignalGateProcessor": return(MediaGraphSignalGateProcessor.DeserializeMediaGraphSignalGateProcessor(element));
                }
            }
            string type = default;
            string name = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphProcessor(type, name, inputs));
        }
        internal static MediaGraphSink DeserializeMediaGraphSink(JsonElement element)
        {
            if (element.TryGetProperty("@type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Media.MediaGraphAssetSink": return(MediaGraphAssetSink.DeserializeMediaGraphAssetSink(element));

                case "#Microsoft.Media.MediaGraphFileSink": return(MediaGraphFileSink.DeserializeMediaGraphFileSink(element));

                case "#Microsoft.Media.MediaGraphIoTHubMessageSink": return(MediaGraphIoTHubMessageSink.DeserializeMediaGraphIoTHubMessageSink(element));
                }
            }
            string type = default;
            string name = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphSink(type, name, inputs));
        }
        internal static MediaGraphIoTHubMessageSink DeserializeMediaGraphIoTHubMessageSink(JsonElement element)
        {
            string hubOutputName = default;
            string type          = default;
            string name          = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("hubOutputName"))
                {
                    hubOutputName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphIoTHubMessageSink(type, name, inputs, hubOutputName));
        }