RTCDispatcher.h 1.5 KB

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