OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/media/media_stream_manager.h" | 5 #include "content/browser/renderer_host/media/media_stream_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 #include "media/capture/video/video_capture_device_factory.h" | 52 #include "media/capture/video/video_capture_device_factory.h" |
53 #include "url/gurl.h" | 53 #include "url/gurl.h" |
54 #include "url/origin.h" | 54 #include "url/origin.h" |
55 | 55 |
56 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
57 #include "base/win/scoped_com_initializer.h" | 57 #include "base/win/scoped_com_initializer.h" |
58 #endif | 58 #endif |
59 | 59 |
60 #if defined(OS_CHROMEOS) | 60 #if defined(OS_CHROMEOS) |
61 #include "chromeos/audio/cras_audio_handler.h" | 61 #include "chromeos/audio/cras_audio_handler.h" |
62 #include "media/capture/video/linux/camera_facing_chromeos.h" | |
62 #endif | 63 #endif |
63 | 64 |
64 namespace content { | 65 namespace content { |
65 | 66 |
66 base::LazyInstance<base::ThreadLocalPointer<MediaStreamManager>>::Leaky | 67 base::LazyInstance<base::ThreadLocalPointer<MediaStreamManager>>::Leaky |
67 g_media_stream_manager_tls_ptr = LAZY_INSTANCE_INITIALIZER; | 68 g_media_stream_manager_tls_ptr = LAZY_INSTANCE_INITIALIZER; |
68 | 69 |
69 namespace { | 70 namespace { |
71 | |
72 #if defined(OS_CHROMEOS) | |
73 base::LazyInstance<media::CameraFacingChromeOS>::Leaky g_camera_facing_ = | |
74 LAZY_INSTANCE_INITIALIZER; | |
75 #endif | |
76 | |
70 // Creates a random label used to identify requests. | 77 // Creates a random label used to identify requests. |
71 std::string RandomLabel() { | 78 std::string RandomLabel() { |
72 // An earlier PeerConnection spec [1] defined MediaStream::label alphabet as | 79 // An earlier PeerConnection spec [1] defined MediaStream::label alphabet as |
73 // an uuid with characters from range: U+0021, U+0023 to U+0027, U+002A to | 80 // an uuid with characters from range: U+0021, U+0023 to U+0027, U+002A to |
74 // U+002B, U+002D to U+002E, U+0030 to U+0039, U+0041 to U+005A, U+005E to | 81 // U+002B, U+002D to U+002E, U+0030 to U+0039, U+0041 to U+005A, U+005E to |
75 // U+007E. That causes problems with searching for labels in bots, so we use a | 82 // U+007E. That causes problems with searching for labels in bots, so we use a |
76 // safe alphanumeric subset |kAlphabet|. | 83 // safe alphanumeric subset |kAlphabet|. |
77 // [1] http://dev.w3.org/2011/webrtc/editor/webrtc.html | 84 // [1] http://dev.w3.org/2011/webrtc/editor/webrtc.html |
78 static const char kAlphabet[] = "0123456789" | 85 static const char kAlphabet[] = "0123456789" |
79 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | 86 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 return MEDIA_DEVICE_TYPE_AUDIO_INPUT; | 207 return MEDIA_DEVICE_TYPE_AUDIO_INPUT; |
201 case MEDIA_DEVICE_VIDEO_CAPTURE: | 208 case MEDIA_DEVICE_VIDEO_CAPTURE: |
202 return MEDIA_DEVICE_TYPE_VIDEO_INPUT; | 209 return MEDIA_DEVICE_TYPE_VIDEO_INPUT; |
203 default: | 210 default: |
204 NOTREACHED(); | 211 NOTREACHED(); |
205 } | 212 } |
206 | 213 |
207 return NUM_MEDIA_DEVICE_TYPES; | 214 return NUM_MEDIA_DEVICE_TYPES; |
208 } | 215 } |
209 | 216 |
217 VideoFacingMode GetVideoFacing(std::string device_id, std::string model_id) { | |
218 #if defined(OS_CHROMEOS) | |
219 media::CameraFacingChromeOS::LensFacing facing = | |
220 g_camera_facing_.Get().GetCameraFacing(device_id, model_id); | |
221 switch (facing) { | |
222 case media::CameraFacingChromeOS::LensFacing::FRONT: | |
223 return VideoFacingMode::MEDIA_VIDEO_FACING_USER; | |
224 case media::CameraFacingChromeOS::LensFacing::BACK: | |
225 return VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT; | |
226 } | |
227 #endif | |
228 return VideoFacingMode::MEDIA_VIDEO_FACING_NONE; | |
229 } | |
230 | |
210 MediaStreamDevices ConvertToMediaStreamDevices( | 231 MediaStreamDevices ConvertToMediaStreamDevices( |
211 MediaStreamType stream_type, | 232 MediaStreamType stream_type, |
212 const MediaDeviceInfoArray& device_infos) { | 233 const MediaDeviceInfoArray& device_infos) { |
213 MediaStreamDevices devices; | 234 MediaStreamDevices devices; |
214 for (const auto& info : device_infos) { | 235 for (const auto& info : device_infos) { |
215 devices.emplace_back(stream_type, info.device_id, info.label); | 236 devices.emplace_back(stream_type, info.device_id, info.label, |
237 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.
| |
216 } | 238 } |
217 | 239 |
218 return devices; | 240 return devices; |
219 } | 241 } |
220 | 242 |
221 } // namespace | 243 } // namespace |
222 | 244 |
223 | 245 |
224 // MediaStreamManager::DeviceRequest represents a request to either enumerate | 246 // MediaStreamManager::DeviceRequest represents a request to either enumerate |
225 // available devices or open one or more devices. | 247 // available devices or open one or more devices. |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1743 generate_stream_test_callback_ = test_callback; | 1765 generate_stream_test_callback_ = test_callback; |
1744 } | 1766 } |
1745 | 1767 |
1746 #if defined(OS_WIN) | 1768 #if defined(OS_WIN) |
1747 void MediaStreamManager::FlushVideoCaptureThreadForTesting() { | 1769 void MediaStreamManager::FlushVideoCaptureThreadForTesting() { |
1748 video_capture_thread_.FlushForTesting(); | 1770 video_capture_thread_.FlushForTesting(); |
1749 } | 1771 } |
1750 #endif | 1772 #endif |
1751 | 1773 |
1752 } // namespace content | 1774 } // namespace content |
OLD | NEW |