From dfd8d1bbeaeb1c65d348afb892b2936b564c0773 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 17 Oct 2023 10:14:34 +0200 Subject: [PATCH] add creation time - functionality to debug whole TX time in OSD (@Pete) --- src/WBStreamTx.cpp | 6 ++++-- src/WBStreamTx.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/WBStreamTx.cpp b/src/WBStreamTx.cpp index a10a14bb..e71e1100 100644 --- a/src/WBStreamTx.cpp +++ b/src/WBStreamTx.cpp @@ -65,7 +65,8 @@ bool WBStreamTx::try_enqueue_packet(std::shared_ptr> packet return res; } -bool WBStreamTx::try_enqueue_block(std::vector>> fragments,int max_block_size, int fec_overhead_perc) { +bool WBStreamTx::try_enqueue_block(std::vector>> fragments,int max_block_size, int fec_overhead_perc, + std::chrono::steady_clock::time_point creation_time) { assert(options.enable_fec); m_n_input_packets+=fragments.size(); for(const auto& fragment:fragments){ @@ -79,6 +80,7 @@ bool WBStreamTx::try_enqueue_block(std::vectorfragments=fragments; item->max_block_size=max_block_size; item->fec_overhead_perc=fec_overhead_perc; + item->creation_time=creation_time; const bool res= m_block_queue->try_enqueue(item); if(!res){ m_n_dropped_packets+=fragments.size(); @@ -136,7 +138,7 @@ void WBStreamTx::loop_process_data() { m_queue_time_calculator.reset(); } process_enqueued_block(*frame); - const auto delta=std::chrono::steady_clock::now()-frame->enqueue_time_point; + const auto delta=std::chrono::steady_clock::now()-frame->creation_time; m_block_until_tx_time.add(delta); if(m_block_until_tx_time.get_delta_since_last_reset()>std::chrono::seconds(2)){ if(options.log_time_blocks_until_tx){ diff --git a/src/WBStreamTx.h b/src/WBStreamTx.h index 2e181415..e9edae7a 100644 --- a/src/WBStreamTx.h +++ b/src/WBStreamTx.h @@ -70,7 +70,8 @@ class WBStreamTx { * If the n of fragments exceeds @param max_block_size, the block is split into one or more sub-blocks. * @return true on success (space in the block queue), false otherwise */ - bool try_enqueue_block(std::vector>> fragments,int max_block_size,int fec_overhead_perc); + bool try_enqueue_block(std::vector>> fragments,int max_block_size,int fec_overhead_perc, + std::chrono::steady_clock::time_point creation_time=std::chrono::steady_clock::now()); // statistics struct Statistics{ int64_t n_provided_packets; @@ -125,6 +126,7 @@ class WBStreamTx { }; struct EnqueuedBlock { std::chrono::steady_clock::time_point enqueue_time_point=std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point creation_time=std::chrono::steady_clock::now(); int max_block_size; int fec_overhead_perc; std::vector>> fragments;