Unverified 提交 2f6bfcab authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

Fix lack of "consumerlayerschange" event when all streams in the producer die (#1122)

上级 1e3a57cb
# Changelog # Changelog
### Next
* `SimulcastConsumer`: Fix lack of "consumerlayerschange" event when all streams in the producer die ([PR #1122](https://github.com/versatica/mediasoup/pull/1122)).
### 3.12.6 ### 3.12.6
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "RTC/RtpHeaderExtensionIds.hpp" #include "RTC/RtpHeaderExtensionIds.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RtpStream.hpp" #include "RTC/RtpStream.hpp"
#include "RTC/RtpStreamRecv.hpp"
#include "RTC/RtpStreamSend.hpp" #include "RTC/RtpStreamSend.hpp"
#include "RTC/Shared.hpp" #include "RTC/Shared.hpp"
#include <absl/container/flat_hash_set.h> #include <absl/container/flat_hash_set.h>
...@@ -129,12 +130,12 @@ namespace RTC ...@@ -129,12 +130,12 @@ namespace RTC
} }
void ProducerPaused(); void ProducerPaused();
void ProducerResumed(); void ProducerResumed();
virtual void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) = 0; virtual void ProducerRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) = 0;
virtual void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) = 0; virtual void ProducerNewRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) = 0;
void ProducerRtpStreamScores(const std::vector<uint8_t>* scores); void ProducerRtpStreamScores(const std::vector<uint8_t>* scores);
virtual void ProducerRtpStreamScore( virtual void ProducerRtpStreamScore(
RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) = 0; RTC::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore) = 0;
virtual void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) = 0; virtual void ProducerRtcpSenderReport(RTC::RtpStreamRecv* rtpStream, bool first) = 0;
void ProducerClosed(); void ProducerClosed();
void SetExternallyManagedBitrate() void SetExternallyManagedBitrate()
{ {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#define MS_RTC_PIPE_CONSUMER_HPP #define MS_RTC_PIPE_CONSUMER_HPP
#include "RTC/Consumer.hpp" #include "RTC/Consumer.hpp"
#include "RTC/RtpStreamSend.hpp"
#include "RTC/SeqManager.hpp" #include "RTC/SeqManager.hpp"
#include "RTC/Shared.hpp" #include "RTC/Shared.hpp"
...@@ -23,10 +22,11 @@ namespace RTC ...@@ -23,10 +22,11 @@ namespace RTC
void FillJson(json& jsonObject) const override; void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) const override; void FillJsonStats(json& jsonArray) const override;
void FillJsonScore(json& jsonObject) const override; void FillJsonScore(json& jsonObject) const override;
void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerNewRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void ProducerRtpStreamScore(
void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) override; RTC::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore) override;
void ProducerRtcpSenderReport(RTC::RtpStreamRecv* rtpStream, bool first) override;
uint8_t GetBitratePriority() const override; uint8_t GetBitratePriority() const override;
uint32_t IncreaseLayer(uint32_t bitrate, bool considerLoss) override; uint32_t IncreaseLayer(uint32_t bitrate, bool considerLoss) override;
void ApplyLayers() override; void ApplyLayers() override;
......
...@@ -40,11 +40,14 @@ namespace RTC ...@@ -40,11 +40,14 @@ namespace RTC
virtual void OnProducerPaused(RTC::Producer* producer) = 0; virtual void OnProducerPaused(RTC::Producer* producer) = 0;
virtual void OnProducerResumed(RTC::Producer* producer) = 0; virtual void OnProducerResumed(RTC::Producer* producer) = 0;
virtual void OnProducerNewRtpStream( virtual void OnProducerNewRtpStream(
RTC::Producer* producer, RTC::RtpStream* rtpStream, uint32_t mappedSsrc) = 0; RTC::Producer* producer, RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) = 0;
virtual void OnProducerRtpStreamScore( virtual void OnProducerRtpStreamScore(
RTC::Producer* producer, RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) = 0; RTC::Producer* producer,
RTC::RtpStreamRecv* rtpStream,
uint8_t score,
uint8_t previousScore) = 0;
virtual void OnProducerRtcpSenderReport( virtual void OnProducerRtcpSenderReport(
RTC::Producer* producer, RTC::RtpStream* rtpStream, bool first) = 0; RTC::Producer* producer, RTC::RtpStreamRecv* rtpStream, bool first) = 0;
virtual void OnProducerRtpPacketReceived(RTC::Producer* producer, RTC::RtpPacket* packet) = 0; virtual void OnProducerRtpPacketReceived(RTC::Producer* producer, RTC::RtpPacket* packet) = 0;
virtual void OnProducerSendRtcpPacket(RTC::Producer* producer, RTC::RTCP::Packet* packet) = 0; virtual void OnProducerSendRtcpPacket(RTC::Producer* producer, RTC::RTCP::Packet* packet) = 0;
virtual void OnProducerNeedWorstRemoteFractionLost( virtual void OnProducerNeedWorstRemoteFractionLost(
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "RTC/Producer.hpp" #include "RTC/Producer.hpp"
#include "RTC/RtpObserver.hpp" #include "RTC/RtpObserver.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RtpStream.hpp" #include "RTC/RtpStreamRecv.hpp"
#include "RTC/Shared.hpp" #include "RTC/Shared.hpp"
#include "RTC/Transport.hpp" #include "RTC/Transport.hpp"
#include "RTC/WebRtcServer.hpp" #include "RTC/WebRtcServer.hpp"
...@@ -65,16 +65,19 @@ namespace RTC ...@@ -65,16 +65,19 @@ namespace RTC
void OnTransportProducerNewRtpStream( void OnTransportProducerNewRtpStream(
RTC::Transport* transport, RTC::Transport* transport,
RTC::Producer* producer, RTC::Producer* producer,
RTC::RtpStream* rtpStream, RTC::RtpStreamRecv* rtpStream,
uint32_t mappedSsrc) override; uint32_t mappedSsrc) override;
void OnTransportProducerRtpStreamScore( void OnTransportProducerRtpStreamScore(
RTC::Transport* transport, RTC::Transport* transport,
RTC::Producer* producer, RTC::Producer* producer,
RTC::RtpStream* rtpStream, RTC::RtpStreamRecv* rtpStream,
uint8_t score, uint8_t score,
uint8_t previousScore) override; uint8_t previousScore) override;
void OnTransportProducerRtcpSenderReport( void OnTransportProducerRtcpSenderReport(
RTC::Transport* transport, RTC::Producer* producer, RTC::RtpStream* rtpStream, bool first) override; RTC::Transport* transport,
RTC::Producer* producer,
RTC::RtpStreamRecv* rtpStream,
bool first) override;
void OnTransportProducerRtpPacketReceived( void OnTransportProducerRtpPacketReceived(
RTC::Transport* transport, RTC::Producer* producer, RTC::RtpPacket* packet) override; RTC::Transport* transport, RTC::Producer* producer, RTC::RtpPacket* packet) override;
void OnTransportNeedWorstRemoteFractionLost( void OnTransportNeedWorstRemoteFractionLost(
......
...@@ -76,6 +76,10 @@ namespace RTC ...@@ -76,6 +76,10 @@ namespace RTC
{ {
return this->transmissionCounter.GetLayerBitrate(nowMs, spatialLayer, temporalLayer); return this->transmissionCounter.GetLayerBitrate(nowMs, spatialLayer, temporalLayer);
} }
bool HasRtpInactivityCheckEnabled() const
{
return this->useRtpInactivityCheck;
}
private: private:
void CalculateJitter(uint32_t rtpTimestamp); void CalculateJitter(uint32_t rtpTimestamp);
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#define MS_RTC_SIMPLE_CONSUMER_HPP #define MS_RTC_SIMPLE_CONSUMER_HPP
#include "RTC/Consumer.hpp" #include "RTC/Consumer.hpp"
#include "RTC/RtpStreamSend.hpp"
#include "RTC/SeqManager.hpp" #include "RTC/SeqManager.hpp"
#include "RTC/Shared.hpp" #include "RTC/Shared.hpp"
...@@ -29,14 +28,17 @@ namespace RTC ...@@ -29,14 +28,17 @@ namespace RTC
return ( return (
RTC::Consumer::IsActive() && RTC::Consumer::IsActive() &&
this->producerRtpStream && this->producerRtpStream &&
(this->producerRtpStream->GetScore() > 0u || this->producerRtpStream->HasDtx()) // If there is no RTP inactivity check do not consider the stream
// inactive despite it has score 0.
(this->producerRtpStream->GetScore() > 0u || !this->producerRtpStream->HasRtpInactivityCheckEnabled())
); );
// clang-format on // clang-format on
} }
void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerNewRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void ProducerRtpStreamScore(
void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) override; RTC::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore) override;
void ProducerRtcpSenderReport(RTC::RtpStreamRecv* rtpStream, bool first) override;
uint8_t GetBitratePriority() const override; uint8_t GetBitratePriority() const override;
uint32_t IncreaseLayer(uint32_t bitrate, bool considerLoss) override; uint32_t IncreaseLayer(uint32_t bitrate, bool considerLoss) override;
void ApplyLayers() override; void ApplyLayers() override;
...@@ -78,7 +80,7 @@ namespace RTC ...@@ -78,7 +80,7 @@ namespace RTC
RTC::RtpStreamSend* rtpStream{ nullptr }; RTC::RtpStreamSend* rtpStream{ nullptr };
// Others. // Others.
std::vector<RTC::RtpStreamSend*> rtpStreams; std::vector<RTC::RtpStreamSend*> rtpStreams;
RTC::RtpStream* producerRtpStream{ nullptr }; RTC::RtpStreamRecv* producerRtpStream{ nullptr };
bool keyFrameSupported{ false }; bool keyFrameSupported{ false };
bool syncRequired{ false }; bool syncRequired{ false };
RTC::SeqManager<uint16_t> rtpSeqManager; RTC::SeqManager<uint16_t> rtpSeqManager;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "RTC/Codecs/PayloadDescriptorHandler.hpp" #include "RTC/Codecs/PayloadDescriptorHandler.hpp"
#include "RTC/Consumer.hpp" #include "RTC/Consumer.hpp"
#include "RTC/RtpStreamSend.hpp"
#include "RTC/SeqManager.hpp" #include "RTC/SeqManager.hpp"
#include "RTC/Shared.hpp" #include "RTC/Shared.hpp"
...@@ -41,18 +40,21 @@ namespace RTC ...@@ -41,18 +40,21 @@ namespace RTC
std::any_of( std::any_of(
this->producerRtpStreams.begin(), this->producerRtpStreams.begin(),
this->producerRtpStreams.end(), this->producerRtpStreams.end(),
[](const RTC::RtpStream* rtpStream) [](const RTC::RtpStreamRecv* rtpStream)
{ {
return (rtpStream != nullptr && (rtpStream->GetScore() > 0u || rtpStream->HasDtx())); // If there is no RTP inactivity check do not consider the stream
// inactive despite it has score 0.
return (rtpStream != nullptr && (rtpStream->GetScore() > 0u || !rtpStream->HasRtpInactivityCheckEnabled()));
} }
) )
); );
// clang-format on // clang-format on
} }
void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerNewRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void ProducerRtpStreamScore(
void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) override; RTC::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore) override;
void ProducerRtcpSenderReport(RTC::RtpStreamRecv* rtpStream, bool first) override;
uint8_t GetBitratePriority() const override; uint8_t GetBitratePriority() const override;
uint32_t IncreaseLayer(uint32_t bitrate, bool considerLoss) override; uint32_t IncreaseLayer(uint32_t bitrate, bool considerLoss) override;
void ApplyLayers() override; void ApplyLayers() override;
...@@ -90,9 +92,9 @@ namespace RTC ...@@ -90,9 +92,9 @@ namespace RTC
bool CanSwitchToSpatialLayer(int16_t spatialLayer) const; bool CanSwitchToSpatialLayer(int16_t spatialLayer) const;
void EmitScore() const; void EmitScore() const;
void EmitLayersChange() const; void EmitLayersChange() const;
RTC::RtpStream* GetProducerCurrentRtpStream() const; RTC::RtpStreamRecv* GetProducerCurrentRtpStream() const;
RTC::RtpStream* GetProducerTargetRtpStream() const; RTC::RtpStreamRecv* GetProducerTargetRtpStream() const;
RTC::RtpStream* GetProducerTsReferenceRtpStream() const; RTC::RtpStreamRecv* GetProducerTsReferenceRtpStream() const;
/* Pure virtual methods inherited from RtpStreamSend::Listener. */ /* Pure virtual methods inherited from RtpStreamSend::Listener. */
public: public:
...@@ -105,7 +107,7 @@ namespace RTC ...@@ -105,7 +107,7 @@ namespace RTC
// Others. // Others.
absl::flat_hash_map<uint32_t, int16_t> mapMappedSsrcSpatialLayer; absl::flat_hash_map<uint32_t, int16_t> mapMappedSsrcSpatialLayer;
std::vector<RTC::RtpStreamSend*> rtpStreams; std::vector<RTC::RtpStreamSend*> rtpStreams;
std::vector<RTC::RtpStream*> producerRtpStreams; // Indexed by spatial layer. std::vector<RTC::RtpStreamRecv*> producerRtpStreams; // Indexed by spatial layer.
bool syncRequired{ false }; bool syncRequired{ false };
int16_t spatialLayerToSync{ -1 }; int16_t spatialLayerToSync{ -1 };
bool lastSentPacketHasMarker{ false }; bool lastSentPacketHasMarker{ false };
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "RTC/Codecs/PayloadDescriptorHandler.hpp" #include "RTC/Codecs/PayloadDescriptorHandler.hpp"
#include "RTC/Consumer.hpp" #include "RTC/Consumer.hpp"
#include "RTC/RtpStreamSend.hpp"
#include "RTC/SeqManager.hpp" #include "RTC/SeqManager.hpp"
#include "RTC/Shared.hpp" #include "RTC/Shared.hpp"
#include <map> #include <map>
...@@ -40,14 +39,17 @@ namespace RTC ...@@ -40,14 +39,17 @@ namespace RTC
return ( return (
RTC::Consumer::IsActive() && RTC::Consumer::IsActive() &&
this->producerRtpStream && this->producerRtpStream &&
(this->producerRtpStream->GetScore() > 0u || this->producerRtpStream->HasDtx()) // If there is no RTP inactivity check do not consider the stream
// inactive despite it has score 0.
(this->producerRtpStream->GetScore() > 0u || !this->producerRtpStream->HasRtpInactivityCheckEnabled())
); );
// clang-format on // clang-format on
} }
void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerNewRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void ProducerRtpStreamScore(
void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) override; RTC::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore) override;
void ProducerRtcpSenderReport(RTC::RtpStreamRecv* rtpStream, bool first) override;
uint8_t GetBitratePriority() const override; uint8_t GetBitratePriority() const override;
uint32_t IncreaseLayer(uint32_t bitrate, bool considerLoss) override; uint32_t IncreaseLayer(uint32_t bitrate, bool considerLoss) override;
void ApplyLayers() override; void ApplyLayers() override;
...@@ -93,7 +95,7 @@ namespace RTC ...@@ -93,7 +95,7 @@ namespace RTC
RTC::RtpStreamSend* rtpStream{ nullptr }; RTC::RtpStreamSend* rtpStream{ nullptr };
// Others. // Others.
std::vector<RTC::RtpStreamSend*> rtpStreams; std::vector<RTC::RtpStreamSend*> rtpStreams;
RTC::RtpStream* producerRtpStream{ nullptr }; RTC::RtpStreamRecv* producerRtpStream{ nullptr };
bool syncRequired{ false }; bool syncRequired{ false };
RTC::SeqManager<uint16_t> rtpSeqManager; RTC::SeqManager<uint16_t> rtpSeqManager;
int16_t preferredSpatialLayer{ -1 }; int16_t preferredSpatialLayer{ -1 };
......
...@@ -69,16 +69,19 @@ namespace RTC ...@@ -69,16 +69,19 @@ namespace RTC
virtual void OnTransportProducerNewRtpStream( virtual void OnTransportProducerNewRtpStream(
RTC::Transport* transport, RTC::Transport* transport,
RTC::Producer* producer, RTC::Producer* producer,
RTC::RtpStream* rtpStream, RTC::RtpStreamRecv* rtpStream,
uint32_t mappedSsrc) = 0; uint32_t mappedSsrc) = 0;
virtual void OnTransportProducerRtpStreamScore( virtual void OnTransportProducerRtpStreamScore(
RTC::Transport* transport, RTC::Transport* transport,
RTC::Producer* producer, RTC::Producer* producer,
RTC::RtpStream* rtpStream, RTC::RtpStreamRecv* rtpStream,
uint8_t score, uint8_t score,
uint8_t previousScore) = 0; uint8_t previousScore) = 0;
virtual void OnTransportProducerRtcpSenderReport( virtual void OnTransportProducerRtcpSenderReport(
RTC::Transport* transport, RTC::Producer* producer, RTC::RtpStream* rtpStream, bool first) = 0; RTC::Transport* transport,
RTC::Producer* producer,
RTC::RtpStreamRecv* rtpStream,
bool first) = 0;
virtual void OnTransportProducerRtpPacketReceived( virtual void OnTransportProducerRtpPacketReceived(
RTC::Transport* transport, RTC::Producer* producer, RTC::RtpPacket* packet) = 0; RTC::Transport* transport, RTC::Producer* producer, RTC::RtpPacket* packet) = 0;
virtual void OnTransportNeedWorstRemoteFractionLost( virtual void OnTransportNeedWorstRemoteFractionLost(
...@@ -204,11 +207,14 @@ namespace RTC ...@@ -204,11 +207,14 @@ namespace RTC
void OnProducerPaused(RTC::Producer* producer) override; void OnProducerPaused(RTC::Producer* producer) override;
void OnProducerResumed(RTC::Producer* producer) override; void OnProducerResumed(RTC::Producer* producer) override;
void OnProducerNewRtpStream( void OnProducerNewRtpStream(
RTC::Producer* producer, RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; RTC::Producer* producer, RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
void OnProducerRtpStreamScore( void OnProducerRtpStreamScore(
RTC::Producer* producer, RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; RTC::Producer* producer,
RTC::RtpStreamRecv* rtpStream,
uint8_t score,
uint8_t previousScore) override;
void OnProducerRtcpSenderReport( void OnProducerRtcpSenderReport(
RTC::Producer* producer, RTC::RtpStream* rtpStream, bool first) override; RTC::Producer* producer, RTC::RtpStreamRecv* rtpStream, bool first) override;
void OnProducerRtpPacketReceived(RTC::Producer* producer, RTC::RtpPacket* packet) override; void OnProducerRtpPacketReceived(RTC::Producer* producer, RTC::RtpPacket* packet) override;
void OnProducerSendRtcpPacket(RTC::Producer* producer, RTC::RTCP::Packet* packet) override; void OnProducerSendRtcpPacket(RTC::Producer* producer, RTC::RTCP::Packet* packet) override;
void OnProducerNeedWorstRemoteFractionLost( void OnProducerNeedWorstRemoteFractionLost(
......
...@@ -137,14 +137,14 @@ namespace RTC ...@@ -137,14 +137,14 @@ namespace RTC
} }
} }
void PipeConsumer::ProducerRtpStream(RTC::RtpStream* /*rtpStream*/, uint32_t /*mappedSsrc*/) void PipeConsumer::ProducerRtpStream(RTC::RtpStreamRecv* /*rtpStream*/, uint32_t /*mappedSsrc*/)
{ {
MS_TRACE(); MS_TRACE();
// Do nothing. // Do nothing.
} }
void PipeConsumer::ProducerNewRtpStream(RTC::RtpStream* /*rtpStream*/, uint32_t /*mappedSsrc*/) void PipeConsumer::ProducerNewRtpStream(RTC::RtpStreamRecv* /*rtpStream*/, uint32_t /*mappedSsrc*/)
{ {
MS_TRACE(); MS_TRACE();
...@@ -152,14 +152,14 @@ namespace RTC ...@@ -152,14 +152,14 @@ namespace RTC
} }
void PipeConsumer::ProducerRtpStreamScore( void PipeConsumer::ProducerRtpStreamScore(
RTC::RtpStream* /*rtpStream*/, uint8_t /*score*/, uint8_t /*previousScore*/) RTC::RtpStreamRecv* /*rtpStream*/, uint8_t /*score*/, uint8_t /*previousScore*/)
{ {
MS_TRACE(); MS_TRACE();
// Do nothing. // Do nothing.
} }
void PipeConsumer::ProducerRtcpSenderReport(RTC::RtpStream* /*rtpStream*/, bool /*first*/) void PipeConsumer::ProducerRtcpSenderReport(RTC::RtpStreamRecv* /*rtpStream*/, bool /*first*/)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -1223,8 +1223,10 @@ namespace RTC ...@@ -1223,8 +1223,10 @@ namespace RTC
} }
} }
// Only perform RTP inactivity check on simulcast. // Only perform RTP inactivity check on simulcast and only if there are
auto useRtpInactivityCheck = this->type == RtpParameters::Type::SIMULCAST; // more than 1 stream.
auto useRtpInactivityCheck =
this->type == RtpParameters::Type::SIMULCAST && this->rtpMapping.encodings.size() > 1;
// Create a RtpStreamRecv for receiving a media stream. // Create a RtpStreamRecv for receiving a media stream.
auto* rtpStream = new RTC::RtpStreamRecv(this, params, SendNackDelay, useRtpInactivityCheck); auto* rtpStream = new RTC::RtpStreamRecv(this, params, SendNackDelay, useRtpInactivityCheck);
...@@ -1255,7 +1257,7 @@ namespace RTC ...@@ -1255,7 +1257,7 @@ namespace RTC
auto mappedSsrc = this->mapRtpStreamMappedSsrc.at(rtpStream); auto mappedSsrc = this->mapRtpStreamMappedSsrc.at(rtpStream);
// Notify the listener. // Notify the listener.
this->listener->OnProducerNewRtpStream(this, static_cast<RTC::RtpStream*>(rtpStream), mappedSsrc); this->listener->OnProducerNewRtpStream(this, rtpStream, mappedSsrc);
} }
inline void Producer::PreProcessRtpPacket(RTC::RtpPacket* packet) inline void Producer::PreProcessRtpPacket(RTC::RtpPacket* packet)
...@@ -1637,7 +1639,8 @@ namespace RTC ...@@ -1637,7 +1639,8 @@ namespace RTC
this->rtpStreamScores[rtpStream->GetEncodingIdx()] = score; this->rtpStreamScores[rtpStream->GetEncodingIdx()] = score;
// Notify the listener. // Notify the listener.
this->listener->OnProducerRtpStreamScore(this, rtpStream, score, previousScore); this->listener->OnProducerRtpStreamScore(
this, static_cast<RTC::RtpStreamRecv*>(rtpStream), score, previousScore);
// Emit the score event. // Emit the score event.
EmitScore(); EmitScore();
......
...@@ -659,7 +659,10 @@ namespace RTC ...@@ -659,7 +659,10 @@ namespace RTC
} }
inline void Router::OnTransportProducerNewRtpStream( inline void Router::OnTransportProducerNewRtpStream(
RTC::Transport* /*transport*/, RTC::Producer* producer, RTC::RtpStream* rtpStream, uint32_t mappedSsrc) RTC::Transport* /*transport*/,
RTC::Producer* producer,
RTC::RtpStreamRecv* rtpStream,
uint32_t mappedSsrc)
{ {
MS_TRACE(); MS_TRACE();
...@@ -674,7 +677,7 @@ namespace RTC ...@@ -674,7 +677,7 @@ namespace RTC
inline void Router::OnTransportProducerRtpStreamScore( inline void Router::OnTransportProducerRtpStreamScore(
RTC::Transport* /*transport*/, RTC::Transport* /*transport*/,
RTC::Producer* producer, RTC::Producer* producer,
RTC::RtpStream* rtpStream, RTC::RtpStreamRecv* rtpStream,
uint8_t score, uint8_t score,
uint8_t previousScore) uint8_t previousScore)
{ {
...@@ -689,7 +692,7 @@ namespace RTC ...@@ -689,7 +692,7 @@ namespace RTC
} }
inline void Router::OnTransportProducerRtcpSenderReport( inline void Router::OnTransportProducerRtcpSenderReport(
RTC::Transport* /*transport*/, RTC::Producer* producer, RTC::RtpStream* rtpStream, bool first) RTC::Transport* /*transport*/, RTC::Producer* producer, RTC::RtpStreamRecv* rtpStream, bool first)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -147,14 +147,14 @@ namespace RTC ...@@ -147,14 +147,14 @@ namespace RTC
} }
} }
void SimpleConsumer::ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t /*mappedSsrc*/) void SimpleConsumer::ProducerRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t /*mappedSsrc*/)
{ {
MS_TRACE(); MS_TRACE();
this->producerRtpStream = rtpStream; this->producerRtpStream = rtpStream;
} }
void SimpleConsumer::ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t /*mappedSsrc*/) void SimpleConsumer::ProducerNewRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t /*mappedSsrc*/)
{ {
MS_TRACE(); MS_TRACE();
...@@ -165,7 +165,7 @@ namespace RTC ...@@ -165,7 +165,7 @@ namespace RTC
} }
void SimpleConsumer::ProducerRtpStreamScore( void SimpleConsumer::ProducerRtpStreamScore(
RTC::RtpStream* /*rtpStream*/, uint8_t /*score*/, uint8_t /*previousScore*/) RTC::RtpStreamRecv* /*rtpStream*/, uint8_t /*score*/, uint8_t /*previousScore*/)
{ {
MS_TRACE(); MS_TRACE();
...@@ -173,7 +173,7 @@ namespace RTC ...@@ -173,7 +173,7 @@ namespace RTC
EmitScore(); EmitScore();
} }
void SimpleConsumer::ProducerRtcpSenderReport(RTC::RtpStream* /*rtpStream*/, bool /*first*/) void SimpleConsumer::ProducerRtcpSenderReport(RTC::RtpStreamRecv* /*rtpStream*/, bool /*first*/)
{ {
MS_TRACE(); MS_TRACE();
......
#define MS_CLASS "RTC::SimulcastConsumer" #define MS_CLASS "RTC::SimulcastConsumer"
// #define MS_LOG_DEV_LEVEL 3 // #define MS_LOG_DEV_LEVEL 3
...@@ -302,7 +303,7 @@ namespace RTC ...@@ -302,7 +303,7 @@ namespace RTC
} }
} }
void SimulcastConsumer::ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) void SimulcastConsumer::ProducerRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc)
{ {
MS_TRACE(); MS_TRACE();
...@@ -315,7 +316,7 @@ namespace RTC ...@@ -315,7 +316,7 @@ namespace RTC
this->producerRtpStreams[spatialLayer] = rtpStream; this->producerRtpStreams[spatialLayer] = rtpStream;
} }
void SimulcastConsumer::ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) void SimulcastConsumer::ProducerNewRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc)
{ {
MS_TRACE(); MS_TRACE();
...@@ -335,7 +336,7 @@ namespace RTC ...@@ -335,7 +336,7 @@ namespace RTC
} }
void SimulcastConsumer::ProducerRtpStreamScore( void SimulcastConsumer::ProducerRtpStreamScore(
RTC::RtpStream* /*rtpStream*/, uint8_t score, uint8_t previousScore) RTC::RtpStreamRecv* /*rtpStream*/, uint8_t score, uint8_t previousScore)
{ {
MS_TRACE(); MS_TRACE();
...@@ -344,9 +345,14 @@ namespace RTC ...@@ -344,9 +345,14 @@ namespace RTC
if (RTC::Consumer::IsActive()) if (RTC::Consumer::IsActive())
{ {
// All Producer streams are dead.
if (!IsActive())
{
UpdateTargetLayers(-1, -1);
}
// Just check target layers if the stream has died or reborned. // Just check target layers if the stream has died or reborned.
// clang-format off // clang-format off
if ( else if (
!this->externallyManagedBitrate || !this->externallyManagedBitrate ||
(score == 0u || previousScore == 0u) (score == 0u || previousScore == 0u)
) )
...@@ -357,7 +363,7 @@ namespace RTC ...@@ -357,7 +363,7 @@ namespace RTC
} }
} }
void SimulcastConsumer::ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) void SimulcastConsumer::ProducerRtcpSenderReport(RTC::RtpStreamRecv* rtpStream, bool first)
{ {
MS_TRACE(); MS_TRACE();
...@@ -1533,7 +1539,7 @@ namespace RTC ...@@ -1533,7 +1539,7 @@ namespace RTC
this->shared->channelNotifier->Emit(this->id, "layerschange", data); this->shared->channelNotifier->Emit(this->id, "layerschange", data);
} }
inline RTC::RtpStream* SimulcastConsumer::GetProducerCurrentRtpStream() const inline RTC::RtpStreamRecv* SimulcastConsumer::GetProducerCurrentRtpStream() const
{ {
MS_TRACE(); MS_TRACE();
...@@ -1544,7 +1550,7 @@ namespace RTC ...@@ -1544,7 +1550,7 @@ namespace RTC
return this->producerRtpStreams.at(this->currentSpatialLayer); return this->producerRtpStreams.at(this->currentSpatialLayer);
} }
inline RTC::RtpStream* SimulcastConsumer::GetProducerTargetRtpStream() const inline RTC::RtpStreamRecv* SimulcastConsumer::GetProducerTargetRtpStream() const
{ {
MS_TRACE(); MS_TRACE();
...@@ -1555,7 +1561,7 @@ namespace RTC ...@@ -1555,7 +1561,7 @@ namespace RTC
return this->producerRtpStreams.at(this->targetSpatialLayer); return this->producerRtpStreams.at(this->targetSpatialLayer);
} }
inline RTC::RtpStream* SimulcastConsumer::GetProducerTsReferenceRtpStream() const inline RTC::RtpStreamRecv* SimulcastConsumer::GetProducerTsReferenceRtpStream() const
{ {
MS_TRACE(); MS_TRACE();
...@@ -1567,7 +1573,7 @@ namespace RTC ...@@ -1567,7 +1573,7 @@ namespace RTC
} }
inline void SimulcastConsumer::OnRtpStreamScore( inline void SimulcastConsumer::OnRtpStreamScore(
RTC::RtpStream* /*rtpStream*/, uint8_t /*score*/, uint8_t /*previousScore*/) RTC::RtpStream* /*rtpStream*/, uint8_t score, uint8_t /*previousScore*/)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -279,14 +279,14 @@ namespace RTC ...@@ -279,14 +279,14 @@ namespace RTC
} }
} }
void SvcConsumer::ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t /*mappedSsrc*/) void SvcConsumer::ProducerRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t /*mappedSsrc*/)
{ {
MS_TRACE(); MS_TRACE();
this->producerRtpStream = rtpStream; this->producerRtpStream = rtpStream;
} }
void SvcConsumer::ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t /*mappedSsrc*/) void SvcConsumer::ProducerNewRtpStream(RTC::RtpStreamRecv* rtpStream, uint32_t /*mappedSsrc*/)
{ {
MS_TRACE(); MS_TRACE();
...@@ -300,7 +300,7 @@ namespace RTC ...@@ -300,7 +300,7 @@ namespace RTC
} }
void SvcConsumer::ProducerRtpStreamScore( void SvcConsumer::ProducerRtpStreamScore(
RTC::RtpStream* /*rtpStream*/, uint8_t score, uint8_t previousScore) RTC::RtpStreamRecv* /*rtpStream*/, uint8_t score, uint8_t previousScore)
{ {
MS_TRACE(); MS_TRACE();
...@@ -322,7 +322,7 @@ namespace RTC ...@@ -322,7 +322,7 @@ namespace RTC
} }
} }
void SvcConsumer::ProducerRtcpSenderReport(RTC::RtpStream* /*rtpStream*/, bool /*first*/) void SvcConsumer::ProducerRtcpSenderReport(RTC::RtpStreamRecv* /*rtpStream*/, bool /*first*/)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -2621,7 +2621,7 @@ namespace RTC ...@@ -2621,7 +2621,7 @@ namespace RTC
} }
inline void Transport::OnProducerNewRtpStream( inline void Transport::OnProducerNewRtpStream(
RTC::Producer* producer, RTC::RtpStream* rtpStream, uint32_t mappedSsrc) RTC::Producer* producer, RTC::RtpStreamRecv* rtpStream, uint32_t mappedSsrc)
{ {
MS_TRACE(); MS_TRACE();
...@@ -2629,7 +2629,7 @@ namespace RTC ...@@ -2629,7 +2629,7 @@ namespace RTC
} }
inline void Transport::OnProducerRtpStreamScore( inline void Transport::OnProducerRtpStreamScore(
RTC::Producer* producer, RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) RTC::Producer* producer, RTC::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore)
{ {
MS_TRACE(); MS_TRACE();
...@@ -2637,7 +2637,7 @@ namespace RTC ...@@ -2637,7 +2637,7 @@ namespace RTC
} }
inline void Transport::OnProducerRtcpSenderReport( inline void Transport::OnProducerRtcpSenderReport(
RTC::Producer* producer, RTC::RtpStream* rtpStream, bool first) RTC::Producer* producer, RTC::RtpStreamRecv* rtpStream, bool first)
{ {
MS_TRACE(); MS_TRACE();
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论