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

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

Issue 2970453003: Add support for facingMode in MediaStreamTrack.getSettings() on Android. (Closed)
Patch Set: 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
« 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 <string>
7 #include <utility> 8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/location.h" 11 #include "base/location.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "build/build_config.h"
15 #include "content/renderer/media/media_stream_constraints_util_video_device.h" 17 #include "content/renderer/media/media_stream_constraints_util_video_device.h"
16 #include "media/capture/video_capture_types.h" 18 #include "media/capture/video_capture_types.h"
17 19
18 namespace content { 20 namespace content {
19 21
20 namespace { 22 namespace {
21 void ResetCallback(std::unique_ptr<VideoCaptureDeliverFrameCB> callback) { 23 void ResetCallback(std::unique_ptr<VideoCaptureDeliverFrameCB> callback) {
22 // |callback| will be deleted when this exits. 24 // |callback| will be deleted when this exits.
23 } 25 }
24 26
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kUser; 421 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kUser;
420 break; 422 break;
421 case media::MEDIA_VIDEO_FACING_ENVIRONMENT: 423 case media::MEDIA_VIDEO_FACING_ENVIRONMENT:
422 settings.facing_mode = 424 settings.facing_mode =
423 blink::WebMediaStreamTrack::FacingMode::kEnvironment; 425 blink::WebMediaStreamTrack::FacingMode::kEnvironment;
424 break; 426 break;
425 default: 427 default:
426 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kNone; 428 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kNone;
427 break; 429 break;
428 } 430 }
431 #if defined(OS_ANDROID)
432 // On Android, the facing mode is not available in the |facing| field,
hbos_chromium 2017/07/05 10:21:04 nit: video_facing field
Guido Urdaneta 2017/07/06 08:20:16 Done.
433 // but is available as part of the label.
434 // TODO(guidou): Remove this code once the |facing| field is supported
435 // on Android. See http://crbug.com/672856.
436 if (source_->device_info().device.name.find("front") != std::string::npos) {
437 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kUser;
438 } else if (source_->device_info().device.name.find("back") !=
439 std::string::npos) {
440 settings.facing_mode = blink::WebMediaStreamTrack::FacingMode::kEnvironment;
441 }
442 #endif
443
429 const base::Optional<CameraCalibration> calibration = 444 const base::Optional<CameraCalibration> calibration =
430 source_->device_info().device.camera_calibration; 445 source_->device_info().device.camera_calibration;
431 if (calibration) { 446 if (calibration) {
432 settings.depth_near = calibration->depth_near; 447 settings.depth_near = calibration->depth_near;
433 settings.depth_far = calibration->depth_far; 448 settings.depth_far = calibration->depth_far;
434 settings.focal_length_x = calibration->focal_length_x; 449 settings.focal_length_x = calibration->focal_length_x;
435 settings.focal_length_y = calibration->focal_length_y; 450 settings.focal_length_y = calibration->focal_length_y;
436 } 451 }
437 } 452 }
438 453
439 void MediaStreamVideoTrack::OnReadyStateChanged( 454 void MediaStreamVideoTrack::OnReadyStateChanged(
440 blink::WebMediaStreamSource::ReadyState state) { 455 blink::WebMediaStreamSource::ReadyState state) {
441 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 456 DCHECK(main_render_thread_checker_.CalledOnValidThread());
442 for (auto* sink : sinks_) 457 for (auto* sink : sinks_)
443 sink->OnReadyStateChanged(state); 458 sink->OnReadyStateChanged(state);
444 } 459 }
445 460
446 } // namespace content 461 } // 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