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}
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
index 03ce626..ad5bc80 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
@@ -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 {