[PPAPI] API thunk for video media stream track.

BUG=330851

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244065 0039d316-1c4b-4281-b951-d872f2087c98
parent 7b6143bd
......@@ -51,6 +51,7 @@
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/c/ppb_instance.h"
#include "ppapi/c/ppb_media_stream_video_track.h"
#include "ppapi/c/ppb_messaging.h"
#include "ppapi/c/ppb_mouse_cursor.h"
#include "ppapi/c/ppb_mouse_lock.h"
......@@ -69,6 +70,7 @@
#include "ppapi/c/ppb_var_array.h"
#include "ppapi/c/ppb_var_array_buffer.h"
#include "ppapi/c/ppb_var_dictionary.h"
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/c/ppb_view.h"
#include "ppapi/c/ppb_websocket.h"
#include "ppapi/c/private/ppb_content_decryptor_private.h"
......
......@@ -74,6 +74,7 @@
#include "ppapi/c/ppb_host_resolver.h"
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/c/ppb_instance.h"
#include "ppapi/c/ppb_media_stream_video_track.h"
#include "ppapi/c/ppb_messaging.h"
#include "ppapi/c/ppb_mouse_cursor.h"
#include "ppapi/c/ppb_mouse_lock.h"
......@@ -92,6 +93,7 @@
#include "ppapi/c/ppb_var_array.h"
#include "ppapi/c/ppb_var_array_buffer.h"
#include "ppapi/c/ppb_var_dictionary.h"
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/c/ppb_view.h"
#include "ppapi/c/ppp.h"
#include "ppapi/c/ppp_instance.h"
......
......@@ -8,6 +8,9 @@
* receiving video frames from a MediaStream video track in the browser.
* This interface is still in development (Dev API status) and may change.
*/
[generate_thunk]
label Chrome {
[channel=dev] M34 = 0.1
};
......@@ -65,6 +68,7 @@ interface PPB_MediaStreamVideoTrack {
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
* MediaStream track has ended or <code>PP_FALSE</code> otherwise.
*/
[on_failure=PP_TRUE]
PP_Bool HasEnded([in] PP_Resource video_track);
/**
......@@ -75,11 +79,8 @@ interface PPB_MediaStreamVideoTrack {
* 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
* <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.
......
......@@ -6,6 +6,9 @@
/**
* Defines the <code>PPB_VideoFrame</code> interface.
*/
[generate_thunk]
label Chrome {
[channel=dev] M34 = 0.1
};
......@@ -62,6 +65,7 @@ interface PPB_VideoFrame {
* @return A <code>PP_TimeDelta</code> containing the timestamp of the video
* frame. Given in seconds since the start of the containing video stream.
*/
[on_failure=0.0]
PP_TimeDelta GetTimestamp([in] PP_Resource frame);
/**
......@@ -85,6 +89,7 @@ interface PPB_VideoFrame {
* @return A <code>PP_VideoFrame_Format</code> containing the format of the
* video frame.
*/
[on_failure=PP_VIDEOFRAME_FORMAT_UNKNOWN]
PP_VideoFrame_Format GetFormat([in] PP_Resource frame);
/**
......
......@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
/* From ppb_media_stream_video_track.idl modified Fri Dec 27 17:28:11 2013. */
/* From ppb_media_stream_video_track.idl modified Thu Jan 9 14:02:56 2014. */
#ifndef PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_
#define PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_
......@@ -87,11 +87,8 @@ struct PPB_MediaStreamVideoTrack_0_1 { /* dev */
* 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
* <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.
......
......@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
/* From ppb_video_frame.idl modified Fri Dec 27 17:21:52 2013. */
/* From ppb_video_frame.idl modified Wed Jan 8 14:06:25 2014. */
#ifndef PPAPI_C_PPB_VIDEO_FRAME_H_
#define PPAPI_C_PPB_VIDEO_FRAME_H_
......
......@@ -76,12 +76,8 @@ class MediaStreamVideoTrack : public Resource {
/// 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 some
/// <code>callback</code> will be called when a new frame is received or some
/// 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] callback A <code>PP_CompletionCallback</code> to be called upon
/// completion of <code>GetFrame()</code>. If success, a VideoFrame will be
......
......@@ -201,6 +201,8 @@
'thunk/ppb_instance_thunk.cc',
'thunk/ppb_isolated_file_system_private_api.h',
'thunk/ppb_isolated_file_system_private_thunk.cc',
'thunk/ppb_media_stream_video_track_api.h',
'thunk/ppb_media_stream_video_track_thunk.cc',
'thunk/ppb_message_loop_api.h',
'thunk/ppb_messaging_thunk.cc',
'thunk/ppb_mouse_cursor_thunk.cc',
......@@ -256,6 +258,8 @@
'thunk/ppb_video_decoder_thunk.cc',
'thunk/ppb_video_destination_private_api.h',
'thunk/ppb_video_destination_private_thunk.cc',
'thunk/ppb_video_frame_api.h',
'thunk/ppb_video_frame_thunk.cc',
'thunk/ppb_video_source_private_api.h',
'thunk/ppb_video_source_private_thunk.cc',
'thunk/ppb_view_api.h',
......
......@@ -61,6 +61,7 @@
'c/ppb_var_array.h',
'c/ppb_var_array_buffer.h',
'c/ppb_var_dictionary.h',
'c/ppb_video_frame.h',
'c/ppb_view.h',
'c/ppb_websocket.h',
'c/ppp.h',
......
......@@ -43,6 +43,7 @@
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/c/ppb_instance.h"
#include "ppapi/c/ppb_media_stream_video_track.h"
#include "ppapi/c/ppb_message_loop.h"
#include "ppapi/c/ppb_messaging.h"
#include "ppapi/c/ppb_mouse_lock.h"
......@@ -61,6 +62,7 @@
#include "ppapi/c/ppb_var_array.h"
#include "ppapi/c/ppb_var_array_buffer.h"
#include "ppapi/c/ppb_var_dictionary.h"
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/c/ppb_view.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppp_instance.h"
......
......@@ -53,6 +53,7 @@
F(PPB_InputEvent_API) \
F(PPB_IsolatedFileSystem_Private_API) \
F(PPB_LayerCompositor_API) \
F(PPB_MediaStreamVideoTrack_API) \
F(PPB_MessageLoop_API) \
F(PPB_NetAddress_API) \
F(PPB_NetworkList_API) \
......@@ -77,6 +78,7 @@
F(PPB_VideoCapture_API) \
F(PPB_VideoDecoder_API) \
F(PPB_VideoDestination_Private_API) \
F(PPB_VideoFrame_API) \
F(PPB_VideoLayer_API) \
F(PPB_VideoSource_Private_API) \
F(PPB_View_API) \
......
......@@ -8,5 +8,8 @@
#include "ppapi/thunk/interfaces_preamble.h"
// Interfaces go here.
PROXIED_IFACE(PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1,
PPB_MediaStreamVideoTrack_0_1)
PROXIED_IFACE(PPB_VIDEOFRAME_INTERFACE_0_1, PPB_VideoFrame_0_1)
#include "ppapi/thunk/interfaces_postamble.h"
// 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.
#ifndef PPAPI_THUNK_PPB_MEDIA_STREAM_VIDEO_TRACK_API_H_
#define PPAPI_THUNK_PPB_MEDIA_STREAM_VIDEO_TRACK_API_H_
namespace ppapi {
namespace thunk {
class PPAPI_THUNK_EXPORT PPB_MediaStreamVideoTrack_API {
public:
virtual ~PPB_MediaStreamVideoTrack_API() {}
virtual PP_Var GetId() = 0;
virtual PP_Bool HasEnded() = 0;
virtual int32_t Configure(uint32_t max_buffered_frames) = 0;
virtual int32_t GetFrame(
PP_Resource* frame,
scoped_refptr<ppapi::TrackedCallback> callback) = 0;
virtual int32_t RecycleFrame(PP_Resource frame) = 0;
virtual void Close() = 0;
};
} // namespace thunk
} // namespace ppapi
#endif // PPAPI_THUNK_PPB_MEDIA_STREAM_VIDEO_TRACK_API_H_
// 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.
// From ppb_media_stream_video_track.idl modified Wed Jan 8 14:08:11 2014.
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_media_stream_video_track.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/ppb_media_stream_video_track_api.h"
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
namespace thunk {
namespace {
PP_Bool IsMediaStreamVideoTrack(PP_Resource resource) {
VLOG(4) << "PPB_MediaStreamVideoTrack::IsMediaStreamVideoTrack()";
EnterResource<PPB_MediaStreamVideoTrack_API> enter(resource, false);
return PP_FromBool(enter.succeeded());
}
int32_t Configure(PP_Resource video_track, uint32_t max_buffered_frames) {
VLOG(4) << "PPB_MediaStreamVideoTrack::Configure()";
EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
if (enter.failed())
return enter.retval();
return enter.object()->Configure(max_buffered_frames);
}
struct PP_Var GetId(PP_Resource video_track) {
VLOG(4) << "PPB_MediaStreamVideoTrack::GetId()";
EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
if (enter.failed())
return PP_MakeUndefined();
return enter.object()->GetId();
}
PP_Bool HasEnded(PP_Resource video_track) {
VLOG(4) << "PPB_MediaStreamVideoTrack::HasEnded()";
EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
if (enter.failed())
return PP_TRUE;
return enter.object()->HasEnded();
}
int32_t GetFrame(PP_Resource video_track,
PP_Resource* frame,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_MediaStreamVideoTrack::GetFrame()";
EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track,
callback,
true);
if (enter.failed())
return enter.retval();
return enter.SetResult(enter.object()->GetFrame(frame, enter.callback()));
}
int32_t RecycleFrame(PP_Resource video_track, PP_Resource frame) {
VLOG(4) << "PPB_MediaStreamVideoTrack::RecycleFrame()";
EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
if (enter.failed())
return enter.retval();
return enter.object()->RecycleFrame(frame);
}
void Close(PP_Resource video_track) {
VLOG(4) << "PPB_MediaStreamVideoTrack::Close()";
EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
if (enter.failed())
return;
enter.object()->Close();
}
const PPB_MediaStreamVideoTrack_0_1 g_ppb_mediastreamvideotrack_thunk_0_1 = {
&IsMediaStreamVideoTrack,
&Configure,
&GetId,
&HasEnded,
&GetFrame,
&RecycleFrame,
&Close
};
} // namespace
const PPB_MediaStreamVideoTrack_0_1* GetPPB_MediaStreamVideoTrack_0_1_Thunk() {
return &g_ppb_mediastreamvideotrack_thunk_0_1;
}
} // namespace thunk
} // namespace ppapi
// 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.
#ifndef PPAPI_THUNK_PPB_VIDEO_FRAME_API_H_
#define PPAPI_THUNK_PPB_VIDEO_FRAME_API_H_
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/thunk/ppapi_thunk_export.h"
namespace ppapi {
namespace thunk {
class PPAPI_THUNK_EXPORT PPB_VideoFrame_API {
public:
virtual ~PPB_VideoFrame_API() {}
virtual PP_TimeDelta GetTimestamp() = 0;
virtual void SetTimestamp(PP_TimeDelta timestamp) = 0;
virtual PP_VideoFrame_Format GetFormat() = 0;
virtual PP_Bool GetSize(PP_Size* size) = 0;
virtual void* GetDataBuffer() = 0;
virtual uint32_t GetDataBufferSize() = 0;
};
} // namespace thunk
} // namespace ppapi
#endif // PPAPI_THUNK_PPB_VIDEO_FRAME_API_H_
// 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.
// From ppb_video_frame.idl modified Wed Jan 8 13:30:05 2014.
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/ppb_video_frame_api.h"
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
namespace thunk {
namespace {
PP_Bool IsVideoFrame(PP_Resource resource) {
VLOG(4) << "PPB_VideoFrame::IsVideoFrame()";
EnterResource<PPB_VideoFrame_API> enter(resource, false);
return PP_FromBool(enter.succeeded());
}
PP_TimeDelta GetTimestamp(PP_Resource frame) {
VLOG(4) << "PPB_VideoFrame::GetTimestamp()";
EnterResource<PPB_VideoFrame_API> enter(frame, true);
if (enter.failed())
return 0.0;
return enter.object()->GetTimestamp();
}
void SetTimestamp(PP_Resource frame, PP_TimeDelta timestamp) {
VLOG(4) << "PPB_VideoFrame::SetTimestamp()";
EnterResource<PPB_VideoFrame_API> enter(frame, true);
if (enter.failed())
return;
enter.object()->SetTimestamp(timestamp);
}
PP_VideoFrame_Format GetFormat(PP_Resource frame) {
VLOG(4) << "PPB_VideoFrame::GetFormat()";
EnterResource<PPB_VideoFrame_API> enter(frame, true);
if (enter.failed())
return PP_VIDEOFRAME_FORMAT_UNKNOWN;
return enter.object()->GetFormat();
}
PP_Bool GetSize(PP_Resource frame, struct PP_Size* size) {
VLOG(4) << "PPB_VideoFrame::GetSize()";
EnterResource<PPB_VideoFrame_API> enter(frame, true);
if (enter.failed())
return PP_FALSE;
return enter.object()->GetSize(size);
}
void* GetDataBuffer(PP_Resource frame) {
VLOG(4) << "PPB_VideoFrame::GetDataBuffer()";
EnterResource<PPB_VideoFrame_API> enter(frame, true);
if (enter.failed())
return NULL;
return enter.object()->GetDataBuffer();
}
uint32_t GetDataBufferSize(PP_Resource frame) {
VLOG(4) << "PPB_VideoFrame::GetDataBufferSize()";
EnterResource<PPB_VideoFrame_API> enter(frame, true);
if (enter.failed())
return 0;
return enter.object()->GetDataBufferSize();
}
const PPB_VideoFrame_0_1 g_ppb_videoframe_thunk_0_1 = {
&IsVideoFrame,
&GetTimestamp,
&SetTimestamp,
&GetFormat,
&GetSize,
&GetDataBuffer,
&GetDataBufferSize
};
} // namespace
const PPB_VideoFrame_0_1* GetPPB_VideoFrame_0_1_Thunk() {
return &g_ppb_videoframe_thunk_0_1;
}
} // namespace thunk
} // namespace ppapi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment