| 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 "base/memory/scoped_ptr.h" | |
| 11 #include "content/common/media/video_capture.h" | |
| 12 #include "content/public/renderer/renderer_ppapi_host.h" | 10 #include "content/public/renderer/renderer_ppapi_host.h" |
| 13 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" | 11 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" |
| 14 #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" |
| 15 #include "media/video/capture/video_capture_types.h" | 14 #include "media/video/capture/video_capture_types.h" |
| 16 #include "ppapi/c/dev/ppp_video_capture_dev.h" | 15 #include "ppapi/c/dev/ppp_video_capture_dev.h" |
| 17 #include "ppapi/host/host_message_context.h" | 16 #include "ppapi/host/host_message_context.h" |
| 18 #include "ppapi/host/resource_host.h" | 17 #include "ppapi/host/resource_host.h" |
| 19 | 18 |
| 20 namespace media { | |
| 21 class VideoFrame; | |
| 22 } // namespace media | |
| 23 | |
| 24 namespace content { | 19 namespace content { |
| 25 class PepperPlatformVideoCapture; | 20 class PepperPlatformVideoCapture; |
| 26 class RendererPpapiHostImpl; | 21 class RendererPpapiHostImpl; |
| 27 | 22 |
| 28 class PepperVideoCaptureHost : public ppapi::host::ResourceHost { | 23 class PepperVideoCaptureHost : public ppapi::host::ResourceHost, |
| 24 public media::VideoCapture::EventHandler { |
| 29 public: | 25 public: |
| 30 PepperVideoCaptureHost(RendererPpapiHostImpl* host, | 26 PepperVideoCaptureHost(RendererPpapiHostImpl* host, |
| 31 PP_Instance instance, | 27 PP_Instance instance, |
| 32 PP_Resource resource); | 28 PP_Resource resource); |
| 33 | 29 |
| 34 virtual ~PepperVideoCaptureHost(); | 30 virtual ~PepperVideoCaptureHost(); |
| 35 | 31 |
| 36 bool Init(); | 32 bool Init(); |
| 37 | 33 |
| 38 virtual int32_t OnResourceMessageReceived( | 34 virtual int32_t OnResourceMessageReceived( |
| 39 const IPC::Message& msg, | 35 const IPC::Message& msg, |
| 40 ppapi::host::HostMessageContext* context) OVERRIDE; | 36 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 41 | 37 |
| 42 // These methods are called by PepperPlatformVideoCapture only. | 38 void OnInitialized(media::VideoCapture* capture, bool succeeded); |
| 43 | 39 |
| 44 // Called when video capture is initialized. We can start | 40 // media::VideoCapture::EventHandler |
| 45 // video capture if |succeeded| is true. | 41 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; |
| 46 void OnInitialized(bool succeeded); | 42 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; |
| 47 | 43 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; |
| 48 // Called when video capture has started successfully. | 44 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; |
| 49 void OnStarted(); | 45 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; |
| 50 | 46 virtual void OnFrameReady(media::VideoCapture* capture, |
| 51 // Called when video capture has stopped. There will be no more | 47 const scoped_refptr<media::VideoFrame>& frame) |
| 52 // frames delivered. | 48 OVERRIDE; |
| 53 void OnStopped(); | |
| 54 | |
| 55 // Called when video capture has paused. | |
| 56 void OnPaused(); | |
| 57 | |
| 58 // Called when video capture cannot be started because of an error. | |
| 59 void OnError(); | |
| 60 | |
| 61 // Called when a video frame is ready. | |
| 62 void OnFrameReady(const scoped_refptr<media::VideoFrame>& frame, | |
| 63 media::VideoCaptureFormat format); | |
| 64 | 49 |
| 65 private: | 50 private: |
| 66 int32_t OnOpen(ppapi::host::HostMessageContext* context, | 51 int32_t OnOpen(ppapi::host::HostMessageContext* context, |
| 67 const std::string& device_id, | 52 const std::string& device_id, |
| 68 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 53 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 69 uint32_t buffer_count); | 54 uint32_t buffer_count); |
| 70 int32_t OnStartCapture(ppapi::host::HostMessageContext* context); | 55 int32_t OnStartCapture(ppapi::host::HostMessageContext* context); |
| 71 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context, | 56 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context, |
| 72 uint32_t buffer); | 57 uint32_t buffer); |
| 73 int32_t OnStopCapture(ppapi::host::HostMessageContext* context); | 58 int32_t OnStopCapture(ppapi::host::HostMessageContext* context); |
| 74 int32_t OnClose(ppapi::host::HostMessageContext* context); | 59 int32_t OnClose(ppapi::host::HostMessageContext* context); |
| 75 | 60 |
| 76 int32_t StopCapture(); | 61 int32_t StopCapture(); |
| 77 int32_t Close(); | 62 int32_t Close(); |
| 78 void PostErrorReply(); | 63 void PostErrorReply(); |
| 79 void AllocBuffers(const gfx::Size& resolution, int frame_rate); | 64 void AllocBuffers(const gfx::Size& resolution, int frame_rate); |
| 80 void ReleaseBuffers(); | 65 void ReleaseBuffers(); |
| 81 void SendStatus(); | 66 void SendStatus(); |
| 82 | 67 |
| 83 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info, | 68 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info, |
| 84 uint32_t buffer_count); | 69 uint32_t buffer_count); |
| 85 | 70 |
| 86 void DetachPlatformVideoCapture(); | 71 void DetachPlatformVideoCapture(); |
| 87 | 72 |
| 88 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); | 73 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); |
| 89 | 74 |
| 90 scoped_ptr<PepperPlatformVideoCapture> platform_video_capture_; | 75 scoped_refptr<PepperPlatformVideoCapture> platform_video_capture_; |
| 91 | 76 |
| 92 // Buffers of video frame. | 77 // Buffers of video frame. |
| 93 struct BufferInfo { | 78 struct BufferInfo { |
| 94 BufferInfo(); | 79 BufferInfo(); |
| 95 ~BufferInfo(); | 80 ~BufferInfo(); |
| 96 | 81 |
| 97 bool in_use; | 82 bool in_use; |
| 98 void* data; | 83 void* data; |
| 99 scoped_refptr<PPB_Buffer_Impl> buffer; | 84 scoped_refptr<PPB_Buffer_Impl> buffer; |
| 100 }; | 85 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 112 ppapi::host::ReplyMessageContext open_reply_context_; | 97 ppapi::host::ReplyMessageContext open_reply_context_; |
| 113 | 98 |
| 114 PepperDeviceEnumerationHostHelper enumeration_helper_; | 99 PepperDeviceEnumerationHostHelper enumeration_helper_; |
| 115 | 100 |
| 116 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost); | 101 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost); |
| 117 }; | 102 }; |
| 118 | 103 |
| 119 } // namespace content | 104 } // namespace content |
| 120 | 105 |
| 121 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ | 106 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ |
| OLD | NEW |