static void Main(string[] args) { VerifyCerts(); var credentials = new MediaServicesCredentials(_wamsAccount, _wamsAccountKey) { AcsBaseAddress = _wamsAcsBaseAddress, Scope = _wamsAcsScope }; _mediaContext = new CloudMediaContext(_wamsEndpoint, credentials); IAsset asset = CreateAsset(); IContentKey key = CreateKeyWithPolicy(asset); IAssetDeliveryPolicy assetDeliveryPolicy = CreateAssetDeliveryPolicy(asset, key); asset.DeliveryPolicies.Add(assetDeliveryPolicy); Console.WriteLine("Asset Delivery Policy Added"); ILocator streamingLocator = CreateLocator(asset); IStreamingEndpoint origin = GetOrigin(recreate: false); Uri uri = GetManifestUrl(origin, asset, streamingLocator); string keyDeliveryUrl = key.GetKeyDeliveryUrl(ContentKeyDeliveryType.FairPlay).ToString(); Console.WriteLine("ism: {0}\nkey delivery: {1}", uri, keyDeliveryUrl); Console.ReadKey(); }
public void RefreshStreamingEndpoint(IStreamingEndpoint origin) { int index = -1; foreach (StreamingEndpointEntry CE in _MyObservStreamingEndpoints) // let's search for index { if (CE.Id == origin.Id) { index = _MyObservStreamingEndpoints.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection origin = _context.StreamingEndpoints.Where(o => o.Id == origin.Id).FirstOrDefault(); //refresh if (origin != null) { _MyObservStreamingEndpoints[index].State = origin.State; _MyObservStreamingEndpoints[index].Description = origin.Description; _MyObservStreamingEndpoints[index].LastModified = origin.LastModified.ToLocalTime(); if (origin.ScaleUnits != null) { _MyObservStreamingEndpoints[index].ScaleUnits = (int)origin.ScaleUnits; this.Refresh(); } } } }
static void Main(string[] args) { // Create and cache the Media Services credentials in a static class variable. _cachedCredentials = new MediaServicesCredentials( _mediaServicesAccountName, _mediaServicesAccountKey); // Used the cached credentials to create CloudMediaContext. _context = new CloudMediaContext(_cachedCredentials); IChannel channel = CreateAndStartChannel(); // Set the Live Encoder to point to the channel's input endpoint: string ingestUrl = channel.Input.Endpoints.FirstOrDefault().Url.ToString(); // Use the previewEndpoint to preview and verify // that the input from the encoder is actually reaching the Channel. string previewEndpoint = channel.Preview.Endpoints.FirstOrDefault().Url.ToString(); // Once you previewed your stream and verified that it is flowing into your Channel, // you can create an event by creating an Asset, Program, and Streaming Locator. IProgram program = CreateAndStartProgram(channel); ILocator locator = CreateLocatorForAsset(program.Asset, program.ArchiveWindowLength); IStreamingEndpoint streamingEndpoint = CreateAndStartStreamingEndpoint(); GetLocatorsInAllStreamingEndpoints(program.Asset); Console.ReadLine(); // Once you are done streaming, clean up your resources. //Cleanup(streamingEndpoint, channel); }
public void RefreshStreamingEndpoint(IStreamingEndpoint origin) { int index = -1; foreach (StreamingEndpointEntry CE in _MyObservStreamingEndpoints) // let's search for index { if (CE.Id == origin.Id) { index = _MyObservStreamingEndpoints.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection origin = _context.StreamingEndpoints.Where(o => o.Id == origin.Id).FirstOrDefault(); //refresh if (origin != null) { _MyObservStreamingEndpoints[index].State = origin.State; if (origin.ScaleUnits != null) { _MyObservStreamingEndpoints[index].ScaleUnits = (int)origin.ScaleUnits; } } Debug.WriteLine("Refresh streaming endpoint status"); } }
public void RefreshStreamingEndpoint(IStreamingEndpoint origin) { int index = -1; foreach (StreamingEndpointEntry CE in _MyObservStreamingEndpoints) // let's search for index { if (CE.Id == origin.Id) { index = _MyObservStreamingEndpoints.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection origin = _context.StreamingEndpoints.Where(o => o.Id == origin.Id).FirstOrDefault(); //refresh if (origin != null) { _MyObservStreamingEndpoints[index].State = origin.State; _MyObservStreamingEndpoints[index].Description = origin.Description; _MyObservStreamingEndpoints[index].LastModified = origin.LastModified.ToLocalTime(); _MyObservStreamingEndpoints[index].Type = StreamingEndpointInformation.ReturnTypeSE(origin); _MyObservStreamingEndpoints[index].CDN = origin.CdnEnabled ? StreamingEndpointInformation.ReturnDisplayedProvider(origin.CdnProvider) ?? "CDN" : string.Empty; _MyObservStreamingEndpoints[index].ScaleUnits = StreamingEndpointInformation.ReturnTypeSE(origin) != StreamingEndpointInformation.StreamEndpointType.Premium ? "" : ((int)origin.ScaleUnits).ToString(); this.Refresh(); } } }
public static MediaOrigin BuildOriginFromIStreamingEndpoint(IStreamingEndpoint endpoint) { var origin = new MediaOrigin { Id = endpoint.Id.NimbusIdToRawGuid(), Name = endpoint.Name, NameShort = endpoint.Name.Substring(0, Math.Min(6, endpoint.Name.Length)).ToUpper(), Description = endpoint.Description, HostName = endpoint.HostName, LastModified = endpoint.LastModified, Created = endpoint.Created, State = endpoint.State.ToString(), ReservedUnits = (endpoint.ScaleUnits.HasValue ? endpoint.ScaleUnits.Value : 0), Health = endpoint.State == StreamingEndpointState.Running ? HealthStatus.Healthy : HealthStatus.Ignore, MaxAge = endpoint.CacheControl?.MaxAge }; if (endpoint.AccessControl != null) { if (endpoint.AccessControl.IPAllowList != null) { origin.IPAllowList = string.Join(";", endpoint.AccessControl.IPAllowList .Select(iprange => string.Format("{0}/{1}", iprange.Address, iprange.SubnetPrefixLength))); } if (endpoint.AccessControl.AkamaiSignatureHeaderAuthenticationKeyList != null) { origin.AuthenticationKeys = endpoint.AccessControl?.AkamaiSignatureHeaderAuthenticationKeyList?.ToList(); } } return(origin); }
private void Cleanup() { IStreamingEndpoint testStreamingEndpoint = GetTestStreamingEndpoint(); if (testStreamingEndpoint != null) { testStreamingEndpoint.Delete(); } IAsset asset; IChannel channel = GetTestChannel(); if (channel != null) { foreach (var program in channel.Programs) { asset = _dataContext.Assets.Where(o => o.Id == program.AssetId).FirstOrDefault(); program.Delete(); if (asset != null) { asset.Delete(); } } channel.Delete(); } asset = GetTestAsset(); if (asset != null) { asset.Delete(); } }
public static void UpdateCrossSiteAccessPoliciesForStreamingEndpoint(IStreamingEndpoint streamingEndpoint) { var clientPolicy = @"<?xml version=""1.0"" encoding=""utf-8""?> <access-policy> <cross-domain-access> <policy> <allow-from http-request-headers=""*"" http-methods=""*""> <domain uri=""*""/> </allow-from> <grant-to> <resource path=""/"" include-subpaths=""true""/> </grant-to> </policy> </cross-domain-access> </access-policy>"; var xdomainPolicy = @"<?xml version=""1.0"" ?> <cross-domain-policy> <allow-access-from domain=""*"" /> </cross-domain-policy>"; streamingEndpoint.CrossSiteAccessPolicies.ClientAccessPolicy = clientPolicy; streamingEndpoint.CrossSiteAccessPolicies.CrossDomainPolicy = xdomainPolicy; streamingEndpoint.Update(); }
// // GET: Display a list ofstreamable media assets public async Task <ActionResult> Index() { //Initializing a model MediaLibraryModel model = new MediaLibraryModel(); model.VideoList = new List <Tuple <IAsset, ILocator, Uri> >(); model.IsCurrentUserMemberOfAdminGroup = IsAdminUser(); model.JwtToken = GetJwtSecurityToken(); if (model.JwtToken == null) { return(View(model)); } try { CloudMediaContext cloudMediaContext = Factory.GetCloudMediaContext(); IStreamingEndpoint streamingEndPoint = cloudMediaContext.StreamingEndpoints.FirstOrDefault(); model.StreamingEndPoint = streamingEndPoint; // Find 30-day read-only access policy. string streamingPolicy = "30d Streaming policy"; var accessPolicy = cloudMediaContext.AccessPolicies.Where(c => c.Name == streamingPolicy).FirstOrDefault(); //Locate all files with smooth streaming Manifest ListExtensions.ForEach(cloudMediaContext.Files.Where(c => c.Name.EndsWith(".ism")), file => { //skip all assets where DynamicEncryption can't be applied if (file.Asset.Options != AssetCreationOptions.None) { return; } ILocator originLocator = null; //Display only assets which associated with streaming 30 day policy if (accessPolicy != null) { originLocator = file.Asset.Locators.Where( c => c.AccessPolicyId == accessPolicy.Id && c.Type == LocatorType.OnDemandOrigin) .FirstOrDefault(); } //If no policy has been found we are storing nulls in a model Tuple <IAsset, ILocator, Uri> item = new Tuple <IAsset, ILocator, Uri>(file.Asset, originLocator, originLocator != null ? new Uri(originLocator.Path + file.Name) : null); model.VideoList.Add(item); }); return(View(model)); } catch (Exception ex) { ViewBag.ErrorMessage = ex.Message; return(View(model)); } }
private void ChooseStreamingEndpoint_Load(object sender, EventArgs e) { label.Text = string.Format(label.Text, _asset.Name); // SE List IStreamingEndpoint BestSE = AssetInfo.GetBestStreamingEndpoint(_context); foreach (var se in _context.StreamingEndpoints) { listBoxSE.Items.Add(new Item(string.Format("{0} ({1}, {2} scale unit{3})", se.Name, se.State, se.ScaleUnits, se.ScaleUnits > 1 ? "s" : string.Empty), se.Id + "|" + se.HostName)); if (se.Id == BestSE.Id) { listBoxSE.SelectedIndex = listBoxSE.Items.Count - 1; } foreach (var custom in se.CustomHostNames) { listBoxSE.Items.Add(new Item(string.Format("{0} ({1}, {2} scale unit{3}) Custom hostname : {4}", se.Name, se.State, se.ScaleUnits, se.ScaleUnits > 1 ? "s" : string.Empty, custom), se.Id + "|" + custom)); } } // Filters listBoxFilter.Items.Add(new Item("(none)", null)); // asset filters _asset.AssetFilters.ToList().ForEach(f => { listBoxFilter.Items.Add(new Item("asset filter : " + f.Name, f.Name)); if (_filter != null && f.Name == _filter) { listBoxFilter.SelectedIndex = listBoxFilter.Items.Count - 1; } } ); // global filters _context.Filters.ToList().ForEach(f => { listBoxFilter.Items.Add(new Item("global filter : " + f.Name, f.Name)); if (_filter != null && f.Name == _filter && listBoxFilter.SelectedIndex < 0) // only if not already selected (asset filter priuority > global filter) { listBoxFilter.SelectedIndex = listBoxFilter.Items.Count - 1; } } ); if (listBoxFilter.SelectedIndex < 0) { listBoxFilter.SelectedIndex = 0; } if (_playertype == PlayerType.DASHIFRefPlayer || _playertype == PlayerType.DASHLiveAzure) { radioButtonDASH.Checked = true; } }
private static IStreamingEndpoint WaitForStreamingEndpointStart(IStreamingEndpoint origin) { while (origin.State != StreamingEndpointState.Running) { Console.WriteLine("Waiting for Endpoint..."); Thread.Sleep(10000); origin = _mediaContext.StreamingEndpoints.AsEnumerable().SingleOrDefault(ep => ep.Id == origin.Id); } Console.WriteLine("Endpoint started."); return(origin); }
public static string StartStreamingEndpoint(MediaClient mediaClient) { string endpointName = string.Empty; IStreamingEndpoint streamingEndpoint = GetStreamingEndpoint(mediaClient); if (streamingEndpoint != null) { streamingEndpoint.StartAsync(); endpointName = streamingEndpoint.Name; } return(endpointName); }
private static IStreamingEndpoint GetStreamingEndpoint(MediaClient mediaClient) { IStreamingEndpoint streamingEndpoint = null; IStreamingEndpoint[] streamingEndpoints = mediaClient.GetEntities(MediaEntity.StreamingEndpoint) as IStreamingEndpoint[]; if (streamingEndpoints.Length > 1) { streamingEndpoint = mediaClient.GetEntityByName(MediaEntity.StreamingEndpoint, Constant.Media.Stream.DefaultEndpointName) as IStreamingEndpoint; } else if (streamingEndpoints.Length == 1) { streamingEndpoint = streamingEndpoints[0]; } return(streamingEndpoint); }
private static Uri GetManifestUrl(IStreamingEndpoint origin, IAsset asset, ILocator streamingLocator) { string manifestFormat = "(format=m3u8-aapl)"; string url = string.Format("{0}{1}.ism/manifest{2}", streamingLocator.Path, asset.Name, manifestFormat); Uri uri = new Uri(url); var builder = new UriBuilder(uri); builder.Scheme = "https"; builder.Host = origin.HostName; builder.Port = -1; uri = builder.Uri; return(uri); }
public static IStreamingEndpoint CreateAndStartStreamingEndpoint() { var options = new StreamingEndpointCreationOptions { Name = StreamingEndpointName, ScaleUnits = 1, AccessControl = GetAccessControl(), CacheControl = GetCacheControl() }; IStreamingEndpoint streamingEndpoint = _context.StreamingEndpoints.Create(options); streamingEndpoint.Start(); return(streamingEndpoint); }
private void Compare(IStreamingEndpoint endpoint, MediaOrigin origin) { Assert.AreEqual(endpoint.Id.Substring(12), origin.Id); Assert.AreEqual(endpoint.Name, origin.Name); Assert.AreEqual(endpoint.HostName, origin.HostName); Assert.AreEqual(endpoint.Created, origin.Created); Assert.AreEqual(endpoint.LastModified, origin.LastModified); Assert.AreEqual(endpoint.ScaleUnits, origin.ReservedUnits); Assert.AreEqual(endpoint.State.ToString(), origin.State); Assert.AreEqual(endpoint.CacheControl?.MaxAge, origin.MaxAge); if (endpoint.AccessControl != null) { var ipAllowList = string.Join(";", endpoint.AccessControl.IPAllowList.Select(iprange => string.Format("{0}/{1}", iprange.Address, iprange.SubnetPrefixLength))); Assert.AreEqual(ipAllowList, origin.IPAllowList); } }
static void Main(string[] args) { AzureAdTokenCredentials tokenCredentials = new AzureAdTokenCredentials(_AADTenantDomain, new AzureAdClientSymmetricKey(_AMSClientId, _AMSClientSecret), AzureEnvironments.AzureCloudEnvironment); var tokenProvider = new AzureAdTokenProvider(tokenCredentials); _context = new CloudMediaContext(new Uri(_RESTAPIEndpoint), tokenProvider); Console.WriteLine("Please choose your Azure Media Services telemety sources"); _streamingEndpoint = ChooseStreamingEndpointForTelemetry(); _channel = ChooseLiveChannelForTelemetry(); var monitoringConfigurations = _context.MonitoringConfigurations; IMonitoringConfiguration monitoringConfiguration = null; // No more than one monitoring configuration settings is allowed. // Once we have created it, it is the one that we shall use in future iterations... // you can use monitoringConfiguration.Delete(); to delete the monitoring configuration. if (monitoringConfigurations.ToArray().Length != 0) { monitoringConfiguration = _context.MonitoringConfigurations.FirstOrDefault(); } else { INotificationEndPoint notificationEndPoint = _context.NotificationEndPoints.Create("monitoring", NotificationEndPointType.AzureTable, GetTableEndPoint()); monitoringConfiguration = _context.MonitoringConfigurations.Create(notificationEndPoint.Id, new List <ComponentMonitoringSetting>() { new ComponentMonitoringSetting(MonitoringComponent.Channel, MonitoringLevel.Verbose), new ComponentMonitoringSetting(MonitoringComponent.StreamingEndpoint, MonitoringLevel.Verbose) }); } //Print metrics for a Streaming Endpoint. PrintMetrics(); Console.WriteLine("\npress any key to exit..."); Console.ReadKey(); }
public static bool IsStreamingEnabled(MediaClient mediaClient, out bool endpointStarting) { endpointStarting = false; bool streamingEnabled = false; IStreamingEndpoint streamingEndpoint = GetStreamingEndpoint(mediaClient); if (streamingEndpoint != null) { endpointStarting = streamingEndpoint.State == StreamingEndpointState.Starting; if (streamingEndpoint.State == StreamingEndpointState.Starting || streamingEndpoint.State == StreamingEndpointState.Running || streamingEndpoint.State == StreamingEndpointState.Scaling) { streamingEnabled = true; } } return(streamingEnabled); }
public static StreamEndpointType ReturnTypeSE(IStreamingEndpoint mySE) { if (mySE.ScaleUnits != null && mySE.ScaleUnits > 0) { return(StreamEndpointType.Premium); } else { if (new Version(mySE.StreamingEndpointVersion) == new Version("1.0")) { return(StreamEndpointType.Classic); } else { return(StreamEndpointType.Standard); } } }
public static string GetUpdatedUri(this Uri baseUri, IStreamingEndpoint origin, string pathSuffix = null) { var uriBuilder = new UriBuilder(baseUri); if (origin != null) { uriBuilder.Host = origin.HostName; // work around for old origins. uriBuilder.Scheme = origin.HostName.Contains(".origin.") ? Uri.UriSchemeHttp : Uri.UriSchemeHttps; uriBuilder.Port = -1; } if (pathSuffix != null) { uriBuilder.Path += pathSuffix; } return(uriBuilder.Uri.AbsoluteUri); }
public static void Cleanup(IStreamingEndpoint streamingEndpoint, IChannel channel) { if (streamingEndpoint != null) { streamingEndpoint.Stop(); streamingEndpoint.Delete(); } IAsset asset; if (channel != null) { foreach (var program in channel.Programs) { asset = _context.Assets.Where(se => se.Id == program.AssetId) .FirstOrDefault(); program.Stop(); program.Delete(); if (asset != null) { foreach (var l in asset.Locators) { l.Delete(); } asset.Delete(); } } channel.Stop(); channel.Delete(); } }
public void CreateStreamingTest() { IStreamingEndpoint streamingEndpoint = _dataContext.StreamingEndpoints.Create( new StreamingEndpointCreationOptions(TestStreamingEndpointName, 2) { CrossSiteAccessPolicies = GetAccessPolicies(), AccessControl = GetAccessControl(), CacheControl = GetCacheControl() }); IChannel channel = _dataContext.Channels.Create( new ChannelCreationOptions { Name = TestChannelName, Input = MakeChannelInput(), Preview = MakeChannelPreview(), Output = MakeChannelOutput() }); IAsset asset = _dataContext.Assets.Create(TestAssetlName, AssetCreationOptions.None); IProgram program = channel.Programs.Create(TestProgramlName, TimeSpan.FromHours(1), asset.Id); Assert.AreEqual(asset.Id, program.AssetId); Assert.AreEqual(channel.Id, program.Channel.Id); }
public TelemetryHelper(MediaServicesAccountConfig account, IChannel channel, IStreamingEndpoint origin = null) : this(account, channel?.Id.NimbusIdToRawGuid(), origin?.Id.NimbusIdToRawGuid()) { }
public static void Cleanup(IStreamingEndpoint streamingEndpoint,string achannelName) { if (streamingEndpoint != null) { if (streamingEndpoint.State == StreamingEndpointState.Running) { streamingEndpoint.Stop();} { streamingEndpoint.Delete(); } } IAsset asset; var channel = _context.Channels.Where(c => c.Name == achannelName).FirstOrDefault(); if (channel != null) { foreach (var program in channel.Programs) { asset = _context.Assets.Where(se => se.Id == program.AssetId) .FirstOrDefault(); if (program.State == ProgramState.Running) { program.Stop(); } program.Delete(); if (asset != null) { foreach (var l in asset.Locators) l.Delete(); asset.Delete(); } } if (channel.State == ChannelState.Running) { channel.Stop(); } channel.Delete(); } }
private async void StartStreamingEndpoint(IStreamingEndpoint myO) { if (myO != null) { TextBoxLogWriteLine("Starting streaming endpoint '{0}'...", myO.Name); await Task.Run(() => StreamingEndpointExecuteOperationAsync(myO.SendStartOperationAsync, myO, "started")); this.BeginInvoke(new Action(() => { this.Notify("Streaming endpoint started", string.Format("{0}", myO.Name), false); })); } }
/// <summary> /// Returns the HLS version 3 URL of the <paramref name="originLocator"/>; otherwise, null. /// </summary> /// <param name="originLocator">The <see cref="ILocator"/> instance.</param> /// <returns>A <see cref="System.Uri"/> representing the HLS version 3 URL of the <paramref name="originLocator"/>; otherwise, null.</returns> public static IEnumerable<Uri> GetHlsv3Uris(ILocator originLocator, IStreamingEndpoint se = null, string filter = null, bool https = false, string customhostname = null, string audiotrack = null) { return GetStreamingUris(originLocator, se, filter, https, customhostname, AMSOutputProtocols.HLSv3, audiotrack); }
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; }
private void DoLoadTelemetry(IStreamingEndpoint streamingEndpoint, bool showErrors) { if (_firsttime) { dataGridViewTelemetry.ColumnCount = 9; dataGridViewTelemetry.Columns[0].HeaderText = "ObservedTime (local)"; dataGridViewTelemetry.Columns[1].HeaderText = "BytesSent"; dataGridViewTelemetry.Columns[2].HeaderText = "EndToEndLatency"; dataGridViewTelemetry.Columns[3].HeaderText = "HostName"; dataGridViewTelemetry.Columns[4].HeaderText = "RequestCount"; dataGridViewTelemetry.Columns[5].HeaderText = "ResultCode"; dataGridViewTelemetry.Columns[6].HeaderText = "RowKey"; dataGridViewTelemetry.Columns[7].HeaderText = "ServerLatency"; dataGridViewTelemetry.Columns[8].HeaderText = "StatusCode"; statusCodeCol = 8; labelTelemetryUI.Text = string.Format("Telemetry for Streaming Endpoint '{0}'", streamingEndpoint.Name); dataGridViewTelemetry.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; _firsttime = false; } // Processors tab /* * dataGridViewTelemetry.ColumnCount = 5; * dataGridViewProcessors.Columns[0].HeaderText = "Vendor"; * dataGridViewProcessors.Columns[0].Width = 82; * dataGridViewProcessors.Columns[1].HeaderText = "Name"; * dataGridViewProcessors.Columns[1].Width = 222; * dataGridViewProcessors.Columns[2].HeaderText = "Version"; * dataGridViewProcessors.Columns[2].Width = 65; * dataGridViewProcessors.Columns[3].HeaderText = "Id"; * dataGridViewProcessors.Columns[3].Width = 230; * dataGridViewProcessors.Columns[4].HeaderText = "Description"; * dataGridViewProcessors.Columns[4].Width = 390; */ dataGridViewTelemetry.Rows.Clear(); var monitorconfig = _context.MonitoringConfigurations.FirstOrDefault(); if (monitorconfig == null) { return; } var currentConfig = _context.NotificationEndPoints.Where(n => n.Id == monitorconfig.NotificationEndPointId).FirstOrDefault(); if (currentConfig == null) { return; } try { // Get some streaming endpoint metrics. var res = _context.StreamingEndPointRequestLogs.GetStreamingEndPointMetrics( currentConfig.EndPointAddress, _storagePassword, new Guid(_credentials.AccountId).ToString(), streamingEndpoint.Id, _timerangeStart, _timerangeEnd ?? DateTime.UtcNow); foreach (var log in res) { if (!showErrors || (showErrors && (log.StatusCode >= 400))) { dataGridViewTelemetry.Rows.Add(log.ObservedTime.ToLocalTime(), log.BytesSent, log.EndToEndLatency, log.HostName, log.RequestCount, log.ResultCode, log.RowKey, log.ServerLatency, log.StatusCode); } } } catch (Exception ex) { MessageBox.Show("Error when accessing to telemetry.\n\n" + ex.Message); _storagePassword = ""; _credentials.AccountId = ""; if (boolSavedStoragePassword) { _credentials.DefaultStorageKey = ""; } } }
public void RefreshStreamingEndpoint(IStreamingEndpoint origin) { int index = -1; foreach (StreamingEndpointEntry CE in _MyObservStreamingEndpoints) // let's search for index { if (CE.Id == origin.Id) { index = _MyObservStreamingEndpoints.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection origin = _context.StreamingEndpoints.Where(o => o.Id == origin.Id).FirstOrDefault(); //refresh if (origin != null) { _MyObservStreamingEndpoints[index].State = origin.State; _MyObservStreamingEndpoints[index].Description = origin.Description; _MyObservStreamingEndpoints[index].LastModified = origin.LastModified; if (origin.ScaleUnits != null) { _MyObservStreamingEndpoints[index].ScaleUnits = (int)origin.ScaleUnits; this.Refresh(); } } } }
// STREAMING ENDPOINT ASYNC OPERATIONS private async Task<IOperation> StartStreamingEndpoint(IStreamingEndpoint myO) { TextBoxLogWriteLine("Streaming endpoint '{0}' : starting...", myO.Name); return await Task.Run(() => StreamingEndpointExecuteOperationAsync(myO.SendStartOperationAsync, myO, "started")); }
private async Task<IOperation> StopStreamingEndpointAsync(IStreamingEndpoint mySE) { TextBoxLogWriteLine("Streaming endpoint '{0}' : stopping...", mySE.Name); return await Task.Run(() => StreamingEndpointExecuteOperationAsync(mySE.SendStopOperationAsync, mySE, "stopped")); }
private async Task<IOperation> DeleteStreamingEndpointAsync(IStreamingEndpoint myO) { TextBoxLogWriteLine("Streaming endpoint '{0}' : deleting...", myO.Name); return await Task.Run(() => StreamingEndpointExecuteOperationAsync(myO.SendDeleteOperationAsync, myO, "deleted")); }
private async void DoDisplayStreamingEndpointInfo(IStreamingEndpoint streamingendpoint) { // Refresh the context _context = Program.ConnectAndGetNewContext(_credentials); StreamingEndpointInformation form = new StreamingEndpointInformation() { MyStreamingEndpoint = streamingendpoint, MyContext = _context }; if (form.ShowDialog() == DialogResult.OK) { streamingendpoint.CustomHostNames = form.GetStreamingCustomHostnames; if (form.GetStreamingAllowList != null) { if (streamingendpoint.AccessControl == null) { streamingendpoint.AccessControl = new StreamingEndpointAccessControl(); } streamingendpoint.AccessControl.IPAllowList = form.GetStreamingAllowList; } else { if (streamingendpoint.AccessControl != null) { streamingendpoint.AccessControl.IPAllowList = null; } } if (form.GetStreamingAkamaiList != null) { if (streamingendpoint.AccessControl == null) { streamingendpoint.AccessControl = new StreamingEndpointAccessControl(); } streamingendpoint.AccessControl.AkamaiSignatureHeaderAuthenticationKeyList = form.GetStreamingAkamaiList; } else { if (streamingendpoint.AccessControl != null) { streamingendpoint.AccessControl.AkamaiSignatureHeaderAuthenticationKeyList = null; } } if (form.MaxCacheAge != null) { if (streamingendpoint.CacheControl == null) { streamingendpoint.CacheControl = new StreamingEndpointCacheControl(); } streamingendpoint.CacheControl.MaxAge = form.MaxCacheAge; } else { if (streamingendpoint.CacheControl != null) { streamingendpoint.CacheControl.MaxAge = null; } } // Client Access Policy if (form.GetOriginClientPolicy != null) { if (streamingendpoint.CrossSiteAccessPolicies == null) { streamingendpoint.CrossSiteAccessPolicies = new CrossSiteAccessPolicies(); } streamingendpoint.CrossSiteAccessPolicies.ClientAccessPolicy = form.GetOriginClientPolicy; } else { if (streamingendpoint.CrossSiteAccessPolicies != null) { streamingendpoint.CrossSiteAccessPolicies.ClientAccessPolicy = null; } } // Cross domain Policy if (form.GetOriginCrossdomaintPolicy != null) { if (streamingendpoint.CrossSiteAccessPolicies == null) { streamingendpoint.CrossSiteAccessPolicies = new CrossSiteAccessPolicies(); } streamingendpoint.CrossSiteAccessPolicies.CrossDomainPolicy = form.GetOriginCrossdomaintPolicy; } else { if (streamingendpoint.CrossSiteAccessPolicies != null) { streamingendpoint.CrossSiteAccessPolicies.CrossDomainPolicy = null; } } streamingendpoint.Description = form.GetOriginDescription; // Let's take actions now if (streamingendpoint.ScaleUnits != form.GetScaleUnits) { Task.Run(async () => { await StreamingEndpointExecuteOperationAsync(streamingendpoint.SendUpdateOperationAsync, streamingendpoint, "updated"); await ScaleStreamingEndpoint(streamingendpoint, form.GetScaleUnits); }); } else // no scaling { Task.Run(async () => { await StreamingEndpointExecuteOperationAsync(streamingendpoint.SendUpdateOperationAsync, streamingendpoint, "updated"); }); } } }
private void ChooseStreamingEndpoint_Load(object sender, EventArgs e) { label.Text = string.Format(label.Text, _asset.Name); // SE List IStreamingEndpoint BestSE = AssetInfo.GetBestStreamingEndpoint(_context); foreach (var se in _context.StreamingEndpoints) { listBoxSE.Items.Add(new Item(string.Format("{0} ({1}, {2} scale unit{3})", se.Name, se.State, se.ScaleUnits, se.ScaleUnits > 1 ? "s" : string.Empty), se.Id + "|" + se.HostName)); if (se.Id == BestSE.Id) { listBoxSE.SelectedIndex = listBoxSE.Items.Count - 1; } foreach (var custom in se.CustomHostNames) { listBoxSE.Items.Add(new Item(string.Format("{0} ({1}, {2} scale unit{3}) Custom hostname : {4}", se.Name, se.State, se.ScaleUnits, se.ScaleUnits > 1 ? "s" : string.Empty, custom), se.Id + "|" + custom)); } } // Filters // asset filters var afilters = _asset.AssetFilters.ToList(); var afiltersnames = afilters.Select(a => a.Name).ToList(); afilters.ForEach(f => { var lvitem = new ListViewItem(new string[] { "asset filter : " + f.Name, f.Name }); if (_filter != null && f.Name == _filter) { lvitem.Checked = true; } listViewFilters.Items.Add(lvitem); } ); // global filters _context.Filters.ToList().ForEach(f => { var lvitem = new ListViewItem(new string[] { "global filter : " + f.Name, f.Name }); if (_filter != null && f.Name == _filter && listViewFilters.CheckedItems.Count == 0) // only if not already selected (asset filter priority > global filter) { lvitem.Checked = true; } if (afiltersnames.Contains(f.Name)) // global filter with same name than asset filter { lvitem.ForeColor = Color.Gray; } listViewFilters.Items.Add(lvitem); } ); if (_playertype == PlayerType.DASHIFRefPlayer || _playertype == PlayerType.DASHLiveAzure) { radioButtonDASH.Checked = true; } UpdatePreviewUrl(); }
private async void DeleteStreamingEndpoint(IStreamingEndpoint myO) { if (myO != null) { TextBoxLogWriteLine("Deleting streaming endpoint '{0}'.", myO.Name); await Task.Run(() => StreamingEndpointExecuteOperationAsync(myO.SendDeleteOperationAsync, myO, "deleted")); DoRefreshGridStreamingEndpointV(false); } }
internal async Task<IOperation> StreamingEndpointExecuteOperationAsync(Func<Task<IOperation>> fCall, IStreamingEndpoint myO, string strStatusSuccess) //used for all except creation { IOperation operation = null; try { var state = myO.State; var STask = fCall(); operation = await STask; while (operation.State == OperationState.InProgress) { //refresh the operation operation = _context.Operations.GetOperation(operation.Id); // refresh the streaming endpoint IStreamingEndpoint myOR = _context.StreamingEndpoints.Where(se => se.Id == myO.Id).FirstOrDefault(); if (myOR != null && state != myOR.State) { state = myOR.State; dataGridViewStreamingEndpointsV.BeginInvoke(new Action(() => dataGridViewStreamingEndpointsV.RefreshStreamingEndpoint(myOR)), null); } System.Threading.Thread.Sleep(1000); } if (operation.State == OperationState.Succeeded) { TextBoxLogWriteLine("Streaming endpoint '{0}' : {1}.", myO.Name, strStatusSuccess); IStreamingEndpoint myse = _context.StreamingEndpoints.Where(se => se.Id == myO.Id).FirstOrDefault(); // we display a notification is taskbar for channel started or reset if (myse != null && strStatusSuccess == "started") { this.BeginInvoke(new Action(() => { this.Notify("Streaming endpoint " + strStatusSuccess, string.Format("{0}", myse.Name), false); })); } } else { TextBoxLogWriteLine("Streaming endpoint '{0}': NOT {1}. (Error {2})", myO.Name, strStatusSuccess, operation.ErrorCode, true); TextBoxLogWriteLine("Error message : {0}", operation.ErrorMessage, true); } dataGridViewStreamingEndpointsV.BeginInvoke(new Action(() => dataGridViewStreamingEndpointsV.RefreshStreamingEndpoint(myO)), null); } catch (Exception ex) { TextBoxLogWriteLine("Streaming endpoint '{0}' : Error {1}", myO.Name, Program.GetErrorMessage(ex), true); } return operation; }
public static IEnumerable<Uri> GetSmoothStreamingUris(ILocator originLocator, IStreamingEndpoint se = null, string filter = null, bool https = false) { return GetStreamingUris(originLocator, string.Empty, se, filter, https); }
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; }
// return the URL with hostname from streaming endpoint public static Uri RW(Uri url, IStreamingEndpoint se, string filter = null, bool https = false) { if (url != null) { string hostname = se.HostName; string path = url.AbsolutePath; if (filter != null) // we want to add filter { path = AddParameterToUrlString(path, string.Format(AssetInfo.filter_url, filter)); } UriBuilder urib = new UriBuilder() { Host = hostname, Scheme = https ? "https://" : "http://", Path = path, }; return urib.Uri; } else return null; }
public static StringBuilder GetDescriptionLocators(IAsset MyAsset, IStreamingEndpoint SelectedSE = null) { StringBuilder sb = new StringBuilder(); foreach (ILocator locator in MyAsset.Locators) { sb.AppendLine("Locator Name : " + locator.Name); sb.AppendLine("Locator Type : " + locator.Type.ToString()); sb.AppendLine("Locator Id : " + locator.Id); sb.AppendLine("Locator Path : " + locator.Path); if (locator.StartTime != null) sb.AppendLine("Start Time : " + ((DateTime)locator.StartTime).ToLongDateString() + " " + ((DateTime)locator.StartTime).ToLongTimeString()); if (locator.ExpirationDateTime != null) sb.AppendLine("Expiration Time : " + ((DateTime)locator.ExpirationDateTime).ToLongDateString() + " " + ((DateTime)locator.ExpirationDateTime).ToLongTimeString()); sb.AppendLine(""); if (locator.Type == LocatorType.OnDemandOrigin) { sb.AppendLine(_prog_down_http_streaming + " : "); foreach (IAssetFile IAF in MyAsset.AssetFiles) sb.AppendLine((new Uri(locator.Path + IAF.Name)).AbsoluteUri); sb.AppendLine(""); if (MyAsset.AssetType == AssetType.MediaServicesHLS) // It is a static HLS asset, so let's propose only the standard HLS V3 locator { sb.AppendLine(AssetInfo._hls + " : "); sb.AppendLine(locator.GetHlsUri().AbsoluteUri); sb.AppendLine(""); } else if (MyAsset.AssetType == AssetType.SmoothStreaming || MyAsset.AssetType == AssetType.MultiBitrateMP4 || MyAsset.AssetType == AssetType.Unknown) //later to change Unknown to live archive { // It's not Static HLS // Smooth or multi MP4 if (locator.GetSmoothStreamingUri() != null) { foreach (var uri in AssetInfo.GetSmoothStreamingUris(locator, SelectedSE)) { sb.AppendLine(AssetInfo._smooth + " : "); sb.AppendLine(uri.AbsoluteUri); } foreach (var uri in AssetInfo.GetSmoothStreamingLegacyUris(locator, SelectedSE)) { sb.AppendLine(AssetInfo._smooth_legacy + " : "); sb.AppendLine(uri.AbsoluteUri); } } if (locator.GetMpegDashUri() != null) { foreach (var uri in AssetInfo.GetMpegDashUris(locator, SelectedSE)) { sb.AppendLine(AssetInfo._dash + " : "); sb.AppendLine(uri.AbsoluteUri); } } if (locator.GetHlsUri() != null) { foreach (var uri in AssetInfo.GetHlsUris(locator, SelectedSE)) { sb.AppendLine(AssetInfo._hls_v4 + " : "); sb.AppendLine(uri.AbsoluteUri); } foreach (var uri in AssetInfo.GetHlsv3Uris(locator, SelectedSE)) { sb.AppendLine(AssetInfo._hls_v3 + " : "); sb.AppendLine(uri.AbsoluteUri); } sb.AppendLine(""); } } } if (locator.Type == LocatorType.Sas) { List<Uri> ProgressiveDownloadUris; IEnumerable<IAssetFile> MyAssetFiles; sb.AppendLine(AssetInfo._prog_down_https_SAS + " : "); MyAssetFiles = MyAsset.AssetFiles.ToList(); // Generate the Progressive Download URLs for each file. ProgressiveDownloadUris = MyAssetFiles.Select(af => af.GetSasUri(locator)).ToList(); ProgressiveDownloadUris.ForEach(uri => sb.AppendLine(uri.AbsoluteUri)); } sb.AppendLine(""); sb.AppendLine("=============================================================================="); sb.AppendLine(""); } return sb; }
public static IEnumerable<Uri> rw(IEnumerable<Uri> urls, IStreamingEndpoint se, string filter = null, bool https = false) { return urls.Select(u => RW(u, se, filter, https)); }
public StreamingEndpointTest() { _endpoint = new StreamingEndpoint <MockEntity>(EntryEndpoint, "endpoint"); }
public static string RW(string path, IStreamingEndpoint se, string filter = null, bool https = false) { return RW(new Uri(path), se, filter, https).AbsoluteUri; }
public static void UpdateCrossSiteAccessPoliciesForStreamingEndpoint(IStreamingEndpoint streamingEndpoint) { var clientPolicy = @"<?xml version=""1.0"" encoding=""utf-8""?> <access-policy> <cross-domain-access> <policy> <allow-from http-request-headers=""*"" http-methods=""*""> <domain uri=""*""/> </allow-from> <grant-to> <resource path=""/"" include-subpaths=""true""/> </grant-to> </policy> </cross-domain-access> </access-policy>"; var xdomainPolicy = @"<?xml version=""1.0"" ?> <cross-domain-policy> <allow-access-from domain=""*"" /> </cross-domain-policy>"; streamingEndpoint.CrossSiteAccessPolicies.ClientAccessPolicy = clientPolicy; streamingEndpoint.CrossSiteAccessPolicies.CrossDomainPolicy = xdomainPolicy; streamingEndpoint.Update(); }
/// <summary> /// Returns the MPEG-DASH URL of the <paramref name="originLocator"/>; otherwise, null. /// </summary> /// <param name="originLocator">The <see cref="ILocator"/> instance.</param> /// <returns>A <see cref="System.Uri"/> representing the MPEG-DASH URL of the <paramref name="originLocator"/>; otherwise, null.</returns> public static IEnumerable<Uri> GetMpegDashUris(ILocator originLocator, IStreamingEndpoint se = null, string filter = null, bool https = false) { return GetStreamingUris(originLocator, MpegDashStreamingParameter, se, filter, https); }
public static bool CanDoDynPackaging(IStreamingEndpoint mySE) { return(ReturnTypeSE(mySE) != StreamEndpointType.Classic); }
private async void StopStreamingEndpoint(IStreamingEndpoint myO) { if (myO != null) { TextBoxLogWriteLine("Stopping streaming endpoint '{0}'...", myO.Name); await Task.Run(() => StreamingEndpointExecuteOperationAsync(myO.SendStopOperationAsync, myO, "stopped")); } }
private void ChooseStreamingEndpoint_Load(object sender, EventArgs e) { label.Text = string.Format(label.Text, _asset.Name); // SE List IStreamingEndpoint BestSE = AssetInfo.GetBestStreamingEndpoint(_context); foreach (var se in _context.StreamingEndpoints) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnit, se.Name, se.State, StreamingEndpointInformation.ReturnTypeSE(se)), se.Id + "|" + se.HostName)); if (se.Id == BestSE.Id) { listBoxSE.SelectedIndex = listBoxSE.Items.Count - 1; } foreach (var custom in se.CustomHostNames) { listBoxSE.Items.Add(new Item(string.Format(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_012ScaleUnitCustomHostname3, se.Name, se.State, StreamingEndpointInformation.ReturnTypeSE(se), custom), se.Id + "|" + custom)); } } // Filters // asset filters var afilters = _asset.AssetFilters.ToList(); var afiltersnames = afilters.Select(a => a.Name).ToList(); afilters.ForEach(f => { var lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_AssetFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter) { lvitem.Checked = true; } listViewFilters.Items.Add(lvitem); } ); // global filters _context.Filters.ToList().ForEach(f => { var lvitem = new ListViewItem(new string[] { AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_GlobalFilter + f.Name, f.Name }); if (_filter != null && f.Name == _filter && listViewFilters.CheckedItems.Count == 0) // only if not already selected (asset filter priority > global filter) { lvitem.Checked = true; } if (afiltersnames.Contains(f.Name)) // global filter with same name than asset filter { lvitem.ForeColor = Color.Gray; } listViewFilters.Items.Add(lvitem); } ); if (_playertype == PlayerType.DASHIFRefPlayer) { radioButtonDASHCSF.Checked = true; } comboBoxBrowser.Items.Add(new Item(AMSExplorer.Properties.Resources.ChooseStreamingEndpoint_ChooseStreamingEndpoint_Load_DefaultBrowser, string.Empty)); if (_displayBrowserSelection) { // let's add the browser options to lplayback the content (IE, Edge, Chrome...) if (IsWindows10()) { comboBoxBrowser.Items.Add(new Item(Constants.BrowserEdge[0], Constants.BrowserEdge[1])); } comboBoxBrowser.Items.Add(new Item(Constants.BrowserIE[0], Constants.BrowserIE[1])); comboBoxBrowser.Items.Add(new Item(Constants.BrowserChrome[0], Constants.BrowserChrome[1])); comboBoxBrowser.SelectedIndex = 0; } comboBoxBrowser.Visible = _displayBrowserSelection; UpdatePreviewUrl(); }
public void DoStreamingEndpointMonitor(IStreamingEndpoint origin, OperationType operationtype) { Task.Run(() => { if (operationtype == OperationType.Scale) { List <StatusInfo> LSI; DateTime starttime = DateTime.Now; System.Threading.Thread.Sleep(1000); // it take some time for the origin to switch to scaling mode while (origin.State == StreamingEndpointState.Scaling) { RefreshStreamingEndpoint(origin); System.Threading.Thread.Sleep(500); if (DateTime.Now > starttime.AddMinutes(10)) { break; } LSI = ListStatus.Where(l => l.EntityName == origin.Name).ToList(); if (LSI.Count > 0) { MessageBox.Show(LSI.FirstOrDefault().ErrorMessage); break; } } RefreshStreamingEndpoint(origin); } else if (operationtype == OperationType.Delete) { string originid = origin.Id; List <StatusInfo> LSI; DateTime starttime = DateTime.Now; while (_context.StreamingEndpoints.Where(o => o.Id == originid).FirstOrDefault() != null) { RefreshStreamingEndpoint(origin); System.Threading.Thread.Sleep(1000); if (DateTime.Now > starttime.AddMinutes(10)) { break; } LSI = ListStatus.Where(l => l.EntityName == origin.Name).ToList(); if (LSI.Count > 0) { MessageBox.Show(LSI.FirstOrDefault().ErrorMessage); break; } } RefreshStreamingEndpoints(); } else { StreamingEndpointState StateToReach; switch (operationtype) { case OperationType.Create: StateToReach = StreamingEndpointState.Stopped; break; case OperationType.Start: StateToReach = StreamingEndpointState.Running; break; case OperationType.Stop: StateToReach = StreamingEndpointState.Stopped; break; default: StateToReach = StreamingEndpointState.Stopped; break; } List <StatusInfo> LSI; DateTime starttime = DateTime.Now; while (origin.State != StateToReach) { RefreshStreamingEndpoint(origin); System.Threading.Thread.Sleep(500); if (DateTime.Now > starttime.AddMinutes(10)) { break; } LSI = ListStatus.Where(l => l.EntityName == origin.Name).ToList(); if (LSI.Count > 0) { MessageBox.Show(LSI.FirstOrDefault().ErrorMessage); break; } } RefreshStreamingEndpoint(origin); } }); }
public static void Cleanup(IStreamingEndpoint streamingEndpoint, IChannel channel) { if (streamingEndpoint != null) { streamingEndpoint.Stop(); streamingEndpoint.Delete(); } IAsset asset; if (channel != null) { foreach (var program in channel.Programs) { asset = _context.Assets.Where(se => se.Id == program.AssetId) .FirstOrDefault(); program.Stop(); program.Delete(); if (asset != null) { foreach (var l in asset.Locators) l.Delete(); asset.Delete(); } } channel.Stop(); channel.Delete(); } }
public static StringBuilder GetStat(IAsset MyAsset, IStreamingEndpoint SelectedSE = null) { StringBuilder sb = new StringBuilder(); string MyAssetType = AssetInfo.GetAssetType(MyAsset); bool bfileinasset = (MyAsset.AssetFiles.Count() == 0) ? false : true; long size = -1; if (bfileinasset) { size = 0; foreach (IAssetFile file in MyAsset.AssetFiles) { size += file.ContentFileSize; } } sb.AppendLine("Asset Name : " + MyAsset.Name); sb.AppendLine("Asset Type : " + MyAsset.AssetType); sb.AppendLine("Asset Id : " + MyAsset.Id); sb.AppendLine("Alternate ID : " + MyAsset.AlternateId); if (size != -1) sb.AppendLine("Size : " + FormatByteSize(size)); sb.AppendLine("State : " + MyAsset.State); sb.AppendLine("Created (UTC) : " + MyAsset.Created.ToLongDateString() + " " + MyAsset.Created.ToLongTimeString()); sb.AppendLine("Last Modified (UTC) : " + MyAsset.LastModified.ToLongDateString() + " " + MyAsset.LastModified.ToLongTimeString()); sb.AppendLine("Creations Options : " + MyAsset.Options); if (MyAsset.State != AssetState.Deleted) { sb.AppendLine("IsStreamable : " + MyAsset.IsStreamable); sb.AppendLine("SupportsDynEnc : " + MyAsset.SupportsDynamicEncryption); sb.AppendLine("Uri : " + MyAsset.Uri.AbsoluteUri); sb.AppendLine(""); sb.AppendLine("Storage Name : " + MyAsset.StorageAccountName); sb.AppendLine("Storage Bytes used : " + FormatByteSize(MyAsset.StorageAccount.BytesUsed)); sb.AppendLine("Storage IsDefault : " + MyAsset.StorageAccount.IsDefault); sb.AppendLine(""); foreach (IAsset p_asset in MyAsset.ParentAssets) { sb.AppendLine("Parent asset Name : " + p_asset.Name); sb.AppendLine("Parent asset Id : " + p_asset.Id); } sb.AppendLine(""); foreach (IContentKey key in MyAsset.ContentKeys) { sb.AppendLine("Content key : " + key.Name); sb.AppendLine("Content key Id : " + key.Id); sb.AppendLine("Content key Type : " + key.ContentKeyType); } sb.AppendLine(""); foreach (var pol in MyAsset.DeliveryPolicies) { sb.AppendLine("Deliv policy Name : " + pol.Name); sb.AppendLine("Deliv policy Id : " + pol.Id); sb.AppendLine("Deliv policy Type : " + pol.AssetDeliveryPolicyType); sb.AppendLine("Deliv pol Protocol : " + pol.AssetDeliveryProtocol); } sb.AppendLine(""); foreach (IAssetFile fileItem in MyAsset.AssetFiles) { if (fileItem.IsPrimary) sb.AppendLine("Primary"); sb.AppendLine("Name : " + fileItem.Name); sb.AppendLine("Id : " + fileItem.Id); sb.AppendLine("File size : " + fileItem.ContentFileSize + " Bytes"); sb.AppendLine("Mime type : " + fileItem.MimeType); sb.AppendLine("Init vector : " + fileItem.InitializationVector); sb.AppendLine("Created : " + fileItem.Created); sb.AppendLine("Last modified : " + fileItem.LastModified); sb.AppendLine("Encrypted : " + fileItem.IsEncrypted); sb.AppendLine("EncryptionScheme : " + fileItem.EncryptionScheme); sb.AppendLine("EncryptionVersion : " + fileItem.EncryptionVersion); sb.AppendLine("Encryption key id : " + fileItem.EncryptionKeyId); sb.AppendLine("InitializationVector : " + fileItem.InitializationVector); sb.AppendLine("ParentAssetId : " + fileItem.ParentAssetId); sb.AppendLine("=============="); sb.AppendLine(""); } sb.Append(GetDescriptionLocators(MyAsset, SelectedSE)); } sb.AppendLine(""); sb.AppendLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); sb.AppendLine(""); return sb; }
private void DoLoadTelemetry(IStreamingEndpoint streamingEndpoint, bool showErrors) { if (_firsttime) { dataGridViewTelemetry.ColumnCount = 9; dataGridViewTelemetry.Columns[0].HeaderText = "ObservedTime"; dataGridViewTelemetry.Columns[1].HeaderText = "BytesSent"; dataGridViewTelemetry.Columns[2].HeaderText = "EndToEndLatency"; dataGridViewTelemetry.Columns[3].HeaderText = "HostName"; dataGridViewTelemetry.Columns[4].HeaderText = "RequestCount"; dataGridViewTelemetry.Columns[5].HeaderText = "ResultCode"; dataGridViewTelemetry.Columns[6].HeaderText = "RowKey"; dataGridViewTelemetry.Columns[7].HeaderText = "ServerLatency"; dataGridViewTelemetry.Columns[8].HeaderText = "StatusCode"; statusCodeCol = 8; labelTelemetryUI.Text = string.Format("Telemetry for Streaming Endpoint '{0}'", streamingEndpoint.Name); dataGridViewTelemetry.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; _firsttime = false; } dataGridViewTelemetry.Rows.Clear(); var monitorconfig = _context.MonitoringConfigurations.FirstOrDefault(); if (monitorconfig == null) { return; } var currentConfig = _context.NotificationEndPoints.Where(n => n.Id == monitorconfig.NotificationEndPointId).FirstOrDefault(); if (currentConfig == null) { return; } try { var telemetry = streamingEndpoint.GetTelemetry(); var res = telemetry.GetStreamingEndpointRequestLogs(_timerangeStart, _timerangeEnd ?? DateTime.UtcNow.AddMinutes(5)); /* * // Get some streaming endpoint metrics. * var res = _context.StreamingEndpoints.FirstOrDefault().GetTelemetry( .stre.StreamingEndPointRequestLogs.GetStreamingEndPointMetrics( * currentConfig.EndPointAddress, * _storagePassword, * new Guid(_credentials.AccountId).ToString(), * streamingEndpoint.Id, * _timerangeStart, * _timerangeEnd ?? DateTime.UtcNow.AddMinutes(5) * ); */ foreach (var log in res.OrderByDescending(l => l.ObservedTime)) { if (!showErrors || (showErrors && (log.StatusCode >= 400))) { dataGridViewTelemetry.Rows.Add( radioButtonLocal.Checked ? log.ObservedTime.ToLocalTime() : log.ObservedTime.ToUniversalTime(), log.BytesSent, log.EndToEndLatency, log.HostName, log.RequestCount, log.ResultCode, log.RowKey, log.ServerLatency, log.StatusCode); } } } catch (Exception ex) { MessageBox.Show("Error when accessing to telemetry.\n\n" + ex.Message); _storagePassword = ""; if (boolSavedStoragePassword) { _credentials.DefaultStorageKey = ""; } } }
private async Task<IOperation> ScaleStreamingEndpoint(IStreamingEndpoint myO, int unit) { IOperation operation = null; if (myO != null) { try { TextBoxLogWriteLine("Streaming endpoint '{0}' : scaling to {1} unit(s)...", myO.Name, unit.ToString()); operation = await myO.SendScaleOperationAsync(unit); while (operation.State == OperationState.InProgress) { //refresh the operation operation = _context.Operations.GetOperation(operation.Id); System.Threading.Thread.Sleep(1000); } if (operation.State == OperationState.Succeeded) { TextBoxLogWriteLine("Streaming endpoint '{0}': scaled.", myO.Name); } else { TextBoxLogWriteLine("Streaming endpoint '{0}' : did NOT scale. (Error {1})", myO.Name, operation.ErrorCode, true); TextBoxLogWriteLine("Error message : {0}", operation.ErrorMessage, true); } dataGridViewStreamingEndpointsV.BeginInvoke(new Action(() => dataGridViewStreamingEndpointsV.RefreshStreamingEndpoint(myO)), null); } catch (Exception ex) { TextBoxLogWriteLine("Streaming endpoint '{0}' : Error when scaling. {1}", myO.Name, Program.GetErrorMessage(ex), true); } } return operation; }