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_PLATFORM_VIDEO_CAPTURE_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_IMPL_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "media/video/capture/video_capture.h"
15 #include "media/video/capture/video_capture_types.h"
16 #include "webkit/plugins/ppapi/plugin_delegate.h"
19 class VideoCaptureHandlerProxy
;
24 class PepperPluginDelegateImpl
;
26 class PepperPlatformVideoCaptureImpl
27 : public webkit::ppapi::PluginDelegate::PlatformVideoCapture
,
28 public media::VideoCapture::EventHandler
{
30 PepperPlatformVideoCaptureImpl(
31 const base::WeakPtr
<PepperPluginDelegateImpl
>& plugin_delegate
,
32 const std::string
& device_id
,
33 webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler
* handler
);
35 // webkit::ppapi::PluginDelegate::PlatformVideoCapture implementation.
36 virtual void StartCapture(
37 media::VideoCapture::EventHandler
* handler
,
38 const media::VideoCaptureCapability
& capability
) OVERRIDE
;
39 virtual void StopCapture(media::VideoCapture::EventHandler
* handler
) OVERRIDE
;
40 virtual void FeedBuffer(scoped_refptr
<VideoFrameBuffer
> buffer
) OVERRIDE
;
41 virtual bool CaptureStarted() OVERRIDE
;
42 virtual int CaptureWidth() OVERRIDE
;
43 virtual int CaptureHeight() OVERRIDE
;
44 virtual int CaptureFrameRate() OVERRIDE
;
45 virtual void DetachEventHandler() OVERRIDE
;
47 // media::VideoCapture::EventHandler implementation
48 virtual void OnStarted(VideoCapture
* capture
) OVERRIDE
;
49 virtual void OnStopped(VideoCapture
* capture
) OVERRIDE
;
50 virtual void OnPaused(VideoCapture
* capture
) OVERRIDE
;
51 virtual void OnError(VideoCapture
* capture
, int error_code
) OVERRIDE
;
52 virtual void OnRemoved(VideoCapture
* capture
) OVERRIDE
;
53 virtual void OnBufferReady(VideoCapture
* capture
,
54 scoped_refptr
<VideoFrameBuffer
> buffer
) OVERRIDE
;
55 virtual void OnDeviceInfoReceived(
56 VideoCapture
* capture
,
57 const media::VideoCaptureParams
& device_info
) OVERRIDE
;
60 virtual ~PepperPlatformVideoCaptureImpl();
65 void OnDeviceOpened(int request_id
,
67 const std::string
& label
);
69 base::WeakPtr
<PepperPluginDelegateImpl
> plugin_delegate_
;
71 std::string device_id_
;
75 scoped_ptr
<media::VideoCaptureHandlerProxy
> handler_proxy_
;
77 webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler
* handler_
;
79 media::VideoCapture
* video_capture_
;
81 // StartCapture() must be balanced by StopCapture(), otherwise this object
83 bool unbalanced_start_
;
85 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCaptureImpl
);
88 } // namespace content
90 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_IMPL_H_