提交 b98404ef authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Don't generate SDP m= line without codecs (fixes #67)

上级 09359951
......@@ -318,7 +318,6 @@ class RTCPeerConnectionPlanB extends RTCPeerConnectionCommon
objMedia.setup = transport.dtlsLocalParameters.role === 'client' ? 'active' : 'passive';
// a=direction attribute.
// TODO: Always?
objMedia.direction = 'sendrecv';
objMedia.rtp = [];
......@@ -386,71 +385,81 @@ class RTCPeerConnectionPlanB extends RTCPeerConnectionCommon
}
}
// Codec payloads.
objMedia.payloads = payloads.join(' ');
// SSRCs.
objMedia.ssrcs = [];
for (let rtpSender of self._peer.rtpSenders)
// If there are no codecs, set this m section as unavailable.
if (payloads.length === 0)
{
// Just the same kind.
if (rtpSender.kind !== kind)
continue;
objMedia.payloads = '7'; // I don't care.
objMedia.port = 0;
objMedia.direction = 'inactive';
}
else
{
// Codec payloads.
objMedia.payloads = payloads.join(' ');
// Just if active.
if (!rtpSender.active)
continue;
// SSRCs.
objMedia.ssrcs = [];
for (let encoding of rtpSender.rtpParameters.encodings)
for (let rtpSender of self._peer.rtpSenders)
{
objMedia.ssrcs.push(
{
id : encoding.ssrc,
attribute : 'cname',
value : rtpSender.rtpParameters.rtcp.cname
});
// Just the same kind.
if (rtpSender.kind !== kind)
continue;
objMedia.ssrcs.push(
{
id : encoding.ssrc,
attribute : 'msid',
value : rtpSender.rtpParameters.userParameters.msid
});
// Just if active.
if (!rtpSender.active)
continue;
for (let encoding of rtpSender.rtpParameters.encodings)
{
objMedia.ssrcs.push(
{
id : encoding.ssrc,
attribute : 'cname',
value : rtpSender.rtpParameters.rtcp.cname
});
objMedia.ssrcs.push(
{
id : encoding.ssrc,
attribute : 'msid',
value : rtpSender.rtpParameters.userParameters.msid
});
}
}
}
// RTP header extensions.
objMedia.ext = [];
// RTP header extensions.
objMedia.ext = [];
for (let headerExtension of capabilities.headerExtensions)
{
if (headerExtension.kind && headerExtension.kind !== kind)
continue;
for (let headerExtension of capabilities.headerExtensions)
{
if (headerExtension.kind && headerExtension.kind !== kind)
continue;
objMedia.ext.push(
{
value : headerExtension.preferredId,
uri : headerExtension.uri
});
}
objMedia.ext.push(
{
value : headerExtension.preferredId,
uri : headerExtension.uri
});
}
// a=rtcp-mux attribute.
objMedia.rtcpMux = 'rtcp-mux';
// a=rtcp-mux attribute.
objMedia.rtcpMux = 'rtcp-mux';
// a=rtcp-rsize
objMedia.rtcpRsize = 'rtcp-rsize';
// a=rtcp-rsize
objMedia.rtcpRsize = 'rtcp-rsize';
// a=x-google-flag:conference.
objMedia.xGoogleFlag = 'conference';
// a=x-google-flag:conference.
objMedia.xGoogleFlag = 'conference';
// Bandwidth.
if (self._options.bandwidth && self._options.bandwidth[kind])
{
objMedia.bandwidth =
[
{ type: 'AS', limit : self._options.bandwidth[kind] }
];
// Bandwidth.
if (self._options.bandwidth && self._options.bandwidth[kind])
{
objMedia.bandwidth =
[
{ type: 'AS', limit : self._options.bandwidth[kind] }
];
}
}
// Add the media section.
......
......@@ -257,8 +257,20 @@ class RTCRtpTransceiver
}
}
// Codec payloads.
objMedia.payloads = payloads.join(' ');
// If there are no codecs, set this m section as unavailable.
if (payloads.length === 0)
{
closed = true;
objMedia.payloads = '7'; // I don't care.
objMedia.port = 0;
objMedia.direction = 'inactive';
}
else
{
// Codec payloads.
objMedia.payloads = payloads.join(' ');
}
// SSCR and CNAME if sender.
if (this._sender && !this._sender.closed)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论