Example #1
0
        // </CreateMediaServicesClient>


        public static List <OutputUrl> GetUrls(ConfigWrapper config,
                                               IAzureMediaServicesClient client,
                                               StreamingLocator locator,
                                               string manifestFileName,
                                               bool smoothStreaming = true,
                                               bool dashCsf         = true,
                                               bool hlsTs           = true,
                                               bool dashCmaf        = true,
                                               bool hlsCmaf         = true
                                               )
        {
            if (!manifestFileName.ToLower().EndsWith(".ism"))
            {
                manifestFileName = manifestFileName + ".ism";
            }

            var streamingEndpoints = client.StreamingEndpoints.List(config.ResourceGroup, config.AccountName);

            var encString   = "(encryption=cenc)";
            var encString2  = ",encryption=cenc";
            var cbcsString2 = ",encryption=cbcs-aapl";

            if (locator.StreamingPolicyName == PredefinedStreamingPolicy.ClearStreamingOnly || locator.StreamingPolicyName == PredefinedStreamingPolicy.DownloadAndClearStreaming)
            {
                encString   = "";
                encString2  = "";
                cbcsString2 = "";
            }


            // Get the URls to stream the output
            var urls = new List <OutputUrl>();

            foreach (var se in streamingEndpoints)
            {
                if (se.ResourceState == StreamingEndpointResourceState.Running)
                {
                    var uriBuilder = new UriBuilder();
                    uriBuilder.Scheme = "https";
                    uriBuilder.Host   = se.HostName;
                    uriBuilder.Path   = "/" + locator.StreamingLocatorId + "/" + manifestFileName + "/manifest";
                    var myPath = uriBuilder.ToString();
                    if (smoothStreaming)
                    {
                        urls.Add(new OutputUrl
                        {
                            Url      = myPath + encString,
                            Protocol = OutputProtocol.SmoothStreaming
                        });
                    }
                    if (dashCsf)
                    {
                        urls.Add(new OutputUrl
                        {
                            Url      = myPath + "(format=mpd-time-csf" + encString2 + ")",
                            Protocol = OutputProtocol.DashCsf
                        });
                    }
                    if (dashCmaf)
                    {
                        urls.Add(new OutputUrl
                        {
                            Url      = myPath + "(format=mpd-time-cmaf" + encString2 + ")",
                            Protocol = OutputProtocol.DashCmaf
                        });
                    }
                    if (hlsCmaf)
                    {
                        urls.Add(new OutputUrl
                        {
                            Url      = myPath + "(format=m3u8-cmaf" + cbcsString2 + ")",
                            Protocol = OutputProtocol.HlsCmaf
                        });
                    }
                    if (hlsTs)
                    {
                        urls.Add(new OutputUrl
                        {
                            Url      = myPath + "(format=m3u8-aapl" + cbcsString2 + ")",
                            Protocol = OutputProtocol.HlsTs
                        });
                    }
                }
            }

            return(urls);
        }
Example #2
0
        // </GetCredentialsAsync>

        /// <summary>
        ///     Creates the AzureMediaServicesClient object based on the credentials
        ///     supplied in local configuration file.
        /// </summary>
        /// <param name="config">The parm is of type ConfigWrapper. This class reads values from local configuration file.</param>
        /// <returns></returns>
        // <CreateMediaServicesClient>
        public static async Task <IAzureMediaServicesClient> CreateMediaServicesClientAsync(ConfigWrapper config)
        {
            var credentials = await GetCredentialsAsync(config);

            return(new AzureMediaServicesClient(config.ArmEndpoint, credentials)
            {
                SubscriptionId = config.SubscriptionId
            });
        }