我正在做一个webRTC videoCall应用程序。暂时我需要一个语音记录(正常),所以我只是从对等连接中删除了音轨,并且在录音之后,我需要向对等连接中添加音轨。但是我做不到!
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);
}
声音没有进入另一侧(错误)