Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions sdk/objc/components/capturer/RTCCameraVideoCapturer.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ - (void)startCaptureWithDevice:(AVCaptureDevice *)device

NSError *error = nil;
if (![self.currentDevice lockForConfiguration:&error]) {
RTCLogError(@"Failed to lock device %@. Error: %@",
self.currentDevice,
RTCLogError(@"Failed to lock device %@. Error: %@", self.currentDevice,
error.userInfo);
if (completionHandler) {
completionHandler(error);
Expand All @@ -187,6 +186,7 @@ - (void)startCaptureWithDevice:(AVCaptureDevice *)device
[self reconfigureCaptureSessionInput];
[self updateDeviceCaptureFormat:format fps:fps];
[self updateVideoDataOutputPixelFormat:format];
[self updateZoomFactor];
[self.captureSession startRunning];
[self.currentDevice unlockForConfiguration];
self.isRunning = YES;
Expand Down Expand Up @@ -287,7 +287,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
RTC_OBJC_TYPE(RTCCVPixelBuffer) *rtcPixelBuffer =
[[RTC_OBJC_TYPE(RTCCVPixelBuffer) alloc] initWithPixelBuffer:pixelBuffer];
int64_t timeStampNs = CMTimeGetSeconds(CMSampleBufferGetPresentationTimeStamp(sampleBuffer)) *
kNanosecondsPerSecond;
kNanosecondsPerSecond;
RTC_OBJC_TYPE(RTCVideoFrame) *videoFrame =
[[RTC_OBJC_TYPE(RTCVideoFrame) alloc] initWithBuffer:rtcPixelBuffer
rotation:_rotation
Expand Down Expand Up @@ -417,8 +417,7 @@ - (void)handleApplicationDidBecomeActive:(NSNotification *)notification {
- (dispatch_queue_t)frameQueue {
if (!_frameQueue) {
_frameQueue = RTCDispatchQueueCreateWithTarget(
"org.webrtc.cameravideocapturer.video",
DISPATCH_QUEUE_SERIAL,
"org.webrtc.cameravideocapturer.video", DISPATCH_QUEUE_SERIAL,
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
}
return _frameQueue;
Expand Down Expand Up @@ -500,6 +499,18 @@ - (void)updateDeviceCaptureFormat:(AVCaptureDeviceFormat *)format fps:(NSInteger
}
}

- (void)updateZoomFactor {
NSAssert([RTC_OBJC_TYPE(RTCDispatcher) isOnQueueForType:RTCDispatcherTypeCaptureSession],
@"updateZoomFactor must be called on the capture queue.");

#if TARGET_OS_IOS || TARGET_OS_TV
CGFloat firstSwitchOverZoomFactor = 1.0;
NSNumber *first = _currentDevice.virtualDeviceSwitchOverVideoZoomFactors.firstObject;
if (first != nil) firstSwitchOverZoomFactor = first.doubleValue;
_currentDevice.videoZoomFactor = firstSwitchOverZoomFactor;
#endif
}

- (void)reconfigureCaptureSessionInput {
NSAssert([RTC_OBJC_TYPE(RTCDispatcher) isOnQueueForType:RTCDispatcherTypeCaptureSession],
@"reconfigureCaptureSessionInput must be called on the capture queue.");
Expand Down