Skip to content

Commit

Permalink
RTT run min
Browse files Browse the repository at this point in the history
  • Loading branch information
baranovmv committed Nov 30, 2024
1 parent c7ac499 commit a54a532
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/internal_modules/roc_rtcp/reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ Reporter::find_stream_(packet::stream_source_t source_id, CreateMode mode) {
(unsigned long)source_id);

stream =
new(stream_pool_) Stream(stream_pool_, source_id, report_time_, config_.rtt, dumper_);
new(stream_pool_) Stream(arena_, stream_pool_, source_id, report_time_, config_.rtt, dumper_);
if (!stream) {
report_error_ = status::StatusNoMem;
return NULL;
Expand Down
7 changes: 4 additions & 3 deletions src/internal_modules/roc_rtcp/reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,15 @@ class Reporter : public core::NonCopyable<> {
struct Stream : core::RefCounted<Stream, core::PoolAllocation>,
core::HashmapNode<>,
core::ListNode<> {
Stream(core::IPool &pool, packet::stream_source_t source_id, core::nanoseconds_t report_time,
Stream(core::IArena &arena, core::IPool &pool, packet::stream_source_t source_id,
core::nanoseconds_t report_time,
const RttConfig &rtt_config, dbgio::CsvDumper *dumper)
: core::RefCounted<Stream, core::PoolAllocation>(pool)
, source_id(source_id)
, has_remote_recv_report(false)
, remote_recv_rtt(rtt_config, dumper)
, remote_recv_rtt(arena, rtt_config, dumper)
, has_remote_send_report(false)
, remote_send_rtt(rtt_config, dumper)
, remote_send_rtt(arena, rtt_config, dumper)
, local_recv_report(NULL)
, last_update(report_time)
, last_local_sr(0)
Expand Down
15 changes: 11 additions & 4 deletions src/internal_modules/roc_rtcp/rtt_estimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
namespace roc {
namespace rtcp {

RttEstimator::RttEstimator(const RttConfig &config, dbgio::CsvDumper *dumper)
RttEstimator::RttEstimator(core::IArena &arena, const RttConfig &config, dbgio::CsvDumper *dumper)
: config_(config)
, metrics_()
, has_metrics_(false)
, first_report_ts_(0)
, last_report_ts_(0)
, dumper_(dumper) {
, dumper_(dumper)
, rtt_stats_(arena, 100){
}

bool RttEstimator::has_metrics() const {
Expand Down Expand Up @@ -86,8 +87,14 @@ void RttEstimator::update(core::nanoseconds_t local_report_ts,
}
last_report_ts_ = local_report_ts;

metrics_.clock_offset = clock_offset;
metrics_.rtt = rtt;
RttOffsetPair p;
p.rtt = rtt;
p.offset = clock_offset;
rtt_stats_.add(p);
RttOffsetPair min = rtt_stats_.mov_min();

metrics_.clock_offset = min.offset;
metrics_.rtt = min.rtt;

has_metrics_ = true;

Expand Down
23 changes: 22 additions & 1 deletion src/internal_modules/roc_rtcp/rtt_estimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "roc_core/time.h"
#include "roc_packet/units.h"
#include "roc_dbgio/csv_dumper.h"
#include "roc_stat/mov_aggregate.h"

namespace roc {
namespace rtcp {
Expand Down Expand Up @@ -52,7 +53,7 @@ struct RttMetrics {
class RttEstimator {
public:
//! Initialize.
RttEstimator(const RttConfig &config, dbgio::CsvDumper *dumper);
RttEstimator(core::IArena &arena, const RttConfig &config, dbgio::CsvDumper *dumper);

//! Check whether metrics are already available.
bool has_metrics() const;
Expand Down Expand Up @@ -83,6 +84,26 @@ class RttEstimator {

dbgio::CsvDumper *dumper_;

struct RttOffsetPair {
core::nanoseconds_t rtt;
core::nanoseconds_t offset;

RttOffsetPair() {
rtt = 10e9;
}

RttOffsetPair(const int64_t &r) {
rtt = r;
offset = 0;
}

operator int64_t() const {
return rtt;
}
};

stat::MovAggregate<RttOffsetPair> rtt_stats_;

};

} // namespace rtcp
Expand Down

0 comments on commit a54a532

Please sign in to comment.