如何在不更改框架的情况下禁用WebRTC移动应用程序(iOS)中的音频 [英] How to disable audio in webrtc mobile app(ios) without changing in framework
本文介绍了如何在不更改框架的情况下禁用WebRTC移动应用程序(iOS)中的音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用webrtc mobile(ios).我无法在webrtc(ios)中禁用音频.我没有禁用音频的标志.通过更改框架/库,可以轻松完成.我的目的是我必须禁用音频而不更改框架/库.有人可以帮我吗?.
I am working with webrtc mobile(ios). I can't disable audio in webrtc(ios). I have got no flag to disable audio.By changing in framwork/library it can done easily. My purpose is that I have to disable audio without changing in framework/library. Can anyone help me?.
推荐答案
使用代码片段(如何创建mediaStrem或音轨(音频/视频))更新您的问题.
Update your question with code snippet, how you are creating mediaStrem or tracks(audio/video).
通常使用默认的本机WebRTC框架,
Generally with default Native WebRTC Framework,
RTCMediaStream localStream = [_factory mediaStreamWithStreamId:kARDMediaStreamId];
if(audioRequired) {
RTCAudioTrack *aTrack = [_lmStream createLocalAudioTrack];
[localStream addAudioTrack:aTrack];
}
RTCVideoTrack *vTrack = [_lmStream createLocalVideoTrack];
[localStream addVideoTrack:vTrack];
[_peerConnection addStream:localStream];
如果要在通话中使音频静音,请使用以下功能.
If you want to mute the Audio during the call, use below function.
- (void)enableAudio:(NSString *)id isAudioEnabled:(BOOL) isAudioEnabled {
NSLog(@"Auido enabled: %d streams count:%d ", id, isAudioEnabled, _peerConnection.localStreams.count);
if(_peerConnection.localStreams.count > 0) {
RTCMediaStream *lStream = _peerConnection.localStreams[0];
if(lStream.audioTracks.count > 0) { // Usually we will have only one track. If you have more than one, need to traverse all.
// isAudioEnabled == 1 -> Unmute
// isAudioEnabled == 0 -> Mute
[lStream.audioTracks[0] setIsEnabled:isAudioEnabled];
}
}
}
这篇关于如何在不更改框架的情况下禁用WebRTC移动应用程序(iOS)中的音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文