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