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" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 const char kVideoKindColor[] = "color"; | |
18 const char kVideoKindDepth[] = "depth"; | |
19 | |
20 blink::WebString GetVideoKindForFormat( | |
Guido Urdaneta
2017/02/10 15:36:17
nit: I still would prefer the function to be in me
aleksandar.stojiljkovic
2017/02/10 16:29:23
Done.
| |
21 const media::VideoCaptureFormat& format) { | |
22 return (format.pixel_format == media::PIXEL_FORMAT_Y16) | |
23 ? blink::WebString::fromASCII(kVideoKindDepth) | |
24 : blink::WebString::fromASCII(kVideoKindColor); | |
25 } | |
26 | |
17 namespace { | 27 namespace { |
18 void ResetCallback(std::unique_ptr<VideoCaptureDeliverFrameCB> callback) { | 28 void ResetCallback(std::unique_ptr<VideoCaptureDeliverFrameCB> callback) { |
19 // |callback| will be deleted when this exits. | 29 // |callback| will be deleted when this exits. |
20 } | 30 } |
21 | 31 |
22 // Empty method used for keeping a reference to the original media::VideoFrame. | 32 // Empty method used for keeping a reference to the original media::VideoFrame. |
23 // The reference to |frame| is kept in the closure that calls this method. | 33 // The reference to |frame| is kept in the closure that calls this method. |
24 void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) { | 34 void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) { |
25 } | 35 } |
26 | 36 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 // TODO(hta): Extract the real value. | 314 // TODO(hta): Extract the real value. |
305 settings.deviceId = blink::WebString("video device ID"); | 315 settings.deviceId = blink::WebString("video device ID"); |
306 if (!source_) | 316 if (!source_) |
307 return; | 317 return; |
308 | 318 |
309 const media::VideoCaptureFormat* format = source_->GetCurrentFormat(); | 319 const media::VideoCaptureFormat* format = source_->GetCurrentFormat(); |
310 if (format) { | 320 if (format) { |
311 settings.frameRate = format->frame_rate; | 321 settings.frameRate = format->frame_rate; |
312 settings.width = format->frame_size.width(); | 322 settings.width = format->frame_size.width(); |
313 settings.height = format->frame_size.height(); | 323 settings.height = format->frame_size.height(); |
324 settings.videoKind = GetVideoKindForFormat(*format); | |
314 } | 325 } |
315 switch (source_->device_info().device.video_facing) { | 326 switch (source_->device_info().device.video_facing) { |
316 case media::MEDIA_VIDEO_FACING_NONE: | 327 case media::MEDIA_VIDEO_FACING_NONE: |
317 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::None; | 328 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::None; |
318 break; | 329 break; |
319 case media::MEDIA_VIDEO_FACING_USER: | 330 case media::MEDIA_VIDEO_FACING_USER: |
320 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::User; | 331 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::User; |
321 break; | 332 break; |
322 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: | 333 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: |
323 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::Environment; | 334 settings.facingMode = blink::WebMediaStreamTrack::FacingMode::Environment; |
(...skipping 13 matching lines...) Expand all Loading... | |
337 } | 348 } |
338 | 349 |
339 void MediaStreamVideoTrack::OnReadyStateChanged( | 350 void MediaStreamVideoTrack::OnReadyStateChanged( |
340 blink::WebMediaStreamSource::ReadyState state) { | 351 blink::WebMediaStreamSource::ReadyState state) { |
341 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 352 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
342 for (auto* sink : sinks_) | 353 for (auto* sink : sinks_) |
343 sink->OnReadyStateChanged(state); | 354 sink->OnReadyStateChanged(state); |
344 } | 355 } |
345 | 356 |
346 } // namespace content | 357 } // namespace content |
OLD | NEW |