forked from roc-streaming/roc-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
141 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2023 Roc Streaming authors | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#include "stream_stats_monitor.h" | ||
#include "roc_status/status_code.h" | ||
|
||
namespace roc { | ||
namespace rtp { | ||
|
||
StreamStatsMonitor::StreamStatsMonitor(packet::IReader& reader, | ||
core::IArena& arena, | ||
const audio::SampleSpec& sample_spec, | ||
const StreamStatsConfig &config) | ||
: reader_(reader) | ||
, arena_(arena) | ||
, config_(config) | ||
, sample_spec_(sample_spec) | ||
{} | ||
|
||
status::StatusCode StreamStatsMonitor::read(PacketPtr& packet) | ||
{ | ||
status::StatusCode result = reader_.read(packet); | ||
if (result == status::Ok) | ||
|
||
return result; | ||
} | ||
|
||
} // namespace packet | ||
} // namespace roc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2023 Roc Streaming authors | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
//! @file roc_rtp/stream_stats_monitor.h | ||
//! @brief Calculates basic network stream statistics. | ||
|
||
|
||
#ifndef ROC_PACKET_STREAMSTATSMONITOR_H_ | ||
#define ROC_PACKET_STREAMSTATSMONITOR_H_ | ||
|
||
#include "roc_core/noncopyable.h" | ||
#include "roc_packet/ireader.h" | ||
#include "roc_core/time.h" | ||
#include "roc_audio/sample_spec.h" | ||
#include "roc_status/status_code.h" | ||
|
||
namespace roc { | ||
namespace rtp { | ||
|
||
struct StreamStatsConfig { | ||
core::nanoseconds_t window_duration; | ||
core::nanoseconds_t window_overlap; | ||
}; | ||
|
||
struct StreamStats { | ||
core::nanoseconds_t windowed_max_jitter; | ||
|
||
size_t windowed_npackets; | ||
size_t windowed_lost_packets; | ||
size_t windowed_recovered_packets; | ||
|
||
float packet_loss_rate; | ||
}; | ||
|
||
class StreamStatsMonitor : public IReader, public core::NonCopyable<> { | ||
public: | ||
StreamStatsMonitor(packet::IReader& reader, core::IArena& arena, | ||
const audio::SampleSpec& sample_spec, | ||
const StreamStatsConfig &config); | ||
|
||
virtual ROC_ATTR_NODISCARD status::StatusCode read(PacketPtr& packet); | ||
private: | ||
packet::IReader& reader_; | ||
core::IArena& arena_; | ||
const StreamStatsConfig config_; | ||
const audio::SampleSpec sample_spec_; | ||
|
||
}; | ||
|
||
} // namespace packet | ||
} // namespace roc | ||
|
||
#endif // ROC_PACKET_STREAMSTATSMONITOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters