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

New RTP probation system (#304)

- Remove RtpProbator class.
- Make WebRtcTransport ask the BWE client (RembClient) whether RTP probation
  is needed.
- If so, make the simulcast/svc consumer resend current media packet via
  retransmission (RTX if supported) up to 3 times to satisfy desired probation
  bitrate.
上级 84218eba
...@@ -231,28 +231,28 @@ const supportedRtpCapabilities = ...@@ -231,28 +231,28 @@ const supportedRtpCapabilities =
}, },
{ {
kind : 'audio', kind : 'audio',
uri : 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time', // eslint-disable-line max-len uri : 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time',
preferredId : 4, preferredId : 4,
preferredEncrypt : false, preferredEncrypt : false,
direction : 'sendrecv' direction : 'sendrecv'
}, },
{ {
kind : 'video', kind : 'video',
uri : 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time', // eslint-disable-line max-len uri : 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time',
preferredId : 4, preferredId : 4,
preferredEncrypt : false, preferredEncrypt : false,
direction : 'sendrecv' direction : 'sendrecv'
}, },
{ {
kind : 'audio', kind : 'audio',
uri : 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01', // eslint-disable-line max-len uri : 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01',
preferredId : 5, preferredId : 5,
preferredEncrypt : false, preferredEncrypt : false,
direction : 'inactive' // TODO: Enable when done. direction : 'inactive' // TODO: Enable when done.
}, },
{ {
kind : 'video', kind : 'video',
uri : 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01', // eslint-disable-line max-len uri : 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01',
preferredId : 5, preferredId : 5,
preferredEncrypt : false, preferredEncrypt : false,
direction : 'inactive' // TODO: Enable when done. direction : 'inactive' // TODO: Enable when done.
......
...@@ -164,11 +164,6 @@ ...@@ -164,11 +164,6 @@
"directory": "PATH/out", "directory": "PATH/out",
"file": "PATH/src/RTC/RtpPacket.cpp" "file": "PATH/src/RTC/RtpPacket.cpp"
}, },
{
"command": "c++ -c -DMS_LITTLE_ENDIAN -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_INT16_T -DHAVE_INT32_T -DHAVE_INT8_T -DHAVE_UINT16_T -DHAVE_UINT32_T -DHAVE_UINT64_T -DHAVE_UINT8_T -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DCPU_CISC -IPATH/include -IPATH/deps/netstring/netstring-c -IPATH/deps/libuv/include -IPATH/deps/openssl/openssl/include -IPATH/deps/libsrtp/srtp/include -std=c++11 -Wall -Wextra -Wno-unused-parameter -m64 -g -o PATH/out/Release/obj.target/mediasoup-worker/src/RTC/RtpProbator.o PATH/src/RTC/RtpProbator.cpp",
"directory": "PATH/out",
"file": "PATH/src/RTC/RtpProbator.cpp"
},
{ {
"command": "c++ -c -DMS_LITTLE_ENDIAN -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_INT16_T -DHAVE_INT32_T -DHAVE_INT8_T -DHAVE_UINT16_T -DHAVE_UINT32_T -DHAVE_UINT64_T -DHAVE_UINT8_T -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DCPU_CISC -IPATH/include -IPATH/deps/netstring/netstring-c -IPATH/deps/libuv/include -IPATH/deps/openssl/openssl/include -IPATH/deps/libsrtp/srtp/include -std=c++11 -Wall -Wextra -Wno-unused-parameter -m64 -g -o PATH/out/Release/obj.target/mediasoup-worker/src/RTC/RtpStream.o PATH/src/RTC/RtpStream.cpp", "command": "c++ -c -DMS_LITTLE_ENDIAN -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_INT16_T -DHAVE_INT32_T -DHAVE_INT8_T -DHAVE_UINT16_T -DHAVE_UINT32_T -DHAVE_UINT64_T -DHAVE_UINT8_T -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DCPU_CISC -IPATH/include -IPATH/deps/netstring/netstring-c -IPATH/deps/libuv/include -IPATH/deps/openssl/openssl/include -IPATH/deps/libsrtp/srtp/include -std=c++11 -Wall -Wextra -Wno-unused-parameter -m64 -g -o PATH/out/Release/obj.target/mediasoup-worker/src/RTC/RtpStream.o PATH/src/RTC/RtpStream.cpp",
"directory": "PATH/out", "directory": "PATH/out",
......
...@@ -26,7 +26,8 @@ namespace RTC ...@@ -26,7 +26,8 @@ namespace RTC
{ {
public: public:
virtual void OnConsumerSendRtpPacket(RTC::Consumer* consumer, RTC::RtpPacket* packet) = 0; virtual void OnConsumerSendRtpPacket(RTC::Consumer* consumer, RTC::RtpPacket* packet) = 0;
virtual void OnConsumerRetransmitRtpPacket(RTC::Consumer* consumer, RTC::RtpPacket* packet) = 0; virtual void OnConsumerRetransmitRtpPacket(
RTC::Consumer* consumer, RTC::RtpPacket* packet, bool probation = false) = 0;
virtual void OnConsumerKeyFrameRequested(RTC::Consumer* consumer, uint32_t mappedSsrc) = 0; virtual void OnConsumerKeyFrameRequested(RTC::Consumer* consumer, uint32_t mappedSsrc) = 0;
virtual void OnConsumerNeedBitrateChange(RTC::Consumer* consumer) = 0; virtual void OnConsumerNeedBitrateChange(RTC::Consumer* consumer) = 0;
virtual void onConsumerProducerClosed(RTC::Consumer* consumer) = 0; virtual void onConsumerProducerClosed(RTC::Consumer* consumer) = 0;
...@@ -69,6 +70,7 @@ namespace RTC ...@@ -69,6 +70,7 @@ namespace RTC
virtual uint32_t IncreaseLayer(uint32_t bitrate); virtual uint32_t IncreaseLayer(uint32_t bitrate);
virtual void ApplyLayers(); virtual void ApplyLayers();
virtual void SendRtpPacket(RTC::RtpPacket* packet) = 0; virtual void SendRtpPacket(RTC::RtpPacket* packet) = 0;
virtual void SendProbationRtpPacket(uint16_t seq) = 0;
virtual std::vector<RTC::RtpStreamSend*> GetRtpStreams() = 0; virtual std::vector<RTC::RtpStreamSend*> GetRtpStreams() = 0;
virtual void GetRtcp( virtual void GetRtcp(
RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) = 0; RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) = 0;
......
...@@ -23,6 +23,7 @@ namespace RTC ...@@ -23,6 +23,7 @@ namespace RTC
void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override;
void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) override; void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) override;
void SendRtpPacket(RTC::RtpPacket* packet) override; void SendRtpPacket(RTC::RtpPacket* packet) override;
void SendProbationRtpPacket(uint16_t seq) override;
void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) override; void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) override;
std::vector<RTC::RtpStreamSend*> GetRtpStreams() override; std::vector<RTC::RtpStreamSend*> GetRtpStreams() override;
void NeedWorstRemoteFractionLost(uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) override; void NeedWorstRemoteFractionLost(uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) override;
...@@ -42,7 +43,8 @@ namespace RTC ...@@ -42,7 +43,8 @@ namespace RTC
/* Pure virtual methods inherited from RtpStreamSend::Listener. */ /* Pure virtual methods inherited from RtpStreamSend::Listener. */
public: public:
void OnRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void OnRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override;
void OnRtpStreamRetransmitRtpPacket(RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet) override; void OnRtpStreamRetransmitRtpPacket(
RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet, bool probation = false) override;
private: private:
// Allocated by this. // Allocated by this.
......
...@@ -28,7 +28,10 @@ namespace RTC ...@@ -28,7 +28,10 @@ namespace RTC
private: private:
bool IsConnected() const override; bool IsConnected() const override;
void SendRtpPacket( void SendRtpPacket(
RTC::RtpPacket* packet, RTC::Consumer* consumer, bool retransmitted = false) override; RTC::RtpPacket* packet,
RTC::Consumer* consumer,
bool retransmitted = false,
bool probation = false) override;
void SendRtcpPacket(RTC::RTCP::Packet* packet) override; void SendRtcpPacket(RTC::RTCP::Packet* packet) override;
void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override; void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override;
void OnPacketRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void OnPacketRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
......
...@@ -28,7 +28,10 @@ namespace RTC ...@@ -28,7 +28,10 @@ namespace RTC
private: private:
bool IsConnected() const override; bool IsConnected() const override;
void SendRtpPacket( void SendRtpPacket(
RTC::RtpPacket* packet, RTC::Consumer* consumer, bool retransmitted = false) override; RTC::RtpPacket* packet,
RTC::Consumer* consumer,
bool retransmitted = false,
bool probation = false) override;
void SendRtcpPacket(RTC::RTCP::Packet* packet) override; void SendRtcpPacket(RTC::RTCP::Packet* packet) override;
void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override; void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override;
void OnPacketRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void OnPacketRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
#include "common.hpp" #include "common.hpp"
#include "RTC/RTCP/FeedbackPsRemb.hpp" #include "RTC/RTCP/FeedbackPsRemb.hpp"
#include "RTC/RtpDataCounter.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RtpProbator.hpp"
namespace RTC namespace RTC
{ {
class RembClient : public RTC::RtpProbator::Listener class RembClient
{ {
public: public:
class Listener class Listener
...@@ -16,8 +16,6 @@ namespace RTC ...@@ -16,8 +16,6 @@ namespace RTC
public: public:
virtual void OnRembClientAvailableBitrate( virtual void OnRembClientAvailableBitrate(
RTC::RembClient* rembClient, uint32_t availableBitrate) = 0; RTC::RembClient* rembClient, uint32_t availableBitrate) = 0;
virtual void OnRembClientSendProbationRtpPacket(
RTC::RembClient* rembClient, RTC::RtpPacket* packet) = 0;
}; };
public: public:
...@@ -30,27 +28,27 @@ namespace RTC ...@@ -30,27 +28,27 @@ namespace RTC
public: public:
void ReceiveRembFeedback(RTC::RTCP::FeedbackPsRembPacket* remb); void ReceiveRembFeedback(RTC::RTCP::FeedbackPsRembPacket* remb);
void SentRtpPacket(RTC::RtpPacket* packet, bool retransmitted); void SentRtpPacket(RTC::RtpPacket* packet, bool retransmitted);
void SentProbationRtpPacket(RTC::RtpPacket* packet);
uint32_t GetAvailableBitrate(); uint32_t GetAvailableBitrate();
void ResecheduleNextEvent(); void ResecheduleNextEvent();
bool IsProbationNeeded();
private: private:
void CheckStatus(uint64_t now); void CheckStatus(uint64_t now);
void CalculateProbationTargetBitrate();
/* Pure virtual methods inherited from RTC::RtpProbator::Listener. */
public:
void OnRtpProbatorSendRtpPacket(RTC::RtpProbator* rtpProbator, RTC::RtpPacket* packet) override;
private: private:
// Passed by argument. // Passed by argument.
Listener* listener{ nullptr }; Listener* listener{ nullptr };
// Allocated by this.
RTC::RtpProbator* rtpProbator{ nullptr };
// Others. // Others.
uint32_t initialAvailableBitrate{ 0 }; uint32_t initialAvailableBitrate{ 0 };
uint32_t minimumAvailableBitrate{ 0 }; uint32_t minimumAvailableBitrate{ 0 };
uint64_t initialAvailableBitrateAt{ 0 }; uint64_t initialAvailableBitrateAt{ 0 };
uint32_t availableBitrate{ 0 }; uint32_t availableBitrate{ 0 };
uint64_t lastEventAt{ 0 }; uint64_t lastEventAt{ 0 };
uint32_t probationTargetBitrate{ 0 };
RTC::RtpDataCounter transmissionCounter;
RTC::RtpDataCounter probationTransmissionCounter;
}; };
} // namespace RTC } // namespace RTC
......
#ifndef MS_RTC_RTP_PROBATOR_HPP
#define MS_RTC_RTP_PROBATOR_HPP
#include "common.hpp"
#include "RTC/RtpDataCounter.hpp"
#include "RTC/RtpPacket.hpp"
namespace RTC
{
class RtpProbator
{
public:
class Listener
{
public:
virtual void OnRtpProbatorSendRtpPacket(RTC::RtpProbator* rtpProbator, RTC::RtpPacket* packet) = 0;
};
public:
explicit RtpProbator(RTC::RtpProbator::Listener* listener);
virtual ~RtpProbator();
public:
void UpdateAvailableBitrate(uint32_t availableBitrate);
void ReceiveRtpPacket(RTC::RtpPacket* packet, bool retransmitted);
private:
// Passed by argument.
Listener* listener{ nullptr };
// Others.
bool enabled{ false };
uint32_t probationTargetBitrate{ 0 };
RTC::RtpDataCounter transmissionCounter;
RTC::RtpDataCounter probationTransmissionCounter;
};
} // namespace RTC
#endif
...@@ -15,7 +15,7 @@ namespace RTC ...@@ -15,7 +15,7 @@ namespace RTC
{ {
public: public:
virtual void OnRtpStreamRetransmitRtpPacket( virtual void OnRtpStreamRetransmitRtpPacket(
RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet) = 0; RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet, bool probation = false) = 0;
}; };
public: public:
...@@ -48,6 +48,7 @@ namespace RTC ...@@ -48,6 +48,7 @@ namespace RTC
RTC::RTCP::SdesChunk* GetRtcpSdesChunk(); RTC::RTCP::SdesChunk* GetRtcpSdesChunk();
void Pause() override; void Pause() override;
void Resume() override; void Resume() override;
void SendProbationRtpPacket(uint16_t seq);
uint32_t GetBitrate(uint64_t now) override; uint32_t GetBitrate(uint64_t now) override;
uint32_t GetBitrate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer) override; uint32_t GetBitrate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer) override;
uint32_t GetLayerBitrate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer) override; uint32_t GetLayerBitrate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer) override;
......
...@@ -24,6 +24,7 @@ namespace RTC ...@@ -24,6 +24,7 @@ namespace RTC
void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override;
void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) override; void ProducerRtcpSenderReport(RTC::RtpStream* rtpStream, bool first) override;
void SendRtpPacket(RTC::RtpPacket* packet) override; void SendRtpPacket(RTC::RtpPacket* packet) override;
void SendProbationRtpPacket(uint16_t seq) override;
std::vector<RTC::RtpStreamSend*> GetRtpStreams() override; std::vector<RTC::RtpStreamSend*> GetRtpStreams() override;
void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) override; void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) override;
void NeedWorstRemoteFractionLost(uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) override; void NeedWorstRemoteFractionLost(uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) override;
...@@ -44,7 +45,8 @@ namespace RTC ...@@ -44,7 +45,8 @@ namespace RTC
/* Pure virtual methods inherited from RtpStreamSend::Listener. */ /* Pure virtual methods inherited from RtpStreamSend::Listener. */
public: public:
void OnRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void OnRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override;
void OnRtpStreamRetransmitRtpPacket(RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet) override; void OnRtpStreamRetransmitRtpPacket(
RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet, bool probation = false) override;
private: private:
// Allocated by this. // Allocated by this.
......
...@@ -31,6 +31,7 @@ namespace RTC ...@@ -31,6 +31,7 @@ namespace RTC
uint32_t IncreaseLayer(uint32_t bitrate) override; uint32_t IncreaseLayer(uint32_t bitrate) override;
void ApplyLayers() override; void ApplyLayers() override;
void SendRtpPacket(RTC::RtpPacket* packet) override; void SendRtpPacket(RTC::RtpPacket* packet) override;
void SendProbationRtpPacket(uint16_t seq) override;
void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) override; void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) override;
std::vector<RTC::RtpStreamSend*> GetRtpStreams() override; std::vector<RTC::RtpStreamSend*> GetRtpStreams() override;
void NeedWorstRemoteFractionLost(uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) override; void NeedWorstRemoteFractionLost(uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) override;
...@@ -62,7 +63,8 @@ namespace RTC ...@@ -62,7 +63,8 @@ namespace RTC
/* Pure virtual methods inherited from RtpStreamSend::Listener. */ /* Pure virtual methods inherited from RtpStreamSend::Listener. */
public: public:
void OnRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; void OnRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override;
void OnRtpStreamRetransmitRtpPacket(RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet) override; void OnRtpStreamRetransmitRtpPacket(
RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet, bool probation = false) override;
private: private:
// Allocated by this. // Allocated by this.
......
...@@ -101,7 +101,10 @@ namespace RTC ...@@ -101,7 +101,10 @@ namespace RTC
RTC::Consumer* GetConsumerByMediaSsrc(uint32_t ssrc) const; RTC::Consumer* GetConsumerByMediaSsrc(uint32_t ssrc) const;
virtual bool IsConnected() const = 0; virtual bool IsConnected() const = 0;
virtual void SendRtpPacket( virtual void SendRtpPacket(
RTC::RtpPacket* packet, RTC::Consumer* consumer, bool retransmitted = false) = 0; RTC::RtpPacket* packet,
RTC::Consumer* consumer,
bool retransmitted = false,
bool probation = false) = 0;
void SendRtcp(uint64_t now); void SendRtcp(uint64_t now);
virtual void SendRtcpPacket(RTC::RTCP::Packet* packet) = 0; virtual void SendRtcpPacket(RTC::RTCP::Packet* packet) = 0;
virtual void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) = 0; virtual void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) = 0;
...@@ -124,7 +127,8 @@ namespace RTC ...@@ -124,7 +127,8 @@ namespace RTC
/* Pure virtual methods inherited from RTC::Consumer::Listener. */ /* Pure virtual methods inherited from RTC::Consumer::Listener. */
public: public:
void OnConsumerSendRtpPacket(RTC::Consumer* consumer, RTC::RtpPacket* packet) override; void OnConsumerSendRtpPacket(RTC::Consumer* consumer, RTC::RtpPacket* packet) override;
void OnConsumerRetransmitRtpPacket(RTC::Consumer* consumer, RTC::RtpPacket* packet) override; void OnConsumerRetransmitRtpPacket(
RTC::Consumer* consumer, RTC::RtpPacket* packet, bool probation) override;
void OnConsumerKeyFrameRequested(RTC::Consumer* consumer, uint32_t mappedSsrc) override; void OnConsumerKeyFrameRequested(RTC::Consumer* consumer, uint32_t mappedSsrc) override;
virtual void OnConsumerNeedBitrateChange(RTC::Consumer* consumer) override = 0; virtual void OnConsumerNeedBitrateChange(RTC::Consumer* consumer) override = 0;
void onConsumerProducerClosed(RTC::Consumer* consumer) override; void onConsumerProducerClosed(RTC::Consumer* consumer) override;
......
...@@ -46,7 +46,10 @@ namespace RTC ...@@ -46,7 +46,10 @@ namespace RTC
bool IsConnected() const override; bool IsConnected() const override;
void MayRunDtlsTransport(); void MayRunDtlsTransport();
void SendRtpPacket( void SendRtpPacket(
RTC::RtpPacket* packet, RTC::Consumer* consumer, bool retransmitted = false) override; RTC::RtpPacket* packet,
RTC::Consumer* consumer,
bool retransmitted = false,
bool probation = false) override;
void SendRtcpPacket(RTC::RTCP::Packet* packet) override; void SendRtcpPacket(RTC::RTCP::Packet* packet) override;
void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override; void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override;
void DistributeAvailableOutgoingBitrate(); void DistributeAvailableOutgoingBitrate();
...@@ -110,7 +113,6 @@ namespace RTC ...@@ -110,7 +113,6 @@ namespace RTC
/* Pure virtual methods inherited from RTC::RembClient::Listener. */ /* Pure virtual methods inherited from RTC::RembClient::Listener. */
public: public:
void OnRembClientAvailableBitrate(RTC::RembClient* rembClient, uint32_t availableBitrate) override; void OnRembClientAvailableBitrate(RTC::RembClient* rembClient, uint32_t availableBitrate) override;
void OnRembClientSendProbationRtpPacket(RTC::RembClient* rembClient, RTC::RtpPacket* packet) override;
/* Pure virtual methods inherited from RTC::RembServer::RemoteBitrateEstimator::Listener. */ /* Pure virtual methods inherited from RTC::RembServer::RemoteBitrateEstimator::Listener. */
public: public:
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
'src/RTC/RtpListener.cpp', 'src/RTC/RtpListener.cpp',
'src/RTC/RtpObserver.cpp', 'src/RTC/RtpObserver.cpp',
'src/RTC/RtpPacket.cpp', 'src/RTC/RtpPacket.cpp',
'src/RTC/RtpProbator.cpp',
'src/RTC/RtpStream.cpp', 'src/RTC/RtpStream.cpp',
'src/RTC/RtpStreamRecv.cpp', 'src/RTC/RtpStreamRecv.cpp',
'src/RTC/RtpStreamSend.cpp', 'src/RTC/RtpStreamSend.cpp',
...@@ -144,7 +143,6 @@ ...@@ -144,7 +143,6 @@
'include/RTC/RtpListener.hpp', 'include/RTC/RtpListener.hpp',
'include/RTC/RtpObserver.hpp', 'include/RTC/RtpObserver.hpp',
'include/RTC/RtpPacket.hpp', 'include/RTC/RtpPacket.hpp',
'include/RTC/RtpProbator.hpp',
'include/RTC/RtpStream.hpp', 'include/RTC/RtpStream.hpp',
'include/RTC/RtpStreamRecv.hpp', 'include/RTC/RtpStreamRecv.hpp',
'include/RTC/RtpStreamSend.hpp', 'include/RTC/RtpStreamSend.hpp',
......
...@@ -220,6 +220,13 @@ namespace RTC ...@@ -220,6 +220,13 @@ namespace RTC
packet->SetSequenceNumber(origSeq); packet->SetSequenceNumber(origSeq);
} }
void PipeConsumer::SendProbationRtpPacket(uint16_t /*seq*/)
{
MS_TRACE();
MS_ABORT("should not call this method");
}
void PipeConsumer::GetRtcp( void PipeConsumer::GetRtcp(
RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now)
{ {
...@@ -493,10 +500,10 @@ namespace RTC ...@@ -493,10 +500,10 @@ namespace RTC
} }
inline void PipeConsumer::OnRtpStreamRetransmitRtpPacket( inline void PipeConsumer::OnRtpStreamRetransmitRtpPacket(
RTC::RtpStreamSend* /*rtpStream*/, RTC::RtpPacket* packet) RTC::RtpStreamSend* /*rtpStream*/, RTC::RtpPacket* packet, bool probation)
{ {
MS_TRACE(); MS_TRACE();
this->listener->OnConsumerRetransmitRtpPacket(this, packet); this->listener->OnConsumerRetransmitRtpPacket(this, packet, probation);
} }
} // namespace RTC } // namespace RTC
...@@ -265,7 +265,7 @@ namespace RTC ...@@ -265,7 +265,7 @@ namespace RTC
} }
void PipeTransport::SendRtpPacket( void PipeTransport::SendRtpPacket(
RTC::RtpPacket* packet, RTC::Consumer* /*consumer*/, bool /*retransmitted*/) RTC::RtpPacket* packet, RTC::Consumer* /*consumer*/, bool /*retransmitted*/, bool /*probation*/)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -452,7 +452,7 @@ namespace RTC ...@@ -452,7 +452,7 @@ namespace RTC
} }
void PlainRtpTransport::SendRtpPacket( void PlainRtpTransport::SendRtpPacket(
RTC::RtpPacket* packet, RTC::Consumer* /*consumer*/, bool /*retransmitted*/) RTC::RtpPacket* packet, RTC::Consumer* /*consumer*/, bool /*retransmitted*/, bool /*probation*/)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -1063,9 +1063,14 @@ namespace RTC ...@@ -1063,9 +1063,14 @@ namespace RTC
{ {
// If video orientation was not yet detected or any value has changed, // If video orientation was not yet detected or any value has changed,
// emit event. // emit event.
// clang-format off
if ( if (
!this->videoOrientationDetected || camera != this->videoOrientation.camera || !this->videoOrientationDetected ||
flip != this->videoOrientation.flip || rotation != this->videoOrientation.rotation) camera != this->videoOrientation.camera ||
flip != this->videoOrientation.flip ||
rotation != this->videoOrientation.rotation
)
// clang-format on
{ {
this->videoOrientationDetected = true; this->videoOrientationDetected = true;
this->videoOrientation.camera = camera; this->videoOrientation.camera = camera;
......
...@@ -23,15 +23,11 @@ namespace RTC ...@@ -23,15 +23,11 @@ namespace RTC
minimumAvailableBitrate(minimumAvailableBitrate) minimumAvailableBitrate(minimumAvailableBitrate)
{ {
MS_TRACE(); MS_TRACE();
this->rtpProbator = new RTC::RtpProbator(this);
} }
RembClient::~RembClient() RembClient::~RembClient()
{ {
MS_TRACE(); MS_TRACE();
delete this->rtpProbator;
} }
void RembClient::ReceiveRembFeedback(RTC::RTCP::FeedbackPsRembPacket* remb) void RembClient::ReceiveRembFeedback(RTC::RTCP::FeedbackPsRembPacket* remb)
...@@ -82,23 +78,32 @@ namespace RTC ...@@ -82,23 +78,32 @@ namespace RTC
notify = true; notify = true;
} }
// Pass available bitrate to the RtpProbator.
this->rtpProbator->UpdateAvailableBitrate(this->availableBitrate);
if (notify) if (notify)
{ {
this->lastEventAt = now; this->lastEventAt = now;
this->listener->OnRembClientAvailableBitrate(this, this->availableBitrate); this->listener->OnRembClientAvailableBitrate(this, this->availableBitrate);
} }
CalculateProbationTargetBitrate();
} }
void RembClient::SentRtpPacket(RTC::RtpPacket* packet, bool retransmitted) void RembClient::SentRtpPacket(RTC::RtpPacket* packet, bool /*retransmitted*/)
{ {
MS_TRACE(); MS_TRACE();
// Pass the packet to the RtpProbator. // Increase transmission counter.
this->rtpProbator->ReceiveRtpPacket(packet, retransmitted); this->transmissionCounter.Update(packet);
}
void RembClient::SentProbationRtpPacket(RTC::RtpPacket* packet)
{
MS_TRACE();
MS_DEBUG_DEV("[seq:%" PRIu16 ", size:%zu]", packet->GetSequenceNumber(), packet->GetSize());
// Increase probation transmission counter.
this->probationTransmissionCounter.Update(packet);
} }
uint32_t RembClient::GetAvailableBitrate() uint32_t RembClient::GetAvailableBitrate()
...@@ -119,6 +124,19 @@ namespace RTC ...@@ -119,6 +124,19 @@ namespace RTC
this->lastEventAt = DepLibUV::GetTime(); this->lastEventAt = DepLibUV::GetTime();
} }
bool RembClient::IsProbationNeeded()
{
MS_TRACE();
if (!this->probationTargetBitrate)
return false;
auto now = DepLibUV::GetTime();
auto probationTransmissionBitrate = this->probationTransmissionCounter.GetBitrate(now);
return (probationTransmissionBitrate <= this->probationTargetBitrate);
}
inline void RembClient::CheckStatus(uint64_t now) inline void RembClient::CheckStatus(uint64_t now)
{ {
MS_TRACE(); MS_TRACE();
...@@ -130,17 +148,52 @@ namespace RTC ...@@ -130,17 +148,52 @@ namespace RTC
this->initialAvailableBitrateAt = now; this->initialAvailableBitrateAt = now;
this->availableBitrate = this->initialAvailableBitrate; this->availableBitrate = this->initialAvailableBitrate;
// Tell the RTP probator to start probing even before receiving REMB CalculateProbationTargetBitrate();
// feedbacks.
this->rtpProbator->UpdateAvailableBitrate(this->initialAvailableBitrate);
} }
} }
inline void RembClient::OnRtpProbatorSendRtpPacket( inline void RembClient::CalculateProbationTargetBitrate()
RTC::RtpProbator* /*rtpProbator*/, RTC::RtpPacket* packet)
{ {
MS_TRACE(); MS_TRACE();
this->listener->OnRembClientSendProbationRtpPacket(this, packet); auto previousProbationTargetBitrate = this->probationTargetBitrate;
this->probationTargetBitrate = 0;
if (this->availableBitrate == 0)
return;
uint64_t now = DepLibUV::GetTime();
auto transmissionBitrate = this->transmissionCounter.GetBitrate(now);
auto factor =
static_cast<float>(transmissionBitrate) / static_cast<float>(this->availableBitrate);
// Just consider probation if transmission bitrate is close to available bitrate
// (without exceeding it much).
if (factor >= 0.8 && factor <= 1.2)
{
if (this->availableBitrate > transmissionBitrate)
this->probationTargetBitrate = 2 * (this->availableBitrate - transmissionBitrate);
else
this->probationTargetBitrate = 0.5 * transmissionBitrate;
}
// If there is no bitrate, set available bitrate as probation target bitrate.
else if (factor == 0)
{
this->probationTargetBitrate = this->availableBitrate;
}
if (this->probationTargetBitrate != previousProbationTargetBitrate)
{
MS_DEBUG_TAG(
bwe,
"probation %s [bitrate:%" PRIu32 ", availableBitrate:%" PRIu32
", factor:%f, probationTargetBitrate:%" PRIu32 "]",
this->probationTargetBitrate ? "enabled" : "disabled",
transmissionBitrate,
this->availableBitrate,
factor,
this->probationTargetBitrate);
}
} }
} // namespace RTC } // namespace RTC
#define MS_CLASS "RTC::RtpProbator"
// #define MS_LOG_DEV
#include "RTC/RtpProbator.hpp"
#include "DepLibUV.hpp"
#include "Logger.hpp"
namespace RTC
{
/* Instance methods. */
RtpProbator::RtpProbator(RTC::RtpProbator::Listener* listener) : listener(listener)
{
MS_TRACE();
}
RtpProbator::~RtpProbator()
{
MS_TRACE();
}
void RtpProbator::UpdateAvailableBitrate(uint32_t availableBitrate)
{
MS_TRACE();
auto wasEnabled = this->enabled;
// Let's do this stateless.
this->enabled = false;
this->probationTargetBitrate = 0;
auto now = DepLibUV::GetTime();
auto transmissionBitrate = this->transmissionCounter.GetBitrate(now);
if (availableBitrate == 0)
{
if (wasEnabled)
MS_DEBUG_TAG(bwe, "probation disabled due zero available bitrate");
return;
}
// Just enable probation if transmission bitrate is close to available bitrate
// (without exceeding it).
auto factor = static_cast<float>(transmissionBitrate) / static_cast<float>(availableBitrate);
if (factor >= 0.8 && factor <= 1.2)
{
this->enabled = true;
if (availableBitrate > transmissionBitrate)
this->probationTargetBitrate = 2 * (availableBitrate - transmissionBitrate);
else
this->probationTargetBitrate = 0.5 * transmissionBitrate;
}
// If there is no bitrate, set available bitrate as probation target bitrate.
else if (factor == 0)
{
this->enabled = true;
this->probationTargetBitrate = availableBitrate;
}
if (!wasEnabled && this->enabled)
{
MS_DEBUG_TAG(
bwe,
"probation enabled [bitrate:%" PRIu32 ", availableBitrate:%" PRIu32
", factor:%f, probationTargetBitrate:%" PRIu32 "]",
transmissionBitrate,
availableBitrate,
factor,
this->probationTargetBitrate);
}
else if (wasEnabled && this->enabled)
{
MS_DEBUG_DEV(
"probation updated [bitrate:%" PRIu32 ", availableBitrate:%" PRIu32
", factor:%f, probationTargetBitrate:%" PRIu32 "]",
transmissionBitrate,
availableBitrate,
factor,
this->probationTargetBitrate);
}
else if (wasEnabled && !this->enabled)
{
MS_DEBUG_TAG(
bwe,
"probation disabled [bitrate:%" PRIu32 ", availableBitrate:%" PRIu32 ", factor:%f]",
transmissionBitrate,
availableBitrate,
factor);
}
}
void RtpProbator::ReceiveRtpPacket(RTC::RtpPacket* packet, bool retransmitted)
{
MS_TRACE();
// Increase transmission counter.
this->transmissionCounter.Update(packet);
// If probation disabled or a retransmitted packet, exit here.
if (!this->enabled || retransmitted)
return;
auto now = DepLibUV::GetTime();
auto probationTransmissionBitrate = this->probationTransmissionCounter.GetBitrate(now);
// Check whether we have to use this packet in probation.
if (probationTransmissionBitrate <= this->probationTargetBitrate)
{
MS_DEBUG_DEV(
"sending probation RTP packet [probationTargetBitrate:%" PRIu32
", probationTransmissionBitrate:%" PRIu32 "]",
this->probationTargetBitrate,
probationTransmissionBitrate);
// Increase probation transmission counter.
this->probationTransmissionCounter.Update(packet);
// Send the probation packet.
this->listener->OnRtpProbatorSendRtpPacket(this, packet);
// Update probation bitrate.
probationTransmissionBitrate = this->probationTransmissionCounter.GetBitrate(now);
}
// May send probation packet twice.
if (probationTransmissionBitrate <= this->probationTargetBitrate)
{
MS_DEBUG_DEV(
"sending probation RTP packet twice [probationTargetBitrate:%" PRIu32
", probationTransmissionBitrate:%" PRIu32 "]",
this->probationTargetBitrate,
probationTransmissionBitrate);
// Increase probation transmission counter.
this->probationTransmissionCounter.Update(packet);
// Send the probation packet.
this->listener->OnRtpProbatorSendRtpPacket(this, packet);
}
}
} // namespace RTC
...@@ -216,6 +216,43 @@ namespace RTC ...@@ -216,6 +216,43 @@ namespace RTC
MS_TRACE(); MS_TRACE();
} }
void RtpStreamSend::SendProbationRtpPacket(uint16_t seq)
{
MS_TRACE();
if (this->storage.empty())
return;
auto* storageItem = this->buffer[seq];
if (!storageItem)
return;
auto* packet = storageItem->packet;
// If we use RTX and the packet has not yet been resent, encode it now.
if (HasRtx())
{
// Increment RTX seq.
++this->rtxSeq;
if (!storageItem->rtxEncoded)
{
packet->RtxEncode(this->params.rtxPayloadType, this->params.rtxSsrc, this->rtxSeq);
storageItem->rtxEncoded = true;
}
else
{
packet->SetSequenceNumber(this->rtxSeq);
}
}
// Retransmit as probation packet.
static_cast<RTC::RtpStreamSend::Listener*>(this->listener)
->OnRtpStreamRetransmitRtpPacket(this, packet, true);
}
uint32_t RtpStreamSend::GetBitrate(uint64_t /*now*/, uint8_t /*spatialLayer*/, uint8_t /*temporalLayer*/) uint32_t RtpStreamSend::GetBitrate(uint64_t /*now*/, uint8_t /*spatialLayer*/, uint8_t /*temporalLayer*/)
{ {
MS_ABORT("invalid method call"); MS_ABORT("invalid method call");
...@@ -320,7 +357,6 @@ namespace RTC ...@@ -320,7 +357,6 @@ namespace RTC
if (!storageItem) if (!storageItem)
{ {
// TODO
MS_ASSERT(this->buffer[idx] == nullptr, "key should be NULL"); MS_ASSERT(this->buffer[idx] == nullptr, "key should be NULL");
continue; continue;
...@@ -467,14 +503,23 @@ namespace RTC ...@@ -467,14 +503,23 @@ namespace RTC
// Stored packet is valid for retransmission. Resend it. // Stored packet is valid for retransmission. Resend it.
else else
{ {
// If we use RTX and the packet has not yet been resent, encode it // If we use RTX and the packet has not yet been resent, encode it now.
// now. if (HasRtx())
if (HasRtx() && !storageItem->rtxEncoded) {
// Increment RTX seq.
++this->rtxSeq;
if (!storageItem->rtxEncoded)
{ {
packet->RtxEncode(this->params.rtxPayloadType, this->params.rtxSsrc, ++this->rtxSeq); packet->RtxEncode(this->params.rtxPayloadType, this->params.rtxSsrc, this->rtxSeq);
storageItem->rtxEncoded = true; storageItem->rtxEncoded = true;
} }
else
{
packet->SetSequenceNumber(this->rtxSeq);
}
}
// Save when this packet was resent. // Save when this packet was resent.
storageItem->resentAtTime = now; storageItem->resentAtTime = now;
......
...@@ -216,6 +216,13 @@ namespace RTC ...@@ -216,6 +216,13 @@ namespace RTC
packet->SetSequenceNumber(origSeq); packet->SetSequenceNumber(origSeq);
} }
void SimpleConsumer::SendProbationRtpPacket(uint16_t seq)
{
MS_TRACE();
this->rtpStream->SendProbationRtpPacket(seq);
}
void SimpleConsumer::GetRtcp( void SimpleConsumer::GetRtcp(
RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now)
{ {
...@@ -452,10 +459,10 @@ namespace RTC ...@@ -452,10 +459,10 @@ namespace RTC
} }
inline void SimpleConsumer::OnRtpStreamRetransmitRtpPacket( inline void SimpleConsumer::OnRtpStreamRetransmitRtpPacket(
RTC::RtpStreamSend* /*rtpStream*/, RTC::RtpPacket* packet) RTC::RtpStreamSend* /*rtpStream*/, RTC::RtpPacket* packet, bool probation)
{ {
MS_TRACE(); MS_TRACE();
this->listener->OnConsumerRetransmitRtpPacket(this, packet); this->listener->OnConsumerRetransmitRtpPacket(this, packet, probation);
} }
} // namespace RTC } // namespace RTC
...@@ -857,6 +857,13 @@ namespace RTC ...@@ -857,6 +857,13 @@ namespace RTC
packet->RestorePayload(); packet->RestorePayload();
} }
void SimulcastConsumer::SendProbationRtpPacket(uint16_t seq)
{
MS_TRACE();
this->rtpStream->SendProbationRtpPacket(seq);
}
void SimulcastConsumer::GetRtcp( void SimulcastConsumer::GetRtcp(
RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now) RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t now)
{ {
...@@ -1320,7 +1327,7 @@ namespace RTC ...@@ -1320,7 +1327,7 @@ namespace RTC
// spatial layer, have Sender Report. // spatial layer, have Sender Report.
// //
// clang-format off // clang-format off
bool canSwitch = ( return (
this->tsReferenceSpatialLayer == -1 || this->tsReferenceSpatialLayer == -1 ||
spatialLayer == this->tsReferenceSpatialLayer || spatialLayer == this->tsReferenceSpatialLayer ||
( (
...@@ -1329,11 +1336,6 @@ namespace RTC ...@@ -1329,11 +1336,6 @@ namespace RTC
) )
); );
// clang-format on // clang-format on
if (!canSwitch)
MS_DEBUG_TAG(simulcast, "cannot switch to spatialLayer:%" PRIi16, spatialLayer);
return canSwitch;
} }
inline void SimulcastConsumer::EmitScore() const inline void SimulcastConsumer::EmitScore() const
...@@ -1418,10 +1420,10 @@ namespace RTC ...@@ -1418,10 +1420,10 @@ namespace RTC
} }
inline void SimulcastConsumer::OnRtpStreamRetransmitRtpPacket( inline void SimulcastConsumer::OnRtpStreamRetransmitRtpPacket(
RTC::RtpStreamSend* /*rtpStream*/, RTC::RtpPacket* packet) RTC::RtpStreamSend* /*rtpStream*/, RTC::RtpPacket* packet, bool probation)
{ {
MS_TRACE(); MS_TRACE();
this->listener->OnConsumerRetransmitRtpPacket(this, packet); this->listener->OnConsumerRetransmitRtpPacket(this, packet, probation);
} }
} // namespace RTC } // namespace RTC
...@@ -877,7 +877,8 @@ namespace RTC ...@@ -877,7 +877,8 @@ namespace RTC
SendRtpPacket(packet, consumer); SendRtpPacket(packet, consumer);
} }
inline void Transport::OnConsumerRetransmitRtpPacket(RTC::Consumer* consumer, RTC::RtpPacket* packet) inline void Transport::OnConsumerRetransmitRtpPacket(
RTC::Consumer* consumer, RTC::RtpPacket* packet, bool probation)
{ {
MS_TRACE(); MS_TRACE();
...@@ -896,7 +897,7 @@ namespace RTC ...@@ -896,7 +897,7 @@ namespace RTC
} }
} }
SendRtpPacket(packet, consumer); SendRtpPacket(packet, consumer, true, probation);
} }
inline void Transport::OnConsumerKeyFrameRequested(RTC::Consumer* consumer, uint32_t mappedSsrc) inline void Transport::OnConsumerKeyFrameRequested(RTC::Consumer* consumer, uint32_t mappedSsrc)
......
...@@ -775,7 +775,8 @@ namespace RTC ...@@ -775,7 +775,8 @@ namespace RTC
} }
} }
void WebRtcTransport::SendRtpPacket(RTC::RtpPacket* packet, RTC::Consumer* consumer, bool retransmitted) void WebRtcTransport::SendRtpPacket(
RTC::RtpPacket* packet, RTC::Consumer* consumer, bool retransmitted, bool probation)
{ {
MS_TRACE(); MS_TRACE();
...@@ -790,6 +791,7 @@ namespace RTC ...@@ -790,6 +791,7 @@ namespace RTC
return; return;
} }
auto seq = packet->GetSequenceNumber();
const uint8_t* data = packet->GetData(); const uint8_t* data = packet->GetData();
size_t len = packet->GetSize(); size_t len = packet->GetSize();
...@@ -812,12 +814,23 @@ namespace RTC ...@@ -812,12 +814,23 @@ namespace RTC
) )
// clang-format on // clang-format on
{ {
uint8_t extenLen; if (!probation)
uint8_t* extenValue = packet->GetExtension( {
static_cast<uint8_t>(RTC::RtpHeaderExtensionUri::Type::ABS_SEND_TIME), extenLen);
if (extenValue && extenLen == 3)
this->rembClient->SentRtpPacket(packet, retransmitted); this->rembClient->SentRtpPacket(packet, retransmitted);
// May need to generate probation packets.
for (int count{ 1 }; count <= 3; ++count)
{
if (!this->rembClient->IsProbationNeeded())
break;
consumer->SendProbationRtpPacket(seq);
}
}
else
{
this->rembClient->SentProbationRtpPacket(packet);
}
} }
} }
...@@ -1604,34 +1617,6 @@ namespace RTC ...@@ -1604,34 +1617,6 @@ namespace RTC
DistributeAvailableOutgoingBitrate(); DistributeAvailableOutgoingBitrate();
} }
inline void WebRtcTransport::OnRembClientSendProbationRtpPacket(
RTC::RembClient* /*rembClient*/, RTC::RtpPacket* packet)
{
MS_TRACE();
if (!IsConnected())
return;
// Ensure there is sending SRTP session.
if (this->srtpSendSession == nullptr)
{
MS_WARN_DEV("ignoring RTP packet due to non sending SRTP session");
return;
}
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
if (!this->srtpSendSession->EncryptRtp(&data, &len))
return;
this->iceSelectedTuple->Send(data, len);
// Increase send transmission.
RTC::Transport::DataSent(len);
}
inline void WebRtcTransport::OnRembServerAvailableBitrate( inline void WebRtcTransport::OnRembServerAvailableBitrate(
const RTC::RembServer::RemoteBitrateEstimator* /*rembServer*/, const RTC::RembServer::RemoteBitrateEstimator* /*rembServer*/,
const std::vector<uint32_t>& ssrcs, const std::vector<uint32_t>& ssrcs,
......
...@@ -17,7 +17,8 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp]") ...@@ -17,7 +17,8 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp]")
{ {
} }
void OnRtpStreamRetransmitRtpPacket(RtpStreamSend* /*rtpStream*/, RtpPacket* packet) override void OnRtpStreamRetransmitRtpPacket(
RtpStreamSend* /*rtpStream*/, RtpPacket* packet, bool /*probation*/) override
{ {
this->retransmittedPackets.push_back(packet); this->retransmittedPackets.push_back(packet);
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论