[Freeswitch-svn] [commit] r4477 - in freeswitch/trunk/src: . mod/endpoints/mod_portaudio
Freeswitch SVN
anthm at freeswitch.org
Wed Mar 7 20:30:52 EST 2007
Author: anthm
Date: Wed Mar 7 20:30:52 2007
New Revision: 4477
Modified:
freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
freeswitch/trunk/src/switch_rtp.c
Log:
update
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Wed Mar 7 20:30:52 2007
@@ -120,6 +120,7 @@
private_t *call_list;
int ring_interval;
GFLAGS flags;
+ switch_timer_t timer;
} globals;
@@ -186,6 +187,7 @@
last = switch_time_now() - waitsec;
+
if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) {
hold_file = val;
} else {
@@ -594,17 +596,6 @@
goto cng;
}
- if (switch_core_timer_init(&tech_pvt->timer,
- globals.timer_name,
- codec_ms,
- globals.read_codec.implementation->samples_per_frame,
- switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
- switch_core_file_close(&tech_pvt->fh);
- switch_core_codec_destroy(&tech_pvt->write_codec);
- goto cng;
- }
-
tech_pvt->hfh = &tech_pvt->fh;
tech_pvt->hold_frame.data = tech_pvt->holdbuf;
tech_pvt->hold_frame.buflen = sizeof(tech_pvt->holdbuf);
@@ -639,6 +630,7 @@
tech_pvt->hold_frame.datalen = (uint32_t)(olen * sizeof(int16_t));
tech_pvt->hold_frame.samples = (uint32_t)olen;
+ tech_pvt->hold_frame.timestamp = tech_pvt->timer.samplecount;
*frame = &tech_pvt->hold_frame;
}
@@ -651,6 +643,9 @@
if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) != 0) {
globals.read_frame.datalen = samples * 2;
globals.read_frame.samples = samples;
+
+ switch_core_timer_check(&globals.timer);
+ globals.read_frame.timestamp = globals.timer.samplecount;
*frame = &globals.read_frame;
if (!switch_test_flag((&globals), GFLAG_MOUTH)) {
@@ -1312,6 +1307,21 @@
return SWITCH_STATUS_FALSE;
}
}
+
+ if (switch_core_timer_init(&globals.timer,
+ globals.timer_name,
+ codec_ms,
+ globals.read_codec.implementation->samples_per_frame,
+ module_pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
+ switch_core_codec_destroy(&globals.read_codec);
+ switch_core_codec_destroy(&globals.write_codec);
+ return SWITCH_STATUS_FALSE;
+ }
+
+
+
+
globals.read_frame.rate = sample_rate;
globals.read_frame.codec = &globals.read_codec;
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Wed Mar 7 20:30:52 2007
@@ -1293,6 +1293,7 @@
}
}
+
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);
@@ -1384,15 +1385,16 @@
}
if (!ts && rtp_session->timer.timer_interface) {
- rtp_session->ts = rtp_session->timer.samplecount;
+ uint32_t sc = rtp_session->timer.samplecount;
+ if (rtp_session->last_write_ts == sc) {
+ rtp_session->ts = sc + rtp_session->packet_size;
+ } else {
+ rtp_session->ts = sc;
+ }
} else {
rtp_session->ts = ts;
}
- if (rtp_session->ts <= rtp_session->last_write_ts) {
- rtp_session->ts += rtp_session->packet_size;
- }
-
if (rtp_session->ts > rtp_session->last_write_ts + rtp_session->packet_size || rtp_session->ts == rtp_session->packet_size) {
mark++;
}
@@ -1449,19 +1451,20 @@
if (frame->timestamp) {
rtp_session->ts = (uint32_t) frame->timestamp;
} else if (!ts && rtp_session->timer.timer_interface) {
- rtp_session->ts = rtp_session->timer.samplecount;
+ uint32_t sc = rtp_session->timer.samplecount;
+ if (rtp_session->last_write_ts == sc) {
+ rtp_session->ts = sc + rtp_session->packet_size;
+ } else {
+ rtp_session->ts = sc;
+ }
} else {
rtp_session->ts = ts;
}
-
+
if (rtp_session->ts > rtp_session->last_write_ts + rtp_session->packet_size || rtp_session->ts == rtp_session->packet_size) {
mark++;
}
- if (rtp_session->ts <= rtp_session->last_write_ts) {
- rtp_session->ts += rtp_session->packet_size;
- }
-
rtp_session->seq = ntohs(rtp_session->seq) + 1;
rtp_session->seq = htons(rtp_session->seq);
rtp_session->send_msg.header.seq = rtp_session->seq;
More information about the Freeswitch-svn
mailing list