private static MediaStream GetMediaStream(string authToken, MediaClient mediaClient, StreamingLocator streamingLocator) { MediaStream mediaStream = null; string streamingUrl = mediaClient.GetStreamingUrl(streamingLocator, null); if (!string.IsNullOrEmpty(streamingUrl)) { Asset asset = mediaClient.GetEntity <Asset>(MediaEntity.Asset, streamingLocator.AssetName); MediaInsight mediaInsight = GetMediaInsight(mediaClient, asset); authToken = !string.IsNullOrEmpty(mediaInsight.ViewToken) ? mediaInsight.ViewToken : string.Concat(Constant.AuthIntegration.AuthScheme, authToken); mediaStream = new MediaStream() { Name = string.IsNullOrEmpty(streamingLocator.Name) ? asset.Name : streamingLocator.Name, Url = streamingUrl, Poster = mediaClient.GetDownloadUrl(asset.Name, Constant.Media.Thumbnail.FileName), Tracks = Track.GetMediaTracks(mediaClient, asset), Insight = mediaInsight, Protection = mediaClient.GetStreamProtection(authToken, mediaClient, streamingLocator) }; List <string> assetFilterNames = new List <string>(); AssetFilter[] assetFilters = mediaClient.GetAllEntities <AssetFilter>(MediaEntity.StreamingFilterAsset, streamingLocator.AssetName); foreach (AssetFilter assetFilter in assetFilters) { assetFilterNames.Add(assetFilter.Name); } mediaStream.Filters = assetFilterNames.ToArray(); } return(mediaStream); }
internal MediaAsset(MediaClient mediaClient, Asset asset) : base(asset.Id, asset.Name, asset.Type, asset.AssetId, asset.Created, asset.LastModified, asset.AlternateId, asset.Description, asset.Container, asset.StorageAccountName, asset.StorageEncryptionFormat) { StorageBlobClient blobClient = new StorageBlobClient(mediaClient.MediaAccount, asset.StorageAccountName); Files = GetAssetFiles(blobClient, asset.Container, null); Filters = mediaClient.GetAllEntities <AssetFilter>(MediaEntity.FilterAsset, null, asset.Name); StreamingLocators = mediaClient.GetStreamingUrls(asset.Name); }
public MediaAsset(MediaClient mediaClient, Asset asset) : base(asset.Id, asset.Name, asset.Type, asset.AssetId, asset.Created, asset.LastModified, asset.AlternateId, asset.Description, asset.Container, asset.StorageAccountName, asset.StorageEncryptionFormat) { StorageBlobClient blobClient = new StorageBlobClient(mediaClient.MediaAccount, asset.StorageAccountName); Files = MediaClient.GetAssetFiles(blobClient, asset.Container, null, out bool assetStreamable); StreamingFilters = mediaClient.GetAllEntities <AssetFilter>(MediaEntity.StreamingFilterAsset, asset.Name); StreamingUrls = mediaClient.GetStreamingUrls(asset.Name); Streamable = assetStreamable; Published = StreamingUrls.Length > 0; }
private static void DeleteEntities <T>(MediaClient mediaClient, MediaEntity entityType) where T : Resource { T[] entities = mediaClient.GetAllEntities <T>(entityType); foreach (T entity in entities) { if (!entity.Name.StartsWith(Constant.Media.PredefinedPrefix)) { if (entityType == MediaEntity.Transform) { Job[] jobs = mediaClient.GetAllEntities <Job>(MediaEntity.TransformJob, null, entity.Name); foreach (Job job in jobs) { mediaClient.DeleteEntity(MediaEntity.TransformJob, job.Name, entity.Name); } } mediaClient.DeleteEntity(entityType, entity.Name); } } }
private static void DeleteEntities <T>(MediaClient mediaClient, MediaEntity entityType) where T : Resource { T[] entities = mediaClient.GetAllEntities <T>(entityType); foreach (T entity in entities) { if (!entity.Name.StartsWith(Constant.Media.PredefinedPrefix, StringComparison.OrdinalIgnoreCase)) { mediaClient.DeleteEntity(entityType, entity.Name); } } }
private static MediaStream[] GetMediaStreams(string authToken, MediaClient mediaClient, StreamingLocator locator) { List <MediaStream> mediaStreams = new List <MediaStream>(); string playerUrl = mediaClient.GetPlayerUrl(locator); if (!string.IsNullOrEmpty(playerUrl)) { Asset asset = mediaClient.GetEntity <Asset>(MediaEntity.Asset, locator.AssetName); MediaStream mediaStream = GetMediaStream(authToken, mediaClient, asset, null, locator, playerUrl); mediaStreams.Add(mediaStream); AssetFilter[] assetFilters = mediaClient.GetAllEntities <AssetFilter>(MediaEntity.FilterAsset, null, locator.AssetName); foreach (AssetFilter assetFilter in assetFilters) { MediaStream mediaFilter = GetMediaStream(authToken, mediaClient, asset, assetFilter, locator, playerUrl); mediaStreams.Add(mediaFilter); } } return(mediaStreams.ToArray()); }
internal MediaLiveEvent(MediaClient mediaClient, LiveEvent liveEvent) : base(liveEvent.Input, liveEvent.Id, liveEvent.Name, liveEvent.Type, liveEvent.Tags, liveEvent.Location, liveEvent.Description, liveEvent.Preview, liveEvent.Encoding, liveEvent.ProvisioningState, liveEvent.ResourceState, liveEvent.CrossSiteAccessPolicies, liveEvent.VanityUrl, liveEvent.StreamOptions, liveEvent.Created, liveEvent.LastModified) { Outputs = mediaClient.GetAllEntities <LiveOutput>(MediaEntity.LiveEventOutput, liveEvent.Name); }