[Freeswitch-branches] [commit] r11138 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax

FreeSWITCH SVN gmaruzz at freeswitch.org
Mon Jan 12 09:29:26 PST 2009


Author: gmaruzz
Date: Mon Jan 12 11:29:26 2009
New Revision: 11138

Log:
skypiax: implemented anthm suggested changes, no more pointer to session in pvt, use uuid instead

Modified:
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c

Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c	(original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c	Mon Jan 12 11:29:26 2009
@@ -59,6 +59,8 @@
 
 static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
 {
+switch_core_session_t *session=NULL;
+
   if (switch_core_codec_init
       (&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1,
        SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
@@ -79,8 +81,12 @@
   tech_pvt->read_frame.rate = sample_rate;
   tech_pvt->read_frame.codec = &tech_pvt->read_codec;
 
-  switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
-  switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
+  session = switch_core_session_locate(tech_pvt->session_uuid_str);
+
+  switch_core_session_set_read_codec(session, &tech_pvt->read_codec);
+  switch_core_session_set_write_codec(session, &tech_pvt->write_codec);
+
+  switch_core_session_rwunlock(session);
 
   return SWITCH_STATUS_SUCCESS;
 
@@ -97,7 +103,7 @@
   switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED,
                     switch_core_session_get_pool(session));
   switch_core_session_set_private(session, tech_pvt);
-  tech_pvt->session = session;
+  switch_copy_string(tech_pvt->session_uuid_str, switch_core_session_get_uuid(session), sizeof(tech_pvt->session_uuid_str));
   if (skypiax_codec(tech_pvt, SAMPLERATE_SKYPIAX, 20) != SWITCH_STATUS_SUCCESS) {
     ERRORA("skypiax_codec FAILED\n", SKYPIAX_P_LOG);
   } else {
@@ -577,7 +583,7 @@
       DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
 
       if (tech_pvt) {
-        session = tech_pvt->session;
+	session = switch_core_session_locate(tech_pvt->session_uuid_str);
 
         if (session) {
           channel = switch_core_session_get_channel(session);
@@ -587,13 +593,13 @@
             ERRORA("no channel?\n", SKYPIAX_P_LOG);
           }
         } else {
-          ERRORA("no session?\n", SKYPIAX_P_LOG);
+          DEBUGA_SKYPE("no session\n", SKYPIAX_P_LOG);
         }
       } else {
         ERRORA("no tech_pvt?\n", SKYPIAX_P_LOG);
       }
       tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-      tech_pvt->session = NULL; //FIXME
+      memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str));
     }
   }
   DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);

Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h	(original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h	Mon Jan 12 11:29:26 2009
@@ -157,7 +157,7 @@
   switch_codec_t write_codec;
   switch_frame_t read_frame;
   unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
-  switch_core_session_t *session;
+  char 	session_uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1];
   switch_caller_profile_t *caller_profile;
   switch_mutex_t *mutex;
   switch_mutex_t *flag_mutex;

Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	(original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	Mon Jan 12 11:29:26 2009
@@ -1353,8 +1353,7 @@
 
               DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
 
-              //tech_pvt = p;
-              session = tech_pvt->session;
+	      session = switch_core_session_locate(tech_pvt->session_uuid_str);
               channel = switch_core_session_get_channel(session);
 
               if (channel) {
@@ -1566,7 +1565,7 @@
 
                 //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
 
-                if (!tech_pvt->session) {   //FIXME FIXME FIXME 
+                if (!strlen(tech_pvt->session_uuid_str)) {   
                   switch_core_session_t *session = NULL;
                   //private_t *tech_pvt = NULL;
                   switch_channel_t *channel = NULL;
@@ -1620,10 +1619,10 @@
                   switch_core_session_t *session = NULL;
                   switch_channel_t *channel = NULL;
 
-                  if (tech_pvt->session) {
-                    session = tech_pvt->session;
+                  if (strlen(tech_pvt->session_uuid_str)) {
+		    session = switch_core_session_locate(tech_pvt->session_uuid_str);
                   } else {
-                    ERRORA("No tech_pvt->session???\n", SKYPIAX_P_LOG);
+                    ERRORA("No session???\n", SKYPIAX_P_LOG);
                   }
                   if (session) {
                     channel = switch_core_session_get_channel(session);
@@ -1714,7 +1713,7 @@
     }
     return -1;
   }
-  tech_pvt->session = session;
+  switch_copy_string(tech_pvt->session_uuid_str, switch_core_session_get_uuid(session), sizeof(tech_pvt->session_uuid_str));
   caller_profile = tech_pvt->caller_profile;
   caller_profile->destination_number = rdest;
 



More information about the Freeswitch-branches mailing list