Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: content/renderer/media/media_stream_video_source.h

Issue 2964003002: Remove support for old getUserMedia video constraints algorithm. (Closed)
Patch Set: fix Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SOURCE_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 23 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
24 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 24 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
25 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 25 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
26 26
27 namespace content { 27 namespace content {
28 28
29 class MediaStreamVideoTrack; 29 class MediaStreamVideoTrack;
30 class VideoTrackAdapter; 30 class VideoTrackAdapter;
31 struct VideoTrackAdapterSettings; 31 struct VideoTrackAdapterSettings;
32 32
33 CONTENT_EXPORT bool IsOldVideoConstraints();
34
35 // MediaStreamVideoSource is an interface used for sending video frames to a 33 // MediaStreamVideoSource is an interface used for sending video frames to a
36 // MediaStreamVideoTrack. 34 // MediaStreamVideoTrack.
37 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html 35 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html
38 // The purpose of this base class is to be able to implement different 36 // The purpose of this base class is to be able to implement different
39 // MediaStreaVideoSources such as local video capture, video sources received 37 // MediaStreaVideoSources such as local video capture, video sources received
40 // on a PeerConnection or a source created in NaCl. 38 // on a PeerConnection or a source created in NaCl.
41 // All methods calls will be done from the main render thread. 39 // All methods calls will be done from the main render thread.
42 // 40 //
43 // When the first track is added to the source by calling AddTrack, the 41 // When the first track is added to the source by calling AddTrack, the
44 // MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. 42 // MediaStreamVideoSource implementation calls GetCurrentSupportedFormats.
hbos_chromium 2017/06/30 15:04:12 Update comment after removing GetCurrentSupportedF
Guido Urdaneta 2017/07/03 18:43:16 Acknowledged. Will do in follow-up CL.
45 // The source implementation must call OnSupportedFormats. 43 // The source implementation must call OnSupportedFormats.
46 // MediaStreamVideoSource then match the constraints provided in AddTrack with 44 // MediaStreamVideoSource then match the constraints provided in AddTrack with
47 // the formats and call StartSourceImpl. The source implementation must call 45 // the formats and call StartSourceImpl. The source implementation must call
48 // OnStartDone when the underlying source has been started or failed to start. 46 // OnStartDone when the underlying source has been started or failed to start.
49 class CONTENT_EXPORT MediaStreamVideoSource : public MediaStreamSource { 47 class CONTENT_EXPORT MediaStreamVideoSource : public MediaStreamSource {
50 public: 48 public:
51 enum { 49 enum {
52 // Default resolution. If no constraints are specified and the delegate 50 // Default resolution. If no constraints are specified and the delegate
53 // support it, this is the resolution that will be used. 51 // support it, this is the resolution that will be used.
54 kDefaultWidth = 640, 52 kDefaultWidth = 640,
(...skipping 11 matching lines...) Expand all
66 64
67 // Returns the MediaStreamVideoSource object owned by |source|. 65 // Returns the MediaStreamVideoSource object owned by |source|.
68 static MediaStreamVideoSource* GetVideoSource( 66 static MediaStreamVideoSource* GetVideoSource(
69 const blink::WebMediaStreamSource& source); 67 const blink::WebMediaStreamSource& source);
70 68
71 // Puts |track| in the registered tracks list. 69 // Puts |track| in the registered tracks list.
72 void AddTrack(MediaStreamVideoTrack* track, 70 void AddTrack(MediaStreamVideoTrack* track,
73 const VideoTrackAdapterSettings& track_adapter_settings, 71 const VideoTrackAdapterSettings& track_adapter_settings,
74 const VideoCaptureDeliverFrameCB& frame_callback, 72 const VideoCaptureDeliverFrameCB& frame_callback,
75 const ConstraintsCallback& callback); 73 const ConstraintsCallback& callback);
76 // TODO(guidou): Remove this method. http://crbug.com/706408
77 void AddTrackLegacy(MediaStreamVideoTrack* track,
78 const VideoCaptureDeliverFrameCB& frame_callback,
79 const blink::WebMediaConstraints& constraints,
80 const ConstraintsCallback& callback);
81 void RemoveTrack(MediaStreamVideoTrack* track); 74 void RemoveTrack(MediaStreamVideoTrack* track);
82 75
83 // Called by |track| to notify the source whether it has any paths to a 76 // Called by |track| to notify the source whether it has any paths to a
84 // consuming endpoint. 77 // consuming endpoint.
85 void UpdateHasConsumers(MediaStreamVideoTrack* track, bool has_consumers); 78 void UpdateHasConsumers(MediaStreamVideoTrack* track, bool has_consumers);
86 79
87 void UpdateCapturingLinkSecure(MediaStreamVideoTrack* track, bool is_secure); 80 void UpdateCapturingLinkSecure(MediaStreamVideoTrack* track, bool is_secure);
88 81
89 // Request underlying source to capture a new frame. 82 // Request underlying source to capture a new frame.
90 virtual void RequestRefreshFrame() {} 83 virtual void RequestRefreshFrame() {}
(...skipping 21 matching lines...) Expand all
112 // |max_requested_height| and |max_requested_width| is the max height and 105 // |max_requested_height| and |max_requested_width| is the max height and
113 // width set as a mandatory constraint if set when calling 106 // width set as a mandatory constraint if set when calling
114 // MediaStreamVideoSource::AddTrack. If max height and max width is not set 107 // MediaStreamVideoSource::AddTrack. If max height and max width is not set
115 // |max_requested_height| and |max_requested_width| are 0. 108 // |max_requested_height| and |max_requested_width| are 0.
116 // TODO(guidou): Remove when the standard constraints code stabilizes. 109 // TODO(guidou): Remove when the standard constraints code stabilizes.
117 // http://crbug.com/706408 110 // http://crbug.com/706408
118 virtual void GetCurrentSupportedFormats( 111 virtual void GetCurrentSupportedFormats(
119 int max_requested_width, 112 int max_requested_width,
120 int max_requested_height, 113 int max_requested_height,
121 double max_requested_frame_rate, 114 double max_requested_frame_rate,
122 const VideoCaptureDeviceFormatsCB& callback) = 0; 115 const VideoCaptureDeviceFormatsCB& callback) = 0;
hbos_chromium 2017/06/30 15:04:12 This was only used by AddTrackLegacy; remove it.
Guido Urdaneta 2017/07/03 18:43:16 Will remove it in a follow-up CL together with oth
123 116
124 // TODO(guidou): Rename to GetCurrentFormat. http://crbug.com/706804 117 // TODO(guidou): Rename to GetCurrentFormat. http://crbug.com/706804
125 virtual base::Optional<media::VideoCaptureFormat> GetCurrentFormatImpl() 118 virtual base::Optional<media::VideoCaptureFormat> GetCurrentFormatImpl()
126 const; 119 const;
127 120
128 // An implementation must start capturing frames using the requested 121 // An implementation must start capturing frames using the requested
129 // |format|. The fulfilled |constraints| are provided as additional context, 122 // |format|. The fulfilled |constraints| are provided as additional context,
130 // and may be used to modify the behavior of the source. When the source has 123 // and may be used to modify the behavior of the source. When the source has
131 // started or the source failed to start OnStartDone must be called. An 124 // started or the source failed to start OnStartDone must be called. An
132 // implementation must call |frame_callback| on the IO thread with the 125 // implementation must call |frame_callback| on the IO thread with the
(...skipping 16 matching lines...) Expand all
149 // frames, giving it the option of running in an "idle" state to minimize 142 // frames, giving it the option of running in an "idle" state to minimize
150 // resource usage. 143 // resource usage.
151 virtual void OnHasConsumers(bool has_consumers) {} 144 virtual void OnHasConsumers(bool has_consumers) {}
152 145
153 // Optionally overridden by subclasses to act on whether the capturing link 146 // Optionally overridden by subclasses to act on whether the capturing link
154 // has become secure or insecure. 147 // has become secure or insecure.
155 virtual void OnCapturingLinkSecured(bool is_secure) {} 148 virtual void OnCapturingLinkSecured(bool is_secure) {}
156 149
157 enum State { 150 enum State {
158 NEW, 151 NEW,
159 // TODO(guidou): Remove this state. http://crbug.com/706408
160 RETRIEVING_CAPABILITIES,
161 STARTING, 152 STARTING,
162 STARTED, 153 STARTED,
163 ENDED 154 ENDED
164 }; 155 };
165 State state() const { return state_; } 156 State state() const { return state_; }
166 157
167 SEQUENCE_CHECKER(sequence_checker_); 158 SEQUENCE_CHECKER(sequence_checker_);
168 159
169 private: 160 private:
170 void OnSupportedFormats(const media::VideoCaptureFormats& formats);
171
172 // Finds the first WebMediaConstraints in |track_descriptors_| that allows
173 // the use of one of the |formats|. |best_format| and |fulfilled_constraints|
174 // are set to the results of this search-and-match operation. Returns false
175 // if no WebMediaConstraints allow the use any of the |formats|.
176 bool FindBestFormatWithConstraints(
177 const media::VideoCaptureFormats& formats,
178 media::VideoCaptureFormat* best_format,
179 blink::WebMediaConstraints* fulfilled_constraints);
180
181 // Trigger all cached callbacks from AddTrack. AddTrack is successful 161 // Trigger all cached callbacks from AddTrack. AddTrack is successful
182 // if the capture delegate has started and the constraints provided in 162 // if the capture delegate has started and the constraints provided in
183 // AddTrack match the format that was used to start the device. 163 // AddTrack match the format that was used to start the device.
184 // Note that it must be ok to delete the MediaStreamVideoSource object 164 // Note that it must be ok to delete the MediaStreamVideoSource object
185 // in the context of the callback. If gUM fails, the implementation will 165 // in the context of the callback. If gUM fails, the implementation will
186 // simply drop the references to the blink source and track which will lead 166 // simply drop the references to the blink source and track which will lead
187 // to this object being deleted. 167 // to this object being deleted.
188 void FinalizeAddTrack(); 168 void FinalizeAddTrack();
189 // TODO(guidou): Remove this method. http://crbug.com/706408
190 void FinalizeAddTrackLegacy();
191 169
192 State state_; 170 State state_;
193 171
194 // TODO(guidou): Remove this field. http://crbug.com/706408
195 media::VideoCaptureFormat current_format_;
196
197 struct TrackDescriptor { 172 struct TrackDescriptor {
198 TrackDescriptor(MediaStreamVideoTrack* track, 173 TrackDescriptor(MediaStreamVideoTrack* track,
199 const VideoCaptureDeliverFrameCB& frame_callback, 174 const VideoCaptureDeliverFrameCB& frame_callback,
200 const blink::WebMediaConstraints& constraints,
201 const ConstraintsCallback& callback);
202 TrackDescriptor(MediaStreamVideoTrack* track,
203 const VideoCaptureDeliverFrameCB& frame_callback,
204 std::unique_ptr<VideoTrackAdapterSettings> adapter_settings, 175 std::unique_ptr<VideoTrackAdapterSettings> adapter_settings,
205 const ConstraintsCallback& callback); 176 const ConstraintsCallback& callback);
206 TrackDescriptor(TrackDescriptor&& other); 177 TrackDescriptor(TrackDescriptor&& other);
207 TrackDescriptor& operator=(TrackDescriptor&& other); 178 TrackDescriptor& operator=(TrackDescriptor&& other);
208 ~TrackDescriptor(); 179 ~TrackDescriptor();
209 180
210 MediaStreamVideoTrack* track; 181 MediaStreamVideoTrack* track;
211 VideoCaptureDeliverFrameCB frame_callback; 182 VideoCaptureDeliverFrameCB frame_callback;
212 // TODO(guidou): remove this field. http://crbug.com/706408
213 blink::WebMediaConstraints constraints;
214 // TODO(guidou): Make |adapter_settings| a regular field instead of a 183 // TODO(guidou): Make |adapter_settings| a regular field instead of a
215 // unique_ptr. 184 // unique_ptr.
216 std::unique_ptr<VideoTrackAdapterSettings> adapter_settings; 185 std::unique_ptr<VideoTrackAdapterSettings> adapter_settings;
217 ConstraintsCallback callback; 186 ConstraintsCallback callback;
218 }; 187 };
219 std::vector<TrackDescriptor> track_descriptors_; 188 std::vector<TrackDescriptor> track_descriptors_;
220 189
221 media::VideoCaptureFormats supported_formats_; 190 media::VideoCaptureFormats supported_formats_;
hbos_chromium 2017/06/30 15:04:12 Remove, I don't think it's used anymore now that R
Guido Urdaneta 2017/07/03 18:43:16 Done.
222 191
223 // |track_adapter_| delivers video frames to the tracks on the IO-thread. 192 // |track_adapter_| delivers video frames to the tracks on the IO-thread.
224 const scoped_refptr<VideoTrackAdapter> track_adapter_; 193 const scoped_refptr<VideoTrackAdapter> track_adapter_;
225 194
226 // Tracks that currently are connected to this source. 195 // Tracks that currently are connected to this source.
227 std::vector<MediaStreamVideoTrack*> tracks_; 196 std::vector<MediaStreamVideoTrack*> tracks_;
228 197
229 // Tracks that have no paths to a consuming endpoint, and so do not need 198 // Tracks that have no paths to a consuming endpoint, and so do not need
230 // frames delivered from the source. This is a subset of |tracks_|. 199 // frames delivered from the source. This is a subset of |tracks_|.
231 std::vector<MediaStreamVideoTrack*> suspended_tracks_; 200 std::vector<MediaStreamVideoTrack*> suspended_tracks_;
232 201
233 // This is used for tracking if all connected video sinks are secure. 202 // This is used for tracking if all connected video sinks are secure.
234 SecureDisplayLinkTracker<MediaStreamVideoTrack> secure_tracker_; 203 SecureDisplayLinkTracker<MediaStreamVideoTrack> secure_tracker_;
235 204
236 // NOTE: Weak pointers must be invalidated before all other member variables. 205 // NOTE: Weak pointers must be invalidated before all other member variables.
237 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; 206 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_;
238 207
239 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); 208 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource);
240 }; 209 };
241 210
242 } // namespace content 211 } // namespace content
243 212
244 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 213 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698