Sort video capture devices.
CFMs currently rely on this behavior. It was removed in https://chromium-review.googlesource.com/c/chromium/src/+/2306918. BUG=b:167805373 TEST='Locally checked order of video capture devices on CFM devices.' Change-Id: I2dc348a88b6821e7cac257ecf9710ec1c5247942 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2573196 Reviewed-by: Guido Urdaneta <guidou@chromium.org> Reviewed-by: Sergey Ulanov <sergeyu@chromium.org> Auto-Submit: Chris Buquicchio <cbuquicchio@google.com> Commit-Queue: Chris Buquicchio <cbuquicchio@google.com> Cr-Commit-Position: refs/heads/master@{#833774}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a1f0357eb4
commit
2685d2e059
@ -37,6 +37,11 @@ namespace media {
|
||||
|
||||
namespace {
|
||||
|
||||
bool CompareCaptureDevices(const VideoCaptureDeviceInfo& a,
|
||||
const VideoCaptureDeviceInfo& b) {
|
||||
return a.descriptor < b.descriptor;
|
||||
}
|
||||
|
||||
// USB VID and PID are both 4 bytes long.
|
||||
const size_t kVidPidSize = 4;
|
||||
const size_t kMaxInterfaceNameSize = 256;
|
||||
@ -242,6 +247,10 @@ void VideoCaptureDeviceFactoryLinux::GetDevicesInfo(
|
||||
}
|
||||
}
|
||||
|
||||
// This is required for some applications that rely on the stable ordering of
|
||||
// devices.
|
||||
std::sort(devices_info.begin(), devices_info.end(), CompareCaptureDevices);
|
||||
|
||||
std::move(callback).Run(std::move(devices_info));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user