RTCDispatcher.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. };
  21. /** Dispatcher that asynchronously dispatches blocks to a specific
  22. * shared dispatch queue.
  23. */
  24. RTC_OBJC_EXPORT
  25. @interface RTC_OBJC_TYPE (RTCDispatcher) : NSObject
  26. - (instancetype)init NS_UNAVAILABLE;
  27. /** Dispatch the block asynchronously on the queue for dispatchType.
  28. * @param dispatchType The queue type to dispatch on.
  29. * @param block The block to dispatch asynchronously.
  30. */
  31. + (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType block:(dispatch_block_t)block;
  32. /** Returns YES if run on queue for the dispatchType otherwise NO.
  33. * Useful for asserting that a method is run on a correct queue.
  34. */
  35. + (BOOL)isOnQueueForType:(RTCDispatcherQueueType)dispatchType;
  36. @end