/**
  * Initializes an audio encoder resource. The plugin should call Initialize()
  * successfully before calling any of the functions below.
  *
  * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
  * encoder.
  * @param[in] channels The number of audio channels to encode.
  * @param[in] input_sampling_rate The sampling rate of the input audio buffer.
  * @param[in] input_sample_size The sample size of the input audio buffer.
  * @param[in] output_profile A <code>PP_AudioProfile</code> specifying the
  * codec profile of the encoded output stream.
  * @param[in] initial_bitrate The initial bitrate for the encoder.
  * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
  * whether to use a hardware accelerated or a software implementation.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion.
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>.
  * Returns PP_ERROR_NOTSUPPORTED if audio encoding is not available, or the
  * requested codec profile is not supported.
  */
 public static int Initialize(PPResource audio_encoder,
                              uint channels,
                              PPAudioBufferSampleRate input_sample_rate,
                              PPAudioBufferSampleSize input_sample_size,
                              PPAudioProfile output_profile,
                              uint initial_bitrate,
                              PPHardwareAcceleration acceleration,
                              PPCompletionCallback callback)
 {
     return(_Initialize(audio_encoder,
                        channels,
                        input_sample_rate,
                        input_sample_size,
                        output_profile,
                        initial_bitrate,
                        acceleration,
                        callback));
 }
Exemple #2
0
        /**
         * Reads data from the socket. The socket must be connected. It may perform a
         * partial read.
         *
         * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
         * socket.
         * @param[out] buffer The buffer to store the received data on success. It
         * must be at least as large as <code>bytes_to_read</code>.
         * @param[in] bytes_to_read The number of bytes to read.
         * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
         * completion.
         *
         * @return A non-negative number on success to indicate how many bytes have
         * been read, 0 means that end-of-file was reached; otherwise, an error code
         * from <code>pp_errors.h</code>.
         */
        public static int Read(PPResource tcp_socket,
                               byte[] buffer,
                               int bytes_to_read,
                               PPCompletionCallback callback)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            unsafe
            {
                fixed(byte *buffer_ = &buffer[0])
                {
                    return(_Read(tcp_socket, (IntPtr)buffer_, bytes_to_read, callback));
                }
            }
        }
Exemple #3
0
        /**
         * Sends data to a specific destination. The socket must be bound.
         *
         * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP
         * socket.
         * @param[in] buffer The buffer containing the data to send.
         * @param[in] num_bytes The number of bytes to send.
         * @param[in] addr A <code>PPB_NetAddress</code> resource holding the
         * destination address.
         * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
         * completion.
         *
         * @return A non-negative number on success to indicate how many bytes have
         * been sent; otherwise, an error code from <code>pp_errors.h</code>.
         * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have
         * required permissions.
         * <code>PP_ERROR_INPROGRESS</code> will be returned if the socket is busy
         * sending. The caller should wait until a pending send completes before
         * retrying.
         */
        public static int SendTo(PPResource udp_socket,
                                 byte[] buffer,
                                 int num_bytes,
                                 PPResource addr,
                                 PPCompletionCallback callback)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            unsafe
            {
                fixed(byte *buffer_ = &buffer[0])
                {
                    return(_SendTo(udp_socket, (IntPtr)buffer_, num_bytes, addr, callback));
                }
            }
        }
Exemple #4
0
        /**
         * Requests resolution of a host name. If the call completes successfully, the
         * results can be retrieved by <code>GetCanonicalName()</code>,
         * <code>GetNetAddressCount()</code> and <code>GetNetAddress()</code>.
         *
         * @param[in] host_resolver A <code>PP_Resource</code> corresponding to a host
         * resolver.
         * @param[in] host The host name (or IP address literal) to resolve.
         * @param[in] port The port number to be set in the resulting network
         * addresses.
         * @param[in] hint A <code>PP_HostResolver_Hint</code> structure providing
         * hints for host resolution.
         * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
         * completion.
         *
         * @return An int32_t containing an error code from <code>pp_errors.h</code>.
         * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have
         * required permissions. <code>PP_ERROR_NAME_NOT_RESOLVED</code> will be
         * returned if the host name couldn't be resolved.
         */
        public static int Resolve(PPResource host_resolver,
                                  byte[] host,
                                  ushort port,
                                  PPHostResolverHint hint,
                                  PPCompletionCallback callback)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            unsafe
            {
                fixed(byte *host_ = &host[0])
                {
                    return(_Resolve(host_resolver, (IntPtr)host_, port, hint, callback));
                }
            }
        }
        /**
         * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's
         * |buffer|. The plugin should wait until the decoder signals completion by
         * returning PP_OK or by running |callback| before calling Decode() again.
         *
         * In general, each bitstream buffer should contain a demuxed bitstream frame
         * for the selected video codec. For example, H264 decoders expect to receive
         * one AnnexB NAL unit, including the 4 byte start code prefix, while VP8
         * decoders expect to receive a bitstream frame without the IVF frame header.
         *
         * If the call to Decode() eventually results in a picture, the |decode_id|
         * parameter is copied into the returned picture. The plugin can use this to
         * associate decoded pictures with Decode() calls (e.g. to assign timestamps
         * or frame numbers to pictures.) This value is opaque to the API so the
         * plugin is free to pass any value.
         *
         * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
         * decoder.
         * @param[in] decode_id An optional value, chosen by the plugin, that can be
         * used to associate calls to Decode() with decoded pictures returned by
         * GetPicture().
         * @param[in] size Buffer size in bytes.
         * @param[in] buffer Starting address of buffer.
         * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
         * completion.
         *
         * @return An int32_t containing an error code from <code>pp_errors.h</code>.
         * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Flush()
         * or Reset() call is pending.
         * Returns PP_ERROR_INPROGRESS if there is another Decode() call pending.
         * Returns PP_ERROR_NOMEMORY if a bitstream buffer can't be created.
         * Returns PP_ERROR_ABORTED when Reset() is called while Decode() is pending.
         */
        public static int Decode(PPResource video_decoder,
                                 uint decode_id,
                                 uint size,
                                 byte[] buffer,
                                 PPCompletionCallback callback)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            unsafe
            {
                fixed(byte *buffer_ = &buffer[0])
                {
                    return(_Decode(video_decoder, decode_id, size, (IntPtr)buffer_,
                                   callback));
                }
            }
        }
Exemple #6
0
        /**
         * Write() writes to an offset in the file.  This function might perform a
         * partial write. The FileIO object must have been opened with write access.
         *
         * @param[in] file_io A <code>PP_Resource</code> corresponding to a file
         * FileIO.
         * @param[in] offset The offset into the file.
         * @param[in] buffer The buffer to hold the specified number of bytes read.
         * @param[in] bytes_to_write The number of bytes to write to
         * <code>offset</code>.
         * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
         * completion of Write().
         *
         * @return The number of bytes written or an error code from
         * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was
         * reached. It is valid to call Write() multiple times with a completion
         * callback to queue up parallel writes to the file, but pending writes
         * cannot be interleaved with other operations.
         */
        public static int Write(PPResource file_io,
                                long offset,
                                byte[] buffer,
                                int bytes_to_write,
                                PPCompletionCallback callback)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            unsafe
            {
                fixed(byte *buffer_ = &buffer[0])
                {
                    return(_Write(file_io, offset, (IntPtr)buffer_,
                                  bytes_to_write,
                                  callback));
                }
            }
        }
 internal CompletionCallback(PPCompletionCallbackFunc callbackFunc, object userData = null, PPCompletionCallbackFlag flags = PPCompletionCallbackFlag.None)
 {
     this.callbackFunc = callbackFunc;
     // if no callbackfunc is specified then
     if (callbackFunc != null)
     {
         if (userData == null)
         {
             this.userData = IntPtr.Zero;
         }
         else
         {
             GCHandle userDataHandle = GCHandle.Alloc(userData, GCHandleType.Normal);
             this.userData = (IntPtr)userDataHandle;
         }
         var ourCallback = new PPCompletionCallback();
         ourCallback.func  = OnCallBack;
         ourCallback.flags = (int)PPCompletionCallbackFlag.None;
         GCHandle userHandle = GCHandle.Alloc(this, GCHandleType.Normal);
         ourCallback.user_data = (IntPtr)userHandle;
         Callback = ourCallback;
     }
 }
Exemple #8
0
 /**
  * Binds the socket to the given address. The socket must not be bound.
  *
  * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
  * socket.
  * @param[in] addr A <code>PPB_NetAddress</code> resource.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion.
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>,
  * including (but not limited to):
  * - <code>PP_ERROR_ADDRESS_IN_USE</code>: the address is already in use.
  * - <code>PP_ERROR_ADDRESS_INVALID</code>: the address is invalid.
  */
 public static int Bind(PPResource tcp_socket,
                        PPResource addr,
                        PPCompletionCallback callback)
 {
     return(_Bind(tcp_socket, addr, callback));
 }
Exemple #9
0
 extern static void _CallOnMainThread(int delay_in_milliseconds,
                                      PPCompletionCallback callback,
                                      int result);
Exemple #10
0
 /**
  * CallOnMainThread() schedules work to be executed on the main module thread
  * after the specified delay. The delay may be 0 to specify a call back as
  * soon as possible.
  *
  * The <code>result</code> parameter will just be passed as the second
  * argument to the callback. Many applications won't need this, but it allows
  * a module to emulate calls of some callbacks which do use this value.
  *
  * <strong>Note:</strong> CallOnMainThread, even when used from the main
  * thread with a delay of 0 milliseconds, will never directly invoke the
  * callback.  Even in this case, the callback will be scheduled
  * asynchronously.
  *
  * <strong>Note:</strong> If the browser is shutting down or if the module
  * has no instances, then the callback function may not be called.
  *
  * @param[in] delay_in_milliseconds An int32_t delay in milliseconds.
  * @param[in] callback A <code>PP_CompletionCallback</code> callback function
  * that the browser will call after the specified delay.
  * @param[in] result An int32_t that the browser will pass to the given
  * <code>PP_CompletionCallback</code>.
  */
 public static void CallOnMainThread(int delay_in_milliseconds,
                                     PPCompletionCallback callback,
                                     int result)
 {
     _CallOnMainThread(delay_in_milliseconds, callback, result);
 }
 extern static int _Configure(PPResource audio_track,
                              int[] attrib_list,
                              PPCompletionCallback callback);
Exemple #12
0
 extern static int _Read(PPResource tcp_socket,
                         IntPtr buffer,
                         int bytes_to_read,
                         PPCompletionCallback callback);
Exemple #13
0
 extern static int _Write(PPResource tcp_socket,
                          IntPtr buffer,
                          int bytes_to_write,
                          PPCompletionCallback callback);
Exemple #14
0
 extern static int _Open(PPResource file_system,
                         long expected_size,
                         PPCompletionCallback callback);
Exemple #15
0
 /**
  * ReadDirectoryEntries() reads all entries in a directory.
  *
  * @param[in] file_ref A <code>PP_Resource</code> corresponding to a directory
  * reference.
  * @param[in] output An output array which will receive
  * <code>PP_DirectoryEntry</code> objects on success.
  * @param[in] callback A <code>PP_CompletionCallback</code> to run on
  * completion.
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>.
  */
 public static int ReadDirectoryEntries(PPResource file_ref,
                                        PPArrayOutput output,
                                        PPCompletionCallback callback)
 {
     return(_ReadDirectoryEntries(file_ref, output, callback));
 }
Exemple #16
0
 extern static int _ReadDirectoryEntries(PPResource file_ref,
                                         PPArrayOutput output,
                                         PPCompletionCallback callback);
Exemple #17
0
 /**
  * Query() queries info about a file or directory. You must have access to
  * read this file or directory if it exists in the external filesystem.
  *
  * @param[in] file_ref A <code>PP_Resource</code> corresponding to a file
  * reference.
  * @param[out] info A pointer to a <code>PP_FileInfo</code> which will be
  * populated with information about the file or directory.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion of Query().
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>.
  */
 public static int Query(PPResource file_ref,
                         out PPFileInfo info,
                         PPCompletionCallback callback)
 {
     return(_Query(file_ref, out info, callback));
 }
Exemple #18
0
 extern static int _Query(PPResource file_ref,
                          out PPFileInfo info,
                          PPCompletionCallback callback);
Exemple #19
0
 /**
  * Rename() renames a file or directory.  Arguments <code>file_ref</code> and
  * <code>new_file_ref</code> must both refer to files in the same file
  * system. It is an error to rename a file or directory that is in use.  It
  * is not valid to rename a file in the external file system.
  *
  * @param[in] file_ref A <code>PP_Resource</code> corresponding to a file
  * reference.
  * @param[in] new_file_ref A <code>PP_Resource</code> corresponding to a new
  * file reference.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion of Rename().
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>.
  */
 public static int Rename(PPResource file_ref,
                          PPResource new_file_ref,
                          PPCompletionCallback callback)
 {
     return(_Rename(file_ref, new_file_ref, callback));
 }
Exemple #20
0
 extern static int _Connect(PPResource tcp_socket,
                            PPResource addr,
                            PPCompletionCallback callback);
Exemple #21
0
 /**
  * Connects the socket to the given address. The socket must not be listening.
  * Binding the socket beforehand is optional.
  *
  * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
  * socket.
  * @param[in] addr A <code>PPB_NetAddress</code> resource.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion.
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>,
  * including (but not limited to):
  * - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required
  *   permissions.
  * - <code>PP_ERROR_ADDRESS_UNREACHABLE</code>: <code>addr</code> is
  *   unreachable.
  * - <code>PP_ERROR_CONNECTION_REFUSED</code>: the connection attempt was
  *   refused.
  * - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed.
  * - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed
  *   out.
  *
  * Since version 1.1, if the socket is listening/connected or has a pending
  * listen/connect request, <code>Connect()</code> will fail without starting a
  * connection attempt; otherwise, any failure during the connection attempt
  * will cause the socket to be closed.
  */
 public static int Connect(PPResource tcp_socket,
                           PPResource addr,
                           PPCompletionCallback callback)
 {
     return(_Connect(tcp_socket, addr, callback));
 }
Exemple #22
0
 /**
  * Starts listening. The socket must be bound and not connected.
  *
  * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
  * socket.
  * @param[in] backlog A hint to determine the maximum length to which the
  * queue of pending connections may grow.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion.
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>,
  * including (but not limited to):
  * - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required
  *   permissions.
  * - <code>PP_ERROR_ADDRESS_IN_USE</code>: Another socket is already listening
  *   on the same port.
  */
 public static int Listen(PPResource tcp_socket,
                          int backlog,
                          PPCompletionCallback callback)
 {
     return(_Listen(tcp_socket, backlog, callback));
 }
Exemple #23
0
 /**
  * Open() opens the file system. A file system must be opened before running
  * any other operation on it.
  *
  * @param[in] file_system A <code>PP_Resource</code> corresponding to a file
  * system.
  *
  * @param[in] expected_size The expected size of the file system. Note that
  * this does not request quota; to do that, you must either invoke
  * requestQuota from JavaScript:
  * http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-requesting-quota
  * or set the unlimitedStorage permission for Chrome Web Store apps:
  * http://code.google.com/chrome/extensions/manifest.html#permissions
  *
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion of Open().
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>.
  */
 public static int Open(PPResource file_system,
                        long expected_size,
                        PPCompletionCallback callback)
 {
     return(_Open(file_system, expected_size, callback));
 }
Exemple #24
0
 /**
  * Accepts a connection. The socket must be listening.
  *
  * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
  * socket.
  * @param[out] accepted_tcp_socket Stores the accepted TCP socket on success.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion.
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>,
  * including (but not limited to):
  * - <code>PP_ERROR_CONNECTION_ABORTED</code>: A connection has been aborted.
  */
 public static int Accept(PPResource tcp_socket,
                          out PPResource accepted_tcp_socket,
                          PPCompletionCallback callback)
 {
     return(_Accept(tcp_socket, out accepted_tcp_socket, callback));
 }
Exemple #25
0
 extern static int _Listen(PPResource tcp_socket,
                           int backlog,
                           PPCompletionCallback callback);
 /**
  * Configures underlying buffers for incoming audio samples.
  * If the application doesn't want to drop samples, then the
  * <code>PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS</code> should be
  * chosen such that inter-buffer processing time variability won't overrun all
  * the input buffers. If all buffers are filled, then samples will be
  * dropped. The application can detect this by examining the timestamp on
  * returned buffers. If <code>Configure()</code> is not called, default
  * settings will be used. Calls to Configure while the plugin holds
  * buffers will fail.
  * Example usage from plugin code:
  * @code
  * int32_t attribs[] = {
  *     PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS, 4,
  *     PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, 10,
  *     PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE};
  * track_if->Configure(track, attribs, callback);
  * @endcode
  *
  * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio
  * resource.
  * @param[in] attrib_list A list of attribute name-value pairs in which each
  * attribute is immediately followed by the corresponding desired value.
  * The list is terminated by
  * <code>PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE</code>.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion of <code>Configure()</code>.
  *
  * @return An int32_t containing a result code from <code>pp_errors.h</code>.
  */
 public static int Configure(PPResource audio_track,
                             int[] attrib_list,
                             PPCompletionCallback callback)
 {
     return(_Configure(audio_track, attrib_list, callback));
 }
Exemple #27
0
 extern static int _Accept(PPResource tcp_socket,
                           out PPResource accepted_tcp_socket,
                           PPCompletionCallback callback);
 extern static int _GetBuffer(PPResource audio_track,
                              out PPResource buffer,
                              PPCompletionCallback callback);
Exemple #29
0
 extern static int _SetOption(PPResource tcp_socket,
                              PPTCPSocketOption name,
                              PPVar value,
                              PPCompletionCallback callback);
 /**
  * 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 slot for another buffer.
  * If there are no audio data in the input buffer,
  * <code>PP_OK_COMPLETIONPENDING</code> will be returned immediately and the
  * <code>callback</code> will be called, when a new buffer of audio samples
  * is received or an error happens.
  *
  * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio
  * resource.
  * @param[out] buffer A <code>PP_Resource</code> corresponding to
  * an AudioBuffer resource.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion of GetBuffer().
  *
  * @return An int32_t containing a result code from <code>pp_errors.h</code>.
  */
 public static int GetBuffer(PPResource audio_track,
                             out PPResource buffer,
                             PPCompletionCallback callback)
 {
     return(_GetBuffer(audio_track, out buffer, callback));
 }