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

Side by Side Diff: content/renderer/media/media_stream_video_track.cc

Issue 2812623004: Check that the source is valid before accessing it in MSVT::GetSettings. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "content/renderer/media/media_stream_video_track.h" 5 #include "content/renderer/media/media_stream_video_track.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 383 DCHECK(main_render_thread_checker_.CalledOnValidThread());
384 if (source_) { 384 if (source_) {
385 source_->RemoveTrack(this); 385 source_->RemoveTrack(this);
386 source_ = NULL; 386 source_ = NULL;
387 } 387 }
388 OnReadyStateChanged(blink::WebMediaStreamSource::kReadyStateEnded); 388 OnReadyStateChanged(blink::WebMediaStreamSource::kReadyStateEnded);
389 } 389 }
390 390
391 void MediaStreamVideoTrack::GetSettings( 391 void MediaStreamVideoTrack::GetSettings(
392 blink::WebMediaStreamTrack::Settings& settings) { 392 blink::WebMediaStreamTrack::Settings& settings) {
393 DCHECK(main_render_thread_checker_.CalledOnValidThread());
394 if (width_ && height_) {
395 settings.width = width_;
396 settings.height = height_;
397 }
mcasas 2017/04/11 17:37:00 nit: maybe nonsense, but what about if (width_)
Guido Urdaneta 2017/04/11 18:40:42 I think the original intent is to return values on
398
399 if (!source_)
400 return;
401
393 base::Optional<media::VideoCaptureFormat> format = 402 base::Optional<media::VideoCaptureFormat> format =
394 source_->GetCurrentFormat(); 403 source_->GetCurrentFormat();
395 if (format) { 404 if (format) {
396 settings.frame_rate = format->frame_rate; 405 settings.frame_rate = format->frame_rate;
397 settings.video_kind = GetVideoKindForFormat(*format); 406 settings.video_kind = GetVideoKindForFormat(*format);
398 } 407 }
399 if (width_ && height_) {
400 settings.width = width_;
401 settings.height = height_;
402 }
403 switch (source_->device_info().device.video_facing) { 408 switch (source_->device_info().device.video_facing) {
404 case media::MEDIA_VIDEO_FACING_NONE: 409 case media::MEDIA_VIDEO_FACING_NONE:
405 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kNone; 410 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kNone;
406 break; 411 break;
407 case media::MEDIA_VIDEO_FACING_USER: 412 case media::MEDIA_VIDEO_FACING_USER:
408 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kUser; 413 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kUser;
409 break; 414 break;
410 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: 415 case media::MEDIA_VIDEO_FACING_ENVIRONMENT:
411 settings.facing_mode = 416 settings.facing_mode =
412 blink::WebMediaStreamTrack::FacingMode::kEnvironment; 417 blink::WebMediaStreamTrack::FacingMode::kEnvironment;
(...skipping 13 matching lines...) Expand all
426 } 431 }
427 432
428 void MediaStreamVideoTrack::OnReadyStateChanged( 433 void MediaStreamVideoTrack::OnReadyStateChanged(
429 blink::WebMediaStreamSource::ReadyState state) { 434 blink::WebMediaStreamSource::ReadyState state) {
430 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 435 DCHECK(main_render_thread_checker_.CalledOnValidThread());
431 for (auto* sink : sinks_) 436 for (auto* sink : sinks_)
432 sink->OnReadyStateChanged(state); 437 sink->OnReadyStateChanged(state);
433 } 438 }
434 439
435 } // namespace content 440 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698