| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 294 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 295 if (source_) { | 295 if (source_) { |
| 296 source_->RemoveTrack(this); | 296 source_->RemoveTrack(this); |
| 297 source_ = NULL; | 297 source_ = NULL; |
| 298 } | 298 } |
| 299 OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded); | 299 OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void MediaStreamVideoTrack::getSettings( | 302 void MediaStreamVideoTrack::getSettings( |
| 303 blink::WebMediaStreamTrack::Settings& settings) { | 303 blink::WebMediaStreamTrack::Settings& settings) { |
| 304 if (source_) { | |
| 305 const media::VideoCaptureFormat* format = source_->GetCurrentFormat(); | |
| 306 if (format) { | |
| 307 settings.frameRate = format->frame_rate; | |
| 308 settings.width = format->frame_size.width(); | |
| 309 settings.height = format->frame_size.height(); | |
| 310 } | |
| 311 switch (source_->device_info().device.video_facing) { | |
| 312 case media::MEDIA_VIDEO_FACING_NONE: | |
| 313 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::None; | |
| 314 break; | |
| 315 case media::MEDIA_VIDEO_FACING_USER: | |
| 316 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::User; | |
| 317 break; | |
| 318 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: | |
| 319 settings.facingMode = | |
| 320 blink::WebMediaStreamTrack::FacingMode::Environment; | |
| 321 break; | |
| 322 default: | |
| 323 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::None; | |
| 324 break; | |
| 325 } | |
| 326 } | |
| 327 // TODO(hta): Extract the real value. | 304 // TODO(hta): Extract the real value. |
| 328 settings.deviceId = blink::WebString("video device ID"); | 305 settings.deviceId = blink::WebString("video device ID"); |
| 306 if (!source_) |
| 307 return; |
| 308 |
| 309 const media::VideoCaptureFormat* format = source_->GetCurrentFormat(); |
| 310 if (format) { |
| 311 settings.frameRate = format->frame_rate; |
| 312 settings.width = format->frame_size.width(); |
| 313 settings.height = format->frame_size.height(); |
| 314 } |
| 315 switch (source_->device_info().device.video_facing) { |
| 316 case media::MEDIA_VIDEO_FACING_NONE: |
| 317 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::None; |
| 318 break; |
| 319 case media::MEDIA_VIDEO_FACING_USER: |
| 320 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::User; |
| 321 break; |
| 322 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: |
| 323 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::Environment; |
| 324 break; |
| 325 default: |
| 326 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::None; |
| 327 break; |
| 328 } |
| 329 const base::Optional<CameraCalibration> calibration = |
| 330 source_->device_info().device.camera_calibration; |
| 331 if (calibration) { |
| 332 settings.depthNear = calibration->depth_near; |
| 333 settings.depthFar = calibration->depth_far; |
| 334 settings.focalLengthX = calibration->focal_length_x; |
| 335 settings.focalLengthY = calibration->focal_length_y; |
| 336 } |
| 329 } | 337 } |
| 330 | 338 |
| 331 void MediaStreamVideoTrack::OnReadyStateChanged( | 339 void MediaStreamVideoTrack::OnReadyStateChanged( |
| 332 blink::WebMediaStreamSource::ReadyState state) { | 340 blink::WebMediaStreamSource::ReadyState state) { |
| 333 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 341 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 334 for (auto* sink : sinks_) | 342 for (auto* sink : sinks_) |
| 335 sink->OnReadyStateChanged(state); | 343 sink->OnReadyStateChanged(state); |
| 336 } | 344 } |
| 337 | 345 |
| 338 } // namespace content | 346 } // namespace content |
| OLD | NEW |