Skip to content

Commit 957d5cd

Browse files
committed
Poll live publisher stats
1 parent 9454b2c commit 957d5cd

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/publisher_api.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,22 @@ PublisherStats Publisher::stats() const {
265265
StatsSnapshot snapshot;
266266
bool split_cmaf_chunks = true;
267267
bool include_sap = false;
268+
std::shared_ptr<ActiveSession> active;
268269
{
269270
std::lock_guard<std::mutex> lock(state_mutex_);
270271
snapshot = stats_;
271272
split_cmaf_chunks = config_.split_cmaf_chunks;
272273
include_sap = config_.include_sap;
273-
if (active_session_ && active_session_->transport) {
274-
snapshot.connection_id = active_session_->transport->connection_id();
275-
}
274+
active = active_session_;
275+
}
276+
if (active && active->session) {
277+
const auto live_stats = active->session->publish_stats();
278+
snapshot.bytes_published = live_stats.bytes_published;
279+
snapshot.objects_published = live_stats.objects_published;
280+
snapshot.groups_published = live_stats.groups_published;
281+
}
282+
if (active && active->transport) {
283+
snapshot.connection_id = active->transport->connection_id();
276284
}
277285

278286
return PublisherStats{

0 commit comments

Comments
 (0)