[Freeswitch-svn] [commit] r4485 - in freeswitch/trunk/src: . mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Thu Mar 8 17:18:34 EST 2007
Author: anthm
Date: Thu Mar 8 17:18:33 2007
New Revision: 4485
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/switch_rtp.c
Log:
update
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Mar 8 17:18:33 2007
@@ -910,20 +910,25 @@
static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from line: %d\n", line);
- if (*session) {
- switch_channel_t *channel = switch_core_session_get_channel(*session);
- struct private_object *tech_pvt = NULL;
- uint8_t running = (uint8_t)switch_core_session_running(*session);
- tech_pvt = switch_core_session_get_private(*session);
-
- if (running) {
- switch_channel_hangup(channel, cause);
- } else {
- sofia_on_hangup(*session);
- switch_core_session_destroy(session);
- }
- }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from line: %d\n", line);
+ if (*session) {
+ switch_channel_t *channel = switch_core_session_get_channel(*session);
+ switch_channel_state_t state = switch_channel_get_state(channel);
+ struct private_object *tech_pvt = NULL;
+ uint8_t running = switch_core_session_running(*session);
+ tech_pvt = switch_core_session_get_private(*session);
+
+ if (running) {
+ switch_channel_hangup(channel, cause);
+ } else {
+ if (tech_pvt) {
+ sofia_on_hangup(*session);
+ }
+ if (session && *session) {
+ switch_core_session_destroy(session);
+ }
+ }
+ }
}
@@ -1618,7 +1623,7 @@
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->agreed_pt,
- tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+ tech_pvt->read_codec.implementation->samples_per_frame,
tech_pvt->codec_ms * 1000,
(switch_rtp_flag_t) flags,
NULL,
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Thu Mar 8 17:18:33 2007
@@ -685,7 +685,7 @@
duration = rtp_session->dtmf_data.out_digit_sofar;
}
- /* ts = rtp_session->dtmf_data.timestamp_dtmf += samples; */
+
rtp_session->dtmf_data.out_digit_packet[2] = (unsigned char) (duration >> 8);
rtp_session->dtmf_data.out_digit_packet[3] = (unsigned char) duration;
@@ -710,6 +710,10 @@
rtp_session->dtmf_data.out_digit_seq);
}
+
+ if (loops == 1) {
+ rtp_session->last_write_seq = 0;
+ }
}
if (!rtp_session->dtmf_data.out_digit_dur && rtp_session->dtmf_data.dtmf_queue && switch_queue_size(rtp_session->dtmf_data.dtmf_queue)) {
@@ -726,17 +730,18 @@
rtp_session->dtmf_data.out_digit_packet[0] = (unsigned char)switch_char_to_rfc2833(rdigit->digit);
rtp_session->dtmf_data.out_digit_packet[1] = 7;
- /* ts = rtp_session->dtmf_data.timestamp_dtmf += samples;
- * rtp_session->dtmf_data.timestamp_dtmf++;
- */
+ if (rtp_session->timer.timer_interface) {
+ rtp_session->dtmf_data.timestamp_dtmf = rtp_session->timer.samplecount;
+ } else {
+ rtp_session->dtmf_data.timestamp_dtmf = rtp_session->last_write_ts;
+ }
- rtp_session->dtmf_data.timestamp_dtmf = rtp_session->last_write_ts;
rtp_session->dtmf_data.out_digit_seq = rtp_session->last_write_seq;
rtp_session->dtmf_data.out_digit_ssrc = rtp_session->last_write_ssrc;
for (x = 0; x < 3; x++) {
- rtp_session->dtmf_data.out_digit_seq++;
+ //rtp_session->dtmf_data.out_digit_seq++;
switch_rtp_write_manual(rtp_session,
rtp_session->dtmf_data.out_digit_packet,
4,
@@ -1168,7 +1173,7 @@
stat = srtp_protect(rtp_session->send_ctx, &send_msg->header, &sbytes);
if (stat) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error: srtp unprotection failed with code %d\n", stat);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error: srtp protection failed with code %d\n", stat);
}
bytes = sbytes;
@@ -1297,6 +1302,9 @@
rtp_session->last_write_ts = ntohl(send_msg->header.ts);
rtp_session->last_write_ssrc = ntohl(send_msg->header.ssrc);
rtp_session->last_write_seq = ntohs((u_short)send_msg->header.seq);
+ if (rtp_session->last_write_seq <= rtp_session->dtmf_data.out_digit_seq) {
+ send = 0;
+ }
if (send) {
switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)send_msg, &bytes);
@@ -1486,6 +1494,7 @@
switch_frame_flag_t *flags)
{
rtp_msg_t send_msg = {{0}};
+ switch_size_t bytes;
if (!switch_rtp_ready(rtp_session)) {
return -1;
@@ -1504,7 +1513,28 @@
send_msg.header.m = m ? 1 : 0;
memcpy(send_msg.body, data, datalen);
- return rtp_common_write(rtp_session, (void *) &send_msg, rtp_header_len + datalen, m, payload, NULL);
+ bytes = rtp_header_len + datalen;
+
+
+ if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE)) {
+ int sbytes = (int)bytes;
+ err_status_t stat;
+
+ stat = srtp_protect(rtp_session->send_ctx, &send_msg.header, &sbytes);
+ if (stat) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error: srtp protection failed with code %d\n", stat);
+ }
+
+ bytes = sbytes;
+ }
+
+
+ if (switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)&send_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
+ bytes = -1;
+ }
+ return (int) bytes;
+
+ //return rtp_common_write(rtp_session, (void *) &send_msg, rtp_header_len + datalen, m, payload, NULL);
}
SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp_t *rtp_session)
More information about the Freeswitch-svn
mailing list