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

Side by Side Diff: media/capture/video/linux/video_capture_device_factory_linux.cc

Issue 2648973003: Sort camera device list to use front camera first (Closed)
Patch Set: address comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/capture/video/linux/video_capture_device_factory_linux.h" 5 #include "media/capture/video/linux/video_capture_device_factory_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <sys/ioctl.h> 10 #include <sys/ioctl.h>
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE, 221 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE,
222 VideoCaptureTransportType::OTHER_TRANSPORT, 222 VideoCaptureTransportType::OTHER_TRANSPORT,
223 g_camera_facing_helper.Get().GetCameraFacing(unique_id, model_id)); 223 g_camera_facing_helper.Get().GetCameraFacing(unique_id, model_id));
224 #else 224 #else
225 device_descriptors->emplace_back( 225 device_descriptors->emplace_back(
226 reinterpret_cast<char*>(cap.card), unique_id, model_id, 226 reinterpret_cast<char*>(cap.card), unique_id, model_id,
227 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE); 227 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE);
228 #endif 228 #endif
229 } 229 }
230 } 230 }
231 // Since JS doesn't have API to get camera facing, we sort the list to make
232 // apps can use the front camera by default.
233 // TODO(henryhsu): remove this after JS API completed (crbug.com/543997).
234 std::sort(device_descriptors->begin(), device_descriptors->end());
Guido Urdaneta 2017/01/24 10:42:07 Is this sorting relevant only for linux, or should
henryhsu 2017/01/25 03:28:18 This is for chromebook
231 } 235 }
232 236
233 void VideoCaptureDeviceFactoryLinux::GetSupportedFormats( 237 void VideoCaptureDeviceFactoryLinux::GetSupportedFormats(
234 const VideoCaptureDeviceDescriptor& device, 238 const VideoCaptureDeviceDescriptor& device,
235 VideoCaptureFormats* supported_formats) { 239 VideoCaptureFormats* supported_formats) {
236 DCHECK(thread_checker_.CalledOnValidThread()); 240 DCHECK(thread_checker_.CalledOnValidThread());
237 if (device.device_id.empty()) 241 if (device.device_id.empty())
238 return; 242 return;
239 base::ScopedFD fd(HANDLE_EINTR(open(device.device_id.c_str(), O_RDONLY))); 243 base::ScopedFD fd(HANDLE_EINTR(open(device.device_id.c_str(), O_RDONLY)));
240 if (!fd.is_valid()) // Failed to open this device. 244 if (!fd.is_valid()) // Failed to open this device.
(...skipping 28 matching lines...) Expand all
269 } 273 }
270 274
271 // static 275 // static
272 VideoCaptureDeviceFactory* 276 VideoCaptureDeviceFactory*
273 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( 277 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory(
274 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 278 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
275 return new VideoCaptureDeviceFactoryLinux(ui_task_runner); 279 return new VideoCaptureDeviceFactoryLinux(ui_task_runner);
276 } 280 }
277 281
278 } // namespace media 282 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698