Пример #1
0
        /// <summary>
        /// Gets a blank video frame which can be filled with video data and passed
        /// to the encoder.
        /// </summary>
        /// <returns>Error code</returns>
        public PPError GetVideoFrame()
        {
            var OnEncoderFrameCallback = new CompletionCallbackWithOutput <PPResource>(OnVideoFrame);

            return((PPError)PPBVideoEncoder.GetVideoFrame(this,
                                                          out OnEncoderFrameCallback.OutputAdapter.output,
                                                          OnEncoderFrameCallback.Callback));
        }
Пример #2
0
        /// <summary>
        // Gets a free frame for output. The frame is allocated by
        // <code>Configure()</code>. The caller should fill it with frame data, and
        // then use |PutFrame()| to send the frame back.
        /// </summary>
        /// <returns>Error code</returns>
        public PPError GetEmptyFrame()
        {
            var action = new Action <PPError, PPResource>((result, resource) =>
            {
                OnGetEmptyFrame(new VideoFrameInfo(result, resource));
            });
            var callback = new CompletionCallbackWithOutput <PPResource>(new CompletionCallbackWithOutputFunc <PPResource>(action));

            return((PPError)PPBMediaStreamVideoTrack.GetEmptyFrame(this, out callback.OutputAdapter.output, callback));
        }
Пример #3
0
        /// <summary>
        /// Gets the next audio buffer from the MediaStream track.
        /// If internal processing is slower than the incoming buffer rate,
        /// new buffers will be dropped from the incoming stream. Once all buffers
        /// are full, audio samples will be dropped until <code>RecycleBuffer()</code>
        /// is called to free a spot for another buffer.
        /// If there are no audio data in the input buffer,
        /// <code>CompletionPending</code> will be returned immediately and the
        /// <code>HandleBuffer</code> event handler will be called when a new buffer of audio samples
        /// is received or some error happens.
        /// </summary>
        /// <returns>Error code</returns>
        public PPError GetBuffer()
        {
            var action = new Action <PPError, PPResource>(
                (result, resource) =>
            {
                OnGetBuffer(new AudioBufferInfo(result, resource));
            }
                );
            var callback = new CompletionCallbackWithOutput <PPResource>(new CompletionCallbackWithOutputFunc <PPResource>(action));

            return((PPError)PPBMediaStreamAudioTrack.GetBuffer(this, out callback.OutputAdapter.output, callback));
        }
Пример #4
0
        /// <summary>
        /// Returns objects that describe the network interfaces.
        /// </summary>
        /// <returns>Error code</returns>
        public PPError UpdateNetworkList()
        {
            Action <PPError, PPResource> callback = new Action <PPError, PPResource>(
                (result, resource) =>
            {
                OnUpdateNetworkList(result, new NetworkList(resource));
            }
                );

            var onUpdateNetworkListCallback = new CompletionCallbackWithOutput <PPResource>(new CompletionCallbackWithOutputFunc <PPResource>(callback));

            return((PPError)PPBNetworkMonitor.UpdateNetworkList(this, out onUpdateNetworkListCallback.OutputAdapter.output, onUpdateNetworkListCallback));
        }
Пример #5
0
        /// <summary>
        /// Retrieves the proxy that will be used for the given URL. The result will
        /// be a string in PAC format. For more details about PAC format, please see
        /// http://en.wikipedia.org/wiki/Proxy_auto-config
        /// </summary>
        /// <param name="instance">An <code>InstanceHandle</code> identifying one
        /// instance of a module.</param>
        /// <param name="url">A string containing a URL.</param>
        /// <returns>Error code</returns>
        public static PPError GetProxyForURL(Instance instance, string url)
        {
            var cbwoAction = new Action <PPError, PPVar>(
                (result, proxy) =>
            {
                HandleProxyForUrl?.Invoke(instance, new ProxyInfo(result, ((Var)proxy).AsString()));
            }

                );

            var cbwo = new CompletionCallbackWithOutput <PPVar>(new CompletionCallbackWithOutputFunc <PPVar>(cbwoAction));

            return((PPError)PPBNetworkProxy.GetProxyForURL(instance, new Var(url), out cbwo.OutputAdapter.output, cbwo));
        }
Пример #6
0
        /// <summary>
        /// Read() reads from an offset in the file.  A PP_ArrayOutput must be
        /// provided so that output will be stored in its allocated buffer.  This
        /// function might perform a partial read.
        /// </summary>
        /// <param name="buffer">An ArraySegment<byte> to hold the specified number of bytes read.</param>
        /// <param name="offset">The offset into the file.</param>
        /// <param name="bytesToRead">The number of bytes to read from <code>offset</code>.</param>
        /// <returns>Error code.  If the return value is 0, then end-of-file was reached.</returns>
        public PPError Read(ArraySegment <byte> buffer, int offset, int bytesToRead)
        {
            var readToArrayAction = new Action <PPError, byte[]>(
                (result, bytes) =>
            {
                Array.Copy(bytes, buffer.Array, Math.Min(bytes.Length, buffer.Count));
                OnReadData(result);
            }

                );

            var arrayOutput = new CompletionCallbackWithOutput <byte[]>(new CompletionCallbackWithOutputFunc <byte[]>(readToArrayAction));

            return((PPError)PPBFileIO.ReadToArray(this, offset, bytesToRead, ref arrayOutput.ArrayOutput, arrayOutput));
        }
Пример #7
0
        /// <summary>
        /// Gets an array of supported video encoder profiles.
        /// These can be used to choose a profile before calling Initialize().
        /// </summary>
        /// <returns>If >= 0, the number of supported profiles returned, otherwise an
        /// error code.
        /// </returns>
        public PPError GetSupportedProfiles()
        {
            var probed = new Action <PPError, PPVideoProfileDescription01[]>
                             ((result, profiles) =>
            {
                var sv = new List <VideoProfileDescription>();
                if (profiles != null)
                {
                    for (int i = 0; i < profiles.Length; ++i)
                    {
                        sv.Add(new VideoProfileDescription(profiles[i]));
                    }
                }

                OnEncoderProbed(result, sv.AsReadOnly());
            });
            var encoderProbedCallback = new CompletionCallbackWithOutput <PPVideoProfileDescription01[]>(new CompletionCallbackWithOutputFunc <PPVideoProfileDescription01[]>(probed));

            return((PPError)PPBVideoEncoder.GetSupportedProfiles(this, encoderProbedCallback, encoderProbedCallback.Callback));
        }
Пример #8
0
        /// <summary>
        /// Query() queries info about the file opened by this FileIO object. This
        /// function will fail if the FileIO object has not been opened.
        /// </summary>
        /// <returns>Error code</returns>
        public PPError Query()
        {
            var ficb = new CompletionCallbackWithOutput <PPFileInfo>(OnQuery);

            return((PPError)PPBFileIO.Query(this, out ficb.OutputAdapter.output, ficb));
        }
Пример #9
0
        /// <summary>
        /// ReadDirectoryEntries() Reads all entries in the directory.
        /// </summary>
        /// <returns>Error code.</returns>
        PPError ReadDirectoryEntries()
        {
            var listCallback = new CompletionCallbackWithOutput <PPDirectoryEntry[], PPResource>(ListCallback, this);

            return((PPError)PPBFileRef.ReadDirectoryEntries(this, listCallback, listCallback));
        }
Пример #10
0
        /// <summary>
        /// Gets the next encoded bitstream buffer from the encoder.
        /// </summary>
        /// <returns>Returns Failed if Initialize() has not successfully completed.
        /// Returns InProgress if a prior call to GetBitstreamBuffer() has
        /// not completed.</returns>
        public PPError GetBitstreamBuffer()
        {
            var callback = new CompletionCallbackWithOutput <PPBitstreamBuffer>(OnBitstreamBuffer);

            return((PPError)PPBVideoEncoder.GetBitstreamBuffer(this, out callback.OutputAdapter.output, callback));
        }