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

RtpListener: Lookup in RID table.

上级 593f861e
# TODO in mediasoup v2 (server-side) # TODO in mediasoup v2 (server-side)
* Properly set extended seq32 for nacked packets.
* Check NackGenerator intervals.
* Remove `producer.on('rtprawpacket')` and, instead, create a special `RtpConsumer` or something like that. * Remove `producer.on('rtprawpacket')` and, instead, create a special `RtpConsumer` or something like that.
* Set a proper value for Producer::FullFrameRequestBlockTimeout (currently 1 second). * Set a proper value for Producer::FullFrameRequestBlockTimeout (currently 1 second).
......
...@@ -31,18 +31,6 @@ namespace RTC ...@@ -31,18 +31,6 @@ namespace RTC
std::map<uint8_t, uint8_t> headerExtensionIds; std::map<uint8_t, uint8_t> headerExtensionIds;
}; };
public:
// TODO: YES?
// RTP header extension ids that must be shared by all the Producers using
// the same Transport.
// NOTE: These ids are the original ids in the RTP packet (before the Producer
// maps them to the corresponding ids in the room).
struct HeaderExtensionIdsForTransport
{
uint8_t absSendTime{ 0 }; // 0 means no abs-send-time id.
uint8_t rid{ 0 }; // 0 means no RID id.
};
private: private:
struct HeaderExtensionIds struct HeaderExtensionIds
{ {
...@@ -77,6 +65,7 @@ namespace RTC ...@@ -77,6 +65,7 @@ namespace RTC
void SetRtpRawEvent(bool enabled); void SetRtpRawEvent(bool enabled);
void SetRtpObjectEvent(bool enabled); void SetRtpObjectEvent(bool enabled);
const RTC::RtpParameters& GetParameters() const; const RTC::RtpParameters& GetParameters() const;
const struct RTC::Transport::HeaderExtensionIds& GetTransportHeaderExtensionIds() const;
bool IsPaused() const; bool IsPaused() const;
void ReceiveRtpPacket(RTC::RtpPacket* packet); void ReceiveRtpPacket(RTC::RtpPacket* packet);
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report); void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
...@@ -124,6 +113,7 @@ namespace RTC ...@@ -124,6 +113,7 @@ namespace RTC
Timer* fullFrameRequestBlockTimer{ nullptr }; Timer* fullFrameRequestBlockTimer{ nullptr };
// Others. // Others.
std::vector<RtpEncodingParameters> outputEncodings; std::vector<RtpEncodingParameters> outputEncodings;
struct RTC::Transport::HeaderExtensionIds transportHeaderExtensionIds;
struct HeaderExtensionIds headerExtensionIds; struct HeaderExtensionIds headerExtensionIds;
bool paused{ false }; bool paused{ false };
bool rtpRawEventEnabled{ false }; bool rtpRawEventEnabled{ false };
...@@ -151,6 +141,11 @@ namespace RTC ...@@ -151,6 +141,11 @@ namespace RTC
return this->rtpParameters; return this->rtpParameters;
} }
inline const struct RTC::Transport::HeaderExtensionIds& Producer::GetTransportHeaderExtensionIds() const
{
return this->transportHeaderExtensionIds;
}
inline bool Producer::IsPaused() const inline bool Producer::IsPaused() const
{ {
return this->paused; return this->paused;
......
...@@ -19,6 +19,7 @@ namespace RTC ...@@ -19,6 +19,7 @@ namespace RTC
Json::Value ToJson() const; Json::Value ToJson() const;
bool HasSsrc(uint32_t ssrc, const RTC::Producer* producer) const; bool HasSsrc(uint32_t ssrc, const RTC::Producer* producer) const;
bool HasMuxId(const std::string& muxId, const RTC::Producer* producer) const; bool HasMuxId(const std::string& muxId, const RTC::Producer* producer) const;
bool HasRid(const std::string& rid, const RTC::Producer* producer) const;
void AddProducer(RTC::Producer* producer); void AddProducer(RTC::Producer* producer);
void RemoveProducer(const RTC::Producer* producer); void RemoveProducer(const RTC::Producer* producer);
RTC::Producer* GetProducer(RTC::RtpPacket* packet); RTC::Producer* GetProducer(RTC::RtpPacket* packet);
...@@ -26,13 +27,18 @@ namespace RTC ...@@ -26,13 +27,18 @@ namespace RTC
private: private:
void RollbackProducer( void RollbackProducer(
RTC::Producer* producer, std::vector<uint32_t>& previousSsrcs, std::string& previousMuxId); RTC::Producer* producer,
std::vector<uint32_t>& previousSsrcs,
std::string& previousMuxId,
std::string& previousRid);
public: public:
// Table of SSRC / Producer pairs. // Table of SSRC / Producer pairs.
std::unordered_map<uint32_t, RTC::Producer*> ssrcTable; std::unordered_map<uint32_t, RTC::Producer*> ssrcTable;
// Table of MID RTP header extension / Producer pairs. // Table of MID RTP header extension / Producer pairs.
std::unordered_map<std::string, const RTC::Producer*> muxIdTable; std::unordered_map<std::string, RTC::Producer*> muxIdTable;
// Table of RID RTP header extension / Producer pairs.
std::unordered_map<std::string, RTC::Producer*> ridTable;
}; };
/* Inline instance methods. */ /* Inline instance methods. */
...@@ -56,6 +62,16 @@ namespace RTC ...@@ -56,6 +62,16 @@ namespace RTC
else else
return (it->second != producer); return (it->second != producer);
} }
inline bool RtpListener::HasRid(const std::string& rid, const RTC::Producer* producer) const
{
auto it = this->ridTable.find(rid);
if (it == this->ridTable.end())
return false;
else
return (it->second != producer);
}
} // namespace RTC } // namespace RTC
#endif #endif
...@@ -114,6 +114,7 @@ namespace RTC ...@@ -114,6 +114,7 @@ namespace RTC
uint8_t* GetExtension(RTC::RtpHeaderExtensionUri::Type uri, uint8_t* len) const; uint8_t* GetExtension(RTC::RtpHeaderExtensionUri::Type uri, uint8_t* len) const;
bool ReadAudioLevel(uint8_t* volume, bool* voice) const; bool ReadAudioLevel(uint8_t* volume, bool* voice) const;
bool ReadAbsSendTime(uint32_t* time) const; bool ReadAbsSendTime(uint32_t* time) const;
bool ReadRid(const uint8_t** data, size_t* len) const;
uint8_t* GetPayload() const; uint8_t* GetPayload() const;
size_t GetPayloadLength() const; size_t GetPayloadLength() const;
void Serialize(uint8_t* buffer); void Serialize(uint8_t* buffer);
...@@ -336,6 +337,22 @@ namespace RTC ...@@ -336,6 +337,22 @@ namespace RTC
return true; return true;
} }
inline bool RtpPacket::ReadRid(const uint8_t** data, size_t* len) const
{
uint8_t extenLen;
uint8_t* extenValue;
extenValue = GetExtension(RTC::RtpHeaderExtensionUri::Type::RTP_STREAM_ID, &extenLen);
if (!extenValue || extenLen == 0)
return false;
*data = extenValue;
*len = static_cast<size_t>(extenLen);
return true;
}
inline uint8_t* RtpPacket::GetPayload() const inline uint8_t* RtpPacket::GetPayload() const
{ {
return this->payload; return this->payload;
......
...@@ -54,6 +54,17 @@ namespace RTC ...@@ -54,6 +54,17 @@ namespace RTC
RTC::Transport* transport, RTC::Consumer* consumer, RTC::RTCP::FeedbackPsPacket* packet) = 0; RTC::Transport* transport, RTC::Consumer* consumer, RTC::RTCP::FeedbackPsPacket* packet) = 0;
}; };
public:
// RTP header extension ids that must be shared by all the Producers using
// the same Transport.
// NOTE: These ids are the original ids in the RTP packet (before the Producer
// maps them to the corresponding ids in the room).
struct HeaderExtensionIds
{
uint8_t absSendTime{ 0 }; // 0 means no abs-send-time id.
uint8_t rid{ 0 }; // 0 means no RID id.
};
public: public:
struct TransportOptions struct TransportOptions
{ {
...@@ -200,6 +211,7 @@ namespace RTC ...@@ -200,6 +211,7 @@ namespace RTC
RTC::DtlsTransport::Role dtlsLocalRole{ RTC::DtlsTransport::Role::AUTO }; RTC::DtlsTransport::Role dtlsLocalRole{ RTC::DtlsTransport::Role::AUTO };
// Others (RtpListener). // Others (RtpListener).
RtpListener rtpListener; RtpListener rtpListener;
struct HeaderExtensionIds headerExtensionIds;
// Others (REMB and bitrate stuff). // Others (REMB and bitrate stuff).
std::unique_ptr<RTC::RemoteBitrateEstimatorAbsSendTime> remoteBitrateEstimator; std::unique_ptr<RTC::RemoteBitrateEstimatorAbsSendTime> remoteBitrateEstimator;
uint32_t maxBitrate{ 0 }; uint32_t maxBitrate{ 0 };
......
...@@ -472,6 +472,7 @@ namespace RTC ...@@ -472,6 +472,7 @@ namespace RTC
absSendTimeId = exten.id; absSendTimeId = exten.id;
this->headerExtensionIds.absSendTime = absSendTimeId; this->headerExtensionIds.absSendTime = absSendTimeId;
this->transportHeaderExtensionIds.absSendTime = exten.id;
} }
if ((ridId == 0u) && exten.type == RTC::RtpHeaderExtensionUri::Type::RTP_STREAM_ID) if ((ridId == 0u) && exten.type == RTC::RtpHeaderExtensionUri::Type::RTP_STREAM_ID)
...@@ -482,6 +483,7 @@ namespace RTC ...@@ -482,6 +483,7 @@ namespace RTC
ridId = exten.id; ridId = exten.id;
this->headerExtensionIds.rid = ridId; this->headerExtensionIds.rid = ridId;
this->transportHeaderExtensionIds.rid = exten.id;
} }
} }
} }
......
...@@ -16,10 +16,12 @@ namespace RTC ...@@ -16,10 +16,12 @@ namespace RTC
static const Json::StaticString JsonStringSsrcTable{ "ssrcTable" }; static const Json::StaticString JsonStringSsrcTable{ "ssrcTable" };
static const Json::StaticString JsonStringMuxIdTable{ "muxIdTable" }; static const Json::StaticString JsonStringMuxIdTable{ "muxIdTable" };
static const Json::StaticString JsonStringRidTable{ "ridTable" };
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
Json::Value jsonSsrcTable(Json::objectValue); Json::Value jsonSsrcTable(Json::objectValue);
Json::Value jsonMuxIdTable(Json::objectValue); Json::Value jsonMuxIdTable(Json::objectValue);
Json::Value jsonRidTable(Json::objectValue);
// Add ssrcTable. // Add ssrcTable.
for (auto& kv : this->ssrcTable) for (auto& kv : this->ssrcTable)
...@@ -41,6 +43,16 @@ namespace RTC ...@@ -41,6 +43,16 @@ namespace RTC
} }
json[JsonStringMuxIdTable] = jsonMuxIdTable; json[JsonStringMuxIdTable] = jsonMuxIdTable;
// Add ridTable.
for (auto& kv : this->ridTable)
{
auto rid = kv.first;
auto producer = kv.second;
jsonRidTable[rid] = std::to_string(producer->producerId);
}
json[JsonStringRidTable] = jsonRidTable;
return json; return json;
} }
...@@ -54,6 +66,7 @@ namespace RTC ...@@ -54,6 +66,7 @@ namespace RTC
std::vector<uint32_t> previousSsrcs; std::vector<uint32_t> previousSsrcs;
std::string previousMuxId; std::string previousMuxId;
std::string previousRid;
for (auto& kv : this->ssrcTable) for (auto& kv : this->ssrcTable)
{ {
...@@ -77,6 +90,19 @@ namespace RTC ...@@ -77,6 +90,19 @@ namespace RTC
} }
} }
for (auto& kv : this->ridTable)
{
auto& rid = kv.first;
auto& existingProducer = kv.second;
if (existingProducer == producer)
{
previousRid = rid;
break;
}
}
// First remove from the listener tables all the entries pointing to // First remove from the listener tables all the entries pointing to
// the given Producer. // the given Producer.
RemoveProducer(producer); RemoveProducer(producer);
...@@ -100,7 +126,7 @@ namespace RTC ...@@ -100,7 +126,7 @@ namespace RTC
else else
{ {
RemoveProducer(producer); RemoveProducer(producer);
RollbackProducer(producer, previousSsrcs, previousMuxId); RollbackProducer(producer, previousSsrcs, previousMuxId, previousRid);
MS_THROW_ERROR("ssrc already exists in RTP listener [ssrc:%" PRIu32 "]", ssrc); MS_THROW_ERROR("ssrc already exists in RTP listener [ssrc:%" PRIu32 "]", ssrc);
} }
...@@ -119,7 +145,7 @@ namespace RTC ...@@ -119,7 +145,7 @@ namespace RTC
else else
{ {
RemoveProducer(producer); RemoveProducer(producer);
RollbackProducer(producer, previousSsrcs, previousMuxId); RollbackProducer(producer, previousSsrcs, previousMuxId, previousRid);
MS_THROW_ERROR("ssrc already exists in RTP listener [ssrc:%" PRIu32 "]", ssrc); MS_THROW_ERROR("ssrc already exists in RTP listener [ssrc:%" PRIu32 "]", ssrc);
} }
...@@ -138,7 +164,7 @@ namespace RTC ...@@ -138,7 +164,7 @@ namespace RTC
else else
{ {
RemoveProducer(producer); RemoveProducer(producer);
RollbackProducer(producer, previousSsrcs, previousMuxId); RollbackProducer(producer, previousSsrcs, previousMuxId, previousRid);
MS_THROW_ERROR("ssrc already exists in RTP listener [ssrc:%" PRIu32 "]", ssrc); MS_THROW_ERROR("ssrc already exists in RTP listener [ssrc:%" PRIu32 "]", ssrc);
} }
...@@ -159,12 +185,35 @@ namespace RTC ...@@ -159,12 +185,35 @@ namespace RTC
else else
{ {
RemoveProducer(producer); RemoveProducer(producer);
RollbackProducer(producer, previousSsrcs, previousMuxId); RollbackProducer(producer, previousSsrcs, previousMuxId, previousRid);
MS_THROW_ERROR("muxId already exists in RTP listener [muxId:'%s']", muxId.c_str()); MS_THROW_ERROR("muxId already exists in RTP listener [muxId:'%s']", muxId.c_str());
} }
} }
} }
// Add entries into ridTable.
{
for (auto& encoding : rtpParameters.encodings)
{
auto& rid = encoding.encodingId;
if (rid.empty())
continue;
if (!this->HasRid(rid, producer))
{
this->ridTable[rid] = producer;
}
else
{
RemoveProducer(producer);
RollbackProducer(producer, previousSsrcs, previousMuxId, previousRid);
MS_THROW_ERROR("rid already exists in RTP listener [rid:'%s']", rid.c_str());
}
}
}
} }
void RtpListener::RemoveProducer(const RTC::Producer* producer) void RtpListener::RemoveProducer(const RTC::Producer* producer)
...@@ -189,6 +238,14 @@ namespace RTC ...@@ -189,6 +238,14 @@ namespace RTC
else else
++it; ++it;
} }
for (auto it = this->ridTable.begin(); it != this->ridTable.end();)
{
if (it->second == producer)
it = this->ridTable.erase(it);
else
++it;
}
} }
RTC::Producer* RtpListener::GetProducer(RTC::RtpPacket* packet) RTC::Producer* RtpListener::GetProducer(RTC::RtpPacket* packet)
...@@ -198,32 +255,39 @@ namespace RTC ...@@ -198,32 +255,39 @@ namespace RTC
// First lookup into the SSRC table. // First lookup into the SSRC table.
{ {
auto it = this->ssrcTable.find(packet->GetSsrc()); auto it = this->ssrcTable.find(packet->GetSsrc());
if (it != this->ssrcTable.end()) if (it != this->ssrcTable.end())
{ {
auto producer = it->second; auto producer = it->second;
auto& rtpParameters = producer->GetParameters();
// Ensure the RTP PT is present in RtpParameters.
for (auto& codec : rtpParameters.codecs)
{
// Check payloads.
if (codec.payloadType == packet->GetPayloadType())
return producer; return producer;
} }
}
// RTP PT not present. // Otherwise lookup into the muxId table.
MS_WARN_TAG(rtp, "unknown RTP payloadType [payloadType:%" PRIu8 "]", packet->GetPayloadType()); // TODO: Do it.
// TODO: We may emit "unhandledrtp" event. // Otherwise lookup into the RID table.
return nullptr; {
} const uint8_t* ridPtr;
} size_t ridLen;
// TODO: RID table? Sure. if (packet->ReadRid(&ridPtr, &ridLen))
{
auto* charRidPtr = const_cast<char*>(reinterpret_cast<const char*>(ridPtr));
std::string rid(charRidPtr, ridLen);
// Otherwise lookup into the muxId table. auto it = this->ridTable.find(rid);
// TODO: do it. if (it != this->ridTable.end())
{
auto producer = it->second;
// Fill the ssrc table.
this->ssrcTable[packet->GetSsrc()] = producer;
return producer;
}
}
}
// TODO: We may emit "unhandledrtp" event. // TODO: We may emit "unhandledrtp" event.
return nullptr; return nullptr;
...@@ -243,7 +307,10 @@ namespace RTC ...@@ -243,7 +307,10 @@ namespace RTC
} }
void RtpListener::RollbackProducer( void RtpListener::RollbackProducer(
RTC::Producer* producer, std::vector<uint32_t>& previousSsrcs, std::string& previousMuxId) RTC::Producer* producer,
std::vector<uint32_t>& previousSsrcs,
std::string& previousMuxId,
std::string& previousRid)
{ {
MS_TRACE(); MS_TRACE();
...@@ -254,5 +321,8 @@ namespace RTC ...@@ -254,5 +321,8 @@ namespace RTC
if (!previousMuxId.empty()) if (!previousMuxId.empty())
this->muxIdTable[previousMuxId] = producer; this->muxIdTable[previousMuxId] = producer;
if (!previousRid.empty())
this->ridTable[previousRid] = producer;
} }
} // namespace RTC } // namespace RTC
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "RTC/Consumer.hpp" #include "RTC/Consumer.hpp"
#include "RTC/Producer.hpp" #include "RTC/Producer.hpp"
#include "RTC/RTCP/FeedbackPsRemb.hpp" #include "RTC/RTCP/FeedbackPsRemb.hpp"
#include "RTC/RtpDictionaries.hpp"
#include <cmath> // std::pow() #include <cmath> // std::pow()
#include <iterator> // std::ostream_iterator #include <iterator> // std::ostream_iterator
#include <sstream> // std::ostringstream #include <sstream> // std::ostringstream
...@@ -19,9 +20,9 @@ ...@@ -19,9 +20,9 @@
static constexpr uint16_t IceCandidateDefaultLocalPriority{ 20000 }; static constexpr uint16_t IceCandidateDefaultLocalPriority{ 20000 };
static constexpr uint16_t IceCandidateLocalPriorityPreferFamilyIncrement{ 10000 }; static constexpr uint16_t IceCandidateLocalPriorityPreferFamilyIncrement{ 10000 };
static constexpr uint16_t IceCandidateLocalPriorityPreferProtocolIncrement{ 5000 }; static constexpr uint16_t IceCandidateLocalPriorityPreferProtocolIncrement{ 5000 };
// We just provide "host" candidates so `type preference` is fixed. // We just provide "host" candidates so type preference is fixed.
static constexpr uint16_t IceTypePreference{ 64 }; static constexpr uint16_t IceTypePreference{ 64 };
// We do not support non rtcp-mux so `component` is always 1. // We do not support non rtcp-mux so component is always 1.
static constexpr uint16_t IceComponent{ 1 }; static constexpr uint16_t IceComponent{ 1 };
/* Static helpers. */ /* Static helpers. */
...@@ -283,36 +284,40 @@ namespace RTC ...@@ -283,36 +284,40 @@ namespace RTC
static const Json::StaticString JsonStringConnecting{ "connecting" }; static const Json::StaticString JsonStringConnecting{ "connecting" };
static const Json::StaticString JsonStringClosed{ "closed" }; static const Json::StaticString JsonStringClosed{ "closed" };
static const Json::StaticString JsonStringFailed{ "failed" }; static const Json::StaticString JsonStringFailed{ "failed" };
static const Json::StaticString JsonStringHeaderExtensionIds{ "headerExtensionIds" };
static const Json::StaticString JsonStringAbsSendTime{ "absSendTime" };
static const Json::StaticString JsonStringRid{ "rid" };
static const Json::StaticString JsonStringUseRemb{ "useRemb" }; static const Json::StaticString JsonStringUseRemb{ "useRemb" };
static const Json::StaticString JsonStringMaxBitrate{ "maxBitrate" }; static const Json::StaticString JsonStringMaxBitrate{ "maxBitrate" };
static const Json::StaticString JsonStringEffectiveMaxBitrate{ "effectiveMaxBitrate" }; static const Json::StaticString JsonStringEffectiveMaxBitrate{ "effectiveMaxBitrate" };
static const Json::StaticString JsonStringRtpListener{ "rtpListener" }; static const Json::StaticString JsonStringRtpListener{ "rtpListener" };
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
Json::Value jsonHeaderExtensionIds(Json::objectValue);
json[JsonStringTransportId] = Json::UInt{ this->transportId }; json[JsonStringTransportId] = Json::UInt{ this->transportId };
// Add `iceRole` (we are always "controlled"). // Add iceRole (we are always "controlled").
json[JsonStringIceRole] = JsonStringControlled; json[JsonStringIceRole] = JsonStringControlled;
// Add `iceLocalParameters`. // Add iceLocalParameters.
json[JsonStringIceLocalParameters][JsonStringUsernameFragment] = json[JsonStringIceLocalParameters][JsonStringUsernameFragment] =
this->iceServer->GetUsernameFragment(); this->iceServer->GetUsernameFragment();
json[JsonStringIceLocalParameters][JsonStringPassword] = this->iceServer->GetPassword(); json[JsonStringIceLocalParameters][JsonStringPassword] = this->iceServer->GetPassword();
json[JsonStringIceLocalParameters][JsonStringIceLite] = true; json[JsonStringIceLocalParameters][JsonStringIceLite] = true;
// Add `iceLocalCandidates`. // Add iceLocalCandidates.
json[JsonStringIceLocalCandidates] = Json::arrayValue; json[JsonStringIceLocalCandidates] = Json::arrayValue;
for (const auto& iceCandidate : this->iceLocalCandidates) for (const auto& iceCandidate : this->iceLocalCandidates)
{ {
json[JsonStringIceLocalCandidates].append(iceCandidate.ToJson()); json[JsonStringIceLocalCandidates].append(iceCandidate.ToJson());
} }
// Add `iceSelectedTuple`. // Add iceSelectedTuple.
if (this->selectedTuple != nullptr) if (this->selectedTuple != nullptr)
json[JsonStringIceSelectedTuple] = this->selectedTuple->ToJson(); json[JsonStringIceSelectedTuple] = this->selectedTuple->ToJson();
// Add `iceState`. // Add iceState.
switch (this->iceServer->GetState()) switch (this->iceServer->GetState())
{ {
case RTC::IceServer::IceState::NEW: case RTC::IceServer::IceState::NEW:
...@@ -329,11 +334,11 @@ namespace RTC ...@@ -329,11 +334,11 @@ namespace RTC
break; break;
} }
// Add `dtlsLocalParameters.fingerprints`. // Add dtlsLocalParameters.fingerprints.
json[JsonStringDtlsLocalParameters][JsonStringFingerprints] = json[JsonStringDtlsLocalParameters][JsonStringFingerprints] =
RTC::DtlsTransport::GetLocalFingerprints(); RTC::DtlsTransport::GetLocalFingerprints();
// Add `dtlsLocalParameters.role`. // Add dtlsLocalParameters.role.
switch (this->dtlsLocalRole) switch (this->dtlsLocalRole)
{ {
case RTC::DtlsTransport::Role::AUTO: case RTC::DtlsTransport::Role::AUTO:
...@@ -349,7 +354,7 @@ namespace RTC ...@@ -349,7 +354,7 @@ namespace RTC
MS_ABORT("invalid local DTLS role"); MS_ABORT("invalid local DTLS role");
} }
// Add `dtlsState`. // Add dtlsState.
switch (this->dtlsTransport->GetState()) switch (this->dtlsTransport->GetState())
{ {
case DtlsTransport::DtlsState::NEW: case DtlsTransport::DtlsState::NEW:
...@@ -369,16 +374,26 @@ namespace RTC ...@@ -369,16 +374,26 @@ namespace RTC
break; break;
} }
// Add `useRemb`. // Add headerExtensionIds.
if (this->headerExtensionIds.absSendTime != 0u)
jsonHeaderExtensionIds[JsonStringAbsSendTime] = this->headerExtensionIds.absSendTime;
if (this->headerExtensionIds.rid != 0u)
jsonHeaderExtensionIds[JsonStringRid] = this->headerExtensionIds.rid;
json[JsonStringHeaderExtensionIds] = jsonHeaderExtensionIds;
// Add useRemb.
json[JsonStringUseRemb] = (static_cast<bool>(this->remoteBitrateEstimator)); json[JsonStringUseRemb] = (static_cast<bool>(this->remoteBitrateEstimator));
// Add `maxBitrate`. // Add maxBitrate.
json[JsonStringMaxBitrate] = Json::UInt{ this->maxBitrate }; json[JsonStringMaxBitrate] = Json::UInt{ this->maxBitrate };
// Add `effectiveMaxBitrate`. // Add effectiveMaxBitrate.
json[JsonStringEffectiveMaxBitrate] = Json::UInt{ this->effectiveMaxBitrate }; json[JsonStringEffectiveMaxBitrate] = Json::UInt{ this->effectiveMaxBitrate };
// Add `rtpListener`. // Add rtpListener.
json[JsonStringRtpListener] = this->rtpListener.ToJson(); json[JsonStringRtpListener] = this->rtpListener.ToJson();
return json; return json;
...@@ -421,6 +436,19 @@ namespace RTC ...@@ -421,6 +436,19 @@ namespace RTC
// Add us as listener. // Add us as listener.
producer->AddListener(this); producer->AddListener(this);
// Take the transport related RTP header extension ids of the Producer
// and add them to the Transport.
if (producer->GetTransportHeaderExtensionIds().absSendTime != 0u)
{
this->headerExtensionIds.absSendTime = producer->GetTransportHeaderExtensionIds().absSendTime;
}
if (producer->GetTransportHeaderExtensionIds().rid != 0u)
{
this->headerExtensionIds.rid = producer->GetTransportHeaderExtensionIds().rid;
}
} }
void Transport::HandleConsumer(RTC::Consumer* consumer) void Transport::HandleConsumer(RTC::Consumer* consumer)
...@@ -1099,6 +1127,26 @@ namespace RTC ...@@ -1099,6 +1127,26 @@ namespace RTC
return; return;
} }
// Apply the Transport RTP header extension ids so the RTP listener can use them.
if (this->headerExtensionIds.rid != 0u)
{
packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::RTP_STREAM_ID, this->headerExtensionIds.rid);
}
// TODO: test getting RID.
// const uint8_t* rid;
// size_t ridLen;
// if (packet->ReadRid(&rid, &ridLen))
// {
// std::string ridStr((const char*)rid, ridLen);
// MS_ERROR("---------- HABEMUS RID !!!: %s", ridStr.c_str());
// }
// Get the associated Producer. // Get the associated Producer.
RTC::Producer* producer = this->rtpListener.GetProducer(packet); RTC::Producer* producer = this->rtpListener.GetProducer(packet);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论