internal static void ValidateEnabledProtocols(EnabledProtocols expected, EnabledProtocols actual)
 {
     Assert.Equal(expected.Dash, actual.Dash);
     Assert.Equal(expected.Download, actual.Download);
     Assert.Equal(expected.Hls, actual.Hls);
     Assert.Equal(expected.SmoothStreaming, actual.SmoothStreaming);
 }
Example #2
0
        private static async Task SearchAndListen(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    var enabledProtocols = EnabledProtocols.ToList();

                    if (enabledProtocols.Contains(PmpSearcher.Instance.Protocol))
                    {
                        await Receive(PmpSearcher.Instance, PmpSearcher.sockets).ConfigureAwait(false);
                    }

                    foreach (ISearcher s in controllers)
                    {
                        if (s.NextSearch < DateTime.Now && enabledProtocols.Contains(s.Protocol))
                        {
                            Log("Searching for: {0}", s.GetType().Name);
                            s.Search();
                        }
                    }
                }
                catch (Exception e)
                {
                }
                await Task.Delay(100).ConfigureAwait(false);
            }
        }
        public static async Task <StreamingPolicy> CreateStreamingPolicyIrdeto(ConfigWrapper config,
                                                                               IAzureMediaServicesClient client, string uniqueness = null)
        {
            if (uniqueness == null)
            {
                uniqueness = Guid.NewGuid().ToString().Substring(0, 13);
            }

            var dash_smooth_protocol = new EnabledProtocols(false, true, false, true);
            var hls_dash_protocol    = new EnabledProtocols(false, true, true, false);
            var cenc_config          = new CencDrmConfiguration(
                new StreamingPolicyPlayReadyConfiguration
            {
                CustomLicenseAcquisitionUrlTemplate = config.IrdetoPlayReadyLAURL
            },
                new StreamingPolicyWidevineConfiguration
            {
                CustomLicenseAcquisitionUrlTemplate = config.IrdetoWidevineLAURL
            }
                );
            var cbcs_config = new CbcsDrmConfiguration(
                new StreamingPolicyFairPlayConfiguration
            {
                CustomLicenseAcquisitionUrlTemplate = config.IrdetoFairPlayLAURL
            }
                );

            var ContentKeysEnc = new StreamingPolicyContentKeys
            {
                DefaultKey = new DefaultKey
                {
                    Label = labelCenc
                }
            };

            var ContentKeysCbcsc = new StreamingPolicyContentKeys
            {
                DefaultKey = new DefaultKey
                {
                    Label = labelCbcs
                }
            };

            var cenc = new CommonEncryptionCenc(dash_smooth_protocol, null, ContentKeysEnc, cenc_config);
            var cbcs = new CommonEncryptionCbcs(hls_dash_protocol, null, ContentKeysCbcsc, cbcs_config);

            var policyName      = uniqueness;
            var streamingPolicy = new StreamingPolicy(Guid.NewGuid().ToString(), policyName, null, DateTime.Now, null,
                                                      null, cenc, cbcs, null);

            streamingPolicy = await client.StreamingPolicies.CreateAsync(config.ResourceGroup, config.AccountName,
                                                                         policyName, streamingPolicy);

            return(streamingPolicy);
        }
Example #4
0
        public static List <string> ReturnOutputProtocolsListCencWidevine(EnabledProtocols protocols)
        {
            var protList = new List <string>();

            if (protocols.Dash)
            {
                protList.AddRange(new List <string>
                {
                    OutputProtocol.DashCmaf.ToString(), OutputProtocol.DashCsf.ToString()
                });
            }

            return(protList);
        }
Example #5
0
        public static List <string> ReturnOutputProtocolsListCbcs(EnabledProtocols protocols)
        // returns the supported protocols for cbcs encryption
        {
            var protList = new List <string>();

            //if (protocols.Dash) protList.AddRange(new List<string> { OutputProtocol.DashCmaf.ToString() });
            if (protocols.Hls)
            {
                protList.AddRange(new List <string>
                {
                    OutputProtocol.HlsCmaf.ToString(), OutputProtocol.HlsTs.ToString()
                });
            }

            return(protList);
        }
Example #6
0
        public static List <string> ReturnOutputProtocolsListCencPlayReady(EnabledProtocols protocols)
        {
            var protList = new List <string>();

            if (protocols.Dash)
            {
                protList.AddRange(new List <string>
                {
                    OutputProtocol.DashCmaf.ToString(), OutputProtocol.DashCsf.ToString()
                });
            }
            if (protocols.SmoothStreaming)
            {
                protList.Add(OutputProtocol.SmoothStreaming.ToString());
            }

            return(protList);
        }
Example #7
0
        public override void WritePayload(ISerializationContext context, IValueWriter writer)
        {
            writer.WriteString(SignatureHashAlgorithm);

            Protocol[] protocols = EnabledProtocols.ToArray();
            writer.WriteInt32(protocols.Length);
            for (int i = 0; i < protocols.Length; ++i)
            {
                protocols[i].Serialize(context, writer);
            }

            writer.WriteInt32(ConnectionId);

            writer.WriteString(PublicEncryptionKey.GetType().GetSimplestName());
            PublicEncryptionKey.Serialize(context, writer);
            writer.WriteString(PublicAuthenticationKey.GetType().GetSimplestName());
            PublicAuthenticationKey.Serialize(context, writer);
        }
Example #8
0
        private static void SearchAndListen()
        {
            while (true)
            {
                searching.WaitOne();

                try
                {
                    var enabledProtocols = EnabledProtocols.ToList();

                    if (enabledProtocols.Contains(UpnpSearcher.Instance.Protocol))
                    {
                        Receive(UpnpSearcher.Instance, UpnpSearcher.sockets);
                    }
                    if (enabledProtocols.Contains(PmpSearcher.Instance.Protocol))
                    {
                        Receive(PmpSearcher.Instance, PmpSearcher.sockets);
                    }

                    foreach (ISearcher s in controllers)
                    {
                        if (s.NextSearch < DateTime.Now && enabledProtocols.Contains(s.Protocol))
                        {
                            Log("Searching for: {0}", s.GetType().Name);
                            s.Search();
                        }
                    }
                }
                catch (Exception e)
                {
                    if (UnhandledException != null)
                    {
                        UnhandledException(typeof(NatUtility), new UnhandledExceptionEventArgs(e, false));
                    }
                }
                Thread.Sleep(10);
            }
        }
Example #9
0
        internal static FileShareData DeserializeFileShareData(JsonElement element)
        {
            Optional <string>         etag                    = default;
            ResourceIdentifier        id                      = default;
            string                    name                    = default;
            ResourceType              type                    = default;
            SystemData                systemData              = default;
            Optional <DateTimeOffset> lastModifiedTime        = default;
            Optional <IDictionary <string, string> > metadata = default;
            Optional <int> shareQuota = default;
            Optional <EnabledProtocols> enabledProtocols = default;
            Optional <RootSquashType>   rootSquash       = default;
            Optional <string>           version          = default;
            Optional <bool>             deleted          = default;
            Optional <DateTimeOffset>   deletedTime      = default;
            Optional <int>                       remainingRetentionDays = default;
            Optional <ShareAccessTier>           accessTier             = default;
            Optional <DateTimeOffset>            accessTierChangeTime   = default;
            Optional <string>                    accessTierStatus       = default;
            Optional <long>                      shareUsageBytes        = default;
            Optional <LeaseStatus>               leaseStatus            = default;
            Optional <LeaseState>                leaseState             = default;
            Optional <LeaseDuration>             leaseDuration          = default;
            Optional <IList <SignedIdentifier> > signedIdentifiers      = default;
            Optional <DateTimeOffset>            snapshotTime           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("lastModifiedTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            lastModifiedTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("metadata"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            Dictionary <string, string> dictionary = new Dictionary <string, string>();
                            foreach (var property1 in property0.Value.EnumerateObject())
                            {
                                dictionary.Add(property1.Name, property1.Value.GetString());
                            }
                            metadata = dictionary;
                            continue;
                        }
                        if (property0.NameEquals("shareQuota"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            shareQuota = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("enabledProtocols"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            enabledProtocols = new EnabledProtocols(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("rootSquash"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            rootSquash = new RootSquashType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("version"))
                        {
                            version = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("deleted"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            deleted = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("deletedTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            deletedTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("remainingRetentionDays"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            remainingRetentionDays = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("accessTier"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            accessTier = new ShareAccessTier(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("accessTierChangeTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            accessTierChangeTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("accessTierStatus"))
                        {
                            accessTierStatus = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("shareUsageBytes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            shareUsageBytes = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("leaseStatus"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            leaseStatus = new LeaseStatus(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("leaseState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            leaseState = new LeaseState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("leaseDuration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            leaseDuration = new LeaseDuration(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("signedIdentifiers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <SignedIdentifier> array = new List <SignedIdentifier>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(SignedIdentifier.DeserializeSignedIdentifier(item));
                            }
                            signedIdentifiers = array;
                            continue;
                        }
                        if (property0.NameEquals("snapshotTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            snapshotTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new FileShareData(id, name, type, systemData, etag.Value, Optional.ToNullable(lastModifiedTime), Optional.ToDictionary(metadata), Optional.ToNullable(shareQuota), Optional.ToNullable(enabledProtocols), Optional.ToNullable(rootSquash), version.Value, Optional.ToNullable(deleted), Optional.ToNullable(deletedTime), Optional.ToNullable(remainingRetentionDays), Optional.ToNullable(accessTier), Optional.ToNullable(accessTierChangeTime), accessTierStatus.Value, Optional.ToNullable(shareUsageBytes), Optional.ToNullable(leaseStatus), Optional.ToNullable(leaseState), Optional.ToNullable(leaseDuration), Optional.ToList(signedIdentifiers), Optional.ToNullable(snapshotTime)));
        }