Browse Source

TT#31403 keep local packet stats for RTCP output/rewriting

Change-Id: Ib086bbacf5613e1480bfb9050612163152e24b28
changes/97/18897/6
Richard Fuchs 8 years ago
parent
commit
368312a4f5
5 changed files with 23 additions and 4 deletions
  1. +10
    -1
      daemon/codec.c
  2. +6
    -0
      daemon/ssrc.h
  3. +5
    -1
      lib/codeclib.c
  4. +1
    -1
      lib/codeclib.h
  5. +1
    -1
      recording-daemon/packet.c

+ 10
- 1
daemon/codec.c View File

@ -504,6 +504,9 @@ static int __packet_encoded(encoder_t *enc, void *u1, void *u2) {
p->free_func = free; p->free_func = free;
g_queue_push_tail(&mp->packets_out, p); g_queue_push_tail(&mp->packets_out, p);
atomic64_inc(&mp->ssrc_out->packets);
atomic64_add(&mp->ssrc_out->octets, inout.len);
if (ret == 0) { if (ret == 0) {
// no more to go // no more to go
break; break;
@ -546,6 +549,9 @@ static int handler_func_transcode(struct codec_handler *h, struct call_media *me
if (G_UNLIKELY(!ch)) if (G_UNLIKELY(!ch))
return 0; return 0;
atomic64_inc(&mp->ssrc_in->packets);
atomic64_add(&mp->ssrc_in->octets, mp->payload.len);
struct transcode_packet *packet = g_slice_alloc0(sizeof(*packet)); struct transcode_packet *packet = g_slice_alloc0(sizeof(*packet));
packet->p.seq = ntohs(mp->rtp->seq_num); packet->p.seq = ntohs(mp->rtp->seq_num);
packet->payload = str_dup(&mp->payload); packet->payload = str_dup(&mp->payload);
@ -564,10 +570,13 @@ static int handler_func_transcode(struct codec_handler *h, struct call_media *me
// got a new packet, run decoder // got a new packet, run decoder
while (1) { while (1) {
packet = packet_sequencer_next_packet(&ch->sequencer);
unsigned int lost;
packet = packet_sequencer_next_packet(&ch->sequencer, &lost);
if (G_UNLIKELY(!packet)) if (G_UNLIKELY(!packet))
break; break;
atomic64_add(&mp->ssrc_in->packets_lost, lost);
ilog(LOG_DEBUG, "Decoding RTP packet: seq %u, TS %lu", ilog(LOG_DEBUG, "Decoding RTP packet: seq %u, TS %lu",
packet->p.seq, packet->ts); packet->p.seq, packet->ts);


+ 6
- 0
daemon/ssrc.h View File

@ -40,7 +40,13 @@ struct ssrc_ctx {
u_int64_t srtp_index, u_int64_t srtp_index,
srtcp_index; srtcp_index;
// XXX move entire crypto context in here? // XXX move entire crypto context in here?
// for transcoding
u_int32_t ssrc_map_out; u_int32_t ssrc_map_out;
atomic64 packets,
octets,
packets_lost;
}; };
struct ssrc_stats_block { struct ssrc_stats_block {


+ 5
- 1
lib/codeclib.c View File

@ -631,7 +631,7 @@ static int packet_tree_search(const void *testseq_p, const void *ts_p) {
return -1; return -1;
} }
// caller must take care of locking // caller must take care of locking
void *packet_sequencer_next_packet(packet_sequencer_t *ps) {
void *packet_sequencer_next_packet(packet_sequencer_t *ps, unsigned int *lost) {
// see if we have a packet with the correct seq nr in the queue // see if we have a packet with the correct seq nr in the queue
seq_packet_t *packet = g_tree_lookup(ps->packets, GINT_TO_POINTER(ps->seq)); seq_packet_t *packet = g_tree_lookup(ps->packets, GINT_TO_POINTER(ps->seq));
if (G_LIKELY(packet != NULL)) { if (G_LIKELY(packet != NULL)) {
@ -679,6 +679,10 @@ void *packet_sequencer_next_packet(packet_sequencer_t *ps) {
dbg("lost multiple packets - returning packet with next highest seq %i", packet->seq); dbg("lost multiple packets - returning packet with next highest seq %i", packet->seq);
out: out:
if (lost) {
u_int16_t l = packet->seq - ps->seq;
*lost = l;
}
g_tree_steal(ps->packets, GINT_TO_POINTER(packet->seq)); g_tree_steal(ps->packets, GINT_TO_POINTER(packet->seq));
ps->seq = (packet->seq + 1) & 0xffff; ps->seq = (packet->seq + 1) & 0xffff;
return packet; return packet;


+ 1
- 1
lib/codeclib.h View File

@ -142,7 +142,7 @@ int encoder_input_fifo(encoder_t *enc, AVFrame *frame,
void packet_sequencer_init(packet_sequencer_t *ps, GDestroyNotify); void packet_sequencer_init(packet_sequencer_t *ps, GDestroyNotify);
void packet_sequencer_destroy(packet_sequencer_t *ps); void packet_sequencer_destroy(packet_sequencer_t *ps);
void *packet_sequencer_next_packet(packet_sequencer_t *ps);
void *packet_sequencer_next_packet(packet_sequencer_t *ps, unsigned int *);
int packet_sequencer_insert(packet_sequencer_t *ps, seq_packet_t *); int packet_sequencer_insert(packet_sequencer_t *ps, seq_packet_t *);


+ 1
- 1
recording-daemon/packet.c View File

@ -105,7 +105,7 @@ static void packet_decode(ssrc_t *ssrc, packet_t *packet) {
static void ssrc_run(ssrc_t *ssrc) { static void ssrc_run(ssrc_t *ssrc) {
while (1) { while (1) {
// see if we have a packet with the correct seq nr in the queue // see if we have a packet with the correct seq nr in the queue
packet_t *packet = packet_sequencer_next_packet(&ssrc->sequencer);
packet_t *packet = packet_sequencer_next_packet(&ssrc->sequencer, NULL);
if (G_UNLIKELY(packet == NULL)) if (G_UNLIKELY(packet == NULL))
break; break;


Loading…
Cancel
Save