]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6067 d0543943-73ff-0310...
authorŁukasz Zwierko <lzwierko@gmail.com>
Sat, 27 Oct 2007 16:00:55 +0000 (16:00 +0000)
committerŁukasz Zwierko <lzwierko@gmail.com>
Sat, 27 Oct 2007 16:00:55 +0000 (16:00 +0000)
src/mod/endpoints/mod_opal/opalh323_backend.cpp
src/mod/endpoints/mod_opal/opalh323_backend.h

index 9340c186d13074c4f29018aa920a40df54fca4f5..f094ec077a8f63a66f4fce896c9c830fd3bac11b 100644 (file)
@@ -49,8 +49,11 @@ typedef struct OpalH323Private_s
  */
 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 @@ FSOpalManager::FSOpalManager() :
     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 @@ bool FSOpalManager::initialize(
     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 @@ bool FSOpalManager::initialize(
     
     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 @@ bool FSOpalManager::initialize(
     
     ///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 @@ BOOL FSOpalManager::OnIncomingConnection(
     }
     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;
     
 }
  
index d25d9c73ddf32c62f406da910c873e97e53c28fc..f1fbefb3b4708760636ee444a2bbc90ede1ab8c9 100644 (file)
@@ -65,7 +65,7 @@ public:
      */
     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 @@ public:
     
 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 */
     
 };