Skip to content

Commit

Permalink
roc-streaminggh-688: Rename metrics and update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv authored and jeshwanthreddy13 committed Aug 6, 2024
1 parent d525f03 commit aadda98
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/internal_modules/roc_audio/depacketizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ status::StatusCode Depacketizer::start_packet_() {
(unsigned long)stream_ts_, (unsigned long)pkt_begin);

dropped_packets_++;
metrics_.late_packet_count++;
metrics_.late_packets++;

payload_decoder_.end_frame();
packet_ = NULL;
Expand Down Expand Up @@ -446,9 +446,9 @@ status::StatusCode Depacketizer::start_packet_() {
}
}

metrics_.decoded_packet_count++;
metrics_.decoded_packets++;
if (packet_->has_flags(packet::Packet::FlagRestored)) {
metrics_.recovered_packet_count++;
metrics_.recovered_packets++;
}

return status::StatusOK;
Expand Down
12 changes: 6 additions & 6 deletions src/internal_modules/roc_audio/depacketizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ namespace audio {
struct DepacketizerMetrics {
//! Cumulative count of packets from which we decoded samples.
//! Incremented each time depacketizer starts decoding a packet.
uint64_t decoded_packet_count;
uint64_t decoded_packets;

//! Cumulative count of packets dropped because they were late.
//! Incremented each time depacketizer drops a packet.
uint64_t late_packet_count;
uint64_t late_packets;

//! Cumulative count of packets repaired by FEC.
//! Incremented each time depacketizer reads a packet with FlagRestored.
//! This metric excludes late packets that were repaired but then dropped.
uint64_t recovered_packet_count;
uint64_t recovered_packets;

DepacketizerMetrics()
: decoded_packet_count(0)
, late_packet_count(0)
, recovered_packet_count(0) {
: decoded_packets(0)
, late_packets(0)
, recovered_packets(0) {
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/internal_modules/roc_audio/feedback_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void FeedbackMonitor::process_feedback(packet::stream_source_t source_id,
if (link_metrics_.expected_packets == 0 || use_packetizer_) {
// If packet counter is not reported from receiver, fallback to
// counter from sender.
link_metrics_.expected_packets = packetizer_.metrics().encoded_packet_count;
link_metrics_.expected_packets = packetizer_.metrics().encoded_packets;
use_packetizer_ = true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/internal_modules/roc_audio/packetizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ status::StatusCode Packetizer::end_packet_() {
return code;
}

metrics_.encoded_packet_count++;
metrics_.payload_byte_count += written_payload_size;
metrics_.encoded_packets++;
metrics_.payload_bytes += written_payload_size;

packet_ = NULL;
packet_pos_ = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/internal_modules/roc_audio/packetizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ namespace audio {
struct PacketizerMetrics {
//! Cumulative count of produced packets.
//! Incremented each time packetizer starts encoding a packet.
uint64_t encoded_packet_count;
uint64_t encoded_packets;

//! Cumulative count of encoded payload bytes.
//! This excludes packet headers and padding.
uint64_t payload_byte_count;
uint64_t payload_bytes;

PacketizerMetrics()
: encoded_packet_count(0)
, payload_byte_count(0) {
: encoded_packets(0)
, payload_bytes(0) {
}
};

Expand Down
40 changes: 25 additions & 15 deletions src/internal_modules/roc_packet/ilink_meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ struct LinkMetrics {
//! The low 16 bits contain the lowest sequence number received in an RTP data
//! packet, and the rest bits extend that sequence number with the corresponding
//! count of seqnum cycles.
//! @note
//! Available on both receiver and sender.
//! Calculated by rtp::LinkMeter on receiver, reported via RTCP to sender.
packet::ext_seqnum_t ext_first_seqnum;

//! Extended highest RTP seqnum received.
//! The low 16 bits contain the highest sequence number received in an RTP data
//! packet, and the rest bits extend that sequence number with the corresponding
//! count of seqnum cycles.
//! @note
//! Available on both receiver and sender.
//! Calculated by rtp::LinkMeter on receiver, reported via RTCP to sender.
packet::ext_seqnum_t ext_last_seqnum;

//! Total amount of packets that receiver expects to be delivered.
//! Calculated based on seqnums of oldest and newest packets.
//! @note
//! Available on both receiver and sender.
//! Calculated by rtp::LinkMeter on receiver, reported via RTCP to sender.
uint64_t expected_packets;

//! Cumulative count of lost packets.
Expand All @@ -42,45 +52,45 @@ struct LinkMetrics {
//! packets actually received, where the number of packets received includes any
//! which are late or duplicates. Packets that arrive late are not counted as lost,
//! and the loss may be negative if there are duplicates.
//! @note
//! Available on both receiver and sender.
//! Calculated by rtp::LinkMeter on receiver, reported via RTCP to sender.
int64_t lost_packets;

//! Cumulate count of recovered packets.
//! How many packets lost packets receiver was able to recover
//! by FEC. The sender is not getting this metric so far.
uint64_t recovered_packets;

//! Estimated interarrival jitter.
//! An estimate of the statistical variance of the RTP data packet
//! interarrival time.
//! An estimate of the statistical variance of the RTP data packet interarrival time.
//! Calculated based on a sliding window.
//! @note
//! This value is calculated on sliding window on a receiver side and sender
//! side gets this value via RTCP.
core::nanoseconds_t jitter;

//! Running max of jitter.
//! Calculated based on a sliding window.
//! @note
//! This value is calculated on sliding window on a receiver side and it is not
//! available on sender.
//! Available only on receiver.
//! Calculated by rtp::LinkMeter.
core::nanoseconds_t max_jitter;

//! Running min of jitter.
//! Calculated based on a sliding window.
//! @note
//! This value is calculated on sliding window on a receiver side and it is not
//! available on sender.
//! Available only on receiver.
//! Calculated by rtp::LinkMeter.
core::nanoseconds_t min_jitter;

//! Estimated round-trip time between sender and receiver.
//! Computed based on NTP-like timestamp exchange implemennted by RTCP protocol.
//! Read-only field. You can read it on sender, but you should not set
//! it on receiver.
//! Calculated based on NTP-like timestamp exchange implemented by RTCP protocol.
//! @note
//! Available on both receiver and sender.
//! Calculated by rtcp::Communicator independently on receiver and sender.
core::nanoseconds_t rtt;

LinkMetrics()
: ext_first_seqnum(0)
, ext_last_seqnum(0)
, expected_packets(0)
, lost_packets(0)
, recovered_packets(0)
, jitter(0)
, max_jitter(0)
, min_jitter(0)
Expand Down
4 changes: 2 additions & 2 deletions src/internal_modules/roc_pipeline/sender_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ rtcp::SendReport SenderSession::query_send_stream(core::nanoseconds_t report_tim
report.report_timestamp = report_time;
report.stream_timestamp = timestamp_extractor_->get_mapping(report_time);
report.sample_rate = packetizer_->sample_rate();
report.packet_count = packet_metrics.encoded_packet_count;
report.byte_count = packet_metrics.payload_byte_count;
report.packet_count = packet_metrics.encoded_packets;
report.byte_count = packet_metrics.payload_bytes;

return report;
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/roc_audio/test_depacketizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ void expect_error(status::StatusCode expected_status,
}

void expect_n_decoded(int packet_count, Depacketizer& depacketizer) {
LONGS_EQUAL(packet_count, depacketizer.metrics().decoded_packet_count);
LONGS_EQUAL(packet_count, depacketizer.metrics().decoded_packets);
}

void expect_n_late(int packet_count, Depacketizer& depacketizer) {
LONGS_EQUAL(packet_count, depacketizer.metrics().late_packet_count);
LONGS_EQUAL(packet_count, depacketizer.metrics().late_packets);
}

class ArrayReader : public packet::IReader {
Expand Down
4 changes: 2 additions & 2 deletions src/tests/roc_audio/test_packetizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ TEST(packetizer, metrics) {

const PacketizerMetrics metrics = packetizer.metrics();

UNSIGNED_LONGS_EQUAL(pn + 1, metrics.encoded_packet_count);
UNSIGNED_LONGS_EQUAL(pn + 1, metrics.encoded_packets);
UNSIGNED_LONGS_EQUAL((pn + 1) * SamplesPerPacket * NumCh * sizeof(int16_t),
metrics.payload_byte_count);
metrics.payload_bytes);
}
}

Expand Down

0 comments on commit aadda98

Please sign in to comment.