本文介绍了我们可以在不重新协商的情况下在 webRTC 视频通话中动态删除和添加音频流吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在做一个 webRTC videoCall 应用程序.在某个时候我需要一个语音记录(正常),所以我只是从 peerconnection 中删除了音轨,并且在记录之后我需要将音轨添加到 peerconnection .但是我做不到!! public void removeAudioTrack() {列表senders = new ArrayList();senders.addAll(peerConnection.getSenders());尝试 {对于(RtpSender 发件人:发件人){如果 (sender.track() != null) {如果 (sender.track().id().equals(AUDIO_TRACK_ID)) {布尔标志 = peerConnection.removeTrack(sender);rtpSender = 发件人;}}}} 捕获(异常 e){}}公共无效 addAudioTrack() {localAudioTrack = createAudioTrack();mediaStream.addTrack(localAudioTrack);audioSender = peerConnection.addTrack(localAudioTrack,mediaStreamLabels);}音频声音没有进入另一侧(错误) 解决方案 根据 webrtc-pc 标准 - 您不能在不重新协商的情况下动态删除或添加流.但是,您可以替换轨道以将当前 RTCPSender 轨道替换为另一个轨道.根据 webrtc-pc 标准,这不需要重新协商.>I am doing a webRTC videoCall application . At apoint I need a voice record ( Normal), So I just removed the audio track from peerconnection and after record I need to add audio track to peerconnection . But i cann't do it !! public void removeAudioTrack() { List<RtpSender> senders = new ArrayList<>(); senders.addAll(peerConnection.getSenders()); try { for (RtpSender sender : senders) { if (sender.track() != null) { if (sender.track().id().equals(AUDIO_TRACK_ID)) { boolean flag = peerConnection.removeTrack(sender); rtpSender = sender; } } } } catch (Exception e) { }} public void addAudioTrack() { localAudioTrack = createAudioTrack(); mediaStream.addTrack(localAudioTrack); audioSender = peerConnection.addTrack(localAudioTrack,mediaStreamLabels);}The audio voice not getting in another side (error) 解决方案 As per the webrtc-pc standard - You cannot remove or add stream dynamically without re-negotiation. However, you can replace track to replace the current RTCPSender track with another track. And as per webrtc-pc standard this doesn't require a re-negotiation. 这篇关于我们可以在不重新协商的情况下在 webRTC 视频通话中动态删除和添加音频流吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-13 22:20