]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix playback_ms and record_ms to work right and add playback_seconds and record_seconds
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 13 Oct 2009 22:29:20 +0000 (22:29 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 13 Oct 2009 22:29:20 +0000 (22:29 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15155 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia.c
src/switch_core_file.c
src/switch_ivr_play_say.c

index 0c9c0386e5ef292ad2f05fe3ac1d504057a2c9bb..e1c8f4813749940b787a44b66299ef2927155eab 100644 (file)
@@ -402,7 +402,7 @@ void sofia_send_callee_id(switch_core_session_t *session, const char *name, cons
 
        if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (session_b = switch_core_session_locate(uuid))) {
                switch_core_session_message_t *msg;
-
+               
                msg = switch_core_session_alloc(session_b, sizeof(*msg));
                MESSAGE_STAMP_FFL(msg);
                msg->message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
@@ -468,6 +468,8 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
        caller_profile = switch_channel_get_caller_profile(channel);
        caller_profile->callee_id_name = switch_core_strdup(caller_profile->pool, name);
        caller_profile->callee_id_number = switch_core_strdup(caller_profile->pool, number);
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Update Callee ID to \"%s\" <%s>\n", name, number);
        
        if (send) {
                sofia_send_callee_id(session, NULL, NULL);
index da63956bbd03a6d4e6117eaaf96aa89452e17e94..b8e86e31ba52b62c59ac5dc1a4ea486b0788b815 100644 (file)
@@ -498,9 +498,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
                                if ((blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen))) {
                                        if (!asis) blen /= 2;
                                        if (fh->channels > 1) blen /= fh->channels;
+                                       
                                        if (fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen) != SWITCH_STATUS_SUCCESS) {
                                                break;
                                        }
+                                       fh->samples_out += blen;
                                }
                        }
                }
index bfc3dc8df1eb7a936ac627f56f557035eeb52184..3a0450eeff357e6a2b6945d02cdc8b204eac9c10 100644 (file)
@@ -715,10 +715,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
                switch_core_codec_destroy(&write_codec);
        }
 
-       switch_channel_set_variable_printf(channel, "record_ms", "%d", fh->samples_in / read_impl.samples_per_second);
-       switch_channel_set_variable_printf(channel, "record_samples", "%d", fh->samples_in);
-
        switch_core_file_close(fh);
+
+       if (read_impl.samples_per_second)  {
+               switch_channel_set_variable_printf(channel, "record_seconds", "%d", fh->samples_out / read_impl.samples_per_second);
+               switch_channel_set_variable_printf(channel, "record_ms", "%d", fh->samples_out / (read_impl.samples_per_second / 1000));
+
+       }
+
+       switch_channel_set_variable_printf(channel, "record_samples", "%d", fh->samples_out);
+
        switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
        return status;
 }
@@ -1425,7 +1431,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
 
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "done playing file\n");
                
-               if (read_impl.samples_per_second) switch_channel_set_variable_printf(channel, "playback_ms", "%d", fh->samples_out / read_impl.samples_per_second);
+               if (read_impl.samples_per_second) {
+                       switch_channel_set_variable_printf(channel, "playback_seconds", 
+                                                                                          "%d", fh->samples_out / read_impl.samples_per_second);
+                       switch_channel_set_variable_printf(channel, "playback_ms", 
+                                                                                          "%d", fh->samples_out / (read_impl.samples_per_second / 1000) );
+               }
                switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_out);
 
                switch_core_file_close(fh);