 Chromium Code Reviews
 Chromium Code Reviews Issue 2609863004:
  Pass camera facing to WebKit  (Closed)
    
  
    Issue 2609863004:
  Pass camera facing to WebKit  (Closed) 
  | 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..7574615918d7faa2659ac34e0ae6f00fd64137e6 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_ = | 
| + 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,27 @@ MediaDeviceType ConvertToMediaDeviceType(MediaStreamType stream_type) { | 
| return NUM_MEDIA_DEVICE_TYPES; | 
| } | 
| +VideoFacingMode GetVideoFacing(std::string device_id, std::string model_id) { | 
| +#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 | 
| + 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)); | 
| 
miu
2017/01/10 22:14:23
This returns the wrong value if content::IsScreenC
 
shenghao
2017/01/11 12:00:53
Done.
 | 
| } | 
| return devices; |