In the WebRTC M80 Release Notes they state they are going to be deprecating the mobile libraries.
To stay up to date with the latest bugfixes and features for the native mobile libraries (iOS and Android), we need to build from source.
After I built the AppRTCMobile example app using WebRTC.framework
built from source, I made a few changes and verified I was able to mute the remote audio track on demand.
In ARDAppClient.h
I add a strong pointer reference for the remote RTCMediaStream
and a method header for toggling the stream mute:
@property(nonatomic, strong) RTCMediaStream *remoteAudioStream;
// ...
- (void)setRemoteAudioEnabled:(BOOL)enabled;
In ARDAppClient.m
in the RTCPeerConnectionDelegate
section, I listen to the didAddStream
delegate and save a reference to the remote stream:
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didAddStream:(RTCMediaStream *)stream {
RTCLog(@"Stream with %lu video tracks and %lu audio tracks was added.",
(unsigned long)stream.videoTracks.count,
(unsigned long)stream.audioTracks.count);
_remoteAudioStream = stream;
}
In ARDAppClient.m
I also add a function to mute/unmute the stream we now have a reference to:
- (void)setRemoteAudioEnabled:(BOOL)enabled {
if (_state == kARDAppClientStateDisconnected) {
return;
}
RTCLog(@"Setting remote stream to be %s", enabled ? "Enabled" : "Not Enabled");
RTCLog(@"Number of remote audio tracks = %lu", (unsigned long)_remoteAudioStream.audioTracks.count);
if (_remoteAudioStream.audioTracks.count == 0) {
RTCLog(@"ERROR no audio tracks to disable!");
return;
}
_remoteAudioTrack = _remoteAudioStream.audioTracks[0];
[_remoteAudioTrack setIsEnabled:enabled];
}
Finally, in ARDVideoCallViewController.m
I override the switch-camera button to toggle the remote audio track mute:
- (void)videoCallViewDidSwitchCamera:(ARDVideoCallView *)view {
// [_captureController switchCamera];
self.audioEnabled = !self.audioEnabled;
[_client setRemoteAudioEnabled:self.audioEnabled];
}