diff --git a/Makefile.am b/Makefile.am index 21b83bad2f..a3e942a036 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,9 +3,17 @@ SUBDIRS = . src AUTOMAKE_OPTIONS = foreign NAME = freeswitch +AM_LIBAPR_CFLAGS := $(shell ./libs/apr/apr-1-config --cflags) +AM_LIBAPR_CPPFLAGS := $(shell ./libs/apr/apr-1-config --cppflags --includes) +AM_LIBAPR_LDFLAGS := $(shell ./libs/apr/apr-1-config --ldflags) +AM_LIBAPR_LIBS := $(subst $(CURDIR)/,,$(shell ./libs/apr/apr-1-config \--link-libtool \--libs)) +AM_LIBAPU_CPPFLAGS := $(shell ./libs/apr-util/apu-1-config --includes) +AM_LIBAPU_LDFLAGS := $(shell ./libs/apr-util/apu-1-config --ldflags) +AM_LIBAPU_LIBS := $(subst $(CURDIR)/,,$(shell ./libs/apr-util/apu-1-config \--link-libtool \--libs)) + AM_CFLAGS = $(SWITCH_AM_CFLAGS) $(SWITCH_ANSI_CFLAGS) AM_CPPFLAGS = $(SWITCH_AM_CXXFLAGS) -Ilibs/sofia-sip/libsofia-sip-ua/sdp -Ilibs/sofia-sip/libsofia-sip-ua/su -AM_LDFLAGS = $(SWITCH_AM_LDFLAGS) +AM_LDFLAGS = $(SWITCH_AM_LDFLAGS) $(AM_LIBAPR_LDFLAGS) $(AM_LIBAPU_LDFLAGS) DEFAULT_SOUNDS=en-us-callie-8000 @@ -101,8 +109,8 @@ $(RECURSIVE_TARGETS): freeswitch exit 1; \ fi ; -CORE_CFLAGS = `$(switch_builddir)/libs/apr/apr-1-config --cflags --cppflags --includes` -CORE_CFLAGS += `$(switch_builddir)/libs/apr-util/apu-1-config --includes` +CORE_CFLAGS = $(AM_LIBAPR_CFLAGS) $(AM_LIBAPR_CPPFLAGS) +CORE_CFLAGS += $(AM_LIBAPU_CPPFLAGS) CORE_CFLAGS += -I$(switch_srcdir)/libs/libtpl-1.5/src CORE_CFLAGS += -I$(switch_srcdir)/libs/stfu CORE_CFLAGS += -I$(switch_builddir)/libs/sqlite @@ -112,7 +120,7 @@ CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/include CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/crypto/include -Ilibs/srtp/crypto/include CORE_CFLAGS += -I$(switch_srcdir)/libs/spandsp/src -I$(switch_srcdir)/libs/tiff-4.0.2/libtiff -CORE_LIBS = libs/apr-util/libaprutil-1.la libs/apr/libapr-1.la +CORE_LIBS = $(AM_LIBAPU_LIBS) $(AM_LIBAPR_LIBS) CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la libs/speex/libspeex/libspeexdsp.la if ENABLE_SRTP diff --git a/acinclude.m4 b/acinclude.m4 index 58b5500a80..aeba17b5c3 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -6,7 +6,6 @@ m4_include([build/config/ac_gcc_archflag.m4]) m4_include([build/config/ac_gcc_x86_cpuid.m4]) m4_include([build/config/ax_lib_mysql.m4]) m4_include([build/config/ax_check_java.m4]) -m4_include([build/config/uuid.m4]) m4_include([build/config/erlang.m4]) m4_include([build/config/odbc.m4]) m4_include([build/config/sched_setaffinity.m4]) diff --git a/build/config/uuid.m4 b/build/config/uuid.m4 deleted file mode 100644 index 7f37c23c66..0000000000 --- a/build/config/uuid.m4 +++ /dev/null @@ -1,17 +0,0 @@ -AC_DEFUN([CHECK_LIBUUID], - [ - PKG_CHECK_MODULES([LIBUUID], [uuid >= 1.41.2], - [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no]) - if test "$LIBUUID_FOUND" = "no" ; then - PKG_CHECK_MODULES([LIBUUID], [uuid], - [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no]) - if test "$LIBUUID_FOUND" = "no" ; then - AC_MSG_WARN([libuuid development package highly recommended!]) - else - LIBUUID_INCLUDEDIR=$(pkg-config --variable=includedir uuid) - LIBUUID_CFLAGS+=" -I$LIBUUID_INCLUDEDIR/uuid " - fi - fi - AC_SUBST([LIBUUID_CFLAGS]) - AC_SUBST([LIBUUID_LIBS]) - ]) diff --git a/conf/rayo/autoload_configs/rayo.conf.xml b/conf/rayo/autoload_configs/rayo.conf.xml index 35419319bc..c8171569af 100644 --- a/conf/rayo/autoload_configs/rayo.conf.xml +++ b/conf/rayo/autoload_configs/rayo.conf.xml @@ -16,6 +16,12 @@ + + + + + + @@ -65,6 +71,7 @@ ]]> ]]> ]]> + ]]> ]]> ]]> ]]> diff --git a/configure.in b/configure.in index d186eebc94..9307c958c9 100644 --- a/configure.in +++ b/configure.in @@ -412,10 +412,6 @@ if test "x$enable_core_odbc_support" != "xno"; then AC_CHECK_LIB([odbc], [SQLDisconnect],, AC_MSG_ERROR([no usable libodbc; please install unixodbc devel package or equivalent])) fi -CHECK_LIBUUID -SWITCH_AM_LDFLAGS="$LIBUUID_LIBS $SWITCH_AM_LDFLAGS" -SWITCH_AM_CFLAGS="$LIBUUID_CFLAGS $SWITCH_AM_CFLAGS" - AC_ARG_ENABLE(core-pgsql-support, [AS_HELP_STRING([--enable-core-pgsql-support], [Compile with PGSQL Support])],,[enable_core_pgsql_support="no"]) AC_ARG_ENABLE(core-pgsql-pkgconfig, diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 3ac9bd0a36..227d5a698f 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -789,11 +789,16 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch len = tech_pvt->read_frame.buflen; if (ftdm_channel_read(tech_pvt->ftdmchan, tech_pvt->read_frame.data, &len) != FTDM_SUCCESS) { + if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Failed to read from dead channel %s device %d:%d\n", name, span_id, chan_id); + goto normal_failure; + } switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); if (++tech_pvt->read_error > FTDM_MAX_READ_WRITE_ERRORS) { switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "too many I/O read errors on channel %s device %d:%d!\n", name, span_id, chan_id); goto fail; } + } else { tech_pvt->read_error = 0; } @@ -822,6 +827,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch fail: switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "clearing IO in channel %s device %d:%d!\n", name, span_id, chan_id); +normal_failure: switch_clear_flag_locked(tech_pvt, TFLAG_IO); return SWITCH_STATUS_GENERR; } diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c index 8cf43bbdfd..fdeb67f4b9 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c +++ b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c @@ -291,13 +291,23 @@ static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(analog_em_set_channel_sig_status) return FTDM_FAIL; case FTDM_SIG_STATE_SUSPENDED: if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { + int cas_bits = 0xFF; ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED); + ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_CAS_BITS, &cas_bits); + if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { + ftdm_channel_command(ftdmchan, FTDM_COMMAND_OFFHOOK, NULL); + } ftdm_analog_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_SUSPENDED); } break; case FTDM_SIG_STATE_UP: if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { + int cas_bits = 0x00; ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED); + ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_CAS_BITS, &cas_bits); + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { + ftdm_channel_command(ftdmchan, FTDM_COMMAND_ONHOOK, NULL); + } if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) { ftdm_analog_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_UP); } @@ -643,7 +653,7 @@ static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj) case FTDM_CHANNEL_STATE_RING: { ftdm_sleep(interval); - if (ftdmchan->state == FTDM_CHANNEL_STATE_UP && cas_answer) { + if (ftdmchan->state == FTDM_CHANNEL_STATE_UP) { cas_bits = 0; ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_CAS_BITS, &cas_bits); if (!(state_counter % 5000)) { diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c index bb7e477092..e7122740aa 100644 --- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c +++ b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c @@ -951,6 +951,21 @@ static FIO_GET_ALARMS_FUNCTION(zt_get_alarms) return FTDM_SUCCESS; } +#define ftdm_zt_set_event_pending(fchan) \ + do { \ + ftdm_set_io_flag(fchan, FTDM_CHANNEL_IO_EVENT); \ + fchan->last_event_time = ftdm_current_time_in_ms(); \ + } while (0); + +#define ftdm_zt_store_chan_event(fchan, revent) \ + do { \ + if (fchan->io_data) { \ + ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Dropping event %d, not retrieved on time\n", revent); \ + } \ + fchan->io_data = (void *)zt_event_id; \ + ftdm_zt_set_event_pending(fchan); \ + } while (0); + /** * \brief Waits for an event on a Zaptel/DAHDI channel * \param ftdmchan Channel to open @@ -1015,7 +1030,7 @@ pollagain: *flags |= FTDM_WRITE; } - if (inflags & POLLPRI) { + if ((inflags & POLLPRI) || (ftdmchan->io_data && (*flags & FTDM_EVENTS))) { *flags |= FTDM_EVENTS; } @@ -1044,19 +1059,28 @@ FIO_SPAN_POLL_EVENT_FUNCTION(zt_poll_event) j++; } - r = poll(pfds, j, ms); + r = poll(pfds, j, ms); if (r == 0) { return FTDM_TIMEOUT; - } else if (r < 0 || (pfds[i-1].revents & POLLERR)) { + } else if (r < 0) { snprintf(span->last_error, sizeof(span->last_error), "%s", strerror(errno)); return FTDM_FAIL; } for(i = 1; i <= span->chan_count; i++) { - if (pfds[i-1].revents & POLLPRI) { - ftdm_set_io_flag(span->channels[i], FTDM_CHANNEL_IO_EVENT); - span->channels[i]->last_event_time = ftdm_current_time_in_ms(); + + ftdm_channel_lock(span->channels[i]); + + if (pfds[i-1].revents & POLLERR) { + ftdm_log_chan(span->channels[i], FTDM_LOG_ERROR, "POLLERR, flags=%d\n", pfds[i-1].events); + + ftdm_channel_unlock(span->channels[i]); + + continue; + } + if ((pfds[i-1].revents & POLLPRI) || (span->channels[i]->io_data)) { + ftdm_zt_set_event_pending(span->channels[i]); k++; } if (pfds[i-1].revents & POLLIN) { @@ -1065,6 +1089,9 @@ FIO_SPAN_POLL_EVENT_FUNCTION(zt_poll_event) if (pfds[i-1].revents & POLLOUT) { ftdm_set_io_flag(span->channels[i], FTDM_CHANNEL_IO_WRITE); } + + ftdm_channel_unlock(span->channels[i]); + } if (!k) { @@ -1243,7 +1270,10 @@ FIO_CHANNEL_NEXT_EVENT_FUNCTION(zt_channel_next_event) ftdm_clear_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT); } - if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { + if (ftdmchan->io_data) { + zt_event_id = (zt_event_t)ftdmchan->io_data; + ftdmchan->io_data = NULL; + } else if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed retrieving event from channel: %s\n", strerror(errno)); return FTDM_FAIL; @@ -1274,30 +1304,48 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event) uint32_t i, event_id = FTDM_OOB_INVALID; zt_event_t zt_event_id = 0; - for(i = 1; i <= span->chan_count; i++) { + for (i = 1; i <= span->chan_count; i++) { ftdm_channel_t *fchan = span->channels[i]; - if (ftdm_test_io_flag(fchan, FTDM_CHANNEL_IO_EVENT)) { - ftdm_clear_io_flag(fchan, FTDM_CHANNEL_IO_EVENT); - if (ioctl(fchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { - snprintf(span->last_error, sizeof(span->last_error), "%s", strerror(errno)); - return FTDM_FAIL; - } - ftdm_channel_lock(fchan); - if ((zt_channel_process_event(fchan, &event_id, zt_event_id)) != FTDM_SUCCESS) { - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to process DAHDI event %d from channel\n", zt_event_id); - ftdm_channel_unlock(fchan); - return FTDM_FAIL; - } + ftdm_channel_lock(fchan); + + if (!ftdm_test_io_flag(fchan, FTDM_CHANNEL_IO_EVENT)) { + ftdm_channel_unlock(fchan); - fchan->last_event_time = 0; - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = fchan; - *event = &span->event_header; - return FTDM_SUCCESS; + continue; } + + ftdm_clear_io_flag(fchan, FTDM_CHANNEL_IO_EVENT); + + if (fchan->io_data) { + zt_event_id = (zt_event_t)fchan->io_data; + fchan->io_data = NULL; + } else if (ioctl(fchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { + ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to retrieve DAHDI event from channel: %s\n", strerror(errno)); + + ftdm_channel_unlock(fchan); + + continue; + } + + if ((zt_channel_process_event(fchan, &event_id, zt_event_id)) != FTDM_SUCCESS) { + ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to process DAHDI event %d from channel\n", zt_event_id); + + ftdm_channel_unlock(fchan); + + return FTDM_FAIL; + } + + fchan->last_event_time = 0; + span->event_header.e_type = FTDM_EVENT_OOB; + span->event_header.enum_id = event_id; + span->event_header.channel = fchan; + *event = &span->event_header; + + ftdm_channel_unlock(fchan); + + return FTDM_SUCCESS; } return FTDM_FAIL; @@ -1348,11 +1396,13 @@ static FIO_READ_FUNCTION(zt_read) } if (handle_dtmf_event(ftdmchan, zt_event_id)) { - /* we should enqueue this event somewhere so it can be retrieved by the user, for now, dropping it to see what it is! */ - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Event %d is not dmtf related. Skipping one media read cycle\n", zt_event_id); + /* Enqueue this event for later */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Deferring event %d to be able to read data\n", zt_event_id); + ftdm_zt_store_chan_event(ftdmchan, zt_event_id); + } else { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Skipping one IO read cycle due to DTMF event processing\n"); } - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Skipping one IO read cycle due to events pending in the driver queue\n"); - break; + continue; } /* Read error, keep going unless to many errors force us to abort ...*/ @@ -1405,8 +1455,9 @@ tryagain: } if (handle_dtmf_event(ftdmchan, zt_event_id)) { - /* we should enqueue this event somewhere so it can be retrieved by the user, for now, dropping it to see what it is! */ - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dropping event %d to be able to write data\n", zt_event_id); + /* Enqueue this event for later */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Deferring event %d to be able to write data\n", zt_event_id); + ftdm_zt_store_chan_event(ftdmchan, zt_event_id); } goto tryagain; diff --git a/libs/libedit/configure.ac b/libs/libedit/configure.ac index 207bb0f118..7bd2ac6326 100644 --- a/libs/libedit/configure.ac +++ b/libs/libedit/configure.ac @@ -71,7 +71,7 @@ AC_PROG_GCC_TRADITIONAL #AC_FUNC_REALLOC AC_TYPE_SIGNAL AC_FUNC_STAT -AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strcspn strdup strerror strrchr strstr strtol issetugid]) +AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strlcat strlcpy strcspn strdup strerror strrchr strstr strtol issetugid]) EL_GETPW_R_POSIX EL_GETPW_R_DRAFT diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index bff9b72a78..aa6adb67e9 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -178,6 +178,7 @@ struct switch_core_session { switch_size_t recur_buffer_len; switch_media_handle_t *media_handle; + uint32_t decoder_errors; }; struct switch_media_bug { diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 9641718f07..5c083101a9 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -68,7 +68,6 @@ typedef enum { SCMF_RUNNING, SCMF_DISABLE_TRANSCODING, SCMF_AUTOFIX_TIMING, - SCMF_AUTOFIX_PT, SCMF_CODEC_GREEDY, SCMF_CODEC_SCROOGE, SCMF_DISABLE_HOLD, @@ -81,6 +80,8 @@ typedef enum { SCMF_AUTOFLUSH, SCMF_REWRITE_TIMESTAMPS, SCMF_RTP_AUTOFLUSH_DURING_BRIDGE, + SCMF_MULTI_ANSWER_AUDIO, + SCMF_MULTI_ANSWER_VIDEO, SCMF_MAX } switch_core_media_flag_t; @@ -156,6 +157,53 @@ typedef struct switch_core_media_params_s { } switch_core_media_params_t; +typedef struct xpayload_map_s { + uint32_t pt; + uint32_t send_pt; + uint32_t rate; + uint32_t ptime; + switch_media_type_t type; + uint8_t negotiated; + char *name; + switch_sdp_type_t sdp_type; + unsigned long hash; + struct xpayload_map_s *next; +} xpayload_map_t; + +typedef struct payload_map_s { + switch_media_type_t type; + switch_sdp_type_t sdp_type; + uint32_t ptime; + uint32_t rate; + uint8_t allocated; + uint8_t negotiated; + unsigned long hash; + + char *rm_encoding; + char *iananame; + switch_payload_t pt; + unsigned long rm_rate; + unsigned long adv_rm_rate; + uint32_t codec_ms; + uint32_t bitrate; + + char *rm_fmtp; + + switch_payload_t agreed_pt; + switch_payload_t recv_pt; + + char *fmtp_out; + + char *remote_sdp_ip; + switch_port_t remote_sdp_port; + + int channels; + int adv_channels; + + struct payload_map_s *next; + +} payload_map_t; + static inline const char *switch_media_type2str(switch_media_type_t type) { switch(type) { @@ -216,7 +264,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi SWITCH_DECLARE(switch_status_t) switch_core_media_ext_address_lookup(switch_core_session_t *session, char **ip, switch_port_t *port, const char *sourceip); SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_core_session_t *session, switch_core_session_t *other_session, switch_t38_options_t *t38_options); -SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, const char *ip, switch_port_t port, const char *sr, int force); +SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, switch_sdp_type_t sdp_type, + const char *ip, switch_port_t port, const char *sr, int force); SWITCH_DECLARE(void)switch_core_media_set_local_sdp(switch_core_session_t *session, const char *sdp_str, switch_bool_t dup); SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session); SWITCH_DECLARE(void) switch_core_media_set_udptl_image_sdp(switch_core_session_t *session, switch_t38_options_t *t38_options, int insist); @@ -232,7 +281,6 @@ SWITCH_DECLARE(void) switch_core_media_kill_socket(switch_core_session_t *sessio SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833(switch_core_session_t *session, switch_media_type_t type, const switch_dtmf_t *dtmf); SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833_in(switch_core_session_t *session, switch_media_type_t type, const switch_dtmf_t *dtmf); SWITCH_DECLARE(uint8_t) switch_core_media_ready(switch_core_session_t *session, switch_media_type_t type); -SWITCH_DECLARE(void) switch_core_media_set_recv_pt(switch_core_session_t *session, switch_media_type_t type, switch_payload_t pt); SWITCH_DECLARE(void) switch_core_media_set_telephony_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te); SWITCH_DECLARE(void) switch_core_media_set_telephony_recv_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te); SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_stats(switch_core_session_t *session, switch_media_type_t type, switch_memory_pool_t *pool); @@ -257,6 +305,14 @@ SWITCH_DECLARE(void) switch_core_media_deinit(void); SWITCH_DECLARE(void) switch_core_media_set_stats(switch_core_session_t *session); SWITCH_DECLARE(void) switch_core_session_wake_video_thread(switch_core_session_t *session); SWITCH_DECLARE(void) switch_core_session_clear_crypto(switch_core_session_t *session); +SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session, + switch_media_type_t type, + const char *name, + switch_sdp_type_t sdp_type, + uint32_t pt, + uint32_t rate, + uint32_t ptime, + uint8_t negotiated); SWITCH_END_EXTERN_C #endif diff --git a/src/include/switch_frame.h b/src/include/switch_frame.h index 39ffb9ca6b..4e46b61d2f 100644 --- a/src/include/switch_frame.h +++ b/src/include/switch_frame.h @@ -37,6 +37,7 @@ #define SWITCH_FRAME_H #include +#include SWITCH_BEGIN_EXTERN_C /*! \brief An abstraction of a data frame */ @@ -71,6 +72,7 @@ SWITCH_BEGIN_EXTERN_C /*! frame flags */ switch_frame_flag_t flags; void *user_data; + payload_map_t *pmap; }; SWITCH_END_EXTERN_C diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index bd509cc29a..ca0b3f3b8d 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -485,7 +485,6 @@ SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *pri */ SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te); SWITCH_DECLARE(void) switch_rtp_set_telephony_recv_event(switch_rtp_t *rtp_session, switch_payload_t te); -SWITCH_DECLARE(void) switch_rtp_set_recv_pt(switch_rtp_t *rtp_session, switch_payload_t pt); /*! \brief Set the payload type for comfort noise @@ -500,7 +499,7 @@ SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_pay \return the pointer to the private data */ SWITCH_DECLARE(void *) switch_rtp_get_private(switch_rtp_t *rtp_session); - +SWITCH_DECLARE(switch_status_t) switch_rtp_set_payload_map(switch_rtp_t *rtp_session, payload_map_t **pmap); SWITCH_DECLARE(void) switch_rtp_intentional_bugs(switch_rtp_t *rtp_session, switch_rtp_bug_flag_t bugs); SWITCH_DECLARE(switch_rtp_stats_t *) switch_rtp_get_stats(switch_rtp_t *rtp_session, switch_memory_pool_t *pool); diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 2e4259817a..4a3153de5a 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1929,40 +1929,91 @@ SWITCH_STANDARD_API(cond_function) } a = argv[0]; + while(*a == ' ' || *a == '\t') a++; - if ((expr = strchr(a, '!'))) { - *expr++ = '\0'; - if (*expr == '=') { - o = O_NE; - } - } else if ((expr = strchr(a, '>'))) { - if (*(expr + 1) == '=') { + if (*a == '\'') { + if ((expr = switch_find_end_paren(a, '\'', '\''))) { + a++; *expr++ = '\0'; - o = O_GE; } else { - o = O_GT; + goto error; } - } else if ((expr = strchr(a, '<'))) { - if (*(expr + 1) == '=') { + } else { + if ((expr = strchr(a, ' '))) { *expr++ = '\0'; - o = O_LE; } else { - o = O_LT; - } - } else if ((expr = strchr(a, '='))) { - *expr++ = '\0'; - if (*expr == '=') { - o = O_EQ; + expr = a; } } + while(expr && *expr) { + switch(*expr) { + case '!': + case '<': + case '>': + case '=': + goto done; + default: + expr++; + break; + } + } + + done: + + switch(*expr) { + case '!': + *expr++ = '\0'; + if (*expr == '=') { + o = O_NE; + *expr++ = '\0'; + } + break; + + case '>': + *expr++ = '\0'; + if (*expr == '=') { + o = O_GE; + *expr++ = '\0'; + } else { + o = O_GT; + } + break; + + case '<': + *expr++ = '\0'; + if (*expr == '=') { + o = O_LE; + *expr++ = '\0'; + } else { + o = O_LT; + } + break; + + case '=': + *expr++ = '\0'; + if (*expr == '=') { + o = O_EQ; + *expr++ = '\0'; + } + break; + + default: + goto error; + } + + if (o) { char *s_a = NULL, *s_b = NULL; int a_is_num, b_is_num; - *expr++ = '\0'; + + expr++; b = expr; + s_a = switch_strip_spaces(a, SWITCH_TRUE); s_b = switch_strip_spaces(b, SWITCH_TRUE); + + a_is_num = switch_is_number(s_a); b_is_num = switch_is_number(s_b); diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 8f3f1a81b8..55e681aa09 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -184,7 +184,8 @@ typedef enum { MFLAG_NOMOH = (1 << 19), MFLAG_VIDEO_BRIDGE = (1 << 20), MFLAG_INDICATE_MUTE_DETECT = (1 << 21), - MFLAG_PAUSE_RECORDING = (1 << 22) + MFLAG_PAUSE_RECORDING = (1 << 22), + MFLAG_ACK_VIDEO = (1 << 23) } member_flag_t; typedef enum { @@ -1796,6 +1797,10 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe channel = switch_core_session_get_channel(member->session); + if (switch_channel_test_flag(channel, CF_VIDEO)) { + switch_set_flag_locked(member, MFLAG_ACK_VIDEO); + } + switch_channel_set_variable_printf(channel, "conference_member_id", "%d", member->id); switch_channel_set_variable_printf(channel, "conference_moderator", "%s", switch_test_flag(member, MFLAG_MOD) ? "true" : "false"); switch_channel_set_variable(channel, "conference_recording", conference->record_filename); @@ -2595,6 +2600,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v char *rfile = switch_channel_expand_variables(channel, conference->auto_record); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto recording file: %s\n", rfile); launch_conference_record_thread(conference, rfile, SWITCH_TRUE); + if (rfile != conference->auto_record) { conference->record_filename = switch_core_strdup(conference->pool, rfile); switch_safe_free(rfile); @@ -3639,6 +3645,12 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v break; } + if (switch_channel_test_flag(channel, CF_VIDEO) && !switch_test_flag(member, MFLAG_ACK_VIDEO)) { + switch_set_flag_locked(member, MFLAG_ACK_VIDEO); + switch_channel_clear_flag(channel, CF_VIDEO_ECHO); + switch_core_session_refresh_video(member->session); + } + /* if we have caller digits, feed them to the parser to find an action */ if (switch_channel_has_dtmf(channel)) { char dtmf[128] = ""; diff --git a/src/mod/applications/mod_mongo/Makefile b/src/mod/applications/mod_mongo/Makefile index 9ce16b1171..7a6e1058ab 100644 --- a/src/mod/applications/mod_mongo/Makefile +++ b/src/mod/applications/mod_mongo/Makefile @@ -1,6 +1,6 @@ BASE=../../../.. -MONGO_CXX_DRIVER_VERSION=v1.8 +MONGO_CXX_DRIVER_VERSION=v2.4 MONGO_CXX_DRIVER_URL=http://downloads.mongodb.org/cxx-driver MONGO_CXX_DRIVER_TARBALL=mongodb-linux-x86_64-$(MONGO_CXX_DRIVER_VERSION)-latest.tgz MONGO_CXX_DRIVER_SRC=$(BASE)/libs/mongo-cxx-driver-$(MONGO_CXX_DRIVER_VERSION) @@ -9,7 +9,7 @@ LIBMONGOCLIENT_A =$(MONGO_CXX_DRIVER_SRC)/libmongoclient.a LOCAL_SOURCES=mongo_conn.cpp LOCAL_OBJS=mongo_conn.o -LOCAL_CFLAGS=-I$(MONGO_CXX_DRIVER_SRC)/mongo +LOCAL_CFLAGS=-I$(MONGO_CXX_DRIVER_SRC)/src LOCAL_LIBADD=$(LIBMONGOCLIENT_A) LOCAL_LDFLAGS=-lboost_thread -lboost_filesystem-mt -lboost_system-mt MODDIR=$(shell pwd) diff --git a/src/mod/applications/mod_mongo/fpic_hack.diff b/src/mod/applications/mod_mongo/fpic_hack.diff index 882f3c899a..1f85f85c97 100644 --- a/src/mod/applications/mod_mongo/fpic_hack.diff +++ b/src/mod/applications/mod_mongo/fpic_hack.diff @@ -1,11 +1,11 @@ ---- SConstruct.orig 2011-04-28 19:00:36.000000000 +0200 -+++ SConstruct 2011-04-28 19:01:19.000000000 +0200 -@@ -45,7 +45,7 @@ - linux = True +--- SConstruct 2013-10-30 17:18:51.160645496 -0400 ++++ new 2013-10-30 17:22:18.790072856 -0400 +@@ -78,7 +78,7 @@ + env['DIST_ARCHIVE_SUFFIX'] = '.tgz' if nix: -- env.Append( CPPFLAGS=" -O3" ) -+ env.Append( CPPFLAGS=" -I../pcre -fPIC -O3" ) - env.Append( LIBS=["pthread"] ) +- env.Append(CCFLAGS=["-O3", "-pthread"]) ++ env.Append(CCFLAGS=["-I../pcre", "-fPIC", "-O3", "-pthread"]) if linux: - env.Append( LINKFLAGS=" -Wl,--as-needed -Wl,-zdefs " ) + env.Append(LINKFLAGS=["-pthread"]) + diff --git a/src/mod/applications/mod_mongo/mod_mongo.cpp b/src/mod/applications/mod_mongo/mod_mongo.cpp index 83b31c7546..8c3536def2 100644 --- a/src/mod/applications/mod_mongo/mod_mongo.cpp +++ b/src/mod/applications/mod_mongo/mod_mongo.cpp @@ -1,6 +1,6 @@ -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2013, Anthony Minessale II * * Version: MPL 1.1 * @@ -22,7 +22,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * + * * Tamas Cseke * * mod_mongo.cpp -- API for MongoDB @@ -53,7 +53,7 @@ SWITCH_STANDARD_API(mongo_mapreduce_function) switch_assert(ns != NULL); if ((json_query = strchr(ns, DELIMITER))) { - *json_query++ = '\0'; + *json_query++ = '\0'; } if (!zstr(ns) && !zstr(json_query)) { @@ -62,7 +62,7 @@ SWITCH_STANDARD_API(mongo_mapreduce_function) BSONObj out; BSONObjBuilder cmd; - cmd.append("mapreduce", conn->nsGetCollection(ns)); + cmd.append("mapreduce", nsGetCollection(ns)); if (!zstr(globals.map)) { cmd.appendCode("map", globals.map); } @@ -79,10 +79,10 @@ SWITCH_STANDARD_API(mongo_mapreduce_function) conn = mongo_connection_pool_get(globals.conn_pool); if (conn) { - conn->runCommand(conn->nsGetDB(ns), cmd.done(), out); + conn->runCommand(nsGetDB(ns), cmd.done(), out); mongo_connection_pool_put(globals.conn_pool, conn, SWITCH_FALSE); - stream->write_function(stream, "-OK\n%s\n", out.toString().c_str()); + stream->write_function(stream, "-OK\n%s\n", out.jsonString().c_str()); } else { stream->write_function(stream, "-ERR\nNo connection\n"); } @@ -93,7 +93,7 @@ SWITCH_STANDARD_API(mongo_mapreduce_function) stream->write_function(stream, "-ERR\n%s\n", e.toString().c_str()); } } else { - stream->write_function(stream, "-ERR\n%s\n", MAPREDUCE_SYNTAX); + stream->write_function(stream, "-ERR\n%s\n", MAPREDUCE_SYNTAX); } switch_safe_free(ns); @@ -104,50 +104,50 @@ SWITCH_STANDARD_API(mongo_mapreduce_function) SWITCH_STANDARD_API(mongo_find_one_function) { - switch_status_t status = SWITCH_STATUS_SUCCESS; - char *ns = NULL, *json_query = NULL, *json_fields = NULL; + switch_status_t status = SWITCH_STATUS_SUCCESS; + char *ns = NULL, *json_query = NULL, *json_fields = NULL; - ns = strdup(cmd); - switch_assert(ns != NULL); + ns = strdup(cmd); + switch_assert(ns != NULL); - if ((json_query = strchr(ns, DELIMITER))) { - *json_query++ = '\0'; - if ((json_fields = strchr(json_query, DELIMITER))) { - *json_fields++ = '\0'; - } - } + if ((json_query = strchr(ns, DELIMITER))) { + *json_query++ = '\0'; + if ((json_fields = strchr(json_query, DELIMITER))) { + *json_fields++ = '\0'; + } + } - if (!zstr(ns) && !zstr(json_query) && !zstr(json_fields)) { + if (!zstr(ns) && !zstr(json_query) && !zstr(json_fields)) { - DBClientBase *conn = NULL; + DBClientBase *conn = NULL; - try { - BSONObj query = fromjson(json_query); - BSONObj fields = fromjson(json_fields); + try { + BSONObj query = fromjson(json_query); + BSONObj fields = fromjson(json_fields); - conn = mongo_connection_pool_get(globals.conn_pool); - if (conn) { - BSONObj res = conn->findOne(ns, Query(query), &fields); - mongo_connection_pool_put(globals.conn_pool, conn, SWITCH_FALSE); + conn = mongo_connection_pool_get(globals.conn_pool); + if (conn) { + BSONObj res = conn->findOne(ns, Query(query), &fields); + mongo_connection_pool_put(globals.conn_pool, conn, SWITCH_FALSE); - stream->write_function(stream, "-OK\n%s\n", res.toString().c_str()); - } else { - stream->write_function(stream, "-ERR\nNo connection\n"); - } - } catch (DBException &e) { - if (conn) { - mongo_connection_pool_put(globals.conn_pool, conn, SWITCH_TRUE); - } - stream->write_function(stream, "-ERR\n%s\n", e.toString().c_str()); - } + stream->write_function(stream, "-OK\n%s\n", res.jsonString().c_str()); + } else { + stream->write_function(stream, "-ERR\nNo connection\n"); + } + } catch (DBException &e) { + if (conn) { + mongo_connection_pool_put(globals.conn_pool, conn, SWITCH_TRUE); + } + stream->write_function(stream, "-ERR\n%s\n", e.toString().c_str()); + } - } else { + } else { stream->write_function(stream, "-ERR\n%s\n", FIND_ONE_SYNTAX); - } + } - switch_safe_free(ns); + switch_safe_free(ns); - return status; + return status; } static switch_status_t config(void) @@ -214,21 +214,21 @@ SWITCH_MODULE_DEFINITION(mod_mongo, mod_mongo_load, mod_mongo_shutdown, NULL); SWITCH_MODULE_LOAD_FUNCTION(mod_mongo_load) { - switch_api_interface_t *api_interface; - switch_application_interface_t *app_interface; + switch_api_interface_t *api_interface; + switch_application_interface_t *app_interface; - *module_interface = switch_loadable_module_create_module_interface(pool, modname); + *module_interface = switch_loadable_module_create_module_interface(pool, modname); - memset(&globals, 0, sizeof(globals)); + memset(&globals, 0, sizeof(globals)); - if (config() != SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_TERM; - } - - SWITCH_ADD_API(api_interface, "mongo_find_one", "findOne", mongo_find_one_function, FIND_ONE_SYNTAX); - SWITCH_ADD_API(api_interface, "mongo_mapreduce", "Map/Reduce", mongo_mapreduce_function, MAPREDUCE_SYNTAX); + if (config() != SWITCH_STATUS_SUCCESS) { + return SWITCH_STATUS_TERM; + } - return SWITCH_STATUS_SUCCESS; + SWITCH_ADD_API(api_interface, "mongo_find_one", "findOne", mongo_find_one_function, FIND_ONE_SYNTAX); + SWITCH_ADD_API(api_interface, "mongo_mapreduce", "Map/Reduce", mongo_mapreduce_function, MAPREDUCE_SYNTAX); + + return SWITCH_STATUS_SUCCESS; } SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_mongo_shutdown) diff --git a/src/mod/applications/mod_mongo/mod_mongo.h b/src/mod/applications/mod_mongo/mod_mongo.h index 00e927f3a1..822dacaf63 100644 --- a/src/mod/applications/mod_mongo/mod_mongo.h +++ b/src/mod/applications/mod_mongo/mod_mongo.h @@ -1,6 +1,6 @@ -/* +/* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2013, Anthony Minessale II * * Version: MPL 1.1 * @@ -32,22 +32,19 @@ #ifndef MOD_MONGO_H #define MOD_MONGO_H -#include -#include -#include -#include +#include using namespace mongo; typedef struct { - char *conn_str; + char *conn_str; - switch_size_t min_connections; - switch_size_t max_connections; - switch_size_t size; - switch_queue_t *connections; - switch_mutex_t *mutex; - switch_memory_pool_t *pool; + switch_size_t min_connections; + switch_size_t max_connections; + switch_size_t size; + switch_queue_t *connections; + switch_mutex_t *mutex; + switch_memory_pool_t *pool; } mongo_connection_pool_t; @@ -56,7 +53,7 @@ switch_status_t mongo_connection_create(DBClientBase **connection, const char *c void mongo_connection_destroy(DBClientBase **conn); switch_status_t mongo_connection_pool_create(mongo_connection_pool_t **conn_pool, switch_size_t min_connections, switch_size_t max_connections, - const char *conn_str); + const char *conn_str); void mongo_connection_pool_destroy(mongo_connection_pool_t **conn_pool); diff --git a/src/mod/applications/mod_mongo/mongo_conn.cpp b/src/mod/applications/mod_mongo/mongo_conn.cpp index 8c7687b860..fd095fe54a 100644 --- a/src/mod/applications/mod_mongo/mongo_conn.cpp +++ b/src/mod/applications/mod_mongo/mongo_conn.cpp @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2012, Anthony Minessale II + * Copyright (C) 2005-2013, Anthony Minessale II * * Version: MPL 1.1 * @@ -42,162 +42,161 @@ switch_status_t mongo_connection_create(DBClientBase **connection, const char *conn_str) { - DBClientBase *conn = NULL; - string conn_string(conn_str), err_msg; - ConnectionString cs = ConnectionString::parse(conn_string, err_msg); - switch_status_t status = SWITCH_STATUS_FALSE; - - if (!cs.isValid()) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't parse url: %s\n", err_msg.c_str()); - return status; - } + DBClientBase *conn = NULL; + string conn_string(conn_str), err_msg; + ConnectionString cs = ConnectionString::parse(conn_string, err_msg); + switch_status_t status = SWITCH_STATUS_FALSE; - try { - conn = cs.connect(err_msg); - } catch (DBException &e) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect to mongo [%s]: %s\n", conn_str, err_msg.c_str()); - return status; - } + if (!cs.isValid()) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't parse url: %s\n", err_msg.c_str()); + return status; + } - if (conn) { - *connection = conn; - status = SWITCH_STATUS_SUCCESS; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to mongo [%s]\n", conn_str); - } + try { + conn = cs.connect(err_msg); + } catch (DBException &e) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect to mongo [%s]: %s\n", conn_str, err_msg.c_str()); + return status; + } - return status; + if (conn) { + *connection = conn; + status = SWITCH_STATUS_SUCCESS; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to mongo [%s]\n", conn_str); + } + + return status; } void mongo_connection_destroy(DBClientBase **conn) { - switch_assert(*conn != NULL); - delete *conn; + switch_assert(*conn != NULL); + delete *conn; - *conn = NULL; + *conn = NULL; } switch_status_t mongo_connection_pool_create(mongo_connection_pool_t **conn_pool, switch_size_t min_connections, switch_size_t max_connections, - const char *conn_str) + const char *conn_str) { - switch_memory_pool_t *pool = NULL; - switch_status_t status = SWITCH_STATUS_SUCCESS; - mongo_connection_pool_t *cpool = NULL; - DBClientBase *conn = NULL; + switch_memory_pool_t *pool = NULL; + switch_status_t status = SWITCH_STATUS_SUCCESS; + mongo_connection_pool_t *cpool = NULL; + DBClientBase *conn = NULL; - if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) { - return status; - } + if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) { + return status; + } - if (!(cpool = (mongo_connection_pool_t *)switch_core_alloc(pool, sizeof(mongo_connection_pool_t)))) { - switch_goto_status(SWITCH_STATUS_MEMERR, done); - } + if (!(cpool = (mongo_connection_pool_t *)switch_core_alloc(pool, sizeof(mongo_connection_pool_t)))) { + switch_goto_status(SWITCH_STATUS_MEMERR, done); + } - if ((status = switch_mutex_init(&cpool->mutex, SWITCH_MUTEX_NESTED, pool)) != SWITCH_STATUS_SUCCESS) { - goto done; - } + if ((status = switch_mutex_init(&cpool->mutex, SWITCH_MUTEX_NESTED, pool)) != SWITCH_STATUS_SUCCESS) { + goto done; + } - if ((status = switch_queue_create(&cpool->connections, max_connections, pool)) != SWITCH_STATUS_SUCCESS) { - goto done; - } + if ((status = switch_queue_create(&cpool->connections, max_connections, pool)) != SWITCH_STATUS_SUCCESS) { + goto done; + } - cpool->min_connections = min_connections; - cpool->max_connections = max_connections; - cpool->conn_str = switch_core_strdup(pool, conn_str); - - cpool->pool = pool; + cpool->min_connections = min_connections; + cpool->max_connections = max_connections; + cpool->conn_str = switch_core_strdup(pool, conn_str); + cpool->pool = pool; - for (cpool->size = 0; cpool->size < min_connections; cpool->size++) { + for (cpool->size = 0; cpool->size < min_connections; cpool->size++) { - if (mongo_connection_create(&conn, conn_str) == SWITCH_STATUS_SUCCESS) { - mongo_connection_pool_put(cpool, conn, SWITCH_FALSE); - } else { - break; - } - } + if (mongo_connection_create(&conn, conn_str) == SWITCH_STATUS_SUCCESS) { + mongo_connection_pool_put(cpool, conn, SWITCH_FALSE); + } else { + break; + } + } done: - if (status == SWITCH_STATUS_SUCCESS) { - *conn_pool = cpool; - } else { - switch_core_destroy_memory_pool(&pool); - } + if (status == SWITCH_STATUS_SUCCESS) { + *conn_pool = cpool; + } else { + switch_core_destroy_memory_pool(&pool); + } - return status; + return status; } void mongo_connection_pool_destroy(mongo_connection_pool_t **conn_pool) { - mongo_connection_pool_t *cpool = *conn_pool; - void *data = NULL; + mongo_connection_pool_t *cpool = *conn_pool; + void *data = NULL; - switch_assert(cpool != NULL); + switch_assert(cpool != NULL); - while (switch_queue_trypop(cpool->connections, &data) == SWITCH_STATUS_SUCCESS) { - mongo_connection_destroy((DBClientBase **)&data); - } + while (switch_queue_trypop(cpool->connections, &data) == SWITCH_STATUS_SUCCESS) { + mongo_connection_destroy((DBClientBase **)&data); + } - switch_mutex_destroy(cpool->mutex); - switch_core_destroy_memory_pool(&cpool->pool); + switch_mutex_destroy(cpool->mutex); + switch_core_destroy_memory_pool(&cpool->pool); - *conn_pool = NULL; + *conn_pool = NULL; } DBClientBase *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool) { - DBClientBase *conn = NULL; - void *data = NULL; + DBClientBase *conn = NULL; + void *data = NULL; - switch_assert(conn_pool != NULL); + switch_assert(conn_pool != NULL); - switch_mutex_lock(conn_pool->mutex); + switch_mutex_lock(conn_pool->mutex); - if (switch_queue_trypop(conn_pool->connections, &data) == SWITCH_STATUS_SUCCESS) { - conn = (DBClientBase *) data; - } else if (mongo_connection_create(&conn, conn_pool->conn_str) == SWITCH_STATUS_SUCCESS) { - if (++conn_pool->size > conn_pool->max_connections) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Connection pool is empty. You may want to increase 'max-connections'\n"); - } - } + if (switch_queue_trypop(conn_pool->connections, &data) == SWITCH_STATUS_SUCCESS) { + conn = (DBClientBase *) data; + } else if (mongo_connection_create(&conn, conn_pool->conn_str) == SWITCH_STATUS_SUCCESS) { + if (++conn_pool->size > conn_pool->max_connections) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Connection pool is empty. You may want to increase 'max-connections'\n"); + } + } - switch_mutex_unlock(conn_pool->mutex); + switch_mutex_unlock(conn_pool->mutex); #ifdef MONGO_POOL_DEBUG - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL get: size %d conn: %p\n", (int) switch_queue_size(conn_pool->connections), conn); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL get: size %d conn: %p\n", (int) switch_queue_size(conn_pool->connections), conn); #endif - return conn; + return conn; } switch_status_t mongo_connection_pool_put(mongo_connection_pool_t *conn_pool, DBClientBase *conn, switch_bool_t destroy) { - switch_status_t status = SWITCH_STATUS_SUCCESS; + switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_assert(conn_pool != NULL); - switch_assert(conn != NULL); + switch_assert(conn_pool != NULL); + switch_assert(conn != NULL); - switch_mutex_lock(conn_pool->mutex); - if (destroy || conn_pool->size > conn_pool->max_connections) { + switch_mutex_lock(conn_pool->mutex); + if (destroy || conn_pool->size > conn_pool->max_connections) { #ifdef MONGO_POOL_DEBUG - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: Destroy connection %p\n", conn); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: Destroy connection %p\n", conn); #endif - mongo_connection_destroy(&conn); - conn_pool->size--; - } else { + mongo_connection_destroy(&conn); + conn_pool->size--; + } else { #ifdef MONGO_POOL_DEBUG - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: push connection %p\n", conn); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: push connection %p\n", conn); #endif - status = switch_queue_push(conn_pool->connections, conn); - } + status = switch_queue_push(conn_pool->connections, conn); + } - switch_mutex_unlock(conn_pool->mutex); + switch_mutex_unlock(conn_pool->mutex); #ifdef MONGO_POOL_DEBUG - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: put size %d conn: %p\n", (int) switch_queue_size(conn_pool->connections), conn); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: put size %d conn: %p\n", (int) switch_queue_size(conn_pool->connections), conn); #endif - return status; + return status; } /* For Emacs: diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c index b1681ea5fa..f3d5585fdf 100644 --- a/src/mod/codecs/mod_opus/mod_opus.c +++ b/src/mod/codecs/mod_opus/mod_opus.c @@ -36,35 +36,229 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load); SWITCH_MODULE_DEFINITION(mod_opus, mod_opus_load, NULL, NULL); +/*! \brief Various codec settings */ +struct opus_codec_settings { + int useinbandfec; + int usedtx; + int maxaveragebitrate; + int stereo; + int cbr; + int sprop_maxcapturerate; + int sprop_stereo; + int maxptime; + int minptime; + int ptime; + int samplerate; +}; +typedef struct opus_codec_settings opus_codec_settings_t; + +static opus_codec_settings_t default_codec_settings = { + /*.useinbandfec */ 1, + /*.usedtx */ 1, + /*.maxaveragebitrate */ 30000, + /*.stereo*/ 0, + /*.cbr*/ 0, + /*.sprop_maxcapturerate*/ 0, + /*.sprop_stereo*/ 0, + /*.maxptime*/ 0, + /*.minptime*/ 0, + /*.ptime*/ 0, + /*.samplerate*/ 0 +}; + struct opus_context { OpusEncoder *encoder_object; OpusDecoder *decoder_object; int frame_size; }; +static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmtp_t *codec_fmtp) +{ + if (codec_fmtp) { + opus_codec_settings_t local_settings = { 0 }; + opus_codec_settings_t *codec_settings = &local_settings; + + if (codec_fmtp->private_info) { + codec_settings = codec_fmtp->private_info; + if (zstr(fmtp)) { + memcpy(codec_settings, &default_codec_settings, sizeof(*codec_settings)); + } + } + + if (fmtp) { + int x, argc; + char *argv[10]; + char *fmtp_dup = strdup(fmtp); + + switch_assert(fmtp_dup); + + argc = switch_separate_string(fmtp_dup, ';', argv, (sizeof(argv) / sizeof(argv[0]))); + for (x = 0; x < argc; x++) { + char *data = argv[x]; + char *arg; + switch_assert(data); + while (*data == ' ') { + data++; + } + + + if ((arg = strchr(data, '='))) { + *arg++ = '\0'; + + if (codec_settings) { + if (!strcasecmp(data, "useinbandfec")) { + codec_settings->useinbandfec = switch_true(arg); + } + + if (!strcasecmp(data, "usedtx")) { + codec_settings->usedtx = switch_true(arg); + } + + if (!strcasecmp(data, "sprop-maxcapturerate")) { + codec_settings->sprop_maxcapturerate = atoi(arg); + } + + if (!strcasecmp(data, "maxptime")) { + codec_settings->maxptime = atoi(arg); + } + + if (!strcasecmp(data, "minptime")) { + codec_settings->minptime = atoi(arg); + } + + if (!strcasecmp(data, "ptime")) { + codec_settings->ptime = atoi(arg); + codec_fmtp->microseconds_per_packet = codec_settings->ptime * 1000; + } + + if (!strcasecmp(data, "samplerate")) { + codec_settings->samplerate = atoi(arg); + codec_fmtp->actual_samples_per_second = codec_settings->samplerate; + } + + if (!strcasecmp(data, "maxaveragebitrate")) { + codec_settings->maxaveragebitrate = atoi(arg); + switch(codec_fmtp->actual_samples_per_second) { + case 8000: + { + if(codec_settings->maxaveragebitrate < 6000 || codec_settings->maxaveragebitrate > 20000) { + codec_settings->maxaveragebitrate = 20000; + } + break; + } + case 12000: + { + if(codec_settings->maxaveragebitrate < 7000 || codec_settings->maxaveragebitrate > 25000) { + codec_settings->maxaveragebitrate = 25000; + } + break; + } + case 16000: + { + if(codec_settings->maxaveragebitrate < 8000 || codec_settings->maxaveragebitrate > 30000) { + codec_settings->maxaveragebitrate = 30000; + } + break; + } + case 24000: + { + if(codec_settings->maxaveragebitrate < 12000 || codec_settings->maxaveragebitrate > 40000) { + codec_settings->maxaveragebitrate = 40000; + } + break; + } + + default: + /* this should never happen but 20000 is common among all rates */ + codec_settings->maxaveragebitrate = 20000; + break; + } + + + codec_fmtp->bits_per_second = codec_settings->maxaveragebitrate; + } + + } + } + } + free(fmtp_dup); + } + //codec_fmtp->bits_per_second = bit_rate; + return SWITCH_STATUS_SUCCESS; + } + return SWITCH_STATUS_FALSE; +} + +static char *gen_fmtp(opus_codec_settings_t *settings, switch_memory_pool_t *pool) +{ + char buf[256] = ""; + + if (settings->useinbandfec) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "useinbandfec=1;"); + } + + if (settings->usedtx) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "usedtx=1;"); + } + + if (settings->maxaveragebitrate) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "maxaveragebitrate=%d;", settings->maxaveragebitrate); + + } + + if (settings->ptime) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "ptime=%d;", settings->ptime); + } + + if (settings->minptime) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "minptime=%d;", settings->minptime); + } + + if (settings->maxptime) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "maxptime=%d;", settings->maxptime); + } + + if (settings->samplerate) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "samplerate=%d;", settings->samplerate); + } + + if (end_of(buf) == ';') { + end_of(buf) = '\0'; + } + + return switch_core_strdup(pool, buf); + +} + static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings) { struct opus_context *context = NULL; int encoding = (flags & SWITCH_CODEC_FLAG_ENCODE); int decoding = (flags & SWITCH_CODEC_FLAG_DECODE); + switch_codec_fmtp_t codec_fmtp; + opus_codec_settings_t opus_codec_settings = { 0 }; if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) { return SWITCH_STATUS_FALSE; } context->frame_size = codec->implementation->samples_per_packet; - + + memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp)); + codec_fmtp.private_info = &opus_codec_settings; + switch_opus_fmtp_parse(codec->fmtp_in, &codec_fmtp); + + codec->fmtp_out = gen_fmtp(&opus_codec_settings, codec->memory_pool); + if (encoding) { /* come up with a way to specify these */ - int bitrate_bps = codec->implementation->bits_per_second; + int bitrate_bps = OPUS_AUTO; int use_vbr = 1; int complexity = 10; - int use_inbandfec = 1; - int use_dtx = 1; - int bandwidth = OPUS_BANDWIDTH_FULLBAND; int err; + int samplerate = opus_codec_settings.samplerate ? opus_codec_settings.samplerate : codec->implementation->actual_samples_per_second; - context->encoder_object = opus_encoder_create(codec->implementation->actual_samples_per_second, + context->encoder_object = opus_encoder_create(samplerate, codec->implementation->number_of_channels, OPUS_APPLICATION_VOIP, &err); @@ -74,12 +268,24 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag } opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(bitrate_bps)); - opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(bandwidth)); + + if (codec->implementation->actual_samples_per_second == 8000) { + opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); + opus_encoder_ctl(context->encoder_object, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); + } else { + opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); + } + opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR(use_vbr)); opus_encoder_ctl(context->encoder_object, OPUS_SET_COMPLEXITY(complexity)); - opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC(use_inbandfec)); - opus_encoder_ctl(context->encoder_object, OPUS_SET_DTX(use_dtx)); + if (opus_codec_settings.useinbandfec) { + opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC(opus_codec_settings.useinbandfec)); + } + + if (opus_codec_settings.usedtx) { + opus_encoder_ctl(context->encoder_object, OPUS_SET_DTX(opus_codec_settings.usedtx)); + } } if (decoding) { @@ -187,19 +393,33 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load) int mss = 10000; int x = 0; int rate = 48000; - int bits = 32000; + int bits = 0; + char *dft_fmtp = NULL; + opus_codec_settings_t settings = { 0 }; /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_CODEC(codec_interface, "OPUS (STANDARD)"); + codec_interface->parse_fmtp = switch_opus_fmtp_parse; + + settings = default_codec_settings; + + for (x = 0; x < 3; x++) { + + settings.ptime = mss / 1000; + settings.maxptime = settings.ptime; + settings.minptime = settings.ptime; + settings.samplerate = rate; + dft_fmtp = gen_fmtp(&settings, pool); + switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */ 116, /* the IANA code number */ "opus",/* the IANA code name */ - NULL, /* default fmtp to send (can be overridden by the init function) */ - rate, /* samples transferred per second */ + dft_fmtp, /* default fmtp to send (can be overridden by the init function) */ + 48000, /* samples transferred per second */ rate, /* actual samples transferred per second */ bits, /* bits transferred per second */ mss, /* number of microseconds per frame */ @@ -219,6 +439,44 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load) } + + samples = 80; + bytes = 160; + mss = 10000; + rate = 8000; + + for (x = 0; x < 3; x++) { + + settings.ptime = mss / 1000; + settings.maxptime = settings.ptime; + settings.minptime = settings.ptime; + settings.samplerate = rate; + dft_fmtp = gen_fmtp(&settings, pool); + + switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */ + 116, /* the IANA code number */ + "opus",/* the IANA code name */ + dft_fmtp, /* default fmtp to send (can be overridden by the init function) */ + 48000, /* samples transferred per second */ + rate, /* actual samples transferred per second */ + bits, /* bits transferred per second */ + mss, /* number of microseconds per frame */ + samples, /* number of samples per frame */ + bytes, /* number of bytes per frame decompressed */ + 0, /* number of bytes per frame compressed */ + 1,/* number of channels represented */ + 1, /* number of frames per network packet */ + switch_opus_init, /* function to initialize a codec handle using this implementation */ + switch_opus_encode, /* function to encode raw data into encoded data */ + switch_opus_decode, /* function to decode encoded data into raw data */ + switch_opus_destroy); /* deinitalize a codec handle using this implementation */ + + bytes += 160; + samples += 80; + mss += 10000; + + } + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/codecs/mod_vp8/mod_vp8.c b/src/mod/codecs/mod_vp8/mod_vp8.c index 121b9ab0c9..2a0a5540ba 100644 --- a/src/mod/codecs/mod_vp8/mod_vp8.c +++ b/src/mod/codecs/mod_vp8/mod_vp8.c @@ -83,9 +83,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_vp8_load) /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_CODEC(codec_interface, "VP8 Video (passthru)"); + switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_VIDEO, 99, "VP8", NULL, 90000, 90000, 0, 0, 0, 0, 0, 1, 1, switch_vp8_init, switch_vp8_encode, switch_vp8_decode, switch_vp8_destroy); + + SWITCH_ADD_CODEC(codec_interface, "red Video (passthru)"); + switch_core_codec_add_implementation(pool, codec_interface, + SWITCH_CODEC_TYPE_VIDEO, 103, "red", NULL, 90000, 90000, 0, + 0, 0, 0, 0, 1, 1, switch_vp8_init, switch_vp8_encode, switch_vp8_decode, switch_vp8_destroy); + + SWITCH_ADD_CODEC(codec_interface, "ulpfec Video (passthru)"); + switch_core_codec_add_implementation(pool, codec_interface, + SWITCH_CODEC_TYPE_VIDEO, 104, "ulpfec", NULL, 90000, 90000, 0, + 0, 0, 0, 0, 1, 1, switch_vp8_init, switch_vp8_encode, switch_vp8_decode, switch_vp8_destroy); + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 7286c5de16..dc6351799d 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -626,13 +626,14 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY nomedia - sending ack\n"); nua_ack(tech_pvt->nh, - TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), - SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str), - SOATAG_REUSE_REJECTED(1), - SOATAG_RTP_SELECT(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), - TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), - TAG_END()); + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + SIPTAG_CONTACT_STR(tech_pvt->reply_contact), + SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str), + SOATAG_REUSE_REJECTED(1), + SOATAG_RTP_SELECT(1), + SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), + TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), + TAG_END()); sofia_clear_flag(tech_pvt, TFLAG_3PCC_INVITE); // all done sofia_set_flag_locked(tech_pvt, TFLAG_ANS); sofia_set_flag_locked(tech_pvt, TFLAG_SDP); @@ -667,7 +668,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) tech_pvt->mparams.local_sdp_str = NULL; switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0); - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); } else { switch_core_media_set_local_sdp(session, b_sdp, SWITCH_TRUE); @@ -683,12 +684,14 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX); if (sofia_use_soa(tech_pvt)) { + nua_respond(tech_pvt->nh, SIP_200_OK, TAG_IF(is_proxy, NUTAG_AUTOANSWER(0)), SIPTAG_CONTACT_STR(tech_pvt->profile->url), SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str), TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)), - SOATAG_REUSE_REJECTED(1), TAG_IF(is_proxy, SOATAG_RTP_SELECT(1)), + SOATAG_REUSE_REJECTED(1), + SOATAG_RTP_SELECT(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), @@ -762,7 +765,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) return status; } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); } @@ -834,7 +837,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str), SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), - TAG_IF(is_proxy, SOATAG_RTP_SELECT(1)), + SOATAG_RTP_SELECT(1), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END()); @@ -1221,7 +1224,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_channel_set_flag(tech_pvt->channel, CF_SECURE); } - if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING) || sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_PT)) { + if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING)) { switch_core_media_reset_autofix(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO); } } @@ -1264,7 +1267,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi ip = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE); port = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE); if (ip && port) { - switch_core_media_gen_local_sdp(session, ip, (switch_port_t)atoi(port), msg->string_arg, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, ip, (switch_port_t)atoi(port), msg->string_arg, 1); } if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { @@ -1397,7 +1400,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi goto end_lock; } } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 1); if (send_invite) { if (!switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { @@ -2081,7 +2084,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); goto end_lock; } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); } diff --git a/src/mod/endpoints/mod_sofia/rtp.c b/src/mod/endpoints/mod_sofia/rtp.c index a34b8cfd74..a1467f9647 100644 --- a/src/mod/endpoints/mod_sofia/rtp.c +++ b/src/mod/endpoints/mod_sofia/rtp.c @@ -513,7 +513,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi } switch_rtp_set_default_payload(tech_pvt->rtp_session, pt); - switch_rtp_set_recv_pt(tech_pvt->rtp_session, pt); + //switch_rtp_set_recv_pt(tech_pvt->rtp_session, pt); } if (compare_var(event, channel, kRFC2833PT)) { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index f2194487d4..527de9b8fb 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1492,8 +1492,8 @@ static void our_sofia_event_callback(nua_event_t event, sofia_reg_check_socket(profile, sofia_private->call_id, sofia_private->network_ip, sofia_private->network_port); + nua_handle_destroy(nh); } - nua_handle_destroy(nh); } break; case nua_r_authenticate: @@ -3743,7 +3743,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) sofia_set_pflag(profile, PFLAG_DISABLE_100REL); profile->auto_restart = 1; sofia_set_media_flag(profile, SCMF_AUTOFIX_TIMING); - sofia_set_media_flag(profile, SCMF_AUTOFIX_PT); + sofia_set_media_flag(profile, SCMF_RENEG_ON_REINVITE); sofia_set_media_flag(profile, SCMF_RTP_AUTOFLUSH_DURING_BRIDGE); profile->contact_user = SOFIA_DEFAULT_CONTACT_USER; sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID); @@ -4381,12 +4381,6 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else { sofia_clear_media_flag(profile, SCMF_AUTOFIX_TIMING); } - } else if (!strcasecmp(var, "rtp-autofix-pt")) { - if (switch_true(val)) { - sofia_set_media_flag(profile, SCMF_AUTOFIX_PT); - } else { - sofia_clear_media_flag(profile, SCMF_AUTOFIX_PT); - } } else if (!strcasecmp(var, "contact-user")) { profile->contact_user = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "nat-options-ping")) { @@ -5250,7 +5244,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status sofia_update_callee_id(session, profile, sip, SWITCH_FALSE); - if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING) || sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_PT)) { + if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING)) { switch_core_media_reset_autofix(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO); } @@ -6204,7 +6198,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } else { switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP"); switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0); - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); sofia_set_flag_locked(tech_pvt, TFLAG_3PCC); switch_channel_set_state(channel, CS_HIBERNATE); if (sofia_use_soa(tech_pvt)) { @@ -6321,7 +6315,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 1); if (sofia_use_soa(tech_pvt)) { nua_respond(tech_pvt->nh, SIP_200_OK, @@ -6427,7 +6421,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Reinvite RTP Error!\n"); @@ -6446,7 +6440,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, if (is_ok) { if (switch_core_session_local_crypto_key(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) { - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); } if (sofia_use_soa(tech_pvt)) { nua_respond(tech_pvt->nh, SIP_200_OK, @@ -6486,7 +6480,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, if (switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0) != SWITCH_STATUS_SUCCESS) { goto done; } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n"); switch_channel_set_flag(tech_pvt->channel, CF_REINVITE); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 833a725d44..d5bbe14c55 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -752,7 +752,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) } if (!switch_channel_get_private(tech_pvt->channel, "t38_options") || zstr(tech_pvt->mparams.local_sdp_str)) { - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 0); } sofia_set_flag_locked(tech_pvt, TFLAG_READY); diff --git a/src/mod/event_handlers/mod_rayo/Makefile b/src/mod/event_handlers/mod_rayo/Makefile index 6fccfdf318..a3bfc45d47 100644 --- a/src/mod/event_handlers/mod_rayo/Makefile +++ b/src/mod/event_handlers/mod_rayo/Makefile @@ -11,6 +11,7 @@ LOCAL_OBJS= $(IKS_LA) \ nlsml.o \ rayo_components.o \ rayo_elements.o \ + rayo_fax_components.o \ rayo_input_component.o \ rayo_output_component.o \ rayo_prompt_component.o \ @@ -23,6 +24,7 @@ LOCAL_SOURCES= \ nlsml.c \ rayo_components.c \ rayo_elements.c \ + rayo_fax_components.c \ rayo_input_component.c \ rayo_output_component.c \ rayo_prompt_component.c \ diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml index 35419319bc..3fdc772daf 100644 --- a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml +++ b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml @@ -16,6 +16,12 @@ + + + + + + @@ -65,6 +71,7 @@ ]]> ]]> ]]> + ]]> ]]> ]]> ]]> diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 6dd58d29c6..88eb44b417 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -126,6 +126,8 @@ struct rayo_call { switch_hash_t *pcps; /** current idle start time */ switch_time_t idle_start_time; + /** true if fax is in progress */ + int faxing; /** 1 if joined to call, 2 if joined to mixer */ int joined; /** pending join */ @@ -950,6 +952,7 @@ static void rayo_call_cleanup(struct rayo_actor *actor) iks_delete(revent); switch_event_destroy(&event); + switch_core_hash_destroy(&call->pcps); } /** @@ -963,11 +966,30 @@ const char *rayo_call_get_dcp_jid(struct rayo_call *call) /** * @param call the Rayo call - * @return true if joined + * @return true if joined (or a join is in progress) */ -static int rayo_call_is_joined(struct rayo_call *call) +int rayo_call_is_joined(struct rayo_call *call) { - return call->joined; + return call->joined || call->pending_join_request; +} + +/** + * @param call to check if faxing + * @return true if faxing is in progress + */ +int rayo_call_is_faxing(struct rayo_call *call) +{ + return call->faxing; +} + +/** + * Set faxing flag + * @param call the call to flag + * @param faxing true if faxing is in progress + */ +void rayo_call_set_faxing(struct rayo_call *call, int faxing) +{ + call->faxing = faxing; } #define RAYO_MIXER_LOCATE(mixer_name) rayo_mixer_locate(mixer_name, __FILE__, __LINE__) @@ -1104,13 +1126,23 @@ static struct rayo_call *_rayo_call_create(const char *uuid, const char *file, i return rayo_call_init(call, pool, uuid, file, line); } +/** + * Mixer destructor + */ +static void rayo_mixer_cleanup(struct rayo_actor *actor) +{ + struct rayo_mixer *mixer = RAYO_MIXER(actor); + switch_core_hash_destroy(&mixer->members); + switch_core_hash_destroy(&mixer->subscribers); +} + /** * Initialize mixer */ static struct rayo_mixer *rayo_mixer_init(struct rayo_mixer *mixer, switch_memory_pool_t *pool, const char *name, const char *file, int line) { char *mixer_jid = switch_mprintf("%s@%s", name, RAYO_JID(globals.server)); - rayo_actor_init(RAYO_ACTOR(mixer), pool, RAT_MIXER, "", name, mixer_jid, NULL, rayo_mixer_send, file, line); + rayo_actor_init(RAYO_ACTOR(mixer), pool, RAT_MIXER, "", name, mixer_jid, rayo_mixer_cleanup, rayo_mixer_send, file, line); switch_core_hash_init(&mixer->members, pool); switch_core_hash_init(&mixer->subscribers, pool); switch_safe_free(mixer_jid); @@ -1281,6 +1313,7 @@ static void rayo_peer_server_cleanup(struct rayo_actor *actor) RAYO_UNLOCK(client); RAYO_DESTROY(client); } + switch_core_hash_destroy(&rserver->clients); switch_mutex_unlock(globals.clients_mutex); } @@ -1942,6 +1975,12 @@ static iks *on_rayo_join(struct rayo_actor *call, struct rayo_message *msg, void goto done; } + if (rayo_call_is_faxing(RAYO_CALL(call))) { + /* can't join a call while it's faxing */ + response = iks_new_error_detailed(msg->payload, STANZA_ERROR_UNEXPECTED_REQUEST, "fax is in progress"); + goto done; + } + if (RAYO_CALL(call)->pending_join_request) { /* don't allow concurrent join requests */ response = iks_new_error_detailed(msg->payload, STANZA_ERROR_UNEXPECTED_REQUEST, "(un)join request is pending"); @@ -2339,11 +2378,14 @@ static iks *on_iq_get_xmpp_disco(struct rayo_actor *server, struct rayo_message iks *node = msg->payload; iks *response = NULL; iks *x; + iks *feature; response = iks_new_iq_result(node); x = iks_insert(response, "query"); iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_DISCO); - x = iks_insert(x, "feature"); - iks_insert_attrib(x, "var", RAYO_NS); + feature = iks_insert(x, "feature"); + iks_insert_attrib(feature, "var", RAYO_NS); + feature = iks_insert(x, "feature"); + iks_insert_attrib(feature, "var", RAYO_FAX_NS); /* TODO The response MUST also include features for the application formats and transport methods supported by * the responding entity, as described in the relevant specifications. @@ -3074,12 +3116,22 @@ static switch_status_t rayo_call_on_read_frame(switch_core_session_t *session, s switch_time_t idle_start = call->idle_start_time; int idle_duration_ms = (now - idle_start) / 1000; /* detect idle session (rayo-client has stopped controlling call) and terminate call */ - if (rayo_call_is_joined(call)) { + if (rayo_call_is_joined(call) || rayo_call_is_faxing(call)) { call->idle_start_time = now; } else if (idle_duration_ms > globals.max_idle_ms) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Ending abandoned call. idle_duration_ms = %i ms\n", idle_duration_ms); switch_channel_hangup(channel, RAYO_CAUSE_HANGUP); } + + /* check for break request */ + { + const char *break_jid = switch_channel_get_variable(channel, "rayo_read_frame_interrupt"); + struct rayo_actor *actor; + if (break_jid && (actor = RAYO_LOCATE(break_jid))) { + RAYO_UNLOCK(actor); + return SWITCH_STATUS_FALSE; + } + } } return SWITCH_STATUS_SUCCESS; } @@ -3117,18 +3169,17 @@ SWITCH_STANDARD_APP(rayo_app) } } if (!call) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Missing rayo call!!\n"); - goto done; + /* this scenario can only happen if a call was originated through a mechanism other than + and then the rayo APP was executed to offer control */ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Outbound call that wasn't created with , will try to offer control\n"); } ok = 1; - } else { - /* inbound call - offer control */ + } + + if (!call) { + /* offer control */ switch_hash_index_t *hi = NULL; iks *offer = NULL; - if (call) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Call is already under Rayo 3PCC!\n"); - goto done; - } call = rayo_call_create(switch_core_session_get_uuid(session)); switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_call_jid", RAYO_JID(call)); @@ -3161,6 +3212,7 @@ SWITCH_STANDARD_APP(rayo_app) /* nobody to offer to */ if (!ok) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Rejecting rayo call - there are no online rayo clients to offer call to\n"); switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE); } } diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.h b/src/mod/event_handlers/mod_rayo/mod_rayo.h index dd0adb3192..b862802f31 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.h +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.h @@ -153,6 +153,9 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l #define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__) #define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x)) +extern int rayo_call_is_joined(struct rayo_call *call); +extern int rayo_call_is_faxing(struct rayo_call *call); +extern void rayo_call_set_faxing(struct rayo_call *call, int faxing); extern const char *rayo_call_get_dcp_jid(struct rayo_call *call); #define rayo_mixer_get_name(mixer) RAYO_ID(mixer) diff --git a/src/mod/event_handlers/mod_rayo/rayo_components.c b/src/mod/event_handlers/mod_rayo/rayo_components.c index b5137d9459..7ad96d2a7d 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_components.c +++ b/src/mod/event_handlers/mod_rayo/rayo_components.c @@ -226,7 +226,8 @@ switch_status_t rayo_components_load(switch_loadable_module_interface_t **module if (rayo_input_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || rayo_output_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || rayo_prompt_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || - rayo_record_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS) { + rayo_record_component_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS || + rayo_fax_components_load(module_interface, pool, config_file) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_TERM; } return SWITCH_STATUS_SUCCESS; @@ -241,6 +242,7 @@ switch_status_t rayo_components_shutdown(void) rayo_output_component_shutdown(); rayo_prompt_component_shutdown(); rayo_record_component_shutdown(); + rayo_fax_components_shutdown(); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/event_handlers/mod_rayo/rayo_components.h b/src/mod/event_handlers/mod_rayo/rayo_components.h index 6e93dfbc43..5d1367d645 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_components.h +++ b/src/mod/event_handlers/mod_rayo/rayo_components.h @@ -49,6 +49,9 @@ #define RAYO_PROMPT_NS RAYO_BASE "prompt:" RAYO_VERSION #define RAYO_PROMPT_COMPLETE_NS RAYO_BASE "prompt:complete:" RAYO_VERSION +#define RAYO_FAX_NS RAYO_BASE "fax:" RAYO_VERSION +#define RAYO_FAX_COMPLETE_NS RAYO_BASE "fax:complete:" RAYO_VERSION + #define COMPONENT_COMPLETE_STOP "stop", RAYO_EXT_COMPLETE_NS #define COMPONENT_COMPLETE_ERROR "error", RAYO_EXT_COMPLETE_NS #define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS @@ -58,12 +61,14 @@ extern switch_status_t rayo_input_component_load(switch_loadable_module_interfac extern switch_status_t rayo_output_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_prompt_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_record_component_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); +extern switch_status_t rayo_fax_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file); extern switch_status_t rayo_components_shutdown(void); extern switch_status_t rayo_input_component_shutdown(void); extern switch_status_t rayo_output_component_shutdown(void); extern switch_status_t rayo_prompt_component_shutdown(void); extern switch_status_t rayo_record_component_shutdown(void); +extern switch_status_t rayo_fax_components_shutdown(void); extern void rayo_component_send_start(struct rayo_component *component, iks *iq); extern void rayo_component_send_iq_error(struct rayo_component *component, iks *iq, const char *error_name, const char *error_type); diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.c b/src/mod/event_handlers/mod_rayo/rayo_elements.c index 34577a9492..78209c3bd6 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_elements.c +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.c @@ -32,6 +32,7 @@ * component validation */ ELEMENT(RAYO_INPUT) + ATTRIB(xmlns,, any) STRING_ATTRIB(mode, any, "any,dtmf,voice") OPTIONAL_ATTRIB(terminator,, dtmf_digit) ATTRIB(recognizer,, any) @@ -48,10 +49,22 @@ ELEMENT(RAYO_INPUT) ATTRIB(start-timers, true, bool) ELEMENT_END +/** + * command validation + */ +ELEMENT(RAYO_JOIN) + ATTRIB(xmlns,, any) + STRING_ATTRIB(direction, duplex, "send,recv,duplex") + STRING_ATTRIB(media, bridge, "bridge,direct") + ATTRIB(call-uri,, any) + ATTRIB(mixer-name,, any) +ELEMENT_END + /** * component validation */ ELEMENT(RAYO_OUTPUT) + ATTRIB(xmlns,, any) ATTRIB(start-offset, 0, not_negative) ATTRIB(start-paused, false, bool) ATTRIB(repeat-interval, 0, not_negative) @@ -65,6 +78,7 @@ ELEMENT_END * validation */ ELEMENT(RAYO_OUTPUT_SEEK) + ATTRIB(xmlns,, any) STRING_ATTRIB(direction,, "forward,back") ATTRIB(amount,-1, positive) ELEMENT_END @@ -73,14 +87,23 @@ ELEMENT_END * component validation */ ELEMENT(RAYO_PROMPT) + ATTRIB(xmlns,, any) ATTRIB(barge-in, true, bool) ELEMENT_END +/** + * command validation + */ +ELEMENT(RAYO_RECEIVEFAX) + ATTRIB(xmlns,, any) +ELEMENT_END + /** * component validation */ ELEMENT(RAYO_RECORD) - ATTRIB(format, mp3, any) + ATTRIB(xmlns,, any) + ATTRIB(format, wav, any) ATTRIB(start-beep, false, bool) ATTRIB(stop-beep, false, bool) ATTRIB(start-paused, false, bool) @@ -92,13 +115,10 @@ ELEMENT(RAYO_RECORD) ELEMENT_END /** - * command validation + * command validation */ -ELEMENT(RAYO_JOIN) - STRING_ATTRIB(direction, duplex, "send,recv,duplex") - STRING_ATTRIB(media, bridge, "bridge,direct") - ATTRIB(call-uri,, any) - ATTRIB(mixer-name,, any) +ELEMENT(RAYO_SENDFAX) + ATTRIB(xmlns,, any) ELEMENT_END diff --git a/src/mod/event_handlers/mod_rayo/rayo_elements.h b/src/mod/event_handlers/mod_rayo/rayo_elements.h index c780f160cf..e76809cc9e 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_elements.h +++ b/src/mod/event_handlers/mod_rayo/rayo_elements.h @@ -32,11 +32,13 @@ #include "iks_helpers.h" ELEMENT_DECL(RAYO_INPUT) +ELEMENT_DECL(RAYO_JOIN) ELEMENT_DECL(RAYO_OUTPUT) ELEMENT_DECL(RAYO_OUTPUT_SEEK) ELEMENT_DECL(RAYO_PROMPT) +ELEMENT_DECL(RAYO_RECEIVEFAX) ELEMENT_DECL(RAYO_RECORD) -ELEMENT_DECL(RAYO_JOIN) +ELEMENT_DECL(RAYO_SENDFAX) #endif diff --git a/src/mod/event_handlers/mod_rayo/rayo_fax_components.c b/src/mod/event_handlers/mod_rayo/rayo_fax_components.c new file mode 100644 index 0000000000..bce34dc9d9 --- /dev/null +++ b/src/mod/event_handlers/mod_rayo/rayo_fax_components.c @@ -0,0 +1,569 @@ +/* + * mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2013, Grasshopper + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is Grasshopper + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Rienzo + * + * rayo_fax_components.c -- Rayo receivefax and sendfax components implementation + * + */ +#include "rayo_components.h" +#include "rayo_elements.h" + +/** + * settings + */ +static struct { + const char *file_prefix; +} globals; + +struct fax_component { + /** component base class */ + struct rayo_component base; + /** Flag to stop fax */ + int stop; +}; + +#define FAX_COMPONENT(x) ((struct fax_component *)x) + +struct receivefax_component { + /** fax component base class */ + struct fax_component base; + /** true if HTTP PUT needs to be done after fax is received */ + int http_put_after_receive; + /** fax stored on local filesystem */ + const char *local_filename; + /** fax final target (may be same as local filename) */ + const char *filename; +}; + +#define RECEIVEFAX_COMPONENT(x) ((struct receivefax_component *)x) + +#define FAX_FINISH "finish", RAYO_FAX_COMPLETE_NS + +/** + * Start execution of call sendfax component + * @param call the call to send fax to + * @param msg the original request + * @param session_data the call's session + */ +static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data) +{ + iks *iq = msg->payload; + switch_core_session_t *session = (switch_core_session_t *)session_data; + struct fax_component *sendfax_component = NULL; + iks *sendfax = iks_find(iq, "sendfax"); + iks *response = NULL; + switch_event_t *execute_event = NULL; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_memory_pool_t *pool; + iks *document; + const char *fax_document; + const char *fax_header; + const char *fax_identity; + const char *pages; + + /* validate attributes */ + if (!VALIDATE_RAYO_SENDFAX(sendfax)) { + return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); + } + + /* fax is only allowed if the call is not currently joined */ + if (rayo_call_is_joined(RAYO_CALL(call))) { + return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't send fax on a joined call"); + } + + if (rayo_call_is_faxing(RAYO_CALL(call))) { + return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress"); + } + + /* get fax document */ + document = iks_find(sendfax, "document"); + if (!document) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "missing document"); + } + fax_document = iks_find_attrib_soft(document, "url"); + if (zstr(fax_document)) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "missing document url"); + } + + /* is valid URL type? */ + if (!strncasecmp(fax_document, "http://", 7) || !strncasecmp(fax_document, "https://", 8)) { + switch_stream_handle_t stream = { 0 }; + SWITCH_STANDARD_STREAM(stream); + /* need to fetch document from server... */ + switch_api_execute("http_get", fax_document, session, &stream); + if (!zstr(stream.data) && !strncmp(fax_document, SWITCH_PATH_SEPARATOR, strlen(SWITCH_PATH_SEPARATOR))) { + fax_document = switch_core_session_strdup(session, stream.data); + } else { + switch_safe_free(stream.data); + return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to fetch document"); + } + switch_safe_free(stream.data); + } else if (!strncasecmp(fax_document, "file://", 7)) { + fax_document = fax_document + 7; + if (zstr(fax_document)) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "invalid file:// url"); + } + } else if (strncasecmp(fax_document, SWITCH_PATH_SEPARATOR, strlen(SWITCH_PATH_SEPARATOR))) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "unsupported url type"); + } + + /* does document exist? */ + if (switch_file_exists(fax_document, pool) != SWITCH_STATUS_SUCCESS) { + return iks_new_error_detailed_printf(iq, STANZA_ERROR_BAD_REQUEST, "file not found: %s", fax_document); + } + + /* get fax identity and header */ + fax_identity = iks_find_attrib_soft(document, "identity"); + if (!zstr(fax_identity)) { + switch_channel_set_variable(channel, "fax_ident", fax_identity); + } else { + switch_channel_set_variable(channel, "fax_ident", NULL); + } + fax_header = iks_find_attrib_soft(document, "header"); + if (!zstr(fax_header)) { + switch_channel_set_variable(channel, "fax_header", fax_header); + } else { + switch_channel_set_variable(channel, "fax_header", NULL); + } + + /* get pages to send */ + pages = iks_find_attrib_soft(document, "pages"); + if (!zstr(pages)) { + if (switch_regex_match(pages, "[1-9][0-9]*(-[1-9][0-9]*)?") == SWITCH_STATUS_FALSE) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "invalid pages value"); + } else { + int start = 0; + int end = 0; + char *pages_dup = switch_core_session_strdup(session, pages); + char *sep = strchr(pages_dup, '-'); + if (sep) { + *sep = '\0'; + sep++; + end = atoi(sep); + } + start = atoi(pages_dup); + if (end && end < start) { + return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "invalid pages value"); + } + switch_channel_set_variable(channel, "fax_start_page", pages_dup); + switch_channel_set_variable(channel, "fax_end_page", sep); + } + } else { + switch_channel_set_variable(channel, "fax_start_page", NULL); + switch_channel_set_variable(channel, "fax_end_page", NULL); + } + + /* create sendfax component */ + switch_core_new_memory_pool(&pool); + sendfax_component = switch_core_alloc(pool, sizeof(*sendfax_component)); + rayo_component_init((struct rayo_component *)sendfax_component, pool, RAT_CALL_COMPONENT, "sendfax", NULL, call, iks_find_attrib(iq, "from")); + + /* add channel variable so that fax component can be located from fax events */ + switch_channel_set_variable(channel, "rayo_fax_jid", RAYO_JID(sendfax_component)); + + /* clear fax result variables */ + switch_channel_set_variable(channel, "fax_success", NULL); + switch_channel_set_variable(channel, "fax_result_code", NULL); + switch_channel_set_variable(channel, "fax_result_text", NULL); + switch_channel_set_variable(channel, "fax_document_transferred_pages", NULL); + switch_channel_set_variable(channel, "fax_document_total_pages", NULL); + switch_channel_set_variable(channel, "fax_image_resolution", NULL); + switch_channel_set_variable(channel, "fax_image_size", NULL); + switch_channel_set_variable(channel, "fax_bad_rows", NULL); + switch_channel_set_variable(channel, "fax_transfer_rate", NULL); + switch_channel_set_variable(channel, "fax_ecm_used", NULL); + switch_channel_set_variable(channel, "fax_local_station_id", NULL); + switch_channel_set_variable(channel, "fax_remote_station_id", NULL); + + /* clear fax interrupt variable */ + switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL); + + rayo_call_set_faxing(RAYO_CALL(call), 1); + + /* execute txfax APP */ + if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", "txfax"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", fax_document); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true"); + if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) { + switch_channel_set_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA); + } + + if (switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) { + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to txfax (queue event failed)"); + if (execute_event) { + switch_event_destroy(&execute_event); + } + rayo_call_set_faxing(RAYO_CALL(call), 0); + RAYO_UNLOCK(sendfax_component); + } else { + /* component starting... */ + rayo_component_send_start(RAYO_COMPONENT(sendfax_component), iq); + } + } else { + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create txfax event"); + rayo_call_set_faxing(RAYO_CALL(call), 0); + RAYO_UNLOCK(sendfax_component); + } + + return response; +} + +/** + * Start execution of call receivefax component + * @param call the call to receive fax from + * @param msg the original request + * @param session_data the call's session + */ +static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data) +{ + iks *iq = msg->payload; + switch_core_session_t *session = (switch_core_session_t *)session_data; + struct receivefax_component *receivefax_component = NULL; + iks *receivefax = iks_find(iq, "receivefax"); + iks *response = NULL; + switch_event_t *execute_event = NULL; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_memory_pool_t *pool; + int file_no; + + /* validate attributes */ + if (!VALIDATE_RAYO_RECEIVEFAX(receivefax)) { + return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); + } + + /* fax is only allowed if the call is not currently joined */ + if (rayo_call_is_joined(RAYO_CALL(call))) { + return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't receive fax on a joined call"); + } + + if (rayo_call_is_faxing(RAYO_CALL(call))) { + return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress"); + } + + /* create receivefax component */ + switch_core_new_memory_pool(&pool); + receivefax_component = switch_core_alloc(pool, sizeof(*receivefax_component)); + rayo_component_init((struct rayo_component *)receivefax_component, pool, RAT_CALL_COMPONENT, "receivefax", NULL, call, iks_find_attrib(iq, "from")); + file_no = rayo_actor_seq_next(call); + receivefax_component->filename = switch_core_sprintf(pool, "%s%s%s-%d.tif", + globals.file_prefix, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no); + if (!strncmp(receivefax_component->filename, "http://", 7) || !strncmp(receivefax_component->filename, "https://", 8)) { + /* This is an HTTP URL, need to PUT after fax is received */ + receivefax_component->local_filename = switch_core_sprintf(pool, "%s%s%s-%d", + SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no); + receivefax_component->http_put_after_receive = 1; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s save fax to HTTP URL\n", RAYO_JID(receivefax_component)); + } else { + /* assume file.. */ + receivefax_component->local_filename = receivefax_component->filename; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s save fax to local file\n", RAYO_JID(receivefax_component)); + } + + /* add channel variable so that fax component can be located from fax events */ + switch_channel_set_variable(channel, "rayo_fax_jid", RAYO_JID(receivefax_component)); + + /* clear fax result variables */ + switch_channel_set_variable(channel, "fax_success", NULL); + switch_channel_set_variable(channel, "fax_result_code", NULL); + switch_channel_set_variable(channel, "fax_result_text", NULL); + switch_channel_set_variable(channel, "fax_document_transferred_pages", NULL); + switch_channel_set_variable(channel, "fax_document_total_pages", NULL); + switch_channel_set_variable(channel, "fax_image_resolution", NULL); + switch_channel_set_variable(channel, "fax_image_size", NULL); + switch_channel_set_variable(channel, "fax_bad_rows", NULL); + switch_channel_set_variable(channel, "fax_transfer_rate", NULL); + switch_channel_set_variable(channel, "fax_ecm_used", NULL); + switch_channel_set_variable(channel, "fax_local_station_id", NULL); + switch_channel_set_variable(channel, "fax_remote_station_id", NULL); + + /* clear fax interrupt variable */ + switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL); + + rayo_call_set_faxing(RAYO_CALL(call), 1); + + /* execute rxfax APP */ + if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", "rxfax"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", receivefax_component->local_filename); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true"); + if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) { + switch_channel_set_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA); + } + + if (switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) { + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to rxfax (queue event failed)"); + if (execute_event) { + switch_event_destroy(&execute_event); + } + rayo_call_set_faxing(RAYO_CALL(call), 0); + RAYO_UNLOCK(receivefax_component); + } else { + /* component starting... */ + rayo_component_send_start(RAYO_COMPONENT(receivefax_component), iq); + } + } else { + response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create rxfax event"); + rayo_call_set_faxing(RAYO_CALL(call), 0); + RAYO_UNLOCK(receivefax_component); + } + + return response; +} + +/** + * Stop execution of fax component + */ +static iks *stop_fax_component(struct rayo_actor *component, struct rayo_message *msg, void *data) +{ + iks *iq = msg->payload; + switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id); + if (session) { + /* fail on read frame until component is destroyed */ + switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", RAYO_JID(component)); + switch_core_session_rwunlock(session); + } + FAX_COMPONENT(component)->stop = 1; + return iks_new_iq_result(iq); +} + +/** + * Add fax metadata to result + * @param event source of metadata + * @param name of metadata + * @param result to add metadata to + */ +static void insert_fax_metadata(switch_event_t *event, const char *name, iks *result) +{ + char actual_name[256]; + const char *value; + snprintf(actual_name, sizeof(actual_name), "variable_%s", name); + actual_name[sizeof(actual_name) - 1] = '\0'; + value = switch_event_get_header(event, actual_name); + if (!zstr(value)) { + iks *metadata = iks_insert(result, "metadata"); + iks_insert_attrib(metadata, "xmlns", RAYO_FAX_COMPLETE_NS); + iks_insert_attrib(metadata, "name", name); + iks_insert_attrib(metadata, "value", value); + } +} + +/** + * Handle fax completion event from FreeSWITCH core + * @param event received from FreeSWITCH core. It will be destroyed by the core after this function returns. + */ +static void on_execute_complete_event(switch_event_t *event) +{ + const char *application = switch_event_get_header(event, "Application"); + + if (!zstr(application) && (!strcmp(application, "rxfax") || !strcmp(application, "txfax"))) { + int is_rxfax = !strcmp(application, "rxfax"); + const char *uuid = switch_event_get_header(event, "Unique-ID"); + const char *fax_jid = switch_event_get_header(event, "variable_rayo_fax_jid"); + struct rayo_actor *component; + if (!zstr(fax_jid) && (component = RAYO_LOCATE(fax_jid))) { + iks *result; + iks *complete; + iks *fax; + int have_fax_document = 1; + switch_core_session_t *session; + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Got result for %s\n", fax_jid); + + /* clean up channel */ + session = switch_core_session_locate(uuid); + if (session) { + switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL); + switch_core_session_rwunlock(session); + } + + /* RX only: transfer HTTP document and delete local copy */ + if (is_rxfax && RECEIVEFAX_COMPONENT(component)->http_put_after_receive && switch_file_exists(RECEIVEFAX_COMPONENT(component)->local_filename, RAYO_POOL(component)) == SWITCH_STATUS_SUCCESS) { + switch_stream_handle_t stream = { 0 }; + SWITCH_STANDARD_STREAM(stream); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s PUT fax to %s\n", RAYO_JID(component), RECEIVEFAX_COMPONENT(component)->filename); + switch_api_execute("http_put", RECEIVEFAX_COMPONENT(component)->filename, NULL, &stream); + /* check if successful */ + if (!zstr(stream.data) && strncmp(stream.data, "+OK", 3)) { + /* PUT failed */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s PUT fax to %s failed: %s\n", RAYO_JID(component), RECEIVEFAX_COMPONENT(component)->filename, (char *)stream.data); + have_fax_document = 0; + } + switch_safe_free(stream.data) + switch_file_remove(RECEIVEFAX_COMPONENT(component)->local_filename, RAYO_POOL(component)); + } + + /* successful fax? */ + if (have_fax_document && switch_true(switch_event_get_header(event, "variable_fax_success"))) { + result = rayo_component_create_complete_event(RAYO_COMPONENT(component), FAX_FINISH); + } else if (have_fax_document && FAX_COMPONENT(component)->stop) { + result = rayo_component_create_complete_event(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); + } else { + result = rayo_component_create_complete_event(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR); + } + complete = iks_find(result, "complete"); + + /* RX only: add fax document information */ + if (is_rxfax && have_fax_document) { + const char *pages = switch_event_get_header(event, "variable_fax_document_transferred_pages"); + if (!zstr(pages) && switch_is_number(pages) && atoi(pages) > 0) { + const char *resolution = switch_event_get_header(event, "variable_fax_file_image_resolution"); + const char *size = switch_event_get_header(event, "variable_fax_image_size"); + + fax = iks_insert(complete, "fax"); + iks_insert_attrib(fax, "xmlns", RAYO_FAX_COMPLETE_NS); + + if (RECEIVEFAX_COMPONENT(component)->http_put_after_receive) { + iks_insert_attrib(fax, "url", RECEIVEFAX_COMPONENT(component)->filename); + } else { + /* convert absolute path to file:// URI */ + iks_insert_attrib_printf(fax, "url", "file://%s", RECEIVEFAX_COMPONENT(component)->filename); + } + + if (!zstr(resolution)) { + iks_insert_attrib(fax, "resolution", resolution); + } + if (!zstr(size)) { + iks_insert_attrib(fax, "size", size); + } + iks_insert_attrib(fax, "pages", pages); + } + } + + /* add metadata from event */ + insert_fax_metadata(event, "fax_success", complete); + insert_fax_metadata(event, "fax_result_code", complete); + insert_fax_metadata(event, "fax_result_text", complete); + insert_fax_metadata(event, "fax_document_transferred_pages", complete); + insert_fax_metadata(event, "fax_document_total_pages", complete); + insert_fax_metadata(event, "fax_image_resolution", complete); + insert_fax_metadata(event, "fax_image_size", complete); + insert_fax_metadata(event, "fax_bad_rows", complete); + insert_fax_metadata(event, "fax_transfer_rate", complete); + insert_fax_metadata(event, "fax_ecm_used", complete); + insert_fax_metadata(event, "fax_local_station_id", complete); + insert_fax_metadata(event, "fax_remote_station_id", complete); + + /* flag faxing as done */ + rayo_call_set_faxing(RAYO_CALL(RAYO_COMPONENT(component)->parent), 0); + + rayo_component_send_complete_event(RAYO_COMPONENT(component), result); + + RAYO_UNLOCK(component); + } + } +} + +/** + * Process module XML configuration + * @param pool memory pool to allocate from + * @param config_file to use + * @return SWITCH_STATUS_SUCCESS on successful configuration + */ +static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_file) +{ + switch_xml_t cfg, xml; + + /* set defaults */ + globals.file_prefix = switch_core_sprintf(pool, "%s%s", SWITCH_GLOBAL_dirs.recordings_dir, SWITCH_PATH_SEPARATOR); + + if (!(xml = switch_xml_open_cfg(config_file, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", config_file); + return SWITCH_STATUS_TERM; + } + + /* get params */ + { + switch_xml_t settings = switch_xml_child(cfg, "fax"); + if (settings) { + switch_xml_t param; + for (param = switch_xml_child(settings, "param"); param; param = param->next) { + const char *var = switch_xml_attr_soft(param, "name"); + const char *val = switch_xml_attr_soft(param, "value"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "param: %s = %s\n", var, val); + if (!strcasecmp(var, "receivefax-file-prefix")) { + if (!zstr(val)) { + globals.file_prefix = switch_core_strdup(pool, val); + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unsupported param: %s\n", var); + } + } + } + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "receivefax-file-prefix = %s\n", globals.file_prefix); + + switch_xml_free(xml); + + return SWITCH_STATUS_SUCCESS; +} + +/** + * Initialize fax components + * @param module_interface + * @param pool memory pool to allocate from + * @param config_file to use + * @return SWITCH_STATUS_SUCCESS if successful + */ +switch_status_t rayo_fax_components_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool, const char *config_file) +{ + if (do_config(pool, config_file) != SWITCH_STATUS_SUCCESS) { + return SWITCH_STATUS_TERM; + } + + switch_event_bind("rayo_fax_components", SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE, NULL, on_execute_complete_event, NULL); + + rayo_actor_command_handler_add(RAT_CALL, "", "set:"RAYO_FAX_NS":receivefax", start_receivefax_component); + rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "receivefax", "set:"RAYO_EXT_NS":stop", stop_fax_component); + + rayo_actor_command_handler_add(RAT_CALL, "", "set:"RAYO_FAX_NS":sendfax", start_sendfax_component); + rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "sendfax", "set:"RAYO_EXT_NS":stop", stop_fax_component); + + return SWITCH_STATUS_SUCCESS; +} + +/** + * Shutdown fax components + * @return SWITCH_STATUS_SUCCESS if successful + */ +switch_status_t rayo_fax_components_shutdown(void) +{ + switch_event_unbind_callback(on_execute_complete_event); + + return SWITCH_STATUS_SUCCESS; +} + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet + */ + diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx index 9afb1d2758..6b36513455 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx @@ -1930,6 +1930,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_TRANS_get() { } +SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_SESSION_MAX_PRIVATES_get() { + int jresult ; + int result; + + result = (int)(2); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_digit_set(void * jarg1, char jarg2) { switch_dtmf_t *arg1 = (switch_dtmf_t *) 0 ; char arg2 ; @@ -6320,6 +6330,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_thread_data_t_alloc_get(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_thread_data_t_pool_set(void * jarg1, void * jarg2) { + switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; + + arg1 = (switch_thread_data_t *)jarg1; + arg2 = (switch_memory_pool_t *)jarg2; + if (arg1) (arg1)->pool = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_thread_data_t_pool_get(void * jarg1) { + void * jresult ; + switch_thread_data_t *arg1 = (switch_thread_data_t *) 0 ; + switch_memory_pool_t *result = 0 ; + + arg1 = (switch_thread_data_t *)jarg1; + result = (switch_memory_pool_t *) ((arg1)->pool); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_thread_data_t() { void * jresult ; switch_thread_data_t *result = 0 ; @@ -6604,6 +6636,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_node_t_hup_profile_get(void * } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_direction_set(void * jarg1, int jarg2) { + switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + switch_call_direction_t arg2 ; + + arg1 = (switch_device_node_t *)jarg1; + arg2 = (switch_call_direction_t)jarg2; + if (arg1) (arg1)->direction = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_device_node_t_direction_get(void * jarg1) { + int jresult ; + switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_device_node_t *)jarg1; + result = (switch_call_direction_t) ((arg1)->direction); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_node_t_parent_set(void * jarg1, void * jarg2) { switch_device_node_t *arg1 = (switch_device_node_t *) 0 ; switch_device_record_s *arg2 = (switch_device_record_s *) 0 ; @@ -6688,6 +6742,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_get(void } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_total_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->total_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->total_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_total_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->total_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_total_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->total_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6710,6 +6808,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_get(vo } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->offhook_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->offhook_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_offhook_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->offhook_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_offhook_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->offhook_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6732,6 +6874,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_get(voi } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->active_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->active_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_active_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->active_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_active_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->active_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6754,6 +6940,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_get(void } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->held_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->held_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_held_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->held_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_held_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->held_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6776,6 +7006,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_get(void * } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->hup_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->hup_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_hup_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->hup_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_hup_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->hup_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6798,6 +7072,50 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_get(vo } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ringing_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->ringing_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ringing_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ringing_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ringing_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->ringing_out); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_set(void * jarg1, unsigned long jarg2) { switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; uint32_t arg2 ; @@ -6820,6 +7138,72 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_get(void } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_in_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->early_in = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_in_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->early_in); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_early_out_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->early_out = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_early_out_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->early_out); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_stats_t_ring_wait_set(void * jarg1, unsigned long jarg2) { + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_device_stats_t *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->ring_wait = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_device_stats_t_ring_wait_get(void * jarg1) { + unsigned long jresult ; + switch_device_stats_t *arg1 = (switch_device_stats_t *) 0 ; + uint32_t result; + + arg1 = (switch_device_stats_t *)jarg1; + result = (uint32_t) ((arg1)->ring_wait); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_device_stats_t() { void * jresult ; switch_device_stats_t *result = 0 ; @@ -6942,6 +7326,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_stats_get(void * jar } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_last_stats_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_stats_t *arg2 = (switch_device_stats_t *) 0 ; + + arg1 = (switch_device_record_t *)jarg1; + arg2 = (switch_device_stats_t *)jarg2; + if (arg1) (arg1)->last_stats = *arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_last_stats_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_device_stats_t *result = 0 ; + + arg1 = (switch_device_record_t *)jarg1; + result = (switch_device_stats_t *)& ((arg1)->last_stats); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_state_set(void * jarg1, int jarg2) { switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; switch_device_state_t arg2 ; @@ -7070,6 +7476,146 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_last_call_time_get(v } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_ring_start_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->ring_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_ring_start_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->ring_start); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_ring_stop_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->ring_stop = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_ring_stop_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->ring_stop); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_hold_start_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->hold_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_hold_start_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->hold_start); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_hold_stop_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->hold_stop = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_hold_stop_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->hold_stop); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_call_start_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t arg2 ; + switch_time_t *argp2 ; + + arg1 = (switch_device_record_t *)jarg1; + argp2 = (switch_time_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_time_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->call_start = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_call_start_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + switch_time_t result; + + arg1 = (switch_device_record_t *)jarg1; + result = ((arg1)->call_start); + jresult = new switch_time_t((const switch_time_t &)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_uuid_list_set(void * jarg1, void * jarg2) { switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; device_uuid_node_s *arg2 = (device_uuid_node_s *) 0 ; @@ -7158,6 +7704,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_pool_get(void * jarg } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_device_record_t_user_data_set(void * jarg1, void * jarg2) { + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (switch_device_record_t *)jarg1; + arg2 = (void *)jarg2; + if (arg1) (arg1)->user_data = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_device_record_t_user_data_get(void * jarg1) { + void * jresult ; + switch_device_record_t *arg1 = (switch_device_record_t *) 0 ; + void *result = 0 ; + + arg1 = (switch_device_record_t *)jarg1; + result = (void *) ((arg1)->user_data); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_device_record_t() { void * jresult ; switch_device_record_t *result = 0 ; @@ -9436,6 +10004,18 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_switchname() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_domain(int jarg1) { + char * jresult ; + switch_bool_t arg1 ; + char *result = 0 ; + + arg1 = (switch_bool_t)jarg1; + result = (char *)switch_core_get_domain(arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_set_variable(char * jarg1, char * jarg2) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -9722,6 +10302,14 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_exec(void * jarg1, void * } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_video_reset(void * jarg1) { + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + + arg1 = (switch_core_session_t *)jarg1; + switch_core_session_video_reset(arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_execute_application_get_flags(void * jarg1, char * jarg2, char * jarg3, void * jarg4) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -9802,27 +10390,31 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_receive_event(void * jarg1 } -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_private(void * jarg1) { +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_private_class(void * jarg1, int jarg2) { void * jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_pvt_class_t arg2 ; void *result = 0 ; arg1 = (switch_core_session_t *)jarg1; - result = (void *)switch_core_session_get_private(arg1); + arg2 = (switch_pvt_class_t)jarg2; + result = (void *)switch_core_session_get_private_class(arg1,arg2); jresult = (void *)result; return jresult; } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_set_private(void * jarg1, void * jarg2) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_set_private_class(void * jarg1, void * jarg2, int jarg3) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; void *arg2 = (void *) 0 ; + switch_pvt_class_t arg3 ; switch_status_t result; arg1 = (switch_core_session_t *)jarg1; arg2 = (void *)jarg2; - result = (switch_status_t)switch_core_session_set_private(arg1,arg2); + arg3 = (switch_pvt_class_t)jarg3; + result = (switch_status_t)switch_core_session_set_private_class(arg1,arg2,arg3); jresult = result; return jresult; } @@ -11071,14 +11663,14 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_db_test_reactive(void * jarg1, ch } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_perform_file_open(char * jarg1, char * jarg2, int jarg3, void * jarg4, char * jarg5, unsigned char jarg6, unsigned long jarg7, unsigned int jarg8, void * jarg9) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_perform_file_open(char * jarg1, char * jarg2, int jarg3, void * jarg4, char * jarg5, unsigned long jarg6, unsigned long jarg7, unsigned int jarg8, void * jarg9) { int jresult ; char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; int arg3 ; switch_file_handle_t *arg4 = (switch_file_handle_t *) 0 ; char *arg5 = (char *) 0 ; - uint8_t arg6 ; + uint32_t arg6 ; uint32_t arg7 ; unsigned int arg8 ; switch_memory_pool_t *arg9 = (switch_memory_pool_t *) 0 ; @@ -11089,7 +11681,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_perform_file_open(char * jarg1, ch arg3 = (int)jarg3; arg4 = (switch_file_handle_t *)jarg4; arg5 = (char *)jarg5; - arg6 = (uint8_t)jarg6; + arg6 = (uint32_t)jarg6; arg7 = (uint32_t)jarg7; arg8 = (unsigned int)jarg8; arg9 = (switch_memory_pool_t *)jarg9; @@ -13605,6 +14197,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_stream_system_fork(char * jarg1, void * } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ice_direction(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_call_direction_t)switch_ice_direction(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_module_name_set(void * jarg1, char * jarg2) { switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; char *arg2 = (char *) 0 ; @@ -13788,6 +14392,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_api_interf } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_json_api_interface_set(void * jarg1, void * jarg2) { + switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; + switch_json_api_interface_t *arg2 = (switch_json_api_interface_t *) 0 ; + + arg1 = (switch_loadable_module_interface *)jarg1; + arg2 = (switch_json_api_interface_t *)jarg2; + if (arg1) (arg1)->json_api_interface = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_json_api_interface_get(void * jarg1) { + void * jresult ; + switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; + switch_json_api_interface_t *result = 0 ; + + arg1 = (switch_loadable_module_interface *)jarg1; + result = (switch_json_api_interface_t *) ((arg1)->json_api_interface); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_file_interface_set(void * jarg1, void * jarg2) { switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; switch_file_interface_t *arg2 = (switch_file_interface_t *) 0 ; @@ -14233,6 +14859,18 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_api_interface(ch } +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_json_api_interface(char * jarg1) { + void * jresult ; + char *arg1 = (char *) 0 ; + switch_json_api_interface_t *result = 0 ; + + arg1 = (char *)jarg1; + result = (switch_json_api_interface_t *)switch_loadable_module_get_json_api_interface((char const *)arg1); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_file_interface(char * jarg1) { void * jresult ; char *arg1 = (char *) 0 ; @@ -14379,6 +15017,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_api_execute(char * jarg1, char * jarg2, } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_json_api_execute(void * jarg1, void * jarg2, void * jarg3) { + int jresult ; + cJSON *arg1 = (cJSON *) 0 ; + switch_core_session_t *arg2 = (switch_core_session_t *) 0 ; + cJSON **arg3 = (cJSON **) 0 ; + switch_status_t result; + + arg1 = (cJSON *)jarg1; + arg2 = (switch_core_session_t *)jarg2; + arg3 = (cJSON **)jarg3; + result = (switch_status_t)switch_json_api_execute(arg1,arg2,arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_load_module(char * jarg1, char * jarg2, int jarg3, void * jarg4) { int jresult ; char *arg1 = (char *) 0 ; @@ -14507,6 +15161,40 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_codec_ready(void * jarg1) { } +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_get_secondary_recover_callback(char * jarg1) { + void * jresult ; + char *arg1 = (char *) 0 ; + switch_core_recover_callback_t result; + + arg1 = (char *)jarg1; + result = (switch_core_recover_callback_t)switch_core_get_secondary_recover_callback((char const *)arg1); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_register_secondary_recover_callback(char * jarg1, void * jarg2) { + int jresult ; + char *arg1 = (char *) 0 ; + switch_core_recover_callback_t arg2 = (switch_core_recover_callback_t) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (switch_core_recover_callback_t)jarg2; + result = (switch_status_t)switch_core_register_secondary_recover_callback((char const *)arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_unregister_secondary_recover_callback(char * jarg1) { + char *arg1 = (char *) 0 ; + + arg1 = (char *)jarg1; + switch_core_unregister_secondary_recover_callback((char const *)arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CMD_CHUNK_LEN_get() { int jresult ; int result; @@ -14624,6 +15312,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_console_run_complete_func(char * jarg1, } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_push_match_unique(void * jarg1, char * jarg2) { + switch_console_callback_match_t **arg1 = (switch_console_callback_match_t **) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_console_callback_match_t **)jarg1; + arg2 = (char *)jarg2; + switch_console_push_match_unique(arg1,(char const *)arg2); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_console_push_match(void * jarg1, char * jarg2) { switch_console_callback_match_t **arg1 = (switch_console_callback_match_t **) 0 ; char *arg2 = (char *) 0 ; @@ -15405,6 +16103,26 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_find_local_ip(char * jarg1, int jarg2, } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_find_interface_ip(char * jarg1, int jarg2, void * jarg3, char * jarg4, int jarg5) { + int jresult ; + char *arg1 = (char *) 0 ; + int arg2 ; + int *arg3 = (int *) 0 ; + char *arg4 = (char *) 0 ; + int arg5 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (int)jarg2; + arg3 = (int *)jarg3; + arg4 = (char *)jarg4; + arg5 = (int)jarg5; + result = (switch_status_t)switch_find_interface_ip(arg1,arg2,arg3,(char const *)arg4,arg5); + jresult = result; + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_get_addr(char * jarg1, void * jarg2, void * jarg3, void * jarg4) { char * jresult ; char *arg1 = (char *) 0 ; @@ -17483,6 +18201,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_caller_profile_direction_get(void * jar } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_logical_direction_set(void * jarg1, int jarg2) { + switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; + switch_call_direction_t arg2 ; + + arg1 = (switch_caller_profile *)jarg1; + arg2 = (switch_call_direction_t)jarg2; + if (arg1) (arg1)->logical_direction = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_caller_profile_logical_direction_get(void * jarg1) { + int jresult ; + switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_caller_profile *)jarg1; + result = (switch_call_direction_t) ((arg1)->logical_direction); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_soft_set(void * jarg1, void * jarg2) { switch_caller_profile *arg1 = (switch_caller_profile *) 0 ; profile_node_t *arg2 = (profile_node_t *) 0 ; @@ -18459,6 +19199,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_frame_user_data_get(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_frame_pmap_set(void * jarg1, void * jarg2) { + switch_frame *arg1 = (switch_frame *) 0 ; + payload_map_t *arg2 = (payload_map_t *) 0 ; + + arg1 = (switch_frame *)jarg1; + arg2 = (payload_map_t *)jarg2; + if (arg1) (arg1)->pmap = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_frame_pmap_get(void * jarg1) { + void * jresult ; + switch_frame *arg1 = (switch_frame *) 0 ; + payload_map_t *result = 0 ; + + arg1 = (switch_frame *)jarg1; + result = (payload_map_t *) ((arg1)->pmap); + jresult = (void *)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_frame() { void * jresult ; switch_frame *result = 0 ; @@ -20827,24 +21589,24 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_native_rate_get(v } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_channels_set(void * jarg1, unsigned char jarg2) { +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_channels_set(void * jarg1, unsigned long jarg2) { switch_file_handle *arg1 = (switch_file_handle *) 0 ; - uint8_t arg2 ; + uint32_t arg2 ; arg1 = (switch_file_handle *)jarg1; - arg2 = (uint8_t)jarg2; + arg2 = (uint32_t)jarg2; if (arg1) (arg1)->channels = arg2; } -SWIGEXPORT unsigned char SWIGSTDCALL CSharp_switch_file_handle_channels_get(void * jarg1) { - unsigned char jresult ; +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_channels_get(void * jarg1) { + unsigned long jresult ; switch_file_handle *arg1 = (switch_file_handle *) 0 ; - uint8_t result; + uint32_t result; arg1 = (switch_file_handle *)jarg1; - result = (uint8_t) ((arg1)->channels); - jresult = result; + result = (uint32_t) ((arg1)->channels); + jresult = (unsigned long)result; return jresult; } @@ -21672,6 +22434,50 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle__params_get(void * jarg1 } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_cur_channels_set(void * jarg1, unsigned long jarg2) { + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_file_handle *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->cur_channels = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_cur_channels_get(void * jarg1) { + unsigned long jresult ; + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + uint32_t result; + + arg1 = (switch_file_handle *)jarg1; + result = (uint32_t) ((arg1)->cur_channels); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_cur_samplerate_set(void * jarg1, unsigned long jarg2) { + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_file_handle *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->cur_samplerate = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_cur_samplerate_get(void * jarg1) { + unsigned long jresult ; + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + uint32_t result; + + arg1 = (switch_file_handle *)jarg1; + result = (uint32_t) ((arg1)->cur_samplerate); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_file_handle() { void * jresult ; switch_file_handle *result = 0 ; @@ -26566,6 +27372,243 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_api_interface(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_interface_name_set(void * jarg1, char * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (char *)jarg2; + { + if (arg2) { + arg1->interface_name = (char const *) (new char[strlen((const char *)arg2)+1]); + strcpy((char *)arg1->interface_name, (const char *)arg2); + } else { + arg1->interface_name = 0; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_json_api_interface_interface_name_get(void * jarg1) { + char * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (char *) ((arg1)->interface_name); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_desc_set(void * jarg1, char * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (char *)jarg2; + { + if (arg2) { + arg1->desc = (char const *) (new char[strlen((const char *)arg2)+1]); + strcpy((char *)arg1->desc, (const char *)arg2); + } else { + arg1->desc = 0; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_json_api_interface_desc_get(void * jarg1) { + char * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (char *) ((arg1)->desc); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_function_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_json_api_function_t arg2 = (switch_json_api_function_t) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_json_api_function_t)jarg2; + if (arg1) (arg1)->function = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_function_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_json_api_function_t result; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_json_api_function_t) ((arg1)->function); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_syntax_set(void * jarg1, char * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *arg2 = (char *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (char *)jarg2; + { + if (arg2) { + arg1->syntax = (char const *) (new char[strlen((const char *)arg2)+1]); + strcpy((char *)arg1->syntax, (const char *)arg2); + } else { + arg1->syntax = 0; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_json_api_interface_syntax_get(void * jarg1) { + char * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + char *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (char *) ((arg1)->syntax); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_rwlock_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_thread_rwlock_t *arg2 = (switch_thread_rwlock_t *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_thread_rwlock_t *)jarg2; + if (arg1) (arg1)->rwlock = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_rwlock_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_thread_rwlock_t *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_thread_rwlock_t *) ((arg1)->rwlock); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_refs_set(void * jarg1, int jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + int arg2 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->refs = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_json_api_interface_refs_get(void * jarg1) { + int jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + int result; + + arg1 = (switch_json_api_interface *)jarg1; + result = (int) ((arg1)->refs); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_reflock_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_mutex_t *arg2 = (switch_mutex_t *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_mutex_t *)jarg2; + if (arg1) (arg1)->reflock = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_reflock_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_mutex_t *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_mutex_t *) ((arg1)->reflock); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_parent_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_loadable_module_interface_t *arg2 = (switch_loadable_module_interface_t *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_loadable_module_interface_t *)jarg2; + if (arg1) (arg1)->parent = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_parent_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_loadable_module_interface_t *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_loadable_module_interface_t *) ((arg1)->parent); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_api_interface_next_set(void * jarg1, void * jarg2) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_json_api_interface *arg2 = (switch_json_api_interface *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + arg2 = (switch_json_api_interface *)jarg2; + if (arg1) (arg1)->next = arg2; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_json_api_interface_next_get(void * jarg1) { + void * jresult ; + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + switch_json_api_interface *result = 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + result = (switch_json_api_interface *) ((arg1)->next); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_json_api_interface() { + void * jresult ; + switch_json_api_interface *result = 0 ; + + result = (switch_json_api_interface *)new switch_json_api_interface(); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_json_api_interface(void * jarg1) { + switch_json_api_interface *arg1 = (switch_json_api_interface *) 0 ; + + arg1 = (switch_json_api_interface *)jarg1; + delete arg1; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_slin_data_session_set(void * jarg1, void * jarg2) { switch_slin_data *arg1 = (switch_slin_data *) 0 ; switch_core_session_t *arg2 = (switch_core_session_t *) 0 ; @@ -28570,6 +29613,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_direction(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_logical_direction(void * jarg1) { + int jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_call_direction_t result; + + arg1 = (switch_channel_t *)jarg1; + result = (switch_call_direction_t)switch_channel_logical_direction(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_set_direction(void * jarg1, int jarg2) { + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + switch_call_direction_t arg2 ; + + arg1 = (switch_channel_t *)jarg1; + arg2 = (switch_call_direction_t)jarg2; + switch_channel_set_direction(arg1,arg2); +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_get_session(void * jarg1) { void * jresult ; switch_channel_t *arg1 = (switch_channel_t *) 0 ; @@ -30383,6 +31448,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_serialize_json(void * jarg1, void } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_serialize_json_obj(void * jarg1, void * jarg2) { + int jresult ; + switch_event_t *arg1 = (switch_event_t *) 0 ; + cJSON **arg2 = (cJSON **) 0 ; + switch_status_t result; + + arg1 = (switch_event_t *)jarg1; + arg2 = (cJSON **)jarg2; + result = (switch_status_t)switch_event_serialize_json_obj(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_json(void * jarg1, char * jarg2) { int jresult ; switch_event_t **arg1 = (switch_event_t **) 0 ; @@ -30587,6 +31666,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_add_presence_data_cols(void * ja } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_json_add_presence_data_cols(void * jarg1, void * jarg2, char * jarg3) { + switch_event_t *arg1 = (switch_event_t *) 0 ; + cJSON *arg2 = (cJSON *) 0 ; + char *arg3 = (char *) 0 ; + + arg1 = (switch_event_t *)jarg1; + arg2 = (cJSON *)jarg2; + arg3 = (char *)jarg3; + switch_json_add_presence_data_cols(arg1,arg2,(char const *)arg3); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_launch_dispatch_threads(unsigned long jarg1) { uint32_t arg1 ; @@ -30595,6 +31686,334 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_launch_dispatch_threads(unsigned } +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_event_channel_broadcast(char * jarg1, void * jarg2, char * jarg3, unsigned long jarg4) { + unsigned long jresult ; + char *arg1 = (char *) 0 ; + cJSON **arg2 = (cJSON **) 0 ; + char *arg3 = (char *) 0 ; + switch_event_channel_id_t arg4 ; + uint32_t result; + + arg1 = (char *)jarg1; + arg2 = (cJSON **)jarg2; + arg3 = (char *)jarg3; + arg4 = (switch_event_channel_id_t)jarg4; + result = (uint32_t)switch_event_channel_broadcast((char const *)arg1,arg2,(char const *)arg3,arg4); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_event_channel_unbind(char * jarg1, void * jarg2) { + unsigned long jresult ; + char *arg1 = (char *) 0 ; + switch_event_channel_func_t arg2 = (switch_event_channel_func_t) 0 ; + uint32_t result; + + arg1 = (char *)jarg1; + arg2 = (switch_event_channel_func_t)jarg2; + result = (uint32_t)switch_event_channel_unbind((char const *)arg1,arg2); + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_channel_bind(char * jarg1, void * jarg2, void * jarg3) { + int jresult ; + char *arg1 = (char *) 0 ; + switch_event_channel_func_t arg2 = (switch_event_channel_func_t) 0 ; + switch_event_channel_id_t *arg3 = (switch_event_channel_id_t *) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (switch_event_channel_func_t)jarg2; + arg3 = (switch_event_channel_id_t *)jarg3; + result = (switch_status_t)switch_event_channel_bind((char const *)arg1,arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_NO_EVENT_CHANNEL_ID_get() { + int jresult ; + int result; + + result = (int)(0); + jresult = result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_EVENT_CHANNEL_GLOBAL_get() { + char * jresult ; + char *result = 0 ; + + result = (char *)("__global__"); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_clear(void * jarg1) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + result = (switch_status_t)switch_live_array_clear(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_bootstrap(void * jarg1, char * jarg2, unsigned long jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_event_channel_id_t arg3 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_event_channel_id_t)jarg3; + result = (switch_status_t)switch_live_array_bootstrap(arg1,(char const *)arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_destroy(void * jarg1) { + int jresult ; + switch_live_array_t **arg1 = (switch_live_array_t **) 0 ; + switch_status_t result; + + arg1 = (switch_live_array_t **)jarg1; + result = (switch_status_t)switch_live_array_destroy(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_create(char * jarg1, char * jarg2, unsigned long jarg3, void * jarg4) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + switch_event_channel_id_t arg3 ; + switch_live_array_t **arg4 = (switch_live_array_t **) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_event_channel_id_t)jarg3; + arg4 = (switch_live_array_t **)jarg4; + result = (switch_status_t)switch_live_array_create((char const *)arg1,(char const *)arg2,arg3,arg4); + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_live_array_get(void * jarg1, char * jarg2) { + void * jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + cJSON *result = 0 ; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + result = (cJSON *)switch_live_array_get(arg1,(char const *)arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_live_array_get_idx(void * jarg1, int jarg2) { + void * jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + int arg2 ; + cJSON *result = 0 ; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (int)jarg2; + result = (cJSON *)switch_live_array_get_idx(arg1,arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_del(void * jarg1, char * jarg2) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + result = (switch_status_t)switch_live_array_del(arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_add(void * jarg1, char * jarg2, int jarg3, void * jarg4, int jarg5) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + cJSON **arg4 = (cJSON **) 0 ; + switch_bool_t arg5 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (int)jarg3; + arg4 = (cJSON **)jarg4; + arg5 = (switch_bool_t)jarg5; + result = (switch_status_t)switch_live_array_add(arg1,(char const *)arg2,arg3,arg4,arg5); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_visible(void * jarg1, int jarg2, int jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + switch_bool_t arg2 ; + switch_bool_t arg3 ; + switch_status_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (switch_bool_t)jarg2; + arg3 = (switch_bool_t)jarg3; + result = (switch_status_t)switch_live_array_visible(arg1,arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_isnew(void * jarg1) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + switch_bool_t result; + + arg1 = (switch_live_array_t *)jarg1; + result = (switch_bool_t)switch_live_array_isnew(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_lock(void * jarg1) { + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + + arg1 = (switch_live_array_t *)jarg1; + switch_live_array_lock(arg1); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_unlock(void * jarg1) { + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + + arg1 = (switch_live_array_t *)jarg1; + switch_live_array_unlock(arg1); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_set_user_data(void * jarg1, void * jarg2) { + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (void *)jarg2; + switch_live_array_set_user_data(arg1,arg2); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_set_command_handler(void * jarg1, void * jarg2) { + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + switch_live_array_command_handler_t arg2 = (switch_live_array_command_handler_t) 0 ; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (switch_live_array_command_handler_t)jarg2; + switch_live_array_set_command_handler(arg1,arg2); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_live_array_parse_json(void * jarg1, unsigned long jarg2) { + cJSON *arg1 = (cJSON *) 0 ; + switch_event_channel_id_t arg2 ; + + arg1 = (cJSON *)jarg1; + arg2 = (switch_event_channel_id_t)jarg2; + switch_live_array_parse_json(arg1,arg2); +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_add_alias(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_bool_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_bool_t)switch_live_array_add_alias(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_live_array_clear_alias(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_live_array_t *arg1 = (switch_live_array_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_bool_t result; + + arg1 = (switch_live_array_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_bool_t)switch_live_array_clear_alias(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_channel_permission_verify(char * jarg1, char * jarg2) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + switch_bool_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + result = (switch_bool_t)switch_event_channel_permission_verify((char const *)arg1,(char const *)arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_channel_permission_modify(char * jarg1, char * jarg2, int jarg3) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + switch_bool_t arg3 ; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_bool_t)jarg3; + switch_event_channel_permission_modify((char const *)arg1,(char const *)arg2,arg3); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_channel_permission_clear(char * jarg1) { + char *arg1 = (char *) 0 ; + + arg1 = (char *)jarg1; + switch_event_channel_permission_clear((char const *)arg1); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RESAMPLE_QUALITY_get() { int jresult ; int result; @@ -35304,16 +36723,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_telephony_recv_event(void * ja } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_recv_pt(void * jarg1, unsigned char jarg2) { - switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; - switch_payload_t arg2 ; - - arg1 = (switch_rtp_t *)jarg1; - arg2 = (switch_payload_t)jarg2; - switch_rtp_set_recv_pt(arg1,arg2); -} - - SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_cng_pt(void * jarg1, unsigned char jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_payload_t arg2 ; @@ -35336,6 +36745,20 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_get_private(void * jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_set_payload_map(void * jarg1, void * jarg2) { + int jresult ; + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + payload_map_t **arg2 = (payload_map_t **) 0 ; + switch_status_t result; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (payload_map_t **)jarg2; + result = (switch_status_t)switch_rtp_set_payload_map(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_intentional_bugs(void * jarg1, int jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_rtp_bug_flag_t arg2 ; @@ -35400,6 +36823,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_add_dtls(void * jarg1, void * jarg2 } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_del_dtls(void * jarg1, int jarg2) { + int jresult ; + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + dtls_type_t arg2 ; + switch_status_t result; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (dtls_type_t)jarg2; + result = (switch_status_t)switch_rtp_del_dtls(arg1,arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_has_dtls() { int jresult ; int result; @@ -38380,6 +39817,28 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_task_cmd_id_get(voi } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_repeat_set(void * jarg1, unsigned long jarg2) { + switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; + uint32_t arg2 ; + + arg1 = (switch_scheduler_task *)jarg1; + arg2 = (uint32_t)jarg2; + if (arg1) (arg1)->repeat = arg2; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_scheduler_task_repeat_get(void * jarg1) { + unsigned long jresult ; + switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; + uint32_t result; + + arg1 = (switch_scheduler_task *)jarg1; + result = (uint32_t) ((arg1)->repeat); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_scheduler_task_group_set(void * jarg1, char * jarg2) { switch_scheduler_task *arg1 = (switch_scheduler_task *) 0 ; char *arg2 = (char *) 0 ; @@ -38971,11 +40430,13 @@ SWIGEXPORT void SWIGSTDCALL CSharp_IvrMenu_Execute(void * jarg1, void * jarg2, c } -SWIGEXPORT void * SWIGSTDCALL CSharp_new_Api() { +SWIGEXPORT void * SWIGSTDCALL CSharp_new_Api(void * jarg1) { void * jresult ; + CoreSession *arg1 = (CoreSession *) NULL ; API *result = 0 ; - result = (API *)new API(); + arg1 = (CoreSession *)jarg1; + result = (API *)new API(arg1); jresult = (void *)result; return jresult; } diff --git a/src/mod/languages/mod_managed/managed/swig.2010.cs b/src/mod/languages/mod_managed/managed/swig.2010.cs index 3aff242242..44cc42ee90 100644 --- a/src/mod/languages/mod_managed/managed/swig.2010.cs +++ b/src/mod/languages/mod_managed/managed/swig.2010.cs @@ -41,7 +41,7 @@ public class Api : IDisposable { } } - public Api() : this(freeswitchPINVOKE.new_Api(), true) { + public Api(CoreSession s) : this(freeswitchPINVOKE.new_Api(CoreSession.getCPtr(s)), true) { } public string Execute(string command, string data) { @@ -1773,6 +1773,11 @@ public class freeswitch { return ret; } + public static string switch_core_get_domain(switch_bool_t dup) { + string ret = freeswitchPINVOKE.switch_core_get_domain((int)dup); + return ret; + } + public static void switch_core_set_variable(string varname, string value) { freeswitchPINVOKE.switch_core_set_variable(varname, value); } @@ -1881,6 +1886,10 @@ public class freeswitch { return ret; } + public static void switch_core_session_video_reset(SWIGTYPE_p_switch_core_session session) { + freeswitchPINVOKE.switch_core_session_video_reset(SWIGTYPE_p_switch_core_session.getCPtr(session)); + } + public static switch_status_t switch_core_session_execute_application_get_flags(SWIGTYPE_p_switch_core_session session, string app, string arg, SWIGTYPE_p_int flags) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_execute_application_get_flags(SWIGTYPE_p_switch_core_session.getCPtr(session), app, arg, SWIGTYPE_p_int.getCPtr(flags)); return ret; @@ -1906,14 +1915,14 @@ public class freeswitch { return ret; } - public static SWIGTYPE_p_void switch_core_session_get_private(SWIGTYPE_p_switch_core_session session) { - IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_private(SWIGTYPE_p_switch_core_session.getCPtr(session)); + public static SWIGTYPE_p_void switch_core_session_get_private_class(SWIGTYPE_p_switch_core_session session, switch_pvt_class_t index) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_private_class(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)index); SWIGTYPE_p_void ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_void(cPtr, false); return ret; } - public static switch_status_t switch_core_session_set_private(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_void private_info) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_set_private(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_void.getCPtr(private_info)); + public static switch_status_t switch_core_session_set_private_class(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_void private_info, switch_pvt_class_t index) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_set_private_class(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_void.getCPtr(private_info), (int)index); return ret; } @@ -2353,7 +2362,7 @@ public class freeswitch { freeswitchPINVOKE.switch_core_db_test_reactive(SWIGTYPE_p_sqlite3.getCPtr(db), test_sql, drop_sql, reactive_sql); } - public static switch_status_t switch_core_perform_file_open(string file, string func, int line, switch_file_handle fh, string file_path, byte channels, uint rate, uint flags, SWIGTYPE_p_apr_pool_t pool) { + public static switch_status_t switch_core_perform_file_open(string file, string func, int line, switch_file_handle fh, string file_path, uint channels, uint rate, uint flags, SWIGTYPE_p_apr_pool_t pool) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_perform_file_open(file, func, line, switch_file_handle.getCPtr(fh), file_path, channels, rate, flags, SWIGTYPE_p_apr_pool_t.getCPtr(pool)); return ret; } @@ -3146,6 +3155,11 @@ public class freeswitch { return ret; } + public static switch_call_direction_t switch_ice_direction(SWIGTYPE_p_switch_core_session session) { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_ice_direction(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + public static switch_status_t switch_loadable_module_init(switch_bool_t autoload) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_loadable_module_init((int)autoload); return ret; @@ -3222,6 +3236,12 @@ public class freeswitch { return ret; } + public static switch_json_api_interface switch_loadable_module_get_json_api_interface(string name) { + IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_json_api_interface(name); + switch_json_api_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_json_api_interface(cPtr, false); + return ret; + } + public static switch_file_interface switch_loadable_module_get_file_interface(string name) { IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_file_interface(name); switch_file_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_file_interface(cPtr, false); @@ -3285,6 +3305,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_json_api_execute(SWIGTYPE_p_cJSON json, SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_cJSON retval) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_json_api_execute(SWIGTYPE_p_cJSON.getCPtr(json), SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_cJSON.getCPtr(retval)); + return ret; + } + public static switch_status_t switch_loadable_module_load_module(string dir, string fname, switch_bool_t runtime, ref string err) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_loadable_module_load_module(dir, fname, (int)runtime, ref err); return ret; @@ -3319,6 +3344,21 @@ public class freeswitch { return ret; } + public static SWIGTYPE_p_f_p_switch_core_session__int switch_core_get_secondary_recover_callback(string key) { + IntPtr cPtr = freeswitchPINVOKE.switch_core_get_secondary_recover_callback(key); + SWIGTYPE_p_f_p_switch_core_session__int ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_core_session__int(cPtr, false); + return ret; + } + + public static switch_status_t switch_core_register_secondary_recover_callback(string key, SWIGTYPE_p_f_p_switch_core_session__int cb) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_register_secondary_recover_callback(key, SWIGTYPE_p_f_p_switch_core_session__int.getCPtr(cb)); + return ret; + } + + public static void switch_core_unregister_secondary_recover_callback(string key) { + freeswitchPINVOKE.switch_core_unregister_secondary_recover_callback(key); + } + public static void switch_console_loop() { freeswitchPINVOKE.switch_console_loop(); } @@ -3359,6 +3399,10 @@ public class freeswitch { return ret; } + public static void switch_console_push_match_unique(SWIGTYPE_p_p_switch_console_callback_match matches, string new_val) { + freeswitchPINVOKE.switch_console_push_match_unique(SWIGTYPE_p_p_switch_console_callback_match.getCPtr(matches), new_val); + } + public static void switch_console_push_match(SWIGTYPE_p_p_switch_console_callback_match matches, string new_val) { freeswitchPINVOKE.switch_console_push_match(SWIGTYPE_p_p_switch_console_callback_match.getCPtr(matches), new_val); } @@ -3605,6 +3649,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_find_interface_ip(string buf, int len, SWIGTYPE_p_int mask, string ifname, int family) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_find_interface_ip(buf, len, SWIGTYPE_p_int.getCPtr(mask), ifname, family); + return ret; + } + public static string get_addr(string buf, SWIGTYPE_p_switch_size_t len, SWIGTYPE_p_sockaddr sa, SWIGTYPE_p_socklen_t salen) { string ret = freeswitchPINVOKE.get_addr(buf, SWIGTYPE_p_switch_size_t.getCPtr(len), SWIGTYPE_p_sockaddr.getCPtr(sa), SWIGTYPE_p_socklen_t.getCPtr(salen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -4546,6 +4595,15 @@ public class freeswitch { return ret; } + public static switch_call_direction_t switch_channel_logical_direction(SWIGTYPE_p_switch_channel channel) { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_channel_logical_direction(SWIGTYPE_p_switch_channel.getCPtr(channel)); + return ret; + } + + public static void switch_channel_set_direction(SWIGTYPE_p_switch_channel channel, switch_call_direction_t direction) { + freeswitchPINVOKE.switch_channel_set_direction(SWIGTYPE_p_switch_channel.getCPtr(channel), (int)direction); + } + public static SWIGTYPE_p_switch_core_session switch_channel_get_session(SWIGTYPE_p_switch_channel channel) { IntPtr cPtr = freeswitchPINVOKE.switch_channel_get_session(SWIGTYPE_p_switch_channel.getCPtr(channel)); SWIGTYPE_p_switch_core_session ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_core_session(cPtr, false); @@ -4911,8 +4969,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_event_binary_deserialize(SWIGTYPE_p_p_switch_event eventp, SWIGTYPE_p_p_void data, SWIGTYPE_p_switch_size_t len, switch_bool_t destroy) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_binary_deserialize(SWIGTYPE_p_p_switch_event.getCPtr(eventp), SWIGTYPE_p_p_void.getCPtr(data), SWIGTYPE_p_switch_size_t.getCPtr(len), (int)destroy); + public static switch_status_t switch_event_binary_deserialize(SWIGTYPE_p_p_switch_event eventp, SWIGTYPE_p_p_void data, SWIGTYPE_p_switch_size_t len, switch_bool_t duplicate) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_binary_deserialize(SWIGTYPE_p_p_switch_event.getCPtr(eventp), SWIGTYPE_p_p_void.getCPtr(data), SWIGTYPE_p_switch_size_t.getCPtr(len), (int)duplicate); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); return ret; } @@ -4932,6 +4990,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_event_serialize_json_obj(switch_event arg0, SWIGTYPE_p_p_cJSON json) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_serialize_json_obj(switch_event.getCPtr(arg0), SWIGTYPE_p_p_cJSON.getCPtr(json)); + return ret; + } + public static switch_status_t switch_event_create_json(SWIGTYPE_p_p_switch_event arg0, string json) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_create_json(SWIGTYPE_p_p_switch_event.getCPtr(arg0), json); return ret; @@ -4990,10 +5053,124 @@ public class freeswitch { freeswitchPINVOKE.switch_event_add_presence_data_cols(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_event.getCPtr(arg1), prefix); } + public static void switch_json_add_presence_data_cols(switch_event arg0, SWIGTYPE_p_cJSON json, string prefix) { + freeswitchPINVOKE.switch_json_add_presence_data_cols(switch_event.getCPtr(arg0), SWIGTYPE_p_cJSON.getCPtr(json), prefix); + } + public static void switch_event_launch_dispatch_threads(uint max) { freeswitchPINVOKE.switch_event_launch_dispatch_threads(max); } + public static uint switch_event_channel_broadcast(string event_channel, SWIGTYPE_p_p_cJSON json, string key, uint id) { + uint ret = freeswitchPINVOKE.switch_event_channel_broadcast(event_channel, SWIGTYPE_p_p_cJSON.getCPtr(json), key, id); + return ret; + } + + public static uint switch_event_channel_unbind(string event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void func) { + uint ret = freeswitchPINVOKE.switch_event_channel_unbind(event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void.getCPtr(func)); + return ret; + } + + public static switch_status_t switch_event_channel_bind(string event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void func, SWIGTYPE_p_unsigned_long id) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_channel_bind(event_channel, SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void.getCPtr(func), SWIGTYPE_p_unsigned_long.getCPtr(id)); + return ret; + } + + public static switch_status_t switch_live_array_clear(SWIGTYPE_p_switch_live_array_s la) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_clear(SWIGTYPE_p_switch_live_array_s.getCPtr(la)); + return ret; + } + + public static switch_status_t switch_live_array_bootstrap(SWIGTYPE_p_switch_live_array_s la, string sessid, uint channel_id) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_bootstrap(SWIGTYPE_p_switch_live_array_s.getCPtr(la), sessid, channel_id); + return ret; + } + + public static switch_status_t switch_live_array_destroy(SWIGTYPE_p_p_switch_live_array_s live_arrayP) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_destroy(SWIGTYPE_p_p_switch_live_array_s.getCPtr(live_arrayP)); + return ret; + } + + public static switch_status_t switch_live_array_create(string event_channel, string name, uint channel_id, SWIGTYPE_p_p_switch_live_array_s live_arrayP) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_create(event_channel, name, channel_id, SWIGTYPE_p_p_switch_live_array_s.getCPtr(live_arrayP)); + return ret; + } + + public static SWIGTYPE_p_cJSON switch_live_array_get(SWIGTYPE_p_switch_live_array_s la, string name) { + IntPtr cPtr = freeswitchPINVOKE.switch_live_array_get(SWIGTYPE_p_switch_live_array_s.getCPtr(la), name); + SWIGTYPE_p_cJSON ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_cJSON(cPtr, false); + return ret; + } + + public static SWIGTYPE_p_cJSON switch_live_array_get_idx(SWIGTYPE_p_switch_live_array_s la, int idx) { + IntPtr cPtr = freeswitchPINVOKE.switch_live_array_get_idx(SWIGTYPE_p_switch_live_array_s.getCPtr(la), idx); + SWIGTYPE_p_cJSON ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_cJSON(cPtr, false); + return ret; + } + + public static switch_status_t switch_live_array_del(SWIGTYPE_p_switch_live_array_s la, string name) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_del(SWIGTYPE_p_switch_live_array_s.getCPtr(la), name); + return ret; + } + + public static switch_status_t switch_live_array_add(SWIGTYPE_p_switch_live_array_s la, string name, int index, SWIGTYPE_p_p_cJSON obj, switch_bool_t destroy) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_add(SWIGTYPE_p_switch_live_array_s.getCPtr(la), name, index, SWIGTYPE_p_p_cJSON.getCPtr(obj), (int)destroy); + return ret; + } + + public static switch_status_t switch_live_array_visible(SWIGTYPE_p_switch_live_array_s la, switch_bool_t visible, switch_bool_t force) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_live_array_visible(SWIGTYPE_p_switch_live_array_s.getCPtr(la), (int)visible, (int)force); + return ret; + } + + public static switch_bool_t switch_live_array_isnew(SWIGTYPE_p_switch_live_array_s la) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_live_array_isnew(SWIGTYPE_p_switch_live_array_s.getCPtr(la)); + return ret; + } + + public static void switch_live_array_lock(SWIGTYPE_p_switch_live_array_s la) { + freeswitchPINVOKE.switch_live_array_lock(SWIGTYPE_p_switch_live_array_s.getCPtr(la)); + } + + public static void switch_live_array_unlock(SWIGTYPE_p_switch_live_array_s la) { + freeswitchPINVOKE.switch_live_array_unlock(SWIGTYPE_p_switch_live_array_s.getCPtr(la)); + } + + public static void switch_live_array_set_user_data(SWIGTYPE_p_switch_live_array_s la, SWIGTYPE_p_void user_data) { + freeswitchPINVOKE.switch_live_array_set_user_data(SWIGTYPE_p_switch_live_array_s.getCPtr(la), SWIGTYPE_p_void.getCPtr(user_data)); + } + + public static void switch_live_array_set_command_handler(SWIGTYPE_p_switch_live_array_s la, SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void command_handler) { + freeswitchPINVOKE.switch_live_array_set_command_handler(SWIGTYPE_p_switch_live_array_s.getCPtr(la), SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void.getCPtr(command_handler)); + } + + public static void switch_live_array_parse_json(SWIGTYPE_p_cJSON json, uint channel_id) { + freeswitchPINVOKE.switch_live_array_parse_json(SWIGTYPE_p_cJSON.getCPtr(json), channel_id); + } + + public static switch_bool_t switch_live_array_add_alias(SWIGTYPE_p_switch_live_array_s la, string event_channel, string name) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_live_array_add_alias(SWIGTYPE_p_switch_live_array_s.getCPtr(la), event_channel, name); + return ret; + } + + public static switch_bool_t switch_live_array_clear_alias(SWIGTYPE_p_switch_live_array_s la, string event_channel, string name) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_live_array_clear_alias(SWIGTYPE_p_switch_live_array_s.getCPtr(la), event_channel, name); + return ret; + } + + public static switch_bool_t switch_event_channel_permission_verify(string cookie, string event_channel) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_event_channel_permission_verify(cookie, event_channel); + return ret; + } + + public static void switch_event_channel_permission_modify(string cookie, string event_channel, switch_bool_t set) { + freeswitchPINVOKE.switch_event_channel_permission_modify(cookie, event_channel, (int)set); + } + + public static void switch_event_channel_permission_clear(string cookie) { + freeswitchPINVOKE.switch_event_channel_permission_clear(cookie); + } + public static switch_status_t switch_resample_perform_create(SWIGTYPE_p_p_switch_audio_resampler_t new_resampler, uint from_rate, uint to_rate, uint to_size, int quality, uint channels, string file, string func, int line) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_resample_perform_create(SWIGTYPE_p_p_switch_audio_resampler_t.getCPtr(new_resampler), from_rate, to_rate, to_size, quality, channels, file, func, line); return ret; @@ -6062,10 +6239,6 @@ public class freeswitch { freeswitchPINVOKE.switch_rtp_set_telephony_recv_event(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), te); } - public static void switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { - freeswitchPINVOKE.switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); - } - public static void switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { freeswitchPINVOKE.switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); } @@ -6076,6 +6249,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_rtp_set_payload_map(SWIGTYPE_p_switch_rtp rtp_session, SWIGTYPE_p_p_payload_map_t pmap) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_set_payload_map(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), SWIGTYPE_p_p_payload_map_t.getCPtr(pmap)); + return ret; + } + public static void switch_rtp_intentional_bugs(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_bug_flag_t bugs) { freeswitchPINVOKE.switch_rtp_intentional_bugs(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)bugs); } @@ -6100,6 +6278,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_rtp_del_dtls(SWIGTYPE_p_switch_rtp rtp_session, dtls_type_t type) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_del_dtls(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)type); + return ret; + } + public static int switch_rtp_has_dtls() { int ret = freeswitchPINVOKE.switch_rtp_has_dtls(); return ret; @@ -6814,6 +6997,7 @@ public class freeswitch { public static readonly int SWITCH_DEFAULT_FILE_BUFFER_LEN = freeswitchPINVOKE.SWITCH_DEFAULT_FILE_BUFFER_LEN_get(); public static readonly int SWITCH_DTMF_LOG_LEN = freeswitchPINVOKE.SWITCH_DTMF_LOG_LEN_get(); public static readonly int SWITCH_MAX_TRANS = freeswitchPINVOKE.SWITCH_MAX_TRANS_get(); + public static readonly int SWITCH_CORE_SESSION_MAX_PRIVATES = freeswitchPINVOKE.SWITCH_CORE_SESSION_MAX_PRIVATES_get(); public static readonly int SWITCH_MAX_STACKS = freeswitchPINVOKE.SWITCH_MAX_STACKS_get(); public static readonly int SWITCH_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_THREAD_STACKSIZE_get(); public static readonly int SWITCH_SYSTEM_THREAD_STACKSIZE = freeswitchPINVOKE.SWITCH_SYSTEM_THREAD_STACKSIZE_get(); @@ -6870,6 +7054,8 @@ public class freeswitch { public static readonly int SWITCH_CMD_CHUNK_LEN = freeswitchPINVOKE.SWITCH_CMD_CHUNK_LEN_get(); public static readonly int SWITCH_SMAX = freeswitchPINVOKE.SWITCH_SMAX_get(); public static readonly int SWITCH_SMIN = freeswitchPINVOKE.SWITCH_SMIN_get(); + public static readonly int NO_EVENT_CHANNEL_ID = freeswitchPINVOKE.NO_EVENT_CHANNEL_ID_get(); + public static readonly string SWITCH_EVENT_CHANNEL_GLOBAL = freeswitchPINVOKE.SWITCH_EVENT_CHANNEL_GLOBAL_get(); public static readonly int SWITCH_RESAMPLE_QUALITY = freeswitchPINVOKE.SWITCH_RESAMPLE_QUALITY_get(); public static readonly int SWITCH_RTP_MAX_BUF_LEN = freeswitchPINVOKE.SWITCH_RTP_MAX_BUF_LEN_get(); public static readonly int SWITCH_RTCP_MAX_BUF_LEN = freeswitchPINVOKE.SWITCH_RTCP_MAX_BUF_LEN_get(); @@ -7561,6 +7747,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_MAX_TRANS_get")] public static extern int SWITCH_MAX_TRANS_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CORE_SESSION_MAX_PRIVATES_get")] + public static extern int SWITCH_CORE_SESSION_MAX_PRIVATES_get(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_dtmf_t_digit_set")] public static extern void switch_dtmf_t_digit_set(HandleRef jarg1, char jarg2); @@ -8683,6 +8872,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_thread_data_t_alloc_get")] public static extern int switch_thread_data_t_alloc_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_thread_data_t_pool_set")] + public static extern void switch_thread_data_t_pool_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_thread_data_t_pool_get")] + public static extern IntPtr switch_thread_data_t_pool_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_thread_data_t")] public static extern IntPtr new_switch_thread_data_t(); @@ -8755,6 +8950,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_hup_profile_get")] public static extern IntPtr switch_device_node_t_hup_profile_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_direction_set")] + public static extern void switch_device_node_t_direction_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_direction_get")] + public static extern int switch_device_node_t_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_node_t_parent_set")] public static extern void switch_device_node_t_parent_set(HandleRef jarg1, HandleRef jarg2); @@ -8779,42 +8980,132 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_get")] public static extern uint switch_device_stats_t_total_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_in_set")] + public static extern void switch_device_stats_t_total_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_in_get")] + public static extern uint switch_device_stats_t_total_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_out_set")] + public static extern void switch_device_stats_t_total_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_total_out_get")] + public static extern uint switch_device_stats_t_total_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_set")] public static extern void switch_device_stats_t_offhook_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_get")] public static extern uint switch_device_stats_t_offhook_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_in_set")] + public static extern void switch_device_stats_t_offhook_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_in_get")] + public static extern uint switch_device_stats_t_offhook_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_out_set")] + public static extern void switch_device_stats_t_offhook_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_offhook_out_get")] + public static extern uint switch_device_stats_t_offhook_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_set")] public static extern void switch_device_stats_t_active_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_get")] public static extern uint switch_device_stats_t_active_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_in_set")] + public static extern void switch_device_stats_t_active_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_in_get")] + public static extern uint switch_device_stats_t_active_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_out_set")] + public static extern void switch_device_stats_t_active_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_active_out_get")] + public static extern uint switch_device_stats_t_active_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_set")] public static extern void switch_device_stats_t_held_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_get")] public static extern uint switch_device_stats_t_held_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_in_set")] + public static extern void switch_device_stats_t_held_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_in_get")] + public static extern uint switch_device_stats_t_held_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_out_set")] + public static extern void switch_device_stats_t_held_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_held_out_get")] + public static extern uint switch_device_stats_t_held_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_set")] public static extern void switch_device_stats_t_hup_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_get")] public static extern uint switch_device_stats_t_hup_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_in_set")] + public static extern void switch_device_stats_t_hup_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_in_get")] + public static extern uint switch_device_stats_t_hup_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_out_set")] + public static extern void switch_device_stats_t_hup_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_hup_out_get")] + public static extern uint switch_device_stats_t_hup_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_set")] public static extern void switch_device_stats_t_ringing_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_get")] public static extern uint switch_device_stats_t_ringing_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_in_set")] + public static extern void switch_device_stats_t_ringing_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_in_get")] + public static extern uint switch_device_stats_t_ringing_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_out_set")] + public static extern void switch_device_stats_t_ringing_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ringing_out_get")] + public static extern uint switch_device_stats_t_ringing_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_set")] public static extern void switch_device_stats_t_early_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_get")] public static extern uint switch_device_stats_t_early_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_in_set")] + public static extern void switch_device_stats_t_early_in_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_in_get")] + public static extern uint switch_device_stats_t_early_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_out_set")] + public static extern void switch_device_stats_t_early_out_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_early_out_get")] + public static extern uint switch_device_stats_t_early_out_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ring_wait_set")] + public static extern void switch_device_stats_t_ring_wait_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_stats_t_ring_wait_get")] + public static extern uint switch_device_stats_t_ring_wait_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_device_stats_t")] public static extern IntPtr new_switch_device_stats_t(); @@ -8845,6 +9136,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_stats_get")] public static extern IntPtr switch_device_record_t_stats_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_stats_set")] + public static extern void switch_device_record_t_last_stats_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_stats_get")] + public static extern IntPtr switch_device_record_t_last_stats_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_state_set")] public static extern void switch_device_record_t_state_set(HandleRef jarg1, int jarg2); @@ -8875,6 +9172,36 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_last_call_time_get")] public static extern IntPtr switch_device_record_t_last_call_time_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_start_set")] + public static extern void switch_device_record_t_ring_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_start_get")] + public static extern IntPtr switch_device_record_t_ring_start_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_stop_set")] + public static extern void switch_device_record_t_ring_stop_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_ring_stop_get")] + public static extern IntPtr switch_device_record_t_ring_stop_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_start_set")] + public static extern void switch_device_record_t_hold_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_start_get")] + public static extern IntPtr switch_device_record_t_hold_start_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_stop_set")] + public static extern void switch_device_record_t_hold_stop_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_hold_stop_get")] + public static extern IntPtr switch_device_record_t_hold_stop_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_call_start_set")] + public static extern void switch_device_record_t_call_start_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_call_start_get")] + public static extern IntPtr switch_device_record_t_call_start_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_uuid_list_set")] public static extern void switch_device_record_t_uuid_list_set(HandleRef jarg1, HandleRef jarg2); @@ -8899,6 +9226,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_pool_get")] public static extern IntPtr switch_device_record_t_pool_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_user_data_set")] + public static extern void switch_device_record_t_user_data_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_device_record_t_user_data_get")] + public static extern IntPtr switch_device_record_t_user_data_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_device_record_t")] public static extern IntPtr new_switch_device_record_t(); @@ -9439,6 +9772,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_switchname")] public static extern string switch_core_get_switchname(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_domain")] + public static extern string switch_core_get_domain(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_set_variable")] public static extern void switch_core_set_variable(string jarg1, string jarg2); @@ -9505,6 +9841,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_exec")] public static extern int switch_core_session_exec(HandleRef jarg1, HandleRef jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_video_reset")] + public static extern void switch_core_session_video_reset(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_execute_application_get_flags")] public static extern int switch_core_session_execute_application_get_flags(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4); @@ -9520,11 +9859,11 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_receive_event")] public static extern int switch_core_session_receive_event(HandleRef jarg1, HandleRef jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_private")] - public static extern IntPtr switch_core_session_get_private(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_private_class")] + public static extern IntPtr switch_core_session_get_private_class(HandleRef jarg1, int jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_set_private")] - public static extern int switch_core_session_set_private(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_set_private_class")] + public static extern int switch_core_session_set_private_class(HandleRef jarg1, HandleRef jarg2, int jarg3); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_add_stream")] public static extern int switch_core_session_add_stream(HandleRef jarg1, HandleRef jarg2); @@ -9788,7 +10127,7 @@ class freeswitchPINVOKE { public static extern void switch_core_db_test_reactive(HandleRef jarg1, string jarg2, string jarg3, string jarg4); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_perform_file_open")] - public static extern int switch_core_perform_file_open(string jarg1, string jarg2, int jarg3, HandleRef jarg4, string jarg5, byte jarg6, uint jarg7, uint jarg8, HandleRef jarg9); + public static extern int switch_core_perform_file_open(string jarg1, string jarg2, int jarg3, HandleRef jarg4, string jarg5, uint jarg6, uint jarg7, uint jarg8, HandleRef jarg9); [DllImport("mod_managed", EntryPoint="CSharp_switch_core_file_read")] public static extern int switch_core_file_read(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); @@ -10381,6 +10720,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_stream_system_fork")] public static extern int switch_stream_system_fork(string jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ice_direction")] + public static extern int switch_ice_direction(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_module_name_set")] public static extern void switch_loadable_module_interface_module_name_set(HandleRef jarg1, string jarg2); @@ -10429,6 +10771,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_api_interface_get")] public static extern IntPtr switch_loadable_module_interface_api_interface_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_json_api_interface_set")] + public static extern void switch_loadable_module_interface_json_api_interface_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_json_api_interface_get")] + public static extern IntPtr switch_loadable_module_interface_json_api_interface_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_file_interface_set")] public static extern void switch_loadable_module_interface_file_interface_set(HandleRef jarg1, HandleRef jarg2); @@ -10543,6 +10891,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_api_interface")] public static extern IntPtr switch_loadable_module_get_api_interface(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_json_api_interface")] + public static extern IntPtr switch_loadable_module_get_json_api_interface(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_file_interface")] public static extern IntPtr switch_loadable_module_get_file_interface(string jarg1); @@ -10576,6 +10927,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_api_execute")] public static extern int switch_api_execute(string jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_execute")] + public static extern int switch_json_api_execute(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_load_module")] public static extern int switch_loadable_module_load_module(string jarg1, string jarg2, int jarg3, ref string jarg4); @@ -10597,6 +10951,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_codec_ready")] public static extern int switch_core_codec_ready(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_secondary_recover_callback")] + public static extern IntPtr switch_core_get_secondary_recover_callback(string jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_register_secondary_recover_callback")] + public static extern int switch_core_register_secondary_recover_callback(string jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_unregister_secondary_recover_callback")] + public static extern void switch_core_unregister_secondary_recover_callback(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CMD_CHUNK_LEN_get")] public static extern int SWITCH_CMD_CHUNK_LEN_get(); @@ -10624,6 +10987,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_console_run_complete_func")] public static extern int switch_console_run_complete_func(string jarg1, string jarg2, string jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_console_push_match_unique")] + public static extern void switch_console_push_match_unique(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_console_push_match")] public static extern void switch_console_push_match(HandleRef jarg1, string jarg2); @@ -10795,6 +11161,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_find_local_ip")] public static extern int switch_find_local_ip(string jarg1, int jarg2, HandleRef jarg3, int jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_find_interface_ip")] + public static extern int switch_find_interface_ip(string jarg1, int jarg2, HandleRef jarg3, string jarg4, int jarg5); + [DllImport("mod_managed", EntryPoint="CSharp_get_addr")] public static extern string get_addr(string jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4); @@ -11242,6 +11611,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_direction_get")] public static extern int switch_caller_profile_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_logical_direction_set")] + public static extern void switch_caller_profile_logical_direction_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_logical_direction_get")] + public static extern int switch_caller_profile_logical_direction_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_caller_profile_soft_set")] public static extern void switch_caller_profile_soft_set(HandleRef jarg1, HandleRef jarg2); @@ -11479,6 +11854,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_user_data_get")] public static extern IntPtr switch_frame_user_data_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_pmap_set")] + public static extern void switch_frame_pmap_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_frame_pmap_get")] + public static extern IntPtr switch_frame_pmap_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_frame")] public static extern IntPtr new_switch_frame(); @@ -12116,10 +12497,10 @@ class freeswitchPINVOKE { public static extern uint switch_file_handle_native_rate_get(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_channels_set")] - public static extern void switch_file_handle_channels_set(HandleRef jarg1, byte jarg2); + public static extern void switch_file_handle_channels_set(HandleRef jarg1, uint jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_channels_get")] - public static extern byte switch_file_handle_channels_get(HandleRef jarg1); + public static extern uint switch_file_handle_channels_get(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_format_set")] public static extern void switch_file_handle_format_set(HandleRef jarg1, uint jarg2); @@ -12325,6 +12706,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle__params_get")] public static extern IntPtr switch_file_handle__params_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_channels_set")] + public static extern void switch_file_handle_cur_channels_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_channels_get")] + public static extern uint switch_file_handle_cur_channels_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_samplerate_set")] + public static extern void switch_file_handle_cur_samplerate_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_cur_samplerate_get")] + public static extern uint switch_file_handle_cur_samplerate_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_file_handle")] public static extern IntPtr new_switch_file_handle(); @@ -13615,6 +14008,66 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_api_interface")] public static extern void delete_switch_api_interface(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_interface_name_set")] + public static extern void switch_json_api_interface_interface_name_set(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_interface_name_get")] + public static extern string switch_json_api_interface_interface_name_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_desc_set")] + public static extern void switch_json_api_interface_desc_set(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_desc_get")] + public static extern string switch_json_api_interface_desc_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_function_set")] + public static extern void switch_json_api_interface_function_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_function_get")] + public static extern IntPtr switch_json_api_interface_function_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_syntax_set")] + public static extern void switch_json_api_interface_syntax_set(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_syntax_get")] + public static extern string switch_json_api_interface_syntax_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_rwlock_set")] + public static extern void switch_json_api_interface_rwlock_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_rwlock_get")] + public static extern IntPtr switch_json_api_interface_rwlock_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_refs_set")] + public static extern void switch_json_api_interface_refs_set(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_refs_get")] + public static extern int switch_json_api_interface_refs_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_reflock_set")] + public static extern void switch_json_api_interface_reflock_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_reflock_get")] + public static extern IntPtr switch_json_api_interface_reflock_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_parent_set")] + public static extern void switch_json_api_interface_parent_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_parent_get")] + public static extern IntPtr switch_json_api_interface_parent_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_next_set")] + public static extern void switch_json_api_interface_next_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_api_interface_next_get")] + public static extern IntPtr switch_json_api_interface_next_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_new_switch_json_api_interface")] + public static extern IntPtr new_switch_json_api_interface(); + + [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_json_api_interface")] + public static extern void delete_switch_json_api_interface(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_slin_data_session_set")] public static extern void switch_slin_data_session_set(HandleRef jarg1, HandleRef jarg2); @@ -14071,6 +14524,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_direction")] public static extern int switch_channel_direction(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_logical_direction")] + public static extern int switch_channel_logical_direction(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_set_direction")] + public static extern void switch_channel_set_direction(HandleRef jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_channel_get_session")] public static extern IntPtr switch_channel_get_session(HandleRef jarg1); @@ -14485,6 +14944,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_event_serialize_json")] public static extern int switch_event_serialize_json(HandleRef jarg1, ref string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_serialize_json_obj")] + public static extern int switch_event_serialize_json_obj(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_create_json")] public static extern int switch_event_create_json(HandleRef jarg1, string jarg2); @@ -14521,9 +14983,87 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_event_add_presence_data_cols")] public static extern void switch_event_add_presence_data_cols(HandleRef jarg1, HandleRef jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_json_add_presence_data_cols")] + public static extern void switch_json_add_presence_data_cols(HandleRef jarg1, HandleRef jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_launch_dispatch_threads")] public static extern void switch_event_launch_dispatch_threads(uint jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_broadcast")] + public static extern uint switch_event_channel_broadcast(string jarg1, HandleRef jarg2, string jarg3, uint jarg4); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_unbind")] + public static extern uint switch_event_channel_unbind(string jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_bind")] + public static extern int switch_event_channel_bind(string jarg1, HandleRef jarg2, HandleRef jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_NO_EVENT_CHANNEL_ID_get")] + public static extern int NO_EVENT_CHANNEL_ID_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_EVENT_CHANNEL_GLOBAL_get")] + public static extern string SWITCH_EVENT_CHANNEL_GLOBAL_get(); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_clear")] + public static extern int switch_live_array_clear(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_bootstrap")] + public static extern int switch_live_array_bootstrap(HandleRef jarg1, string jarg2, uint jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_destroy")] + public static extern int switch_live_array_destroy(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_create")] + public static extern int switch_live_array_create(string jarg1, string jarg2, uint jarg3, HandleRef jarg4); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_get")] + public static extern IntPtr switch_live_array_get(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_get_idx")] + public static extern IntPtr switch_live_array_get_idx(HandleRef jarg1, int jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_del")] + public static extern int switch_live_array_del(HandleRef jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_add")] + public static extern int switch_live_array_add(HandleRef jarg1, string jarg2, int jarg3, HandleRef jarg4, int jarg5); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_visible")] + public static extern int switch_live_array_visible(HandleRef jarg1, int jarg2, int jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_isnew")] + public static extern int switch_live_array_isnew(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_lock")] + public static extern void switch_live_array_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_unlock")] + public static extern void switch_live_array_unlock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_set_user_data")] + public static extern void switch_live_array_set_user_data(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_set_command_handler")] + public static extern void switch_live_array_set_command_handler(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_parse_json")] + public static extern void switch_live_array_parse_json(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_add_alias")] + public static extern int switch_live_array_add_alias(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_live_array_clear_alias")] + public static extern int switch_live_array_clear_alias(HandleRef jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_verify")] + public static extern int switch_event_channel_permission_verify(string jarg1, string jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_modify")] + public static extern void switch_event_channel_permission_modify(string jarg1, string jarg2, int jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_event_channel_permission_clear")] + public static extern void switch_event_channel_permission_clear(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RESAMPLE_QUALITY_get")] public static extern int SWITCH_RESAMPLE_QUALITY_get(); @@ -15511,15 +16051,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_telephony_recv_event")] public static extern void switch_rtp_set_telephony_recv_event(HandleRef jarg1, byte jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_recv_pt")] - public static extern void switch_rtp_set_recv_pt(HandleRef jarg1, byte jarg2); - [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_cng_pt")] public static extern void switch_rtp_set_cng_pt(HandleRef jarg1, byte jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_get_private")] public static extern IntPtr switch_rtp_get_private(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_payload_map")] + public static extern int switch_rtp_set_payload_map(HandleRef jarg1, HandleRef jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_intentional_bugs")] public static extern void switch_rtp_intentional_bugs(HandleRef jarg1, int jarg2); @@ -15535,6 +16075,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_add_dtls")] public static extern int switch_rtp_add_dtls(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, int jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_del_dtls")] + public static extern int switch_rtp_del_dtls(HandleRef jarg1, int jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_has_dtls")] public static extern int switch_rtp_has_dtls(); @@ -16264,6 +16807,12 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_cmd_id_get")] public static extern uint switch_scheduler_task_cmd_id_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_repeat_set")] + public static extern void switch_scheduler_task_repeat_set(HandleRef jarg1, uint jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_repeat_get")] + public static extern uint switch_scheduler_task_repeat_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_scheduler_task_group_set")] public static extern void switch_scheduler_task_group_set(HandleRef jarg1, string jarg2); @@ -16403,7 +16952,7 @@ class freeswitchPINVOKE { public static extern void IvrMenu_Execute(HandleRef jarg1, HandleRef jarg2, string jarg3); [DllImport("mod_managed", EntryPoint="CSharp_new_Api")] - public static extern IntPtr new_Api(); + public static extern IntPtr new_Api(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_delete_Api")] public static extern void delete_Api(HandleRef jarg1); @@ -17624,6 +18173,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_cJSON { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_cJSON(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_cJSON() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_cJSON obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_FILE { private HandleRef swigCPtr; @@ -17744,6 +18323,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_q_const__char_p_cJSON_p_q_const__char_unsigned_long__void obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_p_switch_console_callback_match__switch_status_t { private HandleRef swigCPtr; @@ -17954,6 +18563,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_f_p_q_const__switch_log_node_t_enum_switch_log_level_t__switch_status_t { private HandleRef swigCPtr; @@ -19634,6 +20273,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_live_array_s_p_q_const__char_p_q_const__char_p_cJSON_p_void__void obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_f_p_switch_media_bug_p_void_enum_switch_abc_type_t__switch_bool_t { private HandleRef swigCPtr; @@ -20444,6 +21113,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_payload_map_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_payload_map_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_payload_map_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_payload_map_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_pid_t { private HandleRef swigCPtr; @@ -20564,6 +21263,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_p_payload_map_t { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_payload_map_t(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_payload_map_t() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_p_payload_map_t obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_p_p_char { private HandleRef swigCPtr; @@ -21344,6 +22073,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_p_switch_live_array_s { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_switch_live_array_s(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_switch_live_array_s() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_live_array_s obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_p_switch_log_node_t { private HandleRef swigCPtr; @@ -22394,6 +23153,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_switch_live_array_s { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_switch_live_array_s(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_switch_live_array_s() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_switch_live_array_s obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_switch_media_bug { private HandleRef swigCPtr; @@ -25573,6 +26362,16 @@ public class switch_caller_profile : IDisposable { } } + public switch_call_direction_t logical_direction { + set { + freeswitchPINVOKE.switch_caller_profile_logical_direction_set(swigCPtr, (int)value); + } + get { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_caller_profile_logical_direction_get(swigCPtr); + return ret; + } + } + public profile_node_t soft { set { freeswitchPINVOKE.switch_caller_profile_soft_set(swigCPtr, profile_node_t.getCPtr(value)); @@ -25773,6 +26572,7 @@ public enum switch_channel_callstate_t { CCS_EARLY, CCS_ACTIVE, CCS_HELD, + CCS_RING_WAIT, CCS_HANGUP, CCS_UNHOLD } @@ -25892,6 +26692,7 @@ public enum switch_channel_flag_t { CF_CONFIRM_BLIND_TRANSFER, CF_NO_PRESENCE, CF_CONFERENCE, + CF_CONFERENCE_ADV, CF_RECOVERING, CF_RECOVERING_BRIDGE, CF_TRACKED, @@ -25923,6 +26724,8 @@ public enum switch_channel_flag_t { CF_VIDEO_PASSIVE, CF_NOVIDEO, CF_VIDEO_ECHO, + CF_SLA_INTERCEPT, + CF_VIDEO_BREAK, CF_FLAG_MAX } @@ -27868,6 +28671,10 @@ public enum switch_core_session_message_types_t { SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE, SWITCH_MESSAGE_INDICATE_STUN_ERROR, SWITCH_MESSAGE_INDICATE_MEDIA_RENEG, + SWITCH_MESSAGE_REFER_EVENT, + SWITCH_MESSAGE_ANSWER_EVENT, + SWITCH_MESSAGE_PROGRESS_EVENT, + SWITCH_MESSAGE_RING_EVENT, SWITCH_MESSAGE_INVALID } @@ -28201,6 +29008,16 @@ public class switch_device_node_t : IDisposable { } } + public switch_call_direction_t direction { + set { + freeswitchPINVOKE.switch_device_node_t_direction_set(swigCPtr, (int)value); + } + get { + switch_call_direction_t ret = (switch_call_direction_t)freeswitchPINVOKE.switch_device_node_t_direction_get(swigCPtr); + return ret; + } + } + public switch_device_record_t parent { set { freeswitchPINVOKE.switch_device_node_t_parent_set(swigCPtr, switch_device_record_t.getCPtr(value)); @@ -28313,6 +29130,17 @@ public class switch_device_record_t : IDisposable { } } + public switch_device_stats_t last_stats { + set { + freeswitchPINVOKE.switch_device_record_t_last_stats_set(swigCPtr, switch_device_stats_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_device_record_t_last_stats_get(swigCPtr); + switch_device_stats_t ret = (cPtr == IntPtr.Zero) ? null : new switch_device_stats_t(cPtr, false); + return ret; + } + } + public switch_device_state_t state { set { freeswitchPINVOKE.switch_device_record_t_state_set(swigCPtr, (int)value); @@ -28369,6 +29197,66 @@ public class switch_device_record_t : IDisposable { } } + public SWIGTYPE_p_switch_time_t ring_start { + set { + freeswitchPINVOKE.switch_device_record_t_ring_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_ring_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t ring_stop { + set { + freeswitchPINVOKE.switch_device_record_t_ring_stop_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_ring_stop_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t hold_start { + set { + freeswitchPINVOKE.switch_device_record_t_hold_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_hold_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t hold_stop { + set { + freeswitchPINVOKE.switch_device_record_t_hold_stop_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_hold_stop_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_time_t call_start { + set { + freeswitchPINVOKE.switch_device_record_t_call_start_set(swigCPtr, SWIGTYPE_p_switch_time_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_time_t ret = new SWIGTYPE_p_switch_time_t(freeswitchPINVOKE.switch_device_record_t_call_start_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + public switch_device_node_t uuid_list { set { freeswitchPINVOKE.switch_device_record_t_uuid_list_set(swigCPtr, switch_device_node_t.getCPtr(value)); @@ -28413,6 +29301,17 @@ public class switch_device_record_t : IDisposable { } } + public SWIGTYPE_p_void user_data { + set { + freeswitchPINVOKE.switch_device_record_t_user_data_set(swigCPtr, SWIGTYPE_p_void.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_device_record_t_user_data_get(swigCPtr); + SWIGTYPE_p_void ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_void(cPtr, false); + return ret; + } + } + public switch_device_record_t() : this(freeswitchPINVOKE.new_switch_device_record_t(), true) { } @@ -28492,6 +29391,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint total_in { + set { + freeswitchPINVOKE.switch_device_stats_t_total_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_total_in_get(swigCPtr); + return ret; + } + } + + public uint total_out { + set { + freeswitchPINVOKE.switch_device_stats_t_total_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_total_out_get(swigCPtr); + return ret; + } + } + public uint offhook { set { freeswitchPINVOKE.switch_device_stats_t_offhook_set(swigCPtr, value); @@ -28502,6 +29421,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint offhook_in { + set { + freeswitchPINVOKE.switch_device_stats_t_offhook_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_offhook_in_get(swigCPtr); + return ret; + } + } + + public uint offhook_out { + set { + freeswitchPINVOKE.switch_device_stats_t_offhook_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_offhook_out_get(swigCPtr); + return ret; + } + } + public uint active { set { freeswitchPINVOKE.switch_device_stats_t_active_set(swigCPtr, value); @@ -28512,6 +29451,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint active_in { + set { + freeswitchPINVOKE.switch_device_stats_t_active_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_active_in_get(swigCPtr); + return ret; + } + } + + public uint active_out { + set { + freeswitchPINVOKE.switch_device_stats_t_active_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_active_out_get(swigCPtr); + return ret; + } + } + public uint held { set { freeswitchPINVOKE.switch_device_stats_t_held_set(swigCPtr, value); @@ -28522,6 +29481,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint held_in { + set { + freeswitchPINVOKE.switch_device_stats_t_held_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_held_in_get(swigCPtr); + return ret; + } + } + + public uint held_out { + set { + freeswitchPINVOKE.switch_device_stats_t_held_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_held_out_get(swigCPtr); + return ret; + } + } + public uint hup { set { freeswitchPINVOKE.switch_device_stats_t_hup_set(swigCPtr, value); @@ -28532,6 +29511,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint hup_in { + set { + freeswitchPINVOKE.switch_device_stats_t_hup_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_hup_in_get(swigCPtr); + return ret; + } + } + + public uint hup_out { + set { + freeswitchPINVOKE.switch_device_stats_t_hup_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_hup_out_get(swigCPtr); + return ret; + } + } + public uint ringing { set { freeswitchPINVOKE.switch_device_stats_t_ringing_set(swigCPtr, value); @@ -28542,6 +29541,26 @@ public class switch_device_stats_t : IDisposable { } } + public uint ringing_in { + set { + freeswitchPINVOKE.switch_device_stats_t_ringing_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ringing_in_get(swigCPtr); + return ret; + } + } + + public uint ringing_out { + set { + freeswitchPINVOKE.switch_device_stats_t_ringing_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ringing_out_get(swigCPtr); + return ret; + } + } + public uint early { set { freeswitchPINVOKE.switch_device_stats_t_early_set(swigCPtr, value); @@ -28552,6 +29571,36 @@ public class switch_device_stats_t : IDisposable { } } + public uint early_in { + set { + freeswitchPINVOKE.switch_device_stats_t_early_in_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_early_in_get(swigCPtr); + return ret; + } + } + + public uint early_out { + set { + freeswitchPINVOKE.switch_device_stats_t_early_out_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_early_out_get(swigCPtr); + return ret; + } + } + + public uint ring_wait { + set { + freeswitchPINVOKE.switch_device_stats_t_ring_wait_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_device_stats_t_ring_wait_get(swigCPtr); + return ret; + } + } + public switch_device_stats_t() : this(freeswitchPINVOKE.new_switch_device_stats_t(), true) { } @@ -29842,6 +30891,8 @@ public enum switch_event_types_t { SWITCH_EVENT_RE_SCHEDULE, SWITCH_EVENT_RELOADXML, SWITCH_EVENT_NOTIFY, + SWITCH_EVENT_PHONE_FEATURE, + SWITCH_EVENT_PHONE_FEATURE_SUBSCRIBE, SWITCH_EVENT_SEND_MESSAGE, SWITCH_EVENT_RECV_MESSAGE, SWITCH_EVENT_REQUEST_PARAMS, @@ -29962,7 +31013,8 @@ namespace FreeSWITCH.Native { SWITCH_FILE_BUFFER_DONE = (1 << 14), SWITCH_FILE_WRITE_APPEND = (1 << 15), SWITCH_FILE_WRITE_OVER = (1 << 16), - SWITCH_FILE_NOMUX = (1 << 17) + SWITCH_FILE_NOMUX = (1 << 17), + SWITCH_FILE_BREAK_ON_CHANGE = (1 << 18) } } @@ -30071,12 +31123,12 @@ public class switch_file_handle : IDisposable { } } - public byte channels { + public uint channels { set { freeswitchPINVOKE.switch_file_handle_channels_set(swigCPtr, value); } get { - byte ret = freeswitchPINVOKE.switch_file_handle_channels_get(swigCPtr); + uint ret = freeswitchPINVOKE.switch_file_handle_channels_get(swigCPtr); return ret; } } @@ -30441,6 +31493,26 @@ public class switch_file_handle : IDisposable { } } + public uint cur_channels { + set { + freeswitchPINVOKE.switch_file_handle_cur_channels_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_file_handle_cur_channels_get(swigCPtr); + return ret; + } + } + + public uint cur_samplerate { + set { + freeswitchPINVOKE.switch_file_handle_cur_samplerate_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_file_handle_cur_samplerate_get(swigCPtr); + return ret; + } + } + public switch_file_handle() : this(freeswitchPINVOKE.new_switch_file_handle(), true) { } @@ -30899,6 +31971,17 @@ public class switch_frame : IDisposable { } } + public SWIGTYPE_p_payload_map_t pmap { + set { + freeswitchPINVOKE.switch_frame_pmap_set(swigCPtr, SWIGTYPE_p_payload_map_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_frame_pmap_get(swigCPtr); + SWIGTYPE_p_payload_map_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_payload_map_t(cPtr, false); + return ret; + } + } + public switch_frame() : this(freeswitchPINVOKE.new_switch_frame(), true) { } @@ -32618,6 +33701,150 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class switch_json_api_interface : IDisposable { + private HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal switch_json_api_interface(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr(switch_json_api_interface obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } + + ~switch_json_api_interface() { + Dispose(); + } + + public virtual void Dispose() { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + freeswitchPINVOKE.delete_switch_json_api_interface(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + } + } + + public string interface_name { + set { + freeswitchPINVOKE.switch_json_api_interface_interface_name_set(swigCPtr, value); + } + get { + string ret = freeswitchPINVOKE.switch_json_api_interface_interface_name_get(swigCPtr); + return ret; + } + } + + public string desc { + set { + freeswitchPINVOKE.switch_json_api_interface_desc_set(swigCPtr, value); + } + get { + string ret = freeswitchPINVOKE.switch_json_api_interface_desc_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t function { + set { + freeswitchPINVOKE.switch_json_api_interface_function_set(swigCPtr, SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_function_get(swigCPtr); + SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_q_const__cJSON_p_switch_core_session_p_p_cJSON__switch_status_t(cPtr, false); + return ret; + } + } + + public string syntax { + set { + freeswitchPINVOKE.switch_json_api_interface_syntax_set(swigCPtr, value); + } + get { + string ret = freeswitchPINVOKE.switch_json_api_interface_syntax_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_switch_thread_rwlock_t rwlock { + set { + freeswitchPINVOKE.switch_json_api_interface_rwlock_set(swigCPtr, SWIGTYPE_p_switch_thread_rwlock_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_rwlock_get(swigCPtr); + SWIGTYPE_p_switch_thread_rwlock_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_thread_rwlock_t(cPtr, false); + return ret; + } + } + + public int refs { + set { + freeswitchPINVOKE.switch_json_api_interface_refs_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_json_api_interface_refs_get(swigCPtr); + return ret; + } + } + + public SWIGTYPE_p_switch_mutex_t reflock { + set { + freeswitchPINVOKE.switch_json_api_interface_reflock_set(swigCPtr, SWIGTYPE_p_switch_mutex_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_reflock_get(swigCPtr); + SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false); + return ret; + } + } + + public switch_loadable_module_interface parent { + set { + freeswitchPINVOKE.switch_json_api_interface_parent_set(swigCPtr, switch_loadable_module_interface.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_parent_get(swigCPtr); + switch_loadable_module_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_loadable_module_interface(cPtr, false); + return ret; + } + } + + public switch_json_api_interface next { + set { + freeswitchPINVOKE.switch_json_api_interface_next_set(swigCPtr, switch_json_api_interface.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_json_api_interface_next_get(swigCPtr); + switch_json_api_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_json_api_interface(cPtr, false); + return ret; + } + } + + public switch_json_api_interface() : this(freeswitchPINVOKE.new_switch_json_api_interface(), true) { + } + +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class switch_limit_interface : IDisposable { private HandleRef swigCPtr; protected bool swigCMemOwn; @@ -33016,6 +34243,17 @@ public class switch_loadable_module_interface : IDisposable { } } + public switch_json_api_interface json_api_interface { + set { + freeswitchPINVOKE.switch_loadable_module_interface_json_api_interface_set(swigCPtr, switch_json_api_interface.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_interface_json_api_interface_get(swigCPtr); + switch_json_api_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_json_api_interface(cPtr, false); + return ret; + } + } + public switch_file_interface file_interface { set { freeswitchPINVOKE.switch_loadable_module_interface_file_interface_set(swigCPtr, switch_file_interface.getCPtr(value)); @@ -33581,7 +34819,8 @@ public enum switch_module_interface_name_t { SWITCH_ASR_INTERFACE, SWITCH_MANAGEMENT_INTERFACE, SWITCH_LIMIT_INTERFACE, - SWITCH_CHAT_APPLICATION_INTERFACE + SWITCH_CHAT_APPLICATION_INTERFACE, + SWITCH_JSON_API_INTERFACE } } @@ -33599,9 +34838,11 @@ namespace FreeSWITCH.Native { SOF_NONE = 0, SOF_NOBLOCK = (1 << 0), SOF_FORKED_DIAL = (1 << 1), - SOF_NO_EFFECTIVE_CID_NUM = (1 << 2), - SOF_NO_EFFECTIVE_CID_NAME = (1 << 3), - SOF_NO_LIMITS = (1 << 4) + SOF_NO_EFFECTIVE_ANI = (1 << 2), + SOF_NO_EFFECTIVE_ANIII = (1 << 3), + SOF_NO_EFFECTIVE_CID_NUM = (1 << 4), + SOF_NO_EFFECTIVE_CID_NAME = (1 << 5), + SOF_NO_LIMITS = (1 << 6) } } @@ -33649,6 +34890,22 @@ public enum switch_priority_t { namespace FreeSWITCH.Native { +public enum switch_pvt_class_t { + SWITCH_PVT_PRIMARY = 0, + SWITCH_PVT_SECONDARY +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + public enum switch_ring_ready_t { SWITCH_RING_READY_NONE, SWITCH_RING_READY_RINGING, @@ -33856,7 +35113,8 @@ public enum switch_rtp_bug_flag_t { RTP_BUG_ACCEPT_ANY_PACKETS = (1 << 7), RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8), RTP_BUG_CHANGE_SSRC_ON_MARKER = (1 << 9), - RTP_BUG_FLUSH_JB_ON_DTMF = (1 << 10) + RTP_BUG_FLUSH_JB_ON_DTMF = (1 << 10), + RTP_BUG_ACCEPT_ANY_PAYLOAD = (1 << 11) } } @@ -34044,6 +35302,9 @@ public enum switch_rtp_flag_t { SWITCH_RTP_FLAG_VIDEO, SWITCH_RTP_FLAG_ENABLE_RTCP, SWITCH_RTP_FLAG_RTCP_MUX, + SWITCH_RTP_FLAG_KILL_JB, + SWITCH_RTP_FLAG_VIDEO_BREAK, + SWITCH_RTP_FLAG_PAUSE, SWITCH_RTP_FLAG_INVALID } @@ -34930,6 +36191,16 @@ public class switch_scheduler_task : IDisposable { } } + public uint repeat { + set { + freeswitchPINVOKE.switch_scheduler_task_repeat_set(swigCPtr, value); + } + get { + uint ret = freeswitchPINVOKE.switch_scheduler_task_repeat_get(swigCPtr); + return ret; + } + } + public string group { set { freeswitchPINVOKE.switch_scheduler_task_group_set(swigCPtr, value); @@ -36056,7 +37327,9 @@ public enum switch_status_t { SWITCH_STATUS_FOUND, SWITCH_STATUS_CONTINUE, SWITCH_STATUS_TERM, - SWITCH_STATUS_NOT_INITALIZED + SWITCH_STATUS_NOT_INITALIZED, + SWITCH_STATUS_XBREAK = 35, + SWITCH_STATUS_WINBREAK = 730035 } } @@ -36505,6 +37778,17 @@ public class switch_thread_data_t : IDisposable { } } + public SWIGTYPE_p_apr_pool_t pool { + set { + freeswitchPINVOKE.switch_thread_data_t_pool_set(swigCPtr, SWIGTYPE_p_apr_pool_t.getCPtr(value)); + } + get { + IntPtr cPtr = freeswitchPINVOKE.switch_thread_data_t_pool_get(swigCPtr); + SWIGTYPE_p_apr_pool_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_apr_pool_t(cPtr, false); + return ret; + } + } + public switch_thread_data_t() : this(freeswitchPINVOKE.new_switch_thread_data_t(), true) { } @@ -37377,7 +38661,7 @@ namespace FreeSWITCH.Native { SWITCH_XML_SECTION_CONFIG = (1 << 0), SWITCH_XML_SECTION_DIRECTORY = (1 << 1), SWITCH_XML_SECTION_DIALPLAN = (1 << 2), - SWITCH_XML_SECTION_PHRASES = (1 << 3), + SWITCH_XML_SECTION_LANGUAGES = (1 << 3), SWITCH_XML_SECTION_CHATPLAN = (1 << 4), SWITCH_XML_SECTION_MAX = (1 << 4) } diff --git a/src/switch_core_io.c b/src/switch_core_io.c index b1b42c7f1f..1a5a0469fe 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -644,8 +644,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi default: switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec %s decoder error! [%d]\n", session->read_codec->codec_interface->interface_name, status); - goto done; + + if (++session->decoder_errors < 10) { + status = SWITCH_STATUS_SUCCESS; + } else { + goto done; + } } + + session->decoder_errors = 0; } if (session->bugs) { diff --git a/src/switch_core_media.c b/src/switch_core_media.c index d18b648546..bbef0b79bd 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -68,36 +68,7 @@ typedef struct secure_settings_s { char *remote_crypto_key; } switch_secure_settings_t; -typedef struct codec_params_s { - char *rm_encoding; - char *iananame; - switch_payload_t pt; - unsigned long rm_rate; - unsigned long adv_rm_rate; - uint32_t codec_ms; - uint32_t bitrate; - char *rm_fmtp; - - switch_payload_t agreed_pt; - switch_payload_t recv_pt; - char *fmtp_out; - - - char *remote_sdp_ip; - switch_port_t remote_sdp_port; - - char *local_sdp_ip; - switch_port_t local_sdp_port; - - char *adv_sdp_ip; - switch_port_t adv_sdp_port; - char *proxy_sdp_ip; - switch_port_t proxy_sdp_port; - int channels; - int adv_channels; - -} codec_params_t; struct media_helper { switch_core_session_t *session; @@ -106,6 +77,7 @@ struct media_helper { int up; }; + typedef struct switch_rtp_engine_s { switch_secure_settings_t ssec; switch_media_type_t type; @@ -130,12 +102,23 @@ typedef struct switch_rtp_engine_s { switch_port_t remote_rtcp_port; switch_rtp_bug_flag_t rtp_bugs; + + char *local_sdp_ip; + switch_port_t local_sdp_port; + char *adv_sdp_ip; + switch_port_t adv_sdp_port; + char *proxy_sdp_ip; + switch_port_t proxy_sdp_port; + + /** ZRTP **/ char *local_sdp_zrtp_hash; char *remote_sdp_zrtp_hash; + payload_map_t *cur_payload_map; + payload_map_t *payload_map; + payload_map_t *pmap_tail; - codec_params_t codec_params; uint32_t timestamp_send; char *cand_acl[SWITCH_MAX_CAND_ACL]; @@ -159,6 +142,8 @@ typedef struct switch_rtp_engine_s { switch_thread_t *media_thread; switch_mutex_t *read_mutex; + uint8_t reset_codec; + uint8_t codec_negotiated; } switch_rtp_engine_t; @@ -442,11 +427,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_co remote_host = switch_rtp_get_remote_host(a_engine->rtp_session); remote_port = switch_rtp_get_remote_port(a_engine->rtp_session); - a_engine->codec_params.remote_sdp_ip = switch_core_session_strdup(session, t38_options->remote_ip); - a_engine->codec_params.remote_sdp_port = t38_options->remote_port; + a_engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(session, t38_options->remote_ip); + a_engine->cur_payload_map->remote_sdp_port = t38_options->remote_port; - if (remote_host && remote_port && !strcmp(remote_host, a_engine->codec_params.remote_sdp_ip) && - remote_port == a_engine->codec_params.remote_sdp_port) { + if (remote_host && remote_port && !strcmp(remote_host, a_engine->cur_payload_map->remote_sdp_ip) && + remote_port == a_engine->cur_payload_map->remote_sdp_port) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params are unchanged for %s.\n", switch_channel_get_name(session->channel)); @@ -456,13 +441,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_co switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params changed for %s from %s:%d to %s:%d\n", switch_channel_get_name(session->channel), - remote_host, remote_port, a_engine->codec_params.remote_sdp_ip, a_engine->codec_params.remote_sdp_port); + remote_host, remote_port, a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port); - switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->codec_params.remote_sdp_port); - switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->codec_params.remote_sdp_ip); + switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->remote_sdp_port); + switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->cur_payload_map->remote_sdp_ip); switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); - if (switch_rtp_set_remote_address(a_engine->rtp_session, a_engine->codec_params.remote_sdp_ip, - a_engine->codec_params.remote_sdp_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { + if (switch_rtp_set_remote_address(a_engine->rtp_session, a_engine->cur_payload_map->remote_sdp_ip, + a_engine->cur_payload_map->remote_sdp_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err); switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); } @@ -475,6 +460,81 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_co } +SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session, + switch_media_type_t type, + const char *name, + switch_sdp_type_t sdp_type, + uint32_t pt, + uint32_t rate, + uint32_t ptime, + uint8_t negotiated) +{ + payload_map_t *pmap; + int exists = 0; + switch_media_handle_t *smh; + switch_rtp_engine_t *engine; + + switch_assert(session); + + if (!(smh = session->media_handle)) { + return NULL; + } + + engine = &smh->engines[type]; + + switch_mutex_lock(smh->mutex); + + + for (pmap = engine->payload_map; pmap && pmap->allocated; pmap = pmap->next) { + exists = (!strcasecmp(name, pmap->iananame) && rate == pmap->rate && pmap->ptime == ptime); + + if (exists) { + break; + } + } + + + if (!exists) { + if (engine->payload_map && !engine->payload_map->allocated) { + pmap = engine->payload_map; + } else { + pmap = switch_core_alloc(session->pool, sizeof(*pmap)); + } + + pmap->sdp_type = sdp_type; + pmap->type = type; + pmap->iananame = switch_core_strdup(session->pool, name); + pmap->rm_encoding = pmap->iananame; + pmap->ptime = ptime; + pmap->rate = rate; + } + + pmap->allocated = 1; + pmap->recv_pt = (switch_payload_t)pt; + + if (sdp_type == SDP_TYPE_REQUEST || !exists) { + pmap->pt = (switch_payload_t)pt; + } + + if (negotiated) { + pmap->negotiated = negotiated; + } + + if (!exists) { + if (pmap == engine->payload_map) { + engine->pmap_tail = pmap; + } else if (!engine->payload_map) { + engine->payload_map = engine->pmap_tail = pmap; + } else { + engine->pmap_tail->next = pmap; + engine->pmap_tail = engine->pmap_tail->next; + } + } + + switch_mutex_unlock(smh->mutex); + + return pmap; +} @@ -1058,8 +1118,6 @@ SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t { switch_status_t status = SWITCH_STATUS_FALSE; switch_media_handle_t *smh = NULL; - - *smhp = NULL; if (zstr(params->sdp_username)) { @@ -1069,6 +1127,8 @@ SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t if ((session->media_handle = switch_core_session_alloc(session, (sizeof(*smh))))) { session->media_handle->session = session; + + *smhp = session->media_handle; switch_set_flag(session->media_handle, SMF_INIT); session->media_handle->media_flags[SCMF_RUNNING] = 1; @@ -1079,6 +1139,7 @@ SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t session->media_handle->mparams = params; + switch_mutex_init(&session->media_handle->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO].ssrc = @@ -1087,6 +1148,12 @@ SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].ssrc = (uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO] + (uint32_t) time(NULL) / 2); + session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO].payload_map = switch_core_alloc(session->pool, sizeof(payload_map_t)); + session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO].cur_payload_map = session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO].payload_map; + session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].payload_map = switch_core_alloc(session->pool, sizeof(payload_map_t)); + session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].cur_payload_map = session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].payload_map; + + switch_channel_set_flag(session->channel, CF_DTLS_OK); status = SWITCH_STATUS_SUCCESS; @@ -1242,6 +1309,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session switch_rtp_engine_t *engine; switch_status_t status; switch_media_handle_t *smh; + int do_cng = 0; switch_assert(session); @@ -1299,6 +1367,85 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session goto end; } + /* re-set codec if necessary */ + if (engine->reset_codec > 0) { + const char *val; + int rtp_timeout_sec = 0; + int rtp_hold_timeout_sec = 0; + + engine->reset_codec = 0; + + if (switch_rtp_ready(engine->rtp_session)) { + if (switch_core_media_set_codec(session, 1, 0) != SWITCH_STATUS_SUCCESS) { + *frame = NULL; + switch_goto_status(SWITCH_STATUS_GENERR, end); + } + + if ((val = switch_channel_get_variable(session->channel, "rtp_timeout_sec"))) { + int v = atoi(val); + if (v >= 0) { + rtp_timeout_sec = v; + } + } + + if ((val = switch_channel_get_variable(session->channel, "rtp_hold_timeout_sec"))) { + int v = atoi(val); + if (v >= 0) { + rtp_hold_timeout_sec = v; + } + } + + if (rtp_timeout_sec) { + engine->max_missed_packets = (engine->read_impl.samples_per_second * rtp_timeout_sec) / + engine->read_impl.samples_per_packet; + + switch_rtp_set_max_missed_packets(engine->rtp_session, engine->max_missed_packets); + if (!rtp_hold_timeout_sec) { + rtp_hold_timeout_sec = rtp_timeout_sec * 10; + } + } + + if (rtp_hold_timeout_sec) { + engine->max_missed_hold_packets = (engine->read_impl.samples_per_second * rtp_hold_timeout_sec) / + engine->read_impl.samples_per_packet; + } + } + + + if (session->read_resampler) { + switch_mutex_lock(session->resample_mutex); + switch_resample_destroy(&session->read_resampler); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Deactivating read resampler\n"); + switch_mutex_unlock(session->resample_mutex); + } + + if (session->write_resampler) { + switch_mutex_lock(session->resample_mutex); + switch_resample_destroy(&session->write_resampler); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Deactivating write resampler\n"); + switch_mutex_unlock(session->resample_mutex); + } + + switch_core_session_reset(session, 0, 0); + + + engine->check_frames = 0; + engine->last_ts = 0; + + switch_channel_audio_sync(session->channel); + do_cng = 1; + } + + if (do_cng) { + /* return CNG for now */ + *frame = &engine->read_frame; + switch_set_flag((*frame), SFF_CNG); + (*frame)->datalen = engine->read_impl.encoded_bytes_per_packet; + memset((*frame)->data, 0, (*frame)->datalen); + switch_goto_status(SWITCH_STATUS_SUCCESS, end); + } + + /* Try to read an RTCP frame, if successful raise an event */ if (switch_rtcp_zerocopy_read_frame(engine->rtp_session, &rtcp_frame) == SWITCH_STATUS_SUCCESS) { switch_event_t *event; @@ -1381,22 +1528,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session switch_rtp_dequeue_dtmf(engine->rtp_session, &dtmf); switch_channel_queue_dtmf(session->channel, &dtmf); } - + if (engine->read_frame.datalen > 0) { uint32_t bytes = 0; int frames = 1; + /* autofix timing */ if (!switch_test_flag((&engine->read_frame), SFF_CNG)) { if (!engine->read_codec.implementation || !switch_core_codec_ready(&engine->read_codec)) { *frame = NULL; switch_goto_status(SWITCH_STATUS_GENERR, end); } + + /* check for timing issues */ + if (smh->media_flags[SCMF_AUTOFIX_TIMING] && engine->check_frames < MAX_CODEC_CHECK_FRAMES) { - /* check for timing or codec issues */ - if ((smh->media_flags[SCMF_AUTOFIX_TIMING] || smh->media_flags[SCMF_AUTOFIX_PT]) && - engine->check_frames < MAX_CODEC_CHECK_FRAMES) { - - int reset_codec = 0; engine->check_frames++; @@ -1404,62 +1550,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session engine->check_frames = MAX_CODEC_CHECK_FRAMES; goto skip; } - - /* autofix payload type */ - if (smh->media_flags[SCMF_AUTOFIX_PT] && - engine->read_frame.payload != smh->mparams->cng_pt && - engine->read_frame.payload != smh->mparams->recv_te && - engine->read_frame.payload != smh->mparams->te && - engine->read_frame.payload != engine->codec_params.recv_pt && - engine->read_frame.payload != engine->codec_params.agreed_pt && - engine->read_frame.payload != engine->codec_params.pt) { - - int i = 0; - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "Invalid payload received (received %d, expecting %d). " - "FS doesn't support multiple payload types in a single RTP session.\n", - (int) engine->read_frame.payload, (int) engine->codec_params.agreed_pt); - - /* search for payload type */ - for (i = 0; i < smh->mparams->num_codecs; i++) { - if (engine->read_frame.payload == smh->ianacodes[i]) { - const switch_codec_implementation_t *imp = smh->codecs[i]; - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "Changing current codec to %s (payload type %d).\n", - imp->iananame, (int) engine->read_frame.payload); - - engine->codec_params.iananame = switch_core_session_strdup(smh->session, imp->iananame); - engine->codec_params.pt = imp->ianacode; - engine->codec_params.agreed_pt = imp->ianacode; - engine->codec_params.recv_pt = imp->ianacode; - engine->codec_params.rm_encoding = switch_core_session_strdup(smh->session, imp->iananame); - engine->codec_params.rm_fmtp = NULL; - engine->codec_params.rm_rate = imp->samples_per_second; - engine->codec_params.adv_rm_rate = imp->samples_per_second; - if (strcasecmp(imp->iananame, "g722")) { - engine->codec_params.rm_rate = imp->actual_samples_per_second; - } - engine->codec_params.codec_ms = imp->microseconds_per_packet / 1000; - engine->codec_params.bitrate = imp->bits_per_second; - engine->codec_params.channels = 1; - - /* mark to re-set codec */ - reset_codec = 1; - break; - } - } - - if (!reset_codec) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "Could not change to payload type %d, ignoring...\n", - (int) engine->read_frame.payload); - } - - /* autofix timing */ - } else if (smh->media_flags[SCMF_AUTOFIX_TIMING] && (engine->read_frame.datalen % 10) == 0) { - + + if (smh->media_flags[SCMF_AUTOFIX_TIMING] && (engine->read_frame.datalen % 10) == 0) { + if (engine->last_ts && engine->read_frame.datalen != engine->read_impl.encoded_bytes_per_packet) { uint32_t codec_ms = (int) (engine->read_frame.timestamp - @@ -1478,7 +1571,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session engine->last_codec_ms = codec_ms; if (engine->mismatch_count > MAX_MISMATCH_FRAMES) { - if (codec_ms != engine->codec_params.codec_ms) { + if (codec_ms != engine->cur_payload_map->codec_ms) { if (codec_ms > 120) { /* yeah right */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, @@ -1491,20 +1584,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session engine->read_frame.datalen = 0; - if (codec_ms != engine->codec_params.codec_ms) { + if (codec_ms != engine->cur_payload_map->codec_ms) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Asynchronous PTIME not supported, changing our end from %d to %d\n", - (int) engine->codec_params.codec_ms, + (int) engine->cur_payload_map->codec_ms, (int) codec_ms ); switch_channel_set_variable_printf(session->channel, "rtp_h_X-Broken-PTIME", "Adv=%d;Sent=%d", - (int) engine->codec_params.codec_ms, (int) codec_ms); + (int) engine->cur_payload_map->codec_ms, (int) codec_ms); - engine->codec_params.codec_ms = codec_ms; + engine->cur_payload_map->codec_ms = codec_ms; /* mark to re-set codec */ - reset_codec = 2; + engine->reset_codec = 2; } } } @@ -1520,58 +1613,48 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session engine->mismatch_count = 0; engine->last_ts = 0; } + } - /* re-set codec if necessary */ - if (reset_codec > 0) { - const char *val; - int rtp_timeout_sec = 0; - int rtp_hold_timeout_sec = 0; + /* autofix payload type */ - if (switch_rtp_ready(engine->rtp_session)) { - if (switch_core_media_set_codec(session, 2, 0) != SWITCH_STATUS_SUCCESS) { - *frame = NULL; - switch_goto_status(SWITCH_STATUS_GENERR, end); - } + if (!engine->reset_codec && + engine->codec_negotiated && + engine->read_frame.payload != smh->mparams->cng_pt && + engine->read_frame.payload != smh->mparams->recv_te && + engine->read_frame.payload != smh->mparams->te && + engine->read_frame.payload != engine->cur_payload_map->recv_pt && + engine->read_frame.payload != engine->cur_payload_map->agreed_pt && + engine->read_frame.payload != engine->cur_payload_map->pt) { + + payload_map_t *pmap; + - if ((val = switch_channel_get_variable(session->channel, "rtp_timeout_sec"))) { - int v = atoi(val); - if (v >= 0) { - rtp_timeout_sec = v; - } - } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + "alternate payload received (received %d, expecting %d)\n", + (int) engine->read_frame.payload, (int) engine->cur_payload_map->agreed_pt); - if ((val = switch_channel_get_variable(session->channel, "rtp_hold_timeout_sec"))) { - int v = atoi(val); - if (v >= 0) { - rtp_hold_timeout_sec = v; - } - } - if (rtp_timeout_sec) { - engine->max_missed_packets = (engine->read_impl.samples_per_second * rtp_timeout_sec) / - engine->read_impl.samples_per_packet; + /* search for payload type */ + switch_mutex_lock(smh->mutex); + for (pmap = engine->cur_payload_map; pmap; pmap = pmap->next) { + if (engine->read_frame.payload == pmap->recv_pt) { + engine->cur_payload_map = pmap; - switch_rtp_set_max_missed_packets(engine->rtp_session, engine->max_missed_packets); - if (!rtp_hold_timeout_sec) { - rtp_hold_timeout_sec = rtp_timeout_sec * 10; - } - } - - if (rtp_hold_timeout_sec) { - engine->max_missed_hold_packets = (engine->read_impl.samples_per_second * rtp_hold_timeout_sec) / - engine->read_impl.samples_per_packet; - } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, + "Changing current codec to %s (payload type %d).\n", + pmap->iananame, pmap->pt); + + /* mark to re-set codec */ + engine->reset_codec = 1; + break; } - - engine->check_frames = 0; - engine->last_ts = 0; - - /* return CNG for now */ - *frame = &engine->read_frame; - switch_set_flag((*frame), SFF_CNG); - (*frame)->datalen = engine->read_impl.encoded_bytes_per_packet; - memset((*frame)->data, 0, (*frame)->datalen); - switch_goto_status(SWITCH_STATUS_SUCCESS, end); + } + switch_mutex_unlock(smh->mutex); + + if (!engine->reset_codec) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, + "Could not change to payload type %d, ignoring...\n", + (int) engine->read_frame.payload); } } @@ -1626,7 +1709,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_sessio engine = &smh->engines[type]; - while (!(engine->read_codec.implementation && switch_rtp_ready(engine->rtp_session))) { if (switch_channel_ready(session->channel)) { switch_yield(10000); @@ -1736,7 +1818,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_se v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO]; - if (!v_engine->codec_params.rm_encoding) { + if (!v_engine->codec_negotiated) { return SWITCH_STATUS_FALSE; } @@ -1744,11 +1826,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_se if (!force) { return SWITCH_STATUS_SUCCESS; } - if (strcasecmp(v_engine->read_codec.implementation->iananame, v_engine->codec_params.rm_encoding) || - v_engine->read_codec.implementation->samples_per_second != v_engine->codec_params.rm_rate) { + if (strcasecmp(v_engine->read_codec.implementation->iananame, v_engine->cur_payload_map->rm_encoding) || + v_engine->read_codec.implementation->samples_per_second != v_engine->cur_payload_map->rm_rate) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Changing Codec from %s to %s\n", - v_engine->read_codec.implementation->iananame, v_engine->codec_params.rm_encoding); + v_engine->read_codec.implementation->iananame, v_engine->cur_payload_map->rm_encoding); switch_core_codec_destroy(&v_engine->read_codec); switch_core_codec_destroy(&v_engine->write_codec); } else { @@ -1761,9 +1843,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_se if (switch_core_codec_init(&v_engine->read_codec, - v_engine->codec_params.rm_encoding, - v_engine->codec_params.rm_fmtp, - v_engine->codec_params.rm_rate, + v_engine->cur_payload_map->rm_encoding, + v_engine->cur_payload_map->rm_fmtp, + v_engine->cur_payload_map->rm_rate, 0, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, @@ -1772,9 +1854,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_se return SWITCH_STATUS_FALSE; } else { if (switch_core_codec_init(&v_engine->write_codec, - v_engine->codec_params.rm_encoding, - v_engine->codec_params.rm_fmtp, - v_engine->codec_params.rm_rate, + v_engine->cur_payload_map->rm_encoding, + v_engine->cur_payload_map->rm_fmtp, + v_engine->cur_payload_map->rm_rate, 0, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, @@ -1782,22 +1864,22 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_se switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't load codec?\n"); return SWITCH_STATUS_FALSE; } else { - v_engine->read_frame.rate = v_engine->codec_params.rm_rate; + v_engine->read_frame.rate = v_engine->cur_payload_map->rm_rate; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set VIDEO Codec %s %s/%ld %d ms\n", - switch_channel_get_name(session->channel), v_engine->codec_params.rm_encoding, - v_engine->codec_params.rm_rate, v_engine->codec_params.codec_ms); + switch_channel_get_name(session->channel), v_engine->cur_payload_map->rm_encoding, + v_engine->cur_payload_map->rm_rate, v_engine->cur_payload_map->codec_ms); v_engine->read_frame.codec = &v_engine->read_codec; v_engine->write_codec.fmtp_out = switch_core_session_strdup(session, v_engine->write_codec.fmtp_out); - v_engine->write_codec.agreed_pt = v_engine->codec_params.agreed_pt; - v_engine->read_codec.agreed_pt = v_engine->codec_params.agreed_pt; + v_engine->write_codec.agreed_pt = v_engine->cur_payload_map->agreed_pt; + v_engine->read_codec.agreed_pt = v_engine->cur_payload_map->agreed_pt; switch_core_session_set_video_read_codec(session, &v_engine->read_codec); switch_core_session_set_video_write_codec(session, &v_engine->write_codec); switch_channel_set_variable_printf(session->channel, "rtp_last_video_codec_string", "%s@%dh", - v_engine->codec_params.rm_encoding, v_engine->codec_params.rm_rate); + v_engine->cur_payload_map->rm_encoding, v_engine->cur_payload_map->rm_rate); if (switch_rtp_ready(v_engine->rtp_session)) { @@ -1806,25 +1888,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_se msg.from = __FILE__; msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ; - switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->codec_params.agreed_pt); + switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt); - if (v_engine->codec_params.recv_pt != v_engine->codec_params.agreed_pt) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, - "%s Set video receive payload to %u\n", switch_channel_get_name(session->channel), v_engine->codec_params.recv_pt); - - switch_rtp_set_recv_pt(v_engine->rtp_session, v_engine->codec_params.recv_pt); - } else { - switch_rtp_set_recv_pt(v_engine->rtp_session, v_engine->codec_params.agreed_pt); - } + //XX switch_core_session_receive_message(session, &msg); } - switch_channel_set_variable(session->channel, "rtp_use_video_codec_name", v_engine->codec_params.rm_encoding); - switch_channel_set_variable(session->channel, "rtp_use_video_codec_fmtp", v_engine->codec_params.rm_fmtp); - switch_channel_set_variable_printf(session->channel, "rtp_use_video_codec_rate", "%d", v_engine->codec_params.rm_rate); + switch_channel_set_variable(session->channel, "rtp_use_video_codec_name", v_engine->cur_payload_map->rm_encoding); + switch_channel_set_variable(session->channel, "rtp_use_video_codec_fmtp", v_engine->cur_payload_map->rm_fmtp); + switch_channel_set_variable_printf(session->channel, "rtp_use_video_codec_rate", "%d", v_engine->cur_payload_map->rm_rate); switch_channel_set_variable_printf(session->channel, "rtp_use_video_codec_ptime", "%d", 0); } @@ -1848,7 +1923,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ } a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO]; - if (!a_engine->codec_params.iananame) { + if (!a_engine->cur_payload_map->iananame) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "No audio codec available\n"); switch_goto_status(SWITCH_STATUS_FALSE, end); } @@ -1857,9 +1932,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ if (!force) { switch_goto_status(SWITCH_STATUS_SUCCESS, end); } - if (strcasecmp(a_engine->read_impl.iananame, a_engine->codec_params.rm_encoding) || - (uint32_t) a_engine->read_impl.microseconds_per_packet / 1000 != a_engine->codec_params.codec_ms || - a_engine->read_impl.samples_per_second != a_engine->codec_params.rm_rate ) { + if (strcasecmp(a_engine->read_impl.iananame, a_engine->cur_payload_map->iananame) || + (uint32_t) a_engine->read_impl.microseconds_per_packet / 1000 != a_engine->cur_payload_map->codec_ms || + a_engine->read_impl.samples_per_second != a_engine->cur_payload_map->rm_rate ) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, @@ -1868,9 +1943,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ a_engine->read_impl.microseconds_per_packet / 1000, a_engine->read_impl.samples_per_second, - a_engine->codec_params.rm_encoding, - a_engine->codec_params.codec_ms, - a_engine->codec_params.rm_rate); + a_engine->cur_payload_map->iananame, + a_engine->cur_payload_map->codec_ms, + a_engine->cur_payload_map->rm_rate); switch_yield(a_engine->read_impl.microseconds_per_packet); switch_core_session_lock_codec_write(session); @@ -1887,12 +1962,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ } if (switch_core_codec_init_with_bitrate(&a_engine->read_codec, - a_engine->codec_params.iananame, - a_engine->codec_params.rm_fmtp, - a_engine->codec_params.rm_rate, - a_engine->codec_params.codec_ms, - a_engine->codec_params.channels, - a_engine->codec_params.bitrate, + a_engine->cur_payload_map->iananame, + a_engine->cur_payload_map->rm_fmtp, + a_engine->cur_payload_map->rm_rate, + a_engine->cur_payload_map->codec_ms, + a_engine->cur_payload_map->channels, + a_engine->cur_payload_map->bitrate, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | codec_flags, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't load codec?\n"); @@ -1904,12 +1979,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ if (switch_core_codec_init_with_bitrate(&a_engine->write_codec, - a_engine->codec_params.iananame, - a_engine->codec_params.rm_fmtp, - a_engine->codec_params.rm_rate, - a_engine->codec_params.codec_ms, - a_engine->codec_params.channels, - a_engine->codec_params.bitrate, + a_engine->cur_payload_map->iananame, + a_engine->cur_payload_map->rm_fmtp, + a_engine->cur_payload_map->rm_rate, + a_engine->cur_payload_map->codec_ms, + a_engine->cur_payload_map->channels, + a_engine->cur_payload_map->bitrate, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | codec_flags, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't load codec?\n"); @@ -1919,12 +1994,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ a_engine->write_codec.session = session; - switch_channel_set_variable(session->channel, "rtp_use_codec_name", a_engine->codec_params.iananame); - switch_channel_set_variable(session->channel, "rtp_use_codec_fmtp", a_engine->codec_params.rm_fmtp); - switch_channel_set_variable_printf(session->channel, "rtp_use_codec_rate", "%d", a_engine->codec_params.rm_rate); - switch_channel_set_variable_printf(session->channel, "rtp_use_codec_ptime", "%d", a_engine->codec_params.codec_ms); + switch_channel_set_variable(session->channel, "rtp_use_codec_name", a_engine->cur_payload_map->iananame); + switch_channel_set_variable(session->channel, "rtp_use_codec_fmtp", a_engine->cur_payload_map->rm_fmtp); + switch_channel_set_variable_printf(session->channel, "rtp_use_codec_rate", "%d", a_engine->cur_payload_map->rm_rate); + switch_channel_set_variable_printf(session->channel, "rtp_use_codec_ptime", "%d", a_engine->cur_payload_map->codec_ms); switch_channel_set_variable_printf(session->channel, "rtp_last_audio_codec_string", "%s@%dh@%di", - a_engine->codec_params.iananame, a_engine->codec_params.rm_rate, a_engine->codec_params.codec_ms); + a_engine->cur_payload_map->iananame, a_engine->cur_payload_map->rm_rate, a_engine->cur_payload_map->codec_ms); switch_assert(a_engine->read_codec.implementation); switch_assert(a_engine->write_codec.implementation); @@ -1946,7 +2021,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ } } - a_engine->read_frame.rate = a_engine->codec_params.rm_rate; + a_engine->read_frame.rate = a_engine->cur_payload_map->rm_rate; if (!switch_core_codec_ready(&a_engine->read_codec)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't load codec?\n"); @@ -1954,34 +2029,32 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms %d samples %d bits\n", - switch_channel_get_name(session->channel), a_engine->codec_params.iananame, a_engine->codec_params.rm_rate, - a_engine->codec_params.codec_ms, + switch_channel_get_name(session->channel), a_engine->cur_payload_map->iananame, a_engine->cur_payload_map->rm_rate, + a_engine->cur_payload_map->codec_ms, a_engine->read_impl.samples_per_packet, a_engine->read_impl.bits_per_second); a_engine->read_frame.codec = &a_engine->read_codec; - a_engine->write_codec.agreed_pt = a_engine->codec_params.agreed_pt; - a_engine->read_codec.agreed_pt = a_engine->codec_params.agreed_pt; + a_engine->write_codec.agreed_pt = a_engine->cur_payload_map->agreed_pt; + a_engine->read_codec.agreed_pt = a_engine->cur_payload_map->agreed_pt; if (force != 2) { switch_core_session_set_real_read_codec(session, &a_engine->read_codec); switch_core_session_set_write_codec(session, &a_engine->write_codec); } - a_engine->codec_params.fmtp_out = switch_core_session_strdup(session, a_engine->write_codec.fmtp_out); + a_engine->cur_payload_map->fmtp_out = switch_core_session_strdup(session, a_engine->write_codec.fmtp_out); if (switch_rtp_ready(a_engine->rtp_session)) { - switch_rtp_set_default_payload(a_engine->rtp_session, a_engine->codec_params.pt); - switch_rtp_set_recv_pt(a_engine->rtp_session, a_engine->read_codec.agreed_pt); + switch_rtp_set_default_payload(a_engine->rtp_session, a_engine->cur_payload_map->pt); } end: + if (resetting) { switch_core_session_unlock_codec_write(session); switch_core_session_unlock_codec_read(session); } - switch_core_media_set_video_codec(session, force); - return status; } @@ -2148,7 +2221,7 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_ #ifdef RTCP_MUX } else if (!strcasecmp(attr->a_name, "rtcp-mux")) { engine->rtcp_mux = SWITCH_TRUE; - engine->remote_rtcp_port = engine->codec_params.remote_sdp_port; + engine->remote_rtcp_port = engine->cur_payload_map->remote_sdp_port; got_rtcp_mux++; #endif } else if (!strcasecmp(attr->a_name, "candidate")) { @@ -2317,7 +2390,7 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_ if (engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr && engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port) { char tmp[80] = ""; - engine->codec_params.remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr); + engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE, "setting remote %s ice addr to %s:%d based on candidate\n", type2str(type), engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port); @@ -2326,14 +2399,14 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_ engine->remote_rtp_ice_port = (switch_port_t) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port; engine->remote_rtp_ice_addr = switch_core_session_strdup(smh->session, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr); - engine->codec_params.remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr); - engine->codec_params.remote_sdp_port = (switch_port_t) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port; + engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr); + engine->cur_payload_map->remote_sdp_port = (switch_port_t) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port; if (engine->remote_rtcp_port) { - engine->remote_rtcp_port = engine->codec_params.remote_sdp_port; + engine->remote_rtcp_port = engine->cur_payload_map->remote_sdp_port; } - switch_snprintf(tmp, sizeof(tmp), "%d", engine->codec_params.remote_sdp_port); - switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, engine->codec_params.remote_sdp_ip); + switch_snprintf(tmp, sizeof(tmp), "%d", engine->cur_payload_map->remote_sdp_port); + switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, engine->cur_payload_map->remote_sdp_ip); switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); } @@ -2461,6 +2534,41 @@ SWITCH_DECLARE(void) switch_core_session_set_ice(switch_core_session_t *session) smh->mparams->rtcp_video_interval_msec = "10000"; } +#define MAX_MATCHES 30 +struct matches { + const switch_codec_implementation_t *imp; + sdp_rtpmap_t *map; + int rate; + int codec_idx; +}; + +static void greedy_sort(switch_media_handle_t *smh, struct matches *matches, int m_idx, const switch_codec_implementation_t **codec_array, int total_codecs) +{ + int j = 0, f = 0, g; + struct matches mtmp[MAX_MATCHES] = { { 0 } }; + for(j = 0; j < m_idx; j++) { + *&mtmp[j] = *&matches[j]; + } + for (g = 0; g < smh->mparams->num_codecs && g < total_codecs; g++) { + const switch_codec_implementation_t *imp = codec_array[g]; + + for(j = 0; j < m_idx; j++) { + if (mtmp[j].imp == imp) { + *&matches[f++] = *&mtmp[j]; + } + } + } +} + +static void clear_pmaps(switch_rtp_engine_t *engine) +{ + payload_map_t *pmap; + + for (pmap = engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) { + pmap->negotiated = 0; + } +} + //? SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *session, const char *r_sdp, uint8_t *proceed, switch_sdp_type_t sdp_type) { @@ -2468,10 +2576,9 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s switch_payload_t best_te = 0, te = 0, cng_pt = 0; sdp_media_t *m; sdp_attribute_t *attr; - int first = 0, last = 0; int ptime = 0, dptime = 0, maxptime = 0, dmaxptime = 0; int sendonly = 0, recvonly = 0; - int greedy = 0, x = 0, skip = 0, mine = 0; + int greedy = 0, x = 0, skip = 0; switch_channel_t *channel = switch_core_session_get_channel(session); const char *val; const char *crypto = NULL; @@ -2487,8 +2594,13 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s uint32_t near_rate = 0; const switch_codec_implementation_t *mimp = NULL, *near_match = NULL; sdp_rtpmap_t *mmap = NULL, *near_map = NULL; + struct matches matches[MAX_MATCHES] = { { 0 } }; + struct matches near_matches[MAX_MATCHES] = { { 0 } }; int codec_ms = 0; + uint32_t remote_codec_rate = 0, fmtp_remote_codec_rate = 0; const char *tmp; + int m_idx = 0; + int nm_idx = 0; switch_assert(session); @@ -2516,6 +2628,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s switch_channel_clear_flag(smh->session->channel, CF_DTLS); } + clear_pmaps(a_engine); + clear_pmaps(v_engine); + + if (proceed) *proceed = 1; greedy = !!switch_media_handle_test_media_flag(smh, SCMF_CODEC_GREEDY); @@ -2655,6 +2771,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s check_ice(smh, SWITCH_MEDIA_TYPE_AUDIO, sdp, NULL); check_ice(smh, SWITCH_MEDIA_TYPE_VIDEO, sdp, NULL); + for (m = sdp->sdp_media; m; m = m->m_next) { sdp_connection_t *connection; switch_core_session_t *other_session; @@ -2750,10 +2867,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s switch_channel_set_variable(other_channel, "t38_broken_boolean", "true"); } - a_engine->codec_params.remote_sdp_ip = switch_core_session_strdup(session, t38_options->remote_ip); - a_engine->codec_params.remote_sdp_port = t38_options->remote_port; + a_engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(session, t38_options->remote_ip); + a_engine->cur_payload_map->remote_sdp_port = t38_options->remote_port; - if (remote_host && remote_port && !strcmp(remote_host, a_engine->codec_params.remote_sdp_ip) && remote_port == a_engine->codec_params.remote_sdp_port) { + if (remote_host && remote_port && !strcmp(remote_host, a_engine->cur_payload_map->remote_sdp_ip) && remote_port == a_engine->cur_payload_map->remote_sdp_port) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params are unchanged for %s.\n", switch_channel_get_name(session->channel)); } else { @@ -2761,14 +2878,14 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params changed for %s from %s:%d to %s:%d\n", switch_channel_get_name(session->channel), - remote_host, remote_port, a_engine->codec_params.remote_sdp_ip, a_engine->codec_params.remote_sdp_port); + remote_host, remote_port, a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port); - switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->codec_params.remote_sdp_port); - switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->codec_params.remote_sdp_ip); + switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->remote_sdp_port); + switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->cur_payload_map->remote_sdp_ip); switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); - if (switch_rtp_set_remote_address(a_engine->rtp_session, a_engine->codec_params.remote_sdp_ip, - a_engine->codec_params.remote_sdp_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { + if (switch_rtp_set_remote_address(a_engine->rtp_session, a_engine->cur_payload_map->remote_sdp_ip, + a_engine->cur_payload_map->remote_sdp_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err); switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); } @@ -2855,13 +2972,12 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s break; } - greed: x = 0; - if (a_engine->codec_params.rm_encoding && !(switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) || + if (a_engine->cur_payload_map->rm_encoding && !(switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) || switch_channel_test_flag(session->channel, CF_LIBERAL_DTMF))) { // && !switch_channel_test_flag(session->channel, CF_REINVITE)) { - char *remote_host = a_engine->codec_params.remote_sdp_ip; - switch_port_t remote_port = a_engine->codec_params.remote_sdp_port; + char *remote_host = a_engine->cur_payload_map->remote_sdp_ip; + switch_port_t remote_port = a_engine->cur_payload_map->remote_sdp_port; int same = 0; if (switch_rtp_ready(a_engine->rtp_session)) { @@ -2871,9 +2987,9 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s for (map = m->m_rtpmaps; map; map = map->rm_next) { if ((zstr(map->rm_encoding) || (smh->mparams->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { - match = (map->rm_pt == a_engine->codec_params.pt) ? 1 : 0; + match = (map->rm_pt == a_engine->cur_payload_map->pt) ? 1 : 0; } else { - match = strcasecmp(switch_str_nil(map->rm_encoding), a_engine->codec_params.iananame) ? 0 : 1; + match = strcasecmp(switch_str_nil(map->rm_encoding), a_engine->cur_payload_map->iananame) ? 0 : 1; } if (match && connection->c_address && remote_host && !strcmp(connection->c_address, remote_host) && m->m_port == remote_port) { @@ -2887,7 +3003,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s if (same) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Our existing sdp is still good [%s %s:%d], let's keep it.\n", - a_engine->codec_params.rm_encoding, a_engine->codec_params.remote_sdp_ip, a_engine->codec_params.remote_sdp_port); + a_engine->cur_payload_map->rm_encoding, a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port); got_audio = 1; } else { match = 0; @@ -2896,17 +3012,22 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s } for (map = m->m_rtpmaps; map; map = map->rm_next) { + int32_t i; const char *rm_encoding; - + uint32_t map_bit_rate = 0; + switch_codec_fmtp_t codec_fmtp = { 0 }; + if (!(rm_encoding = map->rm_encoding)) { rm_encoding = ""; } - - + + if (!strcasecmp(rm_encoding, "telephone-event")) { - if (!best_te || map->rm_rate == a_engine->codec_params.rm_rate) { + if (!best_te || map->rm_rate == a_engine->cur_payload_map->rm_rate) { best_te = (switch_payload_t) map->rm_pt; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set telephone-event payload to %u\n", best_te); } + continue; } if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && !cng_pt && !strcasecmp(rm_encoding, "CN")) { @@ -2915,36 +3036,18 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", cng_pt); switch_rtp_set_cng_pt(a_engine->rtp_session, smh->mparams->cng_pt); } + continue; } - - } - - for (map = m->m_rtpmaps; map; map = map->rm_next) { - int32_t i; - const char *rm_encoding; - uint32_t map_bit_rate = 0; - switch_codec_fmtp_t codec_fmtp = { 0 }; - + + if (x++ < skip) { continue; } - if (!(rm_encoding = map->rm_encoding)) { - rm_encoding = ""; - } - if (match) { continue; } - if (greedy) { - first = mine; - last = first + 1; - } else { - first = 0; - last = smh->mparams->num_codecs; - } - codec_ms = ptime; if (maxptime && (!codec_ms || codec_ms > maxptime)) { @@ -2961,6 +3064,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s codec_ms = 30; } + remote_codec_rate = map->rm_rate; + fmtp_remote_codec_rate = 0; + memset(&codec_fmtp, 0, sizeof(codec_fmtp)); + if (zstr(map->rm_fmtp)) { if (!strcasecmp(map->rm_encoding, "ilbc")) { codec_ms = 30; @@ -2977,27 +3084,32 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s if (codec_fmtp.microseconds_per_packet) { codec_ms = (codec_fmtp.microseconds_per_packet / 1000); } + if (codec_fmtp.actual_samples_per_second) { + fmtp_remote_codec_rate = codec_fmtp.actual_samples_per_second; + } } } - - for (i = first; i < last && i < total_codecs; i++) { + for (i = 0; i < smh->mparams->num_codecs && i < total_codecs; i++) { const switch_codec_implementation_t *imp = codec_array[i]; uint32_t bit_rate = imp->bits_per_second; uint32_t codec_rate = imp->samples_per_second; - char *samp = NULL; if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) { continue; } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d:%u]/[%s:%d:%u:%d:%u]\n", - rm_encoding, map->rm_pt, (int) map->rm_rate, codec_ms, map_bit_rate, + rm_encoding, map->rm_pt, (int) remote_codec_rate, codec_ms, map_bit_rate, imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate); if ((zstr(map->rm_encoding) || (smh->mparams->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { match = (map->rm_pt == imp->ianacode) ? 1 : 0; } else { - match = (!strcasecmp(rm_encoding, imp->iananame) && (map->rm_rate == codec_rate)) ? 1 : 0; + match = (!strcasecmp(rm_encoding, imp->iananame) && + (remote_codec_rate == codec_rate || fmtp_remote_codec_rate == imp->actual_samples_per_second)) ? 1 : 0; + if (fmtp_remote_codec_rate) { + remote_codec_rate = fmtp_remote_codec_rate; + } } if (match && bit_rate && map_bit_rate && map_bit_rate != bit_rate && strcasecmp(map->rm_encoding, "ilbc") && @@ -3006,155 +3118,190 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s match = 0; } - if (match && map->rm_rate && codec_rate && map->rm_rate != codec_rate && (!strcasecmp(map->rm_encoding, "pcma") || + if (match && remote_codec_rate && codec_rate && remote_codec_rate != codec_rate && (!strcasecmp(map->rm_encoding, "pcma") || !strcasecmp(map->rm_encoding, "pcmu"))) { /* if the sampling rate is specified and doesn't match, this is not a codec match for G.711 */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "sampling rates have to match for G.711\n"); match = 0; } - if (!zstr(map->rm_fmtp)) { - samp = strstr(map->rm_fmtp, "samplerate="); - } - if (!strcasecmp(map->rm_encoding, "opus") && !strcasecmp(rm_encoding, imp->iananame) && samp) { - char *rate_str = samp + 11; - - if (rate_str && *rate_str) { - near_rate = atoi(rate_str); - near_match = imp; - near_map = mmap = map; - match = 0; - goto near_match; - } - } - if (match) { if (scrooge) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Bah HUMBUG! Sticking with %s@%uh@%ui\n", imp->iananame, imp->samples_per_second, imp->microseconds_per_packet / 1000); - } else if ((ptime && codec_ms && codec_ms * 1000 != imp->microseconds_per_packet) || map->rm_rate != codec_rate) { + } else if ((ptime && codec_ms && codec_ms * 1000 != imp->microseconds_per_packet) || remote_codec_rate != codec_rate) { /* ptime does not match */ match = 0; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + "Audio Codec Compare [%s:%d:%u:%d:%u] is saved as a near-match\n", + imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate); - /* save first near_match */ - if (!near_match) { - near_rate = map->rm_rate; - near_match = imp; - near_map = mmap = map; + near_matches[nm_idx].codec_idx = i; + near_matches[nm_idx].rate = remote_codec_rate; + near_matches[nm_idx].imp = imp; + near_matches[nm_idx].map = map; + nm_idx++; - if (switch_true(switch_channel_get_variable_dup(channel, "rtp_negotiate_near_match", SWITCH_FALSE, -1))) { - goto near_match; - } - } continue; } - mimp = imp; - mmap = map; - break; + + matches[m_idx].codec_idx = i; + matches[m_idx].rate = codec_rate; + matches[m_idx].imp = imp; + matches[m_idx].map = map; + m_idx++; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + "Audio Codec Compare [%s:%d:%u:%d:%u] ++++ is saved as a match\n", + imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate); + + if (m_idx >= MAX_MATCHES) { + break; + } + + match = 0; } } - - if (!match && greedy) { - skip++; - continue; - } - - if (match && mimp) { + if (m_idx >= MAX_MATCHES) { break; } } - near_match: + if (!m_idx && nm_idx) { + int j; - if (!match && near_match) { - const switch_codec_implementation_t *search[1]; - char *prefs[1]; - char tmp[80]; - int num; + for(j = 0; j < nm_idx; j++) { + const switch_codec_implementation_t *search[1]; + char *prefs[1]; + char tmp[80]; + int num; + const switch_codec_implementation_t *timp = NULL; + + near_rate = near_matches[j].rate; + near_match = near_matches[j].imp; + near_map = near_matches[j].map; + + switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second, + codec_ms); + + prefs[0] = tmp; + num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1); - switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second, - codec_ms); + if (num) { + timp = search[0]; + } else { + timp = near_match; + } - prefs[0] = tmp; - num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1); - - if (num) { - mimp = search[0]; - } else { - mimp = near_match; - } - - if (!maxptime || mimp->microseconds_per_packet / 1000 <= maxptime) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n", - mimp->iananame, mimp->microseconds_per_packet / 1000, mimp->samples_per_second); - mmap = near_map; - match = 1; - } else { - mimp = NULL; - mmap = NULL; - match = 0; + if (!maxptime || timp->microseconds_per_packet / 1000 <= maxptime) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n", + timp->iananame, timp->microseconds_per_packet / 1000, timp->actual_samples_per_second); + match = 1; + + matches[m_idx].codec_idx = near_matches[j].codec_idx; + matches[m_idx].rate = near_rate; + matches[m_idx].imp = timp; + matches[m_idx].map = near_map; + m_idx++; + + break; + } } } - if (mimp && mmap) { - char tmp[50]; - const char *mirror = switch_channel_get_variable(session->channel, "rtp_mirror_remote_audio_codec_payload"); + if (m_idx) { + int j; - a_engine->codec_params.rm_encoding = switch_core_session_strdup(session, (char *) mmap->rm_encoding); - a_engine->codec_params.iananame = switch_core_session_strdup(session, (char *) mimp->iananame); - a_engine->codec_params.pt = (switch_payload_t) mmap->rm_pt; - a_engine->codec_params.rm_rate = mimp->samples_per_second; - a_engine->codec_params.adv_rm_rate = mimp->samples_per_second; - if (strcasecmp(mimp->iananame, "g722")) { - a_engine->codec_params.rm_rate = mimp->actual_samples_per_second; - } - a_engine->codec_params.codec_ms = mimp->microseconds_per_packet / 1000; - a_engine->codec_params.bitrate = mimp->bits_per_second; - a_engine->codec_params.channels = mmap->rm_params ? atoi(mmap->rm_params) : 1; - - if (!strcasecmp((char *) mmap->rm_encoding, "opus")) { - if (a_engine->codec_params.channels == 1) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Invalid SDP for opus. Don't ask.. but it needs a /2\n"); - a_engine->codec_params.adv_channels = 1; - } else { - a_engine->codec_params.adv_channels = 2; /* IKR ???*/ - } - if (!zstr((char *) mmap->rm_fmtp) && switch_stristr("stereo=1", (char *) mmap->rm_fmtp)) { - a_engine->codec_params.channels = 2; - } else { - a_engine->codec_params.channels = 1; - } - } else { - a_engine->codec_params.adv_channels = a_engine->codec_params.channels; + if (greedy) { /* sort in favor of mine */ + greedy_sort(smh, matches, m_idx, codec_array, total_codecs); } - a_engine->codec_params.remote_sdp_ip = switch_core_session_strdup(session, (char *) connection->c_address); - a_engine->codec_params.remote_sdp_port = (switch_port_t) m->m_port; - a_engine->codec_params.rm_fmtp = switch_core_session_strdup(session, (char *) mmap->rm_fmtp); + match = 1; + a_engine->codec_negotiated = 1; - a_engine->codec_params.agreed_pt = (switch_payload_t) mmap->rm_pt; - smh->num_negotiated_codecs = 0; - smh->negotiated_codecs[smh->num_negotiated_codecs++] = mimp; - switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->codec_params.remote_sdp_port); - switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->codec_params.remote_sdp_ip); - switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); - a_engine->codec_params.recv_pt = (switch_payload_t)mmap->rm_pt; - - if (!switch_true(mirror) && - switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND && - (!switch_channel_test_flag(session->channel, CF_REINVITE) || switch_media_handle_test_media_flag(smh, SCMF_RENEG_ON_REINVITE))) { - switch_core_media_get_offered_pt(session, mimp, &a_engine->codec_params.recv_pt); + for(j = 0; j < m_idx; j++) { + payload_map_t *pmap = switch_core_media_add_payload_map(session, + SWITCH_MEDIA_TYPE_AUDIO, + matches[j].map->rm_encoding, + sdp_type, + matches[j].map->rm_pt, + matches[j].imp->samples_per_second, + matches[j].imp->microseconds_per_packet / 1000, + SWITCH_TRUE); + mimp = matches[j].imp; + mmap = matches[j].map; + + if (j == 0) { + a_engine->cur_payload_map = pmap; + } + + pmap->rm_encoding = switch_core_session_strdup(session, (char *) mmap->rm_encoding); + pmap->iananame = switch_core_session_strdup(session, (char *) mimp->iananame); + pmap->pt = (switch_payload_t) mmap->rm_pt; + pmap->rm_rate = mimp->samples_per_second; + pmap->adv_rm_rate = mimp->samples_per_second; + if (strcasecmp(mimp->iananame, "g722")) { + pmap->rm_rate = mimp->actual_samples_per_second; + } + pmap->codec_ms = mimp->microseconds_per_packet / 1000; + pmap->bitrate = mimp->bits_per_second; + pmap->channels = mmap->rm_params ? atoi(mmap->rm_params) : 1; + + if (!strcasecmp((char *) mmap->rm_encoding, "opus")) { + if (pmap->channels == 1) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Invalid SDP for opus. Don't ask.. but it needs a /2\n"); + pmap->adv_channels = 1; + } else { + pmap->adv_channels = 2; /* IKR ???*/ + } + if (!zstr((char *) mmap->rm_fmtp) && switch_stristr("stereo=1", (char *) mmap->rm_fmtp)) { + pmap->channels = 2; + } else { + pmap->channels = 1; + } + } else { + pmap->adv_channels = pmap->channels; + } + + pmap->remote_sdp_ip = switch_core_session_strdup(session, (char *) connection->c_address); + pmap->remote_sdp_port = (switch_port_t) m->m_port; + pmap->rm_fmtp = switch_core_session_strdup(session, (char *) mmap->rm_fmtp); + + pmap->agreed_pt = (switch_payload_t) mmap->rm_pt; + smh->num_negotiated_codecs = 0; + smh->negotiated_codecs[smh->num_negotiated_codecs++] = mimp; + pmap->recv_pt = (switch_payload_t)mmap->rm_pt; + } - - switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->codec_params.recv_pt); - switch_channel_set_variable(session->channel, "rtp_audio_recv_pt", tmp); - } if (match) { - if (switch_core_media_set_codec(session, 1, smh->mparams->codec_flags) == SWITCH_STATUS_SUCCESS) { + char tmp[50]; + const char *mirror = switch_channel_get_variable(session->channel, "rtp_mirror_remote_audio_codec_payload"); + + + switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->remote_sdp_port); + switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->cur_payload_map->remote_sdp_ip); + switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); + + + if (!switch_true(mirror) && + switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND && + (!switch_channel_test_flag(session->channel, CF_REINVITE) || switch_media_handle_test_media_flag(smh, SCMF_RENEG_ON_REINVITE))) { + switch_core_media_get_offered_pt(session, mimp, &a_engine->cur_payload_map->recv_pt); + } + + switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->recv_pt); + switch_channel_set_variable(session->channel, "rtp_audio_recv_pt", tmp); + + if (switch_core_codec_ready(&a_engine->read_codec)) { + a_engine->reset_codec = 1; + } + + if (switch_core_media_set_codec(session, 0, smh->mparams->codec_flags) == SWITCH_STATUS_SUCCESS) { got_audio = 1; check_ice(smh, SWITCH_MEDIA_TYPE_AUDIO, sdp, m); } else { @@ -3205,25 +3352,24 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s } } - - if (!match && greedy && mine < total_codecs) { - mine++; - skip = 0; - goto greed; - } - } else if (m->m_type == sdp_media_video && m->m_port) { sdp_rtpmap_t *map; const char *rm_encoding; const switch_codec_implementation_t *mimp = NULL; int vmatch = 0, i; + + nm_idx = 0; + m_idx = 0; + memset(matches, 0, sizeof(matches[0]) * MAX_MATCHES); + memset(near_matches, 0, sizeof(near_matches[0]) * MAX_MATCHES); + switch_channel_set_variable(session->channel, "video_possible", "true"); connection = sdp->sdp_connection; if (m->m_connections) { connection = m->m_connections; } - + if (!connection) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot find a c= line in the sdp at media or session level!\n"); match = 0; @@ -3239,7 +3385,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s } } } - + for (attr = m->m_attributes; attr; attr = attr->a_next) { if (!strcasecmp(attr->a_name, "framerate") && attr->a_value) { //framerate = atoi(attr->a_value); @@ -3289,7 +3435,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s switch_channel_test_flag(session->channel, CF_NOVIDEO)) { continue; } - + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Compare [%s:%d]/[%s:%d]\n", rm_encoding, map->rm_pt, imp->iananame, imp->ianacode); if ((zstr(map->rm_encoding) || (smh->mparams->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { @@ -3300,56 +3446,89 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s if (vmatch && (map->rm_rate == imp->samples_per_second)) { - mimp = imp; - break; - } else { - vmatch = 0; + matches[m_idx].imp = imp; + matches[m_idx].map = map; + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Compare [%s:%d] is saved as a match\n", + imp->iananame, imp->ianacode); + m_idx++; } - } - if (mimp) { - if ((v_engine->codec_params.rm_encoding = switch_core_session_strdup(session, (char *) rm_encoding))) { - char tmp[50]; - const char *mirror = switch_channel_get_variable(session->channel, "rtp_mirror_remote_video_codec_payload"); - - v_engine->codec_params.pt = (switch_payload_t) map->rm_pt; - v_engine->codec_params.rm_rate = map->rm_rate; - v_engine->codec_params.codec_ms = mimp->microseconds_per_packet / 1000; - - - v_engine->codec_params.remote_sdp_ip = switch_core_session_strdup(session, (char *) connection->c_address); - v_engine->codec_params.remote_sdp_port = (switch_port_t) m->m_port; - - v_engine->codec_params.rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp); - - v_engine->codec_params.agreed_pt = (switch_payload_t) map->rm_pt; - switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->codec_params.remote_sdp_port); - switch_channel_set_variable(session->channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, v_engine->codec_params.remote_sdp_ip); - switch_channel_set_variable(session->channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp); - switch_channel_set_variable(session->channel, "rtp_video_fmtp", v_engine->codec_params.rm_fmtp); - switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->codec_params.agreed_pt); - switch_channel_set_variable(session->channel, "rtp_video_pt", tmp); - switch_core_media_check_video_codecs(session); - - v_engine->codec_params.recv_pt = (switch_payload_t)map->rm_pt; - - if (!switch_true(mirror) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - switch_core_media_get_offered_pt(session, mimp, &v_engine->codec_params.recv_pt); - } - - switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->codec_params.recv_pt); - switch_channel_set_variable(session->channel, "rtp_video_recv_pt", tmp); - if (!match && vmatch) match = 1; - - check_ice(smh, SWITCH_MEDIA_TYPE_VIDEO, sdp, m); - //check_ice(smh, SWITCH_MEDIA_TYPE_VIDEO, sdp, NULL); - break; - } else { - vmatch = 0; - } + vmatch = 0; } } - + + if (m_idx) { + char tmp[50]; + const char *mirror = switch_channel_get_variable(session->channel, "rtp_mirror_remote_video_codec_payload"); + int j = 0; + + if (greedy) { /* sort in favor of mine */ + greedy_sort(smh, matches, m_idx, codec_array, total_codecs); + } + + vmatch = 1; + v_engine->codec_negotiated = 1; + + for(j = 0; j < m_idx; j++) { + payload_map_t *pmap = switch_core_media_add_payload_map(session, + SWITCH_MEDIA_TYPE_VIDEO, + matches[j].map->rm_encoding, + sdp_type, + matches[j].map->rm_pt, + matches[j].imp->samples_per_second, + matches[j].imp->microseconds_per_packet / 1000, + SWITCH_TRUE); + + if (j == 0) { + v_engine->cur_payload_map = pmap; + } + + mimp = matches[j].imp; + map = matches[j].map; + + pmap->rm_encoding = switch_core_session_strdup(session, (char *) map->rm_encoding); + pmap->pt = (switch_payload_t) map->rm_pt; + pmap->rm_rate = map->rm_rate; + pmap->codec_ms = mimp->microseconds_per_packet / 1000; + + + pmap->remote_sdp_ip = switch_core_session_strdup(session, (char *) connection->c_address); + pmap->remote_sdp_port = (switch_port_t) m->m_port; + + pmap->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp); + + pmap->agreed_pt = (switch_payload_t) map->rm_pt; + + pmap->recv_pt = (switch_payload_t)map->rm_pt; + + if (!switch_true(mirror) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { + switch_core_media_get_offered_pt(session, mimp, &pmap->recv_pt); + } + } + + + + switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->cur_payload_map->remote_sdp_port); + switch_channel_set_variable(session->channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, v_engine->cur_payload_map->remote_sdp_ip); + switch_channel_set_variable(session->channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp); + switch_channel_set_variable(session->channel, "rtp_video_fmtp", v_engine->cur_payload_map->rm_fmtp); + switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->cur_payload_map->agreed_pt); + switch_channel_set_variable(session->channel, "rtp_video_pt", tmp); + switch_core_media_check_video_codecs(session); + switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->cur_payload_map->recv_pt); + switch_channel_set_variable(session->channel, "rtp_video_recv_pt", tmp); + if (!match && vmatch) match = 1; + + if (switch_core_codec_ready(&v_engine->read_codec)) { + v_engine->reset_codec = 1; + } + + if (switch_core_media_set_video_codec(session, 0) == SWITCH_STATUS_SUCCESS) { + check_ice(smh, SWITCH_MEDIA_TYPE_VIDEO, sdp, m); + } + + } } } @@ -3596,7 +3775,7 @@ static switch_status_t start_video_thread(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s Starting Video thread\n", switch_core_session_get_name(session)); - switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->codec_params.agreed_pt); + switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt); v_engine->mh.session = session; switch_threadattr_create(&thd_attr, pool); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); @@ -3703,20 +3882,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_proxy_remote_addr(switch_core_ goto end; } - a_engine->codec_params.remote_sdp_ip = switch_core_session_strdup(session, rip); - a_engine->codec_params.remote_sdp_port = (switch_port_t) atoi(rp); + a_engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(session, rip); + a_engine->cur_payload_map->remote_sdp_port = (switch_port_t) atoi(rp); if (*rvp) { - v_engine->codec_params.remote_sdp_ip = switch_core_session_strdup(session, rip); - v_engine->codec_params.remote_sdp_port = (switch_port_t) atoi(rvp); + v_engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(session, rip); + v_engine->cur_payload_map->remote_sdp_port = (switch_port_t) atoi(rvp); switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE); switch_channel_set_flag(session->channel, CF_VIDEO); } - if (v_engine->codec_params.remote_sdp_ip && v_engine->codec_params.remote_sdp_port) { - if (!strcmp(v_engine->codec_params.remote_sdp_ip, rip) && atoi(rvp) == v_engine->codec_params.remote_sdp_port) { + if (v_engine->cur_payload_map->remote_sdp_ip && v_engine->cur_payload_map->remote_sdp_port) { + if (!strcmp(v_engine->cur_payload_map->remote_sdp_ip, rip) && atoi(rvp) == v_engine->cur_payload_map->remote_sdp_port) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote video address:port [%s:%d] has not changed.\n", - v_engine->codec_params.remote_sdp_ip, v_engine->codec_params.remote_sdp_port); + v_engine->cur_payload_map->remote_sdp_ip, v_engine->cur_payload_map->remote_sdp_port); } else { switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE); switch_channel_set_flag(session->channel, CF_VIDEO); @@ -3731,12 +3910,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_proxy_remote_addr(switch_core_ } - if (switch_rtp_set_remote_address(v_engine->rtp_session, v_engine->codec_params.remote_sdp_ip, - v_engine->codec_params.remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { + if (switch_rtp_set_remote_address(v_engine->rtp_session, v_engine->cur_payload_map->remote_sdp_ip, + v_engine->cur_payload_map->remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n", - v_engine->codec_params.remote_sdp_ip, v_engine->codec_params.remote_sdp_port); + v_engine->cur_payload_map->remote_sdp_ip, v_engine->cur_payload_map->remote_sdp_port); if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(session->channel, CF_PROXY_MODE) && !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) && !switch_channel_test_flag(session->channel, CF_WEBRTC)) { @@ -3745,7 +3924,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_proxy_remote_addr(switch_core_ start_video_thread(session); } - if (switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_TIMING) || switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_PT)) { + if (switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_TIMING)) { v_engine->check_frames = 0; } } @@ -3759,9 +3938,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_proxy_remote_addr(switch_core_ const char *rport = NULL; switch_port_t remote_rtcp_port = 0; - if (remote_host && remote_port && !strcmp(remote_host, a_engine->codec_params.remote_sdp_ip) && remote_port == a_engine->codec_params.remote_sdp_port) { + if (remote_host && remote_port && !strcmp(remote_host, a_engine->cur_payload_map->remote_sdp_ip) && remote_port == a_engine->cur_payload_map->remote_sdp_port) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote address:port [%s:%d] has not changed.\n", - a_engine->codec_params.remote_sdp_ip, a_engine->codec_params.remote_sdp_port); + a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port); switch_goto_status(SWITCH_STATUS_BREAK, end); } @@ -3770,20 +3949,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_proxy_remote_addr(switch_core_ } - if (switch_rtp_set_remote_address(a_engine->rtp_session, a_engine->codec_params.remote_sdp_ip, - a_engine->codec_params.remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { + if (switch_rtp_set_remote_address(a_engine->rtp_session, a_engine->cur_payload_map->remote_sdp_ip, + a_engine->cur_payload_map->remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err); status = SWITCH_STATUS_GENERR; } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n", - a_engine->codec_params.remote_sdp_ip, a_engine->codec_params.remote_sdp_port); + a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port); if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) && !switch_channel_test_flag(session->channel, CF_WEBRTC)) { /* Reactivate the NAT buster flag. */ switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ); } - if (switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_TIMING) || switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_PT)) { + if (switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_TIMING)) { a_engine->check_frames = 0; } status = SWITCH_STATUS_SUCCESS; @@ -3930,31 +4109,31 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_choose_port(switch_core_sessio /* Don't do anything if we're in proxy mode or if a (remote) port already has been found */ if (!force) { if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || - switch_channel_test_flag(session->channel, CF_PROXY_MEDIA) || engine->codec_params.adv_sdp_port) { + switch_channel_test_flag(session->channel, CF_PROXY_MEDIA) || engine->adv_sdp_port) { return SWITCH_STATUS_SUCCESS; } } /* Release the local sdp port */ - if (engine->codec_params.local_sdp_port) { - switch_rtp_release_port(smh->mparams->rtpip, engine->codec_params.local_sdp_port); + if (engine->local_sdp_port) { + switch_rtp_release_port(smh->mparams->rtpip, engine->local_sdp_port); } /* Request a local port from the core's allocator */ - if (!(engine->codec_params.local_sdp_port = switch_rtp_request_port(smh->mparams->rtpip))) { + if (!(engine->local_sdp_port = switch_rtp_request_port(smh->mparams->rtpip))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "No %s RTP ports available!\n", tstr); return SWITCH_STATUS_FALSE; } - engine->codec_params.local_sdp_ip = smh->mparams->rtpip; + engine->local_sdp_ip = smh->mparams->rtpip; - sdp_port = engine->codec_params.local_sdp_port; + sdp_port = engine->local_sdp_port; /* Check if NAT is detected */ if (!zstr(smh->mparams->remote_ip) && switch_core_media_check_nat(smh, smh->mparams->remote_ip)) { /* Yes, map the port through switch_nat */ - switch_nat_add_mapping(engine->codec_params.local_sdp_port, SWITCH_NAT_UDP, &sdp_port, SWITCH_FALSE); + switch_nat_add_mapping(engine->local_sdp_port, SWITCH_NAT_UDP, &sdp_port, SWITCH_FALSE); switch_snprintf(vname, sizeof(vname), "rtp_adv_%s_ip", tstr); @@ -3981,16 +4160,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_choose_port(switch_core_sessio use_ip = smh->mparams->rtpip; } - engine->codec_params.adv_sdp_port = sdp_port; - engine->codec_params.adv_sdp_ip = smh->mparams->adv_sdp_audio_ip = smh->mparams->extrtpip = switch_core_session_strdup(session, use_ip); + engine->adv_sdp_port = sdp_port; + engine->adv_sdp_ip = smh->mparams->adv_sdp_audio_ip = smh->mparams->extrtpip = switch_core_session_strdup(session, use_ip); if (type == SWITCH_MEDIA_TYPE_AUDIO) { - switch_channel_set_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, engine->codec_params.local_sdp_ip); + switch_channel_set_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, engine->local_sdp_ip); switch_channel_set_variable_printf(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, "%d", sdp_port); - switch_channel_set_variable(session->channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE, engine->codec_params.adv_sdp_ip); + switch_channel_set_variable(session->channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE, engine->adv_sdp_ip); } else { - switch_channel_set_variable(session->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, engine->codec_params.adv_sdp_ip); + switch_channel_set_variable(session->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, engine->adv_sdp_ip); switch_channel_set_variable_printf(session->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, "%d", sdp_port); } @@ -4041,28 +4220,28 @@ SWITCH_DECLARE(void) switch_core_media_deactivate_rtp(switch_core_session_t *ses if (v_engine->rtp_session) { switch_rtp_destroy(&v_engine->rtp_session); - } else if (v_engine->codec_params.local_sdp_port) { - switch_rtp_release_port(smh->mparams->rtpip, v_engine->codec_params.local_sdp_port); + } else if (v_engine->local_sdp_port) { + switch_rtp_release_port(smh->mparams->rtpip, v_engine->local_sdp_port); } - if (v_engine->codec_params.local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) && + if (v_engine->local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) && switch_core_media_check_nat(smh, smh->mparams->remote_ip)) { - switch_nat_del_mapping((switch_port_t) v_engine->codec_params.local_sdp_port, SWITCH_NAT_UDP); - switch_nat_del_mapping((switch_port_t) v_engine->codec_params.local_sdp_port + 1, SWITCH_NAT_UDP); + switch_nat_del_mapping((switch_port_t) v_engine->local_sdp_port, SWITCH_NAT_UDP); + switch_nat_del_mapping((switch_port_t) v_engine->local_sdp_port + 1, SWITCH_NAT_UDP); } if (a_engine->rtp_session) { switch_rtp_destroy(&a_engine->rtp_session); - } else if (a_engine->codec_params.local_sdp_port) { - switch_rtp_release_port(smh->mparams->rtpip, a_engine->codec_params.local_sdp_port); + } else if (a_engine->local_sdp_port) { + switch_rtp_release_port(smh->mparams->rtpip, a_engine->local_sdp_port); } - if (a_engine->codec_params.local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) && + if (a_engine->local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) && switch_core_media_check_nat(smh, smh->mparams->remote_ip)) { - switch_nat_del_mapping((switch_port_t) a_engine->codec_params.local_sdp_port, SWITCH_NAT_UDP); - switch_nat_del_mapping((switch_port_t) a_engine->codec_params.local_sdp_port + 1, SWITCH_NAT_UDP); + switch_nat_del_mapping((switch_port_t) a_engine->local_sdp_port, SWITCH_NAT_UDP); + switch_nat_del_mapping((switch_port_t) a_engine->local_sdp_port + 1, SWITCH_NAT_UDP); } } @@ -4199,7 +4378,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_media_handle_t *smh; switch_assert(session); - + if (!(smh = session->media_handle)) { return SWITCH_STATUS_FALSE; } @@ -4241,6 +4420,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi goto end; } + switch_core_media_set_video_codec(session, 0); + + memset(flags, 0, sizeof(flags)); flags[SWITCH_RTP_FLAG_DATAWAIT]++; @@ -4287,32 +4469,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi char *remote_host = switch_rtp_get_remote_host(a_engine->rtp_session); switch_port_t remote_port = switch_rtp_get_remote_port(a_engine->rtp_session); - if (remote_host && remote_port && !strcmp(remote_host, a_engine->codec_params.remote_sdp_ip) && remote_port == a_engine->codec_params.remote_sdp_port) { + if (remote_host && remote_port && !strcmp(remote_host, a_engine->cur_payload_map->remote_sdp_ip) && + remote_port == a_engine->cur_payload_map->remote_sdp_port) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params are unchanged for %s.\n", switch_channel_get_name(session->channel)); - if (switch_rtp_ready(a_engine->rtp_session)) { - if (a_engine->codec_params.recv_pt != a_engine->codec_params.agreed_pt) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, - "%s Set audio receive payload in Re-INVITE for non-matching dynamic PT to %u\n", - switch_channel_get_name(session->channel), a_engine->codec_params.recv_pt); - - switch_rtp_set_recv_pt(a_engine->rtp_session, a_engine->codec_params.recv_pt); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, - "%s Setting audio receive payload in Re-INVITE to %u\n", - switch_channel_get_name(session->channel), a_engine->codec_params.recv_pt); - switch_rtp_set_recv_pt(a_engine->rtp_session, a_engine->codec_params.agreed_pt); - } - - } + //XX goto video; } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params changed for %s from %s:%d to %s:%d\n", switch_channel_get_name(session->channel), - remote_host, remote_port, a_engine->codec_params.remote_sdp_ip, a_engine->codec_params.remote_sdp_port); + remote_host, remote_port, a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port); - switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->codec_params.remote_sdp_port); - switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->codec_params.remote_sdp_ip); + switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->remote_sdp_port); + switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->cur_payload_map->remote_sdp_ip); switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); } } @@ -4320,30 +4489,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi if (!switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "AUDIO RTP [%s] %s port %d -> %s port %d codec: %u ms: %d\n", switch_channel_get_name(session->channel), - a_engine->codec_params.local_sdp_ip, - a_engine->codec_params.local_sdp_port, - a_engine->codec_params.remote_sdp_ip, - a_engine->codec_params.remote_sdp_port, a_engine->codec_params.agreed_pt, a_engine->read_impl.microseconds_per_packet / 1000); + a_engine->local_sdp_ip, + a_engine->local_sdp_port, + a_engine->cur_payload_map->remote_sdp_ip, + a_engine->cur_payload_map->remote_sdp_port, a_engine->cur_payload_map->agreed_pt, a_engine->read_impl.microseconds_per_packet / 1000); - if (switch_rtp_ready(a_engine->rtp_session)) { - switch_rtp_set_default_payload(a_engine->rtp_session, a_engine->codec_params.agreed_pt); - - if (a_engine->codec_params.recv_pt != a_engine->codec_params.agreed_pt) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, - "%s Set audio receive payload to %u\n", switch_channel_get_name(session->channel), a_engine->codec_params.recv_pt); - - switch_rtp_set_recv_pt(a_engine->rtp_session, a_engine->codec_params.recv_pt); - } else { - switch_rtp_set_recv_pt(a_engine->rtp_session, a_engine->codec_params.agreed_pt); - } - - } + //XX } - switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->codec_params.local_sdp_port); - switch_channel_set_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, a_engine->codec_params.local_sdp_ip); + switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->local_sdp_port); + switch_channel_set_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, a_engine->local_sdp_ip); switch_channel_set_variable(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp); - switch_channel_set_variable(session->channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE, a_engine->codec_params.adv_sdp_ip); + switch_channel_set_variable(session->channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE, a_engine->adv_sdp_ip); if (a_engine->rtp_session && switch_channel_test_flag(session->channel, CF_REINVITE)) { const char *rport = NULL; @@ -4355,14 +4512,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi } } - if (switch_rtp_set_remote_address(a_engine->rtp_session, a_engine->codec_params.remote_sdp_ip, a_engine->codec_params.remote_sdp_port, + if (switch_rtp_set_remote_address(a_engine->rtp_session, a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n", - a_engine->codec_params.remote_sdp_ip, a_engine->codec_params.remote_sdp_port); + a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port); - if (switch_channel_test_flag(session->channel, CF_PROTO_HOLD) && strcmp(a_engine->codec_params.remote_sdp_ip, "0.0.0.0")) { + if (switch_channel_test_flag(session->channel, CF_PROTO_HOLD) && strcmp(a_engine->cur_payload_map->remote_sdp_ip, "0.0.0.0")) { switch_core_media_toggle_hold(session, 0); } @@ -4398,13 +4555,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "PROXY AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n", switch_channel_get_name(session->channel), - a_engine->codec_params.remote_sdp_ip, - a_engine->codec_params.remote_sdp_port, - a_engine->codec_params.remote_sdp_ip, - a_engine->codec_params.remote_sdp_port, a_engine->codec_params.agreed_pt, a_engine->read_impl.microseconds_per_packet / 1000); + a_engine->cur_payload_map->remote_sdp_ip, + a_engine->cur_payload_map->remote_sdp_port, + a_engine->cur_payload_map->remote_sdp_ip, + a_engine->cur_payload_map->remote_sdp_port, a_engine->cur_payload_map->agreed_pt, a_engine->read_impl.microseconds_per_packet / 1000); if (switch_rtp_ready(a_engine->rtp_session)) { - switch_rtp_set_default_payload(a_engine->rtp_session, a_engine->codec_params.agreed_pt); + switch_rtp_set_default_payload(a_engine->rtp_session, a_engine->cur_payload_map->agreed_pt); } } else { @@ -4416,14 +4573,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi } if (switch_channel_up(session->channel)) { - a_engine->rtp_session = switch_rtp_new(a_engine->codec_params.local_sdp_ip, - a_engine->codec_params.local_sdp_port, - a_engine->codec_params.remote_sdp_ip, - a_engine->codec_params.remote_sdp_port, - a_engine->codec_params.agreed_pt, + + a_engine->rtp_session = switch_rtp_new(a_engine->local_sdp_ip, + a_engine->local_sdp_port, + a_engine->cur_payload_map->remote_sdp_ip, + a_engine->cur_payload_map->remote_sdp_port, + a_engine->cur_payload_map->agreed_pt, a_engine->read_impl.samples_per_packet, - a_engine->codec_params.codec_ms * 1000, + a_engine->cur_payload_map->codec_ms * 1000, flags, timer_name, &err, switch_core_session_get_pool(session)); + + if (switch_rtp_ready(a_engine->rtp_session)) { + switch_rtp_set_payload_map(a_engine->rtp_session, &a_engine->payload_map); + } } if (switch_rtp_ready(a_engine->rtp_session)) { @@ -4450,7 +4612,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_channel_set_flag(session->channel, CF_FS_RTP); - switch_channel_set_variable_printf(session->channel, "rtp_use_pt", "%d", a_engine->codec_params.agreed_pt); + switch_channel_set_variable_printf(session->channel, "rtp_use_pt", "%d", a_engine->cur_payload_map->agreed_pt); if ((val = switch_channel_get_variable(session->channel, "rtp_enable_vad_in")) && switch_true(val)) { vad_in = 1; @@ -4680,12 +4842,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_channel_set_variable_printf(session->channel, "rtp_2833_recv_payload", "%d", smh->mparams->recv_te); } - if (a_engine->codec_params.recv_pt != a_engine->codec_params.agreed_pt) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, - "%s Set audio receive payload to %u\n", switch_channel_get_name(session->channel), a_engine->codec_params.recv_pt); - - switch_rtp_set_recv_pt(a_engine->rtp_session, a_engine->codec_params.recv_pt); - } + //XX if (switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) || ((val = switch_channel_get_variable(session->channel, "supress_cng")) && switch_true(val)) || @@ -4714,8 +4871,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_core_session_apply_crypto(session, SWITCH_MEDIA_TYPE_AUDIO); - switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->codec_params.remote_sdp_port); - switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->codec_params.remote_sdp_ip); + switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->remote_sdp_port); + switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->cur_payload_map->remote_sdp_ip); switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); @@ -4737,8 +4894,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi if (switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { switch_core_media_check_video_codecs(session); } - - if (switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE) && v_engine->codec_params.rm_encoding && v_engine->codec_params.remote_sdp_port) { + + if (switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE) && v_engine->cur_payload_map->rm_encoding && v_engine->cur_payload_map->remote_sdp_port) { /******************************************************************************************/ if (v_engine->rtp_session && switch_channel_test_flag(session->channel, CF_REINVITE)) { //const char *ip = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE); @@ -4748,14 +4905,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi - if (remote_host && remote_port && !strcmp(remote_host, v_engine->codec_params.remote_sdp_ip) && remote_port == v_engine->codec_params.remote_sdp_port) { + if (remote_host && remote_port && !strcmp(remote_host, v_engine->cur_payload_map->remote_sdp_ip) && remote_port == v_engine->cur_payload_map->remote_sdp_port) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video params are unchanged for %s.\n", switch_channel_get_name(session->channel)); goto video_up; } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video params changed for %s from %s:%d to %s:%d\n", switch_channel_get_name(session->channel), - remote_host, remote_port, v_engine->codec_params.remote_sdp_ip, v_engine->codec_params.remote_sdp_port); + remote_host, remote_port, v_engine->cur_payload_map->remote_sdp_ip, v_engine->cur_payload_map->remote_sdp_port); } } @@ -4763,17 +4920,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi if (switch_rtp_ready(v_engine->rtp_session)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s port %d -> %s port %d codec: %u ms: %d\n", switch_channel_get_name(session->channel), - a_engine->codec_params.remote_sdp_ip, v_engine->codec_params.local_sdp_port, v_engine->codec_params.remote_sdp_ip, - v_engine->codec_params.remote_sdp_port, v_engine->codec_params.agreed_pt, + a_engine->cur_payload_map->remote_sdp_ip, v_engine->local_sdp_port, v_engine->cur_payload_map->remote_sdp_ip, + v_engine->cur_payload_map->remote_sdp_port, v_engine->cur_payload_map->agreed_pt, a_engine->read_impl.microseconds_per_packet / 1000); start_video_thread(session); - switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->codec_params.agreed_pt); + switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt); } } - switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->codec_params.local_sdp_port); - switch_channel_set_variable(session->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, a_engine->codec_params.adv_sdp_ip); + switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->local_sdp_port); + switch_channel_set_variable(session->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, a_engine->adv_sdp_ip); switch_channel_set_variable(session->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp); @@ -4790,12 +4947,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi } if (switch_rtp_set_remote_address - (v_engine->rtp_session, v_engine->codec_params.remote_sdp_ip, v_engine->codec_params.remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, + (v_engine->rtp_session, v_engine->cur_payload_map->remote_sdp_ip, v_engine->cur_payload_map->remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n", - v_engine->codec_params.remote_sdp_ip, v_engine->codec_params.remote_sdp_port); + v_engine->cur_payload_map->remote_sdp_ip, v_engine->cur_payload_map->remote_sdp_port); if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(session->channel, CF_WEBRTC) && !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val))) { /* Reactivate the NAT buster flag. */ @@ -4823,13 +4980,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "PROXY VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n", switch_channel_get_name(session->channel), - a_engine->codec_params.remote_sdp_ip, - v_engine->codec_params.local_sdp_port, - v_engine->codec_params.remote_sdp_ip, - v_engine->codec_params.remote_sdp_port, v_engine->codec_params.agreed_pt, v_engine->read_impl.microseconds_per_packet / 1000); + a_engine->cur_payload_map->remote_sdp_ip, + v_engine->local_sdp_port, + v_engine->cur_payload_map->remote_sdp_ip, + v_engine->cur_payload_map->remote_sdp_port, v_engine->cur_payload_map->agreed_pt, v_engine->read_impl.microseconds_per_packet / 1000); if (switch_rtp_ready(v_engine->rtp_session)) { - switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->codec_params.agreed_pt); + switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt); } } else { timer_name = smh->mparams->timer_name; @@ -4846,7 +5003,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi } - if (!v_engine->codec_params.local_sdp_port) { + if (!v_engine->local_sdp_port) { switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 1); } @@ -4869,31 +5026,32 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi flags[SWITCH_RTP_FLAG_NOBLOCK] = 0; flags[SWITCH_RTP_FLAG_VIDEO]++; - v_engine->rtp_session = switch_rtp_new(a_engine->codec_params.local_sdp_ip, - v_engine->codec_params.local_sdp_port, - v_engine->codec_params.remote_sdp_ip, - v_engine->codec_params.remote_sdp_port, - v_engine->codec_params.agreed_pt, + v_engine->rtp_session = switch_rtp_new(a_engine->local_sdp_ip, + v_engine->local_sdp_port, + v_engine->cur_payload_map->remote_sdp_ip, + v_engine->cur_payload_map->remote_sdp_port, + v_engine->cur_payload_map->agreed_pt, 1, 90000, flags, NULL, &err, switch_core_session_get_pool(session)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%sVIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n", switch_channel_test_flag(session->channel, CF_PROXY_MEDIA) ? "PROXY " : "", switch_channel_get_name(session->channel), - a_engine->codec_params.remote_sdp_ip, - v_engine->codec_params.local_sdp_port, - v_engine->codec_params.remote_sdp_ip, - v_engine->codec_params.remote_sdp_port, v_engine->codec_params.agreed_pt, + a_engine->cur_payload_map->remote_sdp_ip, + v_engine->local_sdp_port, + v_engine->cur_payload_map->remote_sdp_ip, + v_engine->cur_payload_map->remote_sdp_port, v_engine->cur_payload_map->agreed_pt, 0, switch_rtp_ready(v_engine->rtp_session) ? "SUCCESS" : err); - if (switch_rtp_ready(v_engine->rtp_session)) { - start_video_thread(session); - } - if (switch_rtp_ready(v_engine->rtp_session)) { const char *ssrc; + + switch_rtp_set_payload_map(v_engine->rtp_session, &v_engine->payload_map); + + start_video_thread(session); switch_channel_set_flag(session->channel, CF_VIDEO); + if ((ssrc = switch_channel_get_variable(session->channel, "rtp_use_video_ssrc"))) { uint32_t ssrc_ul = (uint32_t) strtoul(ssrc, NULL, 10); switch_rtp_set_ssrc(v_engine->rtp_session, ssrc_ul); @@ -5007,13 +5165,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_rtp_intentional_bugs(v_engine->rtp_session, v_engine->rtp_bugs | smh->mparams->manual_video_rtp_bugs); - if (v_engine->codec_params.recv_pt != v_engine->codec_params.agreed_pt) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, - "%s Set video receive payload to %u\n", switch_channel_get_name(session->channel), v_engine->codec_params.recv_pt); - switch_rtp_set_recv_pt(v_engine->rtp_session, v_engine->codec_params.recv_pt); - } + + //XX - switch_channel_set_variable_printf(session->channel, "rtp_use_video_pt", "%d", v_engine->codec_params.agreed_pt); + + switch_channel_set_variable_printf(session->channel, "rtp_use_video_pt", "%d", v_engine->cur_payload_map->agreed_pt); v_engine->ssrc = switch_rtp_get_ssrc(v_engine->rtp_session); switch_channel_set_variable_printf(session->channel, "rtp_use_video_ssrc", "%u", v_engine->ssrc); @@ -5082,7 +5238,8 @@ static const char *get_media_profile_name(switch_core_session_t *session, int se //? static void generate_m(switch_core_session_t *session, char *buf, size_t buflen, switch_port_t port, const char *family, const char *ip, - int cur_ptime, const char *append_audio, const char *sr, int use_cng, int cng_type, switch_event_t *map, int secure) + int cur_ptime, const char *append_audio, const char *sr, int use_cng, int cng_type, switch_event_t *map, int secure, + switch_sdp_type_t sdp_type) { int i = 0; int rate; @@ -5202,7 +5359,7 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen, fmtp = check; } } - + if (smh->ianacodes[i] > 95 || switch_channel_test_flag(session->channel, CF_VERBOSE_SDP)) { int channels = get_channels(imp->iananame, imp->number_of_channels); @@ -5280,14 +5437,14 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen, ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port ); - if (!zstr(a_engine->codec_params.local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) && - strcmp(a_engine->codec_params.local_sdp_ip, ice_out->cands[0][0].con_addr) - && a_engine->codec_params.local_sdp_port != ice_out->cands[0][0].con_port) { + if (!zstr(a_engine->local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) && + strcmp(a_engine->local_sdp_ip, ice_out->cands[0][0].con_addr) + && a_engine->local_sdp_port != ice_out->cands[0][0].con_port) { switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\n", tmp2, ice_out->cands[0][0].transport, c2, ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port, - a_engine->codec_params.local_sdp_ip, a_engine->codec_params.local_sdp_port + a_engine->local_sdp_ip, a_engine->local_sdp_port ); } @@ -5299,14 +5456,14 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen, ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (a_engine->rtcp_mux > 0 ? 0 : 1) ); - if (!zstr(a_engine->codec_params.local_sdp_ip) && !zstr(ice_out->cands[0][1].con_addr) && - strcmp(a_engine->codec_params.local_sdp_ip, ice_out->cands[0][1].con_addr) - && a_engine->codec_params.local_sdp_port != ice_out->cands[0][1].con_port) { + if (!zstr(a_engine->local_sdp_ip) && !zstr(ice_out->cands[0][1].con_addr) && + strcmp(a_engine->local_sdp_ip, ice_out->cands[0][1].con_addr) + && a_engine->local_sdp_port != ice_out->cands[0][1].con_port) { switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx raddr %s rport %d generation 0\n", tmp2, ice_out->cands[0][0].transport, c2, ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (a_engine->rtcp_mux > 0 ? 0 : 1), - a_engine->codec_params.local_sdp_ip, a_engine->codec_params.local_sdp_port + (a_engine->rtcp_mux > 0 ? 0 : 1) + a_engine->local_sdp_ip, a_engine->local_sdp_port + (a_engine->rtcp_mux > 0 ? 0 : 1) ); } } @@ -5458,7 +5615,7 @@ SWITCH_DECLARE(void)switch_core_media_set_local_sdp(switch_core_session_t *sessi //? #define SDPBUFLEN 65536 -SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, const char *ip, switch_port_t port, const char *sr, int force) +SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, switch_sdp_type_t sdp_type, const char *ip, switch_port_t port, const char *sr, int force) { char *buf; int ptime = 0; @@ -5486,6 +5643,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_media_handle_t *smh; ice_t *ice_out; int vp8 = 0; + payload_map_t *pmap; switch_assert(session); @@ -5528,7 +5686,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } } - fmtp_out = a_engine->codec_params.fmtp_out; + fmtp_out = a_engine->cur_payload_map->fmtp_out; username = smh->mparams->sdp_username; @@ -5543,26 +5701,40 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess smh->mparams->cng_pt = 0; } + if (!smh->payload_space) { int i; smh->payload_space = 98; - for (i = 0; i < smh->mparams->num_codecs; i++) { - const switch_codec_implementation_t *imp = smh->codecs[i]; + if (sdp_type == SDP_TYPE_REQUEST) { + for (i = 0; i < smh->mparams->num_codecs; i++) { + const switch_codec_implementation_t *imp = smh->codecs[i]; + + smh->ianacodes[i] = imp->ianacode; + + if (smh->ianacodes[i] > 64) { + if (smh->mparams->dtmf_type == DTMF_2833 && smh->mparams->te > 95 && smh->mparams->te == smh->payload_space) { + smh->payload_space++; + } + if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && + smh->mparams->cng_pt && use_cng && smh->mparams->cng_pt == smh->payload_space) { + smh->payload_space++; + } + smh->ianacodes[i] = (switch_payload_t)smh->payload_space++; + } + - smh->ianacodes[i] = imp->ianacode; - - if (smh->ianacodes[i] > 64) { - if (smh->mparams->dtmf_type == DTMF_2833 && smh->mparams->te > 95 && smh->mparams->te == smh->payload_space) { - smh->payload_space++; - } - if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && - smh->mparams->cng_pt && use_cng && smh->mparams->cng_pt == smh->payload_space) { - smh->payload_space++; - } - smh->ianacodes[i] = (switch_payload_t)smh->payload_space++; + switch_core_media_add_payload_map(session, + imp->codec_type == SWITCH_CODEC_TYPE_AUDIO ? SWITCH_MEDIA_TYPE_AUDIO : SWITCH_MEDIA_TYPE_VIDEO, + imp->iananame, + sdp_type, + smh->ianacodes[i], + imp->samples_per_second, + imp->microseconds_per_packet / 1000, + SWITCH_FALSE); } + } } @@ -5581,8 +5753,8 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } if (!ip) { - if (!(ip = a_engine->codec_params.adv_sdp_ip)) { - ip = a_engine->codec_params.proxy_sdp_ip; + if (!(ip = a_engine->adv_sdp_ip)) { + ip = a_engine->proxy_sdp_ip; } } @@ -5593,8 +5765,8 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } if (!port) { - if (!(port = a_engine->codec_params.adv_sdp_port)) { - port = a_engine->codec_params.proxy_sdp_port; + if (!(port = a_engine->adv_sdp_port)) { + port = a_engine->proxy_sdp_port; } } @@ -5604,7 +5776,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess return; } - if (!a_engine->codec_params.rm_encoding && (b_sdp = switch_channel_get_variable(session->channel, SWITCH_B_SDP_VARIABLE))) { + if (!a_engine->cur_payload_map->rm_encoding && (b_sdp = switch_channel_get_variable(session->channel, SWITCH_B_SDP_VARIABLE))) { switch_core_media_sdp_map(b_sdp, &map, &ptmap); } @@ -5655,7 +5827,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } - if (a_engine->codec_params.rm_encoding) { + if (a_engine->codec_negotiated) { /* switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=audio %d RTP/%sAVP%s", port, ((!zstr(local_audio_crypto_key) || switch_channel_test_flag(session->channel, CF_DTLS)) && @@ -5670,7 +5842,18 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess )); - switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", a_engine->codec_params.pt); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", a_engine->cur_payload_map->pt); + + + if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_AUDIO)) { + switch_mutex_lock(smh->mutex); + for (pmap = a_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) { + if (pmap->pt != a_engine->cur_payload_map->pt) { + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", pmap->pt); + } + } + switch_mutex_unlock(smh->mutex); + } if ((smh->mparams->dtmf_type == DTMF_2833 || switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) || switch_channel_test_flag(session->channel, CF_LIBERAL_DTMF)) && smh->mparams->te > 95) { @@ -5684,24 +5867,37 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\n"); - rate = a_engine->codec_params.adv_rm_rate; + rate = a_engine->cur_payload_map->adv_rm_rate; - if (!a_engine->codec_params.adv_channels) { - a_engine->codec_params.adv_channels = get_channels(a_engine->codec_params.rm_encoding, 1); + if (!a_engine->cur_payload_map->adv_channels) { + a_engine->cur_payload_map->adv_channels = get_channels(a_engine->cur_payload_map->rm_encoding, 1); } - - if (a_engine->codec_params.adv_channels > 1) { + + if (a_engine->cur_payload_map->adv_channels > 1) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d/%d\n", - a_engine->codec_params.agreed_pt, a_engine->codec_params.rm_encoding, rate, a_engine->codec_params.adv_channels); + a_engine->cur_payload_map->agreed_pt, a_engine->cur_payload_map->rm_encoding, rate, a_engine->cur_payload_map->adv_channels); } else { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d\n", - a_engine->codec_params.agreed_pt, a_engine->codec_params.rm_encoding, rate); + a_engine->cur_payload_map->agreed_pt, a_engine->cur_payload_map->rm_encoding, rate); } if (fmtp_out) { - switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\n", a_engine->codec_params.agreed_pt, fmtp_out); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\n", a_engine->cur_payload_map->agreed_pt, fmtp_out); } + if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_AUDIO)) { + switch_mutex_lock(smh->mutex); + for (pmap = a_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) { + if (pmap->pt != a_engine->cur_payload_map->pt) { + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%ld\n", + pmap->pt, pmap->iananame, + pmap->rate); + } + } + switch_mutex_unlock(smh->mutex); + } + + if (a_engine->read_codec.implementation && !ptime) { ptime = a_engine->read_codec.implementation->microseconds_per_packet / 1000; } @@ -5722,7 +5918,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } else if (smh->mparams->cng_pt && use_cng) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d CN/8000\n", smh->mparams->cng_pt); - if (!a_engine->codec_params.rm_encoding) { + if (!a_engine->codec_negotiated) { smh->mparams->cng_pt = 0; } } @@ -5795,14 +5991,14 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port ); - if (!zstr(a_engine->codec_params.local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) && - strcmp(a_engine->codec_params.local_sdp_ip, ice_out->cands[0][0].con_addr) - && a_engine->codec_params.local_sdp_port != ice_out->cands[0][0].con_port) { + if (!zstr(a_engine->local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) && + strcmp(a_engine->local_sdp_ip, ice_out->cands[0][0].con_addr) + && a_engine->local_sdp_port != ice_out->cands[0][0].con_port) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\n", tmp2, ice_out->cands[0][0].transport, c3, ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port, - a_engine->codec_params.local_sdp_ip, a_engine->codec_params.local_sdp_port + a_engine->local_sdp_ip, a_engine->local_sdp_port ); } @@ -5817,14 +6013,14 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess - if (!zstr(a_engine->codec_params.local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) && - strcmp(a_engine->codec_params.local_sdp_ip, ice_out->cands[0][0].con_addr) - && a_engine->codec_params.local_sdp_port != ice_out->cands[0][0].con_port) { + if (!zstr(a_engine->local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) && + strcmp(a_engine->local_sdp_ip, ice_out->cands[0][0].con_addr) + && a_engine->local_sdp_port != ice_out->cands[0][0].con_port) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx raddr %s rport %d generation 0\n", tmp2, ice_out->cands[0][0].transport, c4, ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (a_engine->rtcp_mux > 0 ? 0 : 1), - a_engine->codec_params.local_sdp_ip, a_engine->codec_params.local_sdp_port + (a_engine->rtcp_mux > 0 ? 0 : 1) + a_engine->local_sdp_ip, a_engine->local_sdp_port + (a_engine->rtcp_mux > 0 ? 0 : 1) ); } } @@ -5851,7 +6047,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->mparams->cng_pt && use_cng) { cng_type = smh->mparams->cng_pt; - if (!a_engine->codec_params.rm_encoding) { + if (!a_engine->codec_negotiated) { smh->mparams->cng_pt = 0; } } @@ -5865,7 +6061,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess if ((!zstr(local_audio_crypto_key) && switch_channel_test_flag(session->channel, CF_SECURE)) || switch_channel_test_flag(session->channel, CF_DTLS)) { - generate_m(session, buf, SDPBUFLEN, port, family, ip, 0, append_audio, sr, use_cng, cng_type, map, 1); + generate_m(session, buf, SDPBUFLEN, port, family, ip, 0, append_audio, sr, use_cng, cng_type, map, 1, sdp_type); bp = (buf + strlen(buf)); /* asterisk can't handle AVP and SAVP in sep streams, way to blow off the spec....*/ @@ -5876,7 +6072,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } if (both) { - generate_m(session, bp, SDPBUFLEN - strlen(buf), port, family, ip, 0, append_audio, sr, use_cng, cng_type, map, 0); + generate_m(session, bp, SDPBUFLEN - strlen(buf), port, family, ip, 0, append_audio, sr, use_cng, cng_type, map, 0, sdp_type); } } else { @@ -5902,7 +6098,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess if ((!zstr(local_audio_crypto_key) && switch_channel_test_flag(session->channel, CF_SECURE)) || switch_channel_test_flag(session->channel, CF_DTLS)) { - generate_m(session, bp, SDPBUFLEN - strlen(buf), port, family, ip, cur_ptime, append_audio, sr, use_cng, cng_type, map, 1); + generate_m(session, bp, SDPBUFLEN - strlen(buf), port, family, ip, cur_ptime, append_audio, sr, use_cng, cng_type, map, 1, sdp_type); bp = (buf + strlen(buf)); /* asterisk can't handle AVP and SAVP in sep streams, way to blow off the spec....*/ @@ -5916,7 +6112,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } if (both) { - generate_m(session, bp, SDPBUFLEN - strlen(buf), port, family, ip, cur_ptime, append_audio, sr, use_cng, cng_type, map, 0); + generate_m(session, bp, SDPBUFLEN - strlen(buf), port, family, ip, cur_ptime, append_audio, sr, use_cng, cng_type, map, 0, sdp_type); } } @@ -5935,11 +6131,15 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } - if (!v_engine->codec_params.local_sdp_port) { + if (!v_engine->local_sdp_port) { switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 0); } - if ((v_port = v_engine->codec_params.adv_sdp_port)) { + if (switch_channel_test_flag(session->channel, CF_WEBRTC)) { + switch_media_handle_set_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO); + } + + if ((v_port = v_engine->adv_sdp_port)) { if (switch_channel_test_flag(smh->session->channel, CF_ICE)) { gen_ice(session, SWITCH_MEDIA_TYPE_VIDEO, ip, (switch_port_t)v_port); @@ -5959,14 +6159,27 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess /*****************************/ - if (v_engine->codec_params.rm_encoding) { + if (v_engine->codec_negotiated) { + payload_map_t *pmap; switch_core_media_set_video_codec(session, 0); - switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", v_engine->codec_params.agreed_pt); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", v_engine->cur_payload_map->agreed_pt); + + if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO)) { + switch_mutex_lock(smh->mutex); + for (pmap = v_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) { + if (pmap->pt != v_engine->cur_payload_map->pt) { + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", pmap->pt); + } + } + switch_mutex_unlock(smh->mutex); + } + } else if (smh->mparams->num_codecs) { int i; int already_did[128] = { 0 }; for (i = 0; i < smh->mparams->num_codecs; i++) { const switch_codec_implementation_t *imp = smh->codecs[i]; + if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) { continue; @@ -5985,6 +6198,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->ianacodes[i]); + if (!ptime) { ptime = imp->microseconds_per_packet / 1000; } @@ -5994,20 +6208,22 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\n"); - if (v_engine->codec_params.rm_encoding) { + if (v_engine->codec_negotiated) { const char *of; + payload_map_t *pmap; - if (!strcasecmp(v_engine->codec_params.rm_encoding, "VP8")) { - vp8 = v_engine->codec_params.pt; + if (!strcasecmp(v_engine->cur_payload_map->rm_encoding, "VP8")) { + vp8 = v_engine->cur_payload_map->pt; } - rate = v_engine->codec_params.rm_rate; + rate = v_engine->cur_payload_map->rm_rate; switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%ld\n", - v_engine->codec_params.pt, v_engine->codec_params.rm_encoding, - v_engine->codec_params.rm_rate); + v_engine->cur_payload_map->pt, v_engine->cur_payload_map->rm_encoding, + v_engine->cur_payload_map->rm_rate); + if (switch_channel_test_flag(session->channel, CF_RECOVERING)) { - pass_fmtp = v_engine->codec_params.rm_fmtp; + pass_fmtp = v_engine->cur_payload_map->rm_fmtp; } else { pass_fmtp = NULL; @@ -6026,9 +6242,23 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess } if (pass_fmtp) { - switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\n", v_engine->codec_params.pt, pass_fmtp); + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\n", v_engine->cur_payload_map->pt, pass_fmtp); } + + if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO)) { + switch_mutex_lock(smh->mutex); + for (pmap = v_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) { + if (pmap->pt != v_engine->cur_payload_map->pt) { + switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%ld\n", + pmap->pt, pmap->iananame, pmap->rate); + + } + } + switch_mutex_unlock(smh->mutex); + } + + if (append_video) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "%s%s", append_video, end_of(append_video) == '\n' ? "" : "\n"); } @@ -6169,14 +6399,14 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port ); - if (!zstr(v_engine->codec_params.local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) && - strcmp(v_engine->codec_params.local_sdp_ip, ice_out->cands[0][0].con_addr) - && v_engine->codec_params.local_sdp_port != ice_out->cands[0][0].con_port) { + if (!zstr(v_engine->local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) && + strcmp(v_engine->local_sdp_ip, ice_out->cands[0][0].con_addr) + && v_engine->local_sdp_port != ice_out->cands[0][0].con_port) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\n", tmp2, ice_out->cands[0][0].transport, c3, ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port, - v_engine->codec_params.local_sdp_ip, v_engine->codec_params.local_sdp_port + v_engine->local_sdp_ip, v_engine->local_sdp_port ); } @@ -6190,14 +6420,14 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess ); - if (!zstr(v_engine->codec_params.local_sdp_ip) && !zstr(ice_out->cands[0][1].con_addr) && - strcmp(v_engine->codec_params.local_sdp_ip, ice_out->cands[0][1].con_addr) - && v_engine->codec_params.local_sdp_port != ice_out->cands[0][1].con_port) { + if (!zstr(v_engine->local_sdp_ip) && !zstr(ice_out->cands[0][1].con_addr) && + strcmp(v_engine->local_sdp_ip, ice_out->cands[0][1].con_addr) + && v_engine->local_sdp_port != ice_out->cands[0][1].con_port) { switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx generation 0\n", tmp2, ice_out->cands[0][0].transport, c4, ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (v_engine->rtcp_mux > 0 ? 0 : 1), - v_engine->codec_params.local_sdp_ip, v_engine->codec_params.local_sdp_port + (v_engine->rtcp_mux > 0 ? 0 : 1) + v_engine->local_sdp_ip, v_engine->local_sdp_port + (v_engine->rtcp_mux > 0 ? 0 : 1) ); } } @@ -6273,10 +6503,10 @@ SWITCH_DECLARE(void) switch_core_media_absorb_sdp(switch_core_session_t *session } if (connection) { - a_engine->codec_params.proxy_sdp_ip = switch_core_session_strdup(session, connection->c_address); + a_engine->proxy_sdp_ip = switch_core_session_strdup(session, connection->c_address); } - a_engine->codec_params.proxy_sdp_port = (switch_port_t) m->m_port; - if (a_engine->codec_params.proxy_sdp_ip && a_engine->codec_params.proxy_sdp_port) { + a_engine->proxy_sdp_port = (switch_port_t) m->m_port; + if (a_engine->proxy_sdp_ip && a_engine->proxy_sdp_port) { break; } } @@ -6332,8 +6562,8 @@ SWITCH_DECLARE(void) switch_core_media_set_udptl_image_sdp(switch_core_session_t if (!ip) { - if (!(ip = a_engine->codec_params.adv_sdp_ip)) { - ip = a_engine->codec_params.proxy_sdp_ip; + if (!(ip = a_engine->adv_sdp_ip)) { + ip = a_engine->proxy_sdp_ip; } } @@ -6343,8 +6573,8 @@ SWITCH_DECLARE(void) switch_core_media_set_udptl_image_sdp(switch_core_session_t } if (!port) { - if (!(port = a_engine->codec_params.adv_sdp_port)) { - port = a_engine->codec_params.proxy_sdp_port; + if (!(port = a_engine->adv_sdp_port)) { + port = a_engine->proxy_sdp_port; } } @@ -6471,20 +6701,20 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session) return; } - if (zstr(a_engine->codec_params.local_sdp_ip) || !a_engine->codec_params.local_sdp_port) {// || switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) { + if (zstr(a_engine->local_sdp_ip) || !a_engine->local_sdp_port) {// || switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) { if (switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_AUDIO, 1) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s I/O Error\n", switch_channel_get_name(session->channel)); return; } - a_engine->codec_params.iananame = switch_core_session_strdup(session, "PROXY"); - a_engine->codec_params.rm_rate = 8000; - a_engine->codec_params.adv_rm_rate = 8000; - a_engine->codec_params.codec_ms = 20; + a_engine->cur_payload_map->iananame = switch_core_session_strdup(session, "PROXY"); + a_engine->cur_payload_map->rm_rate = 8000; + a_engine->cur_payload_map->adv_rm_rate = 8000; + a_engine->cur_payload_map->codec_ms = 20; } new_sdp = switch_core_session_alloc(session, len); - switch_snprintf(port_buf, sizeof(port_buf), "%u", a_engine->codec_params.local_sdp_port); + switch_snprintf(port_buf, sizeof(port_buf), "%u", a_engine->local_sdp_port); p = smh->mparams->local_sdp_str; @@ -6504,15 +6734,15 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session) goto end; } - if (a_engine->codec_params.local_sdp_ip && !strncmp("c=IN IP", p, 7)) { + if (a_engine->local_sdp_ip && !strncmp("c=IN IP", p, 7)) { strncpy(q, p, 7); p += 7; q += 7; - strncpy(q, strchr(a_engine->codec_params.adv_sdp_ip, ':') ? "6 " : "4 ", 2); + strncpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2); p +=2; q +=2; - strncpy(q, a_engine->codec_params.adv_sdp_ip, strlen(a_engine->codec_params.adv_sdp_ip)); - q += strlen(a_engine->codec_params.adv_sdp_ip); + strncpy(q, a_engine->adv_sdp_ip, strlen(a_engine->adv_sdp_ip)); + q += strlen(a_engine->adv_sdp_ip); while (p && *p && ((*p >= '0' && *p <= '9') || *p == '.' || *p == ':' || (*p >= 'A' && *p <= 'F') || (*p >= 'a' && *p <= 'f'))) { if (p >= pe) { @@ -6623,11 +6853,11 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session) } else if (!strncmp("m=video ", p, 8) && *(p + 8) != '0') { if (!has_video) { switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 1); - v_engine->codec_params.rm_encoding = "PROXY-VID"; - v_engine->codec_params.rm_rate = 90000; - v_engine->codec_params.adv_rm_rate = 90000; - v_engine->codec_params.codec_ms = 0; - switch_snprintf(vport_buf, sizeof(vport_buf), "%u", v_engine->codec_params.adv_sdp_port); + v_engine->cur_payload_map->rm_encoding = "PROXY-VID"; + v_engine->cur_payload_map->rm_rate = 90000; + v_engine->cur_payload_map->adv_rm_rate = 90000; + v_engine->cur_payload_map->codec_ms = 0; + switch_snprintf(vport_buf, sizeof(vport_buf), "%u", v_engine->adv_sdp_port); if (switch_channel_media_ready(session->channel) && !switch_rtp_ready(v_engine->rtp_session)) { switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE); switch_channel_set_flag(session->channel, CF_REINVITE); @@ -7055,9 +7285,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se const char *ip = NULL, *port = NULL; switch_channel_set_flag(session->channel, CF_PROXY_MODE); - if (a_engine->codec_params.rm_encoding) { - a_engine->codec_params.rm_encoding = NULL; - } + + a_engine->codec_negotiated = 0; + switch_core_media_set_local_sdp(session, NULL, SWITCH_FALSE); if (switch_true(switch_channel_get_variable(session->channel, "bypass_keep_codec"))) { @@ -7072,7 +7302,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se port = switch_channel_get_variable(other_channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE); switch_core_session_rwunlock(other_session); if (ip && port) { - switch_core_media_gen_local_sdp(session, ip, (switch_port_t)atoi(port), NULL, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, ip, (switch_port_t)atoi(port), NULL, 1); } } @@ -7109,19 +7339,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se switch_channel_set_variable(session->channel, "codec_string", msg->string_arg); } else { switch_channel_set_variable_printf(session->channel, "codec_string", "=%s%s%s,%s", - v_engine->codec_params.rm_encoding ? v_engine->codec_params.rm_encoding : "", - v_engine->codec_params.rm_encoding ? "," : "", - a_engine->codec_params.rm_encoding, msg->string_arg); + v_engine->cur_payload_map->rm_encoding ? v_engine->cur_payload_map->rm_encoding : "", + v_engine->cur_payload_map->rm_encoding ? "," : "", + a_engine->cur_payload_map->rm_encoding, msg->string_arg); } - - a_engine->codec_params.rm_encoding = NULL; - v_engine->codec_params.rm_encoding = NULL; + a_engine->codec_negotiated = 0; + v_engine->codec_negotiated = 0; switch_channel_clear_flag(session->channel, CF_VIDEO_POSSIBLE); switch_core_media_prepare_codecs(session, SWITCH_TRUE); switch_core_media_check_video_codecs(session); - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 1); } switch_media_handle_set_media_flag(smh, SCMF_RENEG_ON_REINVITE); @@ -7302,22 +7531,6 @@ SWITCH_DECLARE(void) switch_core_media_clear_rtp_flag(switch_core_session_t *ses } } -//? -SWITCH_DECLARE(void) switch_core_media_set_recv_pt(switch_core_session_t *session, switch_media_type_t type, switch_payload_t pt) -{ - switch_media_handle_t *smh; - - switch_assert(session); - - if (!(smh = session->media_handle)) { - return; - } - - if (switch_rtp_ready(smh->engines[type].rtp_session)) { - switch_rtp_set_recv_pt(smh->engines[type].rtp_session, pt); - } -} - //? SWITCH_DECLARE(void) switch_core_media_set_telephony_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te) { @@ -7694,7 +7907,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_sessi engine = &smh->engines[type]; - if (engine->codec_params.iananame) { + if (engine->cur_payload_map->iananame) { return SWITCH_STATUS_SUCCESS; } @@ -7726,18 +7939,18 @@ SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_ switch_channel_set_flag(session->channel, CF_PROXY_MEDIA); - a_engine->codec_params.iananame = switch_core_session_strdup(session, "PROXY"); - a_engine->codec_params.rm_rate = 8000; - a_engine->codec_params.adv_rm_rate = 8000; + a_engine->cur_payload_map->iananame = switch_core_session_strdup(session, "PROXY"); + a_engine->cur_payload_map->rm_rate = 8000; + a_engine->cur_payload_map->adv_rm_rate = 8000; - a_engine->codec_params.codec_ms = 20; + a_engine->cur_payload_map->codec_ms = 20; if (switch_stristr("m=video", r_sdp)) { switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 1); - v_engine->codec_params.rm_encoding = "PROXY-VID"; - v_engine->codec_params.rm_rate = 90000; - v_engine->codec_params.adv_rm_rate = 90000; - v_engine->codec_params.codec_ms = 0; + v_engine->cur_payload_map->rm_encoding = "PROXY-VID"; + v_engine->cur_payload_map->rm_rate = 90000; + v_engine->cur_payload_map->adv_rm_rate = 90000; + v_engine->cur_payload_map->codec_ms = 0; switch_channel_set_flag(session->channel, CF_VIDEO); switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE); } @@ -7806,10 +8019,10 @@ SWITCH_DECLARE(void) switch_core_media_proxy_codec(switch_core_session_t *sessio } for (map = m->m_rtpmaps; map; map = map->rm_next) { - a_engine->codec_params.iananame = switch_core_session_strdup(session, map->rm_encoding); - a_engine->codec_params.rm_rate = map->rm_rate; - a_engine->codec_params.adv_rm_rate = map->rm_rate; - a_engine->codec_params.codec_ms = ptime; + a_engine->cur_payload_map->iananame = switch_core_session_strdup(session, map->rm_encoding); + a_engine->cur_payload_map->rm_rate = map->rm_rate; + a_engine->cur_payload_map->adv_rm_rate = map->rm_rate; + a_engine->cur_payload_map->codec_ms = ptime; switch_core_media_set_codec(session, 0, smh->mparams->codec_flags); break; } @@ -7856,9 +8069,8 @@ SWITCH_DECLARE (void) switch_core_media_recover_session(switch_core_session_t *s a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO]; v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO]; - - a_engine->codec_params.iananame = a_engine->codec_params.rm_encoding = (char *) switch_channel_get_variable(session->channel, "rtp_use_codec_name"); - a_engine->codec_params.rm_fmtp = (char *) switch_channel_get_variable(session->channel, "rtp_use_codec_fmtp"); + a_engine->cur_payload_map->iananame = a_engine->cur_payload_map->rm_encoding = (char *) switch_channel_get_variable(session->channel, "rtp_use_codec_name"); + a_engine->cur_payload_map->rm_fmtp = (char *) switch_channel_get_variable(session->channel, "rtp_use_codec_fmtp"); if ((tmp = switch_channel_get_variable(session->channel, SWITCH_R_SDP_VARIABLE))) { smh->mparams->remote_sdp_str = switch_core_session_strdup(session, tmp); @@ -7885,52 +8097,52 @@ SWITCH_DECLARE (void) switch_core_media_recover_session(switch_core_session_t *s } if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_codec_rate"))) { - a_engine->codec_params.rm_rate = atoi(tmp); - a_engine->codec_params.adv_rm_rate = a_engine->codec_params.rm_rate; + a_engine->cur_payload_map->rm_rate = atoi(tmp); + a_engine->cur_payload_map->adv_rm_rate = a_engine->cur_payload_map->rm_rate; } if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_codec_ptime"))) { - a_engine->codec_params.codec_ms = atoi(tmp); + a_engine->cur_payload_map->codec_ms = atoi(tmp); } if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_pt"))) { - a_engine->codec_params.pt = a_engine->codec_params.agreed_pt = (switch_payload_t)atoi(tmp); + a_engine->cur_payload_map->pt = a_engine->cur_payload_map->agreed_pt = (switch_payload_t)atoi(tmp); } if ((tmp = switch_channel_get_variable(session->channel, "rtp_audio_recv_pt"))) { - a_engine->codec_params.recv_pt = a_engine->codec_params.agreed_pt = (switch_payload_t)atoi(tmp);; + a_engine->cur_payload_map->recv_pt = (switch_payload_t)atoi(tmp); } switch_core_media_set_codec(session, 1, smh->mparams->codec_flags); - a_engine->codec_params.adv_sdp_ip = smh->mparams->extrtpip = (char *) ip; - a_engine->codec_params.adv_sdp_port = a_engine->codec_params.local_sdp_port = (switch_port_t)atoi(port); + a_engine->adv_sdp_ip = smh->mparams->extrtpip = (char *) ip; + a_engine->adv_sdp_port = a_engine->local_sdp_port = (switch_port_t)atoi(port); if (!zstr(ip)) { - a_engine->codec_params.local_sdp_ip = switch_core_session_strdup(session, ip); - smh->mparams->rtpip = a_engine->codec_params.local_sdp_ip; + a_engine->local_sdp_ip = switch_core_session_strdup(session, ip); + smh->mparams->rtpip = a_engine->local_sdp_ip; } if (!zstr(a_ip)) { - a_engine->codec_params.adv_sdp_ip = switch_core_session_strdup(session, a_ip); + a_engine->adv_sdp_ip = switch_core_session_strdup(session, a_ip); } if (r_ip && r_port) { - a_engine->codec_params.remote_sdp_ip = (char *) r_ip; - a_engine->codec_params.remote_sdp_port = (switch_port_t)atoi(r_port); + a_engine->cur_payload_map->remote_sdp_ip = (char *) r_ip; + a_engine->cur_payload_map->remote_sdp_port = (switch_port_t)atoi(r_port); } if (switch_channel_test_flag(session->channel, CF_VIDEO)) { if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_video_pt"))) { - v_engine->codec_params.pt = v_engine->codec_params.agreed_pt = (switch_payload_t)atoi(tmp); + v_engine->cur_payload_map->pt = v_engine->cur_payload_map->agreed_pt = (switch_payload_t)atoi(tmp); } if ((tmp = switch_channel_get_variable(session->channel, "rtp_video_recv_pt"))) { - v_engine->codec_params.recv_pt = a_engine->codec_params.agreed_pt = (switch_payload_t)atoi(tmp);; + v_engine->cur_payload_map->recv_pt = (switch_payload_t)atoi(tmp);; } - v_engine->codec_params.rm_encoding = (char *) switch_channel_get_variable(session->channel, "rtp_use_video_codec_name"); - v_engine->codec_params.rm_fmtp = (char *) switch_channel_get_variable(session->channel, "rtp_use_video_codec_fmtp"); + v_engine->cur_payload_map->rm_encoding = (char *) switch_channel_get_variable(session->channel, "rtp_use_video_codec_name"); + v_engine->cur_payload_map->rm_fmtp = (char *) switch_channel_get_variable(session->channel, "rtp_use_video_codec_fmtp"); ip = switch_channel_get_variable(session->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE); port = switch_channel_get_variable(session->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE); @@ -7940,23 +8152,24 @@ SWITCH_DECLARE (void) switch_core_media_recover_session(switch_core_session_t *s switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE); if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_video_codec_rate"))) { - v_engine->codec_params.rm_rate = atoi(tmp); - v_engine->codec_params.adv_rm_rate = v_engine->codec_params.rm_rate; + v_engine->cur_payload_map->rm_rate = atoi(tmp); + v_engine->cur_payload_map->adv_rm_rate = v_engine->cur_payload_map->rm_rate; } if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_video_codec_ptime"))) { - v_engine->codec_params.codec_ms = atoi(tmp); + v_engine->cur_payload_map->codec_ms = atoi(tmp); } - v_engine->codec_params.adv_sdp_port = v_engine->codec_params.local_sdp_port = (switch_port_t)atoi(port); + v_engine->adv_sdp_port = v_engine->local_sdp_port = (switch_port_t)atoi(port); if (r_ip && r_port) { - v_engine->codec_params.remote_sdp_ip = (char *) r_ip; - v_engine->codec_params.remote_sdp_port = (switch_port_t)atoi(r_port); + v_engine->cur_payload_map->remote_sdp_ip = (char *) r_ip; + v_engine->cur_payload_map->remote_sdp_port = (switch_port_t)atoi(r_port); } } - switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 1); + switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 1); + switch_core_media_set_video_codec(session, 1); if (switch_core_media_activate_rtp(session) != SWITCH_STATUS_SUCCESS) { return; @@ -7983,15 +8196,10 @@ SWITCH_DECLARE (void) switch_core_media_recover_session(switch_core_session_t *s if (switch_core_media_ready(session, SWITCH_MEDIA_TYPE_AUDIO)) { - switch_core_media_set_recv_pt(session, SWITCH_MEDIA_TYPE_AUDIO, a_engine->codec_params.recv_pt); switch_rtp_set_telephony_event(a_engine->rtp_session, smh->mparams->te); switch_rtp_set_telephony_recv_event(a_engine->rtp_session, smh->mparams->recv_te); } - if (switch_core_media_ready(session, SWITCH_MEDIA_TYPE_VIDEO)) { - switch_core_media_set_recv_pt(session, SWITCH_MEDIA_TYPE_VIDEO, v_engine->codec_params.recv_pt); - } - } diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 4d644adf0c..a0e80013f0 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -325,7 +325,6 @@ struct switch_rtp { int8_t sending_dtmf; uint8_t need_mark; switch_payload_t payload; - switch_payload_t rpayload; switch_rtp_invalid_handler_t invalid_handler; void *private_data; uint32_t ts; @@ -398,6 +397,10 @@ struct switch_rtp { switch_size_t last_flush_packet_count; uint32_t interdigit_delay; switch_core_session_t *session; + payload_map_t **pmaps; + payload_map_t *pmap_tail; + int pmap_ttl; + #ifdef ENABLE_ZRTP zrtp_session_t *zrtp_session; zrtp_profile_t *zrtp_profile; @@ -1859,6 +1862,19 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(const char *ip) return port; } +SWITCH_DECLARE(switch_status_t) switch_rtp_set_payload_map(switch_rtp_t *rtp_session, payload_map_t **pmap) +{ + + if (rtp_session) { + switch_mutex_lock(rtp_session->flag_mutex); + rtp_session->pmaps = pmap; + switch_mutex_unlock(rtp_session->flag_mutex); + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_FALSE; +} + SWITCH_DECLARE(void) switch_rtp_intentional_bugs(switch_rtp_t *rtp_session, switch_rtp_bug_flag_t bugs) { rtp_session->rtp_bugs = bugs; @@ -2973,7 +2989,6 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session rtp_session->recv_msg.header.cc = 0; rtp_session->payload = payload; - rtp_session->rpayload = payload; switch_rtp_set_interval(rtp_session, ms_per_packet, samples_per_interval); rtp_session->conf_samples_per_interval = samples_per_interval; @@ -3164,11 +3179,6 @@ SWITCH_DECLARE(void) switch_rtp_set_telephony_recv_event(switch_rtp_t *rtp_sessi } } -SWITCH_DECLARE(void) switch_rtp_set_recv_pt(switch_rtp_t *rtp_session, switch_payload_t pt) -{ - rtp_session->rpayload = pt; -} - SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_payload_t pt) { @@ -4063,6 +4073,27 @@ static int jb_valid(switch_rtp_t *rtp_session) return 1; } +static int check_recv_payload(switch_rtp_t *rtp_session) +{ + int ok = 0; + + if (rtp_session->pmaps && *rtp_session->pmaps) { + payload_map_t *pmap; + switch_mutex_lock(rtp_session->flag_mutex); + for (pmap = *rtp_session->pmaps; pmap && pmap->allocated; pmap = pmap->next) { + if (!pmap->negotiated) { + continue; + } + if (rtp_session->recv_msg.header.pt == pmap->pt) { + ok = 1; + } + } + switch_mutex_unlock(rtp_session->flag_mutex); + } + + return ok; +} + #define return_cng_frame() do_cng = 1; goto timer_check static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes, switch_frame_flag_t *flags, switch_bool_t return_jb_packet) @@ -4149,7 +4180,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t if (status == SWITCH_STATUS_SUCCESS && *bytes) { if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) { *flags &= ~SFF_RTCP; - if (rtp_session->recv_msg.header.pt != rtp_session->rpayload && + if (!check_recv_payload(rtp_session) && (!rtp_session->recv_te || rtp_session->recv_msg.header.pt != rtp_session->recv_te) && (!rtp_session->cng_pt || rtp_session->recv_msg.header.pt != rtp_session->cng_pt) && rtp_session->rtcp_recv_msg_p->header.version == 2 && @@ -4319,7 +4350,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t #ifdef ENABLE_SRTP if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && rtp_session->recv_msg.header.version == 2 && - ((rtp_session->recv_msg.header.pt == rtp_session->rpayload) || + (check_recv_payload(rtp_session) || (rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) || (rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt))) { //if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && (!rtp_session->ice.ice_user || rtp_session->recv_msg.header.version == 2)) { @@ -4376,7 +4407,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t rtp_session->last_read_ts = ts; } - if (rtp_session->flags[SWITCH_RTP_FLAG_BYTESWAP] && rtp_session->recv_msg.header.pt == rtp_session->rpayload) { + if (rtp_session->flags[SWITCH_RTP_FLAG_BYTESWAP] && check_recv_payload(rtp_session)) { switch_swap_linear((int16_t *)RTP_BODY(rtp_session), (int) *bytes - rtp_header_len); } @@ -4602,7 +4633,8 @@ static int using_ice(switch_rtp_t *rtp_session) return 0; } -static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags) +static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type, + payload_map_t **pmapP, switch_frame_flag_t *flags, switch_io_flag_t io_flags) { switch_channel_t *channel = NULL; @@ -4969,11 +5001,33 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] && rtp_session->recv_msg.header.pt != 13 && rtp_session->recv_msg.header.pt != rtp_session->recv_te && - (!rtp_session->cng_pt || rtp_session->recv_msg.header.pt != rtp_session->cng_pt) && - rtp_session->recv_msg.header.pt != rtp_session->rpayload && - !(rtp_session->rtp_bugs & RTP_BUG_ACCEPT_ANY_PAYLOAD) && !(rtp_session->rtp_bugs & RTP_BUG_ACCEPT_ANY_PACKETS)) { - /* drop frames of incorrect payload number and return CNG frame instead */ - return_cng_frame(); + (!rtp_session->cng_pt || rtp_session->recv_msg.header.pt != rtp_session->cng_pt)) { + int accept_packet = 0; + + + if (rtp_session->pmaps && *rtp_session->pmaps) { + payload_map_t *pmap; + switch_mutex_lock(rtp_session->flag_mutex); + for (pmap = *rtp_session->pmaps; pmap && pmap->allocated; pmap = pmap->next) { + if (!pmap->negotiated) { + continue; + } + + if (rtp_session->recv_msg.header.pt == pmap->pt) { + accept_packet = 1; + if (pmapP) { + *pmapP = pmap; + } + } + } + switch_mutex_unlock(rtp_session->flag_mutex); + } + + if (!accept_packet && + !(rtp_session->rtp_bugs & RTP_BUG_ACCEPT_ANY_PAYLOAD) && !(rtp_session->rtp_bugs & RTP_BUG_ACCEPT_ANY_PACKETS)) { + /* drop frames of incorrect payload number and return CNG frame instead */ + return_cng_frame(); + } } if (!bytes && (io_flags & SWITCH_IO_FLAG_NOBLOCK)) { @@ -5085,7 +5139,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ if (rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) { #if 0 - if (rtp_session->recv_msg.header.version == 2 && rtp_session->recv_msg.header.pt == rtp_session->rpayload) { + if (rtp_session->recv_msg.header.version == 2 && check_recv_payload(rtp_session)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "Ignoring udptl packet of size of %ld bytes that looks strikingly like a RTP packet.\n", (long)bytes); bytes = 0; @@ -5335,7 +5389,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void return SWITCH_STATUS_FALSE; } - bytes = rtp_common_read(rtp_session, payload_type, flags, io_flags); + bytes = rtp_common_read(rtp_session, payload_type, NULL, flags, io_flags); if (bytes < 0) { *datalen = 0; @@ -5415,7 +5469,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp return SWITCH_STATUS_FALSE; } - bytes = rtp_common_read(rtp_session, &frame->payload, &frame->flags, io_flags); + bytes = rtp_common_read(rtp_session, &frame->payload, &frame->pmap, &frame->flags, io_flags); frame->data = RTP_BODY(rtp_session); frame->packet = &rtp_session->recv_msg; @@ -5504,7 +5558,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_sessi return SWITCH_STATUS_FALSE; } - bytes = rtp_common_read(rtp_session, payload_type, flags, io_flags); + bytes = rtp_common_read(rtp_session, payload_type, NULL, flags, io_flags); *data = RTP_BODY(rtp_session); if (bytes < 0) { @@ -6146,12 +6200,26 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra rtp_session->stats.outbound.packet_count++; } + if (frame->pmap && rtp_session->pmaps && *rtp_session->pmaps && rtp_session->pmap_ttl > 1) { + payload_map_t *pmap; + switch_mutex_lock(rtp_session->flag_mutex); + + for (pmap = *rtp_session->pmaps; pmap; pmap = pmap->next) { + if (pmap->hash == frame->pmap->hash && !strcmp(pmap->iananame, frame->pmap->iananame)) { + payload = pmap->recv_pt; + break; + } + } + switch_mutex_unlock(rtp_session->flag_mutex); + } + if (fwd) { send_msg = frame->packet; len = frame->packetlen; ts = 0; // Trying this based on http://jira.freeswitch.org/browse/MODSOFIA-90 //if (frame->codec && frame->codec->agreed_pt == frame->payload) { + send_msg->header.pt = payload; //} } else { diff --git a/src/switch_utils.c b/src/switch_utils.c index 0eb66f6a1b..12b417b40a 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -114,7 +114,7 @@ SWITCH_DECLARE(switch_status_t) switch_frame_dup(switch_frame_t *orig, switch_fr memcpy(new_frame->data, orig->data, orig->datalen); new_frame->codec = NULL; - + new_frame->pmap = NULL; *clone = new_frame; return SWITCH_STATUS_SUCCESS;