]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
skypopen: fixing bug from Anton VG, adding some guards against NULL sessions and...
authorGiovanni Maruzzelli <gmaruzz@gmail.com>
Sat, 21 May 2011 07:36:51 +0000 (02:36 -0500)
committerGiovanni Maruzzelli <gmaruzz@gmail.com>
Sat, 21 May 2011 07:36:51 +0000 (02:36 -0500)
src/mod/endpoints/mod_skypopen/mod_skypopen.c

index 7b8bc16507064cf41df6f98cb16ca671d073d772..e86c86dc11bc5e1a7ea9d2b4ac1774f232059d88 100644 (file)
@@ -938,16 +938,21 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
                                                char *p = digit_str;
                                                switch_channel_t *channel = switch_core_session_get_channel(session);
 
-                                               while (p && *p) {
-                                                       switch_dtmf_t dtmf;
-                                                       dtmf.digit = *p;
-                                                       dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
-                                                       switch_channel_queue_dtmf(channel, &dtmf);
-                                                       p++;
+                                               if(channel){
+
+                                                       while (p && *p) {
+                                                               switch_dtmf_t dtmf;
+                                                               dtmf.digit = *p;
+                                                               dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+                                                               switch_channel_queue_dtmf(channel, &dtmf);
+                                                               p++;
+                                                       }
+                                                       NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
+                                                                       (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
+                                                       tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
+                                               }else{
+                                                       WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG);
                                                }
-                                               NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
-                                                          (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp));
-                                               tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
                                        }
                                }
                        }
@@ -2138,33 +2143,37 @@ int dtmf_received(private_t *tech_pvt, char *value)
        switch_channel_t *channel = NULL;
 
        session = switch_core_session_locate(tech_pvt->session_uuid_str);
-       channel = switch_core_session_get_channel(session);
+       if (session) {
+               channel = switch_core_session_get_channel(session);
 
-       if (channel) {
+               if (channel) {
 
-               if (switch_channel_test_flag(channel, CF_BRIDGED)
-                       && !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) {
+                       if (switch_channel_test_flag(channel, CF_BRIDGED)
+                                       && !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) {
 
 
-                       NOTICA
-                               ("received DTMF '%c' on channel %s, but we're BRIDGED, so we DO NOT relay it out of band. If you DO want to relay it out of band when bridged too, on top of audio DTMF, set the channel variable 'skype_add_outband_dtmf_also_when_bridged=true' \n",
-                                SKYPOPEN_P_LOG, value[0], switch_channel_get_name(channel));
+                               NOTICA
+                                       ("received DTMF '%c' on channel %s, but we're BRIDGED, so we DO NOT relay it out of band. If you DO want to relay it out of band when bridged too, on top of audio DTMF, set the channel variable 'skype_add_outband_dtmf_also_when_bridged=true' \n",
+                                        SKYPOPEN_P_LOG, value[0], switch_channel_get_name(channel));
 
-               } else {
+                       } else {
 
 
 
-                       switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
-                       DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPOPEN_P_LOG, dtmf.digit, switch_channel_get_name(channel));
-                       switch_mutex_lock(tech_pvt->flag_mutex);
-                       switch_channel_queue_dtmf(channel, &dtmf);
-                       switch_set_flag(tech_pvt, TFLAG_DTMF);
-                       switch_mutex_unlock(tech_pvt->flag_mutex);
+                               switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
+                               DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPOPEN_P_LOG, dtmf.digit, switch_channel_get_name(channel));
+                               switch_mutex_lock(tech_pvt->flag_mutex);
+                               switch_channel_queue_dtmf(channel, &dtmf);
+                               switch_set_flag(tech_pvt, TFLAG_DTMF);
+                               switch_mutex_unlock(tech_pvt->flag_mutex);
+                       }
+               } else {
+                       WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]);
                }
-       } else {
-               WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]);
+               switch_core_session_rwunlock(session);
+       }else{
+               WARNINGA("received %c DTMF, but no session?\n", SKYPOPEN_P_LOG, value[0]);
        }
-       switch_core_session_rwunlock(session);
 
        return 0;
 }