From 7ddcca53e4ee2d0c7b331de1d53f0938a611d124 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Wed, 18 Dec 2024 18:07:45 +0800 Subject: [PATCH] [fix] update qos module --- src/common/array_view.h | 2 +- src/common/byte_io.h | 16 +++++------ src/common/type_traits.h | 20 +++++--------- ...ack.cc => congestion_control_feedback.cpp} | 0 ...congestion_control_feedback_generator.cpp} | 0 ...> congestion_control_feedback_tracker.cpp} | 27 ++++++++++++------- ...=> receive_side_congestion_controller.cpp} | 4 +-- src/qos/receive_side_congestion_controller.h | 11 ++++---- xmake.lua | 2 +- 9 files changed, 38 insertions(+), 44 deletions(-) rename src/qos/{congestion_control_feedback.cc => congestion_control_feedback.cpp} (100%) rename src/qos/{congestion_control_feedback_generator.cc => congestion_control_feedback_generator.cpp} (100%) rename src/qos/{congestion_control_feedback_tracker.cc => congestion_control_feedback_tracker.cpp} (84%) rename src/qos/{receive_side_congestion_controller.cc => receive_side_congestion_controller.cpp} (98%) diff --git a/src/common/array_view.h b/src/common/array_view.h index 1752f75..4e8a120 100644 --- a/src/common/array_view.h +++ b/src/common/array_view.h @@ -1,7 +1,7 @@ /* * @Author: DI JUNKUN * @Date: 2024-12-18 - * Copyright (c) 2024 by DI JUNKUN, All Rights Reserved. + * Copyright 2018 The WebRTC project authors. All Rights Reserved. */ #ifndef _ARRAY_VIEW_H_ diff --git a/src/common/byte_io.h b/src/common/byte_io.h index 388a1e2..31b60be 100644 --- a/src/common/byte_io.h +++ b/src/common/byte_io.h @@ -1,15 +1,11 @@ /* - * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. + * @Author: DI JUNKUN + * @Date: 2024-12-18 + * Copyright 2018 The WebRTC project authors. All Rights Reserved. */ -#ifndef MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_ -#define MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_ +#ifndef _BYTE_IO_H_ +#define _BYTE_IO_H_ // This file contains classes for reading and writing integer types from/to // byte array representations. Signed/unsigned, partial (whole byte) sizes, @@ -391,4 +387,4 @@ class ByteWriter { } }; -#endif // MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_ +#endif \ No newline at end of file diff --git a/src/common/type_traits.h b/src/common/type_traits.h index 8f90a88..16e15c6 100644 --- a/src/common/type_traits.h +++ b/src/common/type_traits.h @@ -1,22 +1,16 @@ /* - * Copyright 2016 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. + * @Author: DI JUNKUN + * @Date: 2024-12-18 + * Copyright 2018 The WebRTC project authors. All Rights Reserved. */ -#ifndef RTC_BASE_TYPE_TRAITS_H_ -#define RTC_BASE_TYPE_TRAITS_H_ +#ifndef _TYPE_TRAITS_H_ +#define _TYPE_TRAITS_H_ #include #include #include -namespace rtc { - // Determines if the given class has zero-argument .data() and .size() methods // whose return values are convertible to T* and size_t, respectively. template @@ -136,6 +130,4 @@ static_assert(!IsIntlike::value, ""); } // namespace test_enum_intlike -} // namespace rtc - -#endif // RTC_BASE_TYPE_TRAITS_H_ +#endif \ No newline at end of file diff --git a/src/qos/congestion_control_feedback.cc b/src/qos/congestion_control_feedback.cpp similarity index 100% rename from src/qos/congestion_control_feedback.cc rename to src/qos/congestion_control_feedback.cpp diff --git a/src/qos/congestion_control_feedback_generator.cc b/src/qos/congestion_control_feedback_generator.cpp similarity index 100% rename from src/qos/congestion_control_feedback_generator.cc rename to src/qos/congestion_control_feedback_generator.cpp diff --git a/src/qos/congestion_control_feedback_tracker.cc b/src/qos/congestion_control_feedback_tracker.cpp similarity index 84% rename from src/qos/congestion_control_feedback_tracker.cc rename to src/qos/congestion_control_feedback_tracker.cpp index 86a3573..07aefc6 100644 --- a/src/qos/congestion_control_feedback_tracker.cc +++ b/src/qos/congestion_control_feedback_tracker.cpp @@ -4,17 +4,19 @@ #include #include +#include "log.h" + void CongestionControlFeedbackTracker::ReceivedPacket( const RtpPacketReceived& packet) { int64_t unwrapped_sequence_number = unwrapper_.Unwrap(packet.SequenceNumber()); if (last_sequence_number_in_feedback_ && unwrapped_sequence_number < *last_sequence_number_in_feedback_ + 1) { - RTC_LOG(LS_WARNING) - << "Received packet unorderered between feeedback. SSRC: " - << packet.Ssrc() << " Seq: " << packet.SequenceNumber() - << " last feedback: " - << static_cast(*last_sequence_number_in_feedback_); + LOG_WARN( + "Received packet unorderered between feeedback. SSRC: {} Seq: {} last " + "feedback: {}", + packet.Ssrc(), packet.SequenceNumber(), + static_cast(*last_sequence_number_in_feedback_)); // TODO: bugs.webrtc.org/374550342 - According to spec, the old packets // should be reported again. But at the moment, we dont store history of // packet we already reported and thus, they will be reported as lost. Note @@ -49,8 +51,14 @@ void CongestionControlFeedbackTracker::AddPacketsToFeedback( for (int64_t sequence_number = *last_sequence_number_in_feedback_ + 1; sequence_number <= packets_.back().unwrapped_sequence_number; ++sequence_number) { - RTC_DCHECK(packet_it != packets_.end()); - RTC_DCHECK_EQ(ssrc, packet_it->ssrc); + if (packet_it == packets_.end()) { + LOG_FATAL("Invalid packet_it"); + return; + } + if (ssrc != packet_it->ssrc) { + LOG_FATAL("Invalid ssrc"); + return; + } rtc::EcnMarking ecn = rtc::EcnMarking::kNotEct; TimeDelta arrival_time_offset = TimeDelta::MinusInfinity(); @@ -70,9 +78,8 @@ void CongestionControlFeedbackTracker::AddPacketsToFeedback( if (packet_it->ecn == rtc::EcnMarking::kCe) { ecn = rtc::EcnMarking::kCe; } - RTC_LOG(LS_WARNING) << "Received duplicate packet ssrc:" << ssrc - << " seq:" << static_cast(sequence_number) - << " ecn: " << static_cast(ecn); + LOG_WARN("Received duplicate packet ssrc: {} seq: {} ecn: {}", ssrc, + static_cast(sequence_number), static_cast(ecn)); ++packet_it; } } // else - the packet has not been received yet. diff --git a/src/qos/receive_side_congestion_controller.cc b/src/qos/receive_side_congestion_controller.cpp similarity index 98% rename from src/qos/receive_side_congestion_controller.cc rename to src/qos/receive_side_congestion_controller.cpp index a8afd8a..5954518 100644 --- a/src/qos/receive_side_congestion_controller.cc +++ b/src/qos/receive_side_congestion_controller.cpp @@ -126,8 +126,8 @@ void ReceiveSideCongestionController::OnBitrateChanged(int bitrate_bps) { send_bandwidth_estimate); } -TimeDelta ReceiveSideCongestionController::MaybeProcess() { - Timestamp now = env_.clock().CurrentTime(); +int64_t ReceiveSideCongestionController::MaybeProcess() { + int64_t now = env_.clock().CurrentTime(); if (send_rfc8888_congestion_feedback_) { RTC_DCHECK_RUN_ON(&sequence_checker_); return congestion_control_feedback_generator_.Process(now); diff --git a/src/qos/receive_side_congestion_controller.h b/src/qos/receive_side_congestion_controller.h index 2b978ed..6497599 100644 --- a/src/qos/receive_side_congestion_controller.h +++ b/src/qos/receive_side_congestion_controller.h @@ -8,13 +8,14 @@ #define _RECEIVE_SIDE_CONGESTION_CONTROLLER_H_ class ReceiveSideCongestionController { + public: + enum MediaType { VIDEO, AUDIO, DATA }; + public: ReceiveSideCongestionController(); ~ReceiveSideCongestionController() override = default; public: - void EnablSendCongestionControlFeedbackAccordingToRfc8888(); - void OnReceivedPacket(const RtpPacketReceived& packet, MediaType media_type); // Implements CallStatsObserver. @@ -39,13 +40,11 @@ class ReceiveSideCongestionController { // Runs periodic tasks if it is time to run them, returns time until next // call to `MaybeProcess` should be non idle. - TimeDelta MaybeProcess(); + int64_t MaybeProcess(); private: - void PickEstimator(bool has_absolute_send_time) - RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + void PickEstimator(bool has_absolute_send_time); - const Environment env_; RembThrottler remb_throttler_; // TODO: bugs.webrtc.org/42224904 - Use sequence checker for all usage of diff --git a/xmake.lua b/xmake.lua index edb7ab0..a206d8b 100644 --- a/xmake.lua +++ b/xmake.lua @@ -188,7 +188,7 @@ target("media") target("qos") set_kind("object") - add_deps("log") + add_deps("log", "rtp") add_files("src/qos/*.cpp") add_includedirs("src/qos", {public = true})