mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-25 20:54:15 +00:00
revert
This commit is contained in:
1 parent
42bf44de51
commit
cc351ca004
15 files changed
+2007
-1836
No files matched your search
@@ -1,7 +1,19 @@
|
||||
BASE=../../../..
|
||||
LOCAL_INSERT_CFLAGS= pkg-config opal --cflags
|
||||
LOCAL_CFLAGS+=-g -ggdb -I.
|
||||
LOCAL_INSERT_LDFLAGS= pkg-config opal --libs
|
||||
|
||||
PKG_DIR:=/usr/local/lib/pkgconfig
|
||||
ifeq ($(PKG_CONFIG_PATH),)
|
||||
export PKG_CONFIG_PATH:=$(PKG_DIR)
|
||||
else
|
||||
ifeq ($(findstring $(PKG_DIR),$(PKG_CONFIG_PATH)),)
|
||||
export PKG_CONFIG_PATH:=$(PKG_CONFIG_PATH):$(PKG_DIR)
|
||||
endif
|
||||
endif
|
||||
|
||||
#DEBUG_SUFFIX:=--define-variable=suffix=_d
|
||||
|
||||
LOCAL_INSERT_CFLAGS= pkg-config opal $(DEBUG_SUFFIX) --cflags
|
||||
LOCAL_CFLAGS+=-g -ggdb
|
||||
LOCAL_INSERT_LDFLAGS= pkg-config opal $(DEBUG_SUFFIX) --libs
|
||||
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
|
||||
+1280
-1486
File diff suppressed because it is too large.
Load diff
@@ -1,270 +1,330 @@
|
||||
/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /
|
||||
* Soft-Switch Application
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tuyan Ozipek (tuyanozipek@gmail.com)
|
||||
* Lukasz Zwierko (lzwierko@gmail.com)
|
||||
* Robert Jongbloed (robertj@voxlucida.com.au)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __FREESWITCH_MOD_OPAL__
|
||||
#define __FREESWITCH_MOD_OPAL__
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
|
||||
#pragma GCC visibility push(default)
|
||||
#endif
|
||||
|
||||
#include <ptlib.h>
|
||||
#include <opal/manager.h>
|
||||
#include <opal/localep.h>
|
||||
#include <h323/h323ep.h>
|
||||
#include <iax2/iax2ep.h>
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
|
||||
#pragma GCC visibility pop
|
||||
#endif
|
||||
|
||||
#undef strcasecmp
|
||||
#undef strncasecmp
|
||||
|
||||
#define HAVE_APR
|
||||
#include <switch.h>
|
||||
#include <switch_version.h>
|
||||
#define MODNAME "mod_opal"
|
||||
|
||||
|
||||
class FSEndPoint;
|
||||
class FSManager;
|
||||
|
||||
|
||||
struct mod_opal_globals {
|
||||
int trace_level;
|
||||
char *codec_string;
|
||||
char *context;
|
||||
char *dialplan;
|
||||
};
|
||||
|
||||
extern struct mod_opal_globals mod_opal_globals;
|
||||
|
||||
|
||||
class FSProcess:public PLibraryProcess {
|
||||
PCLASSINFO(FSProcess, PLibraryProcess);
|
||||
|
||||
public:
|
||||
FSProcess();
|
||||
~FSProcess();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
FSManager & GetManager() const {
|
||||
return *m_manager;
|
||||
} protected:
|
||||
FSManager * m_manager;
|
||||
};
|
||||
|
||||
|
||||
struct FSListener {
|
||||
FSListener() {
|
||||
} PString name;
|
||||
OpalTransportAddress listenAddress;
|
||||
PString localUserName;
|
||||
PString gatekeeper;
|
||||
};
|
||||
|
||||
|
||||
class FSCall:public OpalCall {
|
||||
PCLASSINFO(FSCall, OpalCall);
|
||||
public:
|
||||
FSCall(OpalManager & manager);
|
||||
virtual PBoolean OnSetUp(OpalConnection & connection);
|
||||
};
|
||||
|
||||
|
||||
class FSManager:public OpalManager {
|
||||
PCLASSINFO(FSManager, OpalManager);
|
||||
|
||||
public:
|
||||
FSManager();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
switch_status_t ReadConfig(int reload);
|
||||
|
||||
switch_endpoint_interface_t *GetSwitchInterface() const {
|
||||
return m_FreeSwitch;
|
||||
} virtual OpalCall *CreateCall(void *userData);
|
||||
|
||||
private:
|
||||
switch_endpoint_interface_t *m_FreeSwitch;
|
||||
|
||||
H323EndPoint *m_h323ep;
|
||||
IAX2EndPoint *m_iaxep;
|
||||
FSEndPoint *m_fsep;
|
||||
|
||||
PString m_gkAddress;
|
||||
PString m_gkIdentifer;
|
||||
PString m_gkInterface;
|
||||
|
||||
list < FSListener > m_listeners;
|
||||
};
|
||||
|
||||
|
||||
class FSConnection;
|
||||
typedef struct {
|
||||
switch_timer_t read_timer;
|
||||
switch_codec_t read_codec;
|
||||
switch_codec_t write_codec;
|
||||
|
||||
switch_timer_t vid_read_timer;
|
||||
switch_codec_t vid_read_codec;
|
||||
switch_codec_t vid_write_codec;
|
||||
FSConnection *me;
|
||||
} opal_private_t;
|
||||
|
||||
|
||||
class FSEndPoint:public OpalLocalEndPoint {
|
||||
PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
|
||||
public:
|
||||
FSEndPoint(FSManager & manager);
|
||||
|
||||
virtual bool OnIncomingCall(OpalLocalConnection &);
|
||||
virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions);
|
||||
};
|
||||
|
||||
|
||||
#define DECLARE_CALLBACK0(name) \
|
||||
static switch_status_t name(switch_core_session_t *session) { \
|
||||
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \
|
||||
return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name() : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name()
|
||||
|
||||
#define DECLARE_CALLBACK1(name, type1, name1) \
|
||||
static switch_status_t name(switch_core_session_t *session, type1 name1) { \
|
||||
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \
|
||||
return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name(name1) : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name(type1 name1)
|
||||
|
||||
#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \
|
||||
static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \
|
||||
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \
|
||||
return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name(type1 name1, type2 name2, type3 name3)
|
||||
|
||||
|
||||
|
||||
|
||||
class FSConnection:public OpalLocalConnection {
|
||||
PCLASSINFO(FSConnection, OpalLocalConnection)
|
||||
|
||||
public:
|
||||
FSConnection(OpalCall & call,
|
||||
FSEndPoint & endpoint,
|
||||
void *userData,
|
||||
unsigned options,
|
||||
OpalConnection::StringOptions * stringOptions,
|
||||
switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel);
|
||||
|
||||
virtual bool OnIncoming();
|
||||
virtual void OnReleased();
|
||||
virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
|
||||
virtual void OnAlerting();
|
||||
virtual void OnEstablished();
|
||||
virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
|
||||
virtual PBoolean OnOpenMediaStream(OpalMediaStream & stream);
|
||||
virtual OpalMediaFormatList GetMediaFormats() const;
|
||||
virtual PBoolean SendUserInputTone(char tone, unsigned duration);
|
||||
virtual PBoolean SendUserInputString(const PString & value);
|
||||
|
||||
void SetCodecs();
|
||||
|
||||
DECLARE_CALLBACK0(on_init);
|
||||
DECLARE_CALLBACK0(on_routing);
|
||||
DECLARE_CALLBACK0(on_execute);
|
||||
|
||||
DECLARE_CALLBACK0(on_exchange_media);
|
||||
DECLARE_CALLBACK0(on_soft_execute);
|
||||
|
||||
DECLARE_CALLBACK1(kill_channel, int, sig);
|
||||
DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
|
||||
DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
|
||||
DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
|
||||
DECLARE_CALLBACK0(state_change);
|
||||
DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
|
||||
DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
|
||||
DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
|
||||
DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
|
||||
|
||||
switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags);
|
||||
switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
|
||||
|
||||
switch_core_session_t *GetSession() const {
|
||||
return m_fsSession;
|
||||
} private:
|
||||
FSEndPoint & m_endpoint;
|
||||
switch_core_session_t *m_fsSession;
|
||||
switch_channel_t *m_fsChannel;
|
||||
PSyncPoint m_rxAudioOpened;
|
||||
PSyncPoint m_txAudioOpened;
|
||||
OpalMediaFormatList m_switchMediaFormats;
|
||||
};
|
||||
|
||||
|
||||
class FSMediaStream:public OpalMediaStream {
|
||||
PCLASSINFO(FSMediaStream, OpalMediaStream);
|
||||
public:
|
||||
FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat, ///< Media format for stream
|
||||
unsigned sessionID, ///< Session number for stream
|
||||
bool isSource ///< Is a source stream
|
||||
);
|
||||
|
||||
virtual PBoolean Open();
|
||||
virtual PBoolean Close();
|
||||
virtual PBoolean IsSynchronous() const;
|
||||
virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
|
||||
|
||||
switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags);
|
||||
switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags);
|
||||
|
||||
private:
|
||||
switch_core_session_t *m_fsSession;
|
||||
switch_channel_t *m_fsChannel;
|
||||
switch_timer_t *m_switchTimer;
|
||||
switch_codec_t *m_switchCodec;
|
||||
switch_frame_t m_readFrame;
|
||||
unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
RTP_DataFrame m_readRTP;
|
||||
bool m_callOnStart;
|
||||
uint32_t m_timeStamp;
|
||||
|
||||
bool CheckPatchAndLock();
|
||||
};
|
||||
|
||||
|
||||
#endif /* __FREESWITCH_MOD_OPAL__ */
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:nil
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:s:
|
||||
*/
|
||||
/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /
|
||||
* Soft-Switch Application
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)
|
||||
* Copyright (c) 2008-2012 Vox Lucida Pty. Ltd. (robertj@voxlucida.com.au)
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tuyan Ozipek (tuyanozipek@gmail.com)
|
||||
* Lukasz Zwierko (lzwierko@gmail.com)
|
||||
* Robert Jongbloed (robertj@voxlucida.com.au)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __FREESWITCH_MOD_OPAL__
|
||||
#define __FREESWITCH_MOD_OPAL__
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
|
||||
#pragma GCC visibility push(default)
|
||||
#endif
|
||||
|
||||
#include <ptlib.h>
|
||||
#include <opal/manager.h>
|
||||
#include <opal/localep.h>
|
||||
#include <h323/h323ep.h>
|
||||
#include <iax2/iax2ep.h>
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
|
||||
#pragma GCC visibility pop
|
||||
#endif
|
||||
|
||||
#undef strcasecmp
|
||||
#undef strncasecmp
|
||||
|
||||
|
||||
#if _MSC_VER < 1600
|
||||
/*The following insanity is because libteletone_generate.h defines int8_t in
|
||||
a slightly different manner to most other cases (SDL, PCAP, Java V8, stdint.h
|
||||
etc) and does not provide a mechanism to prevent it's inclusion. Then, to
|
||||
cap it off, VS2008 barfs on the difference. VS2010 seems OK with it.
|
||||
|
||||
Sigh.
|
||||
*/
|
||||
#pragma include_alias(<libteletone.h>, <../../libs/libteletone/src/libteletone.h>)
|
||||
#pragma include_alias(<libteletone_generate.h>, <../../libs/libteletone/src/libteletone_generate.h>)
|
||||
#pragma include_alias(<libteletone_detect.h>, <../../libs/libteletone/src/libteletone_detect.h>)
|
||||
#define int8_t signed int8_t
|
||||
#include <libteletone_generate.h>
|
||||
#undef int8_t
|
||||
#endif // End of insanity
|
||||
|
||||
|
||||
#define HAVE_APR
|
||||
#define uint32_t uint32_t // Avoid conflict in stdint definitions
|
||||
#include <switch.h>
|
||||
#undef uint32_t
|
||||
|
||||
#include <switch_version.h>
|
||||
|
||||
|
||||
#define MODNAME "mod_opal"
|
||||
|
||||
|
||||
class FSEndPoint;
|
||||
class FSManager;
|
||||
|
||||
|
||||
class FSProcess : public PLibraryProcess
|
||||
{
|
||||
PCLASSINFO(FSProcess, PLibraryProcess);
|
||||
public:
|
||||
FSProcess();
|
||||
~FSProcess();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
FSManager & GetManager() const
|
||||
{
|
||||
return *m_manager;
|
||||
}
|
||||
|
||||
protected:
|
||||
FSManager * m_manager;
|
||||
};
|
||||
|
||||
|
||||
struct FSListener
|
||||
{
|
||||
FSListener() : m_port(H323EndPoint::DefaultTcpSignalPort) { }
|
||||
|
||||
PString m_name;
|
||||
PIPSocket::Address m_address;
|
||||
uint16_t m_port;
|
||||
};
|
||||
|
||||
|
||||
class FSManager : public OpalManager
|
||||
{
|
||||
PCLASSINFO(FSManager, OpalManager);
|
||||
|
||||
public:
|
||||
FSManager();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
switch_status_t ReadConfig(int reload);
|
||||
|
||||
switch_endpoint_interface_t *GetSwitchInterface() const { return m_FreeSwitch; }
|
||||
const PString & GetContext() const { return m_context; }
|
||||
const PString & GetDialPlan() const { return m_dialplan; }
|
||||
const PString & GetCodecPrefs() const { return m_codecPrefs; }
|
||||
bool GetDisableTranscoding() const { return m_disableTranscoding; }
|
||||
|
||||
private:
|
||||
switch_endpoint_interface_t *m_FreeSwitch;
|
||||
|
||||
H323EndPoint *m_h323ep;
|
||||
IAX2EndPoint *m_iaxep;
|
||||
FSEndPoint *m_fsep;
|
||||
|
||||
PString m_context;
|
||||
PString m_dialplan;
|
||||
PString m_codecPrefs;
|
||||
bool m_disableTranscoding;
|
||||
PString m_gkAddress;
|
||||
PString m_gkIdentifer;
|
||||
PString m_gkInterface;
|
||||
|
||||
list <FSListener> m_listeners;
|
||||
};
|
||||
|
||||
|
||||
class FSEndPoint : public OpalLocalEndPoint
|
||||
{
|
||||
PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
|
||||
public:
|
||||
FSEndPoint(FSManager & manager);
|
||||
|
||||
virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions);
|
||||
|
||||
FSManager & GetManager() const { return m_manager; }
|
||||
|
||||
protected:
|
||||
FSManager & m_manager;
|
||||
};
|
||||
|
||||
|
||||
class FSConnection;
|
||||
|
||||
|
||||
class FSMediaStream : public OpalMediaStream
|
||||
{
|
||||
PCLASSINFO(FSMediaStream, OpalMediaStream);
|
||||
public:
|
||||
FSMediaStream(
|
||||
FSConnection & conn,
|
||||
const OpalMediaFormat & mediaFormat, ///< Media format for stream
|
||||
unsigned sessionID, ///< Session number for stream
|
||||
bool isSource ///< Is a source stream
|
||||
);
|
||||
|
||||
virtual PBoolean Open();
|
||||
virtual PBoolean IsSynchronous() const;
|
||||
virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
|
||||
|
||||
switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags);
|
||||
switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags);
|
||||
|
||||
protected:
|
||||
virtual void InternalClose();
|
||||
int StartReadWrite(PatchPtr & mediaPatch) const;
|
||||
|
||||
private:
|
||||
bool CheckPatchAndLock();
|
||||
|
||||
FSConnection &m_connection;
|
||||
switch_timer_t *m_switchTimer;
|
||||
switch_codec_t *m_switchCodec;
|
||||
switch_frame_t m_readFrame;
|
||||
RTP_DataFrame m_readRTP;
|
||||
};
|
||||
|
||||
|
||||
#define DECLARE_CALLBACK0(name) \
|
||||
static switch_status_t name(switch_core_session_t *session) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name() : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name()
|
||||
|
||||
#define DECLARE_CALLBACK1(name, type1, name1) \
|
||||
static switch_status_t name(switch_core_session_t *session, type1 name1) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name(name1) : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name(type1 name1)
|
||||
|
||||
#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \
|
||||
static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \
|
||||
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
|
||||
return tech_pvt != NULL ? tech_pvt->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
|
||||
switch_status_t name(type1 name1, type2 name2, type3 name3)
|
||||
|
||||
|
||||
|
||||
|
||||
class FSConnection : public OpalLocalConnection
|
||||
{
|
||||
PCLASSINFO(FSConnection, OpalLocalConnection)
|
||||
|
||||
public:
|
||||
struct outgoing_params {
|
||||
switch_event_t *var_event;
|
||||
switch_caller_profile_t *outbound_profile;
|
||||
switch_core_session_t **new_session;
|
||||
switch_memory_pool_t **pool;
|
||||
switch_originate_flag_t flags;
|
||||
switch_call_cause_t *cancel_cause;
|
||||
switch_call_cause_t fail_cause;
|
||||
};
|
||||
|
||||
FSConnection(OpalCall & call,
|
||||
FSEndPoint & endpoint,
|
||||
unsigned options,
|
||||
OpalConnection::StringOptions * stringOptions,
|
||||
outgoing_params * params);
|
||||
|
||||
virtual bool OnOutgoingSetUp();
|
||||
virtual bool OnIncoming();
|
||||
virtual void OnReleased();
|
||||
virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
|
||||
virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
|
||||
virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch);
|
||||
virtual OpalMediaFormatList GetMediaFormats() const;
|
||||
virtual PBoolean SendUserInputTone(char tone, unsigned duration);
|
||||
|
||||
DECLARE_CALLBACK0(on_init);
|
||||
DECLARE_CALLBACK0(on_destroy);
|
||||
DECLARE_CALLBACK0(on_routing);
|
||||
DECLARE_CALLBACK0(on_execute);
|
||||
DECLARE_CALLBACK0(on_hangup);
|
||||
|
||||
DECLARE_CALLBACK0(on_exchange_media);
|
||||
DECLARE_CALLBACK0(on_soft_execute);
|
||||
|
||||
DECLARE_CALLBACK1(kill_channel, int, sig);
|
||||
DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
|
||||
DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
|
||||
DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
|
||||
DECLARE_CALLBACK0(state_change);
|
||||
DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
|
||||
DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
|
||||
DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
|
||||
DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
|
||||
|
||||
__inline switch_core_session_t *GetSession() const
|
||||
{
|
||||
return m_fsSession;
|
||||
}
|
||||
|
||||
__inline switch_channel_t *GetChannel() const
|
||||
{
|
||||
return m_fsChannel;
|
||||
}
|
||||
|
||||
bool IsChannelReady() const
|
||||
{
|
||||
return m_fsChannel != NULL && switch_channel_ready(m_fsChannel);
|
||||
}
|
||||
|
||||
bool NeedFlushAudio()
|
||||
{
|
||||
if (!m_flushAudio)
|
||||
return false;
|
||||
m_flushAudio = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetCodecs();
|
||||
bool WaitForMedia();
|
||||
|
||||
switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags);
|
||||
switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
|
||||
|
||||
private:
|
||||
FSEndPoint &m_endpoint;
|
||||
switch_core_session_t *m_fsSession;
|
||||
switch_channel_t *m_fsChannel;
|
||||
PSyncPoint m_rxAudioOpened;
|
||||
PSyncPoint m_txAudioOpened;
|
||||
OpalMediaFormatList m_switchMediaFormats;
|
||||
|
||||
// If FS ever supports more than one audio and one video, this needs to change
|
||||
switch_timer_t m_read_timer;
|
||||
switch_codec_t m_read_codec;
|
||||
switch_codec_t m_write_codec;
|
||||
|
||||
switch_timer_t m_vid_read_timer;
|
||||
switch_codec_t m_vid_read_codec;
|
||||
switch_codec_t m_vid_write_codec;
|
||||
|
||||
bool m_flushAudio;
|
||||
|
||||
friend PBoolean FSMediaStream::Open();
|
||||
};
|
||||
|
||||
|
||||
#endif /* __FREESWITCH_MOD_OPAL__ */
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:nil
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:s:
|
||||
*/
|
||||
@@ -429,6 +429,10 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
||||
gateway_ptr = sofia_reg_find_gateway(gateway_name);
|
||||
}
|
||||
|
||||
if (!tech_pvt) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
rec = sofia_test_flag(tech_pvt, TFLAG_RECOVERING);
|
||||
|
||||
@@ -154,6 +154,7 @@ typedef struct sofia_dispatch_event_s {
|
||||
int save;
|
||||
switch_core_session_t *session;
|
||||
switch_memory_pool_t *pool;
|
||||
struct sofia_dispatch_event_s *next;
|
||||
} sofia_dispatch_event_t;
|
||||
|
||||
struct sofia_private {
|
||||
@@ -166,6 +167,7 @@ struct sofia_private {
|
||||
int is_call;
|
||||
int is_static;
|
||||
sofia_dispatch_event_t *de;
|
||||
sofia_dispatch_event_t *deq;
|
||||
};
|
||||
|
||||
#define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);}
|
||||
|
||||
@@ -969,18 +969,25 @@ static void our_sofia_event_callback(nua_event_t event,
|
||||
int locked = 0;
|
||||
int check_destroy = 1;
|
||||
|
||||
if (sofia_private && sofia_private->is_call && sofia_private->de) {
|
||||
sofia_dispatch_event_t *qde = sofia_private->de;
|
||||
sofia_private->de = NULL;
|
||||
if (sofia_private && sofia_private->is_call) {
|
||||
sofia_dispatch_event_t *qde = NULL;
|
||||
|
||||
if (event == nua_i_cancel) {
|
||||
nua_destroy_event(qde->event);
|
||||
su_free(nh->nh_home, qde);
|
||||
} else {
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
if (sofia_private->de) {
|
||||
qde = sofia_private->de;
|
||||
sofia_private->de = NULL;
|
||||
}
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
|
||||
if (qde) {
|
||||
sofia_process_dispatch_event(&qde);
|
||||
}
|
||||
}
|
||||
|
||||
if (sofia_private && (sofia_private->destroy_me == 12)) {
|
||||
return;
|
||||
}
|
||||
|
||||
profile->last_sip_event = switch_time_now();
|
||||
|
||||
/* sofia_private will be == &mod_sofia_globals.keep_private whenever a request is done with a new handle that has to be
|
||||
@@ -1525,22 +1532,51 @@ void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep)
|
||||
|
||||
void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
|
||||
{
|
||||
sofia_dispatch_event_t *de = *dep;
|
||||
sofia_dispatch_event_t *de = *dep, *deq = NULL;
|
||||
nua_handle_t *nh = de->nh;
|
||||
nua_t *nua = de->nua;
|
||||
sofia_profile_t *profile = de->profile;
|
||||
|
||||
sofia_private_t *sofia_private = nua_handle_magic(de->nh);
|
||||
*dep = NULL;
|
||||
|
||||
our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
|
||||
de->nh, nua_handle_magic(de->nh), de->sip, de, (tagi_t *) de->data->e_tags);
|
||||
de->nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags);
|
||||
|
||||
nua_destroy_event(de->event);
|
||||
su_free(nh->nh_home, de);
|
||||
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
profile->queued_events--;
|
||||
if (sofia_private && sofia_private->is_call && sofia_private->deq) {
|
||||
deq = sofia_private->deq;
|
||||
sofia_private->deq = NULL;
|
||||
}
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
|
||||
if (deq) {
|
||||
for (;;) {
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
if ((de = deq)) {
|
||||
deq = deq->next;
|
||||
de->next = NULL;
|
||||
}
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
|
||||
if (!de) {
|
||||
break;
|
||||
}
|
||||
|
||||
our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
|
||||
de->nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags);
|
||||
|
||||
nua_destroy_event(de->event);
|
||||
su_free(nh->nh_home, de);
|
||||
nua_handle_unref(nh);
|
||||
nua_stack_unref(nua);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nua_handle_unref(nh);
|
||||
nua_stack_unref(nua);
|
||||
@@ -1684,8 +1720,6 @@ void sofia_event_callback(nua_event_t event,
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
profile->queued_events++;
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
@@ -1707,7 +1741,9 @@ void sofia_event_callback(nua_event_t event,
|
||||
memset(sofia_private, 0, sizeof(*sofia_private));
|
||||
sofia_private->is_call++;
|
||||
sofia_private->is_static++;
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
sofia_private->de = de;
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
nua_handle_bind(nh, sofia_private);
|
||||
return;
|
||||
}
|
||||
@@ -1715,7 +1751,23 @@ void sofia_event_callback(nua_event_t event,
|
||||
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) {
|
||||
switch_core_session_t *session;
|
||||
|
||||
if (!zstr(sofia_private->uuid)) {
|
||||
if (zstr(sofia_private->uuid)) {
|
||||
if (sofia_private->is_call && !sofia_private->de) {
|
||||
sofia_dispatch_event_t *dep;
|
||||
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
|
||||
if (!sofia_private->deq) {
|
||||
sofia_private->deq = de;
|
||||
} else {
|
||||
for (dep = sofia_private->deq; dep && dep->next; dep = dep->next);
|
||||
dep->next = de;
|
||||
}
|
||||
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if ((session = switch_core_session_locate(sofia_private->uuid))) {
|
||||
if (switch_core_session_running(session)) {
|
||||
switch_core_session_queue_signal_data(session, de);
|
||||
@@ -1732,7 +1784,7 @@ void sofia_event_callback(nua_event_t event,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sofia_queue_message(de);
|
||||
switch_os_yield();
|
||||
}
|
||||
@@ -6040,9 +6092,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
}
|
||||
}
|
||||
|
||||
if (sofia_private) {
|
||||
sofia_private->destroy_me = 1;
|
||||
}
|
||||
// if (sofia_private) {
|
||||
//sofia_private->destroy_me = 1;
|
||||
//}
|
||||
}
|
||||
|
||||
if (session) {
|
||||
@@ -8013,6 +8065,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
|
||||
profile->ib_calls++;
|
||||
|
||||
|
||||
if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING)) {
|
||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||
goto fail;
|
||||
@@ -8217,14 +8270,8 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
|
||||
nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END());
|
||||
switch_core_session_destroy(&session);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t));
|
||||
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
@@ -9031,6 +9078,10 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
}
|
||||
switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
|
||||
|
||||
if (switch_core_session_running(session) || switch_core_session_started(session)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sip && switch_core_session_thread_launch(session) == SWITCH_STATUS_SUCCESS) {
|
||||
const char *dialog_from_user = "", *dialog_from_host = "", *to_user = "", *to_host = "", *contact_user = "", *contact_host = "";
|
||||
const char *user_agent = "", *call_id = "";
|
||||
@@ -9119,6 +9170,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting NAT mode based on %s\n", is_nat);
|
||||
switch_channel_set_variable(channel, "sip_nat_detected", "true");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9140,10 +9192,12 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
switch_mutex_unlock(tech_pvt->profile->flag_mutex);
|
||||
}
|
||||
|
||||
nua_handle_bind(nh, NULL);
|
||||
sofia_private_free(sofia_private);
|
||||
switch_core_session_destroy(&session);
|
||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||
if (!switch_core_session_running(session)) {
|
||||
nua_handle_bind(nh, NULL);
|
||||
sofia_private_free(sofia_private);
|
||||
switch_core_session_destroy(&session);
|
||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||
}
|
||||
return;
|
||||
|
||||
fail:
|
||||
|
||||
Reference in new issue
Block a user