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.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_
8 #include "base/compiler_specific.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"
13 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h"
14 #include "content/renderer/pepper/ppb_buffer_impl.h"
15 #include "media/video/capture/video_capture_types.h"
16 #include "ppapi/c/dev/ppp_video_capture_dev.h"
17 #include "ppapi/host/host_message_context.h"
18 #include "ppapi/host/resource_host.h"
25 class PepperPlatformVideoCapture
;
26 class RendererPpapiHostImpl
;
28 class PepperVideoCaptureHost
: public ppapi::host::ResourceHost
{
30 PepperVideoCaptureHost(RendererPpapiHostImpl
* host
,
32 PP_Resource resource
);
34 virtual ~PepperVideoCaptureHost();
38 virtual int32_t OnResourceMessageReceived(
39 const IPC::Message
& msg
,
40 ppapi::host::HostMessageContext
* context
) OVERRIDE
;
42 // These methods are called by PepperPlatformVideoCapture only.
44 // Called when video capture is initialized. We can start
45 // video capture if |succeeded| is true.
46 void OnInitialized(bool succeeded
);
48 // Called when video capture has started successfully.
51 // Called when video capture has stopped. There will be no more
55 // Called when video capture has paused.
58 // Called when video capture cannot be started because of an error.
61 // Called when a video frame is ready.
62 void OnFrameReady(const scoped_refptr
<media::VideoFrame
>& frame
,
63 media::VideoCaptureFormat format
);
66 int32_t OnOpen(ppapi::host::HostMessageContext
* context
,
67 const std::string
& device_id
,
68 const PP_VideoCaptureDeviceInfo_Dev
& requested_info
,
69 uint32_t buffer_count
);
70 int32_t OnStartCapture(ppapi::host::HostMessageContext
* context
);
71 int32_t OnReuseBuffer(ppapi::host::HostMessageContext
* context
,
73 int32_t OnStopCapture(ppapi::host::HostMessageContext
* context
);
74 int32_t OnClose(ppapi::host::HostMessageContext
* context
);
76 int32_t StopCapture();
78 void PostErrorReply();
79 void AllocBuffers(const gfx::Size
& resolution
, int frame_rate
);
80 void ReleaseBuffers();
83 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev
& device_info
,
84 uint32_t buffer_count
);
86 void DetachPlatformVideoCapture();
88 bool SetStatus(PP_VideoCaptureStatus_Dev status
, bool forced
);
90 scoped_ptr
<PepperPlatformVideoCapture
> platform_video_capture_
;
92 // Buffers of video frame.
99 scoped_refptr
<PPB_Buffer_Impl
> buffer
;
102 RendererPpapiHostImpl
* renderer_ppapi_host_
;
104 gfx::Size alloc_size_
;
105 std::vector
<BufferInfo
> buffers_
;
106 size_t buffer_count_hint_
;
108 media::VideoCaptureParams video_capture_params_
;
110 PP_VideoCaptureStatus_Dev status_
;
112 ppapi::host::ReplyMessageContext open_reply_context_
;
114 PepperDeviceEnumerationHostHelper enumeration_helper_
;
116 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost
);
119 } // namespace content
121 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_