Skip to content

Commit

Permalink
[PPAPI] API definition for video media stream artifacts
Browse files Browse the repository at this point in the history
This API follows the design at
https://docs.google.com/a/google.com/document/d/1rlwmFhf7VCX8mfrBok8wqXNgvr_ERhL2k6Fqha-pgIo/edit?disco=AAAAAHos8Y8#


It defines new objects for the consumption of media video tracks based on the private VideoSource/VideoDestination classes.

BUG=330851

Review URL: https://codereview.chromium.org/107083004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243099 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
penghuang@chromium.org committed Jan 6, 2014
1 parent c7c265f commit 9134a8c
Show file tree
Hide file tree
Showing 15 changed files with 974 additions and 2 deletions.
2 changes: 2 additions & 0 deletions native_client_sdk/src/libraries/ppapi/library.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'ppb_image_data.h',
'ppb_input_event.h',
'ppb_instance.h',
'ppb_media_stream_video_track.h',
'ppb_message_loop.h',
'ppb_messaging.h',
'ppb_mouse_cursor.h',
Expand All @@ -55,6 +56,7 @@
'ppb_var_array.h',
'ppb_var_dictionary.h',
'ppb_var.h',
'ppb_video_frame.h',
'ppb_view.h',
'ppb_websocket.h',
'pp_completion_callback.h',
Expand Down
4 changes: 4 additions & 0 deletions native_client_sdk/src/libraries/ppapi_cpp/library.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'input_event.cc',
'instance.cc',
'instance_handle.cc',
'media_stream_video_track.cc',
'message_loop.cc',
'module.cc',
'mouse_cursor.cc',
Expand All @@ -54,6 +55,7 @@
'var_array.cc',
'var.cc',
'var_dictionary.cc',
'video_frame.cc',
'view.cc',
'websocket.cc',

Expand Down Expand Up @@ -125,6 +127,7 @@
'instance.h',
'instance_handle.h',
'logging.h',
'media_stream_video_track.h',
'message_loop.h',
'module_embedder.h',
'module.h',
Expand Down Expand Up @@ -152,6 +155,7 @@
'var_array.h',
'var_dictionary.h',
'var.h',
'video_frame.h',
'view.h',
'websocket.h',
],
Expand Down
124 changes: 124 additions & 0 deletions ppapi/api/ppb_media_stream_video_track.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* Copyright 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

/**
* Defines the <code>PPB_MediaStreamVideoTrack</code> interface. Used for
* receiving video frames from a MediaStream video track in the browser.
* This interface is still in development (Dev API status) and may change.
*/
label Chrome {
[channel=dev] M34 = 0.1
};

/**
*/
interface PPB_MediaStreamVideoTrack {
/**
* Determines if a resource is a MediaStream video track resource.
*
* @param[in] resource The <code>PP_Resource</code> to test.
*
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
* resource is a Mediastream video track resource or <code>PP_FALSE</code>
* otherwise.
*/
PP_Bool IsMediaStreamVideoTrack([in] PP_Resource resource);

/**
* Configures underlying frame buffers for incoming frames.
* If the application doesn't want to drop frames, then the
* <code>max_buffered_frames</code> 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 <code>Configure()</code> is not used, default settings will be used.
*
* @param[in] video_track A <code>PP_Resource</code> corresponding to a video
* resource.
* @param[in] max_buffered_frames The maximum number of video frames to
* hold in the input buffer.
*
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
*/
int32_t Configure([in] PP_Resource video_track,
[in] uint32_t max_buffered_frames);

/**
* Returns the track ID of the underlying MediaStream video track.
*
* @param[in] video_track The <code>PP_Resource</code> to check.
*
* @return A <code>PP_Var</code> containing the MediaStream track ID as
* a string.
*/
PP_Var GetId([in] PP_Resource 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.
*
* @param[in] video_track The <code>PP_Resource</code> to check.
*
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
* MediaStream track has ended or <code>PP_FALSE</code> otherwise.
*/
PP_Bool HasEnded([in] PP_Resource video_track);

/**
* 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 <code>RecycleFrame()</code> is called to free
* a spot for another frame to be buffered.
* If there are no frames in the input buffer,
* <code>PP_OK_COMPLETIONPENDING</code> will be returned immediately and the
* <code>callback</code> will be called, when a new frame is received or an
* error happens.
* If the caller holds a frame returned by the previous call of
* <code>GetFrame()</code>, <code>PP_ERROR_INPROGRESS</code> will be returned.
* The caller should recycle the previous frame before getting the next frame.
*
* @param[in] video_track A <code>PP_Resource</code> corresponding to a video
* resource.
* @param[out] frame A <code>PP_Resource</code> corresponding to a VideoFrame
* resource.
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
* completion of GetFrame().
*
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
* Returns PP_ERROR_NOMEMORY if <code>max_buffered_frames</code> frames buffer
* was not allocated successfully.
*/
int32_t GetFrame([in] PP_Resource video_track,
[out] PP_Resource frame,
[in] PP_CompletionCallback callback);

/**
* Recycles a frame returned by <code>GetFrame()</code>, 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
* <code>frame</code> and not use it anymore.
*
* @param[in] video_track A <code>PP_Resource</code> corresponding to a video
* resource.
* @param[in] frame A <code>PP_Resource</code> corresponding to a VideoFrame
* resource returned by <code>GetFrame()</code>.
*
* @return An int32_t containing a result code from <code>pp_errors.h</code>.
*/
int32_t RecycleFrame([in] PP_Resource video_track,
[in] PP_Resource frame);

/**
* Closes the MediaStream video track and disconnects it from video source.
* After calling <code>Close()</code>, no new frames will be received.
*
* @param[in] video_track A <code>PP_Resource</code> corresponding to a
* MediaStream video track resource.
*/
void Close([in] PP_Resource video_track);
};

121 changes: 121 additions & 0 deletions ppapi/api/ppb_video_frame.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/* Copyright 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

/**
* Defines the <code>PPB_VideoFrame</code> interface.
*/
label Chrome {
[channel=dev] M34 = 0.1
};

enum PP_VideoFrame_Format {
/**
* Unknown format value.
*/
PP_VIDEOFRAME_FORMAT_UNKNOWN = 0,

/**
* 12bpp YVU planar 1x1 Y, 2x2 VU samples.
*/
PP_VIDEOFRAME_FORMAT_YV12 = 1,

/**
* 16bpp YVU planar 1x1 Y, 2x1 VU samples.
*/
PP_VIDEOFRAME_FORMAT_YV16 = 2,

/**
* 12bpp YVU planar 1x1 Y, 2x2 VU samples.
*/
PP_VIDEOFRAME_FORMAT_I420 = 3,

/**
* 20bpp YVU planar 1x1 Y, 2x2 VU, 1x1 A samples.
*/
PP_VIDEOFRAME_FORMAT_YV12A = 4,

/**
* JPEG color range version of YV12.
*/
PP_VIDEOFRAME_FORMAT_YV12J = 5
};

interface PPB_VideoFrame {
/**
* Determines if a resource is a VideoFrame resource.
*
* @param[in] resource The <code>PP_Resource</code> to test.
*
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
* resource is a VideoFrame resource or <code>PP_FALSE</code> otherwise.
*/
PP_Bool IsVideoFrame([in] PP_Resource resource);

/**
* Gets the timestamp of the video frame.
*
* @param[in] frame A <code>PP_Resource</code> corresponding to a video frame
* resource.
*
* @return A <code>PP_TimeDelta</code> containing the timestamp of the video
* frame. Given in seconds since the start of the containing video stream.
*/
PP_TimeDelta GetTimestamp([in] PP_Resource frame);

/**
* Sets the timestamp of the video frame. Given in seconds since the
* start of the containing video stream.
*
* @param[in] frame A <code>PP_Resource</code> corresponding to a video frame
* resource.
* @param[in] timestamp A <code>PP_TimeDelta</code> containing the timestamp
* of the video frame. Given in seconds since the start of the containing
* video stream.
*/
void SetTimestamp([in] PP_Resource frame, [in] PP_TimeDelta timestamp);

/**
* Gets the format of the video frame.
*
* @param[in] frame A <code>PP_Resource</code> corresponding to a video frame
* resource.
*
* @return A <code>PP_VideoFrame_Format</code> containing the format of the
* video frame.
*/
PP_VideoFrame_Format GetFormat([in] PP_Resource frame);

/**
* Gets the size of the video frame.
*
* @param[in] frame A <code>PP_Resource</code> corresponding to a video frame
* resource.
* @param[out] size A <code>PP_Size</code>.
*
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> on success or
* <code>PP_FALSE</code> on failure.
*/
PP_Bool GetSize([in] PP_Resource frame, [out] PP_Size size);

/**
* Gets the data buffer for video frame pixels.
*
* @param[in] frame A <code>PP_Resource</code> corresponding to a video frame
* resource.
*
* @return A pointer to the beginning of the data buffer.
*/
mem_t GetDataBuffer([in] PP_Resource frame);

/**
* Gets the size of data buffer.
*
* @param[in] frame A <code>PP_Resource</code> corresponding to a video frame
* resource.
*
* @return The size of the data buffer.
*/
uint32_t GetDataBufferSize([in] PP_Resource frame);
};
4 changes: 2 additions & 2 deletions ppapi/c/pp_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* found in the LICENSE file.
*/

/* From pp_macros.idl modified Wed Mar 6 13:04:56 2013. */
/* From pp_macros.idl modified Mon Oct 21 10:49:59 2013. */

#ifndef PPAPI_C_PP_MACROS_H_
#define PPAPI_C_PP_MACROS_H_


#define PPAPI_RELEASE 33
#define PPAPI_RELEASE 34

/**
* @file
Expand Down
Loading

0 comments on commit 9134a8c

Please sign in to comment.