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

Unified Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 2609863004: Pass camera facing to WebKit (Closed)
Patch Set: address review comment Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/media_stream_manager.cc
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index 029b0638c4e3ced5da47532ccb1c32e5b6504b51..51e50729e47e369ffdaeb32085f9afdcc30a2458 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -59,6 +59,7 @@
#if defined(OS_CHROMEOS)
#include "chromeos/audio/cras_audio_handler.h"
+#include "media/capture/video/linux/camera_facing_chromeos.h"
#endif
namespace content {
@@ -67,6 +68,12 @@ base::LazyInstance<base::ThreadLocalPointer<MediaStreamManager>>::Leaky
g_media_stream_manager_tls_ptr = LAZY_INSTANCE_INITIALIZER;
namespace {
+
+#if defined(OS_CHROMEOS)
+base::LazyInstance<media::CameraFacingChromeOS>::Leaky g_camera_facing_ =
mcasas 2017/01/11 22:24:58 s/g_camera_facing_/g_camera_facing/ (no trailing u
shenghao 2017/01/12 08:10:48 Done.
+ LAZY_INSTANCE_INITIALIZER;
+#endif
+
// Creates a random label used to identify requests.
std::string RandomLabel() {
// An earlier PeerConnection spec [1] defined MediaStream::label alphabet as
@@ -207,12 +214,33 @@ MediaDeviceType ConvertToMediaDeviceType(MediaStreamType stream_type) {
return NUM_MEDIA_DEVICE_TYPES;
}
+VideoFacingMode GetVideoFacing(std::string device_id,
+ std::string model_id,
+ MediaStreamType stream_type) {
+#if defined(OS_CHROMEOS)
+ media::CameraFacingChromeOS::LensFacing facing =
+ g_camera_facing_.Get().GetCameraFacing(device_id, model_id);
+ switch (facing) {
+ case media::CameraFacingChromeOS::LensFacing::FRONT:
+ return VideoFacingMode::MEDIA_VIDEO_FACING_USER;
+ case media::CameraFacingChromeOS::LensFacing::BACK:
+ return VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT;
+ }
+#endif
+ if (IsScreenCaptureMediaType(stream_type)) {
+ return VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT;
+ }
+ return VideoFacingMode::MEDIA_VIDEO_FACING_NONE;
+}
+
MediaStreamDevices ConvertToMediaStreamDevices(
MediaStreamType stream_type,
const MediaDeviceInfoArray& device_infos) {
MediaStreamDevices devices;
for (const auto& info : device_infos) {
- devices.emplace_back(stream_type, info.device_id, info.label);
+ devices.emplace_back(
+ stream_type, info.device_id, info.label,
+ GetVideoFacing(info.device_id, info.model_id, stream_type));
}
return devices;

Powered by Google App Engine
This is Rietveld 408576698