pp::MediaStreamAudioTrack Class Reference

Inheritance diagram for pp::MediaStreamAudioTrack:

List of all members.

Public Member Functions

 MediaStreamAudioTrack ()
 MediaStreamAudioTrack (const MediaStreamAudioTrack &other)
 MediaStreamAudioTrack (const Resource &resource)
 MediaStreamAudioTrack (PassRef, PP_Resource resource)
 ~MediaStreamAudioTrack ()
int32_t Configure (const int32_t attributes[], const CompletionCallback &callback)
int32_t GetAttrib (PP_MediaStreamAudioTrack_Attrib attrib, int32_t *value)
std::string GetId () const
bool HasEnded () const
int32_t GetBuffer (const CompletionCallbackWithOutput< AudioBuffer > &callback)
int32_t RecycleBuffer (const AudioBuffer &buffer)
void Close ()

Static Public Member Functions

static bool IsMediaStreamAudioTrack (const Resource &resource)

Detailed Description

The MediaStreamAudioTrack class contains methods for receiving audio buffers from a MediaStream audio track in the browser.


Constructor & Destructor Documentation

Default constructor for creating an is_null() MediaStreamAudioTrack object.

The copy constructor for MediaStreamAudioTrack.

Parameters:
[in]otherA reference to a MediaStreamAudioTrack.

Constructs a MediaStreamAudioTrack from a Resource.

Parameters:
[in]resourceA PPB_MediaStreamAudioTrack resource.

A constructor used when you have received a PP_Resource as a return value that has had 1 ref added for you.

Parameters:
[in]resourceA PPB_MediaStreamAudioTrack resource.

Member Function Documentation

Closes the MediaStream audio track, and disconnects it from the audio source.

After calling Close(), no new buffers will be received.

int32_t pp::MediaStreamAudioTrack::Configure ( const int32_t  attributes[],
const CompletionCallback callback 
)

Configures underlying buffer buffers for incoming audio samples.

If the application doesn't want to drop samples, then the PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS should be chosen such that inter-buffer processing time variability won't overrun all 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 Configure() is not called, default settings will be used. Calls to Configure while the plugin holds buffers will fail. Example usage from plugin code:

 int32_t attribs[] = {
     PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS, 4,
     PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, 10,
     PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE};
 track.Configure(attribs, callback);
Parameters:
[in]attrib_listA list of attribute name-value pairs in which each attribute is immediately followed by the corresponding desired value. The list is terminated by PP_MEDIASTREAMAUDIOTRACK_AUDIO_NONE.
[in]callbackA CompletionCallback to be called upon completion of Configure().
Returns:
An int32_t containing a result code from pp_errors.h.
int32_t pp::MediaStreamAudioTrack::GetAttrib ( PP_MediaStreamAudioTrack_Attrib  attrib,
int32_t *  value 
)

Gets attribute value for a given attribute name.

Parameters:
[in]attribA PP_MediaStreamAudioTrack_Attrib for querying.
[out]valueA int32_t for storing the attribute value.
Returns:
An int32_t containing a result code from pp_errors.h.

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 RecycleBuffer() is called to free a spot for another buffer. If there are no audio data in the input buffer, PP_OK_COMPLETIONPENDING will be returned immediately and the callback will be called when a new buffer of audio samples is received or some error happens.

Parameters:
[in]callbackA CompletionCallbackWithOutput to be called upon completion of GetBuffer(). If success, an AudioBuffer will be passed into the completion callback function.
Returns:
An int32_t containing a result code from pp_errors.h.
std::string pp::MediaStreamAudioTrack::GetId ( ) const

Returns the track ID of the underlying MediaStream audio track.

Checks whether the underlying MediaStream track has ended.

Calls to GetBuffer while the track has ended are safe to make and will complete, but will fail.

static bool pp::MediaStreamAudioTrack::IsMediaStreamAudioTrack ( const Resource resource) [static]

Checks whether a Resource is a MediaStream audio track, to test whether it is appropriate for use with the MediaStreamAudioTrack constructor.

Parameters:
[in]resourceA Resource to test.
Returns:
True if resource is a MediaStream audio track.

Recycles a buffer returned by GetBuffer(), so the track can reuse the buffer.

And the buffer will become invalid. The caller should release all references it holds to buffer and not use it anymore.

Parameters:
[in]bufferA AudioBuffer returned by GetBuffer().
Returns:
An int32_t containing a result code from pp_errors.h.

The documentation for this class was generated from the following file: