diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2018-08-07 13:00:14 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-08-07 16:51:30 +0000 |
commit | 8ad3dacebb2ec1c160c2cc3b0ec0a8eaec4332f0 (patch) | |
tree | ae024def16eb5b6ccf50bf8cb96a967abfdd81b5 /src/libmsc/a_iface_bssap.c | |
parent | 6cc377d359a938e59dc517a99d0e182315cdf669 (diff) |
mgcp: use codec information returned with ASSIGNMENT COMPL.
When the assignment completes a choosen codec is returned. At the
moment we do not use this information.
- add struct members for codec info (both, RAN and CN)
- parse codec info in BSSMAP ASSIGNMENT COMPLETE
- use codec info on mgcp
Since the MNCC API is not complete yet, we currently only use the
codec info only on the internal MNCC yet.
Change-Id: I9d5b1cd016d9a058b22a367d0e5e9f2ef447931a
Related: OS#2728
Diffstat (limited to 'src/libmsc/a_iface_bssap.c')
-rw-r--r-- | src/libmsc/a_iface_bssap.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c index 1ace43dae..11d367383 100644 --- a/src/libmsc/a_iface_bssap.c +++ b/src/libmsc/a_iface_bssap.c @@ -502,11 +502,50 @@ static int bssmap_rx_sapi_n_rej(struct gsm_subscriber_connection *conn, struct m return 0; } +/* Use the speech codec info we go with the assignment complete to dtermine + * which codec we will signal to the MGW */ +static enum mgcp_codecs mgcp_codec_from_sc(struct gsm0808_speech_codec *sc) +{ + switch (sc->type) { + case GSM0808_SCT_FR1: + return CODEC_GSM_8000_1; + break; + case GSM0808_SCT_FR2: + return CODEC_GSMEFR_8000_1; + break; + case GSM0808_SCT_FR3: + return CODEC_AMR_8000_1; + break; + case GSM0808_SCT_FR4: + return CODEC_AMRWB_16000_1; + break; + case GSM0808_SCT_FR5: + return CODEC_AMRWB_16000_1; + break; + case GSM0808_SCT_HR1: + return CODEC_GSMHR_8000_1; + break; + case GSM0808_SCT_HR3: + return CODEC_AMR_8000_1; + break; + case GSM0808_SCT_HR4: + return CODEC_AMRWB_16000_1; + break; + case GSM0808_SCT_HR6: + return CODEC_AMRWB_16000_1; + break; + default: + return CODEC_PCMU_8000_1; + break; + } +} + /* Endpoint to handle assignment complete */ static int bssmap_rx_ass_compl(struct gsm_subscriber_connection *conn, struct msgb *msg, struct tlv_parsed *tp) { struct sockaddr_storage rtp_addr; + struct gsm0808_speech_codec sc; struct sockaddr_in *rtp_addr_in; int rc; @@ -525,6 +564,15 @@ static int bssmap_rx_ass_compl(struct gsm_subscriber_connection *conn, struct ms return -EINVAL; } + /* Decode speech codec (choosen) element */ + rc = gsm0808_dec_speech_codec(&sc, TLVP_VAL(tp, GSM0808_IE_SPEECH_CODEC), + TLVP_LEN(tp, GSM0808_IE_SPEECH_CODEC)); + if (rc < 0) { + LOGPCONN(conn, LOGL_ERROR, "Unable to decode speech codec (choosen).\n"); + return -EINVAL; + } + conn->rtp.codec_ran = mgcp_codec_from_sc(&sc); + /* use address / port supplied with the AoIP * transport address element */ if (rtp_addr.ss_family == AF_INET) { |