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

Producer: allow unset encodings

上级 7a7b9bbb
...@@ -285,6 +285,10 @@ class Transport extends EnhancedEventEmitter ...@@ -285,6 +285,10 @@ class Transport extends EnhancedEventEmitter
else if (appData && typeof appData !== 'object') else if (appData && typeof appData !== 'object')
throw new TypeError('if given, appData must be an object'); throw new TypeError('if given, appData must be an object');
// If missing encodings, add one.
if (!rtpParameters.encodings || !Array.isArray(rtpParameters.encodings))
rtpParameters.encodings = [ {} ];
// Don't do this in PipeTransports since there we must keep CNAME value in // Don't do this in PipeTransports since there we must keep CNAME value in
// each Producer. // each Producer.
if (this.constructor.name !== 'PipeTransport') if (this.constructor.name !== 'PipeTransport')
......
...@@ -99,8 +99,7 @@ test('webRtcTransport.produce() succeeds', async () => ...@@ -99,8 +99,7 @@ test('webRtcTransport.produce() succeeds', async () =>
id : 12 id : 12
} }
], ],
// Single encoding without ssrc and rid on purpose. // Missing encodings on purpose.
encodings : [ { dtx: true } ],
rtcp : rtcp :
{ {
cname : 'audio-1' cname : 'audio-1'
...@@ -483,7 +482,7 @@ test('transport.produce() with no MID and with single encoding without RID or SS ...@@ -483,7 +482,7 @@ test('transport.produce() with no MID and with single encoding without RID or SS
channels : 2 channels : 2
} }
], ],
encodings : [ { dtx: true } ], encodings : [ {} ],
rtcp : rtcp :
{ {
cname : 'audio-2' cname : 'audio-2'
...@@ -539,7 +538,7 @@ test('producer.dump() succeeds', async () => ...@@ -539,7 +538,7 @@ test('producer.dump() succeeds', async () =>
expect(data.rtpParameters.encodings.length).toBe(1); expect(data.rtpParameters.encodings.length).toBe(1);
expect(data.rtpParameters.encodings).toEqual( expect(data.rtpParameters.encodings).toEqual(
[ [
{ codecPayloadType: 111, dtx: true } { codecPayloadType: 111 }
]); ]);
expect(data.type).toBe('simple'); expect(data.type).toBe('simple');
......
...@@ -656,7 +656,7 @@ namespace RTC ...@@ -656,7 +656,7 @@ namespace RTC
auto* rtpStream = it->second; auto* rtpStream = it->second;
// Ensure no RTX SSRC was previously detected. // Ensure no RTX ssrc was previously detected.
if (rtpStream->HasRtx()) if (rtpStream->HasRtx())
{ {
MS_DEBUG_2TAGS(rtp, rtx, "ignoring RTX packet with new ssrc (ssrc lookup)"); MS_DEBUG_2TAGS(rtp, rtx, "ignoring RTX packet with new ssrc (ssrc lookup)");
...@@ -667,7 +667,7 @@ namespace RTC ...@@ -667,7 +667,7 @@ namespace RTC
// Update the stream RTX data. // Update the stream RTX data.
rtpStream->SetRtx(payloadType, ssrc); rtpStream->SetRtx(payloadType, ssrc);
// Insert the new RTX SSRC into the map. // Insert the new RTX ssrc into the map.
this->mapRtxSsrcRtpStream[ssrc] = rtpStream; this->mapRtxSsrcRtpStream[ssrc] = rtpStream;
return rtpStream; return rtpStream;
...@@ -720,7 +720,7 @@ namespace RTC ...@@ -720,7 +720,7 @@ namespace RTC
if (rtpStream->GetRid() == rid) if (rtpStream->GetRid() == rid)
{ {
// Ensure no RTX SSRC was previously detected. // Ensure no RTX ssrc was previously detected.
if (rtpStream->HasRtx()) if (rtpStream->HasRtx())
{ {
MS_DEBUG_2TAGS(rtp, rtx, "ignoring RTX packet with new SSRC (RID lookup)"); MS_DEBUG_2TAGS(rtp, rtx, "ignoring RTX packet with new SSRC (RID lookup)");
...@@ -731,7 +731,7 @@ namespace RTC ...@@ -731,7 +731,7 @@ namespace RTC
// Update the stream RTX data. // Update the stream RTX data.
rtpStream->SetRtx(payloadType, ssrc); rtpStream->SetRtx(payloadType, ssrc);
// Insert the new RTX SSRC into the map. // Insert the new RTX ssrc into the map.
this->mapRtxSsrcRtpStream[ssrc] = rtpStream; this->mapRtxSsrcRtpStream[ssrc] = rtpStream;
return rtpStream; return rtpStream;
...@@ -749,13 +749,14 @@ namespace RTC ...@@ -749,13 +749,14 @@ namespace RTC
return nullptr; return nullptr;
} }
// If not found, and there is a single encoding, this may be a media or RTX // If not found, and there is a single encoding without ssrc and RID, this
// stream and the single encoding does not signal nor SSRC nor RID. // may be the media or RTX stream.
// //
// clang-format off // clang-format off
if ( if (
this->rtpParameters.encodings.size() == 1 && this->rtpParameters.encodings.size() == 1 &&
this->mapSsrcRtpStream.size() <= 1 !this->rtpParameters.encodings[0].ssrc &&
this->rtpParameters.encodings[0].rid.empty()
) )
// clang-format on // clang-format on
{ {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论