fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-abis/+/35502?usp=email )
Change subject: trau/osmo_ortp: support building without OrtpMemoryFunctions API
......................................................................
trau/osmo_ortp: support building without OrtpMemoryFunctions API
Recent ortp versions (v5.3.0+, maintained by
linphone.org) no longer
have the memory allocator configuration API. See the related commit:
https://gitlab.linphone.org/BC/public/ortp/-/commit/9ba9db486a61bebeb11287e…
A similar API is provided by bctoolbox, a dependency of ortp:
void bctbx_set_memory_functions(BctoolboxMemoryFunctions *functions);
Let's support building against v5.3.0+ by checking (in ./configure)
if the old API is available. Use talloc if possible; otherwise
fall-back to whatever ortp uses by default (glibc's malloc).
Change-Id: I9fe6299fde81faeab86cd6645d67edd2f41e1873
---
M configure.ac
M src/trau/osmo_ortp.c
2 files changed, 43 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/02/35502/1
diff --git a/configure.ac b/configure.ac
index 37ac91a..5097c93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,6 +161,19 @@
[rtp_session_signal_connect requires ulong parameter])])
CFLAGS=$_cflags_save
+_cflags_save=$CFLAGS
+CFLAGS="$CFLAGS $ORTP_CFLAGS"
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <ortp/ortp.h>]],
+ [[OrtpMemoryFunctions memfn = { };]]
+ )],
+ [AC_DEFINE([HAVE_ORTP_MEM_FUNC], [1],
+ [OrtpMemoryFunctions is available, will use talloc])],
+ [AC_DEFINE([HAVE_ORTP_MEM_FUNC], [0],
+ [OrtpMemoryFunctions is not available])])
+CFLAGS=$_cflags_save
+
AC_MSG_RESULT([CFLAGS="$CFLAGS"])
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c
index 015ac34..701b81d 100644
--- a/src/trau/osmo_ortp.c
+++ b/src/trau/osmo_ortp.c
@@ -47,7 +47,7 @@
static void *tall_rtp_ctx;
/* malloc integration */
-
+#if HAVE_ORTP_MEM_FUNC
static void *osmo_ortp_malloc(size_t sz)
{
return talloc_size(tall_rtp_ctx, sz);
@@ -68,6 +68,7 @@
.realloc_fun = osmo_ortp_realloc,
.free_fun = osmo_ortp_free
};
+#endif /* HAVE_ORTP_MEM_FUNC */
/* logging */
@@ -121,13 +122,14 @@
needs_endl = fmt[fmt_len - 1] != '\n' ? 1 : 0;
- str = osmo_ortp_malloc(domain_len + 2 /*": "*/ + fmt_len + needs_endl + 1);
- sprintf(str, "%s%s%s%s", domain_str, domain_len ? ": " :
"", fmt, needs_endl ? "\n" : "");
+ str = talloc_asprintf(tall_rtp_ctx, "%s%s%s%s",
+ domain_str, domain_len ? ": " : "",
+ fmt, needs_endl ? "\n" : "");
osmo_vlogp(DLMIB, ortp_to_osmo_lvl(lev), __FILE__, 0,
0, str, args);
- osmo_ortp_free(str);
+ talloc_free(str);
}
@@ -315,7 +317,9 @@
void osmo_rtp_init(void *ctx)
{
tall_rtp_ctx = ctx;
+#if HAVE_ORTP_MEM_FUNC
ortp_set_memory_functions(&osmo_ortp_memfn);
+#endif
ortp_init();
ortp_set_log_level_mask(
#if HAVE_ORTP_LOG_DOMAIN
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-abis/+/35502?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I9fe6299fde81faeab86cd6645d67edd2f41e1873
Gerrit-Change-Number: 35502
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange