can we remove and add audio stream dynamically in webRTC video call without renegotiation

有些话、适合烂在心里 提交于 2021-02-10 14:35:31

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/56944864/can-we-remove-and-add-audio-stream-dynamically-in-webrtc-video-call-without-rene

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!