git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6094 d0543943-73ff-0310-b7d9-9358b9ac24b2

This commit is contained in:
Łukasz Zwierko 2007-10-31 06:05:45 +00:00
parent b97f786f0f
commit a9d79d7ad0
3 changed files with 59 additions and 50 deletions

View File

@ -12,16 +12,14 @@ moddir=$(prefix)/mod
MODNAME=mod_opal MODNAME=mod_opal
OPAL_DIR=$(switch_builddir)/libs/opal OPALDIR=$(switch_builddir)/libs/opal
mod_LTLIBRARIES = mod_opal.la mod_LTLIBRARIES = mod_opal.la
mod_opal_la_SOURCES = opalh323_backend.cpp mod_opalh323.cpp mod_opal_la_SOURCES = opalh323_backend.cpp mod_opalh323.cpp
mod_opal_la_CFLAGS = $(AM_CFLAGS) mod_opal_la_CPPFLAGS = $(AM_CPPFLAGS) -D_REENTRANT -fno-exceptions -Wall -DPTRACING -Os -felide-constructors -Wreorder -I$(OPALDIR)/include
mod_opal_la_CFLAGS += -I. -I$(OPAL_DIR)/include
mod_opal_la_CPPFLAGS = $(AM_CPPFLAGS)
mod_opal_la_CPPFLAGS += -I. -I$(OPAL_DIR)/include
mod_opal_la_LIBADD = $(switch_builddir)/libfreeswitch.la mod_opal_la_LIBADD = $(switch_builddir)/libfreeswitch.la
mod_opal_la_LDFLAGS = -avoid-version -module -no-undefined mod_opal_la_LDFLAGS = -avoid-version -module -no-undefined -export-symbols-regex ^switch_module_.*$ -rpath $(PREFIX)/$(libdir) -L$(OPALDIR)/lib -lopal_linux_x86_r -lpt_linux_x86_r -lpthread -lsasl2 -lssl -lcrypto -lexpat -ldl
#Override the linstall target so we just install the .so/.dylib #Override the linstall target so we just install the .so/.dylib
@ -34,5 +32,3 @@ $(DESTDIR)$(PREFIX)/$(moddir)/$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).la
else \ else \
$(LIBTOOL) --mode=install $(INSTALL) $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(DESTDIR)$(PREFIX)/$(moddir) >/dev/null ; \ $(LIBTOOL) --mode=install $(INSTALL) $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(DESTDIR)$(PREFIX)/$(moddir) >/dev/null ; \
fi fi
##include $(OPAL_DIR)/opal_inc.mak

View File

@ -63,7 +63,7 @@ static bool OpalH323Private_Create(OpalH323Private_t **o_private, switch_core_se
static bool OpalH323Private_Delete(OpalH323Private_t *o_private) static bool OpalH323Private_Delete(OpalH323Private_t *o_private)
{ {
switch_mutex_destroy(o_private->m_mutex); return (switch_mutex_destroy(o_private->m_mutex)==SWITCH_STATUS_SUCCESS);
} }
/** Default constructor /** Default constructor
@ -106,8 +106,6 @@ bool FSOpalManager::initialize(
switch_endpoint_interface_t *i_endpointInterface switch_endpoint_interface_t *i_endpointInterface
) )
{ {
bool result = true;
/* check if not initialized */ /* check if not initialized */
assert(m_isInitialized); assert(m_isInitialized);
@ -180,21 +178,21 @@ bool FSOpalManager::initialize(
switch_core_session_t* FSOpalManager::getSessionToken(PString &i_token) switch_core_session_t* FSOpalManager::getSessionToken(const PString &i_token)
{ {
assert(m_pSessionsHashTable); assert(m_pSessionsHashTable);
assert(m_pSessionsHashTableMutex); assert(m_pSessionsHashTableMutex);
return static_cast<switch_core_session_t*>(switch_core_hash_find_locked(m_pSessionsHashTable,(const char*)i_token,m_pSessionsHashTableMutex)); return static_cast<switch_core_session_t*>(switch_core_hash_find_locked(m_pSessionsHashTable,(const char*)i_token,m_pSessionsHashTableMutex));
} }
void FSOpalManager::saveSessionToken(PString &i_token,switch_core_session_t* i_session) void FSOpalManager::saveSessionToken(const PString &i_token,switch_core_session_t* i_session)
{ {
assert(m_pSessionsHashTable); assert(m_pSessionsHashTable);
assert(m_pSessionsHashTableMutex); assert(m_pSessionsHashTableMutex);
switch_core_hash_insert_locked(m_pSessionsHashTable,(const char*)i_token,i_session,m_pSessionsHashTableMutex); switch_core_hash_insert_locked(m_pSessionsHashTable,(const char*)i_token,i_session,m_pSessionsHashTableMutex);
} }
void FSOpalManager::deleteToken(PString &i_token) void FSOpalManager::deleteSessionToken(const PString &i_token)
{ {
assert(m_pSessionsHashTable); assert(m_pSessionsHashTable);
assert(m_pSessionsHashTableMutex); assert(m_pSessionsHashTableMutex);
@ -209,7 +207,7 @@ BOOL FSOpalManager::OnIncomingConnection(
) )
{ {
//TODO check if options and stringOptions fields ever apply //TODO check if options and stringOptions fields ever apply
retrun OnIncomingConnection(connection); return OnIncomingConnection(connection);
} }
BOOL FSOpalManager::OnIncomingConnection( BOOL FSOpalManager::OnIncomingConnection(
@ -218,7 +216,7 @@ BOOL FSOpalManager::OnIncomingConnection(
) )
{ {
//TODO, check if options field ever applies //TODO, check if options field ever applies
retrun OnIncomingConnection(connection); return OnIncomingConnection(connection);
} }
BOOL FSOpalManager::OnIncomingConnection( BOOL FSOpalManager::OnIncomingConnection(
@ -228,20 +226,20 @@ BOOL FSOpalManager::OnIncomingConnection(
/* allocate new session in switch core*/ /* allocate new session in switch core*/
switch_core_session_t *session = switch_core_session_request(m_pEndpointInterface , NULL); switch_core_session_t *session = switch_core_session_request(m_pEndpointInterface , NULL);
assert(session); assert(session);
if(!sesion) if(!session)
{ {
///TODO add cause to the connection ///TODO add cause to the connection
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not allocate session object?\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not allocate session object?\n");
return FALSE; return FALSE;
} }
/* allocate private resources */ /* allocate private resources */
OpalH323Private_t *tech_pvt = NULL; OpalH323Private_t *tech_pvt = NULL;
if(!OpalH323Private_Create(&tech_pvt)) if(!OpalH323Private_Create(&tech_pvt,session))
{ {
///TODO add cause to the connection ///TODO add cause to the connection
switch_core_session_destroy(&session); switch_core_session_destroy(&session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not allocate private object?\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not allocate private object?\n");
return false; return false;
} }
tech_pvt->m_opalConnection = &connection; tech_pvt->m_opalConnection = &connection;
@ -263,17 +261,17 @@ BOOL FSOpalManager::OnIncomingConnection(
/** Create calling side profile */ /** Create calling side profile */
tech_pvt->m_callerProfile = switch_caller_profile_new( tech_pvt->m_callerProfile = switch_caller_profile_new(
switch_core_session_get_pool(session), switch_core_session_get_pool(session),
*connection.GetRemotePartyName(), /** username */ (const char*)connection.GetRemotePartyName(), /** username */
"default", /** TODO -> this should be configurable by core */ "default", /** TODO -> this should be configurable by core */
*connection.GetRemotePartyName(), /** caller_id_name */ (const char*)connection.GetRemotePartyName(), /** caller_id_name */
*connection.GetRemotePartyNumber(), /** caller_id_number */ (const char*)connection.GetRemotePartyNumber(), /** caller_id_number */
*connection.GetRemotePartyAddress(), /** network addr */ (const char*)connection.GetRemotePartyAddress(), /** network addr */
NULL, /** ANI */ NULL, /** ANI */
NULL, /** ANI II */ NULL, /** ANI II */
NULL, /** RDNIS */ NULL, /** RDNIS */
m_pModuleName, /** source */ m_pModuleName, /** source */
NULL, /** TODO -> set context */ NULL, /** TODO -> set context */
*connection.GetCalledDestinationNumber() /** destination_number */ (const char*)connection.GetCalledDestinationNumber() /** destination_number */
); );
if(!tech_pvt->m_callerProfile) /* should never error */ if(!tech_pvt->m_callerProfile) /* should never error */
@ -288,7 +286,7 @@ BOOL FSOpalManager::OnIncomingConnection(
/** Set up sessions channel */ /** Set up sessions channel */
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_set_name(channel,*connection.GetToken()); switch_channel_set_name(channel,(const char*)connection.GetToken());
switch_channel_set_caller_profile(channel, tech_pvt->m_callerProfile); switch_channel_set_caller_profile(channel, tech_pvt->m_callerProfile);
switch_channel_set_state(channel, CS_INIT); switch_channel_set_state(channel, CS_INIT);
@ -301,7 +299,7 @@ BOOL FSOpalManager::OnIncomingConnection(
/** lunch thread */ /** lunch thread */
if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS)
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
deleteSessionToken(connection.GetToken()); deleteSessionToken(connection.GetToken());
switch_mutex_unlock(tech_pvt->m_mutex); switch_mutex_unlock(tech_pvt->m_mutex);
OpalH323Private_Delete(tech_pvt); OpalH323Private_Delete(tech_pvt);
@ -387,7 +385,7 @@ switch_status_t FSOpalManager::callback_on_transmit(switch_core_session_t *io_se
switch_call_cause_t FSOpalManager::io_outgoing_channel(switch_core_session_t *i_session, switch_caller_profile_t *i_profile, switch_core_session_t **o_newSession, switch_memory_pool_t **o_memPool) switch_call_cause_t FSOpalManager::io_outgoing_channel(switch_core_session_t *i_session, switch_caller_profile_t *i_profile, switch_core_session_t **o_newSession, switch_memory_pool_t **o_memPool)
{ {
assert(m_isInitialized); assert(m_isInitialized);
return 0; return SWITCH_CAUSE_SUCCESS;
} }
switch_status_t FSOpalManager::io_read_frame(switch_core_session_t *i_session, switch_frame_t **o_frame, int i_timout, switch_io_flag_t i_flag, int i_streamId) switch_status_t FSOpalManager::io_read_frame(switch_core_session_t *i_session, switch_frame_t **o_frame, int i_timout, switch_io_flag_t i_flag, int i_streamId)
@ -430,7 +428,7 @@ switch_status_t FSOpalManager::io_receive_message(switch_core_session_t *i_sessi
{ {
assert(m_isInitialized); assert(m_isInitialized);
OpalH323Private_t* tech_prv = switch_core_session_get_private(i_session); OpalH323Private_t* tech_prv = static_cast<OpalH323Private_t*>(switch_core_session_get_private(i_session));
assert(tech_prv); assert(tech_prv);
switch_mutex_lock(tech_prv->m_mutex); switch_mutex_lock(tech_prv->m_mutex);
@ -438,55 +436,55 @@ switch_status_t FSOpalManager::io_receive_message(switch_core_session_t *i_sessi
switch(i_message->message_id) switch(i_message->message_id)
{ {
case SWITCH_MESSAGE_REDIRECT_AUDIO: case SWITCH_MESSAGE_REDIRECT_AUDIO:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_REDIRECT_AUDIO\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_REDIRECT_AUDIO\n");
break; break;
case SWITCH_MESSAGE_TRANSMIT_TEXT: case SWITCH_MESSAGE_TRANSMIT_TEXT:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_TRANSMIT_TEXT\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_TRANSMIT_TEXT\n");
break; break;
case SWITCH_MESSAGE_INDICATE_ANSWER: case SWITCH_MESSAGE_INDICATE_ANSWER:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_ANSWER\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_ANSWER\n");
/* set call answer */ /* set call answer */
tech_prv->m_opalConnection->AnsweringCall(AnswerCallNow); //tech_prv->m_opalConnection->AnsweringCall(AnswerCallNow);
break; break;
case SWITCH_MESSAGE_INDICATE_PROGRESS: case SWITCH_MESSAGE_INDICATE_PROGRESS:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_PROGRESS\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_PROGRESS\n");
break; break;
case SWITCH_MESSAGE_INDICATE_BRIDGE: case SWITCH_MESSAGE_INDICATE_BRIDGE:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_BRIDGE\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_BRIDGE\n");
break; break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE: case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_UNBRIDGE\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_UNBRIDGE\n");
break; break;
case SWITCH_MESSAGE_INDICATE_TRANSFER: case SWITCH_MESSAGE_INDICATE_TRANSFER:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_TRANSFER\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_TRANSFER\n");
break; break;
case SWITCH_MESSAGE_INDICATE_RINGING: case SWITCH_MESSAGE_INDICATE_RINGING:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_RINGING\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_RINGING\n");
break; break;
case SWITCH_MESSAGE_INDICATE_MEDIA: case SWITCH_MESSAGE_INDICATE_MEDIA:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_MEDIA\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_MEDIA\n");
break; break;
case SWITCH_MESSAGE_INDICATE_NOMEDIA: case SWITCH_MESSAGE_INDICATE_NOMEDIA:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_NOMEDIA\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_NOMEDIA\n");
break; break;
case SWITCH_MESSAGE_INDICATE_HOLD: case SWITCH_MESSAGE_INDICATE_HOLD:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_HOLD\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_HOLD\n");
break; break;
case SWITCH_MESSAGE_INDICATE_UNHOLD: case SWITCH_MESSAGE_INDICATE_UNHOLD:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_UNHOLD\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_UNHOLD\n");
break; break;
case SWITCH_MESSAGE_INDICATE_REDIRECT: case SWITCH_MESSAGE_INDICATE_REDIRECT:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_REDIRECT\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_REDIRECT\n");
break; break;
case SWITCH_MESSAGE_INDICATE_REJECT: case SWITCH_MESSAGE_INDICATE_REJECT:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_REJECT\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_REJECT\n");
break; break;
case SWITCH_MESSAGE_INDICATE_BROADCAST: case SWITCH_MESSAGE_INDICATE_BROADCAST:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_BROADCAST\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_BROADCAST\n");
break; break;
case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT: case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG "SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT\n");
break; break;
} }

View File

@ -94,12 +94,27 @@ public:
switch_status_t io_read_video_frame(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int); switch_status_t io_read_video_frame(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
switch_status_t io_write_video_frame(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int); switch_status_t io_write_video_frame(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
virtual BOOL OnIncomingConnection(
OpalConnection & connection, ///< Connection that is calling
unsigned options, ///< options for new connection (can't use default as overrides will fail)
OpalConnection::StringOptions * stringOptions
);
virtual BOOL OnIncomingConnection(
OpalConnection & connection, ///< Connection that is calling
unsigned options ///< options for new connection (can't use default as overrides will fail)
);
virtual BOOL OnIncomingConnection(
OpalConnection & connection ///< Connection that is calling
);
private: private:
void saveSessionToken(PString &i_token,switch_core_session_t* i_session); void saveSessionToken(const PString &i_token,switch_core_session_t* i_session);
switch_core_session_t* getSessionToken(PString &i_token); switch_core_session_t* getSessionToken(const PString &i_token);
void deleteToken(PString &i_token); void deleteSessionToken(const PString &i_token);
const char *m_pModuleName; /* name of this module */ const char *m_pModuleName; /* name of this module */