]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweaks and fixes
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 15 Mar 2006 22:11:13 +0000 (22:11 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 15 Mar 2006 22:11:13 +0000 (22:11 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@859 d0543943-73ff-0310-b7d9-9358b9ac24b2

16 files changed:
libs/jrtplib/src/jrtp4c.cpp
libs/jrtplib/src/jrtp4c.h
libs/jrtplib/src/rtpconfig.h
libs/jrtplib/src/rtpconfig_win.h
libs/jrtplib/src/rtperrors.cpp
libs/jrtplib/src/rtperrors.h
libs/jrtplib/src/rtppacket.cpp
libs/jrtplib/src/rtpsession.cpp
libs/jrtplib/src/rtpsession.h
libs/jrtplib/src/rtptransmitter.h
libs/jrtplib/src/rtpudpv4transmitter.cpp
libs/jrtplib/src/rtpudpv4transmitter.h
src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
src/switch_ivr.c

index 518a18ef42630133ea4b001d089f60518ed95b4a..d3530ebb1b70f74c32513b6c69ba275a543ae5cd 100644 (file)
@@ -15,162 +15,203 @@ static int WSOCKON = 0;
 #ifdef __cplusplus
 extern "C" {
 #endif
+#ifdef _FORMATBUG
+}
+#endif
+
+struct jrtp4c;
+
+class JRTP4C: public RTPSession  {
+       // add virtuals later 
+public:
+       JRTP4C(): RTPSession() { }
+       void OnInvalidRawPacketType(RTPRawPacket *rawpacket, jrtp_socket_t socket);
+       struct jrtp4c *myjrtp4c;
+};
+
+struct jrtp4c {
+       JRTP4C *session;
+       RTPUDPv4TransmissionParams *transparams;
+       uint32_t ssrc;
+       int payload;
+       invalid_handler on_invalid;
+       void *private_data;
+};
+
+void JRTP4C::OnInvalidRawPacketType(RTPRawPacket *rawpacket, jrtp_socket_t socket)     
+{ 
+       void * data = rawpacket->GetData();
+       unsigned int len = rawpacket->GetDataLength();
+       const RTPAddress *addr = rawpacket->GetSenderAddress();
+       const RTPIPv4Address *Sender = (const RTPIPv4Address *)addr;
+       
+       if (myjrtp4c->on_invalid) {
+               myjrtp4c->on_invalid(myjrtp4c, socket, data, len, ntohl(Sender->GetIP()), ntohs(Sender->GetPort()));
+       }
+}
+
+
+void jrtp4c_set_private(struct jrtp4c *jrtp4c, void *private_data)
+{
+       jrtp4c->private_data = private_data;
+}
+
+void *jrtp4c_get_private(struct jrtp4c *jrtp4c)
+{
+       return jrtp4c->private_data;
+}
 
-       class JRTP4C: public RTPSession  {
-               // add virtuals later 
-       public:
-               JRTP4C(): RTPSession() {}
-       };
-
-       struct jrtp4c {
-               JRTP4C *session;
-               RTPUDPv4TransmissionParams *transparams;
-               uint32_t ssrc;
-               int payload;
-       };
-
-       struct jrtp4c *jrtp4c_new(char *rx_ip, int rx_port, char *tx_ip, int tx_port, int payload, int sps, const char **err)
-       {
-               struct jrtp4c *jrtp4c = NULL;
-               uint32_t destip =  ntohl(inet_addr(tx_ip));
-               uint32_t srcip;
-               RTPIPv4Address addr(destip, tx_port);
-               RTPSessionParams sessparams;
-               int status;
+struct jrtp4c *jrtp4c_new(char *rx_ip, int rx_port, char *tx_ip, int tx_port, int payload, int sps, const char **err)
+{
+       struct jrtp4c *jrtp4c = NULL;
+       uint32_t destip =  ntohl(inet_addr(tx_ip));
+       uint32_t srcip;
+       RTPIPv4Address addr(destip, tx_port);
+       RTPSessionParams sessparams;
+       int status;
                
 #ifdef WIN32
-               if (!WSOCKON) {
-                       WSADATA dat;
-                       WSAStartup(MAKEWORD(2,2),&dat);
-                       WSOCKON = 1;
-               }
+       if (!WSOCKON) {
+               WSADATA dat;
+               WSAStartup(MAKEWORD(2,2),&dat);
+               WSOCKON = 1;
+       }
 #endif // WIN32
 
-               sessparams.SetOwnTimestampUnit(1.0/sps);                
-               //sessparams.SetAcceptOwnPackets(true);
+       sessparams.SetOwnTimestampUnit(1.0/sps);                
+       //sessparams.SetAcceptOwnPackets(true);
 
-               if (!(jrtp4c = new struct jrtp4c)) {
-                       *err = "Memory Error!\n";
-                       memset(jrtp4c, 0, sizeof(*jrtp4c));
-                       return NULL;
-               }
+       if (!(jrtp4c = new struct jrtp4c)) {
+               *err = "Memory Error!\n";
+               return NULL;
+       }
 
-               if (!(jrtp4c->transparams = new RTPUDPv4TransmissionParams)) {
-                       delete jrtp4c;
-                       *err = "Memory Error!\n";
-                       return NULL;
-               }
+       memset(jrtp4c, 0, sizeof(*jrtp4c));
 
+       if (!(jrtp4c->transparams = new RTPUDPv4TransmissionParams)) {
+               delete jrtp4c;
+               *err = "Memory Error!\n";
+               return NULL;
+       }
 
-               if (rx_ip) {
-                       srcip = ntohl(inet_addr(rx_ip));
-                       jrtp4c->transparams->SetBindIP(srcip);
-               }
 
-               jrtp4c->transparams->SetPortbase(rx_port);
+       if (rx_ip) {
+               srcip = ntohl(inet_addr(rx_ip));
+               jrtp4c->transparams->SetBindIP(srcip);
+       }
 
+       jrtp4c->transparams->SetPortbase(rx_port);
 
-               
+       if (!(jrtp4c->session = new JRTP4C)) {
+               *err = "Memory Error!\n";
+               delete jrtp4c->transparams;
+               delete jrtp4c;
+               return NULL;
+       }
 
-               if (!(jrtp4c->session = new JRTP4C)) {
-                       *err = "Memory Error!\n";
-                       delete jrtp4c->transparams;
-            delete jrtp4c;
-            return NULL;
-               }
+       if ((status = jrtp4c->session->Create(sessparams, jrtp4c->transparams)) < 0) {
+               *err = RTPGetErrorString(status).c_str();
+               delete jrtp4c->transparams;
+               delete jrtp4c;
+               return NULL;
+       }
 
-               if ((status = jrtp4c->session->Create(sessparams, jrtp4c->transparams)) < 0) {
-                       *err = RTPGetErrorString(status).c_str();
-                       delete jrtp4c->transparams;
-                       delete jrtp4c;
-                       return NULL;
-               }
+       if ((status = jrtp4c->session->AddDestination(addr)) < 0) {
+               *err = RTPGetErrorString(status).c_str();
+               jrtp4c_destroy(&jrtp4c);
+               return NULL;
+       }
 
+       jrtp4c->session->SetDefaultPayloadType(payload);                
+       jrtp4c->payload = payload;
+       jrtp4c->session->myjrtp4c = jrtp4c;
+       return jrtp4c;
+}
 
-               if ((status = jrtp4c->session->AddDestination(addr)) < 0) {
-                       *err = RTPGetErrorString(status).c_str();
-                       jrtp4c_destroy(&jrtp4c);
-                       return NULL;
-               }
+void jrtp4c_destroy(struct jrtp4c **jrtp4c)
+{
+       (*jrtp4c)->session->BYEDestroy(RTPTime(10,0),0,0);
+       delete (*jrtp4c)->session;
+       delete (*jrtp4c)->transparams;
+       delete (*jrtp4c);
+       *jrtp4c = NULL;
+}
 
-               jrtp4c->session->SetDefaultPayloadType(payload);                
-               jrtp4c->payload = payload;
-               return jrtp4c;
-       }
 
-       void jrtp4c_destroy(struct jrtp4c **jrtp4c)
-       {
-               (*jrtp4c)->session->BYEDestroy(RTPTime(10,0),0,0);
-               delete (*jrtp4c)->session;
-               delete (*jrtp4c)->transparams;
-               delete (*jrtp4c);
-               *jrtp4c = NULL;
-       }
+void jrtp4c_set_invald_handler(struct jrtp4c *jrtp4c, invalid_handler on_invalid)
+{
+       jrtp4c->on_invalid = on_invalid;
+}
 
+jrtp_socket_t jrtp4c_get_rtp_socket(struct jrtp4c *jrtp4c)
+{
 
-       void jrtp4c_killread(struct jrtp4c *jrtp4c)
-       {
-               jrtp4c->session->AbortWait();
-       }
+       return jrtp4c->session->GetRTPSocket();
+}
 
-       int jrtp4c_read(struct jrtp4c *jrtp4c, void *data, int datalen, int *payload_type)
-       {
-               RTPPacket *pack;
-               int slen = 0;
-               bool hasdata = 0;
+void jrtp4c_killread(struct jrtp4c *jrtp4c)
+{
+       jrtp4c->session->AbortWait();
+}
 
-               *payload_type = 0;
+int jrtp4c_read(struct jrtp4c *jrtp4c, void *data, int datalen, int *payload_type)
+{
+       RTPPacket *pack;
+       int slen = 0;
+       bool hasdata = 0;
 
-               jrtp4c->session->BeginDataAccess();
+       *payload_type = 0;
 
-               jrtp4c->session->WaitForIncomingData(RTPTime(.5), &hasdata);
+       jrtp4c->session->BeginDataAccess();
 
-               if (!jrtp4c->session->GotoFirstSourceWithData()) {
-                       jrtp4c->session->EndDataAccess();
-                       return 0;
-               }
+       jrtp4c->session->WaitForIncomingData(RTPTime(.5), &hasdata);
+
+       if (!jrtp4c->session->GotoFirstSourceWithData()) {
+               jrtp4c->session->EndDataAccess();
+               return 0;
+       }
 
                
-               if ((pack = jrtp4c->session->GetNextPacket())) {
-                       slen = pack->GetPayloadLength();
+       if ((pack = jrtp4c->session->GetNextPacket())) {
+               slen = pack->GetPayloadLength();
 
-                       if (slen > datalen) {
-                               slen = datalen;
-                       }
+               if (slen > datalen) {
+                       slen = datalen;
+               }
 
                
-                       *payload_type = pack->GetPayloadType();
+               *payload_type = pack->GetPayloadType();
 
-                       memcpy(data, pack->GetPayloadData(), slen);
+               memcpy(data, pack->GetPayloadData(), slen);
 
-                       delete pack;
-               }
-               jrtp4c->session->EndDataAccess();
+               delete pack;
+       }
+       jrtp4c->session->EndDataAccess();
 
-               return slen;
+       return slen;
 
-       }
+}
 
-       int jrtp4c_write(struct jrtp4c *jrtp4c, void *data, int datalen, uint32_t ts)
-       {
-               return jrtp4c->session->SendPacket(data, datalen, jrtp4c->payload, false, ts);
-       }
+int jrtp4c_write(struct jrtp4c *jrtp4c, void *data, int datalen, uint32_t ts)
+{
+       return jrtp4c->session->SendPacket(data, datalen, jrtp4c->payload, false, ts);
+}
 
-       int jrtp4c_write_payload(struct jrtp4c *jrtp4c, void *data, int datalen, int payload, uint32_t ts, uint32_t mseq)
-       {
-               return jrtp4c->session->SendPacket(data, datalen, payload, false, ts, mseq);
-       }
+int jrtp4c_write_payload(struct jrtp4c *jrtp4c, void *data, int datalen, int payload, uint32_t ts, uint32_t mseq)
+{
+       return jrtp4c->session->SendPacket(data, datalen, payload, false, ts, mseq);
+}
 
-       uint32_t jrtp4c_start(struct jrtp4c *jrtp4c)
-       {
-               //jrtp4c->session->BeginDataAccess();
-               return 0;
-       }
+uint32_t jrtp4c_start(struct jrtp4c *jrtp4c)
+{
+       //jrtp4c->session->BeginDataAccess();
+       return 0;
+}
 
-       uint32_t jrtp4c_get_ssrc(struct jrtp4c *jrtp4c)
-       {
-               return jrtp4c->ssrc;
-       }
+uint32_t jrtp4c_get_ssrc(struct jrtp4c *jrtp4c)
+{
+       return jrtp4c->ssrc;
+}
 
 #ifdef __cplusplus
 }
index e4de89f9ea64016abe35e92da74621467f0cd6ca..5064e269523c639fade54846c6a57b2a927833e2 100644 (file)
@@ -9,6 +9,7 @@
 #ifdef __cplusplus
 #include <rtpsession.h>
 #include <rtppacket.h>
+#include <rtprawpacket.h>
 #include <rtpudpv4transmitter.h>
 #include <rtpipv4address.h>
 #include <rtpsessionparams.h>
 
 extern "C" {
 #endif
+#ifdef _FORMABUG
+}
+#endif
 
-       typedef enum {
-               SR,
-               RR,
-               SDES,
-               BYE,
-               APP,
-               UNK
-       } jrtp4c_packet_t;
+typedef enum {
+       SR,
+       RR,
+       SDES,
+       BYE,
+       APP,
+       UNK
+} jrtp4c_packet_t;
 
 #ifndef uint32_t
 #ifdef WIN32
-       typedef unsigned int uint32_t;
+typedef unsigned int uint32_t;
 #else
 #include <stdint.h>
 #endif
 #endif
+#ifdef WIN32
+typedef SOCKET jrtp_sock_t;
+#else 
+typedef int jrtp_socket_t;
+#endif 
+
+
 
-       struct jrtp4c;
-       struct jrtp4c *jrtp4c_new(char *rx_ip, int rx_port, char *tx_ip, int tx_port, int payload, int sps, const char **err);
-       void jrtp4c_destroy(struct jrtp4c **jrtp4c);
-       int jrtp4c_read(struct jrtp4c *jrtp4c, void *data, int datalen, int *payload_type);
-       int jrtp4c_write(struct jrtp4c *jrtp4c, void *data, int datalen, uint32_t ts);
-       int jrtp4c_write_payload(struct jrtp4c *jrtp4c, void *data, int datalen, int payload, uint32_t ts, uint32_t mseq);
-       uint32_t jrtp4c_start(struct jrtp4c *jrtp4c);
-       uint32_t jrtp4c_get_ssrc(struct jrtp4c *jrtp4c);
-       void jrtp4c_killread(struct jrtp4c *jrtp4c);
+struct jrtp4c;
+typedef void (*invalid_handler)(struct jrtp4c *jrtp4c, jrtp_socket_t sock, void *data, unsigned int datalen, uint32_t fromip, uint16_t fromport);
+struct jrtp4c *jrtp4c_new(char *rx_ip, int rx_port, char *tx_ip, int tx_port, int payload, int sps, const char **err);
+void jrtp4c_destroy(struct jrtp4c **jrtp4c);
+jrtp_socket_t jrtp4c_get_rtp_socket(struct jrtp4c *jrtp4c);
+void jrtp4c_set_invald_handler(struct jrtp4c *jrtp4c, invalid_handler on_invalid);
+int jrtp4c_read(struct jrtp4c *jrtp4c, void *data, int datalen, int *payload_type);
+int jrtp4c_write(struct jrtp4c *jrtp4c, void *data, int datalen, uint32_t ts);
+int jrtp4c_write_payload(struct jrtp4c *jrtp4c, void *data, int datalen, int payload, uint32_t ts, uint32_t mseq);
+uint32_t jrtp4c_start(struct jrtp4c *jrtp4c);
+uint32_t jrtp4c_get_ssrc(struct jrtp4c *jrtp4c);
+void jrtp4c_killread(struct jrtp4c *jrtp4c);
+void jrtp4c_set_private(struct jrtp4c *jrtp4c, void *private_data);
+void *jrtp4c_get_private(struct jrtp4c *jrtp4c);
 #ifdef __cplusplus
 }
 #endif
index 5a52ec43fea8b3dd0fbe5f11ceaf684fa1beb941..eb2eaad39d06c75355e57aa81fd0117e503ee09d 100644 (file)
 #define RTPCONFIG_H
 
 #if (defined(WIN32) || defined(_WIN32_WCE))
+typedef SOCKET jrtp_socket_t;
 #include "rtpconfig_win.h"
 #else
+typedef int jrtp_socket_t;
 #include "rtpconfig_unix.h"
 #endif // WIN32
 
index 20883042a7b47dbd683759f12606b61de6715f9c..edd8b2c4a736b39f85c361a53b96d0b8a8c5c026 100644 (file)
@@ -47,4 +47,3 @@
 //#define RTP_SUPPORT_IPV6MULTICAST
 
 #endif // RTPCONFIG_WIN_H
-
index ec414288effd84bf1859efa19297b5afc86034cf..67cec3bad7d50740e9aee4c2da83bbc981d26a6b 100644 (file)
@@ -201,6 +201,7 @@ static RTPErrorInfo ErrorDescriptions[]=
        { ERR_RTP_GSTV4TRANS_SRCADDRNOTSET, "Got packet but src address information was not set, returning"},
        { ERR_RTP_GSTV4TRANS_NOTNETBUFFER, "Received buffer is not a GstNetBuffer"},
        { ERR_RTP_GSTV4TRANS_WAITNOTIMPLEMENTED, "The WaitForIncomingData is not implemented in the Gst transmitter"},
+       { ERR_RTP_INVALID_PACKET_VERISON, "The packet is not the correct version of RTP"},
        { 0,0 }
 };
 
index 9242e073664b2eeb72df080ab7b19041d0a7be96..ddad1d12d7694538be505dd9f781597270d04140 100644 (file)
@@ -197,6 +197,6 @@ std::string RTPGetErrorString(int errcode);
 #define ERR_RTP_GSTV4TRANS_SRCADDRNOTSET                       -157
 #define ERR_RTP_GSTV4TRANS_NOTNETBUFFER                        -158
 #define ERR_RTP_GSTV4TRANS_WAITNOTIMPLEMENTED                  -159
-
+#define ERR_RTP_INVALID_PACKET_VERISON                                 -160
 #endif // RTPERRORS_H
 
index 1c1a1178500fbb2a62bbfee9dd14150ef1d30fc6..4310a70fe6722205551317b6b41404801d79a127 100644 (file)
@@ -113,16 +113,17 @@ int RTPPacket::ParseRawPacket(RTPRawPacket &rawpack)
        if (!rawpack.IsRTP()) // If we didn't receive it on the RTP port, we'll ignore it
                return ERR_RTP_PACKET_INVALIDPACKET;
        
-       // The length should be at least the size of the RTP header
-       packetlen = rawpack.GetDataLength();
-       if (packetlen < sizeof(RTPHeader))
-               return ERR_RTP_PACKET_INVALIDPACKET;
-       
        packetbytes = (u_int8_t *)rawpack.GetData();
        rtpheader = (RTPHeader *)packetbytes;
        
+
        // The version number should be correct
-       if (rtpheader->version != RTP_VERSION)
+       if (rtpheader->version != RTP_VERSION) {
+               return ERR_RTP_INVALID_PACKET_VERISON;
+       }
+       // The length should be at least the size of the RTP header
+       packetlen = rawpack.GetDataLength();
+       if (packetlen < sizeof(RTPHeader))
                return ERR_RTP_PACKET_INVALIDPACKET;
        
        // We'll check if this is possibly a RTCP packet. For this to be possible
index ec9645317a4392043839e75f14920d33751bdfbd..41386cf949b544681655d8bdd14922b5995154b2 100644 (file)
@@ -1026,6 +1026,15 @@ int RTPSession::SetLocalNote(const void *s,size_t len)
        return status;
 }
 
+#if ! (defined(WIN32) || defined(_WIN32_WCE))
+int RTPSession::GetRTPSocket(void)
+#else
+SOCKET RTPSession::GetRTPSocket(void)
+#endif // WIN32
+{
+       return rtptrans->GetRTPSocket();
+}
+
 int RTPSession::ProcessPolledData()
 {
        RTPRawPacket *rawpack;
@@ -1039,15 +1048,23 @@ int RTPSession::ProcessPolledData()
                // since our sources instance also uses the scheduler (analysis of incoming packets)
                // we'll lock it
                SCHED_LOCK
-               if ((status = sources.ProcessRawPacket(rawpack,rtptrans,acceptownpackets)) < 0)
-               {
+
+
+               status = sources.ProcessRawPacket(rawpack,rtptrans,acceptownpackets);
+               if (status == ERR_RTP_INVALID_PACKET_VERISON) {
+                       OnInvalidRawPacketType(rawpack, rtptrans->GetRTPSocket());
+                       status = 0;
+               }
+
+               if (status < 0)
+                       {
                        SCHED_UNLOCK
                        SOURCES_UNLOCK
                        delete rawpack;
                        return status;
                }
                SCHED_UNLOCK
-                               
+
                if (sources.DetectedOwnCollision()) // collision handling!
                {
                        bool created;
index 274bb73c3eb04132da3f6c98d7de8c7020bcfc7c..683577f23838bd11f2341c6bbe74ab4acb4604b2 100644 (file)
@@ -143,6 +143,11 @@ public:
        int SetLocalPhone(const void *s,size_t len);
        int SetLocalTool(const void *s,size_t len);
        int SetLocalNote(const void *s,size_t len);
+#if ! (defined(WIN32) || defined(_WIN32_WCE))
+       int GetRTPSocket(void);
+#else
+       SOCKET GetRTPSocket(void); 
+#endif // WIN32
 
 #ifdef RTPDEBUG
        void DumpSources();
@@ -168,8 +173,15 @@ protected:
                                         const RTPAddress *senderaddress)                               { }
        virtual void OnUnknownPacketFormat(RTCPPacket *rtcppack,const RTPTime &receivetime,
                                           const RTPAddress *senderaddress)                             { }
+#if (defined(WIN32) || defined(_WIN32_WCE))
+       virtual void OnInvalidRawPacketType(RTPRawPacket *rawpacket, SOCKET socket)     { }
+#else
+       virtual void OnInvalidRawPacketType(RTPRawPacket *rawpacket, int socket)        { }
+#endif
        virtual void OnNoteTimeout(RTPSourceData *srcdat)                                               { }
        virtual void OnBYEPacket(RTPSourceData *srcdat)                                                 { }
+
+       
 #ifdef RTP_SUPPORT_THREAD
        virtual void OnPollThreadError(int errcode)                                                     { }
        virtual void OnPollThreadStep()                                                                 { }
index 9e6f70ab4322619f600502cb264015c7b5a88c40..075c9778035652998d7e54f1e0e5cecee0e052b0 100644 (file)
@@ -61,6 +61,9 @@ public:
        virtual int Create(size_t maxpacksize,const RTPTransmissionParams *transparams) = 0;
        virtual void Destroy() = 0;
 
+       virtual jrtp_socket_t GetRTPSocket() {}
+       virtual jrtp_socket_t GetRTCPSocket() {}
+
        // The user MUST delete the returned instance when it is no longer needed
        virtual RTPTransmissionInfo *GetTransmissionInfo() = 0;
 
@@ -108,6 +111,7 @@ public:
        
        virtual bool NewDataAvailable() = 0;
        virtual RTPRawPacket *GetNextPacket() = 0;
+
 #ifdef RTPDEBUG
        virtual void Dump() = 0;
 #endif // RTPDEBUG
index 5e9ef6047c29711d1280bdb37d6f89a36aa7bf96..c2aa113345a5c351d71523531264ac0d75da977c 100644 (file)
@@ -673,6 +673,17 @@ int RTPUDPv4Transmitter::AbortWait()
        return 0;
 }
 
+jrtp_socket_t RTPUDPv4Transmitter::GetRTPSocket()
+{
+       return rtpsock;
+}
+
+jrtp_socket_t RTPUDPv4Transmitter::GetRTCPSocket()
+{
+       return rtcpsock;
+}
+
+
 int RTPUDPv4Transmitter::SendRTPData(const void *data,size_t len)      
 {
        if (!init)
index 2d8eee83c5d9e69f86b2bf05b309a2c79f917d91..efe46652d7eaa96d2d64639d27e470ce5e97d9aa 100644 (file)
@@ -71,29 +71,16 @@ private:
 class RTPUDPv4TransmissionInfo : public RTPTransmissionInfo
 {
 public:
-#if ! (defined(WIN32) || defined(_WIN32_WCE))
-       RTPUDPv4TransmissionInfo(std::list<u_int32_t> iplist,int rtpsock,int rtcpsock) : RTPTransmissionInfo(RTPTransmitter::IPv4UDPProto) 
-#else
-       RTPUDPv4TransmissionInfo(std::list<u_int32_t> iplist,SOCKET rtpsock,SOCKET rtcpsock) : RTPTransmissionInfo(RTPTransmitter::IPv4UDPProto) 
-#endif  // WIN32
-                                                                                               { localIPlist = iplist; rtpsocket = rtpsock; rtcpsocket = rtcpsock; }
+
+       RTPUDPv4TransmissionInfo(std::list<u_int32_t> iplist,jrtp_socket_t rtpsock,jrtp_socket_t rtcpsock) : RTPTransmissionInfo(RTPTransmitter::IPv4UDPProto) 
+               { localIPlist = iplist; rtpsocket = rtpsock; rtcpsocket = rtcpsock; }
 
        ~RTPUDPv4TransmissionInfo()                                                             { }
        std::list<u_int32_t> GetLocalIPList() const                                             { return localIPlist; }
-#if ! (defined(WIN32) || defined(_WIN32_WCE))
-       int GetRTPSocket() const                                                                { return rtpsocket; }
-       int GetRTCPSocket() const                                                               { return rtcpsocket; }
-#else
-       SOCKET GetRTPSocket() const                                                             { return rtpsocket; }
-       SOCKET GetRTCPSocket() const                                                            { return rtcpsocket; }
-#endif // WIN32
+
 private:
        std::list<u_int32_t> localIPlist;
-#if ! (defined(WIN32) || defined(_WIN32_WCE))
-       int rtpsocket,rtcpsocket;
-#else
-       SOCKET rtpsocket,rtcpsocket;
-#endif // WIN32
+       jrtp_socket_t rtpsocket,rtcpsocket;
 };
        
 #ifdef RTP_SUPPORT_INLINETEMPLATEPARAM
@@ -112,6 +99,8 @@ public:
        RTPUDPv4Transmitter();
        ~RTPUDPv4Transmitter();
 
+       jrtp_socket_t RTPUDPv4Transmitter::GetRTPSocket();
+       jrtp_socket_t RTPUDPv4Transmitter::GetRTCPSocket();
        int Init(bool treadsafe);
        int Create(size_t maxpacksize,const RTPTransmissionParams *transparams);
        void Destroy();
@@ -173,11 +162,7 @@ private:
        bool init;
        bool created;
        bool waitingfordata;
-#if (defined(WIN32) || defined(_WIN32_WCE))
-       SOCKET rtpsock,rtcpsock;
-#else // not using winsock
-       int rtpsock,rtcpsock;
-#endif // WIN32
+       jrtp_socket_t rtpsock,rtcpsock;
        u_int32_t bindIP;
        std::list<u_int32_t> localIPs;
        u_int16_t portbase;
@@ -208,11 +193,7 @@ private:
        RTPKeyHashTable<const u_int32_t,PortInfo*,RTPUDPv4Trans_GetHashIndex_u_int32_t,RTPUDPV4TRANS_HASHSIZE> acceptignoreinfo;
 
        // notification descriptors for AbortWait (0 is for reading, 1 for writing)
-#if (defined(WIN32) || defined(_WIN32_WCE))
-       SOCKET abortdesc[2];
-#else
-       int abortdesc[2];
-#endif // WIN32
+       jrtp_socket_t abortdesc[2];
        int CreateAbortDescriptors();
        void DestroyAbortDescriptors();
        void AbortWaitInternal();
index 9d68075c6204e2fc4ada045f173ec76b8ea17470..906244023254f17f1dca05c664c13d7a5e1c67b6 100644 (file)
@@ -1037,7 +1037,7 @@ static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
        }
        
        if ((fd = sangoma_create_socket_intr(spri->span, event->restart.channel)) < 0) {
-               switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't open fd!\n");
+               switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't open fd [%s]!\n", strerror(errno));
        } else {
                close(fd);
        }
index 4dc52b3dc858ad4df8193b0399e0442f36448ac5..d63b5149bffa5cdc6a987be5f285c2cbb74f67c5 100644 (file)
@@ -83,7 +83,7 @@ static void event_handler(switch_event *event)
                msg = iks_make_msg(IKS_TYPE_NONE, globals.target_jid, buf);
                iks_insert_attrib(msg, "subject", "Event");
                iks_send(globals.session.parser, msg);
-
+               iks_delete(msg);
                break;
        }
 }
index f1dc72ab19ab9ea2a46e21e1bab8c4bda78efaac..0b4cf3f154db72b206489a8dfbf1c94537238567 100644 (file)
@@ -491,6 +491,7 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
        char *voice_name = NULL;
        char *text = NULL;
        char *dtmf_callback = NULL;
+       char *timer_name = NULL;
        switch_codec *codec;
        void *bp = NULL;
        int len = 0;
@@ -524,6 +525,10 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
                }
        }
 
+       if (argc > 4) {
+               timer_name = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
+       }
+
        if (!tts_name && text) {
                return JS_FALSE;
        }
@@ -532,7 +537,7 @@ static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
        switch_ivr_speak_text(jss->session,
                                                  tts_name,
                                                  voice_name && strlen(voice_name) ? voice_name : NULL, 
-                                                 NULL,
+                                                 timer_name,
                                                  codec->implementation->samples_per_second,
                                                  dtmf_func,
                                                  text,
index ea2b21b52dd464bc4feb3a7da4f5d57d3d5ed8ac..a6cab30b77924e4cbd47bd893d3db7795b63cf27 100644 (file)
@@ -893,25 +893,35 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
        switch_channel_add_state_handler(caller_channel, &audio_bridge_caller_state_handlers);
        switch_channel_add_state_handler(peer_channel, &audio_bridge_peer_state_handlers);
        switch_core_session_thread_launch(peer_session);
-
+       time(&start);
 
        for (;;) {
                int state = switch_channel_get_state(peer_channel);
                if (state > CS_RING) {
                        break;
                }
+               
+               if (!switch_channel_ready(caller_channel)) {
+                       break;
+               }
+               
+               if ((time(NULL) - start) > timelimit) {
+                       break;
+               }
                switch_yield(1000);
        }
 
        switch_channel_pre_answer(caller_channel);
        
-       time(&start);
+
        while (switch_channel_ready(caller_channel) &&
                   switch_channel_ready(peer_channel) &&
                   !switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
                   !switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) &&
                   ((time(NULL) - start) < timelimit)) {
 
+
+
                /* read from the channel while we wait if the audio is up on it */
                if (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
                        if (switch_core_session_read_frame(session, &read_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {