Example #1
0
 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
         });
     }
 }
Example #2
0
 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
         });
     }
 }
Example #3
0
        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));
        }
Example #4
0
        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));
        }
Example #5
0
        public LiveEvent UpdateLiveEvent(string eventName, string eventDescription, string eventTags,
                                         LiveEventEncodingType encodingType, string encodingPresetName,
                                         string keyFrameIntervalDuration, CrossSiteAccessPolicies crossSiteAccessPolicies)
        {
            MediaService mediaService = _media.Mediaservices.Get(MediaAccount.ResourceGroupName, MediaAccount.Name);
            LiveEvent    liveEvent    = new LiveEvent()
            {
                Description = eventDescription,
                //Tags = GetCorrelationData(eventTags, false),
                CrossSiteAccessPolicies = crossSiteAccessPolicies,
                Location = mediaService.Location
            };

            liveEvent.Encoding = new LiveEventEncoding()
            {
                EncodingType = encodingType,
                PresetName   = encodingPresetName
            };
            liveEvent.Input = new LiveEventInput()
            {
                KeyFrameIntervalDuration = keyFrameIntervalDuration
            };
            return(_media.LiveEvents.Update(MediaAccount.ResourceGroupName, MediaAccount.Name, eventName, liveEvent));
        }
Example #6
0
 public JsonResult UpdateEvent(string eventName, string eventDescription, string eventTags, LiveEventEncodingType encodingType, string encodingPresetName,
                               string keyFrameIntervalDuration, CrossSiteAccessPolicies crossSiteAccessPolicies)
 {
     try
     {
         LiveEvent liveEvent;
         string    authToken = HomeController.GetAuthToken(Request, Response);
         using (MediaClient mediaClient = new MediaClient(authToken))
         {
             liveEvent = mediaClient.UpdateLiveEvent(eventName, eventDescription, eventTags, encodingType, encodingPresetName, keyFrameIntervalDuration, crossSiteAccessPolicies);
         }
         return(Json(liveEvent));
     }
     catch (ApiErrorException ex)
     {
         return(new JsonResult(ex.Response.Content)
         {
             StatusCode = (int)ex.Response.StatusCode
         });
     }
 }