附:
mediasoup不会向WebRTC发送RTX重传流的SR报文的证据:
void Transport::SendRtcp(uint64_t nowMs)
{
...
for (auto& kv : this->mapConsumers)
{
auto* consumer = kv.second;
// 1.GetRtpStreams返回的是媒体流。
for (auto* rtpStream : consumer->GetRtpStreams())
{
packet.reset(new RTC::RTCP::CompoundPacket());
// 5.生成consumer的SR报文,rtpStream是媒体流。
consumer->GetRtcp(packet.get(), rtpStream, nowMs);
}
}
}
std::vector<RTC::RtpStreamSend*> GetRtpStreams() override
{
// 2.rtpStreams是媒体流。
return this->rtpStreams;
}
void SimulcastConsumer::CreateRtpStream()
{
...
auto& encoding = this->rtpParameters.encodings[0];
RTC::RtpStream::Params params;
params.ssrc = encoding.ssrc;
this->rtpStream = new RTC::RtpStreamSend(this, params, bufferSize);
// 3.rtpStreams是媒体流。
this->rtpStreams.push_back(this->rtpStream);
if (rtxCodec && encoding.hasRtx)
// 4.RTX重传流在这里。
this->rtpStream->SetRtx(rtxCodec->payloadType, encoding.rtx.ssrc);
}
void SimulcastConsumer::GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t nowMs)
{
...
// 6.生成consumer的SR报文,rtpStream是媒体流。
auto* report = this->rtpStream->GetRtcpSenderReport(nowMs);
}
RTC::RTCP::SenderReport* RtpStreamSend::GetRtcpSenderReport(uint64_t nowMs)
{
...
// GetSsrc()返回的是媒体流SSRC,将媒体流的SSRC设置进SR报文。
report->SetSsrc(GetSsrc());
}
WebRTC不会向mediasoup发送RTX重传流的RR报文的证据:
void Transport::HandleRtcpPacket(RTC::RTCP::Packet* packet)
{
...
switch (packet->GetType())
{
case RTC::RTCP::Type::RR:
{
auto* consumer = GetConsumerByMediaSsrc(report->GetSsrc());
}
}
}
inline RTC::Consumer* Transport::GetConsumerByMediaSsrc(uint32_t ssrc) const
{
...
auto mapSsrcConsumerIt = this->mapSsrcConsumer.find(ssrc);
if (mapSsrcConsumerIt == this->mapSsrcConsumer.end())
return nullptr;
auto* consumer = mapSsrcConsumerIt->second;
return consumer;
}
void Transport::HandleRequest(Channel::Request* request)
{
...
case Channel::Request::MethodId::TRANSPORT_CONSUME:
{
// 建立ssrc到consumer的映射。
for (auto ssrc : consumer->GetMediaSsrcs())
{
this->mapSsrcConsumer[ssrc] = consumer;
}
// 建立rtx ssrc到consumer的映射。
for (auto ssrc : consumer->GetRtxSsrcs())
{
this->mapRtxSsrcConsumer[ssrc] = consumer;
}
}
}