gsm_08_08: correct speech codec defaults

The speech codec defaults are not correct. The defaults recommended
in 3GPP TS 28.062, Table 7.11.3.1.3-2 are limited by 3GPP TS 48.008,
Section 3.2.2.103. Some defaults are actually reserved for future
use. Also the endianess of the 16 bit values is reversed.

- correct values so that they match the specification
- transmit bytes in the correct endianess

Change-Id: I6c3a34d39a375d71c4128fd38f06629e8b98b100
This commit is contained in:
Philipp Maier 2018-03-22 17:26:46 +01:00 committed by Harald Welte
parent 04a2a3231f
commit 7e27b14ef2
3 changed files with 13 additions and 13 deletions

View File

@ -460,16 +460,16 @@ struct gsm0808_speech_codec {
* configuration that is used on the air interface (Um).
*
* Default values for FR_AMR, HR_AMR and OHR_AMR:
* See also: 3GPP TS 28.062, Table 7.11.3.1.3-2: Preferred
* Configurations for the Adaptive Multi-Rate Codec Types
* See also: 3GPP TS 28.062, Table 7.11.3.1.3-2: Preferred Configurations for
* the Adaptive Multi-Rate Codec Types and 3GPP TS 48.008, Section 3.2.2.103.
*
* Default values for FR_AMR_WB, OFR_AMR_WB and OHR_AMR_WB:
* See also: 3GPP TS 26.103, Table 5.7-1: Allowed Configurations
* for the Adaptive Multi-Rate - Wideband Codec Types */
enum gsm0808_speech_codec_defaults {
GSM0808_SC_CFG_DEFAULT_FR_AMR = 0xffff,
GSM0808_SC_CFG_DEFAULT_FR_AMR = 0x57ff,
GSM0808_SC_CFG_DEFAULT_HR_AMR = 0x073f,
GSM0808_SC_CFG_DEFAULT_OHR_AMR = 0xffff,
GSM0808_SC_CFG_DEFAULT_OHR_AMR = 0x57ff,
GSM0808_SC_CFG_DEFAULT_FR_AMR_WB = 0x01,
GSM0808_SC_CFG_DEFAULT_OFR_AMR_WB = 0x3f,
GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB = 0x01,

View File

@ -210,7 +210,7 @@ static uint8_t enc_speech_codec(struct msgb *msg,
case GSM0808_SCT_FR3:
case GSM0808_SCT_HR3:
case GSM0808_SCT_HR6:
msgb_put_u16(msg, sc->cfg);
msgb_put_u16(msg, osmo_ntohs(sc->cfg));
break;
case GSM0808_SCT_FR4:
case GSM0808_SCT_FR5:
@ -320,7 +320,7 @@ int gsm0808_dec_speech_codec(struct gsm0808_speech_codec *sc,
case GSM0808_SCT_HR6:
if (len < 2)
return -EINVAL;
sc->cfg = osmo_load16be(elem);
sc->cfg = osmo_load16le(elem);
elem += 2;
break;
default:

View File

@ -88,7 +88,7 @@ static void test_create_layer3_aoip()
0x00, 0x17, 0x57, 0x05, 0x08, 0x00, 0x77, 0x62,
0x83, 0x33, 0x66, 0x44, 0x88, 0x17, 0x01, 0x23,
GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50,
0xcd, 0xef, GSM0808_SCT_FR2 | 0xa0, 0x9f,
0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f,
GSM0808_SCT_CSD | 0x90, 0xc0
};
@ -284,7 +284,7 @@ static void test_create_ass()
{ 0x00, 0x20, 0x01, 0x0b, 0x04, 0x01, 0x0b, 0xa1, 0x25, 0x01, 0x00,
0x04, GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17,
0x04, 0xd2, GSM0808_IE_SPEECH_CODEC_LIST, 0x07,
GSM0808_SCT_FR3 | 0x50, 0xcd, 0xef, GSM0808_SCT_FR2 | 0xa0, 0x9f,
GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f,
GSM0808_SCT_CSD | 0x90, 0xc0, GSM0808_IE_CALL_ID, 0xaa, 0xbb,
0xcc, 0xdd };
@ -354,8 +354,8 @@ static void test_create_ass_compl_aoip()
{ 0x00, 0x1d, 0x02, 0x15, 0x23, 0x21, 0x42, 0x2c, 0x11, 0x40, 0x22,
GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17, 0x04,
0xd2, GSM0808_IE_SPEECH_CODEC, 0x01, GSM0808_SCT_HR1 | 0x90,
GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xcd,
0xef, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xef,
0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
struct msgb *msg;
memset(&sin, 0, sizeof(sin));
@ -402,12 +402,12 @@ static void test_create_ass_fail_aoip()
{
static const uint8_t res1[] =
{ 0x00, 0x0d, 0x03, 0x04, 0x01, 0x23, GSM0808_IE_SPEECH_CODEC_LIST,
0x07, GSM0808_SCT_FR3 | 0x50, 0xcd, 0xef, GSM0808_SCT_FR2 | 0xa0,
0x07, GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0,
0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
static const uint8_t res2[] =
{ 0x00, 0x0f, 0x03, 0x04, 0x01, 0x23, 0x15, 0x02,
GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xcd,
0xef, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xef,
0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
uint8_t rr_res = 2;
struct msgb *msg;
struct gsm0808_speech_codec_list sc_list;