]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_shout] Replace deprecated meta functions with shout_set_meta() 2181/head
authorAndrey Volk <andywolk@gmail.com>
Mon, 24 Jul 2023 23:20:28 +0000 (02:20 +0300)
committerAndrey Volk <andywolk@gmail.com>
Mon, 24 Jul 2023 23:49:51 +0000 (02:49 +0300)
configure.ac
src/mod/formats/mod_shout/Makefile.am
src/mod/formats/mod_shout/mod_shout.c

index 8a8bb102a795122ff21fa74f0c0d3a2efe6c06e5..c6f24f9252555ef344f929e53d733c5a9c10b6df 100644 (file)
@@ -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
index ace4ce4af405e1c11cf8b1937bde62f8aa50187c..6318d312a084950e25324086779b4396c82c6be2 100644 (file)
@@ -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)
 
index 7012cb808d8c0c21f9076f292e59092c71939707..be05ba5c323431771a57a033d88b37c9d6db4ad2 100644 (file)
@@ -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));