Detach RemoteBitrateEstimator interface from Module
Bug: webrtc:7219 Change-Id: I8302c5044582d73b0918013a0df89b9390788728 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267140 Commit-Queue: Philip Eliasson <philipel@webrtc.org> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37393}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
1c951ecb32
commit
2bc41bc980
@ -17,7 +17,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "modules/include/module.h"
|
||||
#include "api/units/time_delta.h"
|
||||
#include "modules/include/module_common_types.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/rtp_rtcp/source/rtcp_packet.h"
|
||||
@ -38,7 +38,7 @@ class RemoteBitrateObserver {
|
||||
virtual ~RemoteBitrateObserver() {}
|
||||
};
|
||||
|
||||
class RemoteBitrateEstimator : public CallStatsObserver, public Module {
|
||||
class RemoteBitrateEstimator : public CallStatsObserver {
|
||||
public:
|
||||
~RemoteBitrateEstimator() override {}
|
||||
|
||||
@ -62,6 +62,8 @@ class RemoteBitrateEstimator : public CallStatsObserver, public Module {
|
||||
|
||||
virtual void SetMinBitrate(int min_bitrate_bps) = 0;
|
||||
|
||||
virtual TimeDelta Process() = 0;
|
||||
|
||||
protected:
|
||||
static const int64_t kProcessIntervalMs = 500;
|
||||
static const int64_t kStreamTimeOutMs = 2000;
|
||||
|
||||
@ -353,11 +353,8 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacketInfo(
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorAbsSendTime::Process() {}
|
||||
|
||||
int64_t RemoteBitrateEstimatorAbsSendTime::TimeUntilNextProcess() {
|
||||
const int64_t kDisabledModuleTime = 1000;
|
||||
return kDisabledModuleTime;
|
||||
TimeDelta RemoteBitrateEstimatorAbsSendTime::Process() {
|
||||
return TimeDelta::PlusInfinity();
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorAbsSendTime::TimeoutStreams(Timestamp now) {
|
||||
|
||||
@ -55,12 +55,7 @@ class RemoteBitrateEstimatorAbsSendTime : public RemoteBitrateEstimator {
|
||||
void IncomingPacket(int64_t arrival_time_ms,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header) override;
|
||||
// This class relies on Process() being called periodically (at least once
|
||||
// every other second) for streams to be timed out properly. Therefore it
|
||||
// shouldn't be detached from the ProcessThread except if it's about to be
|
||||
// deleted.
|
||||
void Process() override;
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
TimeDelta Process() override;
|
||||
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
||||
void RemoveStream(uint32_t ssrc) override;
|
||||
bool LatestEstimate(std::vector<uint32_t>* ssrcs,
|
||||
|
||||
@ -155,22 +155,17 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::Process() {
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
UpdateEstimate(clock_->TimeInMilliseconds());
|
||||
TimeDelta RemoteBitrateEstimatorSingleStream::Process() {
|
||||
MutexLock lock(&mutex_);
|
||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
int64_t next_process_time_ms = last_process_time_ + process_interval_ms_;
|
||||
if (last_process_time_ == -1 || now_ms >= next_process_time_ms) {
|
||||
UpdateEstimate(now_ms);
|
||||
last_process_time_ = now_ms;
|
||||
return TimeDelta::Millis(process_interval_ms_);
|
||||
}
|
||||
last_process_time_ = clock_->TimeInMilliseconds();
|
||||
}
|
||||
|
||||
int64_t RemoteBitrateEstimatorSingleStream::TimeUntilNextProcess() {
|
||||
if (last_process_time_ < 0) {
|
||||
return 0;
|
||||
}
|
||||
MutexLock lock_(&mutex_);
|
||||
RTC_DCHECK_GT(process_interval_ms_, 0);
|
||||
return last_process_time_ + process_interval_ms_ -
|
||||
clock_->TimeInMilliseconds();
|
||||
return TimeDelta::Millis(next_process_time_ms - now_ms);
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/units/time_delta.h"
|
||||
#include "api/units/timestamp.h"
|
||||
#include "modules/remote_bitrate_estimator/aimd_rate_control.h"
|
||||
#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "rtc_base/rate_statistics.h"
|
||||
@ -46,8 +48,7 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
void IncomingPacket(int64_t arrival_time_ms,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header) override;
|
||||
void Process() override;
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
TimeDelta Process() override;
|
||||
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
||||
void RemoveStream(uint32_t ssrc) override;
|
||||
bool LatestEstimate(std::vector<uint32_t>* ssrcs,
|
||||
|
||||
@ -271,8 +271,7 @@ bool RemoteBitrateEstimatorTest::GenerateAndProcessFrame(uint32_t ssrc,
|
||||
delete packet;
|
||||
packets.pop_front();
|
||||
}
|
||||
if (bitrate_estimator_->TimeUntilNextProcess() <= 0)
|
||||
bitrate_estimator_->Process();
|
||||
bitrate_estimator_->Process();
|
||||
clock_.AdvanceTimeMicroseconds(next_time_us - clock_.TimeInMicroseconds());
|
||||
return overuse;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user