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

worker: Apply RTP extension id mapping into the packet before passing it to the Producer.

上级 ed8e46c8
......@@ -64,6 +64,7 @@ namespace RTC
void SetRtpObjectEvent(bool enabled);
const RTC::RtpParameters& GetParameters() const;
bool IsPaused() const;
void ApplyExtensionIdMapping(RTC::RtpPacket* packet) const;
void ReceiveRtpPacket(RTC::RtpPacket* packet);
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
void GetRtcp(RTC::RTCP::CompoundPacket* packet, uint64_t now);
......@@ -75,8 +76,8 @@ namespace RTC
void FillKnownHeaderExtensions();
void CreateRtpStream(RTC::RtpEncodingParameters& encoding);
void ClearRtpStreams();
void ApplyRtpMapping(RTC::RtpPacket* packet);
void ApplySsrcMapping(RTC::RtpPacket* packet);
void ApplyPayloadTypeMapping(RTC::RtpPacket* packet) const;
void ApplySsrcMapping(RTC::RtpPacket* packet) const;
/* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */
public:
......
......@@ -107,7 +107,7 @@ namespace RTC
uint16_t GetExtensionHeaderId() const;
size_t GetExtensionHeaderLength() const;
uint8_t* GetExtensionHeaderValue() const;
void MangleExtensionHeaderIds(std::map<uint8_t, uint8_t>& idMapping);
void MangleExtensionHeaderIds(const std::map<uint8_t, uint8_t>& idMapping);
bool HasOneByteExtensions() const;
bool HasTwoBytesExtensions() const;
void AddExtensionMapping(RtpHeaderExtensionUri::Type uri, uint8_t id);
......
......@@ -293,8 +293,9 @@ namespace RTC
if (this->paused)
return;
// Apply the Producer RTP and SSRC mapping before dispatching the packet.
ApplyRtpMapping(packet);
// Apply the Producer codec payload type and SSRC mapping before dispatching
// the packet.
ApplyPayloadTypeMapping(packet);
ApplySsrcMapping(packet);
for (auto& listener : this->listeners)
......@@ -344,6 +345,27 @@ namespace RTC
this->lastRtcpSentTime = now;
}
void Producer::ApplyExtensionIdMapping(RTC::RtpPacket* packet) const
{
MS_TRACE();
auto& headerExtensionIdMap = this->rtpMapping.headerExtensionIds;
packet->MangleExtensionHeaderIds(headerExtensionIdMap);
if (this->knownHeaderExtensions.ssrcAudioLevelId != 0u)
{
packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL, this->knownHeaderExtensions.ssrcAudioLevelId);
}
if (this->knownHeaderExtensions.absSendTimeId != 0u)
{
packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::ABS_SEND_TIME, this->knownHeaderExtensions.absSendTimeId);
}
}
void Producer::ReceiveRtcpFeedback(RTC::RTCP::FeedbackPsPacket* packet) const
{
MS_TRACE();
......@@ -538,47 +560,27 @@ namespace RTC
this->rtpStreams.clear();
}
void Producer::ApplyRtpMapping(RTC::RtpPacket* packet)
void Producer::ApplyPayloadTypeMapping(RTC::RtpPacket* packet) const
{
MS_TRACE();
auto& codecPayloadTypeMap = this->rtpMapping.codecPayloadTypes;
auto& headerExtensionIdMap = this->rtpMapping.headerExtensionIds;
auto payloadType = packet->GetPayloadType();
// Mangle payload type.
auto& codecPayloadTypeMap = this->rtpMapping.codecPayloadTypes;
auto payloadType = packet->GetPayloadType();
if (codecPayloadTypeMap.find(payloadType) != codecPayloadTypeMap.end())
{
packet->SetPayloadType(codecPayloadTypeMap[payloadType]);
}
// Mangle header extension ids.
packet->MangleExtensionHeaderIds(headerExtensionIdMap);
if (this->knownHeaderExtensions.ssrcAudioLevelId != 0u)
{
packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL, this->knownHeaderExtensions.ssrcAudioLevelId);
}
if (this->knownHeaderExtensions.absSendTimeId != 0u)
{
packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::ABS_SEND_TIME, this->knownHeaderExtensions.absSendTimeId);
packet->SetPayloadType(codecPayloadTypeMap.at(payloadType));
}
}
void Producer::ApplySsrcMapping(RTC::RtpPacket* packet)
void Producer::ApplySsrcMapping(RTC::RtpPacket* packet) const
{
MS_TRACE();
auto ssrc = packet->GetSsrc();
// Mangle SSRC.
if (this->ssrcMapping.find(ssrc) != this->ssrcMapping.end())
packet->SetSsrc(this->ssrcMapping[ssrc]);
packet->SetSsrc(this->ssrcMapping.at(ssrc));
}
void Producer::OnRtpStreamRecvNackRequired(
......
......@@ -206,7 +206,7 @@ namespace RTC
MS_DUMP("</RtpPacket>");
}
void RtpPacket::MangleExtensionHeaderIds(std::map<uint8_t, uint8_t>& idMapping)
void RtpPacket::MangleExtensionHeaderIds(const std::map<uint8_t, uint8_t>& idMapping)
{
MS_TRACE();
......@@ -219,7 +219,7 @@ namespace RTC
if (idMapping.find(id) != idMapping.end())
{
oneByteExtension->id = idMapping[id];
oneByteExtension->id = idMapping.at(id);
}
}
}
......@@ -232,7 +232,7 @@ namespace RTC
if (idMapping.find(id) != idMapping.end())
{
twoBytesExtension->id = idMapping[id];
twoBytesExtension->id = idMapping.at(id);
}
}
}
......
......@@ -1112,8 +1112,9 @@ namespace RTC
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
this->iceServer->ForceSelectedTuple(tuple);
// Pass the RTP packet to the corresponding Producer.
producer->ReceiveRtpPacket(packet);
// Apply the RTP header extension mapping into the packet (we need it for the
// bitrate estimator).
producer->ApplyExtensionIdMapping(packet);
// Feed the remote bitrate estimator (REMB).
if (this->remoteBitrateEstimator)
......@@ -1127,6 +1128,9 @@ namespace RTC
}
}
// Pass the RTP packet to the corresponding Producer.
producer->ReceiveRtpPacket(packet);
delete packet;
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论