Files
osmo-mgw/include/osmocom/mgcp_client/fmtp.h
Neels Hofmeyr 527a45bc67 add fmtp.h
Upcoming patches will add handling of arbitrary ftmp strings to
osmo-mgw as well as libosmo-mgcp-client
(If58590bda8627519ff07e0b6f43aa47a274f052b).

Add generic API for handling ftmp strings. The primary intended user is
osmo-mgw, but this is also generally useful to libosmo-mgcp-client
callers for parsing the received fmtp.

We discussed that fmtp.[hc] should be published in libosmo-mgcp-client,
but also built within osmo-mgw. Hence:
- put fmtp.h and .c in libosmo-mgcp-client/
- in osmo-mgw code, use #include <mgcp_client/fmtp.h> and build the
  src/libosmo-mgcp-client/fmtp.c also into libosmo-mgcp.a.

(This is currently the quickest solution and without side effects since
fmtp.c is fully self-contained; an alternative would be adding a
not-installed libmgcp-common.a within the build tree)

Change-Id: I3eaea353dbd98c19212199b564342d0ac16cbc07
2023-12-22 05:34:43 +01:00

30 lines
1.1 KiB
C

#pragma once
#include <stddef.h>
#include <stdbool.h>
#define OSMO_SDP_NAME_A "a"
#define OSMO_SDP_NAME_FMTP "fmtp"
#define OSMO_SDP_NAME_AMR_OCTET_ALIGN "octet-align"
#define OSMO_SDP_VAL_AMR_OCTET_ALIGN_0 OSMO_SDP_NAME_AMR_OCTET_ALIGN "=0"
#define OSMO_SDP_VAL_AMR_OCTET_ALIGN_1 OSMO_SDP_NAME_AMR_OCTET_ALIGN "=1"
/* "fmtp:" */
#define OSMO_SDP_PREFIX_FMTP OSMO_SDP_NAME_FMTP ":"
/* "a=fmtp:" */
#define OSMO_SDP_PREFIX_A_FMTP OSMO_SDP_NAME_A "=" OSMO_SDP_PREFIX_FMTP
bool osmo_sdp_fmtp_get_val(char *val, size_t val_size, const char *fmtp, const char *option_name);
int osmo_sdp_fmtp_get_int(const char *fmtp, const char *option_name, int default_value);
/* Some AMR related fmtp parameters as in https://www.rfc-editor.org/rfc/rfc4867#section-8.1 that osmo-mgw needs.*/
bool osmo_sdp_fmtp_amr_is_octet_aligned(const char *fmtp);
/*! To compose AMR related fmtp indicating octet-align.
* Usage:
* printf("%s", OSMO_SDP_AMR_SET_OCTET_ALIGN(oa_flag));
*/
#define OSMO_SDP_AMR_SET_OCTET_ALIGN(VAL) \
((VAL) ? OSMO_SDP_VAL_AMR_OCTET_ALIGN_1 : OSMO_SDP_VAL_AMR_OCTET_ALIGN_0 )