Unverified 提交 e2705c1b authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

Fix issue 435 (#438)

When creating a PipeConsumer always set random SSRCs instead of copying the consumable SSRCs of the corresponding Producer.
上级 e5722654
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
### 3.6.14 (WIP) ### 3.6.14 (WIP)
* `TransportCongestionControlClient.cpp`: Enable periodic ALR probing to recover faster from network issues. * `TransportCongestionControlClient.cpp`: Enable periodic ALR probing to recover faster from network issues.
* Fix issue #435 (thanks to @penguinol for reporting).
* Update NPM deps. * Update NPM deps.
* Update `nlohmann::json` C++ dep to 3.9.0. * Update `nlohmann::json` C++ dep to 3.9.0.
* Update `Catch` to 2.13.0. * Update `Catch` to 2.13.0.
......
{"version":3,"file":"ortc.d.ts","sourceRoot":"","sources":["../src/ortc.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,eAAe,EAEf,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,4BAA4B,EAC5B,cAAc,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,MAAM,kBAAkB,CAAC;AAE1B,aAAK,UAAU,GACf;IACC,MAAM,EACN;QACC,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;IAEJ,SAAS,EACT;QACC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,UAAU,EAAE,MAAM,CAAC;KACnB,EAAE,CAAC;CACJ,CAAA;AASD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CA0BnE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,kBAAkB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,CAuBT;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACvC,gBAAgB,EAAE,aAAa,EAC/B,IAAI,EAAE,eAAe,GACnB,aAAa,CAyIf;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,gBAAgB,EAAE,aAAa,EAC/B,SAAS,UAAQ,GACf,aAAa,CAwDf"}
\ No newline at end of file \ No newline at end of file
...@@ -764,8 +764,14 @@ function getPipeConsumerRtpParameters(consumableParams, enableRtx = false) { ...@@ -764,8 +764,14 @@ function getPipeConsumerRtpParameters(consumableParams, enableRtx = false) {
ext.uri !== 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time' && ext.uri !== 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time' &&
ext.uri !== 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01')); ext.uri !== 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01'));
const consumableEncodings = utils.clone(consumableParams.encodings); const consumableEncodings = utils.clone(consumableParams.encodings);
for (const encoding of consumableEncodings) { const baseSsrc = utils.generateRandomNumber();
if (!enableRtx) const baseRtxSsrc = utils.generateRandomNumber();
for (let i = 0; i < consumableEncodings.length; ++i) {
const encoding = consumableEncodings[i];
encoding.ssrc = baseSsrc + i;
if (enableRtx)
encoding.rtx = { ssrc: baseRtxSsrc + i };
else
delete encoding.rtx; delete encoding.rtx;
consumerParams.encodings.push(encoding); consumerParams.encodings.push(encoding);
} }
......
...@@ -1126,10 +1126,18 @@ export function getPipeConsumerRtpParameters( ...@@ -1126,10 +1126,18 @@ export function getPipeConsumerRtpParameters(
const consumableEncodings = const consumableEncodings =
utils.clone(consumableParams.encodings) as RtpEncodingParameters[]; utils.clone(consumableParams.encodings) as RtpEncodingParameters[];
const baseSsrc = utils.generateRandomNumber();
const baseRtxSsrc = utils.generateRandomNumber();
for (const encoding of consumableEncodings) for (let i = 0; i < consumableEncodings.length; ++i)
{ {
if (!enableRtx) const encoding = consumableEncodings[i];
encoding.ssrc = baseSsrc + i;
if (enableRtx)
encoding.rtx = { ssrc: baseRtxSsrc + i };
else
delete encoding.rtx; delete encoding.rtx;
consumerParams.encodings!.push(encoding); consumerParams.encodings!.push(encoding);
......
...@@ -276,10 +276,6 @@ test('router.pipeToRouter() succeeds with audio', async () => ...@@ -276,10 +276,6 @@ test('router.pipeToRouter() succeeds with audio', async () =>
parameters : {} parameters : {}
} }
]); ]);
expect(pipeConsumer.rtpParameters.encodings).toEqual(
[
audioProducer.consumableRtpParameters.encodings[0]
]);
expect(pipeConsumer.type).toBe('pipe'); expect(pipeConsumer.type).toBe('pipe');
expect(pipeConsumer.paused).toBe(false); expect(pipeConsumer.paused).toBe(false);
expect(pipeConsumer.producerPaused).toBe(false); expect(pipeConsumer.producerPaused).toBe(false);
...@@ -316,10 +312,6 @@ test('router.pipeToRouter() succeeds with audio', async () => ...@@ -316,10 +312,6 @@ test('router.pipeToRouter() succeeds with audio', async () =>
parameters : {} parameters : {}
} }
]); ]);
expect(pipeProducer.rtpParameters.encodings).toEqual(
[
audioProducer.consumableRtpParameters.encodings[0]
]);
expect(pipeProducer.paused).toBe(false); expect(pipeProducer.paused).toBe(false);
}, 2000); }, 2000);
...@@ -390,12 +382,6 @@ test('router.pipeToRouter() succeeds with video', async () => ...@@ -390,12 +382,6 @@ test('router.pipeToRouter() succeeds with video', async () =>
parameters : {} parameters : {}
} }
]); ]);
expect(pipeConsumer.rtpParameters.encodings).toEqual(
[
videoProducer.consumableRtpParameters.encodings[0],
videoProducer.consumableRtpParameters.encodings[1],
videoProducer.consumableRtpParameters.encodings[2]
]);
expect(pipeConsumer.type).toBe('pipe'); expect(pipeConsumer.type).toBe('pipe');
expect(pipeConsumer.paused).toBe(false); expect(pipeConsumer.paused).toBe(false);
...@@ -546,12 +532,6 @@ test('router.createPipeTransport() with enableRtx succeeds', async () => ...@@ -546,12 +532,6 @@ test('router.createPipeTransport() with enableRtx succeeds', async () =>
parameters : {} parameters : {}
} }
]); ]);
expect(pipeConsumer.rtpParameters.encodings).toEqual(
[
videoProducer.consumableRtpParameters.encodings[0],
videoProducer.consumableRtpParameters.encodings[1],
videoProducer.consumableRtpParameters.encodings[2]
]);
expect(pipeConsumer.type).toBe('pipe'); expect(pipeConsumer.type).toBe('pipe');
expect(pipeConsumer.paused).toBe(false); expect(pipeConsumer.paused).toBe(false);
......
...@@ -60,7 +60,8 @@ namespace RTC ...@@ -60,7 +60,8 @@ namespace RTC
// Allocated by this. // Allocated by this.
std::vector<RTC::RtpStreamSend*> rtpStreams; std::vector<RTC::RtpStreamSend*> rtpStreams;
// Others. // Others.
std::unordered_map<uint32_t, RTC::RtpStreamSend*> mapMappedSsrcRtpStream; std::unordered_map<uint32_t, uint32_t> mapMappedSsrcSsrc;
std::unordered_map<uint32_t, RTC::RtpStreamSend*> mapSsrcRtpStream;
bool keyFrameSupported{ false }; bool keyFrameSupported{ false };
std::unordered_map<RTC::RtpStreamSend*, bool> mapRtpStreamSyncRequired; std::unordered_map<RTC::RtpStreamSend*, bool> mapRtpStreamSyncRequired;
std::unordered_map<RTC::RtpStreamSend*, RTC::SeqManager<uint16_t>> mapRtpStreamRtpSeqManager; std::unordered_map<RTC::RtpStreamSend*, RTC::SeqManager<uint16_t>> mapRtpStreamRtpSeqManager;
......
...@@ -39,7 +39,8 @@ namespace RTC ...@@ -39,7 +39,8 @@ namespace RTC
delete rtpStream; delete rtpStream;
} }
this->rtpStreams.clear(); this->rtpStreams.clear();
this->mapMappedSsrcRtpStream.clear(); this->mapMappedSsrcSsrc.clear();
this->mapSsrcRtpStream.clear();
} }
void PipeConsumer::FillJson(json& jsonObject) const void PipeConsumer::FillJson(json& jsonObject) const
...@@ -201,7 +202,8 @@ namespace RTC ...@@ -201,7 +202,8 @@ namespace RTC
return; return;
} }
auto* rtpStream = this->mapMappedSsrcRtpStream.at(packet->GetSsrc()); auto ssrc = this->mapMappedSsrcSsrc.at(packet->GetSsrc());
auto* rtpStream = this->mapSsrcRtpStream.at(ssrc);
auto& syncRequired = this->mapRtpStreamSyncRequired.at(rtpStream); auto& syncRequired = this->mapRtpStreamSyncRequired.at(rtpStream);
auto& rtpSeqManager = this->mapRtpStreamRtpSeqManager.at(rtpStream); auto& rtpSeqManager = this->mapRtpStreamRtpSeqManager.at(rtpStream);
...@@ -230,10 +232,11 @@ namespace RTC ...@@ -230,10 +232,11 @@ namespace RTC
rtpSeqManager.Input(packet->GetSequenceNumber(), seq); rtpSeqManager.Input(packet->GetSequenceNumber(), seq);
// Save original packet fields. // Save original packet fields.
auto origSeq = packet->GetSequenceNumber(); auto origSsrc = packet->GetSsrc();
auto origSeq = packet->GetSequenceNumber();
// Rewrite packet. // Rewrite packet.
// NOTE: Do not override the ssrc because we want to honor the consumable ssrcs. packet->SetSsrc(ssrc);
packet->SetSequenceNumber(seq); packet->SetSequenceNumber(seq);
if (isSyncPacket) if (isSyncPacket)
...@@ -241,10 +244,11 @@ namespace RTC ...@@ -241,10 +244,11 @@ namespace RTC
MS_DEBUG_TAG( MS_DEBUG_TAG(
rtp, rtp,
"sending sync packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32 "sending sync packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32
"] from original [seq:%" PRIu16 "]", "] from original [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(), packet->GetSsrc(),
packet->GetSequenceNumber(), packet->GetSequenceNumber(),
packet->GetTimestamp(), packet->GetTimestamp(),
origSsrc,
origSeq); origSeq);
} }
...@@ -262,14 +266,16 @@ namespace RTC ...@@ -262,14 +266,16 @@ namespace RTC
MS_WARN_TAG( MS_WARN_TAG(
rtp, rtp,
"failed to send packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32 "failed to send packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32
"] from original [seq:%" PRIu16 "]", "] from original [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(), packet->GetSsrc(),
packet->GetSequenceNumber(), packet->GetSequenceNumber(),
packet->GetTimestamp(), packet->GetTimestamp(),
origSsrc,
origSeq); origSeq);
} }
// Restore packet fields. // Restore packet fields.
packet->SetSsrc(origSsrc);
packet->SetSequenceNumber(origSeq); packet->SetSequenceNumber(origSeq);
} }
...@@ -337,7 +343,7 @@ namespace RTC ...@@ -337,7 +343,7 @@ namespace RTC
EmitTraceEventNackType(); EmitTraceEventNackType();
auto ssrc = nackPacket->GetMediaSsrc(); auto ssrc = nackPacket->GetMediaSsrc();
auto* rtpStream = this->mapMappedSsrcRtpStream.at(ssrc); auto* rtpStream = this->mapSsrcRtpStream.at(ssrc);
rtpStream->ReceiveNack(nackPacket); rtpStream->ReceiveNack(nackPacket);
} }
...@@ -365,7 +371,7 @@ namespace RTC ...@@ -365,7 +371,7 @@ namespace RTC
default:; default:;
} }
auto* rtpStream = this->mapMappedSsrcRtpStream.at(ssrc); auto* rtpStream = this->mapSsrcRtpStream.at(ssrc);
rtpStream->ReceiveKeyFrameRequest(messageType); rtpStream->ReceiveKeyFrameRequest(messageType);
...@@ -377,7 +383,7 @@ namespace RTC ...@@ -377,7 +383,7 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
auto* rtpStream = this->mapMappedSsrcRtpStream.at(report->GetSsrc()); auto* rtpStream = this->mapSsrcRtpStream.at(report->GetSsrc());
rtpStream->ReceiveRtcpReceiverReport(report); rtpStream->ReceiveRtcpReceiverReport(report);
} }
...@@ -482,8 +488,9 @@ namespace RTC ...@@ -482,8 +488,9 @@ namespace RTC
// as in the given consumableRtpEncodings. // as in the given consumableRtpEncodings.
for (size_t idx{ 0u }; idx < this->rtpParameters.encodings.size(); ++idx) for (size_t idx{ 0u }; idx < this->rtpParameters.encodings.size(); ++idx)
{ {
auto& encoding = this->rtpParameters.encodings[idx]; auto& encoding = this->rtpParameters.encodings[idx];
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding); const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
auto& consumableEncoding = this->consumableRtpEncodings[idx];
MS_DEBUG_TAG( MS_DEBUG_TAG(
rtp, "[ssrc:%" PRIu32 ", payloadType:%" PRIu8 "]", encoding.ssrc, mediaCodec->payloadType); rtp, "[ssrc:%" PRIu32 ", payloadType:%" PRIu8 "]", encoding.ssrc, mediaCodec->payloadType);
...@@ -560,8 +567,9 @@ namespace RTC ...@@ -560,8 +567,9 @@ namespace RTC
rtpStream->SetRtx(rtxCodec->payloadType, encoding.rtx.ssrc); rtpStream->SetRtx(rtxCodec->payloadType, encoding.rtx.ssrc);
this->rtpStreams.push_back(rtpStream); this->rtpStreams.push_back(rtpStream);
this->mapMappedSsrcRtpStream[encoding.ssrc] = rtpStream; this->mapMappedSsrcSsrc[consumableEncoding.ssrc] = encoding.ssrc;
this->mapRtpStreamSyncRequired[rtpStream] = false; this->mapSsrcRtpStream[encoding.ssrc] = rtpStream;
this->mapRtpStreamSyncRequired[rtpStream] = false;
this->mapRtpStreamRtpSeqManager[rtpStream]; this->mapRtpStreamRtpSeqManager[rtpStream];
} }
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论