Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "media/video/capture/video_capture.h" | 15 #include "content/common/media/video_capture.h" |
| 15 #include "media/video/capture/video_capture_types.h" | 16 #include "media/video/capture/video_capture_types.h" |
| 16 | 17 |
| 17 class GURL; | 18 class GURL; |
| 18 | 19 |
| 19 namespace media { | |
| 20 class VideoCaptureHandlerProxy; | |
| 21 } | |
| 22 | |
| 23 namespace content { | 20 namespace content { |
| 24 class PepperMediaDeviceManager; | 21 class PepperMediaDeviceManager; |
| 25 class PepperVideoCaptureHost; | 22 class PepperVideoCaptureHost; |
| 26 class RenderViewImpl; | 23 class RenderViewImpl; |
| 27 class VideoCaptureHandle; | |
| 28 | 24 |
| 29 class PepperPlatformVideoCapture | 25 class PepperPlatformVideoCapture { |
|
Ami GONE FROM CHROMIUM
2014/04/21 23:42:53
Please doco lifecycle/threading assumptions of thi
Alpha Left Google
2014/04/23 18:48:33
Done.
| |
| 30 : public media::VideoCapture, | |
| 31 public base::RefCounted<PepperPlatformVideoCapture>, | |
| 32 public media::VideoCapture::EventHandler { | |
| 33 public: | 26 public: |
| 34 PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view, | 27 PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view, |
| 35 const std::string& device_id, | 28 const std::string& device_id, |
| 36 const GURL& document_url, | 29 const GURL& document_url, |
| 37 PepperVideoCaptureHost* handler); | 30 PepperVideoCaptureHost* handler); |
| 31 virtual ~PepperPlatformVideoCapture(); | |
| 38 | 32 |
| 39 // Detaches the event handler and stops sending notifications to it. | 33 // Detaches the event handler and stops sending notifications to it. |
| 40 void DetachEventHandler(); | 34 void DetachEventHandler(); |
| 41 | 35 |
| 42 // media::VideoCapture implementation. | 36 void StartCapture(const media::VideoCaptureParams& params); |
| 43 virtual void StartCapture(media::VideoCapture::EventHandler* handler, | 37 void StopCapture(); |
| 44 const media::VideoCaptureParams& params) OVERRIDE; | |
| 45 virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE; | |
| 46 virtual bool CaptureStarted() OVERRIDE; | |
| 47 virtual int CaptureFrameRate() OVERRIDE; | |
| 48 virtual void GetDeviceSupportedFormats(const DeviceFormatsCallback& callback) | |
| 49 OVERRIDE; | |
| 50 virtual void GetDeviceFormatsInUse(const DeviceFormatsInUseCallback& callback) | |
| 51 OVERRIDE; | |
| 52 | |
| 53 // media::VideoCapture::EventHandler implementation | |
| 54 virtual void OnStarted(VideoCapture* capture) OVERRIDE; | |
| 55 virtual void OnStopped(VideoCapture* capture) OVERRIDE; | |
| 56 virtual void OnPaused(VideoCapture* capture) OVERRIDE; | |
| 57 virtual void OnError(VideoCapture* capture, int error_code) OVERRIDE; | |
| 58 virtual void OnRemoved(VideoCapture* capture) OVERRIDE; | |
| 59 virtual void OnFrameReady(VideoCapture* capture, | |
| 60 const scoped_refptr<media::VideoFrame>& frame) | |
| 61 OVERRIDE; | |
| 62 | |
| 63 protected: | |
| 64 friend class base::RefCounted<PepperPlatformVideoCapture>; | |
| 65 virtual ~PepperPlatformVideoCapture(); | |
| 66 | 38 |
| 67 private: | 39 private: |
| 68 void Initialize(); | |
| 69 | |
| 70 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); | 40 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); |
| 41 void OnStateUpdate(VideoCaptureState state); | |
| 42 void OnFrameReady( | |
| 43 const scoped_refptr<media::VideoFrame>& frame, | |
| 44 const media::VideoCaptureFormat& format, | |
| 45 const base::TimeTicks& timestamp); | |
| 71 | 46 |
| 72 PepperMediaDeviceManager* GetMediaDeviceManager(); | 47 PepperMediaDeviceManager* GetMediaDeviceManager(); |
| 73 | 48 |
| 74 base::WeakPtr<RenderViewImpl> render_view_; | 49 base::WeakPtr<RenderViewImpl> render_view_; |
| 75 | 50 |
| 76 std::string device_id_; | 51 std::string device_id_; |
| 77 std::string label_; | 52 std::string label_; |
| 78 int session_id_; | 53 int session_id_; |
| 79 | 54 base::Closure release_device_cb_; |
| 80 scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_; | 55 base::Closure stop_capture_cb_; |
| 81 | 56 |
| 82 PepperVideoCaptureHost* handler_; | 57 PepperVideoCaptureHost* handler_; |
| 83 | 58 |
| 84 scoped_ptr<VideoCaptureHandle> video_capture_; | |
| 85 | |
| 86 // StartCapture() must be balanced by StopCapture(), otherwise this object | |
| 87 // will leak. | |
| 88 bool unbalanced_start_; | |
| 89 | |
| 90 // Whether we have a pending request to open a device. We have to make sure | 59 // Whether we have a pending request to open a device. We have to make sure |
| 91 // there isn't any pending request before this object goes away. | 60 // there isn't any pending request before this object goes away. |
| 92 bool pending_open_device_; | 61 bool pending_open_device_; |
| 93 int pending_open_device_id_; | 62 int pending_open_device_id_; |
| 94 | 63 |
| 64 base::WeakPtrFactory<PepperPlatformVideoCapture> weak_factory_; | |
| 65 | |
| 95 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture); | 66 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture); |
| 96 }; | 67 }; |
| 97 | 68 |
| 98 } // namespace content | 69 } // namespace content |
| 99 | 70 |
| 100 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ | 71 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ |
| OLD | NEW |