Disable ContentSettingBubbleModelTest.RPHAllow which is flaky.
[chromium-blink-merge.git] / content / renderer / pepper / pepper_video_capture_host.h
blob03cfd0a501f82f842880618eada3d3cb9a89d609
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 "content/public/renderer/renderer_ppapi_host.h"
11 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h"
12 #include "media/video/capture/video_capture.h"
13 #include "media/video/capture/video_capture_types.h"
14 #include "ppapi/c/dev/ppp_video_capture_dev.h"
15 #include "ppapi/host/host_message_context.h"
16 #include "ppapi/host/resource_host.h"
17 #include "webkit/plugins/ppapi/plugin_delegate.h"
18 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
20 namespace content {
22 class PepperVideoCaptureHost
23 : public ppapi::host::ResourceHost,
24 public webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler,
25 public PepperDeviceEnumerationHostHelper::Delegate {
26 public:
27 PepperVideoCaptureHost(RendererPpapiHost* host,
28 PP_Instance instance,
29 PP_Resource resource);
31 virtual ~PepperVideoCaptureHost();
33 bool Init();
35 virtual int32_t OnResourceMessageReceived(
36 const IPC::Message& msg,
37 ppapi::host::HostMessageContext* context) OVERRIDE;
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;
54 // PepperDeviceEnumerationHostHelper::Delegate implementation.
55 virtual webkit::ppapi::PluginDelegate* GetPluginDelegate() OVERRIDE;
57 private:
58 int32_t OnOpen(ppapi::host::HostMessageContext* context,
59 const std::string& device_id,
60 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
61 uint32_t buffer_count);
62 int32_t OnStartCapture(ppapi::host::HostMessageContext* context);
63 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context,
64 uint32_t buffer);
65 int32_t OnStopCapture(ppapi::host::HostMessageContext* context);
66 int32_t OnClose(ppapi::host::HostMessageContext* context);
68 int32_t StopCapture();
69 int32_t Close();
70 void ReleaseBuffers();
71 void SendStatus();
73 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info,
74 uint32_t buffer_count);
76 void DetachPlatformVideoCapture();
78 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced);
80 scoped_refptr<webkit::ppapi::PluginDelegate::PlatformVideoCapture>
81 platform_video_capture_;
83 // Buffers of video frame.
84 struct BufferInfo {
85 BufferInfo();
86 ~BufferInfo();
88 bool in_use;
89 void* data;
90 scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> buffer;
93 RendererPpapiHost* renderer_ppapi_host_;
95 std::vector<BufferInfo> buffers_;
96 size_t buffer_count_hint_;
98 media::VideoCaptureCapability capability_;
100 PP_VideoCaptureStatus_Dev status_;
102 ppapi::host::ReplyMessageContext open_reply_context_;
104 PepperDeviceEnumerationHostHelper enumeration_helper_;
106 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost);
109 } // namespace content
111 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_