Exemplo n.º 1
0
        private async void btnPublish_Checked(object sender, RoutedEventArgs e)
        {
            try
            {
                await ApplyTargetChannels();

                //RTMP Publish specific Code

                var inputprof = _deviceManager.GetInputProfile();

                _publishsession = new RTMPPublishSession(_deviceManager.PublishProfiles);

                //handle events (if needed)
                _publishsession.PublishFailed += OnPublishFailed;
                _publishsession.SessionClosed += OnSessionClosed;
                //get the sink
                var sink = await _publishsession.GetCaptureSinkAsync();

                if (_deviceManager.EnableLowLatency)
                {
                    _lowlagCapture = await _deviceManager.CurrentCapture.PrepareLowLagRecordToCustomSinkAsync(inputprof, sink);

                    await _lowlagCapture.StartAsync();
                }
                else
                {
                    await _deviceManager.CurrentCapture.StartRecordToCustomSinkAsync(inputprof, sink);
                }


                if (_displayRequest == null)
                {
                    _displayRequest = new DisplayRequest();
                    _displayRequest.RequestActive();
                }
                _deviceManager.IsPublishing = true;


                sessionduration = TimeSpan.FromSeconds(0);
                _clockTimer     = new Timer(new TimerCallback((o) =>
                {
                    this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        sessionduration = sessionduration.Add(TimeSpan.FromMilliseconds(500));
                        tbClock.Text    = sessionduration.ToString(@"hh\:mm\:ss\:fff");
                    });
                }), null, 0, 500);
            }
            catch (Exception Ex)
            {
            }
        }
Exemplo n.º 2
0
 private async void OnSessionClosed(RTMPPublishSession sender, SessionClosedEventArgs args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() =>
     {
         try
         {
             if (_deviceManager.History != null)
             {
                 _deviceManager.AddIngestURLToHistory(_deviceManager.PublishProfiles[0].EndpointUri, "AZURE", args.LastVideoTimestamp, args.LastAudioTimestamp);
             }
         }
         catch
         {
         }
     }));
 }
Exemplo n.º 3
0
 private async void OnPublishFailed(RTMPPublishSession sender, FailureEventArgs args)
 {
     return;
 }