mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] enable congestion controller
This commit is contained in:
@@ -12,8 +12,10 @@ AudioChannelSend::AudioChannelSend(
|
|||||||
: ice_agent_(ice_agent), ice_io_statistics_(ice_io_statistics) {}
|
: ice_agent_(ice_agent), ice_io_statistics_(ice_io_statistics) {}
|
||||||
|
|
||||||
void AudioChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
void AudioChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||||
rtp_packetizer_ = RtpPacketizer::Create(payload_type);
|
|
||||||
rtp_audio_sender_ = std::make_unique<RtpAudioSender>(ice_io_statistics_);
|
rtp_audio_sender_ = std::make_unique<RtpAudioSender>(ice_io_statistics_);
|
||||||
|
rtp_packetizer_ =
|
||||||
|
RtpPacketizer::Create(payload_type, rtp_audio_sender_->GetSsrc());
|
||||||
|
|
||||||
rtp_audio_sender_->SetSendDataFunc(
|
rtp_audio_sender_->SetSendDataFunc(
|
||||||
[this](const char *data, size_t size) -> int {
|
[this](const char *data, size_t size) -> int {
|
||||||
if (!ice_agent_) {
|
if (!ice_agent_) {
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ DataChannelSend::DataChannelSend(
|
|||||||
: ice_agent_(ice_agent), ice_io_statistics_(ice_io_statistics) {}
|
: ice_agent_(ice_agent), ice_io_statistics_(ice_io_statistics) {}
|
||||||
|
|
||||||
void DataChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
void DataChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||||
rtp_packetizer_ = RtpPacketizer::Create(payload_type);
|
|
||||||
rtp_data_sender_ = std::make_unique<RtpDataSender>(ice_io_statistics_);
|
rtp_data_sender_ = std::make_unique<RtpDataSender>(ice_io_statistics_);
|
||||||
|
rtp_packetizer_ =
|
||||||
|
RtpPacketizer::Create(payload_type, rtp_data_sender_->GetSsrc());
|
||||||
|
|
||||||
rtp_data_sender_->SetSendDataFunc(
|
rtp_data_sender_->SetSendDataFunc(
|
||||||
[this](const char *data, size_t size) -> int {
|
[this](const char *data, size_t size) -> int {
|
||||||
if (!ice_agent_) {
|
if (!ice_agent_) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#define RTCP_SR_INTERVAL 1000
|
#define RTCP_SR_INTERVAL 1000
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
RtpAudioSender::RtpAudioSender() { SetPeriod(std::chrono::milliseconds(5)); }
|
RtpAudioSender::RtpAudioSender() { SetPeriod(std::chrono::milliseconds(5)); }
|
||||||
|
|
||||||
RtpAudioSender::RtpAudioSender(std::shared_ptr<IOStatistics> io_statistics)
|
RtpAudioSender::RtpAudioSender(std::shared_ptr<IOStatistics> io_statistics)
|
||||||
: io_statistics_(io_statistics) {
|
: ssrc_(GenerateUniqueSsrc()), io_statistics_(io_statistics) {
|
||||||
SetPeriod(std::chrono::milliseconds(5));
|
SetPeriod(std::chrono::milliseconds(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,6 +18,8 @@ RtpAudioSender::~RtpAudioSender() {
|
|||||||
if (rtp_statistics_) {
|
if (rtp_statistics_) {
|
||||||
rtp_statistics_->Stop();
|
rtp_statistics_->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSRCManager::Instance().DeleteSsrc(ssrc_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtpAudioSender::Enqueue(std::vector<RtpPacket>& rtp_packets) {
|
void RtpAudioSender::Enqueue(std::vector<RtpPacket>& rtp_packets) {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class RtpAudioSender : public ThreadBase {
|
|||||||
public:
|
public:
|
||||||
void Enqueue(std::vector<RtpPacket> &rtp_packets);
|
void Enqueue(std::vector<RtpPacket> &rtp_packets);
|
||||||
void SetSendDataFunc(std::function<int(const char *, size_t)> data_send_func);
|
void SetSendDataFunc(std::function<int(const char *, size_t)> data_send_func);
|
||||||
|
uint32_t GetSsrc() { return ssrc_; }
|
||||||
|
|
||||||
private:
|
|
||||||
private:
|
private:
|
||||||
int SendRtpPacket(RtpPacket &rtp_packet);
|
int SendRtpPacket(RtpPacket &rtp_packet);
|
||||||
int SendRtcpSR(RtcpSenderReport &rtcp_sr);
|
int SendRtcpSR(RtcpSenderReport &rtcp_sr);
|
||||||
@@ -39,6 +39,9 @@ class RtpAudioSender : public ThreadBase {
|
|||||||
private:
|
private:
|
||||||
std::function<int(const char *, size_t)> data_send_func_ = nullptr;
|
std::function<int(const char *, size_t)> data_send_func_ = nullptr;
|
||||||
RingBuffer<RtpPacket> rtp_packe_queue_;
|
RingBuffer<RtpPacket> rtp_packe_queue_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t ssrc_ = 0;
|
||||||
std::unique_ptr<RtpStatistics> rtp_statistics_ = nullptr;
|
std::unique_ptr<RtpStatistics> rtp_statistics_ = nullptr;
|
||||||
std::shared_ptr<IOStatistics> io_statistics_ = nullptr;
|
std::shared_ptr<IOStatistics> io_statistics_ = nullptr;
|
||||||
uint32_t last_send_bytes_ = 0;
|
uint32_t last_send_bytes_ = 0;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#define RTCP_SR_INTERVAL 1000
|
#define RTCP_SR_INTERVAL 1000
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
RtpDataSender::RtpDataSender() {}
|
RtpDataSender::RtpDataSender() {}
|
||||||
|
|
||||||
RtpDataSender::RtpDataSender(std::shared_ptr<IOStatistics> io_statistics)
|
RtpDataSender::RtpDataSender(std::shared_ptr<IOStatistics> io_statistics)
|
||||||
: io_statistics_(io_statistics) {
|
: ssrc_(GenerateUniqueSsrc()), io_statistics_(io_statistics) {
|
||||||
SetPeriod(std::chrono::milliseconds(5));
|
SetPeriod(std::chrono::milliseconds(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,6 +18,8 @@ RtpDataSender::~RtpDataSender() {
|
|||||||
if (rtp_statistics_) {
|
if (rtp_statistics_) {
|
||||||
rtp_statistics_->Stop();
|
rtp_statistics_->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSRCManager::Instance().DeleteSsrc(ssrc_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtpDataSender::Enqueue(std::vector<RtpPacket>& rtp_packets) {
|
void RtpDataSender::Enqueue(std::vector<RtpPacket>& rtp_packets) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class RtpDataSender : public ThreadBase {
|
|||||||
public:
|
public:
|
||||||
void Enqueue(std::vector<RtpPacket> &rtp_packets);
|
void Enqueue(std::vector<RtpPacket> &rtp_packets);
|
||||||
void SetSendDataFunc(std::function<int(const char *, size_t)> data_send_func);
|
void SetSendDataFunc(std::function<int(const char *, size_t)> data_send_func);
|
||||||
|
uint32_t GetSsrc() { return ssrc_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
private:
|
private:
|
||||||
@@ -41,6 +42,7 @@ class RtpDataSender : public ThreadBase {
|
|||||||
RingBuffer<RtpPacket> rtp_packe_queue_;
|
RingBuffer<RtpPacket> rtp_packe_queue_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
uint32_t ssrc_ = 0;
|
||||||
std::unique_ptr<RtpStatistics> rtp_statistics_ = nullptr;
|
std::unique_ptr<RtpStatistics> rtp_statistics_ = nullptr;
|
||||||
std::shared_ptr<IOStatistics> io_statistics_ = nullptr;
|
std::shared_ptr<IOStatistics> io_statistics_ = nullptr;
|
||||||
uint32_t last_send_bytes_ = 0;
|
uint32_t last_send_bytes_ = 0;
|
||||||
|
|||||||
@@ -9,34 +9,35 @@
|
|||||||
#define NV12_BUFFER_SIZE (1280 * 720 * 3 / 2)
|
#define NV12_BUFFER_SIZE (1280 * 720 * 3 / 2)
|
||||||
#define RTCP_RR_INTERVAL 1000
|
#define RTCP_RR_INTERVAL 1000
|
||||||
|
|
||||||
RtpVideoReceiver::RtpVideoReceiver()
|
RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<Clock> clock)
|
||||||
: feedback_ssrc_(GenerateUniqueSsrc()),
|
: feedback_ssrc_(GenerateUniqueSsrc()),
|
||||||
active_remb_module_(nullptr),
|
active_remb_module_(nullptr),
|
||||||
receive_side_congestion_controller_(
|
receive_side_congestion_controller_(
|
||||||
clock_,
|
clock,
|
||||||
[this](std::vector<std::unique_ptr<RtcpPacket>> packets) {
|
[this](std::vector<std::unique_ptr<RtcpPacket>> packets) {
|
||||||
SendCombinedRtcpPacket(std::move(packets));
|
SendCombinedRtcpPacket(std::move(packets));
|
||||||
},
|
},
|
||||||
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
|
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
|
||||||
SendRemb(bitrate_bps, ssrcs);
|
SendRemb(bitrate_bps, ssrcs);
|
||||||
}),
|
}),
|
||||||
clock_(Clock::GetRealTimeClockShared()) {
|
clock_(clock) {
|
||||||
SetPeriod(std::chrono::milliseconds(5));
|
SetPeriod(std::chrono::milliseconds(5));
|
||||||
// rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
|
// rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics)
|
RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<Clock> clock,
|
||||||
|
std::shared_ptr<IOStatistics> io_statistics)
|
||||||
: io_statistics_(io_statistics),
|
: io_statistics_(io_statistics),
|
||||||
feedback_ssrc_(GenerateUniqueSsrc()),
|
feedback_ssrc_(GenerateUniqueSsrc()),
|
||||||
receive_side_congestion_controller_(
|
receive_side_congestion_controller_(
|
||||||
clock_,
|
clock,
|
||||||
[this](std::vector<std::unique_ptr<RtcpPacket>> packets) {
|
[this](std::vector<std::unique_ptr<RtcpPacket>> packets) {
|
||||||
SendCombinedRtcpPacket(std::move(packets));
|
SendCombinedRtcpPacket(std::move(packets));
|
||||||
},
|
},
|
||||||
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
|
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
|
||||||
SendRemb(bitrate_bps, ssrcs);
|
SendRemb(bitrate_bps, ssrcs);
|
||||||
}),
|
}),
|
||||||
clock_(Clock::GetRealTimeClockShared()) {
|
clock_(clock) {
|
||||||
SetPeriod(std::chrono::milliseconds(5));
|
SetPeriod(std::chrono::milliseconds(5));
|
||||||
// rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
|
// rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
|
||||||
|
|
||||||
@@ -404,6 +405,21 @@ int RtpVideoReceiver::SendRtcpRR(RtcpReceiverReport& rtcp_rr) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TimeDelta AtoToTimeDelta(uint16_t receive_info) {
|
||||||
|
// receive_info
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
// |R|ECN| Arrival time offset |
|
||||||
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
const uint16_t ato = receive_info & 0x1FFF;
|
||||||
|
if (ato == 0x1FFE) {
|
||||||
|
return TimeDelta::PlusInfinity();
|
||||||
|
}
|
||||||
|
if (ato == 0x1FFF) {
|
||||||
|
return TimeDelta::MinusInfinity();
|
||||||
|
}
|
||||||
|
return TimeDelta::Seconds(ato) / 1024;
|
||||||
|
}
|
||||||
|
|
||||||
void RtpVideoReceiver::SendCombinedRtcpPacket(
|
void RtpVideoReceiver::SendCombinedRtcpPacket(
|
||||||
std::vector<std::unique_ptr<RtcpPacket>> rtcp_packets) {
|
std::vector<std::unique_ptr<RtcpPacket>> rtcp_packets) {
|
||||||
if (!data_send_func_) {
|
if (!data_send_func_) {
|
||||||
@@ -414,9 +430,18 @@ void RtpVideoReceiver::SendCombinedRtcpPacket(
|
|||||||
|
|
||||||
RTCPSender rtcp_sender(
|
RTCPSender rtcp_sender(
|
||||||
[this](const uint8_t* buffer, size_t size) -> int {
|
[this](const uint8_t* buffer, size_t size) -> int {
|
||||||
|
webrtc::rtcp::CommonHeader rtcp_block;
|
||||||
|
// bool valid = true;
|
||||||
|
// if (!rtcp_block.Parse(buffer, size)) {
|
||||||
|
// valid = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
webrtc::rtcp::CongestionControlFeedback feedback;
|
||||||
|
feedback.Parse(rtcp_block);
|
||||||
|
|
||||||
return data_send_func_((const char*)buffer, size);
|
return data_send_func_((const char*)buffer, size);
|
||||||
},
|
},
|
||||||
IP_PACKET_SIZE);
|
1200);
|
||||||
|
|
||||||
for (auto& rtcp_packet : rtcp_packets) {
|
for (auto& rtcp_packet : rtcp_packets) {
|
||||||
rtcp_packet->SetSenderSsrc(feedback_ssrc_);
|
rtcp_packet->SetSenderSsrc(feedback_ssrc_);
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ using namespace webrtc;
|
|||||||
|
|
||||||
class RtpVideoReceiver : public ThreadBase {
|
class RtpVideoReceiver : public ThreadBase {
|
||||||
public:
|
public:
|
||||||
RtpVideoReceiver();
|
RtpVideoReceiver(std::shared_ptr<Clock> clock);
|
||||||
RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics);
|
RtpVideoReceiver(std::shared_ptr<Clock> clock,
|
||||||
|
std::shared_ptr<IOStatistics> io_statistics);
|
||||||
virtual ~RtpVideoReceiver();
|
virtual ~RtpVideoReceiver();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
// #define SAVE_RTP_SENT_STREAM
|
// #define SAVE_RTP_SENT_STREAM
|
||||||
@@ -11,7 +12,7 @@
|
|||||||
RtpVideoSender::RtpVideoSender() {}
|
RtpVideoSender::RtpVideoSender() {}
|
||||||
|
|
||||||
RtpVideoSender::RtpVideoSender(std::shared_ptr<IOStatistics> io_statistics)
|
RtpVideoSender::RtpVideoSender(std::shared_ptr<IOStatistics> io_statistics)
|
||||||
: io_statistics_(io_statistics) {
|
: ssrc_(GenerateUniqueSsrc()), io_statistics_(io_statistics) {
|
||||||
SetPeriod(std::chrono::milliseconds(5));
|
SetPeriod(std::chrono::milliseconds(5));
|
||||||
#ifdef SAVE_RTP_SENT_STREAM
|
#ifdef SAVE_RTP_SENT_STREAM
|
||||||
file_rtp_sent_ = fopen("rtp_sent_stream.h264", "w+b");
|
file_rtp_sent_ = fopen("rtp_sent_stream.h264", "w+b");
|
||||||
@@ -26,6 +27,8 @@ RtpVideoSender::~RtpVideoSender() {
|
|||||||
rtp_statistics_->Stop();
|
rtp_statistics_->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSRCManager::Instance().DeleteSsrc(ssrc_);
|
||||||
|
|
||||||
#ifdef SAVE_RTP_SENT_STREAM
|
#ifdef SAVE_RTP_SENT_STREAM
|
||||||
if (file_rtp_sent_) {
|
if (file_rtp_sent_) {
|
||||||
fflush(file_rtp_sent_);
|
fflush(file_rtp_sent_);
|
||||||
@@ -51,12 +54,26 @@ void RtpVideoSender::SetSendDataFunc(
|
|||||||
data_send_func_ = data_send_func;
|
data_send_func_ = data_send_func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RtpVideoSender::SetOnSentPacketFunc(
|
||||||
|
std::function<void(const webrtc::RtpPacketToSend&)> on_sent_packet_func) {
|
||||||
|
on_sent_packet_func_ = on_sent_packet_func;
|
||||||
|
}
|
||||||
|
|
||||||
int RtpVideoSender::SendRtpPacket(RtpPacket& rtp_packet) {
|
int RtpVideoSender::SendRtpPacket(RtpPacket& rtp_packet) {
|
||||||
if (!data_send_func_) {
|
if (!data_send_func_) {
|
||||||
LOG_ERROR("data_send_func_ is nullptr");
|
LOG_ERROR("data_send_func_ is nullptr");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (on_sent_packet_func_) {
|
||||||
|
webrtc::RtpPacketToSend rtp_packet_to_send;
|
||||||
|
rtp_packet_to_send.SetSequenceNumber(rtp_packet.SequenceNumber());
|
||||||
|
rtp_packet_to_send.SetSsrc(rtp_packet.Ssrc());
|
||||||
|
rtp_packet_to_send.set_transport_sequence_number(transport_seq_++);
|
||||||
|
rtp_packet_to_send.set_packet_type(webrtc::RtpPacketMediaType::kVideo);
|
||||||
|
on_sent_packet_func_(rtp_packet_to_send);
|
||||||
|
}
|
||||||
|
|
||||||
if (0 != data_send_func_((const char*)rtp_packet.Buffer().data(),
|
if (0 != data_send_func_((const char*)rtp_packet.Buffer().data(),
|
||||||
rtp_packet.Size())) {
|
rtp_packet.Size())) {
|
||||||
// LOG_ERROR("Send rtp packet failed");
|
// LOG_ERROR("Send rtp packet failed");
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "ringbuffer.h"
|
#include "ringbuffer.h"
|
||||||
#include "rtcp_sender_report.h"
|
#include "rtcp_sender_report.h"
|
||||||
#include "rtp_packet.h"
|
#include "rtp_packet.h"
|
||||||
|
#include "rtp_packet_to_send.h"
|
||||||
#include "rtp_statistics.h"
|
#include "rtp_statistics.h"
|
||||||
#include "thread_base.h"
|
#include "thread_base.h"
|
||||||
|
|
||||||
@@ -19,6 +20,9 @@ class RtpVideoSender : public ThreadBase {
|
|||||||
public:
|
public:
|
||||||
void Enqueue(std::vector<RtpPacket> &rtp_packets);
|
void Enqueue(std::vector<RtpPacket> &rtp_packets);
|
||||||
void SetSendDataFunc(std::function<int(const char *, size_t)> data_send_func);
|
void SetSendDataFunc(std::function<int(const char *, size_t)> data_send_func);
|
||||||
|
void SetOnSentPacketFunc(
|
||||||
|
std::function<void(const webrtc::RtpPacketToSend &)> on_sent_packet_func);
|
||||||
|
uint32_t GetSsrc() { return ssrc_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int SendRtpPacket(RtpPacket &rtp_packet);
|
int SendRtpPacket(RtpPacket &rtp_packet);
|
||||||
@@ -31,9 +35,12 @@ class RtpVideoSender : public ThreadBase {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::function<int(const char *, size_t)> data_send_func_ = nullptr;
|
std::function<int(const char *, size_t)> data_send_func_ = nullptr;
|
||||||
|
std::function<void(const webrtc::RtpPacketToSend &)> on_sent_packet_func_ =
|
||||||
|
nullptr;
|
||||||
RingBuffer<RtpPacket> rtp_packe_queue_;
|
RingBuffer<RtpPacket> rtp_packe_queue_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
uint32_t ssrc_ = 0;
|
||||||
std::unique_ptr<RtpStatistics> rtp_statistics_ = nullptr;
|
std::unique_ptr<RtpStatistics> rtp_statistics_ = nullptr;
|
||||||
std::shared_ptr<IOStatistics> io_statistics_ = nullptr;
|
std::shared_ptr<IOStatistics> io_statistics_ = nullptr;
|
||||||
uint32_t last_send_bytes_ = 0;
|
uint32_t last_send_bytes_ = 0;
|
||||||
@@ -41,6 +48,9 @@ class RtpVideoSender : public ThreadBase {
|
|||||||
uint32_t total_rtp_payload_sent_ = 0;
|
uint32_t total_rtp_payload_sent_ = 0;
|
||||||
uint32_t total_rtp_packets_sent_ = 0;
|
uint32_t total_rtp_packets_sent_ = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int64_t transport_seq_ = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FILE *file_rtp_sent_ = nullptr;
|
FILE *file_rtp_sent_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,17 +5,19 @@
|
|||||||
VideoChannelReceive::VideoChannelReceive() {}
|
VideoChannelReceive::VideoChannelReceive() {}
|
||||||
|
|
||||||
VideoChannelReceive::VideoChannelReceive(
|
VideoChannelReceive::VideoChannelReceive(
|
||||||
std::shared_ptr<IceAgent> ice_agent,
|
std::shared_ptr<webrtc::Clock> clock, std::shared_ptr<IceAgent> ice_agent,
|
||||||
std::shared_ptr<IOStatistics> ice_io_statistics,
|
std::shared_ptr<IOStatistics> ice_io_statistics,
|
||||||
std::function<void(VideoFrame &)> on_receive_complete_frame)
|
std::function<void(VideoFrame &)> on_receive_complete_frame)
|
||||||
: ice_agent_(ice_agent),
|
: ice_agent_(ice_agent),
|
||||||
ice_io_statistics_(ice_io_statistics),
|
ice_io_statistics_(ice_io_statistics),
|
||||||
on_receive_complete_frame_(on_receive_complete_frame) {}
|
on_receive_complete_frame_(on_receive_complete_frame),
|
||||||
|
clock_(clock) {}
|
||||||
|
|
||||||
VideoChannelReceive::~VideoChannelReceive() {}
|
VideoChannelReceive::~VideoChannelReceive() {}
|
||||||
|
|
||||||
void VideoChannelReceive::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
void VideoChannelReceive::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||||
rtp_video_receiver_ = std::make_unique<RtpVideoReceiver>(ice_io_statistics_);
|
rtp_video_receiver_ =
|
||||||
|
std::make_unique<RtpVideoReceiver>(clock_, ice_io_statistics_);
|
||||||
rtp_video_receiver_->SetOnReceiveCompleteFrame(
|
rtp_video_receiver_->SetOnReceiveCompleteFrame(
|
||||||
[this](VideoFrame &video_frame) -> void {
|
[this](VideoFrame &video_frame) -> void {
|
||||||
on_receive_complete_frame_(video_frame);
|
on_receive_complete_frame_(video_frame);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#ifndef _VIDEO_CHANNEL_RECEIVE_H_
|
#ifndef _VIDEO_CHANNEL_RECEIVE_H_
|
||||||
#define _VIDEO_CHANNEL_RECEIVE_H_
|
#define _VIDEO_CHANNEL_RECEIVE_H_
|
||||||
|
|
||||||
|
#include "clock.h"
|
||||||
#include "ice_agent.h"
|
#include "ice_agent.h"
|
||||||
#include "rtp_video_receiver.h"
|
#include "rtp_video_receiver.h"
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ class VideoChannelReceive {
|
|||||||
public:
|
public:
|
||||||
VideoChannelReceive();
|
VideoChannelReceive();
|
||||||
VideoChannelReceive(
|
VideoChannelReceive(
|
||||||
std::shared_ptr<IceAgent> ice_agent,
|
std::shared_ptr<webrtc::Clock> clock, std::shared_ptr<IceAgent> ice_agent,
|
||||||
std::shared_ptr<IOStatistics> ice_io_statistics,
|
std::shared_ptr<IOStatistics> ice_io_statistics,
|
||||||
std::function<void(VideoFrame &)> on_receive_complete_frame);
|
std::function<void(VideoFrame &)> on_receive_complete_frame);
|
||||||
|
|
||||||
@@ -31,6 +32,9 @@ class VideoChannelReceive {
|
|||||||
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
||||||
std::unique_ptr<RtpVideoReceiver> rtp_video_receiver_ = nullptr;
|
std::unique_ptr<RtpVideoReceiver> rtp_video_receiver_ = nullptr;
|
||||||
std::function<void(VideoFrame &)> on_receive_complete_frame_ = nullptr;
|
std::function<void(VideoFrame &)> on_receive_complete_frame_ = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<Clock> clock_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
#include "video_channel_send.h"
|
#include "video_channel_send.h"
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "rtc_base/network/sent_packet.h"
|
||||||
|
|
||||||
VideoChannelSend::VideoChannelSend() {}
|
VideoChannelSend::VideoChannelSend() {}
|
||||||
|
|
||||||
VideoChannelSend::~VideoChannelSend() {}
|
VideoChannelSend::~VideoChannelSend() {}
|
||||||
|
|
||||||
VideoChannelSend::VideoChannelSend(
|
VideoChannelSend::VideoChannelSend(
|
||||||
std::shared_ptr<IceAgent> ice_agent,
|
std::shared_ptr<webrtc::Clock> clock, std::shared_ptr<IceAgent> ice_agent,
|
||||||
std::shared_ptr<IOStatistics> ice_io_statistics)
|
std::shared_ptr<IOStatistics> ice_io_statistics)
|
||||||
: ice_agent_(ice_agent), ice_io_statistics_(ice_io_statistics){};
|
: ice_agent_(ice_agent),
|
||||||
|
ice_io_statistics_(ice_io_statistics),
|
||||||
|
clock_(clock){};
|
||||||
|
|
||||||
void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||||
controller_ = std::make_unique<CongestionControl>();
|
controller_ = std::make_unique<CongestionControl>();
|
||||||
|
|
||||||
rtp_packetizer_ = RtpPacketizer::Create(payload_type);
|
|
||||||
rtp_video_sender_ = std::make_unique<RtpVideoSender>(ice_io_statistics_);
|
rtp_video_sender_ = std::make_unique<RtpVideoSender>(ice_io_statistics_);
|
||||||
|
rtp_packetizer_ =
|
||||||
|
RtpPacketizer::Create(payload_type, rtp_video_sender_->GetSsrc());
|
||||||
rtp_video_sender_->SetSendDataFunc(
|
rtp_video_sender_->SetSendDataFunc(
|
||||||
[this](const char* data, size_t size) -> int {
|
[this](const char* data, size_t size) -> int {
|
||||||
if (!ice_agent_) {
|
if (!ice_agent_) {
|
||||||
@@ -33,9 +37,31 @@ void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ice_io_statistics_->UpdateVideoOutboundBytes((uint32_t)size);
|
ice_io_statistics_->UpdateVideoOutboundBytes((uint32_t)size);
|
||||||
|
|
||||||
return ice_agent_->Send(data, size);
|
return ice_agent_->Send(data, size);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rtp_video_sender_->SetOnSentPacketFunc(
|
||||||
|
[this](const webrtc::RtpPacketToSend& packet) -> void {
|
||||||
|
webrtc::PacedPacketInfo pacing_info;
|
||||||
|
size_t transport_overhead_bytes_per_packet_ = 0;
|
||||||
|
webrtc::Timestamp creation_time =
|
||||||
|
webrtc::Timestamp::Millis(clock_->TimeInMilliseconds());
|
||||||
|
transport_feedback_adapter_.AddPacket(
|
||||||
|
packet, pacing_info, transport_overhead_bytes_per_packet_,
|
||||||
|
creation_time);
|
||||||
|
|
||||||
|
rtc::SentPacket sent_packet;
|
||||||
|
sent_packet.packet_id = packet.transport_sequence_number().value();
|
||||||
|
sent_packet.send_time_ms = clock_->TimeInMilliseconds();
|
||||||
|
sent_packet.info.included_in_feedback = true;
|
||||||
|
sent_packet.info.included_in_allocation = true;
|
||||||
|
sent_packet.info.packet_size_bytes = packet.size();
|
||||||
|
sent_packet.info.packet_type = rtc::PacketType::kData;
|
||||||
|
|
||||||
|
transport_feedback_adapter_.ProcessSentPacket(sent_packet);
|
||||||
|
});
|
||||||
|
|
||||||
rtp_video_sender_->Start();
|
rtp_video_sender_->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +97,8 @@ void VideoChannelSend::HandleTransportPacketsFeedback(
|
|||||||
// if (transport_is_ecn_capable_) {
|
// if (transport_is_ecn_capable_) {
|
||||||
// // If transport does not support ECN, packets should not be sent as
|
// // If transport does not support ECN, packets should not be sent as
|
||||||
// ECT(1).
|
// ECT(1).
|
||||||
// // TODO: bugs.webrtc.org/42225697 - adapt to ECN feedback and continue to
|
// // TODO: bugs.webrtc.org/42225697 - adapt to ECN feedback and
|
||||||
|
// continue to
|
||||||
// // send packets as ECT(1) if transport is ECN capable.
|
// // send packets as ECT(1) if transport is ECN capable.
|
||||||
// transport_is_ecn_capable_ = false;
|
// transport_is_ecn_capable_ = false;
|
||||||
// LOG_INFO("Transport is {} ECN capable. Stop sending ECT(1)",
|
// LOG_INFO("Transport is {} ECN capable. Stop sending ECT(1)",
|
||||||
@@ -103,8 +130,8 @@ void VideoChannelSend::PostUpdates(webrtc::NetworkControlUpdate update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VideoChannelSend::UpdateControlState() {
|
void VideoChannelSend::UpdateControlState() {
|
||||||
// std::optional<TargetTransferRate> update = control_handler_->GetUpdate();
|
// std::optional<TargetTransferRate> update =
|
||||||
// if (!update) return;
|
// control_handler_->GetUpdate(); if (!update) return;
|
||||||
// retransmission_rate_limiter_.SetMaxRate(update->target_rate.bps());
|
// retransmission_rate_limiter_.SetMaxRate(update->target_rate.bps());
|
||||||
// observer_->OnTargetTransferRate(*update);
|
// observer_->OnTargetTransferRate(*update);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#define _VIDEO_CHANNEL_SEND_H_
|
#define _VIDEO_CHANNEL_SEND_H_
|
||||||
|
|
||||||
#include "api/transport/network_types.h"
|
#include "api/transport/network_types.h"
|
||||||
|
#include "clock.h"
|
||||||
#include "congestion_control.h"
|
#include "congestion_control.h"
|
||||||
#include "congestion_control_feedback.h"
|
#include "congestion_control_feedback.h"
|
||||||
#include "ice_agent.h"
|
#include "ice_agent.h"
|
||||||
@@ -19,7 +20,8 @@
|
|||||||
class VideoChannelSend {
|
class VideoChannelSend {
|
||||||
public:
|
public:
|
||||||
VideoChannelSend();
|
VideoChannelSend();
|
||||||
VideoChannelSend(std::shared_ptr<IceAgent> ice_agent,
|
VideoChannelSend(std::shared_ptr<webrtc::Clock> clock,
|
||||||
|
std::shared_ptr<IceAgent> ice_agent,
|
||||||
std::shared_ptr<IOStatistics> ice_io_statistics);
|
std::shared_ptr<IOStatistics> ice_io_statistics);
|
||||||
~VideoChannelSend();
|
~VideoChannelSend();
|
||||||
|
|
||||||
@@ -47,6 +49,7 @@ class VideoChannelSend {
|
|||||||
std::unique_ptr<RtpVideoSender> rtp_video_sender_ = nullptr;
|
std::unique_ptr<RtpVideoSender> rtp_video_sender_ = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::shared_ptr<Clock> clock_;
|
||||||
int64_t current_offset_ = std::numeric_limits<int64_t>::min();
|
int64_t current_offset_ = std::numeric_limits<int64_t>::min();
|
||||||
// Used by RFC 8888 congestion control feedback to track base time.
|
// Used by RFC 8888 congestion control feedback to track base time.
|
||||||
std::optional<uint32_t> last_feedback_compact_ntp_time_;
|
std::optional<uint32_t> last_feedback_compact_ntp_time_;
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ NetworkControlUpdate CongestionControl::OnTransportPacketsFeedback(
|
|||||||
if (report.feedback_time > next_loss_update_) {
|
if (report.feedback_time > next_loss_update_) {
|
||||||
next_loss_update_ =
|
next_loss_update_ =
|
||||||
report.feedback_time + TimeDelta::Millis(kLossUpdateInterval);
|
report.feedback_time + TimeDelta::Millis(kLossUpdateInterval);
|
||||||
|
LOG_WARN("lost_packets_since_last_loss_update_ = [{}]",
|
||||||
|
lost_packets_since_last_loss_update_);
|
||||||
bandwidth_estimation_->UpdatePacketsLost(
|
bandwidth_estimation_->UpdatePacketsLost(
|
||||||
lost_packets_since_last_loss_update_,
|
lost_packets_since_last_loss_update_,
|
||||||
expected_packets_since_last_loss_update_, report.feedback_time);
|
expected_packets_since_last_loss_update_, report.feedback_time);
|
||||||
|
|||||||
@@ -297,6 +297,9 @@ bool CongestionControlFeedback::Parse(const rtcp::CommonHeader& packet) {
|
|||||||
|
|
||||||
uint16_t seq_no = base_seqno + i;
|
uint16_t seq_no = base_seqno + i;
|
||||||
bool received = (packet_info & 0x8000);
|
bool received = (packet_info & 0x8000);
|
||||||
|
TimeDelta arrival_time_offset = AtoToTimeDelta(packet_info);
|
||||||
|
LOG_ERROR("received:{} = [{} {}]", received,
|
||||||
|
ToString(arrival_time_offset), arrival_time_offset.IsFinite());
|
||||||
packets_.push_back(
|
packets_.push_back(
|
||||||
{ssrc, seq_no,
|
{ssrc, seq_no,
|
||||||
received ? AtoToTimeDelta(packet_info) : TimeDelta::MinusInfinity(),
|
received ? AtoToTimeDelta(packet_info) : TimeDelta::MinusInfinity(),
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ void CongestionControlFeedbackGenerator::SendFeedback(Timestamp now) {
|
|||||||
for (auto& [unused, tracker] : feedback_trackers_) {
|
for (auto& [unused, tracker] : feedback_trackers_) {
|
||||||
tracker.AddPacketsToFeedback(now, rtcp_packet_info);
|
tracker.AddPacketsToFeedback(now, rtcp_packet_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
marker_bit_seen_ = false;
|
marker_bit_seen_ = false;
|
||||||
first_arrival_time_since_feedback_ = std::nullopt;
|
first_arrival_time_since_feedback_ = std::nullopt;
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ void SendSideBandwidthEstimation::SetBitrates(
|
|||||||
|
|
||||||
void SendSideBandwidthEstimation::SetSendBitrate(DataRate bitrate,
|
void SendSideBandwidthEstimation::SetSendBitrate(DataRate bitrate,
|
||||||
Timestamp at_time) {
|
Timestamp at_time) {
|
||||||
|
LOG_ERROR("3");
|
||||||
// Reset to avoid being capped by the estimate.
|
// Reset to avoid being capped by the estimate.
|
||||||
delay_based_limit_ = DataRate::PlusInfinity();
|
delay_based_limit_ = DataRate::PlusInfinity();
|
||||||
UpdateTargetBitrate(bitrate, at_time);
|
UpdateTargetBitrate(bitrate, at_time);
|
||||||
@@ -244,6 +245,7 @@ DataRate SendSideBandwidthEstimation::GetEstimatedLinkCapacity() const {
|
|||||||
|
|
||||||
void SendSideBandwidthEstimation::UpdateReceiverEstimate(Timestamp at_time,
|
void SendSideBandwidthEstimation::UpdateReceiverEstimate(Timestamp at_time,
|
||||||
DataRate bandwidth) {
|
DataRate bandwidth) {
|
||||||
|
LOG_ERROR("6");
|
||||||
// TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no
|
// TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no
|
||||||
// limitation.
|
// limitation.
|
||||||
receiver_limit_ = bandwidth.IsZero() ? DataRate::PlusInfinity() : bandwidth;
|
receiver_limit_ = bandwidth.IsZero() ? DataRate::PlusInfinity() : bandwidth;
|
||||||
@@ -252,6 +254,7 @@ void SendSideBandwidthEstimation::UpdateReceiverEstimate(Timestamp at_time,
|
|||||||
|
|
||||||
void SendSideBandwidthEstimation::UpdateDelayBasedEstimate(Timestamp at_time,
|
void SendSideBandwidthEstimation::UpdateDelayBasedEstimate(Timestamp at_time,
|
||||||
DataRate bitrate) {
|
DataRate bitrate) {
|
||||||
|
LOG_ERROR("7");
|
||||||
link_capacity_.UpdateDelayBasedEstimate(at_time, bitrate);
|
link_capacity_.UpdateDelayBasedEstimate(at_time, bitrate);
|
||||||
// TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no
|
// TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no
|
||||||
// limitation.
|
// limitation.
|
||||||
@@ -342,7 +345,9 @@ void SendSideBandwidthEstimation::UpdateRtt(TimeDelta rtt, Timestamp at_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
|
void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
|
||||||
|
LOG_ERROR("1");
|
||||||
if (rtt_backoff_.IsRttAboveLimit()) {
|
if (rtt_backoff_.IsRttAboveLimit()) {
|
||||||
|
LOG_ERROR("11");
|
||||||
if (at_time - time_last_decrease_ >= rtt_backoff_.drop_interval_ &&
|
if (at_time - time_last_decrease_ >= rtt_backoff_.drop_interval_ &&
|
||||||
current_target_ > rtt_backoff_.bandwidth_floor_) {
|
current_target_ > rtt_backoff_.bandwidth_floor_) {
|
||||||
time_last_decrease_ = at_time;
|
time_last_decrease_ = at_time;
|
||||||
@@ -357,7 +362,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
|
|||||||
ApplyTargetLimits(at_time);
|
ApplyTargetLimits(at_time);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LOG_ERROR("111");
|
||||||
// We trust the REMB and/or delay-based estimate during the first 2 seconds if
|
// We trust the REMB and/or delay-based estimate during the first 2 seconds if
|
||||||
// we haven't had any packet loss reported, to allow startup bitrate probing.
|
// we haven't had any packet loss reported, to allow startup bitrate probing.
|
||||||
if (last_fraction_loss_ == 0 && IsInStartPhase(at_time)) {
|
if (last_fraction_loss_ == 0 && IsInStartPhase(at_time)) {
|
||||||
@@ -376,22 +381,28 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOG_ERROR("112");
|
||||||
UpdateMinHistory(at_time);
|
UpdateMinHistory(at_time);
|
||||||
if (last_loss_packet_report_.IsInfinite()) {
|
if (last_loss_packet_report_.IsInfinite()) {
|
||||||
// No feedback received.
|
// No feedback received.
|
||||||
// TODO(srte): This is likely redundant in most cases.
|
// TODO(srte): This is likely redundant in most cases.
|
||||||
|
LOG_ERROR("113");
|
||||||
ApplyTargetLimits(at_time);
|
ApplyTargetLimits(at_time);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeDelta time_since_loss_packet_report = at_time - last_loss_packet_report_;
|
TimeDelta time_since_loss_packet_report = at_time - last_loss_packet_report_;
|
||||||
if (time_since_loss_packet_report < 1.2 * kMaxRtcpFeedbackInterval) {
|
if (time_since_loss_packet_report < 1.2 * kMaxRtcpFeedbackInterval) {
|
||||||
|
LOG_ERROR("114");
|
||||||
// We only care about loss above a given bitrate threshold.
|
// We only care about loss above a given bitrate threshold.
|
||||||
float loss = last_fraction_loss_ / 256.0f;
|
float loss = last_fraction_loss_ / 256.0f;
|
||||||
|
LOG_ERROR("current_target_ = [{}], loss = [{}]", ToString(current_target_),
|
||||||
|
loss);
|
||||||
// We only make decisions based on loss when the bitrate is above a
|
// We only make decisions based on loss when the bitrate is above a
|
||||||
// threshold. This is a crude way of handling loss which is uncorrelated
|
// threshold. This is a crude way of handling loss which is uncorrelated
|
||||||
// to congestion.
|
// to congestion.
|
||||||
if (current_target_ < bitrate_threshold_ || loss <= low_loss_threshold_) {
|
if (current_target_ < bitrate_threshold_ || loss <= low_loss_threshold_) {
|
||||||
|
LOG_ERROR("115");
|
||||||
// Loss < 2%: Increase rate by 8% of the min bitrate in the last
|
// Loss < 2%: Increase rate by 8% of the min bitrate in the last
|
||||||
// kBweIncreaseInterval.
|
// kBweIncreaseInterval.
|
||||||
// Note that by remembering the bitrate over the last second one can
|
// Note that by remembering the bitrate over the last second one can
|
||||||
@@ -412,14 +423,18 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
|
|||||||
UpdateTargetBitrate(new_bitrate, at_time);
|
UpdateTargetBitrate(new_bitrate, at_time);
|
||||||
return;
|
return;
|
||||||
} else if (current_target_ > bitrate_threshold_) {
|
} else if (current_target_ > bitrate_threshold_) {
|
||||||
|
LOG_ERROR("116");
|
||||||
if (loss <= high_loss_threshold_) {
|
if (loss <= high_loss_threshold_) {
|
||||||
|
LOG_ERROR("117");
|
||||||
// Loss between 2% - 10%: Do nothing.
|
// Loss between 2% - 10%: Do nothing.
|
||||||
} else {
|
} else {
|
||||||
|
LOG_ERROR("118");
|
||||||
// Loss > 10%: Limit the rate decreases to once a kBweDecreaseInterval
|
// Loss > 10%: Limit the rate decreases to once a kBweDecreaseInterval
|
||||||
// + rtt.
|
// + rtt.
|
||||||
if (!has_decreased_since_last_fraction_loss_ &&
|
if (!has_decreased_since_last_fraction_loss_ &&
|
||||||
(at_time - time_last_decrease_) >=
|
(at_time - time_last_decrease_) >=
|
||||||
(kBweDecreaseInterval + last_round_trip_time_)) {
|
(kBweDecreaseInterval + last_round_trip_time_)) {
|
||||||
|
LOG_ERROR("119");
|
||||||
time_last_decrease_ = at_time;
|
time_last_decrease_ = at_time;
|
||||||
|
|
||||||
// Reduce rate:
|
// Reduce rate:
|
||||||
@@ -436,6 +451,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOG_ERROR("120");
|
||||||
// TODO(srte): This is likely redundant in most cases.
|
// TODO(srte): This is likely redundant in most cases.
|
||||||
ApplyTargetLimits(at_time);
|
ApplyTargetLimits(at_time);
|
||||||
}
|
}
|
||||||
@@ -447,6 +463,7 @@ void SendSideBandwidthEstimation::UpdatePropagationRtt(
|
|||||||
|
|
||||||
void SendSideBandwidthEstimation::OnSentPacket(const SentPacket& sent_packet) {
|
void SendSideBandwidthEstimation::OnSentPacket(const SentPacket& sent_packet) {
|
||||||
// Only feedback-triggering packets will be reported here.
|
// Only feedback-triggering packets will be reported here.
|
||||||
|
LOG_ERROR("5");
|
||||||
rtt_backoff_.last_packet_sent_ = sent_packet.send_time;
|
rtt_backoff_.last_packet_sent_ = sent_packet.send_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,6 +512,7 @@ void SendSideBandwidthEstimation::MaybeLogLowBitrateWarning(DataRate bitrate,
|
|||||||
void SendSideBandwidthEstimation::UpdateTargetBitrate(DataRate new_bitrate,
|
void SendSideBandwidthEstimation::UpdateTargetBitrate(DataRate new_bitrate,
|
||||||
Timestamp at_time) {
|
Timestamp at_time) {
|
||||||
new_bitrate = std::min(new_bitrate, GetUpperLimit());
|
new_bitrate = std::min(new_bitrate, GetUpperLimit());
|
||||||
|
LOG_WARN("new_bitrate: [{}]", ToString(new_bitrate).c_str());
|
||||||
if (new_bitrate < min_bitrate_configured_) {
|
if (new_bitrate < min_bitrate_configured_) {
|
||||||
MaybeLogLowBitrateWarning(new_bitrate, at_time);
|
MaybeLogLowBitrateWarning(new_bitrate, at_time);
|
||||||
new_bitrate = min_bitrate_configured_;
|
new_bitrate = min_bitrate_configured_;
|
||||||
@@ -504,6 +522,7 @@ void SendSideBandwidthEstimation::UpdateTargetBitrate(DataRate new_bitrate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SendSideBandwidthEstimation::ApplyTargetLimits(Timestamp at_time) {
|
void SendSideBandwidthEstimation::ApplyTargetLimits(Timestamp at_time) {
|
||||||
|
LOG_ERROR("2");
|
||||||
UpdateTargetBitrate(current_target_, at_time);
|
UpdateTargetBitrate(current_target_, at_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ TransportFeedbackAdapter::ProcessCongestionControlFeedback(
|
|||||||
int failed_lookups = 0;
|
int failed_lookups = 0;
|
||||||
bool supports_ecn = true;
|
bool supports_ecn = true;
|
||||||
std::vector<PacketResult> packet_result_vector;
|
std::vector<PacketResult> packet_result_vector;
|
||||||
|
LOG_ERROR("20");
|
||||||
for (const rtcp::CongestionControlFeedback::PacketInfo& packet_info :
|
for (const rtcp::CongestionControlFeedback::PacketInfo& packet_info :
|
||||||
feedback.packets()) {
|
feedback.packets()) {
|
||||||
std::optional<PacketFeedback> packet_feedback = RetrievePacketFeedback(
|
std::optional<PacketFeedback> packet_feedback = RetrievePacketFeedback(
|
||||||
@@ -277,7 +278,9 @@ TransportFeedbackAdapter::ProcessCongestionControlFeedback(
|
|||||||
}
|
}
|
||||||
PacketResult result;
|
PacketResult result;
|
||||||
result.sent_packet = packet_feedback->sent;
|
result.sent_packet = packet_feedback->sent;
|
||||||
|
LOG_ERROR("21");
|
||||||
if (packet_info.arrival_time_offset.IsFinite()) {
|
if (packet_info.arrival_time_offset.IsFinite()) {
|
||||||
|
LOG_ERROR("22");
|
||||||
result.receive_time = current_offset_ - packet_info.arrival_time_offset;
|
result.receive_time = current_offset_ - packet_info.arrival_time_offset;
|
||||||
supports_ecn &= packet_info.ecn != EcnMarking::kNotEct;
|
supports_ecn &= packet_info.ecn != EcnMarking::kNotEct;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ class RTCPSender {
|
|||||||
RTCPSender(std::function<int(const uint8_t*, size_t)> callback,
|
RTCPSender(std::function<int(const uint8_t*, size_t)> callback,
|
||||||
size_t max_packet_size)
|
size_t max_packet_size)
|
||||||
: callback_(callback), max_packet_size_(max_packet_size) {
|
: callback_(callback), max_packet_size_(max_packet_size) {
|
||||||
if (max_packet_size > IP_PACKET_SIZE) {
|
if (max_packet_size >= IP_PACKET_SIZE) {
|
||||||
LOG_ERROR("max_packet_size must be less than IP_PACKET_SIZE");
|
LOG_ERROR("max_packet_size must be less than IP_PACKET_SIZE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~RTCPSender() {
|
~RTCPSender() {
|
||||||
if (index_ == 0) {
|
if (index_ != 0) {
|
||||||
LOG_ERROR("Unsent rtcp packet");
|
LOG_ERROR("Unsent rtcp packet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
#include "rtp_packetizer_generic.h"
|
#include "rtp_packetizer_generic.h"
|
||||||
#include "rtp_packetizer_h264.h"
|
#include "rtp_packetizer_h264.h"
|
||||||
|
|
||||||
std::unique_ptr<RtpPacketizer> RtpPacketizer::Create(uint32_t payload_type) {
|
std::unique_ptr<RtpPacketizer> RtpPacketizer::Create(uint32_t payload_type,
|
||||||
|
uint32_t ssrc) {
|
||||||
switch (payload_type) {
|
switch (payload_type) {
|
||||||
case rtp::PAYLOAD_TYPE::H264:
|
case rtp::PAYLOAD_TYPE::H264:
|
||||||
return std::make_unique<RtpPacketizerH264>();
|
return std::make_unique<RtpPacketizerH264>(ssrc);
|
||||||
case rtp::PAYLOAD_TYPE::AV1:
|
case rtp::PAYLOAD_TYPE::AV1:
|
||||||
return std::make_unique<RtpPacketizerAv1>();
|
return std::make_unique<RtpPacketizerAv1>(ssrc);
|
||||||
default:
|
default:
|
||||||
return std::make_unique<RtpPacketizerGeneric>();
|
return std::make_unique<RtpPacketizerGeneric>(ssrc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
class RtpPacketizer {
|
class RtpPacketizer {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<RtpPacketizer> Create(uint32_t payload_type);
|
static std::unique_ptr<RtpPacketizer> Create(uint32_t payload_type,
|
||||||
|
uint32_t ssrc);
|
||||||
|
|
||||||
virtual ~RtpPacketizer() = default;
|
virtual ~RtpPacketizer() = default;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "rtp_packetizer_av1.h"
|
#include "rtp_packetizer_av1.h"
|
||||||
|
|
||||||
RtpPacketizerAv1::RtpPacketizerAv1() {}
|
RtpPacketizerAv1::RtpPacketizerAv1(uint32_t ssrc) {}
|
||||||
|
|
||||||
RtpPacketizerAv1::~RtpPacketizerAv1() {}
|
RtpPacketizerAv1::~RtpPacketizerAv1() {}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
class RtpPacketizerAv1 : public RtpPacketizer {
|
class RtpPacketizerAv1 : public RtpPacketizer {
|
||||||
public:
|
public:
|
||||||
RtpPacketizerAv1();
|
RtpPacketizerAv1(uint32_t ssrc);
|
||||||
|
|
||||||
virtual ~RtpPacketizerAv1();
|
virtual ~RtpPacketizerAv1();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "rtp_packetizer_generic.h"
|
#include "rtp_packetizer_generic.h"
|
||||||
|
|
||||||
RtpPacketizerGeneric::RtpPacketizerGeneric()
|
RtpPacketizerGeneric::RtpPacketizerGeneric(uint32_t ssrc)
|
||||||
: version_(kRtpVersion),
|
: version_(kRtpVersion),
|
||||||
has_padding_(false),
|
has_padding_(false),
|
||||||
has_extension_(true),
|
has_extension_(true),
|
||||||
@@ -9,7 +9,7 @@ RtpPacketizerGeneric::RtpPacketizerGeneric()
|
|||||||
payload_type_(rtp::PAYLOAD_TYPE::DATA),
|
payload_type_(rtp::PAYLOAD_TYPE::DATA),
|
||||||
sequence_number_(0),
|
sequence_number_(0),
|
||||||
timestamp_(0),
|
timestamp_(0),
|
||||||
ssrc_(0),
|
ssrc_(ssrc),
|
||||||
profile_(0),
|
profile_(0),
|
||||||
extension_profile_(0),
|
extension_profile_(0),
|
||||||
extension_len_(0),
|
extension_len_(0),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
class RtpPacketizerGeneric : public RtpPacketizer {
|
class RtpPacketizerGeneric : public RtpPacketizer {
|
||||||
public:
|
public:
|
||||||
RtpPacketizerGeneric();
|
RtpPacketizerGeneric(uint32_t ssrc);
|
||||||
|
|
||||||
virtual ~RtpPacketizerGeneric();
|
virtual ~RtpPacketizerGeneric();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "rtp_packetizer_h264.h"
|
#include "rtp_packetizer_h264.h"
|
||||||
|
|
||||||
RtpPacketizerH264::RtpPacketizerH264()
|
RtpPacketizerH264::RtpPacketizerH264(uint32_t ssrc)
|
||||||
: version_(kRtpVersion),
|
: version_(kRtpVersion),
|
||||||
has_padding_(false),
|
has_padding_(false),
|
||||||
has_extension_(true),
|
has_extension_(true),
|
||||||
@@ -9,7 +9,7 @@ RtpPacketizerH264::RtpPacketizerH264()
|
|||||||
payload_type_(rtp::PAYLOAD_TYPE::H264),
|
payload_type_(rtp::PAYLOAD_TYPE::H264),
|
||||||
sequence_number_(0),
|
sequence_number_(0),
|
||||||
timestamp_(0),
|
timestamp_(0),
|
||||||
ssrc_(0),
|
ssrc_(ssrc),
|
||||||
profile_(0),
|
profile_(0),
|
||||||
extension_profile_(0),
|
extension_profile_(0),
|
||||||
extension_len_(0),
|
extension_len_(0),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
class RtpPacketizerH264 : public RtpPacketizer {
|
class RtpPacketizerH264 : public RtpPacketizer {
|
||||||
public:
|
public:
|
||||||
RtpPacketizerH264();
|
RtpPacketizerH264(uint32_t ssrc);
|
||||||
|
|
||||||
virtual ~RtpPacketizerH264();
|
virtual ~RtpPacketizerH264();
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ IceTransport::IceTransport(
|
|||||||
remote_user_id_(remote_user_id),
|
remote_user_id_(remote_user_id),
|
||||||
ice_ws_transport_(ice_ws_transmission),
|
ice_ws_transport_(ice_ws_transmission),
|
||||||
on_ice_status_change_(on_ice_status_change),
|
on_ice_status_change_(on_ice_status_change),
|
||||||
user_data_(user_data) {}
|
user_data_(user_data),
|
||||||
|
clock_(webrtc::Clock::GetRealTimeClockShared()) {}
|
||||||
|
|
||||||
IceTransport::~IceTransport() {
|
IceTransport::~IceTransport() {
|
||||||
user_data_ = nullptr;
|
user_data_ = nullptr;
|
||||||
@@ -119,8 +120,8 @@ void IceTransport::InitializeChannels(
|
|||||||
rtp::PAYLOAD_TYPE video_codec_payload_type) {
|
rtp::PAYLOAD_TYPE video_codec_payload_type) {
|
||||||
video_codec_payload_type_ = video_codec_payload_type;
|
video_codec_payload_type_ = video_codec_payload_type;
|
||||||
|
|
||||||
video_channel_send_ =
|
video_channel_send_ = std::make_unique<VideoChannelSend>(clock_, ice_agent_,
|
||||||
std::make_unique<VideoChannelSend>(ice_agent_, ice_io_statistics_);
|
ice_io_statistics_);
|
||||||
audio_channel_send_ =
|
audio_channel_send_ =
|
||||||
std::make_unique<AudioChannelSend>(ice_agent_, ice_io_statistics_);
|
std::make_unique<AudioChannelSend>(ice_agent_, ice_io_statistics_);
|
||||||
data_channel_send_ =
|
data_channel_send_ =
|
||||||
@@ -132,7 +133,7 @@ void IceTransport::InitializeChannels(
|
|||||||
|
|
||||||
std::weak_ptr<IceTransport> weak_self = shared_from_this();
|
std::weak_ptr<IceTransport> weak_self = shared_from_this();
|
||||||
video_channel_receive_ = std::make_unique<VideoChannelReceive>(
|
video_channel_receive_ = std::make_unique<VideoChannelReceive>(
|
||||||
ice_agent_, ice_io_statistics_,
|
clock_, ice_agent_, ice_io_statistics_,
|
||||||
[this, weak_self](VideoFrame &video_frame) {
|
[this, weak_self](VideoFrame &video_frame) {
|
||||||
if (auto self = weak_self.lock()) {
|
if (auto self = weak_self.lock()) {
|
||||||
OnReceiveCompleteFrame(video_frame);
|
OnReceiveCompleteFrame(video_frame);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
// #include "congestion_control.h"
|
// #include "congestion_control.h"
|
||||||
#include "audio_channel_receive.h"
|
#include "audio_channel_receive.h"
|
||||||
#include "audio_channel_send.h"
|
#include "audio_channel_send.h"
|
||||||
|
#include "clock.h"
|
||||||
#include "data_channel_receive.h"
|
#include "data_channel_receive.h"
|
||||||
#include "data_channel_send.h"
|
#include "data_channel_send.h"
|
||||||
#include "ice_agent.h"
|
#include "ice_agent.h"
|
||||||
@@ -219,6 +220,7 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
|||||||
on_receive_net_status_report_ = nullptr;
|
on_receive_net_status_report_ = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::shared_ptr<webrtc::Clock> clock_;
|
||||||
std::unique_ptr<VideoChannelSend> video_channel_send_ = nullptr;
|
std::unique_ptr<VideoChannelSend> video_channel_send_ = nullptr;
|
||||||
std::unique_ptr<VideoChannelReceive> video_channel_receive_ = nullptr;
|
std::unique_ptr<VideoChannelReceive> video_channel_receive_ = nullptr;
|
||||||
std::unique_ptr<AudioChannelSend> audio_channel_send_ = nullptr;
|
std::unique_ptr<AudioChannelSend> audio_channel_send_ = nullptr;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ target("common")
|
|||||||
add_deps("log")
|
add_deps("log")
|
||||||
add_files("src/common/common.cpp",
|
add_files("src/common/common.cpp",
|
||||||
"src/common/rtc_base/*.cc",
|
"src/common/rtc_base/*.cc",
|
||||||
|
"src/common/rtc_base/network/*.cc",
|
||||||
"src/common/rtc_base/numerics/*.cc",
|
"src/common/rtc_base/numerics/*.cc",
|
||||||
"src/common/api/units/*.cc",
|
"src/common/api/units/*.cc",
|
||||||
"src/common/api/transport/*.cc")
|
"src/common/api/transport/*.cc")
|
||||||
|
|||||||
Reference in New Issue
Block a user