Notify delegates about audio glitches in real time
Bug: webrtc:7819 Change-Id: I72ec77d216ce386dd45aef68eeac833b3a75b670 Reviewed-on: https://chromium-review.googlesource.com/543239 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Henrik Andreasson <henrika@webrtc.org> Commit-Queue: Anders Carlsson <andersc@webrtc.org> Cr-Commit-Position: refs/heads/master@{#18778}
This commit is contained in:
committed by
Commit Bot
parent
93ad1f7f1b
commit
121ea329ba
@ -22,7 +22,8 @@
|
||||
#import "WebRTC/RTCMediaConstraints.h"
|
||||
|
||||
@interface ARDVideoCallViewController () <ARDAppClientDelegate,
|
||||
ARDVideoCallViewDelegate>
|
||||
ARDVideoCallViewDelegate,
|
||||
RTCAudioSessionDelegate>
|
||||
@property(nonatomic, strong) RTCVideoTrack *remoteVideoTrack;
|
||||
@property(nonatomic, readonly) ARDVideoCallView *videoCallView;
|
||||
@end
|
||||
@ -57,6 +58,9 @@
|
||||
_videoCallView.statusLabel.text =
|
||||
[self statusTextForState:RTCIceConnectionStateNew];
|
||||
self.view = _videoCallView;
|
||||
|
||||
RTCAudioSession *session = [RTCAudioSession sharedInstance];
|
||||
[session addDelegate:self];
|
||||
}
|
||||
|
||||
#pragma mark - ARDAppClientDelegate
|
||||
@ -158,6 +162,13 @@
|
||||
_videoCallView.statsView.hidden = NO;
|
||||
}
|
||||
|
||||
#pragma mark - RTCAudioSessionDelegate
|
||||
|
||||
- (void)audioSession:(RTCAudioSession *)audioSession
|
||||
didDetectPlayoutGlitch:(int64_t)totalNumberOfGlitches {
|
||||
RTCLog(@"Audio session detected glitch, total: %lld", totalNumberOfGlitches);
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)setRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack {
|
||||
|
||||
@ -672,6 +672,12 @@ void AudioDeviceIOS::HandlePlayoutGlitchDetected() {
|
||||
num_detected_playout_glitches_++;
|
||||
RTCLog(@"Number of detected playout glitches: %lld",
|
||||
num_detected_playout_glitches_);
|
||||
|
||||
int64_t glitch_count = num_detected_playout_glitches_;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
RTCAudioSession* session = [RTCAudioSession sharedInstance];
|
||||
[session notifyDidDetectPlayoutGlitch:glitch_count];
|
||||
});
|
||||
}
|
||||
|
||||
void AudioDeviceIOS::HandleOutputVolumeChange() {
|
||||
|
||||
@ -90,6 +90,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)notifyDidChangeCanPlayOrRecord:(BOOL)canPlayOrRecord;
|
||||
- (void)notifyDidStartPlayOrRecord;
|
||||
- (void)notifyDidStopPlayOrRecord;
|
||||
- (void)notifyDidDetectPlayoutGlitch:(int64_t)totalNumberOfGlitches;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -914,4 +914,13 @@ NSString * const kRTCAudioSessionOutputVolumeSelector = @"outputVolume";
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyDidDetectPlayoutGlitch:(int64_t)totalNumberOfGlitches {
|
||||
for (auto delegate : self.delegates) {
|
||||
SEL sel = @selector(audioSession:didDetectPlayoutGlitch:);
|
||||
if ([delegate respondsToSelector:sel]) {
|
||||
[delegate audioSession:self didDetectPlayoutGlitch:totalNumberOfGlitches];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -78,6 +78,12 @@ RTC_EXPORT
|
||||
- (void)audioSession:(RTCAudioSession *)audioSession
|
||||
didChangeOutputVolume:(float)outputVolume;
|
||||
|
||||
/** Called when the audio device detects a playout glitch. The argument is the
|
||||
* number of glitches detected so far in the current audio playout session.
|
||||
*/
|
||||
- (void)audioSession:(RTCAudioSession *)audioSession
|
||||
didDetectPlayoutGlitch:(int64_t)totalNumberOfGlitches;
|
||||
|
||||
@end
|
||||
|
||||
/** This is a protocol used to inform RTCAudioSession when the audio session
|
||||
|
||||
Reference in New Issue
Block a user