rtpdec: Cosmetic cleanup

Mainly clean up the RTP statistics code, plus a few other obviously
misindentend lines.

Remove some useless comments, de-doxygenize some comments,
add spacing around operators and fix a typo.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2012-10-22 15:54:25 +03:00
parent 424b1e7642
commit 48f01398ba

View File

@ -166,17 +166,14 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int l
#define RTP_SEQ_MOD (1<<16) #define RTP_SEQ_MOD (1<<16)
/** static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence)
* called on parse open packet
*/
static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence) // called on parse open packet.
{ {
memset(s, 0, sizeof(RTPStatistics)); memset(s, 0, sizeof(RTPStatistics));
s->max_seq = base_sequence; s->max_seq = base_sequence;
s->probation = 1; s->probation = 1;
} }
/** /*
* called whenever there is a large jump in sequence numbers, or when they get out of probation... * called whenever there is a large jump in sequence numbers, or when they get out of probation...
*/ */
static void rtp_init_sequence(RTPStatistics *s, uint16_t seq) static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
@ -192,7 +189,7 @@ static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
s->transit = 0; s->transit = 0;
} }
/** /*
* returns 1 if we should handle this packet. * returns 1 if we should handle this packet.
*/ */
static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq) static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
@ -203,8 +200,7 @@ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
const int MIN_SEQUENTIAL = 2; const int MIN_SEQUENTIAL = 2;
/* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */ /* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */
if(s->probation) if (s->probation) {
{
if (seq == s->max_seq + 1) { if (seq == s->max_seq + 1) {
s->probation--; s->probation--;
s->max_seq = seq; s->max_seq = seq;
@ -220,7 +216,7 @@ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
} else if (udelta < MAX_DROPOUT) { } else if (udelta < MAX_DROPOUT) {
// in order, with permissible gap // in order, with permissible gap
if (seq < s->max_seq) { if (seq < s->max_seq) {
//sequence number wrapped; count antother 64k cycles // sequence number wrapped; count another 64k cycles
s->cycles += RTP_SEQ_MOD; s->cycles += RTP_SEQ_MOD;
} }
s->max_seq = seq; s->max_seq = seq;
@ -290,8 +286,10 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
received_interval = stats->received - stats->received_prior; received_interval = stats->received - stats->received_prior;
stats->received_prior = stats->received; stats->received_prior = stats->received;
lost_interval = expected_interval - received_interval; lost_interval = expected_interval - received_interval;
if (expected_interval==0 || lost_interval<=0) fraction= 0; if (expected_interval == 0 || lost_interval <= 0)
else fraction = (lost_interval<<8)/expected_interval; fraction = 0;
else
fraction = (lost_interval << 8) / expected_interval;
fraction = (fraction << 24) | lost; fraction = (fraction << 24) | lost;
@ -299,8 +297,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
avio_wb32(pb, extended_max); /* max sequence received */ avio_wb32(pb, extended_max); /* max sequence received */
avio_wb32(pb, stats->jitter >> 4); /* jitter */ avio_wb32(pb, stats->jitter >> 4); /* jitter */
if(s->last_rtcp_ntp_time==AV_NOPTS_VALUE) if (s->last_rtcp_ntp_time == AV_NOPTS_VALUE) {
{
avio_wb32(pb, 0); /* last SR timestamp */ avio_wb32(pb, 0); /* last SR timestamp */
avio_wb32(pb, 0); /* delay since last SR */ avio_wb32(pb, 0); /* delay since last SR */
} else { } else {
@ -431,8 +428,7 @@ RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext
return s; return s;
} }
void void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx,
ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx,
RTPDynamicProtocolHandler *handler) RTPDynamicProtocolHandler *handler)
{ {
s->dynamic_protocol_context = ctx; s->dynamic_protocol_context = ctx;