Bug 1629984 - Stop enumerating suspended cameras. r=padenot

Suspended cameras are not able to capture data thus they are removed from the list of enumerated devices.

Differential Revision: https://phabricator.services.mozilla.com/D74210
This commit is contained in:
Alex Chronopoulos 2020-05-07 12:57:08 +00:00
Родитель 55681e438e
Коммит e72615c01c
1 изменённых файлов: 25 добавлений и 3 удалений

Просмотреть файл

@ -43,17 +43,39 @@
}
+ (int)captureDeviceCount {
return [[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo] count];
int cnt = 0;
for (AVCaptureDevice* device in
[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
if ([device isSuspended]) {
continue;
}
cnt++;
}
return cnt;
}
+ (AVCaptureDevice*)captureDeviceForIndex:(int)index {
return [[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]
objectAtIndex:index];
int cnt = 0;
for (AVCaptureDevice* device in
[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
if ([device isSuspended]) {
continue;
}
if (cnt == index) {
return device;
}
cnt++;
}
return nil;
}
+ (AVCaptureDevice*)captureDeviceForUniqueId:(NSString*)uniqueId {
for (AVCaptureDevice* device in
[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
if ([device isSuspended]) {
continue;
}
if ([uniqueId isEqual:device.uniqueID]) {
return device;
}