diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-08-03 11:59:04 +0000 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-08-03 23:57:16 +0800 |
commit | 3186892771fe8174e42c7e3cddc7baf4c9abb0cd (patch) | |
tree | 92a9c02c013ecb8fe83e472529478f40ad0828bb /openbsc/src/mgcp/mgcp_network.c | |
parent | ebc824cd2e1777294e71e47dffd8a41a253b2045 (diff) |
mgcp: Move the rtp state into a struct
Use a struct to group the rtp state for the up and the down
link of the bts.
Diffstat (limited to 'openbsc/src/mgcp/mgcp_network.c')
-rw-r--r-- | openbsc/src/mgcp/mgcp_network.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c index 5923fea79..d2dbeebe4 100644 --- a/openbsc/src/mgcp/mgcp_network.c +++ b/openbsc/src/mgcp/mgcp_network.c @@ -94,7 +94,7 @@ int mgcp_send_dummy(struct mgcp_endpoint *endp) endp->net_rtp, buf, 1); } -static void patch_and_count(uint16_t *last_seq, int *lost, int payload, char *data, int len) +static void patch_and_count(struct mgcp_rtp_state *state, int payload, char *data, int len) { uint16_t seq; struct rtp_hdr *rtp_hdr; @@ -105,14 +105,13 @@ static void patch_and_count(uint16_t *last_seq, int *lost, int payload, char *da rtp_hdr = (struct rtp_hdr *) data; seq = ntohs(rtp_hdr->sequence); - /* 0 is assumed to be not set */ - if (*last_seq == 0) - *last_seq = seq; - else if (*last_seq + 1 != seq) - *lost = abs(seq - (*last_seq + 1)); - - *last_seq = seq; + if (!state->initialized) { + state->seq_no = seq; + state->initialized = 1; + } else if (state->seq_no + 1u != seq) + state->lost_no = abs(seq - (state->seq_no + 1)); + state->seq_no = seq; if (payload < 0) return; @@ -210,14 +209,14 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what) if (dest == DEST_NETWORK) { if (proto == PROTO_RTP) - patch_and_count(&endp->bts_seq_no, &endp->bts_lost_no, + patch_and_count(&endp->bts_state, endp->net_payload_type, buf, rc); return udp_send(fd->fd, &endp->remote, proto == PROTO_RTP ? endp->net_rtp : endp->net_rtcp, buf, rc); } else { if (proto == PROTO_RTP) - patch_and_count(&endp->net_seq_no, &endp->net_lost_no, + patch_and_count(&endp->net_state, endp->bts_payload_type, buf, rc); return udp_send(fd->fd, &endp->bts, proto == PROTO_RTP ? endp->bts_rtp : endp->bts_rtcp, |