pp::MediaStreamVideoTrack Class Reference

Inheritance diagram for pp::MediaStreamVideoTrack:

List of all members.

Public Member Functions

 MediaStreamVideoTrack ()
 MediaStreamVideoTrack (const MediaStreamVideoTrack &other)
 MediaStreamVideoTrack (const Resource &resource)
 MediaStreamVideoTrack (const InstanceHandle &instance)
 MediaStreamVideoTrack (PassRef, PP_Resource resource)
 ~MediaStreamVideoTrack ()
int32_t Configure (const int32_t attributes[], const CompletionCallback &callback)
int32_t GetAttrib (PP_MediaStreamVideoTrack_Attrib attrib, int32_t *value)
std::string GetId () const
bool HasEnded () const
int32_t GetFrame (const CompletionCallbackWithOutput< VideoFrame > &callback)
int32_t RecycleFrame (const VideoFrame &frame)
void Close ()
int32_t GetEmptyFrame (const CompletionCallbackWithOutput< VideoFrame > &callback)
int32_t PutFrame (const VideoFrame &frame)

Static Public Member Functions

static bool IsMediaStreamVideoTrack (const Resource &resource)

Detailed Description

The MediaStreamVideoTrack class contains methods for receiving video frames from a MediaStream video track in the browser.


Constructor & Destructor Documentation

Default constructor for creating an is_null() MediaStreamVideoTrack object.

The copy constructor for MediaStreamVideoTrack.

Parameters:
[in]otherA reference to a MediaStreamVideoTrack.

Constructs a MediaStreamVideoTrack from a Resource.

Parameters:
[in]resourceA PPB_MediaStreamVideoTrack resource.

Constructs a MediaStreamVideoTrack that outputs given frames to a new video track, which will be consumed by Javascript.

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_MediaStreamVideoTrack resource.

Member Function Documentation

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

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

int32_t pp::MediaStreamVideoTrack::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_MEDIASTREAMVIDEOTRACK_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 some attributes are not specified, default values will be used for those unspecified attributes. If Configure() is not called, default settings will be used. Example usage from plugin code:

 int32_t attribs[] = {
     PP_MEDIASTREAMVIDEOTRACK_ATTRIB_BUFFERED_FRAMES, 4,
     PP_MEDIASTREAMVIDEOTRACK_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_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE.
[in]callbackA CompletionCallback to be called upon completion of Configure().
Returns:
An int32_t containing a result code from pp_errors.h. Returns PP_ERROR_INPROGRESS if there is a pending call of Configure() or GetFrame(), or the plugin holds some frames which are not recycled with RecycleFrame(). If an error is returned, all attributes and the underlying buffer will not be changed.
int32_t pp::MediaStreamVideoTrack::GetAttrib ( PP_MediaStreamVideoTrack_Attrib  attrib,
int32_t *  value 
)

Gets attribute value for a given attribute name.

Parameters:
[in]attribA PP_MediaStreamVideoTrack_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 video 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.

Parameters:
[in]callbackA CompletionCallbackWithOutput to be called upon completion of GetFrame(). If success, a VideoFrame will be passed into the completion callback function.
Returns:
An int32_t containing a result code from pp_errors.h. Returns PP_ERROR_NOMEMORY if max_buffered_frames frames buffer was not allocated successfully.
std::string pp::MediaStreamVideoTrack::GetId ( ) const

Returns the track ID of the underlying MediaStream video track.

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::MediaStreamVideoTrack::IsMediaStreamVideoTrack ( const Resource resource) [static]

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

Parameters:
[in]resourceA Resource to test.
Returns:
True if resource is a MediaStream video track.
int32_t pp::MediaStreamVideoTrack::PutFrame ( const VideoFrame 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.

Parameters:
[in]frameA VideoFrame returned by GetFrame().
Returns:
An int32_t containing a result code from pp_errors.h.

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