Merge branch 'nsg-4.3' of ssh://git.sangoma.com/smg_freeswitch into nsg-4.3
This commit is contained in:
commit
5d3718fdb8
File diff suppressed because it is too large
Load Diff
|
@ -4,6 +4,7 @@
|
|||
* 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
|
||||
|
@ -46,6 +47,8 @@
|
|||
#define HAVE_APR
|
||||
#include <switch.h>
|
||||
#include <switch_version.h>
|
||||
|
||||
|
||||
#define MODNAME "mod_opal"
|
||||
|
||||
|
||||
|
@ -53,50 +56,37 @@ 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 {
|
||||
class FSProcess : public PLibraryProcess
|
||||
{
|
||||
PCLASSINFO(FSProcess, PLibraryProcess);
|
||||
|
||||
public:
|
||||
FSProcess();
|
||||
~FSProcess();
|
||||
|
||||
bool Initialise(switch_loadable_module_interface_t *iface);
|
||||
|
||||
FSManager & GetManager() const {
|
||||
FSManager & GetManager() const
|
||||
{
|
||||
return *m_manager;
|
||||
} protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
FSManager * m_manager;
|
||||
};
|
||||
|
||||
|
||||
struct FSListener {
|
||||
FSListener() {
|
||||
} PString name;
|
||||
OpalTransportAddress listenAddress;
|
||||
PString localUserName;
|
||||
PString gatekeeper;
|
||||
struct FSListener
|
||||
{
|
||||
FSListener() : m_port(H323EndPoint::DefaultTcpSignalPort) { }
|
||||
|
||||
PString m_name;
|
||||
PIPSocket::Address m_address;
|
||||
uint16_t m_port;
|
||||
};
|
||||
|
||||
|
||||
class FSCall:public OpalCall {
|
||||
PCLASSINFO(FSCall, OpalCall);
|
||||
public:
|
||||
FSCall(OpalManager & manager);
|
||||
virtual PBoolean OnSetUp(OpalConnection & connection);
|
||||
};
|
||||
|
||||
|
||||
class FSManager:public OpalManager {
|
||||
class FSManager : public OpalManager
|
||||
{
|
||||
PCLASSINFO(FSManager, OpalManager);
|
||||
|
||||
public:
|
||||
|
@ -106,9 +96,10 @@ class FSManager:public OpalManager {
|
|||
|
||||
switch_status_t ReadConfig(int reload);
|
||||
|
||||
switch_endpoint_interface_t *GetSwitchInterface() const {
|
||||
return m_FreeSwitch;
|
||||
} virtual OpalCall *CreateCall(void *userData);
|
||||
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; }
|
||||
|
||||
private:
|
||||
switch_endpoint_interface_t *m_FreeSwitch;
|
||||
|
@ -117,85 +108,127 @@ class FSManager:public OpalManager {
|
|||
IAX2EndPoint *m_iaxep;
|
||||
FSEndPoint *m_fsep;
|
||||
|
||||
PString m_context;
|
||||
PString m_dialplan;
|
||||
PString m_codecPrefs;
|
||||
PString m_gkAddress;
|
||||
PString m_gkIdentifer;
|
||||
PString m_gkInterface;
|
||||
|
||||
list < FSListener > m_listeners;
|
||||
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 {
|
||||
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);
|
||||
|
||||
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) { \
|
||||
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()
|
||||
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) { \
|
||||
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)
|
||||
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) { \
|
||||
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)
|
||||
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 {
|
||||
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,
|
||||
void *userData,
|
||||
unsigned options,
|
||||
OpalConnection::StringOptions * stringOptions,
|
||||
switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel);
|
||||
outgoing_params * params);
|
||||
|
||||
virtual bool OnOutgoingSetUp();
|
||||
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 void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch);
|
||||
virtual OpalMediaFormatList GetMediaFormats() const;
|
||||
virtual PBoolean SendUserInputTone(char tone, unsigned duration);
|
||||
virtual PBoolean SendUserInputString(const PString & value);
|
||||
|
||||
void SetCodecs();
|
||||
bool WaitForMedia();
|
||||
|
||||
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);
|
||||
|
@ -213,46 +246,49 @@ class FSConnection:public OpalLocalConnection {
|
|||
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 {
|
||||
__inline switch_core_session_t *GetSession() const
|
||||
{
|
||||
return m_fsSession;
|
||||
} private:
|
||||
FSEndPoint & m_endpoint;
|
||||
}
|
||||
|
||||
__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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
);
|
||||
switch_timer_t m_vid_read_timer;
|
||||
switch_codec_t m_vid_read_codec;
|
||||
switch_codec_t m_vid_write_codec;
|
||||
|
||||
virtual PBoolean Open();
|
||||
virtual PBoolean Close();
|
||||
virtual PBoolean IsSynchronous() const;
|
||||
virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
|
||||
bool m_flushAudio;
|
||||
|
||||
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();
|
||||
friend PBoolean FSMediaStream::Open();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue