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

Freeswitch SVN lzwierko at freeswitch.org
Sat Oct 27 12:00:56 EDT 2007


Author: lzwierko
Date: Sat Oct 27 12:00:55 2007
New Revision: 6067

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

Log:


Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/opalh323_backend.cpp
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/opalh323_backend.cpp	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/opalh323_backend.cpp	Sat Oct 27 12:00:55 2007
@@ -49,8 +49,11 @@
  */
 FSOpalManager::FSOpalManager() :
     m_isInitialized(false),
-    m_pH323Endpoint(NULL);
-    m_pMemoryPool(NULL)
+    m_pH323Endpoint(NULL),
+    m_pMemoryPool(NULL).
+    m_pEndpointInterface(NULL),
+    m_pSessionsHashTable(NULL),
+    m_pSessionsHashTableMutex(NULL)
 {
     
 }
@@ -66,8 +69,9 @@
     if(m_isInitialized)
     {
         delete m_pH323Endpoint;
-        m_pH323Endpoint = NULL;
-        m_isInitialized = false;
+        switch_mutex_destroy(m_pSessionsHashTableMutex);
+        switch_core_hash_destroy(m_pSessionsHashTable);
+      
     }
 }
 
@@ -85,6 +89,8 @@
     assert(m_isInitialized);
     assert(!m_pH323Endpoint);
     assert(!m_pMemoryPool)
+    assert(!m_pEndpointInterface);
+    assert(!m_pSessionsHashTable);
     
     /* check input parameters */
     assert(i_memoryPool);
@@ -94,12 +100,33 @@
     
     m_pMemoryPool = i_memoryPool;
     m_pEndpointInterface = i_endpointInterface;
+
+    /**
+     * Create hash table for storing pointers to session objects,
+     * Each OpalConnection object will retreive it's session object using
+     * its callToken as a key
+     */
+    
+    if(switch_core_hash_init(&m_pSessionsHashTable,m_pMemoryPool)!=SWITCH_STATUS_SUCCESS)
+    {
+        assert(0);
+        return false;
+    }
+    
+    if(switch_mutex_init(&m_pSessionsHashTableMutex,SWITCH_THREAD_MUTEX_UNNESTED,m_pMemoryPool)!=SWITCH_STATUS_SUCCESS)
+    {
+       assert(0);
+       switch_core_hash_destroy(m_pSessionsHashTable);     
+       return false; 
+    }
     
     /* create h323 endpoint */
     m_pH323Endpoint = new H323EndPoint(this);   ///TODO, replace prefix and signaling port by values from configuration
     if(!m_pH323Endpoint)
     {
         assert(0);
+        switch_core_hash_destroy(m_pSessionsHashTable); 
+        switch_mutex_destroy(m_pSessionsHashTableMutex);
         return false;
     }
     
@@ -117,11 +144,12 @@
     
     ///TODO address should be configurable, should allow creaeing listeners on multiple interfaces
     OpalTransportAddress opalTransportAddress("0.0.0.0",1720); //for time being create listener on all ip's and default port
-    result = m_pH323Endpoint->StartListeners(opalTransportAddress);
-    assert(result);
-    if(!result)
+    if(!m_pH323Endpoint->StartListeners(opalTransportAddress))
     {
-        delete m_pH323Endpoint:
+        assert(0);
+        swith_core_hash_destroy(m_pSessionsHashTable);    
+        switch_mutex_destroy(m_pSessionsHashTableMutex);
+        delete m_pH323Endpoint:            
         return false;
     }                 
     
@@ -176,10 +204,20 @@
     }
     tech_pvt->m_opalConnection = &connection;
     switch_mutex_init(&tech_pvt->m_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-    /** save private data under hash and in session */
     
+    /** Save private data in session private data, and save session in hash tabel, under GetToken() key */
+    switch_core_session_set_private(session,static_cast<void*>(tech_pvt));                                      ///save private data in session context
+    switch_core_hash_insert_locked(m_pSessionsHashTable,*(connection.GetToken()),static_cast<void*>(session));  ///save pointer to session in hash table, for later retreival    
+               
     /***Mark incoming call as AnsweredPending ??? */
-
+    
+    
+    
+    
+    
+    
+    
+    return TRUE;
     
 }
  

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/opalh323_backend.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/opalh323_backend.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/opalh323_backend.h	Sat Oct 27 12:00:55 2007
@@ -65,7 +65,7 @@
      */
     bool initialize(
             switch_memory_pool_t* i_memoryPool,
-            switch_endpoint_interface_t *i_endpointInterface
+            switch_endpoint_interface_t *i_endpointInterface,
             );
     
     /** FS callback handlers declarations
@@ -80,11 +80,12 @@
     
 private:
     
-    bool                        m_isInitilized;         /* true if module has been initialized properly */
-    H323Endpoint                *m_pH323Endpoint;       /* h323 endpoint control */
-    switch_memory_pool_t        *m_pMemoryPool;         /* FS memory pool */
-    switch_endpoint_interface_t *m_pEndpointInterface;  /* FS endpoint inerface */
-    
+    bool                        m_isInitilized;             /* true if module has been initialized properly */
+    H323Endpoint                *m_pH323Endpoint;           /* h323 endpoint control */
+    switch_memory_pool_t        *m_pMemoryPool;             /* FS memory pool */
+    switch_endpoint_interface_t *m_pEndpointInterface;      /* FS endpoint inerface */
+    switch_hash_t               *m_pSessionsHashTable;      /* Stores pointrs to session object for each Opal connection */
+    switch_mutex_t              *m_pSessionsHashTableMutex; /* Protects hash table */
     
 };
 



More information about the Freeswitch-svn mailing list