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/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
12 #include "content/common/media/video_capture.h" | 12 #include "content/common/media/video_capture.h" |
13 #include "content/public/renderer/render_frame.h" | |
13 #include "content/renderer/media/media_stream_video_source.h" | 14 #include "content/renderer/media/media_stream_video_source.h" |
14 | 15 |
15 namespace media { | 16 namespace media { |
16 class VideoCapturerSource; | 17 class VideoCapturerSource; |
17 } // namespace media | 18 } // namespace media |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 // Representation of a video stream coming from a camera, owned by Blink as | 22 // Representation of a video stream coming from a camera, owned by Blink as |
22 // WebMediaStreamSource. Objects of this class are created and live on main | 23 // WebMediaStreamSource. Objects of this class are created and live on main |
23 // Render thread. Objects can be constructed either by indicating a |device| to | 24 // Render thread. Objects can be constructed either by indicating a |device| to |
24 // look for, or by plugging in a |source| constructed elsewhere. | 25 // look for, or by plugging in a |source| constructed elsewhere. |
25 class CONTENT_EXPORT MediaStreamVideoCapturerSource | 26 class CONTENT_EXPORT MediaStreamVideoCapturerSource |
26 : public MediaStreamVideoSource { | 27 : public MediaStreamVideoSource { |
27 public: | 28 public: |
28 MediaStreamVideoCapturerSource( | 29 MediaStreamVideoCapturerSource( |
29 const SourceStoppedCallback& stop_callback, | 30 const SourceStoppedCallback& stop_callback, |
30 std::unique_ptr<media::VideoCapturerSource> source); | 31 std::unique_ptr<media::VideoCapturerSource> source); |
31 MediaStreamVideoCapturerSource(const SourceStoppedCallback& stop_callback, | 32 MediaStreamVideoCapturerSource(const SourceStoppedCallback& stop_callback, |
32 const StreamDeviceInfo& device_info); | 33 const StreamDeviceInfo& device_info, |
34 RenderFrame* render_frame); | |
33 ~MediaStreamVideoCapturerSource() override; | 35 ~MediaStreamVideoCapturerSource() override; |
34 | 36 |
35 // Implements MediaStreamVideoSource. | 37 // Implements MediaStreamVideoSource. |
36 void RequestRefreshFrame() override; | 38 void RequestRefreshFrame() override; |
37 | 39 |
40 void SetCapturingLinkSecured(bool is_secure) override; | |
41 | |
38 private: | 42 private: |
39 friend class CanvasCaptureHandlerTest; | 43 friend class CanvasCaptureHandlerTest; |
40 friend class MediaStreamVideoCapturerSourceTest; | 44 friend class MediaStreamVideoCapturerSourceTest; |
41 | 45 |
42 // Implements MediaStreamVideoSource. | 46 // Implements MediaStreamVideoSource. |
43 void GetCurrentSupportedFormats( | 47 void GetCurrentSupportedFormats( |
44 int max_requested_width, | 48 int max_requested_width, |
45 int max_requested_height, | 49 int max_requested_height, |
46 double max_requested_frame_rate, | 50 double max_requested_frame_rate, |
47 const VideoCaptureDeviceFormatsCB& callback) override; | 51 const VideoCaptureDeviceFormatsCB& callback) override; |
48 void StartSourceImpl( | 52 void StartSourceImpl( |
49 const media::VideoCaptureFormat& format, | 53 const media::VideoCaptureFormat& format, |
50 const blink::WebMediaConstraints& constraints, | 54 const blink::WebMediaConstraints& constraints, |
51 const VideoCaptureDeliverFrameCB& frame_callback) override; | 55 const VideoCaptureDeliverFrameCB& frame_callback) override; |
52 void StopSourceImpl() override; | 56 void StopSourceImpl() override; |
53 | 57 |
54 // Method to bind as RunningCallback in VideoCapturerSource::StartCapture(). | 58 // Method to bind as RunningCallback in VideoCapturerSource::StartCapture(). |
55 void OnStarted(bool result); | 59 void OnStarted(bool result); |
56 | 60 |
57 const char* GetPowerLineFrequencyForTesting() const; | 61 const char* GetPowerLineFrequencyForTesting() const; |
58 | 62 |
59 // The source that provides video frames. | 63 // The source that provides video frames. |
60 const std::unique_ptr<media::VideoCapturerSource> source_; | 64 const std::unique_ptr<media::VideoCapturerSource> source_; |
61 | 65 |
66 // This is used to send IPC messages to the browser process. | |
67 RenderFrame* const render_frame_; // Not owned. | |
miu
2016/05/06 18:56:22
For safety, instead of having this render_frame_ m
xjz
2016/05/06 22:08:45
Done.
| |
68 | |
62 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); | 69 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); |
63 }; | 70 }; |
64 | 71 |
65 } // namespace content | 72 } // namespace content |
66 | 73 |
67 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ | 74 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ |
OLD | NEW |