RTCAudioSession+Private.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2016 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 "RTCAudioSession.h"
  11. NS_ASSUME_NONNULL_BEGIN
  12. @class RTC_OBJC_TYPE(RTCAudioSessionConfiguration);
  13. @interface RTC_OBJC_TYPE (RTCAudioSession)
  14. ()
  15. /** Number of times setActive:YES has succeeded without a balanced call to
  16. * setActive:NO.
  17. */
  18. @property(nonatomic, readonly) int activationCount;
  19. /** The number of times |beginWebRTCSession| was called without a balanced call
  20. * to |endWebRTCSession|.
  21. */
  22. @property(nonatomic, readonly) int webRTCSessionCount;
  23. /** Convenience BOOL that checks useManualAudio and isAudioEnebled. */
  24. @property(readonly) BOOL canPlayOrRecord;
  25. /** Tracks whether we have been sent an interruption event that hasn't been matched by either an
  26. * interrupted end event or a foreground event.
  27. */
  28. @property(nonatomic, assign) BOOL isInterrupted;
  29. - (BOOL)checkLock:(NSError **)outError;
  30. /** Adds the delegate to the list of delegates, and places it at the front of
  31. * the list. This delegate will be notified before other delegates of
  32. * audio events.
  33. */
  34. - (void)pushDelegate:(id<RTC_OBJC_TYPE(RTCAudioSessionDelegate)>)delegate;
  35. /** Signals RTCAudioSession that a WebRTC session is about to begin and
  36. * audio configuration is needed. Will configure the audio session for WebRTC
  37. * if not already configured and if configuration is not delayed.
  38. * Successful calls must be balanced by a call to endWebRTCSession.
  39. */
  40. - (BOOL)beginWebRTCSession:(NSError **)outError;
  41. /** Signals RTCAudioSession that a WebRTC session is about to end and audio
  42. * unconfiguration is needed. Will unconfigure the audio session for WebRTC
  43. * if this is the last unmatched call and if configuration is not delayed.
  44. */
  45. - (BOOL)endWebRTCSession:(NSError **)outError;
  46. /** Configure the audio session for WebRTC. This call will fail if the session
  47. * is already configured. On other failures, we will attempt to restore the
  48. * previously used audio session configuration.
  49. * |lockForConfiguration| must be called first.
  50. * Successful calls to configureWebRTCSession must be matched by calls to
  51. * |unconfigureWebRTCSession|.
  52. */
  53. - (BOOL)configureWebRTCSession:(NSError **)outError;
  54. /** Unconfigures the session for WebRTC. This will attempt to restore the
  55. * audio session to the settings used before |configureWebRTCSession| was
  56. * called.
  57. * |lockForConfiguration| must be called first.
  58. */
  59. - (BOOL)unconfigureWebRTCSession:(NSError **)outError;
  60. /** Returns a configuration error with the given description. */
  61. - (NSError *)configurationErrorWithDescription:(NSString *)description;
  62. // Properties and methods for tests.
  63. - (void)notifyDidBeginInterruption;
  64. - (void)notifyDidEndInterruptionWithShouldResumeSession:(BOOL)shouldResumeSession;
  65. - (void)notifyDidChangeRouteWithReason:(AVAudioSessionRouteChangeReason)reason
  66. previousRoute:(AVAudioSessionRouteDescription *)previousRoute;
  67. - (void)notifyMediaServicesWereLost;
  68. - (void)notifyMediaServicesWereReset;
  69. - (void)notifyDidChangeCanPlayOrRecord:(BOOL)canPlayOrRecord;
  70. - (void)notifyDidStartPlayOrRecord;
  71. - (void)notifyDidStopPlayOrRecord;
  72. - (void)notifyDidDetectPlayoutGlitch:(int64_t)totalNumberOfGlitches;
  73. @end
  74. NS_ASSUME_NONNULL_END