Use Timestamp type instead of int64_t in Flexfec classes
Bug: webrtc:13757 Change-Id: Ideafea65adb827b5457de22a04e3235cda3ffd5c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301260 Commit-Queue: Rasmus Brandt <brandtr@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39948}
This commit is contained in:
parent
b035dcc0a2
commit
52275845a0
@ -16,6 +16,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/sequence_checker.h"
|
#include "api/sequence_checker.h"
|
||||||
|
#include "api/units/timestamp.h"
|
||||||
#include "modules/rtp_rtcp/include/recovered_packet_receiver.h"
|
#include "modules/rtp_rtcp/include/recovered_packet_receiver.h"
|
||||||
#include "modules/rtp_rtcp/source/forward_error_correction.h"
|
#include "modules/rtp_rtcp/source/forward_error_correction.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
||||||
@ -67,7 +68,8 @@ class FlexfecReceiver {
|
|||||||
|
|
||||||
// Logging and stats.
|
// Logging and stats.
|
||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
int64_t last_recovered_packet_ms_ RTC_GUARDED_BY(sequence_checker_);
|
Timestamp last_recovered_packet_ RTC_GUARDED_BY(sequence_checker_) =
|
||||||
|
Timestamp::MinusInfinity();
|
||||||
FecPacketCounter packet_counter_ RTC_GUARDED_BY(sequence_checker_);
|
FecPacketCounter packet_counter_ RTC_GUARDED_BY(sequence_checker_);
|
||||||
|
|
||||||
RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
#include "api/rtp_parameters.h"
|
#include "api/rtp_parameters.h"
|
||||||
|
#include "api/units/timestamp.h"
|
||||||
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
|
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
|
||||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_header_extension_size.h"
|
#include "modules/rtp_rtcp/source/rtp_header_extension_size.h"
|
||||||
@ -77,7 +78,7 @@ class FlexfecSender : public VideoFecGenerator {
|
|||||||
// Utility.
|
// Utility.
|
||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
Random random_;
|
Random random_;
|
||||||
int64_t last_generated_packet_ms_;
|
Timestamp last_generated_packet_ = Timestamp::MinusInfinity();
|
||||||
|
|
||||||
// Config.
|
// Config.
|
||||||
const int payload_type_;
|
const int payload_type_;
|
||||||
|
|||||||
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
|
#include "api/units/time_delta.h"
|
||||||
|
#include "api/units/timestamp.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ namespace {
|
|||||||
constexpr size_t kMinFlexfecHeaderSize = 20;
|
constexpr size_t kMinFlexfecHeaderSize = 20;
|
||||||
|
|
||||||
// How often to log the recovered packets to the text log.
|
// How often to log the recovered packets to the text log.
|
||||||
constexpr int kPacketLogIntervalMs = 10000;
|
constexpr TimeDelta kPacketLogInterval = TimeDelta::Seconds(10);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -48,8 +50,7 @@ FlexfecReceiver::FlexfecReceiver(
|
|||||||
erasure_code_(
|
erasure_code_(
|
||||||
ForwardErrorCorrection::CreateFlexfec(ssrc, protected_media_ssrc)),
|
ForwardErrorCorrection::CreateFlexfec(ssrc, protected_media_ssrc)),
|
||||||
recovered_packet_receiver_(recovered_packet_receiver),
|
recovered_packet_receiver_(recovered_packet_receiver),
|
||||||
clock_(clock),
|
clock_(clock) {
|
||||||
last_recovered_packet_ms_(-1) {
|
|
||||||
// It's OK to create this object on a different thread/task queue than
|
// It's OK to create this object on a different thread/task queue than
|
||||||
// the one used during main operation.
|
// the one used during main operation.
|
||||||
sequence_checker_.Detach();
|
sequence_checker_.Detach();
|
||||||
@ -173,9 +174,9 @@ void FlexfecReceiver::ProcessReceivedPacket(
|
|||||||
recovered_packet_receiver_->OnRecoveredPacket(parsed_packet);
|
recovered_packet_receiver_->OnRecoveredPacket(parsed_packet);
|
||||||
|
|
||||||
// Periodically log the incoming packets at LS_INFO.
|
// Periodically log the incoming packets at LS_INFO.
|
||||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
Timestamp now = clock_->CurrentTime();
|
||||||
bool should_log_periodically =
|
bool should_log_periodically =
|
||||||
now_ms - last_recovered_packet_ms_ > kPacketLogIntervalMs;
|
now - last_recovered_packet_ > kPacketLogInterval;
|
||||||
if (RTC_LOG_CHECK_LEVEL(LS_VERBOSE) || should_log_periodically) {
|
if (RTC_LOG_CHECK_LEVEL(LS_VERBOSE) || should_log_periodically) {
|
||||||
rtc::LoggingSeverity level =
|
rtc::LoggingSeverity level =
|
||||||
should_log_periodically ? rtc::LS_INFO : rtc::LS_VERBOSE;
|
should_log_periodically ? rtc::LS_INFO : rtc::LS_VERBOSE;
|
||||||
@ -185,7 +186,7 @@ void FlexfecReceiver::ProcessReceivedPacket(
|
|||||||
<< recovered_packet->pkt->data.size()
|
<< recovered_packet->pkt->data.size()
|
||||||
<< " from FlexFEC stream with SSRC: " << ssrc_;
|
<< " from FlexFEC stream with SSRC: " << ssrc_;
|
||||||
if (should_log_periodically) {
|
if (should_log_periodically) {
|
||||||
last_recovered_packet_ms_ = now_ms;
|
last_recovered_packet_ = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "api/units/time_delta.h"
|
||||||
|
#include "api/units/timestamp.h"
|
||||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||||
#include "modules/rtp_rtcp/source/forward_error_correction.h"
|
#include "modules/rtp_rtcp/source/forward_error_correction.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
||||||
@ -42,7 +44,7 @@ constexpr size_t kFlexfecMaxHeaderSize = 32;
|
|||||||
const int kMsToRtpTimestamp = kVideoPayloadTypeFrequency / 1000;
|
const int kMsToRtpTimestamp = kVideoPayloadTypeFrequency / 1000;
|
||||||
|
|
||||||
// How often to log the generated FEC packets to the text log.
|
// How often to log the generated FEC packets to the text log.
|
||||||
constexpr int64_t kPacketLogIntervalMs = 10000;
|
constexpr TimeDelta kPacketLogInterval = TimeDelta::Seconds(10);
|
||||||
|
|
||||||
RtpHeaderExtensionMap RegisterSupportedExtensions(
|
RtpHeaderExtensionMap RegisterSupportedExtensions(
|
||||||
const std::vector<RtpExtension>& rtp_header_extensions) {
|
const std::vector<RtpExtension>& rtp_header_extensions) {
|
||||||
@ -79,7 +81,6 @@ FlexfecSender::FlexfecSender(
|
|||||||
Clock* clock)
|
Clock* clock)
|
||||||
: clock_(clock),
|
: clock_(clock),
|
||||||
random_(clock_->TimeInMicroseconds()),
|
random_(clock_->TimeInMicroseconds()),
|
||||||
last_generated_packet_ms_(-1),
|
|
||||||
payload_type_(payload_type),
|
payload_type_(payload_type),
|
||||||
// Reset RTP state if this is not the first time we are operating.
|
// Reset RTP state if this is not the first time we are operating.
|
||||||
// Otherwise, randomize the initial timestamp offset and RTP sequence
|
// Otherwise, randomize the initial timestamp offset and RTP sequence
|
||||||
@ -168,17 +169,17 @@ std::vector<std::unique_ptr<RtpPacketToSend>> FlexfecSender::GetFecPackets() {
|
|||||||
ulpfec_generator_.ResetState();
|
ulpfec_generator_.ResetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
Timestamp now = clock_->CurrentTime();
|
||||||
if (!fec_packets_to_send.empty() &&
|
if (!fec_packets_to_send.empty() &&
|
||||||
now_ms - last_generated_packet_ms_ > kPacketLogIntervalMs) {
|
now - last_generated_packet_ > kPacketLogInterval) {
|
||||||
RTC_LOG(LS_VERBOSE) << "Generated " << fec_packets_to_send.size()
|
RTC_LOG(LS_VERBOSE) << "Generated " << fec_packets_to_send.size()
|
||||||
<< " FlexFEC packets with payload type: "
|
<< " FlexFEC packets with payload type: "
|
||||||
<< payload_type_ << " and SSRC: " << ssrc_ << ".";
|
<< payload_type_ << " and SSRC: " << ssrc_ << ".";
|
||||||
last_generated_packet_ms_ = now_ms;
|
last_generated_packet_ = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
MutexLock lock(&mutex_);
|
MutexLock lock(&mutex_);
|
||||||
fec_bitrate_.Update(total_fec_data_bytes, now_ms);
|
fec_bitrate_.Update(total_fec_data_bytes, now.ms());
|
||||||
|
|
||||||
return fec_packets_to_send;
|
return fec_packets_to_send;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user