| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "content/public/renderer/renderer_ppapi_host.h" | 10 #include "content/public/renderer/renderer_ppapi_host.h" |
| 11 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" | 11 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" |
| 12 #include "content/renderer/pepper/ppb_buffer_impl.h" | 12 #include "content/renderer/pepper/ppb_buffer_impl.h" |
| 13 #include "media/video/capture/video_capture.h" | 13 #include "media/video/capture/video_capture.h" |
| 14 #include "media/video/capture/video_capture_types.h" | 14 #include "media/video/capture/video_capture_types.h" |
| 15 #include "ppapi/c/dev/ppp_video_capture_dev.h" | 15 #include "ppapi/c/dev/ppp_video_capture_dev.h" |
| 16 #include "ppapi/host/host_message_context.h" | 16 #include "ppapi/host/host_message_context.h" |
| 17 #include "ppapi/host/resource_host.h" | 17 #include "ppapi/host/resource_host.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class PepperPlatformVideoCapture; | 20 class PepperPlatformVideoCapture; |
| 21 class RendererPpapiHostImpl; | 21 class RendererPpapiHostImpl; |
| 22 | 22 |
| 23 class PepperVideoCaptureHost | 23 class PepperVideoCaptureHost : public ppapi::host::ResourceHost, |
| 24 : public ppapi::host::ResourceHost, | 24 public media::VideoCapture::EventHandler { |
| 25 public media::VideoCapture::EventHandler { | |
| 26 public: | 25 public: |
| 27 PepperVideoCaptureHost(RendererPpapiHostImpl* host, | 26 PepperVideoCaptureHost(RendererPpapiHostImpl* host, |
| 28 PP_Instance instance, | 27 PP_Instance instance, |
| 29 PP_Resource resource); | 28 PP_Resource resource); |
| 30 | 29 |
| 31 virtual ~PepperVideoCaptureHost(); | 30 virtual ~PepperVideoCaptureHost(); |
| 32 | 31 |
| 33 bool Init(); | 32 bool Init(); |
| 34 | 33 |
| 35 virtual int32_t OnResourceMessageReceived( | 34 virtual int32_t OnResourceMessageReceived( |
| 36 const IPC::Message& msg, | 35 const IPC::Message& msg, |
| 37 ppapi::host::HostMessageContext* context) OVERRIDE; | 36 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 38 | 37 |
| 39 void OnInitialized(media::VideoCapture* capture, bool succeeded); | 38 void OnInitialized(media::VideoCapture* capture, bool succeeded); |
| 40 | 39 |
| 41 // media::VideoCapture::EventHandler | 40 // media::VideoCapture::EventHandler |
| 42 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; | 41 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; |
| 43 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; | 42 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; |
| 44 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; | 43 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; |
| 45 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; | 44 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; |
| 46 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; | 45 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; |
| 47 virtual void OnFrameReady( | 46 virtual void OnFrameReady(media::VideoCapture* capture, |
| 48 media::VideoCapture* capture, | 47 const scoped_refptr<media::VideoFrame>& frame) |
| 49 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; | 48 OVERRIDE; |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 int32_t OnOpen(ppapi::host::HostMessageContext* context, | 51 int32_t OnOpen(ppapi::host::HostMessageContext* context, |
| 53 const std::string& device_id, | 52 const std::string& device_id, |
| 54 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 53 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 55 uint32_t buffer_count); | 54 uint32_t buffer_count); |
| 56 int32_t OnStartCapture(ppapi::host::HostMessageContext* context); | 55 int32_t OnStartCapture(ppapi::host::HostMessageContext* context); |
| 57 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context, | 56 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context, |
| 58 uint32_t buffer); | 57 uint32_t buffer); |
| 59 int32_t OnStopCapture(ppapi::host::HostMessageContext* context); | 58 int32_t OnStopCapture(ppapi::host::HostMessageContext* context); |
| 60 int32_t OnClose(ppapi::host::HostMessageContext* context); | 59 int32_t OnClose(ppapi::host::HostMessageContext* context); |
| 61 | 60 |
| 62 int32_t StopCapture(); | 61 int32_t StopCapture(); |
| 63 int32_t Close(); | 62 int32_t Close(); |
| 64 void PostErrorReply(); | 63 void PostErrorReply(); |
| 65 void AllocBuffers(const gfx::Size& resolution, | 64 void AllocBuffers(const gfx::Size& resolution, int frame_rate); |
| 66 int frame_rate); | |
| 67 void ReleaseBuffers(); | 65 void ReleaseBuffers(); |
| 68 void SendStatus(); | 66 void SendStatus(); |
| 69 | 67 |
| 70 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info, | 68 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info, |
| 71 uint32_t buffer_count); | 69 uint32_t buffer_count); |
| 72 | 70 |
| 73 void DetachPlatformVideoCapture(); | 71 void DetachPlatformVideoCapture(); |
| 74 | 72 |
| 75 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); | 73 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); |
| 76 | 74 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 99 ppapi::host::ReplyMessageContext open_reply_context_; | 97 ppapi::host::ReplyMessageContext open_reply_context_; |
| 100 | 98 |
| 101 PepperDeviceEnumerationHostHelper enumeration_helper_; | 99 PepperDeviceEnumerationHostHelper enumeration_helper_; |
| 102 | 100 |
| 103 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost); | 101 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost); |
| 104 }; | 102 }; |
| 105 | 103 |
| 106 } // namespace content | 104 } // namespace content |
| 107 | 105 |
| 108 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ | 106 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ |
| OLD | NEW |