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 "base/threading/thread_checker.h" |
16 #include "content/common/media/video_capture.h" | |
15 #include "media/video/capture/video_capture_types.h" | 17 #include "media/video/capture/video_capture_types.h" |
16 | 18 |
17 class GURL; | 19 class GURL; |
18 | 20 |
19 namespace media { | |
20 class VideoCaptureHandlerProxy; | |
21 } | |
22 | |
23 namespace content { | 21 namespace content { |
24 class PepperMediaDeviceManager; | 22 class PepperMediaDeviceManager; |
25 class PepperVideoCaptureHost; | 23 class PepperVideoCaptureHost; |
26 class RenderViewImpl; | 24 class RenderViewImpl; |
27 class VideoCaptureHandle; | |
28 | 25 |
29 class PepperPlatformVideoCapture | 26 // This is a render thread only object. All methods must be accessed on |
30 : public media::VideoCapture, | 27 // the render thread including cosntructor and destructor. |
bbudge
2014/04/25 23:18:58
sp constructor
Alpha Left Google
2014/04/25 23:33:23
Done.
| |
31 public base::RefCounted<PepperPlatformVideoCapture>, | 28 class PepperPlatformVideoCapture { |
32 public media::VideoCapture::EventHandler { | |
33 public: | 29 public: |
34 PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view, | 30 PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view, |
35 const std::string& device_id, | 31 const std::string& device_id, |
36 const GURL& document_url, | 32 const GURL& document_url, |
37 PepperVideoCaptureHost* handler); | 33 PepperVideoCaptureHost* handler); |
34 virtual ~PepperPlatformVideoCapture(); | |
38 | 35 |
39 // Detaches the event handler and stops sending notifications to it. | 36 // Detaches the event handler and stops sending notifications to it. |
40 void DetachEventHandler(); | 37 void DetachEventHandler(); |
41 | 38 |
42 // media::VideoCapture implementation. | 39 void StartCapture(const media::VideoCaptureParams& params); |
43 virtual void StartCapture(media::VideoCapture::EventHandler* handler, | 40 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 | 41 |
67 private: | 42 private: |
68 void Initialize(); | |
69 | |
70 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); | 43 void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); |
44 void OnStateUpdate(VideoCaptureState state); | |
45 void OnFrameReady( | |
46 const scoped_refptr<media::VideoFrame>& frame, | |
47 const media::VideoCaptureFormat& format); | |
bbudge
2014/04/25 23:18:58
Have you run git cl format? I think we're starting
Alpha Left Google
2014/04/25 23:33:23
Done.
| |
71 | 48 |
72 PepperMediaDeviceManager* GetMediaDeviceManager(); | 49 PepperMediaDeviceManager* GetMediaDeviceManager(); |
73 | 50 |
74 base::WeakPtr<RenderViewImpl> render_view_; | 51 base::WeakPtr<RenderViewImpl> render_view_; |
75 | 52 |
76 std::string device_id_; | 53 std::string device_id_; |
77 std::string label_; | 54 std::string label_; |
78 int session_id_; | 55 int session_id_; |
79 | 56 base::Closure release_device_cb_; |
80 scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_; | 57 base::Closure stop_capture_cb_; |
81 | 58 |
82 PepperVideoCaptureHost* handler_; | 59 PepperVideoCaptureHost* handler_; |
83 | 60 |
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 | 61 // 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. | 62 // there isn't any pending request before this object goes away. |
92 bool pending_open_device_; | 63 bool pending_open_device_; |
93 int pending_open_device_id_; | 64 int pending_open_device_id_; |
94 | 65 |
66 base::ThreadChecker thread_checker_; | |
67 | |
68 base::WeakPtrFactory<PepperPlatformVideoCapture> weak_factory_; | |
69 | |
95 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture); | 70 DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture); |
96 }; | 71 }; |
97 | 72 |
98 } // namespace content | 73 } // namespace content |
99 | 74 |
100 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ | 75 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_ |
OLD | NEW |