]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4079 FS-4540 minor refactoring to fix some minor side effects of recent changes
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 23 Aug 2012 16:10:03 +0000 (11:10 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 23 Aug 2012 16:10:03 +0000 (11:10 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index 54670fd802b0238b9a554ffc4263d7ecb4f91f6e..e52359c90b4ca6a237bdd71e2cd2ec61fae3f6e1 100644 (file)
@@ -4445,12 +4445,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
                goto error;
        }
 
-       if (!(tech_pvt = (struct private_object *) switch_core_session_alloc(nsession, sizeof(*tech_pvt)))) {
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error Creating Session\n");
-               goto error;
-       }
-       switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession));
-       switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession));
+       tech_pvt = sofia_glue_new_pvt(session);
 
        data = switch_core_session_strdup(nsession, outbound_profile->destination_number);
        if ((dest_to = strchr(data, '^'))) {
index 97d397255d014a4c658b792b94485f0122536a5b..ecbf36d7a4c57866ac4bd20a54721ecf0acb0918 100644 (file)
@@ -1188,6 +1188,8 @@ void sofia_presence_check_subscriptions(sofia_profile_t *profile, time_t now);
 void sofia_msg_thread_start(int idx);
 void crtp_init(switch_loadable_module_interface_t *module_interface);
 int sofia_recover_callback(switch_core_session_t *session);
+void sofia_glue_set_name(private_object_t *tech_pvt, const char *channame);
+private_object_t *sofia_glue_new_pvt(switch_core_session_t *session);
 
 /* For Emacs:
  * Local Variables:
index f8262b907ecb97dc3ccd4a985d52fc0dffb75b00..d48b30d0154d04df327ceb4d764e01dbb92c9ffd 100644 (file)
@@ -1718,15 +1718,8 @@ void sofia_event_callback(nua_event_t event,
                }
 
                if (session) {
-                       private_object_t *tech_pvt;
-
-                       tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t));
-                       tech_pvt->profile = profile;
-                       tech_pvt->channel = switch_core_session_get_channel(session);
-                       tech_pvt->session = session;
-                       switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-                       switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-                       switch_core_session_set_private(session, tech_pvt);
+                       private_object_t *tech_pvt = sofia_glue_new_pvt(session);
+                       sofia_glue_attach_private(session, profile, tech_pvt, NULL);
 
                } else {
                        nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
@@ -8582,7 +8575,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                }
        }
 
-       sofia_glue_attach_private(session, profile, tech_pvt, channel_name);
+       sofia_glue_set_name(tech_pvt, channel_name);
        sofia_glue_tech_prepare_codecs(tech_pvt);
 
        switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL");
index 0f20a8a4f781057f500ab1e752b0080732c9c677..c642657fb71c7e709441d4f8c14504e38d370d3d 100644 (file)
@@ -881,13 +881,31 @@ void sofia_glue_check_video_codecs(private_object_t *tech_pvt)
        }
 }
 
+private_object_t *sofia_glue_new_pvt(switch_core_session_t *session)
+{
+       private_object_t *tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t));
+       switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+       switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+       return tech_pvt;
+}
 
-void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame)
+void sofia_glue_set_name(private_object_t *tech_pvt, const char *channame)
 {
        char name[256];
-       unsigned int x;
        char *p;
 
+       switch_snprintf(name, sizeof(name), "sofia/%s/%s", tech_pvt->profile->name, channame);
+       if ((p = strchr(name, ';'))) {
+               *p = '\0';
+       }
+       switch_channel_set_name(tech_pvt->channel, name);
+}
+
+void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame)
+{
+
+       unsigned int x;
+
        switch_assert(session != NULL);
        switch_assert(profile != NULL);
        switch_assert(tech_pvt != NULL);
@@ -949,12 +967,9 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
        switch_core_session_set_private(session, tech_pvt);
 
        if (channame) {
-               switch_snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
-               if ((p = strchr(name, ';'))) {
-                       *p = '\0';
-               }
-               switch_channel_set_name(tech_pvt->channel, name);
+               sofia_glue_set_name(tech_pvt, channame);
        }
+
 }
 
 switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_object_t *tech_pvt, char **ip, switch_port_t *port,