如何在peer.js中使用sdptransform?
我正在使用Peer.js开发一个为Android开发语音呼叫应用程序。它正在工作,但音频有滞后(大约1-5秒)。因此,我正在寻找修复程序,发现我可以启用dtx音频
以减少发送的数据包数量。但是我不知道如何在peer.js中访问和更改sdp
对象。这是我的代码,
let audioConstraints = {
channelCount: 1,
sampleRate: 16000,
sampleSize: 8,
volume: 1,
latency: 0.003,
echoCancellation: true,
noiseSuppression: true,
autoGainControl: true,
};
constraints = { audio: audioConstraints, video: false };
let localStream;
//listen for calls
function listen() {
peer.on("call", (call) => {
navigator.mediaDevices
.getUserMedia(constraints)
.then(function (stream) {
localVideo.srcObject = stream;
localStream = stream;
call.answer(stream);
call.on("stream", (remoteStream) => {
Android.onPeerStream();
remoteVideo.srcObject = remoteStream;
});
})
.catch(function (err) {
Android.logEvent("getUserMedia error: " + err);
});
});
}
//start call
function startCall(otherUserId) {
navigator.mediaDevices
.getUserMedia(constraints)
.then(function (stream) {
localVideo.srcObject = stream;
localStream = stream;
const call = peer.call(otherUserId, stream);
call.on("stream", (remoteStream) => {
Android.onPeerStream();
remoteVideo.srcObject = remoteStream;
});
})
.catch(function (err) {
Android.logEvent("getUserMedia error: " + err);
});
}
有人可以在peer.js中分享一个如何访问和修改SDP的工作示例?另外,如何调整audioconstraints
在保持体面的语音质量的同时达到低网络滞后?
更新 找到了在PEER.JS中访问SDP的方法,但仍然无法弄清楚如何启用DTX音频。
I am developing a voice call app for android using peer.js. It is working but there is a lag in audio (around 1-5 seconds). So I was searching for a fix and found out that I can enable DTX Audio
to reduce the number of packets sent. But I have no idea How to access and change SDP
object in peer.js. Here is my code,
let audioConstraints = {
channelCount: 1,
sampleRate: 16000,
sampleSize: 8,
volume: 1,
latency: 0.003,
echoCancellation: true,
noiseSuppression: true,
autoGainControl: true,
};
constraints = { audio: audioConstraints, video: false };
let localStream;
//listen for calls
function listen() {
peer.on("call", (call) => {
navigator.mediaDevices
.getUserMedia(constraints)
.then(function (stream) {
localVideo.srcObject = stream;
localStream = stream;
call.answer(stream);
call.on("stream", (remoteStream) => {
Android.onPeerStream();
remoteVideo.srcObject = remoteStream;
});
})
.catch(function (err) {
Android.logEvent("getUserMedia error: " + err);
});
});
}
//start call
function startCall(otherUserId) {
navigator.mediaDevices
.getUserMedia(constraints)
.then(function (stream) {
localVideo.srcObject = stream;
localStream = stream;
const call = peer.call(otherUserId, stream);
call.on("stream", (remoteStream) => {
Android.onPeerStream();
remoteVideo.srcObject = remoteStream;
});
})
.catch(function (err) {
Android.logEvent("getUserMedia error: " + err);
});
}
could someone please share a working example of how to access and modify SDP in peer.js? Also, how can I tune the audioConstraints
to achieve low network lag while keeping decent voice quality?
UPDATE
Found the way to access SDP in peer.js but still can't figure it out how to enable DTX audio.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论