зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
55681e438e
Коммит
e72615c01c
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче