/// <summary> /// Create streaming endpoint data from the creation options. /// </summary> /// <param name="options">Streaming endpoint creation options.</param> /// <returns></returns> internal StreamingEndpointData(StreamingEndpointCreationOptions options) { Name = options.Name; Description = options.Description; ScaleUnits = options.ScaleUnits; CdnEnabled = options.CdnEnabled; CdnProfile = options.CdnProfile; CdnProvider = options.CdnProvider.ToString(); StreamingEndpointVersion = options.StreamingEndpointVersion == null ? StreamingEndpointCreationOptions.DefaultVersion.ToString() : options.StreamingEndpointVersion.ToString(); CrossSiteAccessPolicies = options.CrossSiteAccessPolicies; if (options.CustomHostNames != null) { CustomHostNames = (options.CustomHostNames as IList <string>) ?? options.CustomHostNames.ToList(); } _accessControl = options.AccessControl; _cacheControl = options.CacheControl; ValidateSettings(); }
/// <summary> /// Creates a new streaming endpoint asynchronously. /// </summary> /// <param name="options">Streaming endpoint creation options</param> /// <returns>The streaming endpoint creation task.</returns> public Task <IStreamingEndpoint> CreateAsync(StreamingEndpointCreationOptions options) { var response = CreateStreamingEndpointAsync(options); return(response.ContinueWith <IStreamingEndpoint>(t => { t.ThrowIfFaulted(); string operationId = t.Result.Single().Headers[StreamingConstants.OperationIdHeader]; IOperation operation = AsyncHelper.WaitOperationCompletion( MediaContext, operationId, StreamingConstants.CreateStreamingEndpointPollInterval); string messageFormat = Resources.ErrorCreateStreamingEndpointFailedFormat; string message; switch (operation.State) { case OperationState.Succeeded: var result = (StreamingEndpointData)t.Result.AsyncState; result.Refresh(); return result; case OperationState.Failed: message = string.Format(CultureInfo.CurrentCulture, messageFormat, Resources.Failed, operationId, operation.ErrorMessage); throw new InvalidOperationException(message); default: // can never happen unless state enum is extended message = string.Format(CultureInfo.CurrentCulture, messageFormat, Resources.InInvalidState, operationId, operation.State); throw new InvalidOperationException(message); } })); }
private Task <IMediaDataServiceResponse> CreateStreamingEndpointAsync(StreamingEndpointCreationOptions options) { if (options == null) { throw new ArgumentNullException("options"); } if (string.IsNullOrEmpty(options.Name)) { throw new ArgumentException(Resources.ErrorEmptyStreamingEndpointName); } var streamingEndpoint = new StreamingEndpointData { Name = options.Name, Description = options.Description, ScaleUnits = options.ScaleUnits, CrossSiteAccessPolicies = options.CrossSiteAccessPolicies }; if (options.CustomHostNames != null) { streamingEndpoint.CustomHostNames = (options.CustomHostNames as IList <string>) ?? options.CustomHostNames.ToList(); } ((IStreamingEndpoint)streamingEndpoint).AccessControl = options.AccessControl; ((IStreamingEndpoint)streamingEndpoint).CacheControl = options.CacheControl; streamingEndpoint.ValidateSettings(); streamingEndpoint.SetMediaContext(MediaContext); IMediaDataServiceContext dataContext = MediaContext.MediaServicesClassFactory.CreateDataServiceContext(); dataContext.AddObject(StreamingEndpointSet, streamingEndpoint); MediaRetryPolicy retryPolicy = MediaContext.MediaServicesClassFactory.GetSaveChangesRetryPolicy(dataContext as IRetryPolicyAdapter); return(retryPolicy.ExecuteAsync(() => dataContext.SaveChangesAsync(streamingEndpoint))); }
/// <summary> /// Sends create streaming endpoint operation to the service asynchronously. Use Operations collection to get operation's status. /// </summary> /// <param name="options">Streaming endpoint creation options</param> /// <returns>Task to wait on for operation sending completion.</returns> public Task <IOperation> SendCreateOperationAsync(StreamingEndpointCreationOptions options) { var response = CreateStreamingEndpointAsync(options); return(response.ContinueWith(t => { t.ThrowIfFaulted(); string operationId = t.Result.Single().Headers[StreamingConstants.OperationIdHeader]; IOperation result = new OperationData { ErrorCode = null, ErrorMessage = null, Id = operationId, State = OperationState.InProgress.ToString(), }; return result; })); }
private Task <IMediaDataServiceResponse> CreateStreamingEndpointAsync(StreamingEndpointCreationOptions options) { if (options == null) { throw new ArgumentNullException("options"); } if (string.IsNullOrEmpty(options.Name)) { throw new ArgumentException(Resources.ErrorEmptyStreamingEndpointName); } var streamingEndpoint = new StreamingEndpointData(options); streamingEndpoint.SetMediaContext(MediaContext); IMediaDataServiceContext dataContext = MediaContext.MediaServicesClassFactory.CreateDataServiceContext(); dataContext.AddObject(StreamingEndpointSet, streamingEndpoint); MediaRetryPolicy retryPolicy = MediaContext.MediaServicesClassFactory.GetSaveChangesRetryPolicy(dataContext as IRetryPolicyAdapter); return(retryPolicy.ExecuteAsync(() => dataContext.SaveChangesAsync(streamingEndpoint))); }
public static IStreamingEndpoint CreateStreamingEndpoint(string aStreamingEndPointName) { var options = new StreamingEndpointCreationOptions { Name = aStreamingEndPointName, ScaleUnits = 1, AccessControl = GetAccessControl(), CacheControl = GetCacheControl() }; IStreamingEndpoint streamingEndpoint = _context.StreamingEndpoints.Create(options); //TODO: remove following line to just create endpoint streamingEndpoint.Start(); return streamingEndpoint; }
private async void DoCreateStreamingEndpoint() { CreateStreamingEndpoint form = new CreateStreamingEndpoint() { scaleUnits = 1 }; if (form.ShowDialog() == DialogResult.OK) { TextBoxLogWriteLine("Creating streaming endpoint {0}...", form.StreamingEndpointName); var options = new StreamingEndpointCreationOptions() { Name = form.StreamingEndpointName, ScaleUnits = form.scaleUnits, Description = form.StreamingEndpointDescription, CdnEnabled = form.EnableAzureCDN }; await Task.Run(() => IObjectExecuteOperationAsync( () => _context.StreamingEndpoints.SendCreateOperationAsync(options), form.StreamingEndpointName, "Streaming Endpoint", "created", _context)); DoRefreshGridStreamingEndpointV(false); } }
/// <summary> /// Creates a new streaming endpoint. /// </summary> /// <param name="options">Streaming endpoint creation options</param> /// <returns>The created streaming endpoint.</returns> public IStreamingEndpoint Create(StreamingEndpointCreationOptions options) { return(AsyncHelper.Wait(CreateAsync(options))); }
/// <summary> /// Sends create streaming endpoint operation to the service and returns. Use Operations collection to get operation's status. /// </summary> /// <param name="options">Streaming endpoint creation options</param> /// <returns>Operation info that can be used to track the operation.</returns> public IOperation SendCreateOperation(StreamingEndpointCreationOptions options) { return(AsyncHelper.Wait(SendCreateOperationAsync(options))); }
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; }
public static IStreamingEndpoint CreateAndStartStreamingEndpoint(CloudMediaContext _context) { var options = new StreamingEndpointCreationOptions { Name = "VidManLiveStreamingEndpoint", ScaleUnits = 1, AccessControl = GetAccessControl(), CacheControl = GetCacheControl() }; IStreamingEndpoint streamingEndpoint = _context.StreamingEndpoints.Create(options); streamingEndpoint.Start(); return streamingEndpoint; }