Skip to content

Commit 88ce717

Browse files
committed
Fix Deprecated AvCaptureDevice Enumeration
1 parent 982f21c commit 88ce717

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

mac/platformcontext.mm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ of this software and associated documentation files (the "Software"), to deal
8888
LOG(LOG_DEBUG, "enumerateDevices called\n");
8989

9090
m_devices.clear();
91-
for (AVCaptureDevice* device in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo])
91+
AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera,AVCaptureDeviceTypeExternalUnknown]
92+
mediaType:AVMediaTypeVideo
93+
position:AVCaptureDevicePositionBack];
94+
for (AVCaptureDevice* device in [captureDeviceDiscoverySession devices])
9295
{
9396
platformDeviceInfo* deviceInfo = new platformDeviceInfo();
9497
deviceInfo->m_captureDevice = CFBridgingRetain(device);
@@ -104,7 +107,7 @@ of this software and associated documentation files (the "Software"), to deal
104107
NSRange vidRange = [device.modelID rangeOfString:@"VendorID_"];
105108
if (vidRange.length > 0)
106109
{
107-
uint32_t maxLen = device.modelID.length - vidRange.location - 9;
110+
unsigned long maxLen = device.modelID.length - vidRange.location - 9;
108111
maxLen = (maxLen > 5) ? 5 : maxLen;
109112
deviceInfo->m_vid = [[device.modelID substringWithRange:NSMakeRange(vidRange.location + 9, maxLen)] intValue];
110113
}
@@ -117,7 +120,7 @@ of this software and associated documentation files (the "Software"), to deal
117120
NSRange pidRange = [device.modelID rangeOfString:@"ProductID_"];
118121
if (pidRange.length > 0)
119122
{
120-
uint32_t maxLen = device.modelID.length - pidRange.location - 10;
123+
unsigned long maxLen = device.modelID.length - pidRange.location - 10;
121124
maxLen = (maxLen > 5) ? 5 : maxLen;
122125
deviceInfo->m_pid = [[device.modelID substringWithRange:NSMakeRange(pidRange.location + 10, maxLen)] intValue];
123126
}

mac/platformstream.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
8383
if (CVPixelBufferLockBaseAddress(pixelBuffer, 0) == kCVReturnSuccess)
8484
{
8585
const uint8_t *pixelPtr = static_cast<const uint8_t*>(CVPixelBufferGetBaseAddress(pixelBuffer));
86-
uint32_t frameBytes = CVPixelBufferGetHeight(pixelBuffer) *
86+
unsigned long frameBytes = CVPixelBufferGetHeight(pixelBuffer) *
8787
CVPixelBufferGetBytesPerRow(pixelBuffer);
8888

89-
m_stream->callback(pixelPtr, frameBytes);
89+
m_stream->callback(pixelPtr, (uint32_t)frameBytes);
9090

9191
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
9292
}

mac/uvcctrl.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ of this software and associated documentation files (the "Software"), to deal
146146
CFMutableDictionaryRef dict = IOServiceMatching(kIOUSBDeviceClassName);
147147

148148
io_iterator_t serviceIterator;
149-
IOServiceGetMatchingServices(kIOMasterPortDefault, dict, &serviceIterator);
149+
IOServiceGetMatchingServices(NULL, dict, &serviceIterator);
150150

151151
io_service_t device;
152152
while((device = IOIteratorNext(serviceIterator)) != 0)
@@ -789,4 +789,4 @@ of this software and associated documentation files (the "Software"), to deal
789789
LOG(LOG_VERBOSE,"DISCOMMIT");
790790
}
791791
LOG(LOG_VERBOSE,"\n");
792-
}
792+
}

0 commit comments

Comments
 (0)