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 <memory> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
11 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
12 #include "content/common/media/video_capture.h" | 14 #include "content/common/media/video_capture.h" |
13 #include "content/public/renderer/render_frame_observer.h" | 15 #include "content/public/renderer/render_frame_observer.h" |
14 #include "content/renderer/media/media_stream_video_source.h" | 16 #include "content/renderer/media/media_stream_video_source.h" |
15 | 17 |
16 namespace media { | 18 namespace media { |
17 class VideoCapturerSource; | 19 class VideoCapturerSource; |
18 } // namespace media | 20 } // namespace media |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 | 23 |
22 // Representation of a video stream coming from a camera, owned by Blink as | 24 // Representation of a video stream coming from a camera, owned by Blink as |
23 // WebMediaStreamSource. Objects of this class are created and live on main | 25 // WebMediaStreamSource. Objects of this class are created and live on main |
24 // Render thread. Objects can be constructed either by indicating a |device| to | 26 // Render thread. Objects can be constructed either by indicating a |device| to |
25 // look for, or by plugging in a |source| constructed elsewhere. | 27 // look for, or by plugging in a |source| constructed elsewhere. |
26 class CONTENT_EXPORT MediaStreamVideoCapturerSource | 28 class CONTENT_EXPORT MediaStreamVideoCapturerSource |
27 : public MediaStreamVideoSource, | 29 : public MediaStreamVideoSource, |
28 public RenderFrameObserver { | 30 public RenderFrameObserver { |
29 public: | 31 public: |
30 MediaStreamVideoCapturerSource( | 32 MediaStreamVideoCapturerSource( |
31 const SourceStoppedCallback& stop_callback, | 33 const SourceStoppedCallback& stop_callback, |
32 std::unique_ptr<media::VideoCapturerSource> source); | 34 std::unique_ptr<media::VideoCapturerSource> source); |
| 35 // TODO(guidou): Remove this constructor. http://crbug.com/706408 |
33 MediaStreamVideoCapturerSource(const SourceStoppedCallback& stop_callback, | 36 MediaStreamVideoCapturerSource(const SourceStoppedCallback& stop_callback, |
34 const StreamDeviceInfo& device_info, | 37 const StreamDeviceInfo& device_info, |
35 RenderFrame* render_frame); | 38 RenderFrame* render_frame); |
| 39 MediaStreamVideoCapturerSource( |
| 40 const SourceStoppedCallback& stop_callback, |
| 41 const StreamDeviceInfo& device_info, |
| 42 const media::VideoCaptureParams& capture_params, |
| 43 RenderFrame* render_frame); |
36 ~MediaStreamVideoCapturerSource() override; | 44 ~MediaStreamVideoCapturerSource() override; |
37 | 45 |
38 private: | 46 private: |
39 friend class CanvasCaptureHandlerTest; | 47 friend class CanvasCaptureHandlerTest; |
40 friend class MediaStreamVideoCapturerSourceTest; | 48 friend class MediaStreamVideoCapturerSourceTest; |
41 | 49 |
42 // MediaStreamVideoSource overrides. | 50 // MediaStreamVideoSource overrides. |
43 void RequestRefreshFrame() override; | 51 void RequestRefreshFrame() override; |
44 void OnHasConsumers(bool has_consumers) override; | 52 void OnHasConsumers(bool has_consumers) override; |
45 void OnCapturingLinkSecured(bool is_secure) override; | 53 void OnCapturingLinkSecured(bool is_secure) override; |
46 void GetCurrentSupportedFormats( | 54 void GetCurrentSupportedFormats( |
47 int max_requested_width, | 55 int max_requested_width, |
48 int max_requested_height, | 56 int max_requested_height, |
49 double max_requested_frame_rate, | 57 double max_requested_frame_rate, |
50 const VideoCaptureDeviceFormatsCB& callback) override; | 58 const VideoCaptureDeviceFormatsCB& callback) override; |
51 void StartSourceImpl( | 59 void StartSourceImpl( |
52 const media::VideoCaptureFormat& format, | 60 const media::VideoCaptureFormat& format, |
53 const blink::WebMediaConstraints& constraints, | 61 const blink::WebMediaConstraints& constraints, |
54 const VideoCaptureDeliverFrameCB& frame_callback) override; | 62 const VideoCaptureDeliverFrameCB& frame_callback) override; |
55 void StopSourceImpl() override; | 63 void StopSourceImpl() override; |
| 64 base::Optional<media::VideoCaptureFormat> GetCurrentFormatImpl() |
| 65 const override; |
56 | 66 |
57 // RenderFrameObserver implementation. | 67 // RenderFrameObserver implementation. |
58 void OnDestruct() final {} | 68 void OnDestruct() final {} |
59 | 69 |
60 // Method to bind as RunningCallback in VideoCapturerSource::StartCapture(). | 70 // Method to bind as RunningCallback in VideoCapturerSource::StartCapture(). |
61 void OnRunStateChanged(bool is_running); | 71 void OnRunStateChanged(bool is_running); |
62 | 72 |
63 const char* GetPowerLineFrequencyForTesting() const; | 73 const char* GetPowerLineFrequencyForTesting() const; |
64 | 74 |
65 // The source that provides video frames. | 75 // The source that provides video frames. |
66 const std::unique_ptr<media::VideoCapturerSource> source_; | 76 const std::unique_ptr<media::VideoCapturerSource> source_; |
67 | 77 |
68 // Indicates whether the capture is in starting. It is set to true by | 78 // Indicates whether the capture is in starting. It is set to true by |
69 // StartSourceImpl() when starting the capture, and is reset after starting | 79 // StartSourceImpl() when starting the capture, and is reset after starting |
70 // is completed. | 80 // is completed. |
71 bool is_capture_starting_ = false; | 81 bool is_capture_starting_ = false; |
72 | 82 |
| 83 media::VideoCaptureParams capture_params_; |
| 84 |
73 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); | 85 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); |
74 }; | 86 }; |
75 | 87 |
76 } // namespace content | 88 } // namespace content |
77 | 89 |
78 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ | 90 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ |
OLD | NEW |