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..2581785c3ae957ee7631ce23a7a626402379a356 100644 |
--- a/content/browser/renderer_host/media/media_stream_manager.cc |
+++ b/content/browser/renderer_host/media/media_stream_manager.cc |
@@ -49,6 +49,7 @@ |
#include "media/base/audio_parameters.h" |
#include "media/base/channel_layout.h" |
#include "media/base/media_switches.h" |
+#include "media/capture/video/linux/camera_facing_chromeos.h" |
jochen (gone - plz use gerrit)
2017/01/05 12:17:59
we shouldn't unconditionally include platform spec
shenghao
2017/01/06 09:43:01
Done.
|
#include "media/capture/video/video_capture_device_factory.h" |
#include "url/gurl.h" |
#include "url/origin.h" |
@@ -67,6 +68,10 @@ base::LazyInstance<base::ThreadLocalPointer<MediaStreamManager>>::Leaky |
g_media_stream_manager_tls_ptr = LAZY_INSTANCE_INITIALIZER; |
namespace { |
+ |
+base::LazyInstance<media::CameraFacingChromeOS>::Leaky g_camera_facing_ = |
jochen (gone - plz use gerrit)
2017/01/05 12:17:59
why is that a singleton can't we create a new inst
shenghao
2017/01/06 09:43:01
It's a lazy instance so it only be constructed whe
|
+ LAZY_INSTANCE_INITIALIZER; |
+ |
// Creates a random label used to identify requests. |
std::string RandomLabel() { |
// An earlier PeerConnection spec [1] defined MediaStream::label alphabet as |
@@ -207,12 +212,25 @@ MediaDeviceType ConvertToMediaDeviceType(MediaStreamType stream_type) { |
return NUM_MEDIA_DEVICE_TYPES; |
} |
+VideoFacingMode GetVideoFacing(std::string device_id, std::string model_id) { |
+ 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; |
+ } |
+ 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)); |
} |
return devices; |