Example #1
0
        private async Task <PPError> ConfigureAsyncCore(MediaStreamVideoTrackAttributes attributes, MessageLoop messageLoop = null)
        {
            var tcs = new TaskCompletionSource <PPError>();
            EventHandler <PPError> handler = (s, e) => { tcs.TrySetResult(e); };

            try
            {
                HandleConfigure += handler;

                if (MessageLoop == null && messageLoop == null)
                {
                    Configure(attributes);
                }
                else
                {
                    Action <PPError> action = new Action <PPError>((e) =>
                    {
                        var result = (PPError)PPBMediaStreamVideoTrack.Configure(this, attributes.ToAttributes(),
                                                                                 new BlockUntilComplete()
                                                                                 );
                        tcs.TrySetResult(result);
                    }
                                                                   );

                    InvokeHelper(action, messageLoop);
                }
                return(await tcs.Task);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                tcs.SetException(exc);
                return(PPError.Aborted);
            }
            finally
            {
                HandleConfigure -= handler;
            }
        }
Example #2
0
 /// <summary>
 /// Configures underlying frame buffers for incoming frames asynchronously.
 /// If the application doesn't want to drop frames, then the
 /// <code>BufferedFrames</code> should be
 /// chosen such that inter-frame processing time variability won't overrun the
 /// input buffer. If the buffer is overfilled, then frames will be dropped.
 /// The application can detect this by examining the timestamp on returned
 /// frames. If some attributes are not specified, default values will be used
 /// for those unspecified attributes. If <code>Configure()</code> is not
 /// called, default settings will be used.
 /// Example usage from plugin code:
 /// <code>
 /// var attribList = new MediaStreamVideoTrackAttributes()
 /// {
 ///     BufferedFrames = 4
 /// };
 /// await track.ConfigureAsync(attribList);
 /// </code>
 /// </summary>
 /// <param name="attributes">A MediaStreamVideoTrackAttributes instance</param>
 /// <param name="messageLoop">Optional MessageLoop instance used to run the command on.</param>
 /// <returns>Error code.  Returns <code>InProgress</code> if there is a pending call of
 /// <code>Configure()</code> or <code>GetFrame()</code>, or the plugin
 /// holds some frames which are not recycled with <code>RecycleFrame()</code>.
 /// If an error is returned, all attributes and the underlying buffer will not
 /// be changed.</returns>
 public Task <PPError> ConfigureAsync(MediaStreamVideoTrackAttributes attributes, MessageLoop messageLoop = null)
 => ConfigureAsyncCore(attributes, messageLoop);
Example #3
0
 /// <summary>
 /// Configures underlying frame buffers for incoming frames.
 /// If the application doesn't want to drop frames, then the
 /// <code>BufferedFrames</code> should be
 /// chosen such that inter-frame processing time variability won't overrun the
 /// input buffer. If the buffer is overfilled, then frames will be dropped.
 /// The application can detect this by examining the timestamp on returned
 /// frames. If some attributes are not specified, default values will be used
 /// for those unspecified attributes. If <code>Configure()</code> is not
 /// called, default settings will be used.
 /// Example usage from plugin code:
 /// <code>
 /// var attribList = new MediaStreamVideoTrackAttributes()
 /// {
 ///     BufferedFrames = 4
 /// };
 /// track.Configure(attribList);
 /// </code>
 /// </summary>
 /// <param name="attributes">A MediaStreamVideoTrackAttributes instance</param>
 /// <returns>Error code.  Returns <code>InProgress</code> if there is a pending call of
 /// <code>Configure()</code> or <code>GetFrame()</code>, or the plugin
 /// holds some frames which are not recycled with <code>RecycleFrame()</code>.
 /// If an error is returned, all attributes and the underlying buffer will not
 /// be changed.</returns>
 public PPError Configure(MediaStreamVideoTrackAttributes attributes)
 => (PPError)PPBMediaStreamVideoTrack.Configure(this, attributes.ToAttributes(), new CompletionCallback(OnConfigure));