diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-04 00:11:30 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-04 00:11:30 +0000 |
commit | b76257d27a5916f9a2b5d80f8800ed1eef300a0b (patch) | |
tree | e7c13526b9522f2dccfb98436a6104044b0b0dbc /ppapi | |
parent | bd7b8a3167a7b39b39291779212e079354cf8deb (diff) | |
download | chromium_src-b76257d27a5916f9a2b5d80f8800ed1eef300a0b.zip chromium_src-b76257d27a5916f9a2b5d80f8800ed1eef300a0b.tar.gz chromium_src-b76257d27a5916f9a2b5d80f8800ed1eef300a0b.tar.bz2 |
Adds internal APIs, thunks, resources, and resource hosts.
Adds IPC messages to support the new resources.
Adds stubbed out host methods to hold implementation
TBR=tsepez@chromium.org, yzshen@chromium.org
BUG=230980
TESTS=none
Review URL: https://codereview.chromium.org/13771020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/ppapi_proxy.gypi | 6 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 6 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 23 | ||||
-rw-r--r-- | ppapi/proxy/ppb_image_data_proxy.cc | 62 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.cc | 13 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.h | 2 | ||||
-rw-r--r-- | ppapi/proxy/video_destination_resource.cc | 102 | ||||
-rw-r--r-- | ppapi/proxy/video_destination_resource.h | 56 | ||||
-rw-r--r-- | ppapi/proxy/video_source_resource.cc | 112 | ||||
-rw-r--r-- | ppapi/proxy/video_source_resource.h | 65 | ||||
-rw-r--r-- | ppapi/shared_impl/resource.h | 2 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_private.h | 5 | ||||
-rw-r--r-- | ppapi/thunk/ppb_video_destination_private_api.h | 32 | ||||
-rw-r--r-- | ppapi/thunk/ppb_video_destination_private_thunk.cc | 74 | ||||
-rw-r--r-- | ppapi/thunk/ppb_video_source_private_api.h | 33 | ||||
-rw-r--r-- | ppapi/thunk/ppb_video_source_private_thunk.cc | 71 | ||||
-rw-r--r-- | ppapi/thunk/resource_creation_api.h | 2 |
18 files changed, 640 insertions, 28 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 011b867..51be328 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -181,6 +181,10 @@ 'proxy/var_serialization_rules.h', 'proxy/video_capture_resource.cc', 'proxy/video_capture_resource.h', + 'proxy/video_destination_resource.cc', + 'proxy/video_destination_resource.h', + 'proxy/video_source_resource.cc', + 'proxy/video_source_resource.h', 'proxy/websocket_resource.cc', 'proxy/websocket_resource.h', ], @@ -222,6 +226,8 @@ 'proxy/serialized_flash_menu.cc', 'proxy/talk_resource.cc', 'proxy/video_capture_resource.cc', + 'proxy/video_destination_resource.cc', + 'proxy/video_source_resource.cc', ], }], ], diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 101bd94..daa04bc 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -248,6 +248,10 @@ 'thunk/ppb_video_capture_thunk.cc', 'thunk/ppb_video_decoder_api.h', 'thunk/ppb_video_decoder_thunk.cc', + 'thunk/ppb_video_destination_private_api.h', + 'thunk/ppb_video_destination_private_thunk.cc', + 'thunk/ppb_video_source_private_api.h', + 'thunk/ppb_video_source_private_thunk.cc', 'thunk/ppb_view_api.h', 'thunk/ppb_view_dev_thunk.cc', 'thunk/ppb_view_thunk.cc', @@ -305,6 +309,8 @@ 'thunk/ppb_url_util_thunk.cc', 'thunk/ppb_video_capture_thunk.cc', 'thunk/ppb_video_decoder_thunk.cc', + 'thunk/ppb_video_destination_private_thunk.cc', + 'thunk/ppb_video_source_private_thunk.cc', ], }], # We exclude a few more things for nacl_win64, to avoid pulling in diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index e5195d5..bf5bb4b 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -78,6 +78,8 @@ #include "ppapi/c/private/ppb_tcp_server_socket_private.h" #include "ppapi/c/private/ppb_tcp_socket_private.h" #include "ppapi/c/private/ppb_udp_socket_private.h" +#include "ppapi/c/private/ppb_video_destination_private.h" +#include "ppapi/c/private/ppb_video_source_private.h" #include "ppapi/c/private/ppb_x509_certificate_private.h" #include "ppapi/c/private/ppp_content_decryptor_private.h" #include "ppapi/c/trusted/ppb_broker_trusted.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 0e00d52..76fe6ec 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1844,4 +1844,27 @@ IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoCapture_OnError, IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoCapture_OnBufferReady, uint32_t /* buffer */) +// MediaStream ----------------------------------------------------------------- + +// VideoDestination Private. +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoDestination_Create) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_VideoDestination_Open, + std::string /* stream_url */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_VideoDestination_OpenReply) +IPC_MESSAGE_CONTROL2(PpapiHostMsg_VideoDestination_PutFrame, + ppapi::HostResource /* image_data */, + PP_TimeTicks /* timestamp */) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoDestination_Close) + +// VideoSource Private. +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoSource_Create) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_VideoSource_Open, + std::string /* stream_url */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_VideoSource_OpenReply) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoSource_GetFrame) +IPC_MESSAGE_CONTROL2(PpapiPluginMsg_VideoSource_GetFrameReply, + ppapi::HostResource /* image_data */, + PP_TimeTicks /* timestamp */) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoSource_Close) + #endif // !defined(OS_NACL) && !defined(NACL_WIN64) diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index d27deaf..cef71d6 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc @@ -25,6 +25,7 @@ #include "ppapi/shared_impl/host_resource.h" #include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/resource.h" +#include "ppapi/shared_impl/scoped_pp_resource.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" @@ -537,25 +538,30 @@ PP_Resource PPB_ImageData_Proxy::CreateImageData( if (enter.failed()) return 0; - PP_Resource result = 0; - PP_Bool clear = init_to_zero ? PP_TRUE : PP_FALSE; - if (is_nacl_plugin) { - result = enter.functions()->CreateImageDataNaCl( - instance, static_cast<PP_ImageDataFormat>(format), &size, clear); - } else { - result = enter.functions()->CreateImageData( - instance, static_cast<PP_ImageDataFormat>(format), &size, clear); - } - if (!result) + PP_Bool pp_init_to_zero = init_to_zero ? PP_TRUE : PP_FALSE; + ppapi::ScopedPPResource resource( + ppapi::ScopedPPResource::PassRef(), + is_nacl_plugin ? + enter.functions()->CreateImageDataNaCl(instance, format, &size, + pp_init_to_zero) : + enter.functions()->CreateImageData(instance, format, &size, + pp_init_to_zero)); + if (!resource.get()) return 0; - thunk::EnterResourceNoLock<PPB_ImageData_API> enter_resource(result, false); - if (enter_resource.object()->Describe(desc) != PP_TRUE) + thunk::EnterResourceNoLock<PPB_ImageData_API> enter_resource(resource.get(), + false); + if (enter_resource.object()->Describe(desc) != PP_TRUE) { DVLOG(1) << "CreateImageData failed: could not Describe"; + return 0; + } int local_fd = 0; - if (enter_resource.object()->GetSharedMemory(&local_fd, byte_count) != PP_OK) + if (enter_resource.object()->GetSharedMemory(&local_fd, + byte_count) != PP_OK) { DVLOG(1) << "CreateImageData failed: could not GetSharedMemory"; + return 0; + } #if defined(OS_WIN) *image_handle = dispatcher->ShareHandleWithRemote( @@ -572,7 +578,7 @@ PP_Resource PPB_ImageData_Proxy::CreateImageData( #error Not implemented. #endif - return result; + return resource.Release(); } void PPB_ImageData_Proxy::OnHostMsgCreate(PP_Instance instance, @@ -585,13 +591,13 @@ void PPB_ImageData_Proxy::OnHostMsgCreate(PP_Instance instance, PP_ImageDataDesc desc; IPC::PlatformFileForTransit image_handle; uint32_t byte_count; - PP_Resource resource = CreateImageData( - instance, - static_cast<PP_ImageDataFormat>(format), - size, - true /* init_to_zero */, - false /* is_nacl_plugin */, - &desc, &image_handle, &byte_count); + PP_Resource resource = + CreateImageData(instance, + static_cast<PP_ImageDataFormat>(format), + size, + true /* init_to_zero */, + false /* is_nacl_plugin */, + &desc, &image_handle, &byte_count); result->SetHostResource(instance, resource); if (resource) { image_data_desc->resize(sizeof(PP_ImageDataDesc)); @@ -619,13 +625,13 @@ void PPB_ImageData_Proxy::OnHostMsgCreateNaCl( PP_ImageDataDesc desc; IPC::PlatformFileForTransit image_handle; uint32_t byte_count; - PP_Resource resource = CreateImageData( - instance, - static_cast<PP_ImageDataFormat>(format), - size, - true /* init_to_zero */, - true /* is_nacl_plugin */, - &desc, &image_handle, &byte_count); + PP_Resource resource = + CreateImageData(instance, + static_cast<PP_ImageDataFormat>(format), + size, + true /* init_to_zero */, + true /* is_nacl_plugin */, + &desc, &image_handle, &byte_count); result->SetHostResource(instance, resource); if (resource) { diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 4fe204d..a234ca6 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -42,6 +42,8 @@ #include "ppapi/proxy/url_request_info_resource.h" #include "ppapi/proxy/url_response_info_resource.h" #include "ppapi/proxy/video_capture_resource.h" +#include "ppapi/proxy/video_destination_resource.h" +#include "ppapi/proxy/video_source_resource.h" #include "ppapi/proxy/websocket_resource.h" #include "ppapi/shared_impl/api_id.h" #include "ppapi/shared_impl/host_resource.h" @@ -382,6 +384,17 @@ PP_Resource ResourceCreationProxy::CreateVideoDecoder( instance, context3d_id, profile); } +PP_Resource ResourceCreationProxy::CreateVideoDestination( + PP_Instance instance) { + return (new VideoDestinationResource(GetConnection(), + instance))->GetReference(); +} + +PP_Resource ResourceCreationProxy::CreateVideoSource( + PP_Instance instance) { + return (new VideoSourceResource(GetConnection(), instance))->GetReference(); +} + #endif // !defined(OS_NACL) bool ResourceCreationProxy::Send(IPC::Message* msg) { diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 2654651..404c219 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -160,6 +160,8 @@ class ResourceCreationProxy : public InterfaceProxy, PP_Instance instance, PP_Resource context3d_id, PP_VideoDecoder_Profile profile) OVERRIDE; + virtual PP_Resource CreateVideoDestination(PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateVideoSource(PP_Instance instance) OVERRIDE; #endif // !defined(OS_NACL) virtual bool Send(IPC::Message* msg) OVERRIDE; diff --git a/ppapi/proxy/video_destination_resource.cc b/ppapi/proxy/video_destination_resource.cc new file mode 100644 index 0000000..b08d063 --- /dev/null +++ b/ppapi/proxy/video_destination_resource.cc @@ -0,0 +1,102 @@ +// Copyright (c) 2013 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. + +#include "ppapi/proxy/video_destination_resource.h" + +#include "base/bind.h" +#include "ipc/ipc_message.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/pp_video_frame_private.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/resource_tracker.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_image_data_api.h" + +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_VideoDestination_Private_API; + +namespace ppapi { +namespace proxy { + +VideoDestinationResource::VideoDestinationResource( + Connection connection, + PP_Instance instance) + : PluginResource(connection, instance), + is_open_(false) { + SendCreate(RENDERER, PpapiHostMsg_VideoDestination_Create()); +} + +VideoDestinationResource::~VideoDestinationResource() { +} + +PPB_VideoDestination_Private_API* + VideoDestinationResource::AsPPB_VideoDestination_Private_API() { + return this; +} + +int32_t VideoDestinationResource::Open( + const PP_Var& stream_url, + scoped_refptr<TrackedCallback> callback) { + if (TrackedCallback::IsPending(open_callback_)) + return PP_ERROR_INPROGRESS; + + open_callback_ = callback; + + scoped_refptr<StringVar> stream_url_var = StringVar::FromPPVar(stream_url); + const uint32_t kMaxStreamIdSizeInBytes = 16384; + if (!stream_url_var || + stream_url_var->value().size() > kMaxStreamIdSizeInBytes) + return PP_ERROR_BADARGUMENT; + Call<PpapiPluginMsg_VideoDestination_OpenReply>(RENDERER, + PpapiHostMsg_VideoDestination_Open(stream_url_var->value()), + base::Bind(&VideoDestinationResource::OnPluginMsgOpenComplete, this)); + return PP_OK_COMPLETIONPENDING; +} + +int32_t VideoDestinationResource::PutFrame( + const PP_VideoFrame_Private& frame) { + if (!is_open_) + return PP_ERROR_FAILED; + + thunk::EnterResourceNoLock<thunk::PPB_ImageData_API> enter_image( + frame.image_data, true); + if (enter_image.failed()) + return PP_ERROR_BADRESOURCE; + + // Check that the PP_Instance matches. + Resource* image_object = + PpapiGlobals::Get()->GetResourceTracker()->GetResource(frame.image_data); + if (!image_object || pp_instance() != image_object->pp_instance()) { + Log(PP_LOGLEVEL_ERROR, + "VideoDestinationPrivateResource.PutFrame: Bad image resource."); + return PP_ERROR_BADRESOURCE; + } + + Post(RENDERER, + PpapiHostMsg_VideoDestination_PutFrame(image_object->host_resource(), + frame.timestamp)); + return PP_OK; +} + +void VideoDestinationResource::Close() { + Post(RENDERER, PpapiHostMsg_VideoDestination_Close()); + + if (TrackedCallback::IsPending(open_callback_)) + open_callback_->PostAbort(); +} + +void VideoDestinationResource::OnPluginMsgOpenComplete( + const ResourceMessageReplyParams& params) { + if (TrackedCallback::IsPending(open_callback_)) { + int32_t result = params.result(); + if (result == PP_OK) + is_open_ = true; + open_callback_->Run(result); + } +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/video_destination_resource.h b/ppapi/proxy/video_destination_resource.h new file mode 100644 index 0000000..91c0d1d --- /dev/null +++ b/ppapi/proxy/video_destination_resource.h @@ -0,0 +1,56 @@ +// Copyright (c) 2013 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_PROXY_VIDEO_DESTINATION_RESOURCE_H_ +#define PPAPI_PROXY_VIDEO_DESTINATION_RESOURCE_H_ + +#include <string> + +#include "ppapi/c/pp_var.h" +#include "ppapi/proxy/connection.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/thunk/ppb_video_destination_private_api.h" + +struct PP_VideoFrame_Private; + +namespace ppapi { + +class TrackedCallback; + +namespace proxy { + +class PPAPI_PROXY_EXPORT VideoDestinationResource + : public PluginResource, + public thunk::PPB_VideoDestination_Private_API { + public: + VideoDestinationResource(Connection connection, + PP_Instance instance); + virtual ~VideoDestinationResource(); + + // Resource overrides. + virtual thunk::PPB_VideoDestination_Private_API* + AsPPB_VideoDestination_Private_API() OVERRIDE; + + // PPB_VideoDestination_Private_API implementation. + virtual int32_t Open( + const PP_Var& stream_url, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual int32_t PutFrame(const PP_VideoFrame_Private& frame) OVERRIDE; + virtual void Close() OVERRIDE; + + private: + void OnPluginMsgOpenComplete( + const ResourceMessageReplyParams& params); + + scoped_refptr<TrackedCallback> open_callback_; + bool is_open_; + + DISALLOW_COPY_AND_ASSIGN(VideoDestinationResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_VIDEO_DESTINATION_RESOURCE_H_ diff --git a/ppapi/proxy/video_source_resource.cc b/ppapi/proxy/video_source_resource.cc new file mode 100644 index 0000000..4585eb3 --- /dev/null +++ b/ppapi/proxy/video_source_resource.cc @@ -0,0 +1,112 @@ +// Copyright (c) 2013 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. + +#include "ppapi/proxy/video_source_resource.h" + +#include "base/bind.h" +#include "ipc/ipc_message.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/pp_video_frame_private.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/resource_tracker.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/enter.h" + +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_VideoSource_Private_API; + +namespace ppapi { +namespace proxy { + +VideoSourceResource::VideoSourceResource( + Connection connection, + PP_Instance instance) + : PluginResource(connection, instance), + is_open_(false) { + SendCreate(RENDERER, PpapiHostMsg_VideoSource_Create()); +} + +VideoSourceResource::~VideoSourceResource() { +} + +PPB_VideoSource_Private_API* + VideoSourceResource::AsPPB_VideoSource_Private_API() { + return this; +} + +int32_t VideoSourceResource::Open( + const PP_Var& stream_url, + scoped_refptr<TrackedCallback> callback) { + if (TrackedCallback::IsPending(open_callback_)) + return PP_ERROR_INPROGRESS; + + open_callback_ = callback; + + scoped_refptr<StringVar> stream_url_var = StringVar::FromPPVar(stream_url); + const uint32_t kMaxStreamIdSizeInBytes = 16384; + if (!stream_url_var || + stream_url_var->value().size() > kMaxStreamIdSizeInBytes) + return PP_ERROR_BADARGUMENT; + Call<PpapiPluginMsg_VideoSource_OpenReply>(RENDERER, + PpapiHostMsg_VideoSource_Open(stream_url_var->value()), + base::Bind(&VideoSourceResource::OnPluginMsgOpenComplete, this)); + return PP_OK_COMPLETIONPENDING; +} + +int32_t VideoSourceResource::GetFrame( + PP_VideoFrame_Private* frame, + scoped_refptr<TrackedCallback> callback) { + if (!is_open_) + return PP_ERROR_FAILED; + + if (TrackedCallback::IsPending(get_frame_callback_)) + return PP_ERROR_INPROGRESS; + + get_frame_callback_ = callback; + + Call<PpapiPluginMsg_VideoSource_GetFrameReply>(RENDERER, + PpapiHostMsg_VideoSource_GetFrame(), + base::Bind(&VideoSourceResource::OnPluginMsgGetFrameComplete, this, + frame)); + return PP_OK_COMPLETIONPENDING; +} + +void VideoSourceResource::Close() { + Post(RENDERER, PpapiHostMsg_VideoSource_Close()); + + if (TrackedCallback::IsPending(open_callback_)) + open_callback_->PostAbort(); + if (TrackedCallback::IsPending(get_frame_callback_)) + get_frame_callback_->PostAbort(); +} + +void VideoSourceResource::OnPluginMsgOpenComplete( + const ResourceMessageReplyParams& params) { + if (TrackedCallback::IsPending(open_callback_)) { + int32_t result = params.result(); + if (result == PP_OK) + is_open_ = true; + open_callback_->Run(result); + } +} + +void VideoSourceResource::OnPluginMsgGetFrameComplete( + PP_VideoFrame_Private* frame, + const ResourceMessageReplyParams& params, + const HostResource& image_data, + PP_TimeTicks timestamp) { + // The callback may have been aborted by Close(). + if (TrackedCallback::IsPending(get_frame_callback_)) { + int32_t result = params.result(); + if (result == PP_OK) { + frame->timestamp = timestamp; + frame->image_data = image_data.host_resource(); + } + get_frame_callback_->Run(result); + } +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/video_source_resource.h b/ppapi/proxy/video_source_resource.h new file mode 100644 index 0000000..641a723 --- /dev/null +++ b/ppapi/proxy/video_source_resource.h @@ -0,0 +1,65 @@ +// Copyright (c) 2013 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_PROXY_VIDEO_SOURCE_RESOURCE_H_ +#define PPAPI_PROXY_VIDEO_SOURCE_RESOURCE_H_ + +#include <string> + +#include "ppapi/c/pp_time.h" +#include "ppapi/c/pp_var.h" +#include "ppapi/proxy/connection.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/thunk/ppb_video_source_private_api.h" + +struct PP_VideoFrame_Private; + +namespace ppapi { + +class TrackedCallback; + +namespace proxy { + +class PPAPI_PROXY_EXPORT VideoSourceResource + : public PluginResource, + public thunk::PPB_VideoSource_Private_API { + public: + VideoSourceResource(Connection connection, + PP_Instance instance); + virtual ~VideoSourceResource(); + + // Resource overrides. + virtual thunk::PPB_VideoSource_Private_API* + AsPPB_VideoSource_Private_API() OVERRIDE; + + // PPB_VideoSource_Private_API implementation. + virtual int32_t Open( + const PP_Var& stream_url, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual int32_t GetFrame( + PP_VideoFrame_Private* frame, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual void Close() OVERRIDE; + + private: + void OnPluginMsgOpenComplete( + const ResourceMessageReplyParams& params); + void OnPluginMsgGetFrameComplete( + PP_VideoFrame_Private* frame, + const ResourceMessageReplyParams& params, + const HostResource& image_data, + PP_TimeTicks timestamp); + + scoped_refptr<TrackedCallback> open_callback_; + scoped_refptr<TrackedCallback> get_frame_callback_; + bool is_open_; + + DISALLOW_COPY_AND_ASSIGN(VideoSourceResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_VIDEO_SOURCE_RESOURCE_H_ diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h index 4e7ff88..9333a0b 100644 --- a/ppapi/shared_impl/resource.h +++ b/ppapi/shared_impl/resource.h @@ -68,7 +68,9 @@ F(PPB_URLResponseInfo_API) \ F(PPB_VideoCapture_API) \ F(PPB_VideoDecoder_API) \ + F(PPB_VideoDestination_Private_API) \ F(PPB_VideoLayer_API) \ + F(PPB_VideoSource_Private_API) \ F(PPB_View_API) \ F(PPB_WebSocket_API) \ F(PPB_Widget_API) \ diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h index 60ac0bb..94dd53f 100644 --- a/ppapi/thunk/interfaces_ppb_private.h +++ b/ppapi/thunk/interfaces_ppb_private.h @@ -47,6 +47,11 @@ PROXIED_IFACE(NoAPIName, PPB_TALK_PRIVATE_INTERFACE_1_0, // This uses the FileIO API which is declared in the public stable file. PROXIED_IFACE(NoAPIName, PPB_FILEIOTRUSTED_INTERFACE_0_4, PPB_FileIOTrusted_0_4) +PROXIED_IFACE(NoAPIName, PPB_VIDEODESTINATION_PRIVATE_INTERFACE_0_1, + PPB_VideoDestination_Private_0_1) +PROXIED_IFACE(NoAPIName, PPB_VIDEOSOURCE_PRIVATE_INTERFACE_0_1, + PPB_VideoSource_Private_0_1) + // Hack to keep font working. The Font 0.6 API is binary compatible with // BrowserFont 1.0, so just map the string to the same thing. // TODO(brettw) remove support for the old Font API. diff --git a/ppapi/thunk/ppb_video_destination_private_api.h b/ppapi/thunk/ppb_video_destination_private_api.h new file mode 100644 index 0000000..49a696a --- /dev/null +++ b/ppapi/thunk/ppb_video_destination_private_api.h @@ -0,0 +1,32 @@ +// Copyright (c) 2013 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_DESTINATION_PRIVATE_API_H_ +#define PPAPI_THUNK_PPB_VIDEO_DESTINATION_PRIVATE_API_H_ + +#include "base/memory/ref_counted.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +struct PP_VideoFrame_Private; + +namespace ppapi { + +class TrackedCallback; + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_VideoDestination_Private_API { + public: + virtual ~PPB_VideoDestination_Private_API() {} + + virtual int32_t Open(const PP_Var& stream_url, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t PutFrame(const PP_VideoFrame_Private& frame) = 0; + virtual void Close() = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_VIDEO_DESTINATION_PRIVATE_API_H_ diff --git a/ppapi/thunk/ppb_video_destination_private_thunk.cc b/ppapi/thunk/ppb_video_destination_private_thunk.cc new file mode 100644 index 0000000..072b135 --- /dev/null +++ b/ppapi/thunk/ppb_video_destination_private_thunk.cc @@ -0,0 +1,74 @@ +// Copyright (c) 2013 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. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/pp_video_frame_private.h" +#include "ppapi/c/private/ppb_video_destination_private.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_destination_private_api.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateVideoDestination(instance); +} + +PP_Bool IsVideoDestination(PP_Resource resource) { + EnterResource<PPB_VideoDestination_Private_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t Open(PP_Resource destination, + PP_Var stream_url, + PP_CompletionCallback callback) { + EnterResource<PPB_VideoDestination_Private_API> enter(destination, + callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Open(stream_url, enter.callback())); +} + +int32_t PutFrame(PP_Resource destination, + const PP_VideoFrame_Private* frame) { + EnterResource<PPB_VideoDestination_Private_API> enter(destination, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->PutFrame(*frame)); +} + +void Close(PP_Resource destination) { + EnterResource<PPB_VideoDestination_Private_API> enter(destination, true); + if (enter.succeeded()) + enter.object()->Close(); +} + +const PPB_VideoDestination_Private_0_1 + g_ppb_video_destination_private_thunk_0_1 = { + &Create, + &IsVideoDestination, + &Open, + &PutFrame, + &Close +}; + +} // namespace + +const PPB_VideoDestination_Private_0_1* + GetPPB_VideoDestination_Private_0_1_Thunk() { + return &g_ppb_video_destination_private_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_video_source_private_api.h b/ppapi/thunk/ppb_video_source_private_api.h new file mode 100644 index 0000000..c732051 --- /dev/null +++ b/ppapi/thunk/ppb_video_source_private_api.h @@ -0,0 +1,33 @@ +// Copyright (c) 2013 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_SOURCE_PRIVATE_API_H_ +#define PPAPI_THUNK_PPB_VIDEO_SOURCE_PRIVATE_API_H_ + +#include "base/memory/ref_counted.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +struct PP_VideoFrame_Private; + +namespace ppapi { + +class TrackedCallback; + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_VideoSource_Private_API { + public: + virtual ~PPB_VideoSource_Private_API() {} + + virtual int32_t Open(const PP_Var& stream_url, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t GetFrame(PP_VideoFrame_Private* frame, + scoped_refptr<TrackedCallback> callback) = 0; + virtual void Close() = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_VIDEO_SOURCE_PRIVATE_API_H_ diff --git a/ppapi/thunk/ppb_video_source_private_thunk.cc b/ppapi/thunk/ppb_video_source_private_thunk.cc new file mode 100644 index 0000000..a2910a5 --- /dev/null +++ b/ppapi/thunk/ppb_video_source_private_thunk.cc @@ -0,0 +1,71 @@ +// Copyright (c) 2013 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. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/pp_video_frame_private.h" +#include "ppapi/c/private/ppb_video_source_private.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_video_source_private_api.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateVideoSource(instance); +} + +PP_Bool IsVideoSource(PP_Resource resource) { + EnterResource<PPB_VideoSource_Private_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t Open(PP_Resource source, + PP_Var stream_url, + PP_CompletionCallback callback) { + EnterResource<PPB_VideoSource_Private_API> enter(source, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Open(stream_url, enter.callback())); +} + +int32_t GetFrame(PP_Resource source, + PP_VideoFrame_Private* frame, + PP_CompletionCallback callback) { + EnterResource<PPB_VideoSource_Private_API> enter(source, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->GetFrame(frame, enter.callback())); +} + +void Close(PP_Resource source) { + EnterResource<PPB_VideoSource_Private_API> enter(source, true); + if (enter.succeeded()) + enter.object()->Close(); +} + +const PPB_VideoSource_Private_0_1 g_ppb_video_source_private_thunk_0_1 = { + &Create, + &IsVideoSource, + &Open, + &GetFrame, + &Close +}; + +} // namespace + +const PPB_VideoSource_Private_0_1* GetPPB_VideoSource_Private_0_1_Thunk() { + return &g_ppb_video_source_private_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 0eb4f83..d2c5129 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -167,6 +167,8 @@ class ResourceCreationAPI { PP_Instance instance, PP_Resource context3d_id, PP_VideoDecoder_Profile profile) = 0; + virtual PP_Resource CreateVideoDestination(PP_Instance instance) = 0; + virtual PP_Resource CreateVideoSource(PP_Instance instance) = 0; #endif // !defined(OS_NACL) static const ApiID kApiID = API_ID_RESOURCE_CREATION; |