falconia has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-mgw/+/41629?usp=email )


Change subject: mgcp_client: add fmtp string to struct ptmap
......................................................................

mgcp_client: add fmtp string to struct ptmap

Allow MGCP clients to pass arbitrary fmtp strings to MGWs, beyond
the fixed set of parameters captured in legacy struct mgcp_codec_param,
and set a different fmtp string per payload type, as opposed to global.

Credit: this patch is a derivative work based on Neels Hofmeyr's
patch If58590bda8627519ff07e0b6f43aa47a274f052b from WIP branch
neels/sdp, reduced to just libosmo-mgcp-client.

Present necessity: this functional addition is needed in order to
allow osmo-bsc to pass this construct to its MGW when the CN
requested the use of TW-TS-006 extended payload format for AMR:

        a=rtpmap:112 AMR/8000/1
        a=fmtp:112 octet-align=1; tw-ts-006=1

AMR codec fmtp parameter tw-ts-006 (defined in TW-TS-006 spec
section B.1) is not supported by osmo-mgw; however, it is supported
by tw-e1abis-mgw, which is the OsmoBSC-compatible MGW needed for
E1 BTS with AMR and CSD.

Change-Id: I84ba2ed5ab9d379ac0b675520796446ad6ee0710
---
M TODO-RELEASE
M include/osmocom/mgcp_client/mgcp_client.h
M include/osmocom/mgcp_client/mgcp_client_fsm.h
M src/libosmo-mgcp-client/mgcp_client.c
4 files changed, 49 insertions(+), 30 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/29/41629/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 0ed7189..582e4ce 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library       what                    description / commit summary line
+libosmo-mgcp-client    ABI break       struct ptmap extended
diff --git a/include/osmocom/mgcp_client/mgcp_client.h 
b/include/osmocom/mgcp_client/mgcp_client.h
index d53f442..2cddf00 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -78,6 +78,9 @@
 
        /*! payload type number (96-127) */
        unsigned int pt;
+
+       /*! the MGCP 'a=fmtp:N <...>' string, e.g. 
"mode-set=1,2,3;octet-align=0". */
+       char fmtp[256];
 };

 int ptmap_cmp(const struct ptmap *a, const struct ptmap *b);
diff --git a/include/osmocom/mgcp_client/mgcp_client_fsm.h 
b/include/osmocom/mgcp_client/mgcp_client_fsm.h
index dbd5128..3e31e9c 100644
--- a/include/osmocom/mgcp_client/mgcp_client_fsm.h
+++ b/include/osmocom/mgcp_client/mgcp_client_fsm.h
@@ -57,10 +57,11 @@
         * address is set. If != MGCP_CONN_NONE, force this conn mode. */
        enum mgcp_connection_mode conn_mode;

-       /*! If the codec requires additional format parameters (fmtp), those 
cann be set here, see also
-        * mgcp_common.h */
-       bool param_present;
-       struct mgcp_codec_param param;
+       /*! Deprectated, use ptmap[].fmtp instead.
+        * Global codec params. In case the codec requires additional format 
parameters (fmtp), those can be set
+        * here, see also mgcp_common.h. The format parameters will be applied 
on all codecs where applicable. */
+       bool param_present OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use 
ptmap[].fmtp instead");
+       struct mgcp_codec_param param 
OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use ptmap[].fmtp instead");
 };

 struct osmo_fsm_inst *mgcp_conn_create(struct mgcp_client *mgcp, struct 
osmo_fsm_inst *parent_fi, uint32_t parent_term_evt,
diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 4924be4..09c273c 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -1425,34 +1425,45 @@
        MSGB_PRINTF_OR_RET("\r\n");

        /* Add optional codec parameters (fmtp) */
-       if (mgcp_msg->param_present) {
-               for (i = 0; i < mgcp_msg->ptmap_len; i++) {
-                       pt = mgcp_msg->ptmap[i].pt;
-                       switch (mgcp_msg->ptmap[i].codec) {
-                       case CODEC_AMR_8000_1:
-                       case CODEC_AMRWB_16000_1:
-                               if (!mgcp_msg->param.amr_octet_aligned_present)
-                                       break;
-                               MSGB_PRINTF_OR_RET("a=fmtp:%u 
octet-align=%d\r\n",
-                                                  pt, 
(int)mgcp_msg->param.amr_octet_aligned);
+       for (i = 0; i < mgcp_msg->ptmap_len; i++) {
+               pt = mgcp_msg->ptmap[i].pt;
+
+               /* Add fmtp string, if any is set. */
+               if (mgcp_msg->ptmap[i].fmtp[0]) {
+                       MSGB_PRINTF_OR_RET("a=fmtp:%u %s\r\n", pt,
+                                          mgcp_msg->ptmap[i].fmtp);
+                       continue;
+               }
+
+               /* LEGACY COMPAT. Fill in fmtp with the legacy mgcp_msg->param,
+                * if any, when no individual fmtp is set on the codec. */
+               if (!mgcp_msg->param_present)
+                       continue;
+
+               switch (mgcp_msg->ptmap[i].codec) {
+               case CODEC_AMR_8000_1:
+               case CODEC_AMRWB_16000_1:
+                       if (!mgcp_msg->param.amr_octet_aligned_present)
                                break;
-                       case CODEC_GSM_8000_1:
-                       case CODEC_GSMEFR_8000_1:
-                               if (!mgcp_msg->param.fr_efr_twts001_present)
-                                       break;
-                               MSGB_PRINTF_OR_RET("a=fmtp:%u tw-ts-001=%d\r\n",
-                                                  pt, 
(int)mgcp_msg->param.fr_efr_twts001);
+                       MSGB_PRINTF_OR_RET("a=fmtp:%u octet-align=%d\r\n",
+                                          pt, 
(int)mgcp_msg->param.amr_octet_aligned);
+                       break;
+               case CODEC_GSM_8000_1:
+               case CODEC_GSMEFR_8000_1:
+                       if (!mgcp_msg->param.fr_efr_twts001_present)
                                break;
-                       case CODEC_GSMHR_8000_1:
-                               if (!mgcp_msg->param.hr_twts002_present)
-                                       break;
-                               MSGB_PRINTF_OR_RET("a=fmtp:%u tw-ts-002=%d\r\n",
-                                                  pt, 
(int)mgcp_msg->param.hr_twts002);
+                       MSGB_PRINTF_OR_RET("a=fmtp:%u tw-ts-001=%d\r\n",
+                                          pt, 
(int)mgcp_msg->param.fr_efr_twts001);
+                       break;
+               case CODEC_GSMHR_8000_1:
+                       if (!mgcp_msg->param.hr_twts002_present)
                                break;
-                       default:
-                               /* no parameters for the remaining codecs */
-                               break;
-                       }
+                       MSGB_PRINTF_OR_RET("a=fmtp:%u tw-ts-002=%d\r\n",
+                                          pt, (int)mgcp_msg->param.hr_twts002);
+                       break;
+               default:
+                       /* no parameters for the remaining codecs */
+                       break;
                }
        }

@@ -1686,5 +1697,8 @@
        rc = OSMO_CMP(a->codec, b->codec);
        if (rc)
                return rc;
-       return OSMO_CMP(a->pt, b->pt);
+       rc = OSMO_CMP(a->pt, b->pt);
+       if (rc)
+               return rc;
+       return strcmp(a->fmtp, b->fmtp);
 }

--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/41629?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I84ba2ed5ab9d379ac0b675520796446ad6ee0710
Gerrit-Change-Number: 41629
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <[email protected]>

Reply via email to