public static string AddProtocolFormatInUrlString(string urlstr, AMSOutputProtocols protocol = AMSOutputProtocols.NotSpecified) { switch (protocol) { case AMSOutputProtocols.Dash: return AddParameterToUrlString(urlstr, string.Format(AssetInfo.format_url, AssetInfo.format_dash)); case AMSOutputProtocols.HDS: return AddParameterToUrlString(urlstr, string.Format(AssetInfo.format_url, AssetInfo.format_hds)); case AMSOutputProtocols.HLSv3: return AddParameterToUrlString(urlstr, string.Format(AssetInfo.format_url, AssetInfo.format_hls_v3)); case AMSOutputProtocols.HLSv4: return AddParameterToUrlString(urlstr, string.Format(AssetInfo.format_url, AssetInfo.format_hls_v4)); case AMSOutputProtocols.SmoothLegacy: return AddParameterToUrlString(urlstr, string.Format(AssetInfo.format_url, AssetInfo.format_smooth_legacy)); case AMSOutputProtocols.NotSpecified: default: return urlstr; } }
public static string RW(string path, IStreamingEndpoint se, string filter = null, bool https = false, string customhostname = null, AMSOutputProtocols protocol = AMSOutputProtocols.NotSpecified, string audiotrackname = null) { return RW(new Uri(path), se, filter, https, customhostname, protocol, audiotrackname).AbsoluteUri; }
private static IEnumerable<Uri> GetStreamingUris(ILocator originLocator, IStreamingEndpoint se = null, string filter = null, bool https = false, string customhostname = null, AMSOutputProtocols outputprotocol = AMSOutputProtocols.NotSpecified, string audiotrack = null) { const string BaseStreamingUrlTemplate = "{0}/{1}/manifest"; if (originLocator == null) { throw new ArgumentNullException("locator", "The locator cannot be null."); } if (originLocator.Type != LocatorType.OnDemandOrigin) { throw new ArgumentException("The locator type must be on-demand origin.", "originLocator"); } IEnumerable<Uri> smoothStreamingUri = null; IAsset asset = originLocator.Asset; IEnumerable<IAssetFile> manifestAssetFiles = GetManifestAssetFiles(asset); if (manifestAssetFiles != null) { smoothStreamingUri = manifestAssetFiles.Select(f => new Uri( string.Format( CultureInfo.InvariantCulture, BaseStreamingUrlTemplate, originLocator.Path.TrimEnd('/'), f.Name ), UriKind.Absolute)); } if (se != null) { string hostname = customhostname == null ? se.HostName : customhostname; smoothStreamingUri = smoothStreamingUri.Select(u => new UriBuilder() { Host = hostname, Scheme = https ? "https://" : "http://", Path = AssetInfo.AddAudioTrackToUrlString(AssetInfo.AddProtocolFormatInUrlString(AssetInfo.AddFilterToUrlString(u.AbsolutePath, filter), outputprotocol), audiotrack) }.Uri); } return smoothStreamingUri; }
// return the URL with hostname from streaming endpoint public static Uri RW(Uri url, IStreamingEndpoint se, string filter = null, bool https = false, string customHostName = null, AMSOutputProtocols protocol = AMSOutputProtocols.NotSpecified, string audiotrackname = null) { if (url != null) { string hostname = se.HostName; string path = AddFilterToUrlString(url.AbsolutePath, filter); path = AddProtocolFormatInUrlString(path, protocol); path = AddAudioTrackToUrlString(path, audiotrackname); UriBuilder urib = new UriBuilder() { Host = customHostName == null ? hostname : customHostName, Scheme = https ? "https://" : "http://", Path = path, }; return urib.Uri; } else return null; }