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_PLATFORM_VIDEO_CAPTURE_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_CAPTURE_IMPL_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "media/video/capture/video_capture.h"
16 #include "webkit/plugins/ppapi/plugin_delegate.h"
18 class PepperPluginDelegateImpl
;
21 class VideoCaptureHandlerProxy
;
24 class PepperPlatformVideoCaptureImpl
25 : public webkit::ppapi::PluginDelegate::PlatformVideoCapture
,
26 public media::VideoCapture::EventHandler
{
28 PepperPlatformVideoCaptureImpl(
29 const base::WeakPtr
<PepperPluginDelegateImpl
>& plugin_delegate
,
30 const std::string
& device_id
,
31 webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler
* handler
);
32 virtual ~PepperPlatformVideoCaptureImpl();
34 // webkit::ppapi::PluginDelegate::PlatformVideoCapture implementation.
35 virtual void StartCapture(media::VideoCapture::EventHandler
* handler
,
36 const VideoCaptureCapability
& capability
) OVERRIDE
;
37 virtual void StopCapture(media::VideoCapture::EventHandler
* handler
) OVERRIDE
;
38 virtual void FeedBuffer(scoped_refptr
<VideoFrameBuffer
> buffer
) OVERRIDE
;
39 virtual bool CaptureStarted() OVERRIDE
;
40 virtual int CaptureWidth() OVERRIDE
;
41 virtual int CaptureHeight() OVERRIDE
;
42 virtual int CaptureFrameRate() OVERRIDE
;
43 virtual void DetachEventHandler() OVERRIDE
;
45 // media::VideoCapture::EventHandler implementation
46 virtual void OnStarted(VideoCapture
* capture
) OVERRIDE
;
47 virtual void OnStopped(VideoCapture
* capture
) OVERRIDE
;
48 virtual void OnPaused(VideoCapture
* capture
) OVERRIDE
;
49 virtual void OnError(VideoCapture
* capture
, int error_code
) OVERRIDE
;
50 virtual void OnRemoved(VideoCapture
* capture
) OVERRIDE
;
51 virtual void OnBufferReady(VideoCapture
* capture
,
52 scoped_refptr
<VideoFrameBuffer
> buffer
) OVERRIDE
;
53 virtual void OnDeviceInfoReceived(
54 VideoCapture
* capture
,
55 const media::VideoCaptureParams
& device_info
) OVERRIDE
;
60 void OnDeviceOpened(int request_id
,
62 const std::string
& label
);
64 base::WeakPtr
<PepperPluginDelegateImpl
> plugin_delegate_
;
66 std::string device_id_
;
70 scoped_ptr
<media::VideoCaptureHandlerProxy
> handler_proxy_
;
72 webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler
* handler_
;
74 media::VideoCapture
* video_capture_
;
76 // StartCapture() must be balanced by StopCapture(), otherwise this object
78 bool unbalanced_start_
;
80 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCaptureImpl
);
83 #endif // CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_CAPTURE_IMPL_H_