public JsonResult CreateEvent(string eventName, string eventDescription, string eventTags, string inputStreamId, LiveEventInputProtocol inputProtocol, LiveEventEncodingType encodingType, string encodingPresetName, string streamingPolicyName, bool lowLatency, bool autoStart) { try { LiveEvent liveEvent; string authToken = HomeController.GetAuthToken(Request, Response); using (MediaClient mediaClient = new MediaClient(authToken)) { liveEvent = mediaClient.CreateLiveEvent(eventName, eventDescription, eventTags, inputStreamId, inputProtocol, encodingType, encodingPresetName, streamingPolicyName, lowLatency, autoStart); } return(Json(liveEvent)); } catch (ValidationException ex) { Error error = new Error() { Type = HttpStatusCode.BadRequest, Message = ex.Message }; return(new JsonResult(error) { StatusCode = (int)error.Type }); } catch (ApiErrorException ex) { return(new JsonResult(ex.Response.Content) { StatusCode = (int)ex.Response.StatusCode }); } }
public LiveEvent CreateLiveEvent(string eventName, string eventDescription, string eventTags, string inputStreamId, LiveEventInputProtocol inputProtocol, LiveEventEncodingType encodingType, string encodingPresetName, string streamingPolicyName, bool lowLatency, bool autoStart) { LiveEventInput eventInput = new LiveEventInput() { AccessToken = inputStreamId, StreamingProtocol = inputProtocol, AccessControl = new LiveEventInputAccessControl() { Ip = new IPAccessControl() { Allow = new IPRange[] { new IPRange() { Name = "Any IP Address", Address = "0.0.0.0", SubnetPrefixLength = 0 } } } } }; LiveEventEncoding eventEncoding = new LiveEventEncoding() { EncodingType = encodingType, PresetName = encodingPresetName }; LiveEventPreview eventPreview = new LiveEventPreview() { PreviewLocator = inputStreamId, StreamingPolicyName = streamingPolicyName }; List <StreamOptionsFlag?> streamOptions = new List <StreamOptionsFlag?>(); if (lowLatency) { streamOptions.Add(StreamOptionsFlag.LowLatency); } else { streamOptions.Add(StreamOptionsFlag.Default); } MediaService mediaService = _media.Mediaservices.Get(MediaAccount.ResourceGroupName, MediaAccount.Name); LiveEvent liveEvent = new LiveEvent() { VanityUrl = true, Description = eventDescription, //Tags = GetCorrelationData(eventTags, false), Input = eventInput, Encoding = eventEncoding, Preview = eventPreview, StreamOptions = streamOptions, Location = mediaService.Location }; return(_media.LiveEvents.Create(MediaAccount.ResourceGroupName, MediaAccount.Name, eventName, liveEvent, autoStart)); }
public JsonResult CreateEvent(string eventName, string eventDescription, string eventTags, LiveEventInputProtocol inputProtocol = LiveEventInputProtocol.FragmentedMP4, LiveEventEncodingType encodingType = LiveEventEncodingType.None, string encodingPresetName = null, string streamingPolicyName = null, bool lowLatency = false, bool autoStart = false) { try { LiveEvent liveEvent; string authToken = HomeController.GetAuthToken(Request, Response); using (MediaClient mediaClient = new MediaClient(authToken)) { liveEvent = mediaClient.CreateLiveEvent(eventName, eventDescription, eventTags, inputProtocol, encodingType, encodingPresetName, streamingPolicyName, lowLatency, autoStart); string eventOutputName = string.Concat(eventName, Constant.Media.LiveEvent.OutputNameSuffix); string eventOutputAssetName = string.Concat(eventName, Constant.Media.LiveEvent.OutputAssetNameSuffix); CreateOutput(eventName, eventOutputName, null, eventOutputAssetName, Constant.Media.LiveEvent.OutputArchiveWindowMinutes); } return(Json(liveEvent)); } catch (ApiErrorException ex) { return(new JsonResult(ex.Response.Content) { StatusCode = (int)ex.Response.StatusCode }); } }
public LiveEvent CreateLiveEvent(string eventName, string eventDescription, string eventTags, LiveEventInputProtocol inputProtocol, LiveEventEncodingType encodingType, string encodingPresetName, string streamingPolicyName, bool lowLatency, bool autoStart) { LiveEventInput eventInput = new LiveEventInput() { StreamingProtocol = inputProtocol }; LiveEventEncoding eventEncoding = new LiveEventEncoding() { EncodingType = encodingType, PresetName = encodingPresetName }; LiveEventPreview eventPreview = new LiveEventPreview() { StreamingPolicyName = streamingPolicyName }; List <StreamOptionsFlag?> streamOptions = new List <StreamOptionsFlag?>(); if (lowLatency) { streamOptions.Add(StreamOptionsFlag.LowLatency); } MediaService mediaService = _media.Mediaservices.Get(MediaAccount.ResourceGroupName, MediaAccount.Name); LiveEvent liveEvent = new LiveEvent() { VanityUrl = true, Description = eventDescription, Tags = GetDataItems(eventTags), Input = eventInput, Encoding = eventEncoding, Preview = eventPreview, StreamOptions = streamOptions, Location = mediaService.Location }; return(_media.LiveEvents.Create(MediaAccount.ResourceGroupName, MediaAccount.Name, eventName, liveEvent, autoStart)); }