Esempio n. 1
0
 /// <summary>
 /// Handler for the wrapped media sink object's IncomingConnectionEvent. Expose the wrapped event to
 /// listeners as own IncomingConnectionArrived event.
 /// </summary>
 private void mediaSink_IncomingConnectionEvent(StspMediaSink sender, IncomingConnectionEventArgs args)
 {
     if (IncomingConnectionArrived != null && forwardEvents)
     {
         IncomingConnectionArrived(sender, args);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Starts media recording asynchronously
        /// </summary>
        /// <param name="encodingProfile">
        /// Encoding profile used for the recording session
        /// </param>
        public async Task StartRecordingAsync(MediaEncodingProfile encodingProfile)
        {
            try
            {
                // We cannot start recording twice.
                if (mediaSink != null && recordingStarted)
                {
                    throw new InvalidOperationException("Recording already started.");
                }

                // Release sink if there is one already.
                CleanupSink();

                // Create new sink
                mediaSink = new StspMediaSink();
                mediaSink.IncomingConnectionEvent += mediaSink_IncomingConnectionEvent;

                await mediaSink.InitializeAsync(encodingProfile.Audio, encodingProfile.Video);

                await mediaCapture.StartRecordToCustomSinkAsync(encodingProfile, mediaSink);

                recordingStarted = true;
            }
            catch (Exception e)
            {
                CleanupSink();
                throw e;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Cleans up the resources.
 /// </summary>
 private void CleanupSink()
 {
     if (mediaSink != null)
     {
         mediaSink.IncomingConnectionEvent -= mediaSink_IncomingConnectionEvent;
         mediaSink.Close();
         mediaSink = null;
         recordingStarted = false;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Cleans up the resources.
 /// </summary>
 private void CleanupSink()
 {
     if (mediaSink != null)
     {
         mediaSink.IncomingConnectionEvent -= mediaSink_IncomingConnectionEvent;
         mediaSink.Close();
         mediaSink        = null;
         recordingStarted = false;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Handler for the wrapped media sink object's IncomingConnectionEvent. Expose the wrapped event to
 /// listeners as own IncomingConnectionArrived event.
 /// </summary>
 private void mediaSink_IncomingConnectionEvent(StspMediaSink sender, IncomingConnectionEventArgs args)
 {
     if (IncomingConnectionArrived != null && forwardEvents) IncomingConnectionArrived(sender, args);
 }
Esempio n. 6
0
        /// <summary>
        /// Starts media recording asynchronously
        /// </summary>
        /// <param name="encodingProfile">
        /// Encoding profile used for the recording session
        /// </param>
        public async Task StartRecordingAsync(MediaEncodingProfile encodingProfile)
        {
            try
            {
                // We cannot start recording twice.
                if (mediaSink != null && recordingStarted)
                {
                    throw new InvalidOperationException("Recording already started.");
                }

                // Release sink if there is one already.
                CleanupSink();

                // Create new sink
                mediaSink = new StspMediaSink();
                mediaSink.IncomingConnectionEvent += mediaSink_IncomingConnectionEvent;

                await mediaSink.InitializeAsync(encodingProfile.Audio, encodingProfile.Video);
                await mediaCapture.StartRecordToCustomSinkAsync(encodingProfile, mediaSink);

                recordingStarted = true;
            }
            catch (Exception e)
            {
                CleanupSink();
                throw e;
            }
        }