我试图将我的音频呼叫强制为单声道,我愿意使用 PCMU、G.729、OPUS 和 SpeeX 作为我的编解码器来处理这个呼叫。
现在我正在使用以下代码在我的 sdp 消息中搜索所选的编解码器:
function maybePreferCodec(sdp, type, dir, codec) {
var str = type + ' ' + dir + ' codec';
if (codec === '') {
return sdp;
}
var sdpLines = sdp.split('\r\n');
// Search for m line.
var mLineIndex = findLine(sdpLines, 'm=', type);
if (mLineIndex === null) {
return sdp;
}
// If the codec is available, set it as the default in m line.
var codecIndex = findLine(sdpLines, 'a=rtpmap', codec);
console.log('codecIndex', codecIndex);
if …Run Code Online (Sandbox Code Playgroud)