Address tkchin's comments on RTCCameraVideoCapturer.

BUG=webrtc:7177

Review-Url: https://codereview.webrtc.org/2800853006
Cr-Commit-Position: refs/heads/master@{#17986}
This commit is contained in:
sakal 2017-05-03 03:50:17 -07:00 committed by Commit bot
parent 70e39e159e
commit cee5141eb0
4 changed files with 25 additions and 3 deletions

View File

@ -361,6 +361,8 @@ static inline BOOL IsMediaSubTypeSupported(FourCharCode mediaSubType) {
#pragma mark - Private, called inside capture queue
- (void)updateDeviceCaptureFormat:(AVCaptureDeviceFormat *)format fps:(int)fps {
NSAssert([RTCDispatcher isOnQueueForType:RTCDispatcherTypeCaptureSession],
@"updateDeviceCaptureFormat must be called on the capture queue.");
@try {
_currentDevice.activeFormat = format;
_currentDevice.activeVideoMinFrameDuration = CMTimeMake(1, fps);
@ -371,6 +373,8 @@ static inline BOOL IsMediaSubTypeSupported(FourCharCode mediaSubType) {
}
- (void)reconfigureCaptureSessionInput {
NSAssert([RTCDispatcher isOnQueueForType:RTCDispatcherTypeCaptureSession],
@"reconfigureCaptureSessionInput must be called on the capture queue.");
NSError *error = nil;
AVCaptureDeviceInput *input =
[AVCaptureDeviceInput deviceInputWithDevice:_currentDevice error:&error];
@ -391,6 +395,8 @@ static inline BOOL IsMediaSubTypeSupported(FourCharCode mediaSubType) {
}
- (void)updateOrientation {
NSAssert([RTCDispatcher isOnQueueForType:RTCDispatcherTypeCaptureSession],
@"updateOrientation must be called on the capture queue.");
#if TARGET_OS_IPHONE
BOOL usingFrontCamera = _currentDevice.position == AVCaptureDevicePositionFront;
switch ([UIDevice currentDevice].orientation) {

View File

@ -33,6 +33,17 @@ static dispatch_queue_t kCaptureSessionQueue = nil;
dispatch_async(queue, block);
}
+ (BOOL)isOnQueueForType:(RTCDispatcherQueueType)dispatchType {
dispatch_queue_t targetQueue = [self dispatchQueueForType:dispatchType];
const char* targetLabel = dispatch_queue_get_label(targetQueue);
const char* currentLabel = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
NSAssert(strlen(targetLabel) > 0, @"Label is required for the target queue.");
NSAssert(strlen(currentLabel) > 0, @"Label is required for the current queue.");
return strcmp(targetLabel, currentLabel) == 0;
}
#pragma mark - Private
+ (dispatch_queue_t)dispatchQueueForType:(RTCDispatcherQueueType)dispatchType {

View File

@ -20,6 +20,9 @@ RTC_EXPORT
// (usually RTCVideoSource).
@interface RTCCameraVideoCapturer : RTCVideoCapturer
// Capture session that is used for capturing. Valid from initialization to dealloc.
@property(readonly, nonatomic) AVCaptureSession *captureSession;
// Returns list of available capture devices that support video capture.
+ (NSArray<AVCaptureDevice *> *)captureDevices;
// Returns list of formats that are supported by this class for this device.
@ -32,9 +35,6 @@ RTC_EXPORT
// Stops the capture session asynchronously.
- (void)stopCapture;
// Capture session that is used for capturing. Valid from initialization to dealloc.
@property(readonly, nonatomic) AVCaptureSession *captureSession;
@end
NS_ASSUME_NONNULL_END

View File

@ -37,4 +37,9 @@ RTC_EXPORT
+ (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType
block:(dispatch_block_t)block;
/** Returns YES if run on queue for the dispatchType otherwise NO.
* Useful for asserting that a method is run on a correct queue.
*/
+ (BOOL)isOnQueueForType:(RTCDispatcherQueueType)dispatchType;
@end