diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-09-03 18:10:26 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-09-03 18:10:26 +0200 |
commit | 099fb3b17cf29d6d152abb4d2cf4aef76916f8a0 (patch) | |
tree | d5fcc1c0ad7e47ac9f12cebab2086fb497460d14 | |
parent | 716dded7731f69f6a58de15aaa6315b44784e6ce (diff) |
Sysmobts L1: Implement HR codec support
We don't really know if the HR encoding is compatible with other
equipment, but it _should_ follow Chapter 5.2 of ETSI TS 101 318.
Please note that RFC5993 also specifies a way to encode GSM-HR into RTP,
we do not try to be compatible with that. The only difference seems to
be one additional TOC octet at the beginning of the payload field.
-rw-r--r-- | src/osmo-bts-sysmo/tch.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c index 6710edde..12250108 100644 --- a/src/osmo-bts-sysmo/tch.c +++ b/src/osmo-bts-sysmo/tch.c @@ -158,10 +158,18 @@ static struct msgb *l1_to_rtppayload_hr(uint8_t *l1_payload, uint8_t payload_len struct msgb *msg = msgb_alloc_headroom(1024, 128, "L1C-to-RTP"); uint8_t *cur; -#warning Test GSM HR + if (payload_len != GSM_HR_BYTES) { + LOGP(DL1C, LOGL_ERROR, "L1 HR frame length %u != expected %u\n", + payload_len, GSM_HR_BYTES); + return NULL; + } + cur = msgb_put(msg, GSM_HR_BYTES); memcpy(cur, l1_payload, GSM_HR_BYTES); + /* reverse the bit-order of each payload byte */ + osmo_revbytebits_buf(cur, GSM_HR_BYTES); + return msg; } @@ -174,8 +182,19 @@ static struct msgb *l1_to_rtppayload_hr(uint8_t *l1_payload, uint8_t payload_len static int rtppayload_to_l1_hr(uint8_t *l1_payload, uint8_t *rtp_payload, unsigned int payload_len) { -#warning Implement GSM HR - return 0; + + if (payload_len != GSM_HR_BYTES) { + LOGP(DL1C, LOGL_ERROR, "RTP HR frame length %u != expected %u\n", + payload_len, GSM_HR_BYTES); + return 0; + } + + memcpy(l1_payload, rtp_payload, GSM_HR_BYTES); + + /* reverse the bit-order of each payload byte */ + osmo_revbytebits_buf(l1_payload, GSM_HR_BYTES); + + return GSM_HR_BYTES; } #define AMR_TOC_QBIT 0x04 |