提交 14275814 authored 作者: Łukasz Zwierko's avatar Łukasz Zwierko

1. added Tuyan fix/simplification for Opal engine starting

2. some progress in call control implementation

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6138 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 cd6a8d99
......@@ -159,7 +159,7 @@ bool FSOpalManager::initialize(
///TODO m_pH323Endpoint->SetVendorIdentifierInfo()
///TODO address should be configurable, should allow creaeing listeners on multiple interfaces
OpalTransportAddress opalTransportAddress("localhost",1720); //for time being create listener on all ip's and default port
OpalTransportAddress opalTransportAddress("192.168.0.1",1720); //for time being create listener on all ip's and default port
if(!m_pH323Endpoint->StartListeners(opalTransportAddress))
{
assert(0);
......@@ -174,8 +174,6 @@ bool FSOpalManager::initialize(
return true;
}
switch_core_session_t* FSOpalManager::getSessionToken(const PString &i_token)
{
assert(m_pSessionsHashTable);
......@@ -197,6 +195,18 @@ void FSOpalManager::deleteSessionToken(const PString &i_token)
switch_core_hash_delete_locked(m_pSessionsHashTable,(const char*)i_token,m_pSessionsHashTableMutex);
}
switch_call_cause_t FSOpalManager::causeH323ToOpal(OpalConnection::CallEndReason i_cause)
{
//TODO -> fill all causes
return SWITCH_CAUSE_NORMAL_CLEARING;
}
OpalConnection::CallEndReason FSOpalManager::causeOpalToH323(switch_call_cause_t i_cause)
{
//TODO -> fill all causes
return OpalConnection::EndedByLocalUser;
}
BOOL FSOpalManager::OnIncomingConnection(
OpalConnection & connection, ///< Connection that is calling
......@@ -263,7 +273,7 @@ BOOL FSOpalManager::OnIncomingConnection(
"default", /** TODO -> this should be configurable by core */
(const char*)connection.GetRemotePartyName(), /** caller_id_name */
(const char*)connection.GetRemotePartyNumber(), /** caller_id_number */
(const char*)connection.GetRemotePartyAddress(), /** network addr */
(const char*)connection.GetRemotePartyAddress(),/** network addr */
NULL, /** ANI */
NULL, /** ANI II */
NULL, /** RDNIS */
......@@ -313,7 +323,17 @@ BOOL FSOpalManager::OnIncomingConnection(
}
OpalConnection::AnswerCallResponse FSOpalManager::OnAnswerCall(
OpalConnection &connection,
const PString &caller)
{
switch_core_session_t *session = getSessionToken((const char*)connection.GetToken());
if(session==NULL) /* that can mean that session has been already destroyed by core and we should release it */
{
return OpalConnection::AnswerCallDenied;
}
return OpalConnection::AnswerCallDeferred; //don't send alerting signal yet
}
......@@ -326,6 +346,22 @@ BOOL FSOpalManager::OnIncomingConnection(
switch_status_t FSOpalManager::callback_on_init(switch_core_session_t *io_session)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"callback_on_init\n");
OpalH323Private_t* tech_prv = (OpalH323Private_t*)switch_core_session_get_private(io_session);
if(tech_prv==NULL)
{
assert(0);
return SWITCH_STATUS_NOTFOUND;
}
SLock(tech_prv->m_mutex); /* lock channel */
switch_channel_t *channel = switch_core_session_get_channel(io_session);
assert(channel);
/* Move Channel's State Machine to RING */
switch_channel_set_state(channel, CS_RING);
return SWITCH_STATUS_SUCCESS;
}
......@@ -336,6 +372,7 @@ switch_status_t FSOpalManager::callback_on_init(switch_core_session_t *io_sessio
switch_status_t FSOpalManager::callback_on_ring(switch_core_session_t *io_session)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"callback_on_ring\n");
return SWITCH_STATUS_SUCCESS;
}
......@@ -346,6 +383,7 @@ switch_status_t FSOpalManager::callback_on_ring(switch_core_session_t *io_sessio
switch_status_t FSOpalManager::callback_on_execute(switch_core_session_t *io_session)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"callback_on_execute\n");
return SWITCH_STATUS_SUCCESS;
}
......@@ -356,6 +394,20 @@ switch_status_t FSOpalManager::callback_on_execute(switch_core_session_t *io_ses
switch_status_t FSOpalManager::callback_on_hangup(switch_core_session_t *io_session)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"callback_on_hangup\n");
OpalH323Private_t* tech_prv = (OpalH323Private_t*)switch_core_session_get_private(io_session);
switch_mutex_lock(tech_prv->m_mutex); /* lock channel */
deleteSessionToken(tech_prv->m_opalConnection->GetToken()); //delete this connection form connection pool
switch_channel_t *channel = switch_core_session_get_channel(io_session);
if(tech_prv->m_opalConnection)
{
//switch_call_cause_t cause = switch_channel_get_cause(channel);
tech_prv->m_opalConnection->Release(); ///TODO add cause
}
switch_mutex_unlock(tech_prv->m_mutex);
OpalH323Private_Delete(tech_prv);
return SWITCH_STATUS_SUCCESS;
}
......@@ -367,6 +419,7 @@ switch_status_t FSOpalManager::callback_on_hangup(switch_core_session_t *io_sess
switch_status_t FSOpalManager::callback_on_loopback(switch_core_session_t *io_session)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"callback_on_loopback\n");
return SWITCH_STATUS_SUCCESS;
}
......@@ -377,48 +430,56 @@ switch_status_t FSOpalManager::callback_on_loopback(switch_core_session_t *io_se
switch_status_t FSOpalManager::callback_on_transmit(switch_core_session_t *io_session)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"callback_on_transmit\n");
return SWITCH_STATUS_SUCCESS;
}
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);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_outgoing_channel\n");
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)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_read_frame\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSOpalManager::io_write_frame(switch_core_session_t *i_session, switch_frame_t *i_frame, int i_timeout, switch_io_flag_t i_flag, int i_streamId)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_write_frame\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSOpalManager::io_kill_channel(switch_core_session_t *i_session, int sig)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_kill_channel\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSOpalManager::io_waitfor_read(switch_core_session_t *i_session, int i_ms, int i_streamId)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_waitfor_read\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSOpalManager::io_waitfor_write(switch_core_session_t *i_session, int i_ms, int i_streamId)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_waitfor_write\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSOpalManager::io_send_dtmf(switch_core_session_t *i_session, char *i_dtmf)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_send_dtmf\n");
return SWITCH_STATUS_SUCCESS;
}
......@@ -484,6 +545,8 @@ switch_status_t FSOpalManager::io_receive_message(switch_core_session_t *i_sessi
case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT\n");
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"SWITCH_MESSAGE_???\n");
}
switch_mutex_unlock(tech_prv->m_mutex);
......@@ -493,23 +556,27 @@ switch_status_t FSOpalManager::io_receive_message(switch_core_session_t *i_sessi
switch_status_t FSOpalManager::io_receive_event(switch_core_session_t *i_session, switch_event_t *i_event)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_receive_event\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSOpalManager::io_state_change(switch_core_session_t *)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_state_change\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSOpalManager::io_read_video_frame(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_read_video_frame\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSOpalManager::io_write_video_frame(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int)
{
assert(m_isInitialized);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG ,"io_write_video_frame\n");
return SWITCH_STATUS_SUCCESS;
}
......@@ -36,6 +36,35 @@
#include <opal/manager.h>
#include <h323/h323ep.h>
/**
* Helper class for mutex use
*
**/
class SLock
{
public:
SLock(switch_mutex_t* i_mutex) :
m_mutex(NULL)
{
assert(i_mutex);
m_mutex = i_mutex;
switch_mutex_lock(m_mutex);
}
~SLock()
{
switch_mutex_unlock(m_mutex);
}
private:
switch_mutex_t* m_mutex;
};
/** This class is OpalManager implementation
* for FreeSWITCH OpalH323 module.
* All methods are inherited from base OpalManagerClass.
......@@ -94,6 +123,13 @@ 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_write_video_frame(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
/**
* Following OnIncomingConnection functions
* have been overriden for serving
* connections comming from H323 network
* They are called on receiving SETUP
*/
virtual BOOL OnIncomingConnection(
OpalConnection & connection, ///< Connection that is calling
unsigned options, ///< options for new connection (can't use default as overrides will fail)
......@@ -108,6 +144,16 @@ public:
OpalConnection & connection ///< Connection that is calling
);
/**
* OnAnswerCall function is overriden for
* serving a situation where H323 driver has send
* CALL PROCEEDING message
*/
virtual OpalConnection::AnswerCallResponse OnAnswerCall(
OpalConnection &connection,
const PString &caller);
private:
......@@ -116,6 +162,9 @@ private:
switch_core_session_t* getSessionToken(const PString &i_token);
void deleteSessionToken(const PString &i_token);
switch_call_cause_t causeH323ToOpal(OpalConnection::CallEndReason i_cause);
OpalConnection::CallEndReason causeOpalToH323(switch_call_cause_t i_cause);
const char *m_pModuleName; /* name of this module */
bool m_isInitialized; /* true if module has been initialized properly */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论