Chromium Code Reviews| Index: talk/app/webrtc/objc/avfoundationvideocapturer.mm |
| diff --git a/talk/app/webrtc/objc/avfoundationvideocapturer.mm b/talk/app/webrtc/objc/avfoundationvideocapturer.mm |
| index e1b0f88fb6ee590b405af970fefbef4db921bd11..8efacf0514f257c787760b0a6ba80cfc9634394e 100644 |
| --- a/talk/app/webrtc/objc/avfoundationvideocapturer.mm |
| +++ b/talk/app/webrtc/objc/avfoundationvideocapturer.mm |
| @@ -28,6 +28,7 @@ |
| #include "talk/app/webrtc/objc/avfoundationvideocapturer.h" |
| #include "webrtc/base/bind.h" |
| +#import "webrtc/base/objc/RTCDispatcher.h" |
|
tkchin_webrtc
2015/12/07 18:27:07
nit: move this under the #import section
Chuck
2015/12/07 19:34:31
Done.
|
| #import <AVFoundation/AVFoundation.h> |
| #import <Foundation/Foundation.h> |
| @@ -41,11 +42,6 @@ static cricket::VideoFormat const kDefaultFormat = |
| cricket::VideoFormat::FpsToInterval(30), |
| cricket::FOURCC_NV12); |
| -// This queue is used to start and stop the capturer without blocking the |
| -// calling thread. -[AVCaptureSession startRunning] blocks until the camera is |
| -// running. |
| -static dispatch_queue_t kBackgroundQueue = nil; |
| - |
| // This class used to capture frames using AVFoundation APIs on iOS. It is meant |
| // to be owned by an instance of AVFoundationVideoCapturer. The reason for this |
| // because other webrtc objects own cricket::VideoCapturer, which is not |
| @@ -80,15 +76,6 @@ static dispatch_queue_t kBackgroundQueue = nil; |
| @synthesize useBackCamera = _useBackCamera; |
| @synthesize isRunning = _isRunning; |
| -+ (void)initialize { |
| - static dispatch_once_t onceToken; |
| - dispatch_once(&onceToken, ^{ |
| - kBackgroundQueue = dispatch_queue_create( |
| - "com.google.webrtc.RTCAVFoundationCapturerBackground", |
| - DISPATCH_QUEUE_SERIAL); |
| - }); |
| -} |
| - |
| - (instancetype)initWithCapturer:(webrtc::AVFoundationVideoCapturer*)capturer { |
| NSParameterAssert(capturer); |
| if (self = [super init]) { |
| @@ -132,9 +119,10 @@ static dispatch_queue_t kBackgroundQueue = nil; |
| _orientationHasChanged = NO; |
| [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; |
| AVCaptureSession* session = _captureSession; |
| - dispatch_async(kBackgroundQueue, ^{ |
| + [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession |
| + block:^{ |
| [session startRunning]; |
| - }); |
| + }]; |
| _isRunning = YES; |
| } |
| @@ -144,9 +132,10 @@ static dispatch_queue_t kBackgroundQueue = nil; |
| } |
| [_videoOutput setSampleBufferDelegate:nil queue:nullptr]; |
| AVCaptureSession* session = _captureSession; |
| - dispatch_async(kBackgroundQueue, ^{ |
| + [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession |
| + block:^{ |
| [session stopRunning]; |
| - }); |
| + }]; |
| [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; |
| _isRunning = NO; |
| } |