OLD | NEW |
(Empty) | |
| 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 |
| 11 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h" |
| 12 |
| 13 #include "webrtc/modules/audio_device/ios/audio_session_observer.h" |
| 14 |
| 15 #import "webrtc/base/objc/RTCLogging.h" |
| 16 |
| 17 @implementation RTCAudioSessionDelegateAdapter { |
| 18 webrtc::AudioSessionObserver *_observer; |
| 19 } |
| 20 |
| 21 - (instancetype)initWithObserver:(webrtc::AudioSessionObserver *)observer { |
| 22 NSParameterAssert(observer); |
| 23 if (self = [super init]) { |
| 24 _observer = observer; |
| 25 } |
| 26 return self; |
| 27 } |
| 28 |
| 29 #pragma mark - RTCAudioSessionDelegate |
| 30 |
| 31 - (void)audioSessionDidBeginInterruption:(RTCAudioSession *)session { |
| 32 _observer->OnInterruptionBegin(); |
| 33 } |
| 34 |
| 35 - (void)audioSessionDidEndInterruption:(RTCAudioSession *)session |
| 36 shouldResumeSession:(BOOL)shouldResumeSession { |
| 37 _observer->OnInterruptionEnd(); |
| 38 } |
| 39 |
| 40 - (void)audioSessionDidChangeRoute:(RTCAudioSession *)session |
| 41 reason:(AVAudioSessionRouteChangeReason)reason |
| 42 previousRoute:(AVAudioSessionRouteDescription *)previousRoute { |
| 43 switch (reason) { |
| 44 case AVAudioSessionRouteChangeReasonUnknown: |
| 45 case AVAudioSessionRouteChangeReasonNewDeviceAvailable: |
| 46 case AVAudioSessionRouteChangeReasonOldDeviceUnavailable: |
| 47 case AVAudioSessionRouteChangeReasonCategoryChange: |
| 48 // It turns out that we see a category change (at least in iOS 9.2) |
| 49 // when making a switch from a BT device to e.g. Speaker using the |
| 50 // iOS Control Center and that we therefore must check if the sample |
| 51 // rate has changed. And if so is the case, restart the audio unit. |
| 52 case AVAudioSessionRouteChangeReasonOverride: |
| 53 case AVAudioSessionRouteChangeReasonWakeFromSleep: |
| 54 case AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory: |
| 55 _observer->OnValidRouteChange(); |
| 56 break; |
| 57 case AVAudioSessionRouteChangeReasonRouteConfigurationChange: |
| 58 // The set of input and output ports has not changed, but their |
| 59 // configuration has, e.g., a port’s selected data source has |
| 60 // changed. Ignore this type of route change since we are focusing |
| 61 // on detecting headset changes. |
| 62 RTCLog(@"Ignoring RouteConfigurationChange"); |
| 63 break; |
| 64 } |
| 65 } |
| 66 |
| 67 - (void)audioSessionMediaServicesWereLost:(RTCAudioSession *)session { |
| 68 } |
| 69 |
| 70 - (void)audioSessionMediaServicesWereReset:(RTCAudioSession *)session { |
| 71 } |
| 72 |
| 73 - (void)audioSessionShouldConfigure:(RTCAudioSession *)session { |
| 74 } |
| 75 |
| 76 - (void)audioSessionShouldUnconfigure:(RTCAudioSession *)session { |
| 77 } |
| 78 |
| 79 @end |
OLD | NEW |