mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] set SendBurstInterval and QueueTimeLimit when packet sender created
This commit is contained in:
@@ -93,7 +93,6 @@ void BitrateProber::OnIncomingPacket(DataSize packet_size) {
|
|||||||
|
|
||||||
void BitrateProber::CreateProbeCluster(
|
void BitrateProber::CreateProbeCluster(
|
||||||
const ProbeClusterConfig& cluster_config) {
|
const ProbeClusterConfig& cluster_config) {
|
||||||
LOG_WARN("a1");
|
|
||||||
while (!clusters_.empty() &&
|
while (!clusters_.empty() &&
|
||||||
(cluster_config.at_time - clusters_.front().requested_at >
|
(cluster_config.at_time - clusters_.front().requested_at >
|
||||||
kProbeClusterTimeout ||
|
kProbeClusterTimeout ||
|
||||||
|
|||||||
@@ -92,9 +92,7 @@ PacingController::~PacingController() = default;
|
|||||||
|
|
||||||
void PacingController::CreateProbeClusters(
|
void PacingController::CreateProbeClusters(
|
||||||
rtc::ArrayView<const ProbeClusterConfig> probe_cluster_configs) {
|
rtc::ArrayView<const ProbeClusterConfig> probe_cluster_configs) {
|
||||||
LOG_WARN("b0");
|
|
||||||
for (const ProbeClusterConfig probe_cluster_config : probe_cluster_configs) {
|
for (const ProbeClusterConfig probe_cluster_config : probe_cluster_configs) {
|
||||||
LOG_WARN("b1");
|
|
||||||
prober_.CreateProbeCluster(probe_cluster_config);
|
prober_.CreateProbeCluster(probe_cluster_config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,11 +182,6 @@ void PacingController::EnqueuePacket(std::unique_ptr<RtpPacketToSend> packet) {
|
|||||||
// queue). Flush any pending packets currently in the queue for that stream
|
// queue). Flush any pending packets currently in the queue for that stream
|
||||||
// in order to get the new keyframe out as quickly as possible.
|
// in order to get the new keyframe out as quickly as possible.
|
||||||
packet_queue_.RemovePacketsForSsrc(packet->Ssrc());
|
packet_queue_.RemovePacketsForSsrc(packet->Ssrc());
|
||||||
std::optional<uint32_t> rtx_ssrc =
|
|
||||||
packet_sender_->GetRtxSsrcForMedia(packet->Ssrc());
|
|
||||||
if (rtx_ssrc) {
|
|
||||||
packet_queue_.RemovePacketsForSsrc(*rtx_ssrc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prober_.OnIncomingPacket(DataSize::Bytes(packet->payload_size()));
|
prober_.OnIncomingPacket(DataSize::Bytes(packet->payload_size()));
|
||||||
@@ -399,14 +392,11 @@ void PacingController::ProcessPackets() {
|
|||||||
if (now + early_execute_margin < target_send_time) {
|
if (now + early_execute_margin < target_send_time) {
|
||||||
// We are too early, but if queue is empty still allow draining some debt.
|
// We are too early, but if queue is empty still allow draining some debt.
|
||||||
// Probing is allowed to be sent up to kMinSleepTime early.
|
// Probing is allowed to be sent up to kMinSleepTime early.
|
||||||
LOG_ERROR("!!!!!!! too early, target_send_time {}, now {}, {}",
|
|
||||||
target_send_time.ms(), now.ms(), early_execute_margin.ms());
|
|
||||||
UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(now));
|
UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(now));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_send_time);
|
TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_send_time);
|
||||||
|
|
||||||
if (elapsed_time > TimeDelta::Zero()) {
|
if (elapsed_time > TimeDelta::Zero()) {
|
||||||
UpdateBudgetWithElapsedTime(elapsed_time);
|
UpdateBudgetWithElapsedTime(elapsed_time);
|
||||||
}
|
}
|
||||||
@@ -436,7 +426,6 @@ void PacingController::ProcessPackets() {
|
|||||||
std::unique_ptr<RtpPacketToSend> rtp_packet =
|
std::unique_ptr<RtpPacketToSend> rtp_packet =
|
||||||
GetPendingPacket(pacing_info, target_send_time, now);
|
GetPendingPacket(pacing_info, target_send_time, now);
|
||||||
if (!rtp_packet) {
|
if (!rtp_packet) {
|
||||||
LOG_WARN("rtp_packet == nullptr");
|
|
||||||
// No packet available to send, check if we should send padding.
|
// No packet available to send, check if we should send padding.
|
||||||
if (now - target_send_time > kMaxPaddingReplayDuration) {
|
if (now - target_send_time > kMaxPaddingReplayDuration) {
|
||||||
// The target send time is more than `kMaxPaddingReplayDuration` behind
|
// The target send time is more than `kMaxPaddingReplayDuration` behind
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ void RtpVideoSender::Enqueue(
|
|||||||
for (auto& rtp_packet : rtp_packets) {
|
for (auto& rtp_packet : rtp_packets) {
|
||||||
std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet_to_send(
|
std::unique_ptr<webrtc::RtpPacketToSend> rtp_packet_to_send(
|
||||||
static_cast<webrtc::RtpPacketToSend*>(rtp_packet.release()));
|
static_cast<webrtc::RtpPacketToSend*>(rtp_packet.release()));
|
||||||
rtp_packet_to_send->set_capture_time(
|
rtp_packet_to_send->set_capture_time(clock_->CurrentTime());
|
||||||
webrtc::Timestamp::Millis(capture_timestamp_ms));
|
|
||||||
rtp_packet_to_send->set_transport_sequence_number(transport_seq_++);
|
rtp_packet_to_send->set_transport_sequence_number(transport_seq_++);
|
||||||
rtp_packet_to_send->set_packet_type(webrtc::RtpPacketMediaType::kVideo);
|
rtp_packet_to_send->set_packet_type(webrtc::RtpPacketMediaType::kVideo);
|
||||||
// rtp_packet_queue_.push(std::move(rtp_packet_to_send));
|
// rtp_packet_queue_.push(std::move(rtp_packet_to_send));
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ void IceTransportController::Create(
|
|||||||
packet_sender_ = std::make_shared<PacketSenderImp>(ice_agent, webrtc_clock_);
|
packet_sender_ = std::make_shared<PacketSenderImp>(ice_agent, webrtc_clock_);
|
||||||
packet_sender_->SetPacingRates(DataRate::BitsPerSec(300000),
|
packet_sender_->SetPacingRates(DataRate::BitsPerSec(300000),
|
||||||
DataRate::Zero());
|
DataRate::Zero());
|
||||||
|
packet_sender_->SetSendBurstInterval(TimeDelta::Millis(40));
|
||||||
|
packet_sender_->SetQueueTimeLimit(TimeDelta::Millis(2000));
|
||||||
packet_sender_->SetOnSentPacketFunc(
|
packet_sender_->SetOnSentPacketFunc(
|
||||||
[this](const webrtc::RtpPacketToSend& packet) {
|
[this](const webrtc::RtpPacketToSend& packet) {
|
||||||
if (ice_agent_) {
|
if (ice_agent_) {
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ PacketSenderImp::PacketSenderImp(std::shared_ptr<IceAgent> ice_agent,
|
|||||||
is_started_(false),
|
is_started_(false),
|
||||||
is_shutdown_(false),
|
is_shutdown_(false),
|
||||||
packet_size_(/*alpha=*/0.95),
|
packet_size_(/*alpha=*/0.95),
|
||||||
include_overhead_(false) {}
|
include_overhead_(false),
|
||||||
|
last_send_time_(webrtc::Timestamp::Millis(0)) {}
|
||||||
|
|
||||||
PacketSenderImp::~PacketSenderImp() {}
|
PacketSenderImp::~PacketSenderImp() {}
|
||||||
|
|
||||||
@@ -89,11 +90,6 @@ void PacketSenderImp::EnqueuePackets(
|
|||||||
}
|
}
|
||||||
MaybeProcessPackets(webrtc::Timestamp::MinusInfinity());
|
MaybeProcessPackets(webrtc::Timestamp::MinusInfinity());
|
||||||
});
|
});
|
||||||
|
|
||||||
// webrtc::PacedPacketInfo cluster_info;
|
|
||||||
// for (auto &packet : packets) {
|
|
||||||
// SendPacket(std::move(packet), cluster_info);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketSenderImp::RemovePacketsForSsrc(uint32_t ssrc) {
|
void PacketSenderImp::RemovePacketsForSsrc(uint32_t ssrc) {
|
||||||
@@ -157,9 +153,7 @@ void PacketSenderImp::OnStatsUpdated(const Stats &stats) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PacketSenderImp::MaybeScheduleProcessPackets() {
|
void PacketSenderImp::MaybeScheduleProcessPackets() {
|
||||||
LOG_ERROR("x1");
|
|
||||||
if (!processing_packets_) {
|
if (!processing_packets_) {
|
||||||
LOG_ERROR("x2");
|
|
||||||
MaybeProcessPackets(webrtc::Timestamp::MinusInfinity());
|
MaybeProcessPackets(webrtc::Timestamp::MinusInfinity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ class PacketSenderImp : public PacketSender,
|
|||||||
|
|
||||||
packet->UpdateSequenceNumber(ssrc_seq_[packet->Ssrc()]++);
|
packet->UpdateSequenceNumber(ssrc_seq_[packet->Ssrc()]++);
|
||||||
|
|
||||||
|
webrtc::Timestamp now = clock_->CurrentTime();
|
||||||
|
webrtc::TimeDelta interval = now - last_send_time_;
|
||||||
|
webrtc::TimeDelta delay = now - packet->capture_time();
|
||||||
|
LOG_WARN("interval: {}, delay: {}", interval.ms(), delay.seconds());
|
||||||
|
last_send_time_ = now;
|
||||||
|
|
||||||
on_sent_packet_func_(*packet);
|
on_sent_packet_func_(*packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,6 +222,8 @@ class PacketSenderImp : public PacketSender,
|
|||||||
TaskQueue task_queue_;
|
TaskQueue task_queue_;
|
||||||
int64_t transport_seq_ = 0;
|
int64_t transport_seq_ = 0;
|
||||||
std::map<int32_t, int16_t> ssrc_seq_;
|
std::map<int32_t, int16_t> ssrc_seq_;
|
||||||
|
|
||||||
|
webrtc::Timestamp last_send_time_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user