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

Side by Side Diff: content/renderer/media/webrtc/media_stream_video_webrtc_sink.cc

Issue 2964003002: Remove support for old getUserMedia video constraints algorithm. (Closed)
Patch Set: rebase and address hbos@ comments 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 #include "content/renderer/media/webrtc/media_stream_video_webrtc_sink.h" 5 #include "content/renderer/media/webrtc/media_stream_video_webrtc_sink.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 capture_adapter_->OnFrameCaptured(frame); 259 capture_adapter_->OnFrameCaptured(frame);
260 } 260 }
261 261
262 MediaStreamVideoWebRtcSink::MediaStreamVideoWebRtcSink( 262 MediaStreamVideoWebRtcSink::MediaStreamVideoWebRtcSink(
263 const blink::WebMediaStreamTrack& track, 263 const blink::WebMediaStreamTrack& track,
264 PeerConnectionDependencyFactory* factory) 264 PeerConnectionDependencyFactory* factory)
265 : weak_factory_(this) { 265 : weak_factory_(this) {
266 MediaStreamVideoTrack* video_track = 266 MediaStreamVideoTrack* video_track =
267 MediaStreamVideoTrack::GetVideoTrack(track); 267 MediaStreamVideoTrack::GetVideoTrack(track);
268 DCHECK(video_track); 268 DCHECK(video_track);
269 rtc::Optional<bool> needs_denoising;
270 bool is_screencast = false;
271 base::Optional<double> min_frame_rate;
272 base::Optional<double> max_frame_rate;
273 269
274 if (IsOldVideoConstraints()) { 270 rtc::Optional<bool> needs_denoising =
275 const blink::WebMediaConstraints& constraints = video_track->constraints(); 271 ToRtcOptional(video_track->noise_reduction());
276 272 bool is_screencast = is_screencast = video_track->is_screencast();
277 // Check for presence of mediaStreamSource constraint. The value is ignored. 273 base::Optional<double> min_frame_rate = video_track->min_frame_rate();
278 std::string value; 274 base::Optional<double> max_frame_rate = video_track->max_frame_rate();
279 is_screencast = GetConstraintValueAsString(
280 constraints, &blink::WebMediaTrackConstraintSet::media_stream_source,
281 &value);
282
283 // Extract denoising preference, if no value is set this currently falls
284 // back to a codec-specific default inside webrtc, hence the tri-state of
285 // {on, off unset}.
286 // TODO(pbos): Add tests that make sure that googNoiseReduction has properly
287 // propagated from getUserMedia down to a VideoTrackSource.
288 bool denoising_value;
289 if (GetConstraintValueAsBoolean(
290 constraints,
291 &blink::WebMediaTrackConstraintSet::goog_noise_reduction,
292 &denoising_value)) {
293 needs_denoising = rtc::Optional<bool>(denoising_value);
294 }
295 double frame_rate_value;
296 if (GetConstraintMinAsDouble(constraints,
297 &blink::WebMediaTrackConstraintSet::frame_rate,
298 &frame_rate_value) &&
299 frame_rate_value >= 0.0) {
300 min_frame_rate = frame_rate_value;
301 }
302 if (GetConstraintMaxAsDouble(constraints,
303 &blink::WebMediaTrackConstraintSet::frame_rate,
304 &frame_rate_value) &&
305 frame_rate_value >= 0.0) {
306 max_frame_rate = frame_rate_value;
307 }
308 } else {
309 needs_denoising = ToRtcOptional(video_track->noise_reduction());
310 is_screencast = video_track->is_screencast();
311 min_frame_rate = video_track->min_frame_rate();
312 max_frame_rate = video_track->max_frame_rate();
313 }
314 275
315 // Enable automatic frame refreshes for the screen capture sources, which will 276 // Enable automatic frame refreshes for the screen capture sources, which will
316 // stop producing frames whenever screen content is not changing. Check the 277 // stop producing frames whenever screen content is not changing. Check the
317 // frameRate constraint to determine the rate of refreshes. If a minimum 278 // frameRate constraint to determine the rate of refreshes. If a minimum
318 // frameRate is provided, use that. Otherwise, use the maximum frameRate if it 279 // frameRate is provided, use that. Otherwise, use the maximum frameRate if it
319 // happens to be less than the default. 280 // happens to be less than the default.
320 base::TimeDelta refresh_interval = base::TimeDelta::FromMicroseconds(0); 281 base::TimeDelta refresh_interval = base::TimeDelta::FromMicroseconds(0);
321 if (is_screencast) { 282 if (is_screencast) {
322 // Start with the default refresh interval, and refine based on constraints. 283 // Start with the default refresh interval, and refine based on constraints.
323 refresh_interval = 284 refresh_interval =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 DCHECK(thread_checker_.CalledOnValidThread()); 359 DCHECK(thread_checker_.CalledOnValidThread());
399 content::RequestRefreshFrameFromVideoTrack(connected_track()); 360 content::RequestRefreshFrameFromVideoTrack(connected_track());
400 } 361 }
401 362
402 rtc::Optional<bool> MediaStreamVideoWebRtcSink::SourceNeedsDenoisingForTesting() 363 rtc::Optional<bool> MediaStreamVideoWebRtcSink::SourceNeedsDenoisingForTesting()
403 const { 364 const {
404 return video_source_->needs_denoising(); 365 return video_source_->needs_denoising();
405 } 366 }
406 367
407 } // namespace content 368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698