提交 652dff13 authored 作者: José Luis Millán's avatar José Luis Millán

Provide the consumer with the profile to which the packet belongs

上级 00a2122f
......@@ -47,7 +47,7 @@ namespace RTC
bool IsEnabled() const;
const RTC::RtpParameters& GetParameters() const;
bool IsPaused() const;
void SendRtpPacket(RTC::RtpPacket* packet);
void SendRtpPacket(RTC::RtpPacket* packet, RTC::RtpProfile profile);
void GetRtcp(RTC::RTCP::CompoundPacket* packet, uint64_t now);
void ReceiveNack(RTC::RTCP::FeedbackRtpNackPacket* nackPacket);
void ReceiveRtcpReceiverReport(RTC::RTCP::ReceiverReport* report);
......@@ -89,6 +89,8 @@ namespace RTC
uint16_t lastRecvSeqNum{ 0 };
uint32_t lastRecvRtpTimestamp{ 0 };
bool syncRequired{ true };
// RTP profiles.
RTC::RtpProfile effectiveProfile{ RTC::RtpProfile::DEFAULT };
};
/* Inline methods. */
......
......@@ -76,6 +76,7 @@ namespace RTC
void CreateRtpStream(RTC::RtpEncodingParameters& encoding);
void ClearRtpStreams();
void ApplyRtpMapping(RTC::RtpPacket* packet) const;
RTC::RtpProfile GetRtpProfile(RTC::RtpPacket* packet);
/* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */
public:
......@@ -102,6 +103,7 @@ namespace RTC
// Allocated by this.
std::map<uint32_t, RTC::RtpStreamRecv*> rtpStreams;
std::map<uint32_t, RTC::RtpStreamRecv*> mapRtxStreams;
std::map<uint32_t, RTC::RtpProfile> rtpProfiles;
Timer* fullFrameRequestBlockTimer{ nullptr };
// Others.
std::vector<RtpEncodingParameters> outputEncodings;
......
......@@ -16,7 +16,7 @@ namespace RTC
virtual void OnProducerRtpParametersUpdated(RTC::Producer* producer) = 0;
virtual void OnProducerPaused(RTC::Producer* producer) = 0;
virtual void OnProducerResumed(RTC::Producer* producer) = 0;
virtual void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet) = 0;
virtual void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet, RTC::RtpProfile profile) = 0;
};
} // namespace RTC
......
......@@ -67,7 +67,7 @@ namespace RTC
void OnProducerRtpParametersUpdated(RTC::Producer* producer) override;
void OnProducerPaused(RTC::Producer* producer) override;
void OnProducerResumed(RTC::Producer* producer) override;
void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet) override;
void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet, RTC::RtpProfile profile) override;
/* Pure virtual methods inherited from RTC::ConsumerListener. */
public:
......
......@@ -234,6 +234,7 @@ namespace RTC
bool active{ true };
std::string encodingId;
std::vector<std::string> dependencyEncodingIds;
RTC::RtpProfile profile{ RTC::RtpProfile::DEFAULT };
};
class RtpHeaderExtensionParameters
......
......@@ -153,7 +153,7 @@ namespace RTC
void OnProducerRtpParametersUpdated(RTC::Producer* producer) override;
void OnProducerPaused(RTC::Producer* producer) override;
void OnProducerResumed(RTC::Producer* producer) override;
void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet) override;
void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet, RTC::RtpProfile profile) override;
/* Pure virtual methods inherited from RTC::ConsumerListener. */
public:
......
......@@ -245,7 +245,7 @@ namespace RTC
this->retransmittedCounter.Reset();
}
void Consumer::SendRtpPacket(RTC::RtpPacket* packet)
void Consumer::SendRtpPacket(RTC::RtpPacket* packet, RTC::RtpProfile profile)
{
MS_TRACE();
......@@ -268,6 +268,11 @@ namespace RTC
return;
}
// If the packet belongs to different profile than the one being sent, drop it.
// NOTE: This is specific to simulcast with no temporal layers.
if (profile != this->effectiveProfile)
return;
// Check whether sequence number and timestamp sync is required.
if (this->syncRequired)
{
......
......@@ -303,13 +303,24 @@ namespace RTC
if (this->paused)
return;
RTC::RtpProfile profile;
try
{
profile = GetRtpProfile(packet);
}
catch(const MediaSoupError& error)
{
return;
}
// Apply the Producer codec payload type and extension header mapping before
// dispatching the packet.
ApplyRtpMapping(packet);
for (auto& listener : this->listeners)
{
listener->OnProducerRtpPacket(this, packet);
listener->OnProducerRtpPacket(this, packet, profile);
}
// Emit "rtpraw" if enabled.
......@@ -577,6 +588,31 @@ namespace RTC
}
}
RTC::RtpProfile Producer::GetRtpProfile(RTC::RtpPacket* packet)
{
auto ssrc = packet->GetSsrc();
// The SSRC is already mapped to a profile.
if (this->rtpProfiles.find(ssrc) != this->rtpProfiles.end())
{
return this->rtpProfiles[ssrc];
}
// Look for the encoding associated with the SSRC.
// NOTE: This is specific to simulcast with no temporal layers.
for (auto& encoding : this->rtpParameters.encodings)
{
if (encoding.ssrc == ssrc)
{
this->rtpProfiles[ssrc] = encoding.profile;
return encoding.profile;
}
}
MS_THROW_ERROR("unknown RTP packet received [ssrc:%" PRIu32 "]", ssrc);
}
void Producer::OnRtpStreamRecvNackRequired(
RTC::RtpStreamRecv* rtpStream, const std::vector<uint16_t>& seqNumbers)
{
......
......@@ -1329,7 +1329,7 @@ namespace RTC
}
}
void Router::OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet)
void Router::OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet, RTC::RtpProfile profile)
{
MS_TRACE();
......@@ -1344,7 +1344,7 @@ namespace RTC
for (auto* consumer : consumers)
{
if (consumer->IsEnabled())
consumer->SendRtpPacket(packet);
consumer->SendRtpPacket(packet, profile);
}
// Update audio levels.
......
......@@ -1555,7 +1555,7 @@ namespace RTC
// Do nothing.
}
void Transport::OnProducerRtpPacket(RTC::Producer* /*producer*/, RTC::RtpPacket* /*packet*/)
void Transport::OnProducerRtpPacket(RTC::Producer* /*producer*/, RTC::RtpPacket* /*packet*/, RTC::RtpProfile /*profile*/)
{
// Do nothing.
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论