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.
This commit is contained in:
Harald Welte 2011-09-03 18:10:26 +02:00
parent 716dded773
commit 099fb3b17c
1 changed files with 22 additions and 3 deletions

View File

@ -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