]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_amqp] Add support for newer librabbitmq 2846/head
authorAndrey Volk <andywolk@gmail.com>
Sat, 12 Jul 2025 11:55:57 +0000 (11:55 +0000)
committerAndrey Volk <andywolk@gmail.com>
Mon, 14 Jul 2025 13:14:55 +0000 (16:14 +0300)
configure.ac [changed mode: 0755->0644]
src/mod/event_handlers/mod_amqp/Makefile.am
src/mod/event_handlers/mod_amqp/mod_amqp.h
src/mod/event_handlers/mod_amqp/mod_amqp_connection.c
w32/rabbitmq-c-version.props
w32/rabbitmq-c.props

old mode 100755 (executable)
new mode 100644 (file)
index 1d0c71f..1bddd56
@@ -1546,9 +1546,22 @@ PKG_CHECK_MODULES([SIGNALWIRE_CLIENT], [signalwire_client2 >= 2.0.0],[
   ])
 ])
 
-PKG_CHECK_MODULES([AMQP], [librabbitmq >= 0.5.2],[
-  AM_CONDITIONAL([HAVE_AMQP],[true])],[
-  AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_AMQP],[false])])
+PKG_CHECK_MODULES([AMQP], [librabbitmq >= 0.5.2], [
+       AM_CONDITIONAL([HAVE_AMQP], [true])
+       # Extract the version of librabbitmq
+       AMQP_VERSION=`$PKG_CONFIG --modversion librabbitmq`
+       AC_DEFINE_UNQUOTED([AMQP_VERSION], ["$AMQP_VERSION"], [Version of librabbitmq])
+       # Parse major and minor version numbers
+       AMQP_MAJOR_VERSION=`echo $AMQP_VERSION | cut -d. -f1`
+       AMQP_MINOR_VERSION=`echo $AMQP_VERSION | cut -d. -f2`
+       AC_DEFINE_UNQUOTED([AMQP_MAJOR_VERSION], [$AMQP_MAJOR_VERSION], [Major version of librabbitmq])
+       AC_DEFINE_UNQUOTED([AMQP_MINOR_VERSION], [$AMQP_MINOR_VERSION], [Minor version of librabbitmq])
+       AC_SUBST(AMQP_MAJOR_VERSION)
+       AC_SUBST(AMQP_MINOR_VERSION)
+   ], [
+       AC_MSG_RESULT([no])
+       AM_CONDITIONAL([HAVE_AMQP], [false])
+   ])
 
 PKG_CHECK_MODULES([H2O], [libh2o-evloop >= 0.11.0],[
   AM_CONDITIONAL([HAVE_H2O],[true])],[
index 7bb93927b8e13bc6f6964e1615d3ffb2a57e3f62..1266e9e09a48b371ad2580873bdf013167a7842e 100644 (file)
@@ -5,7 +5,7 @@ if HAVE_AMQP
 
 mod_LTLIBRARIES = mod_amqp.la
 mod_amqp_la_SOURCES  = mod_amqp_utils.c mod_amqp_connection.c mod_amqp_producer.c mod_amqp_command.c mod_amqp_logging.c mod_amqp.c
-mod_amqp_la_CFLAGS   = $(AM_CFLAGS) $(AMQP_CFLAGS)
+mod_amqp_la_CFLAGS   = $(AM_CFLAGS) $(AMQP_CFLAGS) -DAMQP_MAJOR_VERSION=$(AMQP_MAJOR_VERSION) -DAMQP_MINOR_VERSION=$(AMQP_MINOR_VERSION)
 mod_amqp_la_LIBADD   = $(switch_builddir)/libfreeswitch.la
 mod_amqp_la_LDFLAGS  = -avoid-version -module -no-undefined -shared $(AMQP_LIBS) $(SWITCH_AM_LDFLAGS)
 
index f5c63780a47aa93fe22d7961adaf731e6ef72fc0..39df8638ebcbd198fbf6fe0c6b2c7c392cf539ab 100644 (file)
 #define MOD_AMQP_H
 
 #include <switch.h>
+#define AMQP_VERSION_INT(a, b) ((a)<<8 | (b))
+#if AMQP_VERSION_INT(AMQP_MAJOR_VERSION, AMQP_MINOR_VERSION) >= AMQP_VERSION_INT(0, 12)
+#include <rabbitmq-c/amqp.h>
+#include <rabbitmq-c/framing.h>
+#include <rabbitmq-c/tcp_socket.h>
+#include <rabbitmq-c/ssl_socket.h>
+#else
 #include <amqp.h>
 #include <amqp_framing.h>
 #include <amqp_tcp_socket.h>
 #include <amqp_ssl_socket.h>
+#endif
 
 #ifndef _MSC_VER
 #include <strings.h>
index 73cf09a35407a2313d5b53b2169dff92c8cd8ec6..758eac241e4f4d34fa1338bf63719dee11438dec 100644 (file)
@@ -117,7 +117,9 @@ switch_status_t mod_amqp_connection_open(mod_amqp_connection_t *connections, mod
 
        while (connection_attempt && amqp_status){
                if (connection_attempt->ssl_on == 1) {
+#if AMQP_VERSION_INT(AMQP_MAJOR_VERSION, AMQP_MINOR_VERSION) < AMQP_VERSION_INT(0, 13)
                        amqp_set_initialize_ssl_library(connection_attempt->ssl_on);
+#endif
                        if (!(socket = amqp_ssl_socket_new(newConnection))) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not create SSL socket\n");
                                goto err;
index 885ccb6986149ab3f5ff04bb5887b4ce10476cb2..6143d8a317c3abbbceeda8a139cd3cc7c0cc719d 100644 (file)
@@ -4,6 +4,9 @@
     <Import Project="basedir.props" Condition=" '$(BaseDirImported)' == ''"/>
   </ImportGroup>
   <PropertyGroup Label="UserMacros">
+    <rabbitmq_cMajorVersion>0</rabbitmq_cMajorVersion>
+    <rabbitmq_cMinorVersion>15</rabbitmq_cMinorVersion>
+    <rabbitmq_cRevisionVersion>0</rabbitmq_cRevisionVersion>
     <rabbitmq_cVersion>0.15.0</rabbitmq_cVersion>
     <rabbitmq_cBuildNumber>0</rabbitmq_cBuildNumber>
   </PropertyGroup>
index 9ed46830da3e55c0827fa13ccd0a2f50f217946c..7a96177f590fecf6d72906549b391b9be61d8e18 100644 (file)
@@ -52,6 +52,7 @@
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(rabbitmq_c_libDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>AMQP_MAJOR_VERSION=$(rabbitmq_cMajorVersion);AMQP_MINOR_VERSION=$(rabbitmq_cMinorVersion);%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(rabbitmq_c_libDir)\binaries\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>