OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "content/common/media/video_capture.h" | 10 #include "content/common/media/video_capture.h" |
11 #include "content/renderer/media/media_stream_video_source.h" | 11 #include "content/renderer/media/media_stream_video_source.h" |
12 #include "media/video/capture/video_capture.h" | |
13 | 12 |
14 namespace content { | 13 namespace content { |
15 | 14 |
16 class VideoCaptureHandle; | |
17 | |
18 // VideoCapturerDelegate is a delegate used by MediaStreamVideoCapturerSource | 15 // VideoCapturerDelegate is a delegate used by MediaStreamVideoCapturerSource |
19 // for local video capturer. It uses VideoCaptureImplManager to start / stop | 16 // for local video capturer. It uses VideoCaptureImplManager to start / stop |
20 // and receive I420 frames from Chrome's video capture implementation. | 17 // and receive I420 frames from Chrome's video capture implementation. |
Ami GONE FROM CHROMIUM
2014/04/21 23:42:53
please doco lifecycle/threading.
Alpha Left Google
2014/04/23 18:48:33
Done. It is simple right now: it's render thread o
| |
21 class CONTENT_EXPORT VideoCapturerDelegate | 18 class CONTENT_EXPORT VideoCapturerDelegate |
22 : public media::VideoCapture::EventHandler, | 19 : public base::RefCountedThreadSafe<VideoCapturerDelegate> { |
23 public base::RefCountedThreadSafe<VideoCapturerDelegate> { | |
24 public: | 20 public: |
25 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>&)> | 21 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>&)> |
26 NewFrameCallback; | 22 NewFrameCallback; |
27 typedef base::Callback<void(bool running)> StartedCallback; | 23 typedef base::Callback<void(bool running)> StartedCallback; |
28 typedef base::Callback<void(const media::VideoCaptureFormats& formats)> | 24 typedef base::Callback<void(const media::VideoCaptureFormats& formats)> |
29 SupportedFormatsCallback; | 25 SupportedFormatsCallback; |
Ami GONE FROM CHROMIUM
2014/04/21 23:42:53
These typedefs have a non-trivial overlap with con
Alpha Left Google
2014/04/23 18:48:33
Done.
| |
30 | 26 |
31 explicit VideoCapturerDelegate( | 27 explicit VideoCapturerDelegate( |
32 const StreamDeviceInfo& device_info); | 28 const StreamDeviceInfo& device_info); |
33 | 29 |
34 // Collects the formats that can currently be used. | 30 // Collects the formats that can currently be used. |
35 // |max_requested_height| and |max_requested_width| is used by Tab and Screen | 31 // |max_requested_height| and |max_requested_width| is used by Tab and Screen |
36 // capture to decide what resolution to generate. | 32 // capture to decide what resolution to generate. |
37 // |callback| is triggered when the formats have been collected. | 33 // |callback| is triggered when the formats have been collected. |
38 virtual void GetCurrentSupportedFormats( | 34 virtual void GetCurrentSupportedFormats( |
39 int max_requested_width, | 35 int max_requested_width, |
40 int max_requested_height, | 36 int max_requested_height, |
41 const SupportedFormatsCallback& callback); | 37 const SupportedFormatsCallback& callback); |
42 | 38 |
43 // Starts deliver frames using the resolution in |params|. | 39 // Starts deliver frames using the resolution in |params|. |
44 // |new_frame_callback| is triggered when a new video frame is available. | 40 // |new_frame_callback| is triggered when a new video frame is available. |
45 // |started_callback| is triggered before the first video frame is received | 41 // |started_callback| is triggered before the first video frame is received |
46 // or if the underlying video capturer fails to start. | 42 // or if the underlying video capturer fails to start. |
47 virtual void StartDeliver( | 43 virtual void StartDeliver( |
Ami GONE FROM CHROMIUM
2014/04/21 23:42:53
VerbVerb is not a particularly readable choice (pr
Alpha Left Google
2014/04/23 18:48:33
Done.
| |
48 const media::VideoCaptureParams& params, | 44 const media::VideoCaptureParams& params, |
49 const NewFrameCallback& new_frame_callback, | 45 const NewFrameCallback& new_frame_callback, |
50 const StartedCallback& started_callback); | 46 const StartedCallback& started_callback); |
51 | 47 |
52 // Stops deliver frames and clears all callbacks including the | 48 // Stops deliver frames and clears all callbacks including the |
53 // SupportedFormatsCallback callback. | 49 // SupportedFormatsCallback callback. |
54 virtual void StopDeliver(); | 50 virtual void StopDeliver(); |
55 | 51 |
56 protected: | |
57 // media::VideoCapture::EventHandler implementation. | |
58 // These functions are called on the IO thread (same as where | |
59 // |capture_engine_| runs). | |
60 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; | |
61 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; | |
62 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; | |
63 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; | |
64 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; | |
65 virtual void OnFrameReady( | |
66 media::VideoCapture* capture, | |
67 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; | |
68 | |
69 private: | 52 private: |
70 friend class base::RefCountedThreadSafe<VideoCapturerDelegate>; | 53 friend class base::RefCountedThreadSafe<VideoCapturerDelegate>; |
71 friend class MockVideoCapturerDelegate; | 54 friend class MockVideoCapturerDelegate; |
72 | 55 |
73 virtual ~VideoCapturerDelegate(); | 56 virtual ~VideoCapturerDelegate(); |
74 | 57 |
75 void OnFrameReadyOnRenderThread( | 58 void OnFrameReadyOnRenderThread( |
76 media::VideoCapture* capture, | 59 const scoped_refptr<media::VideoFrame>& frame, |
77 const scoped_refptr<media::VideoFrame>& frame); | 60 const media::VideoCaptureFormat& format, |
78 void OnErrorOnRenderThread(media::VideoCapture* capture); | 61 const base::TimeTicks& timestamp); |
62 void OnStateUpdateOnRenderThread(VideoCaptureState state); | |
79 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats); | 63 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats); |
80 void OnDeviceSupportedFormatsEnumerated( | 64 void OnDeviceSupportedFormatsEnumerated( |
81 const media::VideoCaptureFormats& formats); | 65 const media::VideoCaptureFormats& formats); |
82 | 66 |
83 // The id identifies which video capture device is used for this video | 67 // The id identifies which video capture device is used for this video |
84 // capture session. | 68 // capture session. |
85 media::VideoCaptureSessionId session_id_; | 69 media::VideoCaptureSessionId session_id_; |
86 scoped_ptr<VideoCaptureHandle> capture_engine_; | 70 base::Closure release_device_cb_; |
71 base::Closure stop_capture_cb_; | |
87 | 72 |
88 bool is_screen_cast_; | 73 bool is_screen_cast_; |
89 | 74 |
90 // Accessed on the thread where StartDeliver is called. | 75 // Accessed on the thread where StartDeliver is called. |
91 bool got_first_frame_; | 76 bool got_first_frame_; |
92 | 77 |
93 // |new_frame_callback_| is provided to this class in StartDeliver and must be | 78 // |new_frame_callback_| is provided to this class in StartDeliver and must be |
94 // valid until StopDeliver is called. | 79 // valid until StopDeliver is called. |
95 NewFrameCallback new_frame_callback_; | 80 NewFrameCallback new_frame_callback_; |
96 // |started_callback| is provided to this class in StartDeliver and must be | 81 // |started_callback| is provided to this class in StartDeliver and must be |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 private: | 114 private: |
130 // The delegate that provides video frames. | 115 // The delegate that provides video frames. |
131 scoped_refptr<VideoCapturerDelegate> delegate_; | 116 scoped_refptr<VideoCapturerDelegate> delegate_; |
132 | 117 |
133 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); | 118 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); |
134 }; | 119 }; |
135 | 120 |
136 } // namespace content | 121 } // namespace content |
137 | 122 |
138 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ | 123 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ |
OLD | NEW |