1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2015 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #import <Foundation/Foundation.h> 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker #import "RTCMacros.h" 14*d9f75844SAndroid Build Coastguard Worker 15*d9f75844SAndroid Build Coastguard Worker typedef NS_ENUM(NSInteger, RTCDispatcherQueueType) { 16*d9f75844SAndroid Build Coastguard Worker // Main dispatcher queue. 17*d9f75844SAndroid Build Coastguard Worker RTCDispatcherTypeMain, 18*d9f75844SAndroid Build Coastguard Worker // Used for starting/stopping AVCaptureSession, and assigning 19*d9f75844SAndroid Build Coastguard Worker // capture session to AVCaptureVideoPreviewLayer. 20*d9f75844SAndroid Build Coastguard Worker RTCDispatcherTypeCaptureSession, 21*d9f75844SAndroid Build Coastguard Worker // Used for operations on AVAudioSession. 22*d9f75844SAndroid Build Coastguard Worker RTCDispatcherTypeAudioSession, 23*d9f75844SAndroid Build Coastguard Worker // Used for operations on NWPathMonitor. 24*d9f75844SAndroid Build Coastguard Worker RTCDispatcherTypeNetworkMonitor, 25*d9f75844SAndroid Build Coastguard Worker }; 26*d9f75844SAndroid Build Coastguard Worker 27*d9f75844SAndroid Build Coastguard Worker /** Dispatcher that asynchronously dispatches blocks to a specific 28*d9f75844SAndroid Build Coastguard Worker * shared dispatch queue. 29*d9f75844SAndroid Build Coastguard Worker */ 30*d9f75844SAndroid Build Coastguard Worker RTC_OBJC_EXPORT 31*d9f75844SAndroid Build Coastguard Worker @interface RTC_OBJC_TYPE (RTCDispatcher) : NSObject 32*d9f75844SAndroid Build Coastguard Worker 33*d9f75844SAndroid Build Coastguard Worker - (instancetype)init NS_UNAVAILABLE; 34*d9f75844SAndroid Build Coastguard Worker 35*d9f75844SAndroid Build Coastguard Worker /** Dispatch the block asynchronously on the queue for dispatchType. 36*d9f75844SAndroid Build Coastguard Worker * @param dispatchType The queue type to dispatch on. 37*d9f75844SAndroid Build Coastguard Worker * @param block The block to dispatch asynchronously. 38*d9f75844SAndroid Build Coastguard Worker */ 39*d9f75844SAndroid Build Coastguard Worker + (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType block:(dispatch_block_t)block; 40*d9f75844SAndroid Build Coastguard Worker 41*d9f75844SAndroid Build Coastguard Worker /** Returns YES if run on queue for the dispatchType otherwise NO. 42*d9f75844SAndroid Build Coastguard Worker * Useful for asserting that a method is run on a correct queue. 43*d9f75844SAndroid Build Coastguard Worker */ 44*d9f75844SAndroid Build Coastguard Worker + (BOOL)isOnQueueForType:(RTCDispatcherQueueType)dispatchType; 45*d9f75844SAndroid Build Coastguard Worker 46*d9f75844SAndroid Build Coastguard Worker @end 47