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

Producer: improve header extension ids handling

上级 d8c4928f
...@@ -31,21 +31,23 @@ namespace RTC ...@@ -31,21 +31,23 @@ namespace RTC
}; };
public: public:
// TODO: YES?
// RTP header extension ids that must be shared by all the Producers using // RTP header extension ids that must be shared by all the Producers using
// the same Transport. // the same Transport.
// NOTE: These ids are the original ids in the RTP packet (before the Producer // NOTE: These ids are the original ids in the RTP packet (before the Producer
// maps them to the corresponding ids in the room). // maps them to the corresponding ids in the room).
struct HeaderExtensionsForTransport struct HeaderExtensionIdsForTransport
{ {
uint8_t absSendTimeId{ 0 }; // 0 means no abs-send-time id. uint8_t absSendTime{ 0 }; // 0 means no abs-send-time id.
uint8_t ridId{ 0 }; // 0 means no abs-send-time id. uint8_t rid{ 0 }; // 0 means no RID id.
}; };
private: private:
struct KnownHeaderExtensions struct HeaderExtensionIds
{ {
uint8_t ssrcAudioLevelId{ 0 }; // 0 means no ssrc-audio-level id. uint8_t ssrcAudioLevel{ 0 }; // 0 means no ssrc-audio-level id.
uint8_t absSendTimeId{ 0 }; // 0 means no abs-send-time id. uint8_t absSendTime{ 0 }; // 0 means no abs-send-time id.
uint8_t rid{ 0 }; // 0 means no RID id.
}; };
public: public:
...@@ -83,7 +85,7 @@ namespace RTC ...@@ -83,7 +85,7 @@ namespace RTC
void RequestFullFrame(bool force = false); void RequestFullFrame(bool force = false);
private: private:
void FillKnownHeaderExtensions(); void FillHeaderExtensionIds();
void CreateRtpStream(RTC::RtpEncodingParameters& encoding); void CreateRtpStream(RTC::RtpEncodingParameters& encoding);
void ClearRtpStreams(); void ClearRtpStreams();
void ApplyRtpMapping(RTC::RtpPacket* packet) const; void ApplyRtpMapping(RTC::RtpPacket* packet) const;
...@@ -118,7 +120,7 @@ namespace RTC ...@@ -118,7 +120,7 @@ namespace RTC
Timer* fullFrameRequestBlockTimer{ nullptr }; Timer* fullFrameRequestBlockTimer{ nullptr };
// Others. // Others.
std::vector<RtpEncodingParameters> outputEncodings; std::vector<RtpEncodingParameters> outputEncodings;
struct KnownHeaderExtensions knownHeaderExtensions; struct HeaderExtensionIds headerExtensionIds;
bool paused{ false }; bool paused{ false };
bool rtpRawEventEnabled{ false }; bool rtpRawEventEnabled{ false };
bool rtpObjectEventEnabled{ false }; bool rtpObjectEventEnabled{ false };
......
...@@ -34,7 +34,7 @@ namespace RTC ...@@ -34,7 +34,7 @@ namespace RTC
this->rtpMapping = rtpMapping; this->rtpMapping = rtpMapping;
// Fill ids of well known RTP header extensions with the mapped ids (if any). // Fill ids of well known RTP header extensions with the mapped ids (if any).
FillKnownHeaderExtensions(); FillHeaderExtensionIds();
// Set the RTCP report generation interval. // Set the RTCP report generation interval.
if (this->kind == RTC::Media::Kind::AUDIO) if (this->kind == RTC::Media::Kind::AUDIO)
...@@ -76,13 +76,16 @@ namespace RTC ...@@ -76,13 +76,16 @@ namespace RTC
static const Json::StaticString JsonStringKind{ "kind" }; static const Json::StaticString JsonStringKind{ "kind" };
static const Json::StaticString JsonStringRtpParameters{ "rtpParameters" }; static const Json::StaticString JsonStringRtpParameters{ "rtpParameters" };
static const Json::StaticString JsonStringRtpStreams{ "rtpStreams" }; static const Json::StaticString JsonStringRtpStreams{ "rtpStreams" };
static const Json::StaticString JsonStringSsrcAudioLevelId{ "ssrcAudioLevelId" }; static const Json::StaticString JsonStringHeaderExtensionIds{ "headerExtensionIds" };
static const Json::StaticString JsonStringAbsSendTimeId{ "absSendTimeId" }; static const Json::StaticString JsonStringSsrcAudioLevel{ "ssrcAudioLevel" };
static const Json::StaticString JsonStringAbsSendTime{ "absSendTime" };
static const Json::StaticString JsonStringRid{ "rid" };
static const Json::StaticString JsonStringPaused{ "paused" }; static const Json::StaticString JsonStringPaused{ "paused" };
static const Json::StaticString JsonStringRtpRawEventEnabled{ "rtpRawEventEnabled" }; static const Json::StaticString JsonStringRtpRawEventEnabled{ "rtpRawEventEnabled" };
static const Json::StaticString JsonStringRtpObjectEventEnabled{ "rtpObjectEventEnabled" }; static const Json::StaticString JsonStringRtpObjectEventEnabled{ "rtpObjectEventEnabled" };
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
Json::Value jsonHeaderExtensionIds(Json::objectValue);
Json::Value jsonRtpStreams(Json::arrayValue); Json::Value jsonRtpStreams(Json::arrayValue);
json[JsonStringProducerId] = Json::UInt{ this->producerId }; json[JsonStringProducerId] = Json::UInt{ this->producerId };
...@@ -99,11 +102,16 @@ namespace RTC ...@@ -99,11 +102,16 @@ namespace RTC
} }
json[JsonStringRtpStreams] = jsonRtpStreams; json[JsonStringRtpStreams] = jsonRtpStreams;
if (this->knownHeaderExtensions.ssrcAudioLevelId != 0u) if (this->headerExtensionIds.ssrcAudioLevel != 0u)
json[JsonStringSsrcAudioLevelId] = this->knownHeaderExtensions.ssrcAudioLevelId; jsonHeaderExtensionIds[JsonStringSsrcAudioLevel] = this->headerExtensionIds.ssrcAudioLevel;
if (this->knownHeaderExtensions.absSendTimeId != 0u) if (this->headerExtensionIds.absSendTime != 0u)
json[JsonStringAbsSendTimeId] = this->knownHeaderExtensions.absSendTimeId; jsonHeaderExtensionIds[JsonStringAbsSendTime] = this->headerExtensionIds.absSendTime;
if (this->headerExtensionIds.rid != 0u)
jsonHeaderExtensionIds[JsonStringRid] = this->headerExtensionIds.rid;
json[JsonStringHeaderExtensionIds] = jsonHeaderExtensionIds;
json[JsonStringPaused] = this->paused; json[JsonStringPaused] = this->paused;
...@@ -433,13 +441,14 @@ namespace RTC ...@@ -433,13 +441,14 @@ namespace RTC
this->isFullFrameRequested = false; this->isFullFrameRequested = false;
} }
void Producer::FillKnownHeaderExtensions() void Producer::FillHeaderExtensionIds()
{ {
MS_TRACE(); MS_TRACE();
auto& idMapping = this->rtpMapping.headerExtensionIds; auto& idMapping = this->rtpMapping.headerExtensionIds;
uint8_t ssrcAudioLevelId{ 0 }; uint8_t ssrcAudioLevelId{ 0 };
uint8_t absSendTimeId{ 0 }; uint8_t absSendTimeId{ 0 };
uint8_t ridId{ 0 };
for (auto& exten : this->rtpParameters.headerExtensions) for (auto& exten : this->rtpParameters.headerExtensions)
{ {
...@@ -452,7 +461,7 @@ namespace RTC ...@@ -452,7 +461,7 @@ namespace RTC
else else
ssrcAudioLevelId = exten.id; ssrcAudioLevelId = exten.id;
this->knownHeaderExtensions.ssrcAudioLevelId = ssrcAudioLevelId; this->headerExtensionIds.ssrcAudioLevel = ssrcAudioLevelId;
} }
if ((absSendTimeId == 0u) && exten.type == RTC::RtpHeaderExtensionUri::Type::ABS_SEND_TIME) if ((absSendTimeId == 0u) && exten.type == RTC::RtpHeaderExtensionUri::Type::ABS_SEND_TIME)
...@@ -462,7 +471,17 @@ namespace RTC ...@@ -462,7 +471,17 @@ namespace RTC
else else
absSendTimeId = exten.id; absSendTimeId = exten.id;
this->knownHeaderExtensions.absSendTimeId = absSendTimeId; this->headerExtensionIds.absSendTime = absSendTimeId;
}
if ((ridId == 0u) && exten.type == RTC::RtpHeaderExtensionUri::Type::RTP_STREAM_ID)
{
if (idMapping.find(exten.id) != idMapping.end())
ridId = idMapping[exten.id];
else
ridId = exten.id;
this->headerExtensionIds.rid = ridId;
} }
} }
} }
...@@ -573,16 +592,22 @@ namespace RTC ...@@ -573,16 +592,22 @@ namespace RTC
packet->MangleExtensionHeaderIds(headerExtensionIdMap); packet->MangleExtensionHeaderIds(headerExtensionIdMap);
if (this->knownHeaderExtensions.ssrcAudioLevelId != 0u) if (this->headerExtensionIds.ssrcAudioLevel != 0u)
{
packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL, this->headerExtensionIds.ssrcAudioLevel);
}
if (this->headerExtensionIds.absSendTime != 0u)
{ {
packet->AddExtensionMapping( packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL, this->knownHeaderExtensions.ssrcAudioLevelId); RtpHeaderExtensionUri::Type::ABS_SEND_TIME, this->headerExtensionIds.absSendTime);
} }
if (this->knownHeaderExtensions.absSendTimeId != 0u) if (this->headerExtensionIds.rid != 0u)
{ {
packet->AddExtensionMapping( packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::ABS_SEND_TIME, this->knownHeaderExtensions.absSendTimeId); RtpHeaderExtensionUri::Type::RTP_STREAM_ID, this->headerExtensionIds.rid);
} }
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论