[Freeswitch-svn] [commit] r6138 - freeswitch/trunk/src/mod/endpoints/mod_opal

Freeswitch SVN lzwierko at freeswitch.org
Thu Nov 1 17:36:41 EDT 2007


Author: lzwierko
Date: Thu Nov  1 17:36:41 2007
New Revision: 6138

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp
   freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.cpp
   freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.h

Log:
1. added Tuyan fix/simplification for Opal engine starting  
2. some progress in call control implementation

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp	Thu Nov  1 17:36:41 2007
@@ -26,11 +26,12 @@
  *
  * $Log: mod_opal.cpp,v $
  *
- * Revision 1.00  2007/10/24 07:29:52  lzwierko
+ * Revision 1.00  2007/10/24 07:29:52  Lukasz Zwierko
  * Initial revision
  */
 
-
+#include <ptlib.h>
+#include <ptlib/svcproc.h>
 #include "mod_opal.h"
 #include "opal_backend.h"
 #include <switch.h>
@@ -65,161 +66,22 @@
  */
 static switch_memory_pool_t *opal_pool = NULL;
 static switch_endpoint_interface_t *opalh323_endpoint_interface = NULL;
+static FSOpalManager *opal_manager = NULL;
 
-/** 
- * Declaration of PProces ancestor for OpalManager starting 
- *
- */
-class OpalStartProcess : public PProcess
-{
-  PCLASSINFO(OpalStartProcess, PProcess)
 
-  public:
-    
-      
-    /** 
-     * This dunction creates new instace of 
-     * OpalStartProcess and starts it's task
-     */
-    static void createInstance(
-            const char* i_moduleName,
-            switch_memory_pool_t *i_memoryPool,
-            switch_endpoint_interface_t *i_endpointInterface)
-    {       
-        assert(!s_startProcess);
-        assert(i_moduleName);
-        assert(i_memoryPool);
-        assert(i_endpointInterface);        
-               
-        PProcess::PreInitialise(0, NULL, NULL);
-        s_startProcess = new OpalStartProcess(i_moduleName,i_memoryPool,i_endpointInterface);
-        assert(s_startProcess);
-        if(!s_startProcess)
-        {
-            return;
-        }
-        s_startProcess->_main(); /* run process */    
-        delete s_startProcess;   /* delete opal manager instance */ 
-        s_startProcess = NULL;   /* clear pointer */
-    }
-    
-    static OpalStartProcess* getInstance()
-    {
-        assert(s_startProcess);
-        return s_startProcess;
-    }
-    
-    static bool checkInstanceExists()
-    {        
-        return s_startProcess!=NULL;
-    }
-    
-    OpalStartProcess(
-        const char* i_moduleName,
-        switch_memory_pool_t *i_memoryPool,
-        switch_endpoint_interface_t *i_endpointInterface
-    ):             
-        PProcess("FreeSWITCH", "mod_opal"),
-        m_pStopCondition(NULL),  
-        m_pModuleName(i_moduleName),
-        m_pMemoryPool(i_memoryPool),
-        m_pEndpointInterface(i_endpointInterface)
-    {                    
-           
-        
-            switch_status_t status = switch_thread_cond_create(&m_pStopCondition, m_pMemoryPool);
-            assert(status==SWITCH_STATUS_SUCCESS);
-            if(status!=SWITCH_STATUS_SUCCESS) 
-            {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can not init stop condition.");
-                return;
-            }                        
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "OpalStartProcess created\n");
-    }
-        
-    ~OpalStartProcess()
-    {
-        switch_thread_cond_destroy(m_pStopCondition);
-                
-        m_pModuleName        = NULL;
-        m_pMemoryPool        = NULL;
-        m_pEndpointInterface = NULL; 
-    }
-    
-    FSOpalManager *getManager()
-    {
-        assert(!m_pFSOpalManager);
-        return m_pFSOpalManager;
-    }
-      
-    /* main task of this PProcess */
-    void Main()
-    {                
-        /* backend initialization */
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Begin opal backend init\n");
-        m_pFSOpalManager = new FSOpalManager();
-        assert(m_pFSOpalManager);
-        if(!m_pFSOpalManager) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can not create opal manger\n");
-            return;
-        }
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager created\n");
-        
-        if(!m_pFSOpalManager->initialize(m_pModuleName, m_pMemoryPool, m_pEndpointInterface)) 
-        {
-            delete m_pFSOpalManager;
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can not initialize opal manger\n");
-            return; /* if can't initialize return general error */
-        }
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager initilaized and running\n");       
-        WaitUntilStopped();        
-        delete m_pFSOpalManager;        
-        m_pFSOpalManager = NULL;                        
-    }        
-    
-    /** 
-     * Waits until this process is terminated
-     * which means it exits Main() function
-     */
-    void StopProcess()
-    {
-        switch_thread_cond_signal(m_pStopCondition);
-    }
-    
-  protected:              
-      
-      /*
-       * After entering this functon, process 
-       * locks o condition
-       * and stays there until signalled 
-       */
-      
-      void WaitUntilStopped()
-      {
-          switch_mutex_t* mutex = NULL;
-          switch_status_t status = switch_mutex_init(&mutex, SWITCH_MUTEX_NESTED, m_pMemoryPool);
-          if(status!=SWITCH_STATUS_SUCCESS) 
-          {
-              switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"Error acquiring mutex!\n");
-              assert(0);
-              return;
-          }
-          switch_mutex_lock(mutex);
-          switch_thread_cond_wait(m_pStopCondition, mutex);
-          switch_mutex_unlock(mutex);
-          switch_mutex_destroy(mutex);            
-      }
-      
-      static OpalStartProcess     *s_startProcess;
-      
-      const char                  *m_pModuleName;
-      switch_memory_pool_t        *m_pMemoryPool;
-      switch_endpoint_interface_t *m_pEndpointInterface;              
-      FSOpalManager               *m_pFSOpalManager;
-      switch_thread_cond_t        *m_pStopCondition; /* the main thread waits on this condition until is to be stopped */      
-        
-};
-OpalStartProcess* OpalStartProcess::s_startProcess = NULL;
+/*
+ * This is Tuyan's Ozipek neat trick 
+ * to initialize PProcess instance
+ * which is needed by OpalManager
+ */
+class _FSOpalProcess : public PProcess
+{
+   PCLASSINFO(_FSOpalProcess, PProcess)
+   public:
+       _FSOpalProcess(){PTrace::SetLevel(PSystemLog::Info);}; //just for fun and eyecandy ;)
+       void Main() {};
+} FSOpalProcess;
+
 
 /*
  * IO routines handlers set declaration 
@@ -253,8 +115,7 @@
  */
 SWITCH_MODULE_LOAD_FUNCTION(mod_opal_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_opal_shutdown);
-SWITCH_MODULE_RUNTIME_FUNCTION(mod_opal_runtime);
-SWITCH_MODULE_DEFINITION(mod_opal, mod_opal_load, mod_opal_shutdown, mod_opal_runtime);
+SWITCH_MODULE_DEFINITION(mod_opal, mod_opal_load, mod_opal_shutdown, NULL);
 
 /*
  * This function is called on module load
@@ -277,27 +138,33 @@
         return SWITCH_STATUS_MEMERR;
     }
     opalh323_endpoint_interface = (switch_endpoint_interface_t*)switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
-    opalh323_endpoint_interface->interface_name = "OpalH323";
+    opalh323_endpoint_interface->interface_name = "opalH323";
     opalh323_endpoint_interface->io_routines = &opalh323_io_routines;
     opalh323_endpoint_interface->state_handler = &opalh323_event_handlers;
        
+    
+    /* backend initialization */
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Begin opal backend init\n");
+    opal_manager = new FSOpalManager();
+    assert(opal_manager);
+    if(!opal_manager) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can not create opal manger\n");
+        return SWITCH_STATUS_MEMERR;
+    }
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager created\n");
+    
+    if(!opal_manager->initialize(modname, opal_pool, opalh323_endpoint_interface)) {
+        delete opal_manager;
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can not initialize opal manger\n");
+        return SWITCH_STATUS_FALSE; /* if can't initialize return general error */
+    }
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager initilaized and running\n");
+        
+    
     return SWITCH_STATUS_SUCCESS;
 }
 
 /*
- * This function is called after module initilization
- * It sets up and run backend interface to opal
- *
- */
-
-SWITCH_MODULE_RUNTIME_FUNCTION(mod_opal_runtime)
-{
-    OpalStartProcess::createInstance(modname,opal_pool,opalh323_endpoint_interface);    
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"Opal runtime fun exit\n");
-    return SWITCH_STATUS_TERM;
-}
-
-/*
  * This functionis called on module teardown
  * It releases all internal resources, i.e. 
  * it dealocates OPAL core
@@ -307,12 +174,10 @@
 {
     /* deallocate OPAL manager */
     
-    OpalStartProcess::getInstance()->StopProcess(); /* terminate process */    
-    while(OpalStartProcess::checkInstanceExists())
-    {
-        switch_yield(1000); /* wait 1s in each loop */
-    }
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"Opal shutdown succesfully\n");
+    delete opal_manager;
+    opal_manager = NULL;
+    opal_pool = NULL;
+    opalh323_endpoint_interface = NULL;
     return SWITCH_STATUS_SUCCESS;
 }
 
@@ -325,62 +190,62 @@
         switch_core_session_t **new_session, 
         switch_memory_pool_t **pool)
 {
-     return  OpalStartProcess::getInstance()->getManager()->io_outgoing_channel(session,outbound_profile,new_session,pool);
+     return  opal_manager->io_outgoing_channel(session,outbound_profile,new_session,pool);
 }
 
 static switch_status_t opalh323_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_read_frame(session,frame,timeout,flags,stream_id);
+    return opal_manager->io_read_frame(session,frame,timeout,flags,stream_id);
 }
 
 static switch_status_t opalh323_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_write_frame(session,frame,timeout,flags,stream_id);
+    return opal_manager->io_write_frame(session,frame,timeout,flags,stream_id);
 }
 
 static switch_status_t opalh323_kill_channel(switch_core_session_t *session, int sig)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_kill_channel(session,sig);
+    return opal_manager->io_kill_channel(session,sig);
 }
 
 static switch_status_t opalh323_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_waitfor_read(session,ms,stream_id);
+    return opal_manager->io_waitfor_read(session,ms,stream_id);
 }
 
 static switch_status_t opalh323_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_waitfor_write(session,ms,stream_id);
+    return opal_manager->io_waitfor_write(session,ms,stream_id);
 }
 
 static switch_status_t opalh323_send_dtmf(switch_core_session_t *session, char *dtmf)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_send_dtmf(session,dtmf);
+    return opal_manager->io_send_dtmf(session,dtmf);
 }
 
 static switch_status_t opalh323_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_receive_message(session,msg);
+    return opal_manager->io_receive_message(session,msg);
 }
 
 static switch_status_t opalh323_receive_event(switch_core_session_t *session, switch_event_t *event)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_receive_event(session,event);
+    return opal_manager->io_receive_event(session,event);
 }
 
 static switch_status_t opalh323_state_change(switch_core_session_t *session)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_state_change(session);
+    return opal_manager->io_state_change(session);
 }
 
 static switch_status_t opalh323_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flag, int stream_id)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_read_video_frame(session,frame,timeout,flag,stream_id);
+    return opal_manager->io_read_video_frame(session,frame,timeout,flag,stream_id);
 }
 
 static switch_status_t opalh323_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flag, int stream_id)
 {
-    return OpalStartProcess::getInstance()->getManager()->io_write_video_frame(session,frame,timeout,flag,stream_id);
+    return opal_manager->io_write_video_frame(session,frame,timeout,flag,stream_id);
 }
 
 /*
@@ -389,30 +254,30 @@
 
 static switch_status_t opalh323_on_init(switch_core_session_t *session)
 {
-    return OpalStartProcess::getInstance()->getManager()->callback_on_init(session);
+    return opal_manager->callback_on_init(session);
 }
 
 static switch_status_t opalh323_on_ring(switch_core_session_t *session)
 {
-    return OpalStartProcess::getInstance()->getManager()->callback_on_ring(session);
+    return opal_manager->callback_on_ring(session);
 }
 
 static switch_status_t opalh323_on_execute(switch_core_session_t *session)
 {
-    return OpalStartProcess::getInstance()->getManager()->callback_on_execute(session);
+    return opal_manager->callback_on_execute(session);
 }
 
 static switch_status_t opalh323_on_hangup(switch_core_session_t *session)
 {
-    return OpalStartProcess::getInstance()->getManager()->callback_on_hangup(session);
+    return opal_manager->callback_on_hangup(session);
 }
 
 static switch_status_t opalh323_on_loopback(switch_core_session_t *session)
 {
-    return OpalStartProcess::getInstance()->getManager()->callback_on_loopback(session);
+    return opal_manager->callback_on_loopback(session);
 }
 
 static switch_status_t opalh323_on_transmit(switch_core_session_t *session)
 {
-    return OpalStartProcess::getInstance()->getManager()->callback_on_transmit(session);
+    return opal_manager->callback_on_transmit(session);
 }

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.cpp
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.cpp	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.cpp	Thu Nov  1 17:36:41 2007
@@ -159,7 +159,7 @@
     ///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 @@
     return true;
 }
 
-
-
 switch_core_session_t* FSOpalManager::getSessionToken(const PString &i_token)
 {
     assert(m_pSessionsHashTable);
@@ -197,6 +195,18 @@
     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
@@ -259,11 +269,11 @@
     /** Create calling side profile */
     tech_pvt->m_callerProfile = switch_caller_profile_new(
             switch_core_session_get_pool(session),
-            (const char*)connection.GetRemotePartyName(),               /**  username */
+            (const char*)connection.GetRemotePartyName(),   /**  username */
             "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.GetRemotePartyName(),   /** caller_id_name */
+            (const char*)connection.GetRemotePartyNumber(), /** caller_id_number */
+            (const char*)connection.GetRemotePartyAddress(),/** network addr */
             NULL,                                           /** ANI */
             NULL,                                           /** ANI II */
             NULL,                                           /** RDNIS */
@@ -292,7 +302,7 @@
     
           
     /***Mark incoming call as AnsweredPending ??? */
-    
+   
 
     /** lunch thread */       
     if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) 
@@ -312,8 +322,18 @@
     return TRUE;
     
 }
- 
 
+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 @@
 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_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_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_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_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_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;
 }
 
@@ -483,7 +544,9 @@
     break;        
     case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT\n");
-    break;        
+    break;  
+    default:
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"SWITCH_MESSAGE_???\n");            
     }
     
     switch_mutex_unlock(tech_prv->m_mutex);
@@ -491,25 +554,29 @@
 }
 
 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;
 }

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/opal_backend.h	Thu Nov  1 17:36:41 2007
@@ -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 @@
     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)
@@ -107,6 +143,16 @@
     virtual BOOL OnIncomingConnection(
         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);
+    
         
         
     
@@ -116,6 +162,9 @@
     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 */



More information about the Freeswitch-svn mailing list