Address tkchin's comments on RTCCameraVideoCapturer.

BUG=webrtc:7177

Review-Url: https://codereview.webrtc.org/2800853006
Cr-Original-Commit-Position: refs/heads/master@{#17986}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: cee5141eb0b77739dad0d3f0707425f71ee472fe
diff --git a/sdk/objc/Framework/Classes/RTCCameraVideoCapturer.m b/sdk/objc/Framework/Classes/RTCCameraVideoCapturer.m
index 16ddc13..9a0b40f 100644
--- a/sdk/objc/Framework/Classes/RTCCameraVideoCapturer.m
+++ b/sdk/objc/Framework/Classes/RTCCameraVideoCapturer.m
@@ -361,6 +361,8 @@
 #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 @@
 }
 
 - (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 @@
 }
 
 - (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) {
diff --git a/sdk/objc/Framework/Classes/RTCDispatcher.m b/sdk/objc/Framework/Classes/RTCDispatcher.m
index 94176ac..530e51a 100644
--- a/sdk/objc/Framework/Classes/RTCDispatcher.m
+++ b/sdk/objc/Framework/Classes/RTCDispatcher.m
@@ -33,6 +33,17 @@
   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 {
diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCCameraVideoCapturer.h b/sdk/objc/Framework/Headers/WebRTC/RTCCameraVideoCapturer.h
index 3a6cf0e..6eb6a9d 100644
--- a/sdk/objc/Framework/Headers/WebRTC/RTCCameraVideoCapturer.h
+++ b/sdk/objc/Framework/Headers/WebRTC/RTCCameraVideoCapturer.h
@@ -20,6 +20,9 @@
 // (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 @@
 // 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
diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCDispatcher.h b/sdk/objc/Framework/Headers/WebRTC/RTCDispatcher.h
index 328beaf..3dddead 100644
--- a/sdk/objc/Framework/Headers/WebRTC/RTCDispatcher.h
+++ b/sdk/objc/Framework/Headers/WebRTC/RTCDispatcher.h
@@ -37,4 +37,9 @@
 + (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