Rewrite session statistic routines according to new code style
Remove the __RTP_STATS__ test as gathering statistics is no longer optional
This commit is contained in:
parent
3fc85e2875
commit
33cf96b2e6
34
src/conn.cc
34
src/conn.cc
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
kvz_rtp::connection::connection(bool reader):
|
||||
config_(nullptr),
|
||||
reader_(reader),
|
||||
socket_()
|
||||
socket_(),
|
||||
reader_(reader)
|
||||
{
|
||||
rtp_sequence_ = 45175;
|
||||
rtp_ssrc_ = 0x72b644;
|
||||
|
|
@ -71,29 +71,39 @@ kvz_rtp::socket kvz_rtp::connection::get_socket() const
|
|||
return socket_;
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::incRTPSequence(uint16_t seq)
|
||||
void kvz_rtp::connection::inc_rtp_sequence(size_t n)
|
||||
{
|
||||
rtp_sequence_ += seq;
|
||||
rtp_sequence_ += n;
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::incProcessedBytes(uint32_t nbytes)
|
||||
void kvz_rtp::connection::inc_processed_bytes(size_t n)
|
||||
{
|
||||
processedBytes_ += nbytes;
|
||||
processed_bytes_ += n;
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::incOverheadBytes(uint32_t nbytes)
|
||||
void kvz_rtp::connection::inc_overhead_bytes(size_t n)
|
||||
{
|
||||
overheadBytes_ += nbytes;
|
||||
overhead_bytes_ += n;
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::incTotalBytes(uint32_t nbytes)
|
||||
void kvz_rtp::connection::inc_total_bytes(size_t n)
|
||||
{
|
||||
totalBytes_ += nbytes;
|
||||
total_bytes_ += n;
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::incProcessedPackets(uint32_t npackets)
|
||||
void kvz_rtp::connection::inc_processed_pkts(size_t n)
|
||||
{
|
||||
processedPackets_ += npackets;
|
||||
processed_pkts_ += n;
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::inc_processed_pkts()
|
||||
{
|
||||
processed_pkts_++;
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::inc_rtp_sequence()
|
||||
{
|
||||
rtp_sequence_++;
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::fill_rtp_header(uint8_t *buffer, uint32_t timestamp)
|
||||
|
|
|
|||
31
src/conn.hh
31
src/conn.hh
|
|
@ -35,12 +35,17 @@ namespace kvz_rtp {
|
|||
void set_payload(rtp_format_t fmt);
|
||||
void set_ssrc(uint32_t ssrc);
|
||||
|
||||
/* TODO: this is awful! */
|
||||
void incRTPSequence(uint16_t seq);
|
||||
void incProcessedBytes(uint32_t nbytes);
|
||||
void incOverheadBytes(uint32_t nbytes);
|
||||
void incTotalBytes(uint32_t nbytes);
|
||||
void incProcessedPackets(uint32_t npackets);
|
||||
/* functions for increasing various RTP statistics
|
||||
*
|
||||
* overloaded functions without parameters increase the counter by 1*/
|
||||
void inc_rtp_sequence(size_t n);
|
||||
void inc_processed_bytes(size_t n);
|
||||
void inc_overhead_bytes(size_t n);
|
||||
void inc_total_bytes(size_t n);
|
||||
void inc_processed_pkts(size_t n);
|
||||
|
||||
void inc_processed_pkts();
|
||||
void inc_rtp_sequence();
|
||||
|
||||
/* config set and get */
|
||||
void set_config(void *config);
|
||||
|
|
@ -57,18 +62,18 @@ namespace kvz_rtp {
|
|||
kvz_rtp::socket socket_;
|
||||
|
||||
private:
|
||||
/* TODO: should these be public so we could get rid of setters/getters */
|
||||
bool reader_;
|
||||
|
||||
// RTP
|
||||
/* RTP */
|
||||
uint16_t rtp_sequence_;
|
||||
uint8_t rtp_payload_;
|
||||
uint32_t rtp_ssrc_;
|
||||
|
||||
// Statistics
|
||||
uint32_t processedBytes_;
|
||||
uint32_t overheadBytes_;
|
||||
uint32_t totalBytes_;
|
||||
uint32_t processedPackets_;
|
||||
/* statistics for RTCP reports */
|
||||
size_t processed_bytes_;
|
||||
size_t overhead_bytes_;
|
||||
size_t total_bytes_;
|
||||
size_t processed_pkts_;
|
||||
size_t dropped_pkts_;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
26
src/send.cc
26
src/send.cc
|
|
@ -21,13 +21,10 @@ rtp_error_t kvz_rtp::sender::write_payload(kvz_rtp::connection *conn, uint8_t *p
|
|||
if (!conn)
|
||||
return RTP_INVALID_VALUE;
|
||||
|
||||
#ifdef __RTP_STATS__
|
||||
conn->incProcessedBytes(payload_len);
|
||||
conn->incTotalBytes(payload_len);
|
||||
conn->incProcessedPackets(1);
|
||||
#endif
|
||||
|
||||
conn->incRTPSequence(1);
|
||||
conn->inc_processed_bytes(payload_len);
|
||||
conn->inc_total_bytes(payload_len);
|
||||
conn->inc_processed_pkts();
|
||||
conn->inc_rtp_sequence();
|
||||
|
||||
return conn->get_socket().sendto(payload, payload_len, 0, NULL);
|
||||
}
|
||||
|
|
@ -37,10 +34,8 @@ rtp_error_t kvz_rtp::sender::write_generic_header(kvz_rtp::connection *conn, uin
|
|||
if (!conn)
|
||||
return RTP_INVALID_VALUE;
|
||||
|
||||
#ifdef __RTP_STATS__
|
||||
conn->incOverheadBytes(header_len);
|
||||
conn->incTotalBytes(header_len);
|
||||
#endif
|
||||
conn->inc_overhead_bytes(header_len);
|
||||
conn->inc_total_bytes(header_len);
|
||||
|
||||
#ifdef __linux__
|
||||
return conn->get_socket().sendto(header, header_len, MSG_MORE, NULL);
|
||||
|
|
@ -150,7 +145,8 @@ rtp_error_t kvz_rtp::sender::enqueue_message(
|
|||
msg_ptr += 1;
|
||||
hdr_ptr += 1;
|
||||
|
||||
conn->incRTPSequence(1);
|
||||
conn->inc_rtp_sequence();
|
||||
conn->inc_processed_pkts();
|
||||
|
||||
return RTP_OK;
|
||||
}
|
||||
|
|
@ -186,7 +182,8 @@ rtp_error_t kvz_rtp::sender::enqueue_message(
|
|||
msg_ptr++;
|
||||
hdr_ptr++;
|
||||
|
||||
conn->incRTPSequence(1);
|
||||
conn->inc_rtp_sequence();
|
||||
conn->inc_processed_pkts();
|
||||
|
||||
return RTP_OK;
|
||||
}
|
||||
|
|
@ -224,7 +221,8 @@ rtp_error_t kvz_rtp::sender::enqueue_message(
|
|||
msg_ptr += 1;
|
||||
hdr_ptr += 1;
|
||||
|
||||
conn->incRTPSequence(1);
|
||||
conn->inc_rtp_sequence();
|
||||
conn->inc_processed_pkts();
|
||||
|
||||
return RTP_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue