[safe_browsing] Remove unused ContainsBrowseUrl() parameter.
[chromium-blink-merge.git] / content / renderer / pepper / pepper_video_capture_host.h
blob8326c5ec1aa4c4d9cd72b769c754489f0fb85872
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"
20 namespace media {
21 class VideoFrame;
22 } // namespace media
24 namespace content {
25 class PepperPlatformVideoCapture;
26 class RendererPpapiHostImpl;
28 class PepperVideoCaptureHost : public ppapi::host::ResourceHost {
29 public:
30 PepperVideoCaptureHost(RendererPpapiHostImpl* host,
31 PP_Instance instance,
32 PP_Resource resource);
34 virtual ~PepperVideoCaptureHost();
36 bool Init();
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.
49 void OnStarted();
51 // Called when video capture has stopped. There will be no more
52 // frames delivered.
53 void OnStopped();
55 // Called when video capture has paused.
56 void OnPaused();
58 // Called when video capture cannot be started because of an error.
59 void OnError();
61 // Called when a video frame is ready.
62 void OnFrameReady(const scoped_refptr<media::VideoFrame>& frame,
63 media::VideoCaptureFormat format);
65 private:
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,
72 uint32_t buffer);
73 int32_t OnStopCapture(ppapi::host::HostMessageContext* context);
74 int32_t OnClose(ppapi::host::HostMessageContext* context);
76 int32_t StopCapture();
77 int32_t Close();
78 void PostErrorReply();
79 void AllocBuffers(const gfx::Size& resolution, int frame_rate);
80 void ReleaseBuffers();
81 void SendStatus();
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.
93 struct BufferInfo {
94 BufferInfo();
95 ~BufferInfo();
97 bool in_use;
98 void* data;
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_