From 7f03b92fe61a824199923c97c7dc463631d9c128 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 4 Apr 2006 04:15:39 +0000 Subject: [PATCH] switch_rtp windows tweaks and type changes. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1026 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_platform.h | 10 +--- src/include/switch_rtp.h | 34 ++++++-------- .../endpoints/mod_dingaling/mod_dingaling.c | 2 +- src/mod/endpoints/mod_exosip/mod_exosip.c | 22 ++++----- src/switch_rtp.c | 46 +++++++++---------- w32/vsnet/FreeSwitchCore.vcproj | 16 +++++-- w32/vsnet/GetLibs.vbs | 25 +++++++++- 7 files changed, 88 insertions(+), 67 deletions(-) diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index f4949d784b..5cf538de8e 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -38,13 +38,6 @@ extern "C" { #endif -#ifdef WIN32 -#include -typedef SOCKET switch_raw_socket_t; -#else -typedef int switch_raw_socket_t; -#endif - #ifdef __ICC #pragma warning (disable:810 869 981 279 1469 188) #endif @@ -67,8 +60,9 @@ typedef int switch_raw_socket_t; * C4204: nonstandard extension used : non-constant aggregate initializer * C4706: assignment within conditional expression * C4055: type cast from data pointer to function pointer (apr carries function pointers as data pointers) + * C4214: nonstandard extension used : bit field types other than int */ -#pragma warning(disable:4152 4054 4100 4142 4200 4204 4706 4055) +#pragma warning(disable:4152 4054 4100 4142 4200 4204 4706 4055 4214) #if (_MSC_VER >= 1400) // VC8+ #ifndef _CRT_SECURE_NO_DEPRECATE diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index 23ef520957..c08654024e 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -55,31 +55,27 @@ typedef void (*switch_rtp_invalid_handler)(switch_rtp *rtp_session, switch_sockaddr_t *from_addr); -switch_rtp *switch_rtp_new(char *rx_ip, - int rx_port, +SWITCH_DECLARE(switch_rtp *)switch_rtp_new(char *rx_ip, + switch_port_t rx_port, char *tx_ip, - int tx_port, + switch_port_t tx_port, int payload, switch_rtp_flag_t flags, const char **err, switch_memory_pool *pool); -void switch_rtp_destroy(switch_rtp **rtp_session); -switch_socket_t *switch_rtp_get_rtp_socket(switch_rtp *rtp_session); -void switch_rtp_set_invald_handler(switch_rtp *rtp_session, switch_rtp_invalid_handler on_invalid); -int switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t datalen, int *payload_type); -int switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, int *payload_type); -int switch_rtp_write(switch_rtp *rtp_session, void *data, int datalen, uint32_t ts); -int switch_rtp_write_payload(switch_rtp *rtp_session, void *data, int datalen, int payload, uint32_t ts, uint32_t mseq); -uint32_t switch_rtp_start(switch_rtp *rtp_session); -uint32_t switch_rtp_get_ssrc(switch_rtp *rtp_session); -void switch_rtp_killread(switch_rtp *rtp_session); -void switch_rtp_set_private(switch_rtp *rtp_session, void *private_data); -void *switch_rtp_get_private(switch_rtp *rtp_session); - - - -#include +SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp **rtp_session); +SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp *rtp_session); +SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp *rtp_session, switch_rtp_invalid_handler on_invalid); +SWITCH_DECLARE(int) switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t datalen, int *payload_type); +SWITCH_DECLARE(int) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, int *payload_type); +SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, int datalen, uint32_t ts); +SWITCH_DECLARE(int) switch_rtp_write_payload(switch_rtp *rtp_session, void *data, int datalen, uint8_t payload, uint32_t ts, uint16_t mseq); +SWITCH_DECLARE(uint32_t) switch_rtp_start(switch_rtp *rtp_session); +SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp *rtp_session); +SWITCH_DECLARE(void) switch_rtp_killread(switch_rtp *rtp_session); +SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp *rtp_session, void *private_data); +SWITCH_DECLARE(void *)switch_rtp_get_private(switch_rtp *rtp_session); #ifdef __cplusplus } diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 1bcde85589..a694a112fc 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -131,7 +131,7 @@ struct private_object { unsigned char out_digit_packet[4]; unsigned int out_digit_sofar; unsigned int out_digit_dur; - unsigned int out_digit_seq; + uint16_t out_digit_seq; int32_t timestamp_send; int32_t timestamp_recv; int32_t timestamp_dtmf; diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.c b/src/mod/endpoints/mod_exosip/mod_exosip.c index b846c3d323..f90a538143 100644 --- a/src/mod/endpoints/mod_exosip/mod_exosip.c +++ b/src/mod/endpoints/mod_exosip/mod_exosip.c @@ -80,8 +80,8 @@ static struct { int bytes_per_frame; char *dialplan; int port; - int rtp_start; - int rtp_end; + switch_port_t rtp_start; + switch_port_t rtp_end; char *codec_string; char *codec_order[SWITCH_MAX_CODECS]; int codec_order_last; @@ -114,9 +114,9 @@ struct private_object { sdp_message_t *remote_sdp; sdp_message_t *local_sdp; char remote_sdp_audio_ip[50]; - int remote_sdp_audio_port; + switch_port_t remote_sdp_audio_port; char local_sdp_audio_ip[50]; - int local_sdp_audio_port; + switch_port_t local_sdp_audio_port; char call_id[50]; int ssrc; char last_digit; @@ -129,13 +129,13 @@ struct private_object { unsigned char out_digit_packet[4]; unsigned int out_digit_sofar; unsigned int out_digit_dur; - unsigned int out_digit_seq; + uint16_t out_digit_seq; }; -static int next_rtp_port(void) +static switch_port_t next_rtp_port(void) { - int port; + switch_port_t port; switch_mutex_lock(globals.port_lock); port = globals.rtp_start; @@ -1176,7 +1176,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) remote_med = eXosip_get_audio_media(remote_sdp); snprintf(tech_pvt->remote_sdp_audio_ip, 50, conn->c_addr); - tech_pvt->remote_sdp_audio_port = atoi(remote_med->m_port); + tech_pvt->remote_sdp_audio_port = (switch_port_t)atoi(remote_med->m_port); snprintf(tech_pvt->call_id, sizeof(tech_pvt->call_id), "%d", event->cid); eXosip_lock(); @@ -1346,7 +1346,7 @@ static void handle_answer(eXosip_event_t * event) remote_med = eXosip_get_audio_media(remote_sdp); /* Grab IP/port */ - tech_pvt->remote_sdp_audio_port = atoi(remote_med->m_port); + tech_pvt->remote_sdp_audio_port = (switch_port_t)atoi(remote_med->m_port); snprintf(tech_pvt->remote_sdp_audio_ip, 50, conn->c_addr); /* Grab codec elements */ @@ -1576,9 +1576,9 @@ static int config_exosip(int reload) globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS); } else if (!strcmp(var, "rtp_min_port")) { - globals.rtp_start = atoi(val); + globals.rtp_start = (switch_port_t)atoi(val); } else if (!strcmp(var, "rtp_max_port")) { - globals.rtp_end = atoi(val); + globals.rtp_end = (switch_port_t)atoi(val); } else if (!strcmp(var, "codec_ms")) { globals.codec_ms = atoi(val); } else if (!strcmp(var, "dtmf_duration")) { diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 124d421a0b..444155e68b 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -73,7 +73,7 @@ struct switch_rtp { rtp_msg_t recv_msg; srtp_ctx_t *recv_ctx; - uint32_t seq; + uint16_t seq; uint32_t payload; switch_rtp_invalid_handler invalid_handler; @@ -98,10 +98,10 @@ static void init_rtp(void) } -switch_rtp *switch_rtp_new(char *rx_ip, - int rx_port, +SWITCH_DECLARE(switch_rtp *)switch_rtp_new(char *rx_ip, + switch_port_t rx_port, char *tx_ip, - int tx_port, + switch_port_t tx_port, int payload, switch_rtp_flag_t flags, const char **err, @@ -176,7 +176,7 @@ switch_rtp *switch_rtp_new(char *rx_ip, rtp_session->send_msg.header.ts = 0; rtp_session->send_msg.header.seq = (uint16_t) rand(); rtp_session->send_msg.header.m = 0; - rtp_session->send_msg.header.pt = htonl(payload); + rtp_session->send_msg.header.pt = (uint8_t)htonl(payload); rtp_session->send_msg.header.version = 2; rtp_session->send_msg.header.p = 0; rtp_session->send_msg.header.x = 0; @@ -187,7 +187,7 @@ switch_rtp *switch_rtp_new(char *rx_ip, rtp_session->recv_msg.header.ts = 0; rtp_session->recv_msg.header.seq = 0; rtp_session->recv_msg.header.m = 0; - rtp_session->recv_msg.header.pt = htonl(payload); + rtp_session->recv_msg.header.pt = (uint8_t)htonl(payload); rtp_session->recv_msg.header.version = 2; rtp_session->recv_msg.header.p = 0; rtp_session->recv_msg.header.x = 0; @@ -201,7 +201,7 @@ switch_rtp *switch_rtp_new(char *rx_ip, return rtp_session; } -void switch_rtp_killread(switch_rtp *rtp_session) +SWITCH_DECLARE(void) switch_rtp_killread(switch_rtp *rtp_session) { apr_socket_shutdown(rtp_session->sock, APR_SHUTDOWN_READWRITE); switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO); @@ -209,7 +209,7 @@ void switch_rtp_killread(switch_rtp *rtp_session) } -void switch_rtp_destroy(switch_rtp **rtp_session) +SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp **rtp_session) { switch_rtp_killread(*rtp_session); @@ -218,19 +218,19 @@ void switch_rtp_destroy(switch_rtp **rtp_session) return; } -switch_socket_t *switch_rtp_get_rtp_socket(switch_rtp *rtp_session) +SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp *rtp_session) { return rtp_session->sock; } -void switch_rtp_set_invald_handler(switch_rtp *rtp_session, switch_rtp_invalid_handler on_invalid) +SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp *rtp_session, switch_rtp_invalid_handler on_invalid) { rtp_session->invalid_handler = on_invalid; } -int switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t datalen, int *payload_type) +SWITCH_DECLARE(int) switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t datalen, int *payload_type) { - switch_size_t bytes; + uint32_t bytes; if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) { return -1; @@ -257,9 +257,9 @@ int switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t datalen, int * } -int switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, int *payload_type) +SWITCH_DECLARE(int) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, int *payload_type) { - switch_size_t bytes; + uint32_t bytes; *data = NULL; if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) { @@ -285,7 +285,7 @@ int switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, int *payload_ return bytes - rtp_header_len; } -int switch_rtp_write(switch_rtp *rtp_session, void *data, int datalen, uint32_t ts) +SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, int datalen, uint32_t ts) { switch_size_t bytes; @@ -304,10 +304,10 @@ int switch_rtp_write(switch_rtp *rtp_session, void *data, int datalen, uint32_t bytes = datalen + rtp_header_len; switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)&rtp_session->send_msg, &bytes); - return bytes; + return (int)bytes; } -int switch_rtp_write_payload(switch_rtp *rtp_session, void *data, int datalen, int payload, uint32_t ts, uint32_t mseq) +SWITCH_DECLARE(int) switch_rtp_write_payload(switch_rtp *rtp_session, void *data, int datalen, uint8_t payload, uint32_t ts, uint16_t mseq) { switch_size_t bytes; @@ -317,32 +317,32 @@ int switch_rtp_write_payload(switch_rtp *rtp_session, void *data, int datalen, i rtp_session->ts += ts; rtp_session->send_msg.header.seq = htons(mseq); rtp_session->send_msg.header.ts = htonl(rtp_session->ts); - rtp_session->send_msg.header.pt = htonl(payload); + rtp_session->send_msg.header.pt = (uint8_t)htonl(payload); memcpy(rtp_session->send_msg.body, data, datalen); bytes = datalen + rtp_header_len; switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)&rtp_session->send_msg, &bytes); - return bytes; + return (int)bytes; } -uint32_t switch_rtp_start(switch_rtp *rtp_session) +SWITCH_DECLARE(uint32_t) switch_rtp_start(switch_rtp *rtp_session) { switch_set_flag(rtp_session, SWITCH_RTP_FLAG_IO); return 0; } -uint32_t switch_rtp_get_ssrc(switch_rtp *rtp_session) +SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp *rtp_session) { return rtp_session->send_msg.header.ssrc; } -void switch_rtp_set_private(switch_rtp *rtp_session, void *private_data) +SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp *rtp_session, void *private_data) { rtp_session->private_data = private_data; } -void *switch_rtp_get_private(switch_rtp *rtp_session) +SWITCH_DECLARE(void *)switch_rtp_get_private(switch_rtp *rtp_session) { return rtp_session->private_data; } diff --git a/w32/vsnet/FreeSwitchCore.vcproj b/w32/vsnet/FreeSwitchCore.vcproj index d868aacfc9..5b69721847 100644 --- a/w32/vsnet/FreeSwitchCore.vcproj +++ b/w32/vsnet/FreeSwitchCore.vcproj @@ -64,10 +64,10 @@ /> + + @@ -305,6 +309,10 @@ RelativePath="..\..\src\include\switch_resample.h" > + + diff --git a/w32/vsnet/GetLibs.vbs b/w32/vsnet/GetLibs.vbs index 87eafc009b..1582fae28b 100644 --- a/w32/vsnet/GetLibs.vbs +++ b/w32/vsnet/GetLibs.vbs @@ -162,6 +162,9 @@ If BuildCore Then FSO.CopyFile LibDestDir & "libresample\include\*.h", LibDestDir & "include" BuildLibs_sqlite BuildDebug, BuildRelease FSO.CopyFile LibDestDir & "sqlite\*.h", LibDestDir & "include" + BuildLibs_srtp BuildDebug, BuildRelease + FSO.CopyFile LibDestDir & "srtp\include\*.h", LibDestDir & "include" + FSO.CopyFile LibDestDir & "srtp\crypto\include\*.h", LibDestDir & "include" End If If BuildModzeroconf Then @@ -257,7 +260,7 @@ Sub BuildLibs_aprutil(BuildDebug, BuildRelease) End If End If If BuildRelease Then - If Not FSO.FileExists(LibDestDir & "apr-util\xml\expat\lib\LibR

\xml.lib") Then + If Not FSO.FileExists(LibDestDir & "apr-util\xml\expat\lib\LibR\xml.lib") Then BuildViaVCBuild LibDestDir & "apr-util\xml\expat\lib\xml.vcproj", "Release" End If If Not FSO.FileExists(LibDestDir & "apr-util\Release\libaprutil-1.lib") Then @@ -387,6 +390,26 @@ Sub BuildLibs_libosip2(BuildDebug, BuildRelease) End If End Sub +Sub BuildLibs_srtp(BuildDebug, BuildRelease) + If Not FSO.FolderExists(LibDestDir & "srtp") Then + WgetUnCompress LibsBase & "srtp.zip", LibDestDir + End If + If FSO.FolderExists(LibDestDir & "srtp") Then + If BuildDebug Then + If Not FSO.FileExists(LibDestDir & "srtp\Debug\srtp.lib") Then + BuildViaVCBuild LibDestDir & "srtp\srtp.vcproj", "Debug" + End If + End If + If BuildRelease Then + If Not FSO.FileExists(LibDestDir & "srtp\Release\srtp.lib") Then + BuildViaVCBuild LibDestDir & "srtp\srtp.vcproj", "Release" + End If + End If + Else + Wscript.echo "Unable to download srtp" + End If +End Sub + Sub BuildLibs_jrtplib(BuildDebug, BuildRelease) If FSO.FolderExists(LibDestDir & "jrtplib")Then