OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "content/public/renderer/renderer_ppapi_host.h" |
| 11 #include "media/video/capture/video_capture.h" |
| 12 #include "media/video/capture/video_capture_types.h" |
| 13 #include "ppapi/c/dev/ppp_video_capture_dev.h" |
| 14 #include "ppapi/host/host_message_context.h" |
| 15 #include "ppapi/host/resource_host.h" |
| 16 #include "ppapi/shared_impl/ppb_device_ref_shared.h" |
| 17 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 18 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
| 19 |
| 20 namespace content { |
| 21 |
| 22 class PepperVideoCaptureHost |
| 23 : public ppapi::host::ResourceHost, |
| 24 public webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler, |
| 25 public base::SupportsWeakPtr<PepperVideoCaptureHost> { |
| 26 public: |
| 27 PepperVideoCaptureHost(RendererPpapiHost* host, |
| 28 PP_Instance instance, |
| 29 PP_Resource resource); |
| 30 |
| 31 virtual ~PepperVideoCaptureHost(); |
| 32 |
| 33 bool Init(); |
| 34 |
| 35 virtual int32_t OnResourceMessageReceived( |
| 36 const IPC::Message& msg, |
| 37 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 38 |
| 39 // PluginDelegate::PlatformVideoCaptureEventHandler |
| 40 virtual void OnInitialized(media::VideoCapture* capture, |
| 41 bool succeeded) OVERRIDE; |
| 42 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; |
| 43 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; |
| 44 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; |
| 45 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; |
| 46 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; |
| 47 virtual void OnBufferReady( |
| 48 media::VideoCapture* capture, |
| 49 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) OVERRIDE; |
| 50 virtual void OnDeviceInfoReceived( |
| 51 media::VideoCapture* capture, |
| 52 const media::VideoCaptureParams& device_info) OVERRIDE; |
| 53 |
| 54 private: |
| 55 webkit::ppapi::PluginInstance* GetPluginInstance() const; |
| 56 |
| 57 int32_t OnEnumerateDevices( |
| 58 ppapi::host::HostMessageContext* context); |
| 59 int32_t OnOpen(ppapi::host::HostMessageContext* context, |
| 60 const std::string& device_id, |
| 61 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 62 uint32_t buffer_count); |
| 63 int32_t OnStartCapture(ppapi::host::HostMessageContext* context); |
| 64 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context, |
| 65 uint32_t buffer); |
| 66 int32_t OnStopCapture(ppapi::host::HostMessageContext* context); |
| 67 int32_t OnClose(ppapi::host::HostMessageContext* context); |
| 68 |
| 69 int32_t StopCapture(); |
| 70 int32_t Close(); |
| 71 void ReleaseBuffers(); |
| 72 void SendStatus(); |
| 73 |
| 74 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info, |
| 75 uint32_t buffer_count); |
| 76 |
| 77 void DetachPlatformVideoCapture(); |
| 78 |
| 79 void EnumerateDevicesCallbackFunc( |
| 80 int request_id, |
| 81 bool succeeded, |
| 82 const std::vector<ppapi::DeviceRefData>& devices); |
| 83 |
| 84 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); |
| 85 |
| 86 scoped_refptr<webkit::ppapi::PluginDelegate::PlatformVideoCapture> |
| 87 platform_video_capture_; |
| 88 |
| 89 // Buffers of video frame. |
| 90 struct BufferInfo { |
| 91 BufferInfo(); |
| 92 ~BufferInfo(); |
| 93 |
| 94 bool in_use; |
| 95 void* data; |
| 96 scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> buffer; |
| 97 }; |
| 98 |
| 99 RendererPpapiHost* renderer_ppapi_host_; |
| 100 |
| 101 std::vector<BufferInfo> buffers_; |
| 102 size_t buffer_count_hint_; |
| 103 |
| 104 media::VideoCaptureCapability capability_; |
| 105 |
| 106 PP_VideoCaptureStatus_Dev status_; |
| 107 |
| 108 ppapi::host::ReplyMessageContext open_reply_context_; |
| 109 ppapi::host::ReplyMessageContext enum_reply_context_; |
| 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost); |
| 112 }; |
| 113 |
| 114 } // namespace content |
| 115 |
| 116 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ |
OLD | NEW |