From 47e18be18d166031fac685510947296c88bda194 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Tue, 25 Jul 2023 02:20:28 +0300 Subject: [PATCH] [mod_shout] Replace deprecated meta functions with shout_set_meta() --- configure.ac | 16 ++++++++++++++- src/mod/formats/mod_shout/Makefile.am | 4 ++-- src/mod/formats/mod_shout/mod_shout.c | 29 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 8a8bb102a7..c6f24f9252 100644 --- a/configure.ac +++ b/configure.ac @@ -1352,7 +1352,21 @@ PKG_CHECK_MODULES([MPG123], [libmpg123 >= 1.16.0],[ AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_MPG123],[false])]) PKG_CHECK_MODULES([SHOUT], [shout >= 2.2.2],[ - AM_CONDITIONAL([HAVE_SHOUT],[true])],[ + AM_CONDITIONAL([HAVE_SHOUT],[true]) + SHOUT_VERSION="`$PKG_CONFIG --modversion shout`" + SHOUT_MAJOR_VERSION="`echo $SHOUT_VERSION | cut -d. -f1`" + SHOUT_MINOR_VERSION="`echo $SHOUT_VERSION | cut -d. -f2`" + SHOUT_PATCH_VERSION="`echo $SHOUT_VERSION | cut -d. -f3`" + test -n "$SHOUT_PATCH_VERSION" || SHOUT_PATCH_VERSION=0 + AC_MSG_NOTICE([SHOUT version: $SHOUT_VERSION]) + AC_MSG_NOTICE([SHOUT major version: $SHOUT_MAJOR_VERSION]) + AC_MSG_NOTICE([SHOUT minor version: $SHOUT_MINOR_VERSION]) + AC_MSG_NOTICE([SHOUT patch version: $SHOUT_PATCH_VERSION]) + AC_SUBST([SHOUT_VERSION]) + AC_SUBST([SHOUT_MAJOR_VERSION]) + AC_SUBST([SHOUT_MINOR_VERSION]) + AC_SUBST([SHOUT_PATCH_VERSION]) + ],[ AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SHOUT],[false])]) mp3lame=false diff --git a/src/mod/formats/mod_shout/Makefile.am b/src/mod/formats/mod_shout/Makefile.am index ace4ce4af4..6318d312a0 100644 --- a/src/mod/formats/mod_shout/Makefile.am +++ b/src/mod/formats/mod_shout/Makefile.am @@ -7,8 +7,8 @@ if HAVE_MP3LAME mod_LTLIBRARIES = mod_shout.la mod_shout_la_SOURCES = mod_shout.c -mod_shout_la_CFLAGS = $(AM_CFLAGS) -mod_shout_la_CPPFLAGS = $(CURL_CFLAGS) $(AM_CPPFLAGS) $(SHOUT_CFLAGS) $(MP3LAME_CFLAGS) $(MPG123_CFLAGS) +mod_shout_la_CFLAGS = $(AM_CFLAGS) -DSHOUT_VERSION=$(SHOUT_VERSION) -DSHOUT_MAJOR_VERSION=$(SHOUT_MAJOR_VERSION) -DSHOUT_MINOR_VERSION=$(SHOUT_MINOR_VERSION) -DSHOUT_PATCH_VERSION=$(SHOUT_PATCH_VERSION) +mod_shout_la_CPPFLAGS = $(CURL_CFLAGS) $(AM_CPPFLAGS) $(SHOUT_CFLAGS) $(MP3LAME_CFLAGS) $(MPG123_CFLAGS) -DSHOUT_VERSION=$(SHOUT_VERSION) -DSHOUT_MAJOR_VERSION=$(SHOUT_MAJOR_VERSION) -DSHOUT_MINOR_VERSION=$(SHOUT_MINOR_VERSION) -DSHOUT_PATCH_VERSION=$(SHOUT_PATCH_VERSION) mod_shout_la_LIBADD = $(switch_builddir)/libfreeswitch.la mod_shout_la_LDFLAGS = $(CURL_LIBS) -avoid-version -module -no-undefined -shared $(SHOUT_LIBS) $(MP3LAME_LIBS) $(MPG123_LIBS) diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index 7012cb808d..be05ba5c32 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -51,6 +51,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_shout_shutdown); SWITCH_MODULE_DEFINITION(mod_shout, mod_shout_load, mod_shout_shutdown, NULL); +#define CHECK_SHOUT_MIN_VERSION(major, minor, patch) \ + (SHOUT_MAJOR_VERSION > major || \ + (SHOUT_MAJOR_VERSION == major && SHOUT_MINOR_VERSION > minor) || \ + (SHOUT_MAJOR_VERSION == major && SHOUT_MINOR_VERSION == minor && SHOUT_PATCH_VERSION >= patch)) + static char *supported_formats[SWITCH_MAX_CODECS] = { 0 }; static struct { @@ -871,12 +876,20 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char goto error; } +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_URL, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) { +#else if (shout_set_url(context->shout, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) { +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout)); goto error; } +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_DESCRIPTION, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) { +#else if (shout_set_description(context->shout, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) { +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting description: %s\n", shout_get_error(context->shout)); goto error; } @@ -886,7 +899,11 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char goto error; } +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_content_format(context->shout, SHOUT_FORMAT_MP3, SHOUT_USAGE_AUDIO, NULL) != SHOUTERR_SUCCESS) { +#else if (shout_set_format(context->shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) { +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting format: %s\n", shout_get_error(context->shout)); goto error; } @@ -1136,21 +1153,33 @@ static switch_status_t shout_file_set_string(switch_file_handle_t *handle, switc switch (col) { case SWITCH_AUDIO_COL_STR_TITLE: +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_NAME, string) == SHOUTERR_SUCCESS) { +#else if (shout_set_name(context->shout, string) == SHOUTERR_SUCCESS) { +#endif status = SWITCH_STATUS_SUCCESS; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout)); } break; case SWITCH_AUDIO_COL_STR_COMMENT: +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_URL, string) == SHOUTERR_SUCCESS) { +#else if (shout_set_url(context->shout, string) == SHOUTERR_SUCCESS) { +#endif status = SWITCH_STATUS_SUCCESS; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout)); } break; case SWITCH_AUDIO_COL_STR_ARTIST: +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_DESCRIPTION, string) == SHOUTERR_SUCCESS) { +#else if (shout_set_description(context->shout, string) == SHOUTERR_SUCCESS) { +#endif status = SWITCH_STATUS_SUCCESS; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));