| 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/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/time/time.h" |
| 16 #include "content/common/media/video_capture.h" | 17 #include "content/common/media/video_capture.h" |
| 17 #include "media/video/capture/video_capture_types.h" | 18 #include "media/video/capture/video_capture_types.h" |
| 18 | 19 |
| 19 class GURL; | 20 class GURL; |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 class PepperMediaDeviceManager; | 23 class PepperMediaDeviceManager; |
| 23 class PepperVideoCaptureHost; | 24 class PepperVideoCaptureHost; |
| 24 class RenderViewImpl; | 25 class RenderViewImpl; |
| 25 | 26 |
| 26 // This object must only be used on the thread it's constructed on. | 27 // This object must only be used on the thread it's constructed on. |
| 27 class PepperPlatformVideoCapture { | 28 class PepperPlatformVideoCapture { |
| 28 public: | 29 public: |
| 29 PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view, | 30 PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view, |
| 30 const std::string& device_id, | 31 const std::string& device_id, |
| 31 const GURL& document_url, | 32 const GURL& document_url, |
| 32 PepperVideoCaptureHost* handler); | 33 PepperVideoCaptureHost* handler); |
| 33 virtual ~PepperPlatformVideoCapture(); | 34 virtual ~PepperPlatformVideoCapture(); |
| 34 | 35 |
| 35 // Detaches the event handler and stops sending notifications to it. | 36 // Detaches the event handler and stops sending notifications to it. |
| 36 void DetachEventHandler(); | 37 void DetachEventHandler(); |
| 37 | 38 |
| 38 void StartCapture(const media::VideoCaptureParams& params); | 39 void StartCapture(const media::VideoCaptureParams& params); |
| 39 void StopCapture(); | 40 void StopCapture(); |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); | 43 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); |
| 43 void OnStateUpdate(VideoCaptureState state); | 44 void OnStateUpdate(VideoCaptureState state); |
| 44 void OnFrameReady(const scoped_refptr<media::VideoFrame>& frame, | 45 void OnFrameReady(const scoped_refptr<media::VideoFrame>& frame, |
| 45 const media::VideoCaptureFormat& format); | 46 const media::VideoCaptureFormat& format, |
| 47 const base::TimeTicks& estimated_capture_time); |
| 46 | 48 |
| 47 PepperMediaDeviceManager* GetMediaDeviceManager(); | 49 PepperMediaDeviceManager* GetMediaDeviceManager(); |
| 48 | 50 |
| 49 base::WeakPtr<RenderViewImpl> render_view_; | 51 base::WeakPtr<RenderViewImpl> render_view_; |
| 50 | 52 |
| 51 std::string device_id_; | 53 std::string device_id_; |
| 52 std::string label_; | 54 std::string label_; |
| 53 int session_id_; | 55 int session_id_; |
| 54 base::Closure release_device_cb_; | 56 base::Closure release_device_cb_; |
| 55 base::Closure stop_capture_cb_; | 57 base::Closure stop_capture_cb_; |
| 56 | 58 |
| 57 PepperVideoCaptureHost* handler_; | 59 PepperVideoCaptureHost* handler_; |
| 58 | 60 |
| 59 // Whether we have a pending request to open a device. We have to make sure | 61 // Whether we have a pending request to open a device. We have to make sure |
| 60 // there isn't any pending request before this object goes away. | 62 // there isn't any pending request before this object goes away. |
| 61 bool pending_open_device_; | 63 bool pending_open_device_; |
| 62 int pending_open_device_id_; | 64 int pending_open_device_id_; |
| 63 | 65 |
| 64 base::ThreadChecker thread_checker_; | 66 base::ThreadChecker thread_checker_; |
| 65 | 67 |
| 66 base::WeakPtrFactory<PepperPlatformVideoCapture> weak_factory_; | 68 base::WeakPtrFactory<PepperPlatformVideoCapture> weak_factory_; |
| 67 | 69 |
| 68 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture); | 70 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture); |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 } // namespace content | 73 } // namespace content |
| 72 | 74 |
| 73 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ | 75 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ |
| OLD | NEW |