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 #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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()); | 393 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 394 if (!source_) |
| 395 return; |
| 396 |
394 if (width_ && height_) { | 397 if (width_ && height_) { |
395 settings.width = width_; | 398 settings.width = width_; |
396 settings.height = height_; | 399 settings.height = height_; |
397 } | 400 } |
398 | 401 |
399 if (!source_) | 402 // 0.0 means the track is using the source's frame rate. |
400 return; | 403 if (frame_rate_ != 0.0) { |
| 404 settings.frame_rate = frame_rate_; |
| 405 } |
401 | 406 |
402 base::Optional<media::VideoCaptureFormat> format = | 407 base::Optional<media::VideoCaptureFormat> format = |
403 source_->GetCurrentFormat(); | 408 source_->GetCurrentFormat(); |
404 if (format) { | 409 if (format) { |
405 settings.frame_rate = format->frame_rate; | 410 if (frame_rate_ == 0.0) |
| 411 settings.frame_rate = format->frame_rate; |
406 settings.video_kind = GetVideoKindForFormat(*format); | 412 settings.video_kind = GetVideoKindForFormat(*format); |
407 } | 413 } |
408 switch (source_->device_info().device.video_facing) { | 414 switch (source_->device_info().device.video_facing) { |
409 case media::MEDIA_VIDEO_FACING_NONE: | 415 case media::MEDIA_VIDEO_FACING_NONE: |
410 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kNone; | 416 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kNone; |
411 break; | 417 break; |
412 case media::MEDIA_VIDEO_FACING_USER: | 418 case media::MEDIA_VIDEO_FACING_USER: |
413 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kUser; | 419 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kUser; |
414 break; | 420 break; |
415 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: | 421 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: |
(...skipping 15 matching lines...) Expand all Loading... |
431 } | 437 } |
432 | 438 |
433 void MediaStreamVideoTrack::OnReadyStateChanged( | 439 void MediaStreamVideoTrack::OnReadyStateChanged( |
434 blink::WebMediaStreamSource::ReadyState state) { | 440 blink::WebMediaStreamSource::ReadyState state) { |
435 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 441 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
436 for (auto* sink : sinks_) | 442 for (auto* sink : sinks_) |
437 sink->OnReadyStateChanged(state); | 443 sink->OnReadyStateChanged(state); |
438 } | 444 } |
439 | 445 |
440 } // namespace content | 446 } // namespace content |
OLD | NEW |