OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_CAPTURE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_CAPTURE_IMPL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 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" |
| 17 |
| 18 class PepperPluginDelegateImpl; |
| 19 |
| 20 namespace media { |
| 21 class VideoCaptureHandlerProxy; |
| 22 } |
| 23 |
| 24 class PepperPlatformVideoCaptureImpl |
| 25 : public webkit::ppapi::PluginDelegate::PlatformVideoCapture, |
| 26 public media::VideoCapture::EventHandler { |
| 27 public: |
| 28 PepperPlatformVideoCaptureImpl( |
| 29 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, |
| 30 const std::string& device_id, |
| 31 webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler* handler); |
| 32 virtual ~PepperPlatformVideoCaptureImpl(); |
| 33 |
| 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; |
| 44 |
| 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; |
| 56 |
| 57 private: |
| 58 void Initialize(); |
| 59 |
| 60 void OnDeviceOpened(int request_id, |
| 61 bool succeeded, |
| 62 const std::string& label); |
| 63 |
| 64 base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_; |
| 65 |
| 66 std::string device_id_; |
| 67 std::string label_; |
| 68 int session_id_; |
| 69 |
| 70 scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_; |
| 71 |
| 72 webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler* handler_; |
| 73 |
| 74 media::VideoCapture* video_capture_; |
| 75 |
| 76 // StartCapture() must be balanced by StopCapture(), otherwise this object |
| 77 // will leak. |
| 78 bool unbalanced_start_; |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCaptureImpl); |
| 81 }; |
| 82 |
| 83 #endif // CONTENT_RENDERER_PEPPER_PLATFORM_VIDEO_CAPTURE_IMPL_H_ |
OLD | NEW |