skypiax: Synching audio

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16851 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Giovanni Maruzzelli 2010-03-01 13:25:04 +00:00
parent 3fe4d7a3d8
commit 265c79a5bf
2 changed files with 63 additions and 11 deletions

View File

@ -847,22 +847,63 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_ANSWER:
{
DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
switch_core_timer_sync(&tech_pvt->timer_read);
switch_core_timer_sync(&tech_pvt->timer_write);
DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_ANSWER\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
channel_answer_channel(session);
if(tech_pvt->read_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer);
switch_core_timer_sync(&tech_pvt->timer_read);
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
if(tech_pvt->write_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer);
switch_core_timer_sync(&tech_pvt->timer_write);
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
}
DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG);
}
break;
case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
switch_core_timer_sync(&tech_pvt->timer_read);
switch_core_timer_sync(&tech_pvt->timer_write);
if(tech_pvt->read_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer);
switch_core_timer_sync(&tech_pvt->timer_read);
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
if(tech_pvt->write_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer);
switch_core_timer_sync(&tech_pvt->timer_write);
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
}
DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG);
break;
case SWITCH_MESSAGE_INDICATE_BRIDGE:
DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_BRIDGE\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
switch_core_timer_sync(&tech_pvt->timer_read);
switch_core_timer_sync(&tech_pvt->timer_write);
if(tech_pvt->read_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer);
switch_core_timer_sync(&tech_pvt->timer_read);
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
if(tech_pvt->write_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer);
switch_core_timer_sync(&tech_pvt->timer_write);
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
}
DEBUGA_SKYPE("Synching audio\n", SKYPIAX_P_LOG);
break;
default:

View File

@ -501,11 +501,22 @@ int skypiax_signaling_read(private_t * tech_pvt)
if (!strcasecmp(prop, "FAILUREREASON")) {
DEBUGA_SKYPE("Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPIAX_P_LOG, id);
}
if (!strcasecmp(prop, "DURATION")) { /* each 20 seconds, we sync ithe timers */
if (!strcasecmp(prop, "DURATION")) { /* each 20 seconds, we zero the buffers and sync the timers */
if (!((atoi(value) % 20))) {
switch_core_timer_sync(&tech_pvt->timer_read);
switch_core_timer_sync(&tech_pvt->timer_write);
DEBUGA_SKYPE("Synching on skype_call: %s.\n", SKYPIAX_P_LOG, id);
if(tech_pvt->read_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_srv);
switch_buffer_zero(tech_pvt->read_buffer);
switch_core_timer_sync(&tech_pvt->timer_read);
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
}
if(tech_pvt->write_buffer){
switch_mutex_lock(tech_pvt->mutex_audio_cli);
switch_buffer_zero(tech_pvt->write_buffer);
switch_core_timer_sync(&tech_pvt->timer_write);
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
}
DEBUGA_SKYPE("Synching audio on skype_call: %s.\n", SKYPIAX_P_LOG, id);
}
}
if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {