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

Producer: create RtpStreamRecvs on the fly (upon receipt of RTP packet).

上级 42bae442
# TODO in mediasoup v2 (server-side) # TODO in mediasoup v2 (server-side)
* Remote `producer.on('rtprawpacket')` and, instead, create a special `RtpConsumer` or something like that. * `RtpListener`: Remove `ptTable` (period) and add `ridTable`.
* Remove `producer.on('rtprawpacket')` and, instead, create a special `RtpConsumer` or something like that.
* Must avoid passing JSON data to Transport/Producer/Consumer instance methods. Instead, create API methods that receive "nice" C++ params and do all the JSON decode work in `Router::HandleRequest()`. * Must avoid passing JSON data to Transport/Producer/Consumer instance methods. Instead, create API methods that receive "nice" C++ params and do all the JSON decode work in `Router::HandleRequest()`.
......
...@@ -31,6 +31,14 @@ namespace RTC ...@@ -31,6 +31,14 @@ namespace RTC
static std::map<Kind, Json::StaticString> kind2Json; static std::map<Kind, Json::StaticString> kind2Json;
}; };
enum class RtpProfile : uint8_t
{
DEFAULT = 0,
LOW,
MEDIUM,
HIGH
};
class RtpCodecMimeType class RtpCodecMimeType
{ {
public: public:
......
...@@ -110,8 +110,8 @@ namespace RTC ...@@ -110,8 +110,8 @@ namespace RTC
void MangleExtensionHeaderIds(const std::map<uint8_t, uint8_t>& idMapping); void MangleExtensionHeaderIds(const std::map<uint8_t, uint8_t>& idMapping);
bool HasOneByteExtensions() const; bool HasOneByteExtensions() const;
bool HasTwoBytesExtensions() const; bool HasTwoBytesExtensions() const;
void AddExtensionMapping(RtpHeaderExtensionUri::Type uri, uint8_t id); void AddExtensionMapping(RTC::RtpHeaderExtensionUri::Type uri, uint8_t id);
uint8_t* GetExtension(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;
uint8_t* GetPayload() const; uint8_t* GetPayload() const;
...@@ -131,7 +131,7 @@ namespace RTC ...@@ -131,7 +131,7 @@ namespace RTC
ExtensionHeader* extensionHeader{ nullptr }; ExtensionHeader* extensionHeader{ nullptr };
std::map<uint8_t, OneByteExtension*> oneByteExtensions; std::map<uint8_t, OneByteExtension*> oneByteExtensions;
std::map<uint8_t, TwoBytesExtension*> twoBytesExtensions; std::map<uint8_t, TwoBytesExtension*> twoBytesExtensions;
std::map<RtpHeaderExtensionUri::Type, uint8_t> extensionMap; std::map<RTC::RtpHeaderExtensionUri::Type, uint8_t> extensionMap;
uint8_t* payload{ nullptr }; uint8_t* payload{ nullptr };
size_t payloadLength{ 0 }; size_t payloadLength{ 0 };
uint8_t payloadPadding{ 0 }; uint8_t payloadPadding{ 0 };
...@@ -266,12 +266,12 @@ namespace RTC ...@@ -266,12 +266,12 @@ namespace RTC
return (GetExtensionHeaderId() & 0b1111111111110000) == 0b0001000000000000; return (GetExtensionHeaderId() & 0b1111111111110000) == 0b0001000000000000;
} }
inline void RtpPacket::AddExtensionMapping(RtpHeaderExtensionUri::Type uri, uint8_t id) inline void RtpPacket::AddExtensionMapping(RTC::RtpHeaderExtensionUri::Type uri, uint8_t id)
{ {
this->extensionMap[uri] = id; this->extensionMap[uri] = id;
} }
inline uint8_t* RtpPacket::GetExtension(RtpHeaderExtensionUri::Type uri, uint8_t* len) const inline uint8_t* RtpPacket::GetExtension(RTC::RtpHeaderExtensionUri::Type uri, uint8_t* len) const
{ {
*len = 0; *len = 0;
...@@ -309,7 +309,7 @@ namespace RTC ...@@ -309,7 +309,7 @@ namespace RTC
uint8_t extenLen; uint8_t extenLen;
uint8_t* extenValue; uint8_t* extenValue;
extenValue = GetExtension(RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL, &extenLen); extenValue = GetExtension(RTC::RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL, &extenLen);
if (!extenValue || extenLen != 1) if (!extenValue || extenLen != 1)
return false; return false;
...@@ -326,7 +326,7 @@ namespace RTC ...@@ -326,7 +326,7 @@ namespace RTC
uint8_t extenLen; uint8_t extenLen;
uint8_t* extenValue; uint8_t* extenValue;
extenValue = GetExtension(RtpHeaderExtensionUri::Type::ABS_SEND_TIME, &extenLen); extenValue = GetExtension(RTC::RtpHeaderExtensionUri::Type::ABS_SEND_TIME, &extenLen);
if (!extenValue || extenLen != 3) if (!extenValue || extenLen != 3)
return false; return false;
......
...@@ -36,12 +36,6 @@ namespace RTC ...@@ -36,12 +36,6 @@ namespace RTC
// 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(); FillKnownHeaderExtensions();
// Create RtpStreamRecv instances.
for (auto& encoding : this->rtpParameters.encodings)
{
CreateRtpStream(encoding);
}
// 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)
this->maxRtcpInterval = RTC::RTCP::MaxAudioIntervalMs; this->maxRtcpInterval = RTC::RTCP::MaxAudioIntervalMs;
...@@ -153,12 +147,6 @@ namespace RTC ...@@ -153,12 +147,6 @@ namespace RTC
// Clear previous RtpStreamRecv instances. // Clear previous RtpStreamRecv instances.
ClearRtpStreams(); ClearRtpStreams();
// Create new RtpStreamRecv instances.
for (auto& encoding : this->rtpParameters.encodings)
{
CreateRtpStream(encoding);
}
for (auto& listener : this->listeners) for (auto& listener : this->listeners)
{ {
// NOTE: This may throw. // NOTE: This may throw.
...@@ -166,8 +154,6 @@ namespace RTC ...@@ -166,8 +154,6 @@ namespace RTC
} }
MS_DEBUG_DEV("Producer RTP parameters updated [producerId:%" PRIu32 "]", this->producerId); MS_DEBUG_DEV("Producer RTP parameters updated [producerId:%" PRIu32 "]", this->producerId);
RequestFullFrame(true);
} }
void Producer::Pause() void Producer::Pause()
...@@ -266,6 +252,28 @@ namespace RTC ...@@ -266,6 +252,28 @@ namespace RTC
// Find the corresponding RtpStreamRecv. // Find the corresponding RtpStreamRecv.
uint32_t ssrc = packet->GetSsrc(); uint32_t ssrc = packet->GetSsrc();
if (
this->rtpStreams.find(ssrc) == this->rtpStreams.end() &&
this->mapRtxStreams.find(ssrc) == this->mapRtxStreams.end())
{
for (auto& encoding : this->rtpParameters.encodings)
{
// TODO: This is not ready for RID usage (without SSRC in encodings).
if (
encoding.ssrc == ssrc || (encoding.hasRtx && encoding.rtx.ssrc == ssrc) ||
(encoding.hasFec && encoding.fec.ssrc == ssrc))
{
CreateRtpStream(encoding);
// If this is the first media packet for this stream request a full frame.
if (encoding.ssrc == ssrc)
RequestFullFrame(true);
break;
}
}
}
RTC::RtpStreamRecv* rtpStream{ nullptr }; RTC::RtpStreamRecv* rtpStream{ nullptr };
if (this->rtpStreams.find(ssrc) != this->rtpStreams.end()) if (this->rtpStreams.find(ssrc) != this->rtpStreams.end())
......
...@@ -412,12 +412,13 @@ namespace RTC ...@@ -412,12 +412,13 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
// Add to the map.
this->producers.insert(producer);
// Pass it to the RtpListener. // Pass it to the RtpListener.
// NOTE: This may throw.
this->rtpListener.AddProducer(producer); this->rtpListener.AddProducer(producer);
// Add to the map.
this->producers.insert(producer);
// Add us as listener. // Add us as listener.
producer->AddListener(this); producer->AddListener(this);
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论