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..14889a8385160a1144f2b0076ba847fef4e2f2fb 100644 |
--- a/content/browser/renderer_host/media/media_stream_manager.cc |
+++ b/content/browser/renderer_host/media/media_stream_manager.cc |
@@ -25,6 +25,7 @@ |
#include "base/task_runner_util.h" |
#include "base/threading/thread.h" |
#include "base/threading/thread_local.h" |
+#include "base/threading/thread_restrictions.h" |
#include "build/build_config.h" |
#include "content/browser/child_process_security_policy_impl.h" |
#include "content/browser/renderer_host/media/audio_input_device_manager.h" |
@@ -59,6 +60,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 +69,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 = |
+ LAZY_INSTANCE_INITIALIZER; |
hta - Chromium
2017/01/12 19:36:41
If this is a singleton, does it make the assumptio
shenghao
2017/01/13 11:09:34
No.
|
+#endif |
+ |
// Creates a random label used to identify requests. |
std::string RandomLabel() { |
// An earlier PeerConnection spec [1] defined MediaStream::label alphabet as |
@@ -207,12 +215,34 @@ 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; |
hta - Chromium
2017/01/12 19:36:41
How does this choice make sense?
I'd have thought
shenghao
2017/01/13 11:09:34
done
|
+ } |
+ return VideoFacingMode::MEDIA_VIDEO_FACING_NONE; |
+} |
+ |
MediaStreamDevices ConvertToMediaStreamDevices( |
MediaStreamType stream_type, |
const MediaDeviceInfoArray& device_infos) { |
+ base::ThreadRestrictions::SetIOAllowed(true); |
jochen (gone - plz use gerrit)
2017/01/12 11:54:41
why is this required? how long will the operation
shenghao
2017/01/13 11:09:34
Because we need to access camera config file when
|
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; |