OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_TRACK_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ |
7 | 7 |
8 #include <memory> | |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
15 #include "content/public/renderer/media_stream_video_sink.h" | 16 #include "content/public/renderer/media_stream_video_sink.h" |
16 #include "content/renderer/media/media_stream_track.h" | 17 #include "content/renderer/media/media_stream_track.h" |
17 #include "content/renderer/media/media_stream_video_source.h" | 18 #include "content/renderer/media/media_stream_video_source.h" |
18 #include "content/renderer/media/secure_display_link_tracker.h" | 19 #include "content/renderer/media/secure_display_link_tracker.h" |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 | 22 |
23 struct VideoTrackAdapterSettings; | |
24 | |
22 // MediaStreamVideoTrack is a video specific representation of a | 25 // MediaStreamVideoTrack is a video specific representation of a |
23 // blink::WebMediaStreamTrack in content. It is owned by the blink object | 26 // blink::WebMediaStreamTrack in content. It is owned by the blink object |
24 // and can be retrieved from a blink object using | 27 // and can be retrieved from a blink object using |
25 // WebMediaStreamTrack::getExtraData() or MediaStreamVideoTrack::GetVideoTrack. | 28 // WebMediaStreamTrack::getExtraData() or MediaStreamVideoTrack::GetVideoTrack. |
26 class CONTENT_EXPORT MediaStreamVideoTrack : public MediaStreamTrack { | 29 class CONTENT_EXPORT MediaStreamVideoTrack : public MediaStreamTrack { |
27 public: | 30 public: |
28 // Help method to create a blink::WebMediaStreamTrack and a | 31 // Help method to create a blink::WebMediaStreamTrack and a |
29 // MediaStreamVideoTrack instance. The MediaStreamVideoTrack object is owned | 32 // MediaStreamVideoTrack instance. The MediaStreamVideoTrack object is owned |
30 // by the blink object in its WebMediaStreamTrack::ExtraData member. | 33 // by the blink object in its WebMediaStreamTrack::ExtraData member. |
31 // |callback| is triggered if the track is added to the source | 34 // |callback| is triggered if the track is added to the source |
32 // successfully and will receive video frames that match |constraints| | 35 // successfully and will receive video frames that match the given settings |
33 // or if the source fail to provide video frames. | 36 // or if the source fails to provide video frames. |
34 // If |enabled| is true, sinks added to the track will | 37 // If |enabled| is true, sinks added to the track will |
35 // receive video frames when the source deliver frames to the track. | 38 // receive video frames when the source delivers frames to the track. |
39 // TODO(guidou): Remove the variant that takes a |constraints| argument. | |
40 // http://crbug.com/706408 | |
41 static blink::WebMediaStreamTrack CreateVideoTrack( | |
42 MediaStreamVideoSource* source, | |
43 const MediaStreamVideoSource::ConstraintsCallback& callback, | |
44 bool enabled); | |
36 static blink::WebMediaStreamTrack CreateVideoTrack( | 45 static blink::WebMediaStreamTrack CreateVideoTrack( |
37 MediaStreamVideoSource* source, | 46 MediaStreamVideoSource* source, |
38 const blink::WebMediaConstraints& constraints, | 47 const blink::WebMediaConstraints& constraints, |
39 const MediaStreamVideoSource::ConstraintsCallback& callback, | 48 const MediaStreamVideoSource::ConstraintsCallback& callback, |
40 bool enabled); | 49 bool enabled); |
50 static blink::WebMediaStreamTrack CreateVideoTrack( | |
51 MediaStreamVideoSource* source, | |
52 const VideoTrackAdapterSettings& adapter_settings, | |
53 const base::Optional<bool>& noise_reduction, | |
54 bool is_screencast, | |
55 double min_frame_rate, | |
56 const MediaStreamVideoSource::ConstraintsCallback& callback, | |
57 bool enabled); | |
41 | 58 |
42 static MediaStreamVideoTrack* GetVideoTrack( | 59 static MediaStreamVideoTrack* GetVideoTrack( |
43 const blink::WebMediaStreamTrack& track); | 60 const blink::WebMediaStreamTrack& track); |
44 | 61 |
45 // Constructor for video tracks. | 62 // Constructors for video tracks. |
63 // TODO(guidou): Remove this variant that takes a |constraints| argument. | |
hbos_chromium
2017/04/05 12:37:28
nit: the variant
Guido Urdaneta
2017/04/05 16:17:17
Done.
| |
64 // http://crbug.com/706408 | |
65 MediaStreamVideoTrack( | |
66 MediaStreamVideoSource* source, | |
67 const MediaStreamVideoSource::ConstraintsCallback& callback, | |
68 bool enabled); | |
46 MediaStreamVideoTrack( | 69 MediaStreamVideoTrack( |
47 MediaStreamVideoSource* source, | 70 MediaStreamVideoSource* source, |
48 const blink::WebMediaConstraints& constraints, | 71 const blink::WebMediaConstraints& constraints, |
49 const MediaStreamVideoSource::ConstraintsCallback& callback, | 72 const MediaStreamVideoSource::ConstraintsCallback& callback, |
50 bool enabled); | 73 bool enabled); |
74 MediaStreamVideoTrack( | |
75 MediaStreamVideoSource* source, | |
76 const VideoTrackAdapterSettings& adapter_settings, | |
77 const base::Optional<bool>& noise_reduction, | |
78 bool is_screen_cast, | |
79 double min_frame_rate, | |
80 const MediaStreamVideoSource::ConstraintsCallback& callback, | |
81 bool enabled); | |
51 ~MediaStreamVideoTrack() override; | 82 ~MediaStreamVideoTrack() override; |
52 | 83 |
53 // MediaStreamTrack overrides. | 84 // MediaStreamTrack overrides. |
54 void SetEnabled(bool enabled) override; | 85 void SetEnabled(bool enabled) override; |
55 void SetContentHint( | 86 void SetContentHint( |
56 blink::WebMediaStreamTrack::ContentHintType content_hint) override; | 87 blink::WebMediaStreamTrack::ContentHintType content_hint) override; |
57 void Stop() override; | 88 void Stop() override; |
58 void getSettings(blink::WebMediaStreamTrack::Settings& settings) override; | 89 void getSettings(blink::WebMediaStreamTrack::Settings& settings) override; |
59 | 90 |
60 void OnReadyStateChanged(blink::WebMediaStreamSource::ReadyState state); | 91 void OnReadyStateChanged(blink::WebMediaStreamSource::ReadyState state); |
61 | 92 |
62 const blink::WebMediaConstraints& constraints() const { return constraints_; } | 93 const blink::WebMediaConstraints& constraints() const { |
94 DCHECK(IsOldVideoConstraints()); | |
95 return constraints_; | |
96 } | |
97 const base::Optional<bool>& noise_reduction() const { | |
98 DCHECK(!IsOldVideoConstraints()); | |
99 return noise_reduction_; | |
100 } | |
101 bool is_screencast() const { | |
102 DCHECK(!IsOldVideoConstraints()); | |
103 return is_screencast_; | |
104 } | |
105 double min_frame_rate() const { | |
106 DCHECK(!IsOldVideoConstraints()); | |
107 return min_frame_rate_; | |
108 } | |
109 const VideoTrackAdapterSettings& adapter_settings() const { | |
110 DCHECK(!IsOldVideoConstraints()); | |
111 return *adapter_settings_; | |
112 } | |
63 | 113 |
64 // Setting information about the track size. | 114 // Setting information about the track size. |
65 // Called from MediaStreamVideoSource at track initialization. | 115 // Called from MediaStreamVideoSource at track initialization. |
66 void SetTargetSize(int width, int height) { | 116 void SetTargetSize(int width, int height) { |
67 width_ = width; | 117 width_ = width; |
68 height_ = height; | 118 height_ = height; |
69 } | 119 } |
70 | 120 |
71 private: | 121 private: |
72 // MediaStreamVideoSink is a friend to allow it to call AddSink() and | 122 // MediaStreamVideoSink is a friend to allow it to call AddSink() and |
(...skipping 14 matching lines...) Expand all Loading... | |
87 bool is_sink_secure); | 137 bool is_sink_secure); |
88 void RemoveSink(MediaStreamVideoSink* sink); | 138 void RemoveSink(MediaStreamVideoSink* sink); |
89 | 139 |
90 std::vector<MediaStreamVideoSink*> sinks_; | 140 std::vector<MediaStreamVideoSink*> sinks_; |
91 | 141 |
92 // |FrameDeliverer| is an internal helper object used for delivering video | 142 // |FrameDeliverer| is an internal helper object used for delivering video |
93 // frames on the IO-thread using callbacks to all registered tracks. | 143 // frames on the IO-thread using callbacks to all registered tracks. |
94 class FrameDeliverer; | 144 class FrameDeliverer; |
95 const scoped_refptr<FrameDeliverer> frame_deliverer_; | 145 const scoped_refptr<FrameDeliverer> frame_deliverer_; |
96 | 146 |
147 // TODO(guidou): remove this field. http://crbug.com/706408 | |
97 const blink::WebMediaConstraints constraints_; | 148 const blink::WebMediaConstraints constraints_; |
98 | 149 |
150 // TODO(guidou): Make this field a regular field instead of a unique_ptr. | |
151 std::unique_ptr<VideoTrackAdapterSettings> adapter_settings_; | |
152 base::Optional<bool> noise_reduction_; | |
153 bool is_screencast_; | |
154 double min_frame_rate_; | |
155 | |
99 // Weak ref to the source this tracks is connected to. | 156 // Weak ref to the source this tracks is connected to. |
100 base::WeakPtr<MediaStreamVideoSource> source_; | 157 base::WeakPtr<MediaStreamVideoSource> source_; |
101 | 158 |
102 // This is used for tracking if all connected video sinks are secure. | 159 // This is used for tracking if all connected video sinks are secure. |
103 SecureDisplayLinkTracker<MediaStreamVideoSink> secure_tracker_; | 160 SecureDisplayLinkTracker<MediaStreamVideoSink> secure_tracker_; |
104 | 161 |
105 // Remembering our desired video size. | 162 // Remembering our desired video size. |
106 int width_ = 0; | 163 int width_ = 0; |
107 int height_ = 0; | 164 int height_ = 0; |
108 | 165 |
109 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoTrack); | 166 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoTrack); |
110 }; | 167 }; |
111 | 168 |
112 } // namespace content | 169 } // namespace content |
113 | 170 |
114 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ | 171 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ |
OLD | NEW |