diff options
author | Max <msuraev@sysmocom.de> | 2016-06-03 13:29:29 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-06-07 15:32:39 +0000 |
commit | 51bfebec39cc0a01e30ac9c655866678a46b5c2d (patch) | |
tree | 657176dd9645ca6696a1a0e1a4ba7de06e3a377b /src/common/l1sap.c | |
parent | ef30f50d5d6d5f863fc147d05ccdceb89284934e (diff) |
Fix RTP timestamps in case of DTX
Compute RTP user_ts adjustment based on the difference between current
and previous FN instead of hard-coded value.
Change-Id: If1677ddcf754b29990ff7cd846e11c32e3d30b33
Related: OS#1562
Reviewed-on: https://gerrit.osmocom.org/196
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Diffstat (limited to 'src/common/l1sap.c')
-rw-r--r-- | src/common/l1sap.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/common/l1sap.c b/src/common/l1sap.c index ac398d35..77fd1a09 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -69,6 +69,20 @@ get_active_lchan_by_chan_nr(struct gsm_bts_trx *trx, unsigned int chan_nr) static int l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap); +static uint32_t fn_ms_adj(uint32_t fn, uint32_t last_fn) +{ + if (last_fn) { + uint32_t ms_passed = GSM_FN_TO_MS(fn - last_fn), + samples_passed = GSM_MS_TO_SAMPLES(ms_passed); + /* round number of samples to the nearest multiple of + GSM_RTP_DURATION */ + uint32_t r = samples_passed + GSM_RTP_DURATION / 2; + r -= r % GSM_RTP_DURATION; + return r; + } + return GSM_RTP_DURATION; +} + static const uint8_t fill_frame[GSM_MACBLOCK_LEN] = { 0x03, 0x03, 0x01, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, @@ -853,7 +867,7 @@ static int l1sap_tch_ind(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap, /* hand msg to RTP code for transmission */ if (lchan->abis_ip.rtp_socket) osmo_rtp_send_frame(lchan->abis_ip.rtp_socket, - msg->data, msg->len, 160); + msg->data, msg->len, fn_ms_adj(fn, lchan->tch.last_fn)); /* if loopback is enabled, also queue received RTP data */ if (lchan->loopback) { @@ -871,7 +885,7 @@ static int l1sap_tch_ind(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap, msgb_enqueue(&lchan->dl_tch_queue, msg); } - + lchan->tch.last_fn = fn; return 0; } |