{{+bindTo:partials.standard_nacl_article}}
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 | GetFrame (const CompletionCallbackWithOutput< AudioFrame > &callback) |
int32_t | RecycleFrame (const AudioFrame &frame) |
void | Close () |
static bool | IsMediaStreamAudioTrack (const Resource &resource) |
The MediaStreamAudioTrack
class contains methods for receiving audio frames from a MediaStream audio track in the browser.
Default constructor for creating an is_null() MediaStreamAudioTrack
object.
pp::MediaStreamAudioTrack::MediaStreamAudioTrack | ( | const MediaStreamAudioTrack & | other | ) |
The copy constructor for MediaStreamAudioTrack
.
[in] | other | A reference to a MediaStreamAudioTrack . |
pp::MediaStreamAudioTrack::MediaStreamAudioTrack | ( | const Resource & | resource | ) | [explicit] |
Constructs a MediaStreamAudioTrack
from a Resource
.
[in] | resource | A PPB_MediaStreamAudioTrack resource. |
pp::MediaStreamAudioTrack::MediaStreamAudioTrack | ( | PassRef | , |
PP_Resource | resource | ||
) |
A constructor used when you have received a PP_Resource
as a return value that has had 1 ref added for you.
[in] | resource | A PPB_MediaStreamAudioTrack resource. |
void pp::MediaStreamAudioTrack::Close | ( | ) |
Closes the MediaStream audio track, and disconnects it from the audio source.
After calling Close()
, no new frames will be received.
int32_t pp::MediaStreamAudioTrack::Configure | ( | const int32_t | attributes[], |
const CompletionCallback & | callback | ||
) |
Configures underlying frame buffers for incoming frames.
If the application doesn't want to drop frames, then the PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERED_FRAMES
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 Configure()
is not called, default settings will be used. Example usage from plugin code:
int32_t attribs[] = { PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERED_FRAMES, 4, PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, 10, PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE}; track.Configure(attribs, callback);
[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 PP_MEDIASTREAMAUDIOTRACK_AUDIO_NONE . |
[in] | callback | A PP_CompletionCallback to be called upon completion of Configure() . |
pp_errors.h
. int32_t pp::MediaStreamAudioTrack::GetAttrib | ( | PP_MediaStreamAudioTrack_Attrib | attrib, |
int32_t * | value | ||
) |
Gets attribute value for a given attribute name.
[in] | attrib | A PP_MediaStreamAudioTrack_Attrib for querying. |
[out] | value | A int32_t for storing the attribute value. |
pp_errors.h
. int32_t pp::MediaStreamAudioTrack::GetFrame | ( | const CompletionCallbackWithOutput< AudioFrame > & | callback | ) |
Gets the next audio frame from the MediaStream track.
If internal processing is slower than the incoming frame rate, new frames will be dropped from the incoming stream. Once the input buffer is full, frames will be dropped until RecycleFrame()
is called to free a spot for another frame to be buffered. If there are no frames in the input buffer, PP_OK_COMPLETIONPENDING
will be returned immediately and the callback
will be called when a new frame is received or some error happens.
[in] | callback | A PP_CompletionCallback to be called upon completion of GetFrame() . If success, an AudioFrame will be passed into the completion callback function. |
pp_errors.h
. Returns PP_ERROR_NOMEMORY if max_buffered_frames
frames buffer was not allocated successfully. std::string pp::MediaStreamAudioTrack::GetId | ( | ) | const |
Returns the track ID of the underlying MediaStream audio track.
bool pp::MediaStreamAudioTrack::HasEnded | ( | ) | const |
Checks whether the underlying MediaStream track has ended.
Calls to GetFrame 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.
[in] | resource | A Resource to test. |
resource
is a MediaStream audio track. int32_t pp::MediaStreamAudioTrack::RecycleFrame | ( | const AudioFrame & | frame | ) |
Recycles a frame returned by GetFrame()
, so the track can reuse the underlying buffer of this frame.
And the frame will become invalid. The caller should release all references it holds to frame
and not use it anymore.
[in] | frame | A AudioFrame returned by GetFrame() . |
pp_errors.h
.