添加回溯轨道在 WebRTC 上不起作用

Adding Back Tracks Does Not Work on WebRTC

我们使用 React Native WebRTC 和 Janus Gateway 创建了一个应用程序。它按需工作。我们的应用程序基于一键通。因此,当处于监听模式的用户需要为其他应用程序打破 microphone 时。并在有人按下发言按钮时收回。

麦克风坏了:

if (!globalTrack) {
     globalTracks = config.myStream.getTracks();
}
config.myStream.getTracks().forEach(t => {
    config.myStream.removeTrack(t);
});

找回踪迹:

globalTracks.forEach(t => {
    config.myStream.addTrack(t);
});

pluginHandle.createOffer({
    media: { addVideo: true },
    success: function(jsep) {
        Janus.debug(jsep);
        pluginHandle.send({message: {audio: true, video: false}, "jsep": jsep });
    },
    error: function(error) {
        console.log("WebRTC error... " + JSON.stringify(error));
    }
});

// also I have try this:

devices = await mediaDevices.getUserMedia({audio: true, video: false})
// devices output https://pastebin.ubuntu.com/p/KQqBq2QRy3/
devices._tracks.forEach(t => {
    config.myStream.addTrack(t);
}); 

pluginHandle.createOffer({
    media: {audio: {deviceId: devices._tracks[0]['id']}, replaceAudio: true},
    success: function(jsep) {
        pluginHandle.send({message: {audio: true, video: false}, "jsep": jsep});
    },
    error: function(error) {
        console.log(("WebRTC error... " + JSON.stringify(error));
    }
});

问题:

问题:例如:当 phone 接到电话并接听电话时。重启应用后,用户语音也不再传

在 Janus Gateway 上一切正常。我认为问题在于重新谈判。

Janus 网关日志,当我在房间说话时:

There's a message for JANUS AudioBridge plugin
Setting muted property: true (room 20, user 2301490876606211)
Notifying participant 329012611897879 (kardan)
Sending event to transport...
  >> 0 (Success)

我们找不到通用的解决方案。

目前重新启动应用程序适用于 react-native-restart