Freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- 12151 discussions
19 Jul '06
Author: anthm
Date: Tue Jul 18 21:22:56 2006
New Revision: 1964
Modified:
freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c
freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.h
Log:
work in progress
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c Tue Jul 18 21:22:56 2006
@@ -79,18 +79,19 @@
};
-enum tech_flags {
+typedef enum {
TFLAG_OUTBOUND = (1 << 0),
TFLAG_INBOUND = (1 << 1),
TFLAG_IO = (1 << 2),
TFLAG_BYE = (1 << 3),
TFLAG_ANSWERED = (1 << 4),
TFLAG_USING_CODEC = (1 << 5),
+ TFLAG_RTP = (1 << 6),
TFLAG_READING = (1 << 10),
TFLAG_WRITING = (1 << 11),
TFLAG_TIMER = (1 << 20)
-};
+} tech_flag_t;
#define set_param(ptr, val) if ( ptr ) { free( ptr ); ptr = NULL; } if ( val ) { ptr = strdup( val ); }
@@ -347,8 +348,8 @@
/* remove call from hash */
switch_core_hash_delete( profile->call_hash, tech_pvt->call_id );
- switch_set_flag( tech_pvt, TFLAG_BYE );
- switch_clear_flag( tech_pvt, TFLAG_IO );
+ switch_set_flag_locked( tech_pvt, TFLAG_BYE );
+ switch_clear_flag_locked( tech_pvt, TFLAG_IO );
stop_rtp( tech_pvt );
@@ -443,7 +444,7 @@
return SWITCH_STATUS_GENERR;
}
}
- switch_set_flag( tech_pvt, TFLAG_ANSWERED );
+ switch_set_flag_locked( tech_pvt, TFLAG_ANSWERED );
return SWITCH_STATUS_SUCCESS;
}
@@ -462,8 +463,8 @@
tech_pvt = switch_core_session_get_private( session );
assert( tech_pvt != NULL );
- switch_clear_flag( tech_pvt, TFLAG_IO );
- switch_set_flag( tech_pvt, TFLAG_BYE );
+ switch_clear_flag_locked( tech_pvt, TFLAG_IO );
+ switch_set_flag_locked( tech_pvt, TFLAG_BYE );
if( tech_pvt->rtp_session ) {
switch_rtp_kill_socket( tech_pvt->rtp_session );
@@ -523,24 +524,20 @@
switch_core_session_add_stream( *new_session, NULL );
/* create new call */
- tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object));
- if (!tech_pvt) {
+ if (!(tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new private object for call\n" );
goto err;
}
- pj_memset( tech_pvt, 0, sizeof(struct private_object) );
-
+ switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
+ tech_pvt->profile = profile;
+ tech_pvt->session = *new_session;
switch_core_session_set_private( *new_session, tech_pvt );
-
channel = switch_core_session_get_channel( *new_session );
/* create channel name, copy profile and parse destination number (?) */
snprintf( tmp, sizeof(tmp), "pjsip/%s-%04x", outbound_profile->destination_number, rand() & 0xffff );
switch_channel_set_name( channel, tmp );
- tech_pvt->session = *new_session;
- tech_pvt->profile = profile;
-
/* get list of all available codecs */
tech_pvt->num_codecs = switch_loadable_module_get_codecs( switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs,
sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]) );
@@ -560,103 +557,163 @@
return SWITCH_STATUS_GENERR;
}
+
static switch_status_t pjsip_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
- switch_io_flag_t flags, int stream_id)
+ switch_io_flag_t flags, int stream_id)
{
- struct private_object *tech_pvt;
- switch_channel_t *channel;
+ struct private_object *tech_pvt = NULL;
+ size_t bytes = 0, samples = 0, frames = 0, ms = 0;
+ switch_channel_t *channel = NULL;
+ int payload = 0;
+ switch_time_t now, started = switch_time_now(), last_act = switch_time_now();
+ unsigned int elapsed;
+ uint32_t hard_timeout = 60000 * 3;
- assert( session != NULL );
- assert( frame != NULL );
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- tech_pvt = switch_core_session_get_private( session );
- assert( tech_pvt != NULL );
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel( session );
- assert( channel != NULL );
+ tech_pvt->read_frame.datalen = 0;
+ switch_set_flag_locked(tech_pvt, TFLAG_READING);
- switch_set_flag( tech_pvt, TFLAG_READING );
- tech_pvt->read_frame.datalen = 0;
+ samples = tech_pvt->read_codec.implementation->samples_per_frame;
+ ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
+
+ if (tech_pvt->last_read) {
+ elapsed = (unsigned int)((switch_time_now() - tech_pvt->last_read) / 1000);
+ if (elapsed > 60000) {
+ return SWITCH_STATUS_TIMEOUT;
+ }
+ }
- if( switch_test_flag( tech_pvt, TFLAG_IO ) ) {
+ if (switch_test_flag(tech_pvt, TFLAG_IO)) {
switch_status_t status;
- assert( tech_pvt->rtp_session != NULL );
+ assert(tech_pvt->rtp_session != NULL);
+ tech_pvt->read_frame.datalen = 0;
- while( !switch_test_flag( tech_pvt, TFLAG_BYE ) &&
- switch_test_flag( tech_pvt, TFLAG_IO ) &&
- !tech_pvt->read_frame.datalen )
- {
- status = switch_rtp_zerocopy_read_frame( tech_pvt->rtp_session, &tech_pvt->read_frame );
- if( status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK ) {
+
+ while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
+ now = switch_time_now();
+ tech_pvt->read_frame.flags = 0;
+
+ status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
+ if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
return SWITCH_STATUS_FALSE;
}
+
+ payload = tech_pvt->read_frame.payload;
- if( tech_pvt->read_frame.datalen > 0 ) {
- int samples, bytes, frames;
+ elapsed = (unsigned int)((switch_time_now() - started) / 1000);
+ if (timeout > -1) {
+ if (elapsed >= (unsigned int)timeout) {
+ return SWITCH_STATUS_BREAK;
+ }
+ }
+
+ elapsed = (unsigned int)((switch_time_now() - last_act) / 1000);
+
+ if (elapsed >= hard_timeout) {
+ return SWITCH_STATUS_BREAK;
+ }
+
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = tech_pvt->read_frame.datalen / bytes;
+ } else {
+ frames = 1;
+ }
+
+ samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
+
+
+ if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) {
+ char dtmf[128];
+ switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, dtmf, sizeof(dtmf));
+ switch_channel_queue_dtmf(channel, dtmf);
+ }
+
+
+ if (tech_pvt->read_frame.datalen > 0) {
+ tech_pvt->last_read = switch_time_now();
if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = tech_pvt->read_frame.datalen / bytes;
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = (tech_pvt->read_frame.datalen / bytes);
} else {
frames = 1;
}
- samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
-
- tech_pvt->read_frame.samples = (int)samples;
+ samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
+ ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
+ tech_pvt->read_frame.samples = (int) samples;
break;
}
- switch_yield( 1000 );
+ switch_yield(1000);
}
+
}
- switch_clear_flag( tech_pvt, TFLAG_READING );
+ switch_clear_flag_locked(tech_pvt, TFLAG_READING);
+
+ if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ return SWITCH_STATUS_FALSE;
+ }
+
*frame = &tech_pvt->read_frame;
return SWITCH_STATUS_SUCCESS;
-}
+}
+
static switch_status_t pjsip_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
- switch_io_flag_t flags, int stream_id)
+ switch_io_flag_t flags, int stream_id)
{
struct private_object *tech_pvt;
- switch_channel_t *channel;
+ switch_channel_t *channel = NULL;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ int bytes = 0, samples = 0, frames = 0;
- assert( session != NULL );
- assert( frame != NULL );
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- tech_pvt = switch_core_session_get_private( session );
- assert( tech_pvt != NULL );
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel( session );
- assert( channel != NULL );
+ if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+ return SWITCH_STATUS_SUCCESS;
+ }
- switch_set_flag( tech_pvt, TFLAG_WRITING );
+ if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ return SWITCH_STATUS_FALSE;
+ }
- if( switch_test_flag( tech_pvt, TFLAG_IO ) ) {
- int samples, frames, bytes;
+ switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
- assert( tech_pvt->rtp_session != NULL );
- if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (int)frame->datalen / bytes;
- } else {
- frames = 1 ;
- }
- samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
- switch_rtp_write_frame( tech_pvt->rtp_session, frame, samples );
+
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = ((int) frame->datalen / bytes);
+ } else {
+ frames = 1;
}
- switch_clear_flag( tech_pvt, TFLAG_WRITING );
+ samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
+ switch_rtp_write_frame( tech_pvt->rtp_session, frame, samples );
- return SWITCH_STATUS_SUCCESS;
-}
+ switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
+ return status;
+}
+
/* END: freeswitch callbacks */
@@ -705,15 +762,21 @@
/* allocate new session */
switch_core_session_add_stream( session, NULL );
- if ((tech_pvt = (struct private_object *) switch_core_session_alloc( session, sizeof(struct private_object) ))) {
- memset( tech_pvt, 0, sizeof(struct private_object) );
- switch_core_session_set_private( session, tech_pvt );
- tech_pvt->session = session;
- } else {
+ if (!(tech_pvt = (struct private_object *) switch_core_session_alloc( session, sizeof(struct private_object) ))) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new channel for inbound call\n" );
switch_core_session_destroy( &session );
return;
}
+
+ switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+
+ /* need the invite data in pjsip_on_init */
+ tech_pvt->sip_ua = pjsip_ua_instance();
+ tech_pvt->profile = profile;
+
+ switch_core_session_set_private( session, tech_pvt );
+ tech_pvt->session = session;
+
/* give the new session a name */
pj_strdup_with_null( pjsip_pool, &tmp, &((pjsip_sip_uri *)rxdata->msg_info.from->uri)->host );
snprintf( name, sizeof(name), "pjsip/%s/%s-%04x", profile->name, tmp.ptr, rand() & 0xffff );
@@ -721,9 +784,7 @@
switch_channel_clear_flag( channel, CF_OUTBOUND );
- /* need the invite data in pjsip_on_init */
- tech_pvt->sip_ua = pjsip_ua_instance();
- tech_pvt->profile = profile;
+
/* create UAS dialog */
status = pjsip_dlg_create_uas( tech_pvt->sip_ua, rxdata, NULL, &dialog );
@@ -739,8 +800,8 @@
/* load codecs */
tech_pvt->num_codecs = switch_loadable_module_get_codecs( switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs,
- sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]) );
-
+ sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]) );
+
/* Create our initial sdp */
create_sdp( dialog->pool, tech_pvt, &sdp, NULL );
@@ -782,7 +843,7 @@
/* set call id */
pjsip_strncpy( tech_pvt->call_id, &dialog->call_id->id, sizeof( tech_pvt->call_id ) );
- switch_set_flag( tech_pvt, TFLAG_INBOUND );
+ switch_set_flag_locked( tech_pvt, TFLAG_INBOUND );
/* Send 100 Trying */
status = pjsip_inv_initial_answer( tech_pvt->sip_invite, rxdata, 100, NULL, NULL, &txdata );
@@ -1017,7 +1078,7 @@
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SDP re-negotiation received %s\n", tech_pvt->call_id );
stop_rtp( tech_pvt );
- switch_clear_flag( tech_pvt, TFLAG_IO );
+ switch_clear_flag_locked( tech_pvt, TFLAG_IO );
/* destroy codecs */
if ( switch_test_flag( tech_pvt, TFLAG_USING_CODEC ) ) {
@@ -1054,8 +1115,8 @@
if( status != PJ_SUCCESS ) {
/* No valid codec found */
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SDP negotation failed, codec unknown\n" );
- switch_set_flag( tech_pvt, TFLAG_BYE );
- switch_clear_flag( tech_pvt, TFLAG_IO );
+ switch_set_flag_locked( tech_pvt, TFLAG_BYE );
+ switch_clear_flag_locked( tech_pvt, TFLAG_IO );
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
return;
}
@@ -1112,7 +1173,7 @@
start_rtp( tech_pvt );
/* activate io */
- switch_set_flag( tech_pvt, TFLAG_IO );
+ switch_set_flag_locked( tech_pvt, TFLAG_IO );
}
static switch_status_t pjsip_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
@@ -1129,17 +1190,17 @@
switch( msg->message_id )
{
case SWITCH_MESSAGE_INDICATE_BRIDGE:
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "MSG Indicate Bridge\n" );
- if( tech_pvt->rtp_session && switch_test_flag( tech_pvt, TFLAG_TIMER ) ) {
- switch_rtp_clear_flag( tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER );
- }
- break;
+ if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
+ switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
+ }
+ break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "MSG Indicate Unbridge\n" );
- if( tech_pvt->rtp_session && switch_test_flag( tech_pvt, TFLAG_TIMER ) ) {
- switch_rtp_set_flag( tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER );
- }
- break;
+ if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
+ switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
+ }
+ break;
case SWITCH_MESSAGE_INDICATE_PROGRESS:
{
pj_status_t status;
@@ -1323,27 +1384,28 @@
rate,
ms );
+ flags = SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_USE_TIMER;
tech_pvt->rtp_session = switch_rtp_new( tech_pvt->local_sdp_audio_addr,
- tech_pvt->local_sdp_audio_port,
- tech_pvt->remote_sdp_audio_addr,
- tech_pvt->remote_sdp_audio_port,
- tech_pvt->read_codec.implementation->ianacode,
- 0,
- tech_pvt->read_codec.implementation->microseconds_per_frame / 1000,
- flags,
- NULL,
- &err, switch_core_session_get_pool( tech_pvt->session ) );
-
+ tech_pvt->local_sdp_audio_port,
+ tech_pvt->remote_sdp_audio_addr,
+ tech_pvt->remote_sdp_audio_port,
+ tech_pvt->read_codec.implementation->ianacode,
+ 0,
+ tech_pvt->read_codec.implementation->microseconds_per_frame,
+ flags,
+ NULL,
+ &err, switch_core_session_get_pool( tech_pvt->session ) );
+
if( !tech_pvt->rtp_session ) {
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
- switch_set_flag( tech_pvt, TFLAG_BYE );
+ switch_set_flag_locked( tech_pvt, TFLAG_BYE );
return SWITCH_STATUS_FALSE;
}
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting RTP done\n" );
- switch_set_flag( tech_pvt, TFLAG_IO );
+ switch_set_flag_locked( tech_pvt, TFLAG_IO);
return SWITCH_STATUS_SUCCESS;
}
@@ -1472,6 +1534,8 @@
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to initialize pjlib\n" );
return SWITCH_STATUS_TERM;
}
+
+ pj_log_set_level(0);
/* next: pjlib_util */
status = pjlib_util_init();
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.h
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.h (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.h Tue Jul 18 21:22:56 2006
@@ -35,6 +35,8 @@
int num_codecs;
switch_frame_t read_frame;
+ switch_mutex_t *flag_mutex;
+ switch_time_t last_read;
};
/*
1
0
Author: anthm
Date: Tue Jul 18 21:19:46 2006
New Revision: 1963
Modified:
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/switch_core.c
Log:
small fix to sql shipping stuff
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Tue Jul 18 21:19:46 2006
@@ -92,7 +92,7 @@
#define SWITCH_MAX_STATE_HANDLERS 30
#define SWITCH_TRUE 1
#define SWITCH_FALSE 0
-#define SWITCH_CORE_QUEUE_LEN 20000
+#define SWITCH_CORE_QUEUE_LEN 100000
typedef enum {
SWITCH_XML_SECTION_RESULT = 0,
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Tue Jul 18 21:19:46 2006
@@ -2730,7 +2730,7 @@
uint32_t itterations = 0;
uint8_t trans = 0;
switch_time_t last_commit = switch_time_now();
- uint32_t freq = 1000, target = 500, diff = 0;
+ uint32_t freq = 1000, target = 1000, diff = 0;
if (!runtime.event_db) {
runtime.event_db = switch_core_db_handle();
@@ -2810,7 +2810,7 @@
switch (event->event_id) {
case SWITCH_EVENT_CHANNEL_DESTROY:
- switch_core_db_mprintf("delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
+ sql = switch_core_db_mprintf("delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
break;
case SWITCH_EVENT_CHANNEL_CREATE:
sql = switch_core_db_mprintf("insert into channels (uuid,created,name,state) values('%q','%q','%q','%q')",
1
0
[commit] r1962 - in freeswitch/branches/stkn: scripts/rss src src/mod/asr_tts/mod_cepstral src/mod/codecs/mod_speex src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_exosip src/mod/endpoints/mod_iax
by Freeswitch SVN 19 Jul '06
by Freeswitch SVN 19 Jul '06
19 Jul '06
Author: stkn
Date: Tue Jul 18 21:18:25 2006
New Revision: 1962
Added:
freeswitch/branches/stkn/scripts/rss/syncrss.pl
- copied unchanged from r1961, /freeswitch/trunk/scripts/rss/syncrss.pl
Modified:
freeswitch/branches/stkn/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
freeswitch/branches/stkn/src/mod/codecs/mod_speex/mod_speex.c
freeswitch/branches/stkn/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/branches/stkn/src/mod/endpoints/mod_exosip/mod_exosip.c
freeswitch/branches/stkn/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/branches/stkn/src/switch_rtp.c
Log:
Merge changes from trunk.
Modified: freeswitch/branches/stkn/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/asr_tts/mod_cepstral/mod_cepstral.c (original)
+++ freeswitch/branches/stkn/src/mod/asr_tts/mod_cepstral/mod_cepstral.c Tue Jul 18 21:18:25 2006
@@ -27,6 +27,12 @@
*
*
* mod_cepstral.c -- Cepstral Interface
+ *
+ * Contains some material derived from the Cepstral Swift SDK, by
+ * permission. You are free to copy and modify the source under the
+ * terms of FreeSWITCH itself, without additional permission from
+ * Cepstral
+ *
*
*/
#ifdef __ICC
Modified: freeswitch/branches/stkn/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/codecs/mod_speex/mod_speex.c (original)
+++ freeswitch/branches/stkn/src/mod/codecs/mod_speex/mod_speex.c Tue Jul 18 21:18:25 2006
@@ -202,8 +202,6 @@
}
-
-
speex_bits_pack(&context->encoder_bits, 15, 5);
*encoded_data_len = speex_bits_write(&context->encoder_bits, (char *) encoded_data, context->encoder_frame_size);
speex_bits_reset(&context->encoder_bits);
@@ -226,6 +224,7 @@
return SWITCH_STATUS_FALSE;
}
+
buf = decoded_data;
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
speex_decode_int(context->decoder_state, NULL, buf);
@@ -276,7 +275,7 @@
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 640,
/*.bytes_per_frame */ 1280,
- /*.encoded_bytes_per_frame */ 43,
+ /*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
@@ -295,7 +294,7 @@
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 320,
/*.bytes_per_frame */ 640,
- /*.encoded_bytes_per_frame */ 43,
+ /*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
@@ -315,7 +314,7 @@
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 29,
+ /*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_dingaling/mod_dingaling.c Tue Jul 18 21:18:25 2006
@@ -291,15 +291,15 @@
}
if (!(tech_pvt->rtp_session = switch_rtp_new(tech_pvt->profile->ip,
- tech_pvt->local_port,
- tech_pvt->remote_ip,
- tech_pvt->remote_port,
- tech_pvt->codec_num,
- tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
- tech_pvt->read_codec.implementation->microseconds_per_frame,
- flags,
- NULL,
- &err, switch_core_session_get_pool(tech_pvt->session)))) {
+ tech_pvt->local_port,
+ tech_pvt->remote_ip,
+ tech_pvt->remote_port,
+ tech_pvt->codec_num,
+ 0,
+ tech_pvt->read_codec.implementation->microseconds_per_frame,
+ flags,
+ NULL,
+ &err, switch_core_session_get_pool(tech_pvt->session)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return -1;
@@ -784,8 +784,12 @@
}
if (tech_pvt->read_frame.datalen > 0) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (tech_pvt->read_frame.datalen / bytes);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = (tech_pvt->read_frame.datalen / bytes);
+ } else {
+ frames = 1;
+ }
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
tech_pvt->timestamp_recv += (int32_t) samples;
@@ -841,9 +845,13 @@
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = ((int) frame->datalen / bytes);
+ } else {
+ frames = 1;
+ }
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = ((int) frame->datalen / bytes);
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
//printf("%s send %d bytes %d samples in %d frames ts=%d\n", switch_channel_get_name(channel), frame->datalen, samples, frames, tech_pvt->timestamp_send);
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_exosip/mod_exosip.c (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_exosip/mod_exosip.c Tue Jul 18 21:18:25 2006
@@ -562,7 +562,7 @@
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->read_codec.implementation->ianacode,
- tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+ 0, //tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
ms,
flags,
key,
@@ -718,8 +718,12 @@
if (tech_pvt->read_frame.datalen > 0) {
tech_pvt->last_read = switch_time_now();
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (tech_pvt->read_frame.datalen / bytes);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = (tech_pvt->read_frame.datalen / bytes);
+ } else {
+ frames = 1;
+ }
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
tech_pvt->timestamp_recv += (int32_t) samples;
@@ -776,8 +780,12 @@
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = ((int) frame->datalen / bytes);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = ((int) frame->datalen / bytes);
+ } else {
+ frames = 1;
+ }
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
} else {
assert(0);
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_iax/mod_iax.c Tue Jul 18 21:18:25 2006
@@ -129,6 +129,7 @@
{AST_FORMAT_SLINEAR, 10, "slinear"},
{AST_FORMAT_LPC10, 7, "lpc10"},
{AST_FORMAT_G729A, 18, "g729"},
+{AST_FORMAT_SPEEX, 97, "speex"},
{AST_FORMAT_SPEEX, 98, "speex"},
{AST_FORMAT_ILBC, 102, "ilbc"},
{AST_FORMAT_MAX_AUDIO, 999, ""},
@@ -1098,8 +1099,12 @@
break;
}
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (int) (tech_pvt->read_frame.datalen / bytes);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = (int) (tech_pvt->read_frame.datalen / bytes);
+ } else {
+ frames = 1;
+ }
tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
Modified: freeswitch/branches/stkn/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/stkn/src/switch_rtp.c (original)
+++ freeswitch/branches/stkn/src/switch_rtp.c Tue Jul 18 21:18:25 2006
@@ -796,10 +796,11 @@
switch_sockaddr_ip_get(&tx_host, rtp_session->from_addr);
switch_sockaddr_ip_get(&old_host, rtp_session->remote_addr);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
- old_host, old, tx_host, rtp_session->from_addr->port);
- switch_rtp_set_remote_address(rtp_session, tx_host, rtp_session->from_addr->port, &err);
+ if (!switch_strlen_zero(tx_host) && rtp_session->from_addr->port > 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
+ old_host, old, tx_host, rtp_session->from_addr->port);
+ switch_rtp_set_remote_address(rtp_session, tx_host, rtp_session->from_addr->port, &err);
+ }
}
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
}
@@ -1083,7 +1084,8 @@
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) &&
rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode &&
- datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) {
+ ((datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) ||
+ (datalen > SWITCH_RTP_CNG_PAYLOAD && rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame == 0))) {
int16_t decoded[SWITCH_RECCOMMENDED_BUFFER_SIZE/sizeof(int16_t)];
uint32_t rate;
uint32_t flags;
1
0
Author: sphere
Date: Tue Jul 18 18:08:50 2006
New Revision: 1961
Added:
freeswitch/branches/ptinsley/
Log:
Creating empty folder for ptinsley
1
0
Author: sphere
Date: Tue Jul 18 16:55:49 2006
New Revision: 1960
Added:
freeswitch/branches/edorsey/
Log:
Creating empty folder for edorsey
1
0
18 Jul '06
Author: stkn
Date: Tue Jul 18 15:32:05 2006
New Revision: 1959
Modified:
freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c
Log:
Add RTP I/O fix by anthm.
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c Tue Jul 18 15:32:05 2006
@@ -597,8 +597,12 @@
if( tech_pvt->read_frame.datalen > 0 ) {
int samples, bytes, frames;
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = tech_pvt->read_frame.datalen / bytes;
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = tech_pvt->read_frame.datalen / bytes;
+ } else {
+ frames = 1;
+ }
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
tech_pvt->read_frame.samples = (int)samples;
@@ -637,9 +641,12 @@
int samples, frames, bytes;
assert( tech_pvt->rtp_session != NULL );
-
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (int)frame->datalen / bytes;
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = (int)frame->datalen / bytes;
+ } else {
+ frames = 1 ;
+ }
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
switch_rtp_write_frame( tech_pvt->rtp_session, frame, samples );
@@ -1318,16 +1325,16 @@
tech_pvt->rtp_session = switch_rtp_new( tech_pvt->local_sdp_audio_addr,
- tech_pvt->local_sdp_audio_port,
- tech_pvt->remote_sdp_audio_addr,
- tech_pvt->remote_sdp_audio_port,
- tech_pvt->read_codec.implementation->ianacode,
- tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
- tech_pvt->read_codec.implementation->microseconds_per_frame / 1000,
- flags,
- NULL,
- &err, switch_core_session_get_pool( tech_pvt->session ) );
-
+ tech_pvt->local_sdp_audio_port,
+ tech_pvt->remote_sdp_audio_addr,
+ tech_pvt->remote_sdp_audio_port,
+ tech_pvt->read_codec.implementation->ianacode,
+ 0,
+ tech_pvt->read_codec.implementation->microseconds_per_frame / 1000,
+ flags,
+ NULL,
+ &err, switch_core_session_get_pool( tech_pvt->session ) );
+
if( !tech_pvt->rtp_session ) {
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
switch_set_flag( tech_pvt, TFLAG_BYE );
1
0
18 Jul '06
Author: stkn
Date: Tue Jul 18 15:20:28 2006
New Revision: 1958
Modified:
freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c
freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.h
freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip_sdp.c
Log:
Naming convention fixes
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.c Tue Jul 18 15:20:28 2006
@@ -95,13 +95,13 @@
#define set_param(ptr, val) if ( ptr ) { free( ptr ); ptr = NULL; } if ( val ) { ptr = strdup( val ); }
static switch_status_t create_sdp( pj_pool_t *pool,
- struct pjsip_tech_pvt *pvt,
+ struct private_object *tech_pvt,
pjmedia_sdp_session **p_sdp,
pjmedia_sdp_session *ref_sdp );
-static switch_status_t start_rtp( struct pjsip_tech_pvt *pvt );
-static switch_status_t stop_rtp( struct pjsip_tech_pvt *pvt );
-//static struct pjsip_tech_pvt * find_pvt_by_callid( char *id );
+static switch_status_t start_rtp( struct private_object *tech_pvt );
+static switch_status_t stop_rtp( struct private_object *tech_pvt );
+//static struct private_object * find_pvt_by_callid( char *id );
/* BEGIN: freeswitch callbacks */
/* event handlers */
@@ -183,21 +183,21 @@
static switch_status_t pjsip_on_init(switch_core_session_t *session)
{
struct pjsip_profile *profile;
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
pj_status_t status;
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
- profile = pvt->profile;
+ profile = tech_pvt->profile;
assert( profile != NULL );
/* register switch thread to pjsip core */
- status = pj_thread_register( NULL, pvt->thread_desc, &pvt->thread );
+ status = pj_thread_register( NULL, tech_pvt->thread_desc, &tech_pvt->thread );
if( status != PJ_SUCCESS ) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not register switch session thread to pjlib\n" );
switch_core_session_destroy( &session );
@@ -211,7 +211,7 @@
char tmp[1024], *destination;
pj_str_t dst;
- switch_copy_string( tmp, pvt->caller_profile->destination_number, sizeof( tmp ) );
+ switch_copy_string( tmp, tech_pvt->caller_profile->destination_number, sizeof( tmp ) );
if( !(destination = strchr( tmp, '/' )) ) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Malformed URL!\n" );
switch_core_session_destroy( &session );
@@ -222,17 +222,17 @@
pj_ansi_sprintf( tmp, "<sip:%s:%d>", destination, 5060 );
pj_cstr( &dst, tmp );
- pvt->sip_ua = pjsip_ua_instance();
+ tech_pvt->sip_ua = pjsip_ua_instance();
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Dst: %s, Local: %s %s\n", tmp, pvt->profile->local_uri.ptr, pvt->profile->local_contact.ptr );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Dst: %s, Local: %s %s\n", tmp, tech_pvt->profile->local_uri.ptr, tech_pvt->profile->local_contact.ptr );
/* create new UAC dialog */
- status = pjsip_dlg_create_uac( pvt->sip_ua,
- &pvt->profile->local_uri,
- &pvt->profile->local_contact,
+ status = pjsip_dlg_create_uac( tech_pvt->sip_ua,
+ &tech_pvt->profile->local_uri,
+ &tech_pvt->profile->local_contact,
&dst,
&dst,
- &pvt->sip_dialog );
+ &tech_pvt->sip_dialog );
if ( status != PJ_SUCCESS ) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new UAC dialog for call\n" );
@@ -241,65 +241,65 @@
}
/* create SDP */
- create_sdp( pvt->sip_dialog->pool, pvt, &sdp, NULL );
+ create_sdp( tech_pvt->sip_dialog->pool, tech_pvt, &sdp, NULL );
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initial SDP created\n" );
/* create INVITE session */
- status = pjsip_inv_create_uac( pvt->sip_dialog, sdp, 0, &pvt->sip_invite );
+ status = pjsip_inv_create_uac( tech_pvt->sip_dialog, sdp, 0, &tech_pvt->sip_invite );
if ( status != PJ_SUCCESS ) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new INVITE session for call %s\n" );
- pjsip_dlg_terminate( pvt->sip_dialog );
+ pjsip_dlg_terminate( tech_pvt->sip_dialog );
return SWITCH_STATUS_GENERR;
}
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invite UAC created\n" );
/* attach private object to pjsip session data */
- pvt->sip_invite->mod_data[globals.mod_app.id] = pvt;
+ tech_pvt->sip_invite->mod_data[globals.mod_app.id] = tech_pvt;
/* create invite request */
- status = pjsip_inv_invite( pvt->sip_invite, &txdata );
+ status = pjsip_inv_invite( tech_pvt->sip_invite, &txdata );
if ( status != PJ_SUCCESS ) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create initial INVITE request for call %s\n" );
- pjsip_dlg_terminate( pvt->sip_dialog );
+ pjsip_dlg_terminate( tech_pvt->sip_dialog );
return SWITCH_STATUS_GENERR;
}
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initial INVITE created\n" );
/* send request */
- status = pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ status = pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
if ( status != PJ_SUCCESS ) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to send INVITE request for call %s\n" );
- pjsip_dlg_terminate( pvt->sip_dialog );
+ pjsip_dlg_terminate( tech_pvt->sip_dialog );
return SWITCH_STATUS_GENERR;
}
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INVITE sent\n" );
/* set call id */
- strncpy( pvt->call_id, pvt->sip_invite->dlg->call_id->id.ptr, PJ_MAX_STRLEN( pvt->call_id, pvt->sip_invite->dlg->call_id->id ) );
+ strncpy( tech_pvt->call_id, tech_pvt->sip_invite->dlg->call_id->id.ptr, PJ_MAX_STRLEN( tech_pvt->call_id, tech_pvt->sip_invite->dlg->call_id->id ) );
} else {
pjsip_tx_data *txdata;
/* Send 180 Ring */
- status = pjsip_inv_answer( pvt->sip_invite, 180, NULL, NULL, &txdata );
+ status = pjsip_inv_answer( tech_pvt->sip_invite, 180, NULL, NULL, &txdata );
if( status != PJ_SUCCESS ) {
- status = pjsip_inv_answer( pvt->sip_invite, PJSIP_SC_NOT_ACCEPTABLE, NULL, NULL, &txdata );
+ status = pjsip_inv_answer( tech_pvt->sip_invite, PJSIP_SC_NOT_ACCEPTABLE, NULL, NULL, &txdata );
if( status == PJ_SUCCESS )
- pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
else
- pjsip_inv_terminate( pvt->sip_invite, 500, PJ_FALSE );
+ pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_FALSE );
switch_core_session_destroy( &session );
return SWITCH_STATUS_GENERR;
}
- pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
}
/* add call to hash */
- switch_core_hash_insert( profile->call_hash, pvt->call_id, pvt );
+ switch_core_hash_insert( profile->call_hash, tech_pvt->call_id, tech_pvt );
switch_channel_set_state( channel, CS_RING );
return SWITCH_STATUS_SUCCESS;
@@ -307,7 +307,7 @@
static switch_status_t pjsip_on_ring(switch_core_session_t *session)
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
assert( session != NULL );
@@ -315,8 +315,8 @@
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "RING %s\n", switch_channel_get_name( channel ) );
@@ -326,7 +326,7 @@
static switch_status_t pjsip_on_hangup(switch_core_session_t *session)
{
struct pjsip_profile *profile;
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
pj_status_t status;
pjsip_tx_data *txdata;
@@ -336,49 +336,49 @@
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
- profile = pvt->profile;
+ profile = tech_pvt->profile;
assert( profile != NULL );
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup call %s\n", pvt->call_id );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup call %s\n", tech_pvt->call_id );
/* remove call from hash */
- switch_core_hash_delete( profile->call_hash, pvt->call_id );
+ switch_core_hash_delete( profile->call_hash, tech_pvt->call_id );
- switch_set_flag( pvt, TFLAG_BYE );
- switch_clear_flag( pvt, TFLAG_IO );
+ switch_set_flag( tech_pvt, TFLAG_BYE );
+ switch_clear_flag( tech_pvt, TFLAG_IO );
- stop_rtp( pvt );
+ stop_rtp( tech_pvt );
- if( pvt->sip_invite->state < PJSIP_INV_STATE_CONFIRMED ) {
- pjsip_inv_terminate( pvt->sip_invite, 500, PJ_TRUE );
+ if( tech_pvt->sip_invite->state < PJSIP_INV_STATE_CONFIRMED ) {
+ pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_TRUE );
} else {
- status = pjsip_inv_end_session( pvt->sip_invite, 200, NULL, &txdata );
+ status = pjsip_inv_end_session( tech_pvt->sip_invite, 200, NULL, &txdata );
if( status != PJ_SUCCESS )
- pjsip_inv_terminate( pvt->sip_invite, 500, PJ_TRUE );
+ pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_TRUE );
else
- pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
}
- if ( switch_test_flag( pvt, TFLAG_USING_CODEC ) ) {
- switch_core_codec_destroy( &pvt->read_codec );
- switch_core_codec_destroy( &pvt->write_codec );
+ if ( switch_test_flag( tech_pvt, TFLAG_USING_CODEC ) ) {
+ switch_core_codec_destroy( &tech_pvt->read_codec );
+ switch_core_codec_destroy( &tech_pvt->write_codec );
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t pjsip_on_loopback(switch_core_session_t *session)
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
/* do nothing */
@@ -387,7 +387,7 @@
static switch_status_t pjsip_on_transmit(switch_core_session_t *session)
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
assert( session != NULL );
@@ -395,8 +395,8 @@
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
/* do nothing */
@@ -406,7 +406,7 @@
/* answer channel */
static switch_status_t pjsip_answer_channel(switch_core_session_t *session)
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
assert( session != NULL );
@@ -414,36 +414,36 @@
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Answering call %s\n", pvt->call_id );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Answering call %s\n", tech_pvt->call_id );
- if( !switch_test_flag( pvt, TFLAG_ANSWERED ) &&
+ if( !switch_test_flag( tech_pvt, TFLAG_ANSWERED ) &&
!switch_channel_test_flag( channel, CF_OUTBOUND ) )
{
pjsip_tx_data *txdata;
pj_status_t status;
- assert( pvt->sip_invite != NULL );
+ assert( tech_pvt->sip_invite != NULL );
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Sending 200 on INVITE to %s (%s)\n", pvt->call_id, switch_channel_get_name( channel ) );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Sending 200 on INVITE to %s (%s)\n", tech_pvt->call_id, switch_channel_get_name( channel ) );
/* create SIP 200 with SDP */
- status = pjsip_inv_answer( pvt->sip_invite, 200, NULL, NULL, &txdata );
+ status = pjsip_inv_answer( tech_pvt->sip_invite, 200, NULL, NULL, &txdata );
if( status != PJ_SUCCESS ) {
- pjsip_inv_terminate( pvt->sip_invite, 500, PJ_TRUE );
+ pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_TRUE );
switch_core_session_destroy( &session );
return SWITCH_STATUS_GENERR;
}
- status = pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ status = pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
if( status != PJ_SUCCESS ) {
- pjsip_inv_terminate( pvt->sip_invite, 500, PJ_TRUE );
+ pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_TRUE );
switch_core_session_destroy( &session );
return SWITCH_STATUS_GENERR;
}
}
- switch_set_flag( pvt, TFLAG_ANSWERED );
+ switch_set_flag( tech_pvt, TFLAG_ANSWERED );
return SWITCH_STATUS_SUCCESS;
}
@@ -451,7 +451,7 @@
/* kill channel */
static switch_status_t pjsip_kill_channel(switch_core_session_t *session, int sig)
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
assert( session != NULL );
@@ -459,14 +459,14 @@
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
- switch_clear_flag( pvt, TFLAG_IO );
- switch_set_flag( pvt, TFLAG_BYE );
+ switch_clear_flag( tech_pvt, TFLAG_IO );
+ switch_set_flag( tech_pvt, TFLAG_BYE );
- if( pvt->rtp_session ) {
- switch_rtp_kill_socket( pvt->rtp_session );
+ if( tech_pvt->rtp_session ) {
+ switch_rtp_kill_socket( tech_pvt->rtp_session );
}
return SWITCH_STATUS_SUCCESS;
}
@@ -492,7 +492,7 @@
static switch_status_t pjsip_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
switch_core_session_t **new_session, switch_memory_pool_t *pool)
{
- struct pjsip_tech_pvt *pvt = NULL;
+ struct private_object *tech_pvt = NULL;
switch_channel_t *channel = NULL;
struct pjsip_profile *profile = NULL;
switch_caller_profile_t *caller_profile = NULL;
@@ -523,14 +523,14 @@
switch_core_session_add_stream( *new_session, NULL );
/* create new call */
- pvt = (struct pjsip_tech_pvt *) switch_core_session_alloc(*new_session, sizeof(struct pjsip_tech_pvt));
- if (!pvt) {
+ tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object));
+ if (!tech_pvt) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new private object for call\n" );
goto err;
}
- pj_memset( pvt, 0, sizeof(struct pjsip_tech_pvt) );
+ pj_memset( tech_pvt, 0, sizeof(struct private_object) );
- switch_core_session_set_private( *new_session, pvt );
+ switch_core_session_set_private( *new_session, tech_pvt );
channel = switch_core_session_get_channel( *new_session );
@@ -538,17 +538,17 @@
snprintf( tmp, sizeof(tmp), "pjsip/%s-%04x", outbound_profile->destination_number, rand() & 0xffff );
switch_channel_set_name( channel, tmp );
- pvt->session = *new_session;
- pvt->profile = profile;
+ tech_pvt->session = *new_session;
+ tech_pvt->profile = profile;
/* get list of all available codecs */
- pvt->num_codecs = switch_loadable_module_get_codecs( switch_core_session_get_pool(pvt->session), pvt->codecs,
- sizeof(pvt->codecs) / sizeof(pvt->codecs[0]) );
+ tech_pvt->num_codecs = switch_loadable_module_get_codecs( switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs,
+ sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]) );
caller_profile = switch_caller_profile_clone( *new_session, outbound_profile );
switch_channel_set_caller_profile( channel, caller_profile );
- pvt->caller_profile = caller_profile;
+ tech_pvt->caller_profile = caller_profile;
switch_channel_set_flag( channel, CF_OUTBOUND );
switch_channel_set_state( channel, CS_INIT );
@@ -563,45 +563,45 @@
static switch_status_t pjsip_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
switch_io_flag_t flags, int stream_id)
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
assert( session != NULL );
assert( frame != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- switch_set_flag( pvt, TFLAG_READING );
+ switch_set_flag( tech_pvt, TFLAG_READING );
- pvt->read_frame.datalen = 0;
+ tech_pvt->read_frame.datalen = 0;
- if( switch_test_flag( pvt, TFLAG_IO ) ) {
+ if( switch_test_flag( tech_pvt, TFLAG_IO ) ) {
switch_status_t status;
- assert( pvt->rtp_session != NULL );
+ assert( tech_pvt->rtp_session != NULL );
- while( !switch_test_flag( pvt, TFLAG_BYE ) &&
- switch_test_flag( pvt, TFLAG_IO ) &&
- !pvt->read_frame.datalen )
+ while( !switch_test_flag( tech_pvt, TFLAG_BYE ) &&
+ switch_test_flag( tech_pvt, TFLAG_IO ) &&
+ !tech_pvt->read_frame.datalen )
{
- status = switch_rtp_zerocopy_read_frame( pvt->rtp_session, &pvt->read_frame );
+ status = switch_rtp_zerocopy_read_frame( tech_pvt->rtp_session, &tech_pvt->read_frame );
if( status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK ) {
return SWITCH_STATUS_FALSE;
}
- if( pvt->read_frame.datalen > 0 ) {
+ if( tech_pvt->read_frame.datalen > 0 ) {
int samples, bytes, frames;
- bytes = pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = pvt->read_frame.datalen / bytes;
- samples = frames * pvt->read_codec.implementation->samples_per_frame;
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = tech_pvt->read_frame.datalen / bytes;
+ samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
- pvt->read_frame.samples = (int)samples;
+ tech_pvt->read_frame.samples = (int)samples;
break;
}
@@ -609,9 +609,9 @@
}
}
- switch_clear_flag( pvt, TFLAG_READING );
+ switch_clear_flag( tech_pvt, TFLAG_READING );
- *frame = &pvt->read_frame;
+ *frame = &tech_pvt->read_frame;
return SWITCH_STATUS_SUCCESS;
}
@@ -619,33 +619,33 @@
static switch_status_t pjsip_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
switch_io_flag_t flags, int stream_id)
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
assert( session != NULL );
assert( frame != NULL );
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- switch_set_flag( pvt, TFLAG_WRITING );
+ switch_set_flag( tech_pvt, TFLAG_WRITING );
- if( switch_test_flag( pvt, TFLAG_IO ) ) {
+ if( switch_test_flag( tech_pvt, TFLAG_IO ) ) {
int samples, frames, bytes;
- assert( pvt->rtp_session != NULL );
+ assert( tech_pvt->rtp_session != NULL );
- bytes = pvt->read_codec.implementation->encoded_bytes_per_frame;
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
frames = (int)frame->datalen / bytes;
- samples = frames * pvt->read_codec.implementation->samples_per_frame;
+ samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
- switch_rtp_write_frame( pvt->rtp_session, frame, samples );
+ switch_rtp_write_frame( tech_pvt->rtp_session, frame, samples );
}
- switch_clear_flag( pvt, TFLAG_WRITING );
+ switch_clear_flag( tech_pvt, TFLAG_WRITING );
return SWITCH_STATUS_SUCCESS;
}
@@ -675,18 +675,18 @@
/* check call limit */
if( profile->max_calls && ( profile->calls + 1 ) > profile->max_calls ) {
const pj_str_t reason = pj_str("Too many calls");
-
pjsip_endpt_respond_stateless( globals.sip_endpt, rxdata,
500, &reason,
NULL, NULL);
+
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Too many calls (profile: %s)\n", profile->name );
- return;
+ return;
}
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "PJSIP process id %lu, thread name %s\n", pj_getpid(), pj_thread_get_name( pj_thread_this() ) );
if ((session = switch_core_session_request( &pjsip_endpoint_interface, NULL ))) {
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
pjmedia_sdp_session *sdp;
pjsip_dialog *dialog;
@@ -698,10 +698,10 @@
/* allocate new session */
switch_core_session_add_stream( session, NULL );
- if ((pvt = (struct pjsip_tech_pvt *) switch_core_session_alloc( session, sizeof(struct pjsip_tech_pvt) ))) {
- memset( pvt, 0, sizeof(struct pjsip_tech_pvt) );
- switch_core_session_set_private( session, pvt );
- pvt->session = session;
+ if ((tech_pvt = (struct private_object *) switch_core_session_alloc( session, sizeof(struct private_object) ))) {
+ memset( tech_pvt, 0, sizeof(struct private_object) );
+ switch_core_session_set_private( session, tech_pvt );
+ tech_pvt->session = session;
} else {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new channel for inbound call\n" );
switch_core_session_destroy( &session );
@@ -715,11 +715,11 @@
switch_channel_clear_flag( channel, CF_OUTBOUND );
/* need the invite data in pjsip_on_init */
- pvt->sip_ua = pjsip_ua_instance();
- pvt->profile = profile;
+ tech_pvt->sip_ua = pjsip_ua_instance();
+ tech_pvt->profile = profile;
/* create UAS dialog */
- status = pjsip_dlg_create_uas( pvt->sip_ua, rxdata, NULL, &dialog );
+ status = pjsip_dlg_create_uas( tech_pvt->sip_ua, rxdata, NULL, &dialog );
if( status != PJ_SUCCESS ) {
const pj_str_t reason = pj_str("Unable to create dialog");
pjsip_endpt_respond_stateless( globals.sip_endpt, rxdata,
@@ -731,14 +731,14 @@
}
/* load codecs */
- pvt->num_codecs = switch_loadable_module_get_codecs( switch_core_session_get_pool(pvt->session), pvt->codecs,
- sizeof(pvt->codecs) / sizeof(pvt->codecs[0]) );
+ tech_pvt->num_codecs = switch_loadable_module_get_codecs( switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs,
+ sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]) );
/* Create our initial sdp */
- create_sdp( dialog->pool, pvt, &sdp, NULL );
+ create_sdp( dialog->pool, tech_pvt, &sdp, NULL );
/* Create UAS invite session */
- status = pjsip_inv_create_uas( dialog, rxdata, sdp, 0, &pvt->sip_invite );
+ status = pjsip_inv_create_uas( dialog, rxdata, sdp, 0, &tech_pvt->sip_invite );
if( status != PJ_SUCCESS ) {
pjsip_dlg_create_response( dialog, rxdata, 500, NULL, &txdata );
pjsip_dlg_send_response( dialog, pjsip_rdata_get_tsx( rxdata ), txdata );
@@ -752,7 +752,7 @@
pj_strdup_with_null( pjsip_pool, &host, &((pjsip_sip_uri *)rxdata->msg_info.from->uri)->host );
pj_strdup_with_null( pjsip_pool, &destination, &((pjsip_sip_uri *)rxdata->msg_info.to->uri)->host );
- if ( (pvt->caller_profile = switch_caller_profile_new( switch_core_session_get_pool( session ),
+ if ( (tech_pvt->caller_profile = switch_caller_profile_new( switch_core_session_get_pool( session ),
username.ptr,
profile->dialplan,
username.ptr,
@@ -764,33 +764,33 @@
(char *)modname,
NULL,
destination.ptr)) != 0 ) {
- switch_channel_set_caller_profile( channel, pvt->caller_profile );
+ switch_channel_set_caller_profile( channel, tech_pvt->caller_profile );
}
/* assign vars */
- pvt->sip_invite->mod_data[globals.mod_app.id] = pvt;
- pvt->sip_dialog = dialog;
- pvt->profile = profile;
+ tech_pvt->sip_invite->mod_data[globals.mod_app.id] = tech_pvt;
+ tech_pvt->sip_dialog = dialog;
+ tech_pvt->profile = profile;
/* set call id */
- pjsip_strncpy( pvt->call_id, &dialog->call_id->id, sizeof( pvt->call_id ) );
+ pjsip_strncpy( tech_pvt->call_id, &dialog->call_id->id, sizeof( tech_pvt->call_id ) );
- switch_set_flag( pvt, TFLAG_INBOUND );
+ switch_set_flag( tech_pvt, TFLAG_INBOUND );
/* Send 100 Trying */
- status = pjsip_inv_initial_answer( pvt->sip_invite, rxdata, 100, NULL, NULL, &txdata );
+ status = pjsip_inv_initial_answer( tech_pvt->sip_invite, rxdata, 100, NULL, NULL, &txdata );
if( status != PJ_SUCCESS ) {
- status = pjsip_inv_initial_answer( pvt->sip_invite, rxdata, PJSIP_SC_NOT_ACCEPTABLE, NULL, NULL, &txdata );
+ status = pjsip_inv_initial_answer( tech_pvt->sip_invite, rxdata, PJSIP_SC_NOT_ACCEPTABLE, NULL, NULL, &txdata );
if( status == PJ_SUCCESS )
- pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
else
- pjsip_inv_terminate( pvt->sip_invite, 500, PJ_FALSE );
+ pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_FALSE );
switch_core_session_destroy( &session );
return;
}
- pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
/* Print the initial SDP to the console / log */
{
@@ -802,7 +802,7 @@
"\n** Our initial SDP **\n%s\n*********************\n", tmp_sdp );
}
}
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Starting session thread for call %s\n", pvt->call_id );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Starting session thread for call %s\n", tech_pvt->call_id );
/* set initial state */
switch_channel_set_state( channel, CS_INIT );
@@ -836,19 +836,19 @@
static void call_on_tsx_state_changed( pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e )
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
struct pjsip_profile *profile;
switch_core_session_t *session;
assert( inv != NULL && tsx != NULL );
- pvt = inv->mod_data[globals.mod_app.id];
- assert( pvt != NULL );
+ tech_pvt = inv->mod_data[globals.mod_app.id];
+ assert( tech_pvt != NULL );
- profile = pvt->profile;
+ profile = tech_pvt->profile;
assert( profile != NULL );
- session = pvt->session;
+ session = tech_pvt->session;
assert( session != NULL );
if( inv->state == PJSIP_INV_STATE_EARLY &&
@@ -860,7 +860,7 @@
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Ring received (call %s)\n", pvt->call_id );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Ring received (call %s)\n", tech_pvt->call_id );
}
}
@@ -871,20 +871,20 @@
static void call_on_state_changed( pjsip_inv_session *inv,
pjsip_event *evt )
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
struct pjsip_profile *profile;
switch_core_session_t *session;
switch_channel_t *channel;
assert( evt != NULL && inv != NULL );
- pvt = inv->mod_data[globals.mod_app.id];
- assert( pvt != NULL );
+ tech_pvt = inv->mod_data[globals.mod_app.id];
+ assert( tech_pvt != NULL );
- profile = pvt->profile;
+ profile = tech_pvt->profile;
assert( profile != NULL );
- session = pvt->session;
+ session = tech_pvt->session;
assert( session != NULL );
channel = switch_core_session_get_channel( session );
@@ -893,10 +893,10 @@
switch( inv->state )
{
case PJSIP_INV_STATE_DISCONNECTED:
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "* Call %s (%s) has been disconnected\n", pvt->call_id,
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "* Call %s (%s) has been disconnected\n", tech_pvt->call_id,
switch_channel_get_name( channel ) );
- if( !switch_test_flag( pvt, TFLAG_BYE ) ) {
+ if( !switch_test_flag( tech_pvt, TFLAG_BYE ) ) {
switch_call_cause_t cause;
switch( evt->body.rx_msg.rdata->msg_info.msg->line.status.code )
@@ -908,7 +908,7 @@
}
break;
case PJSIP_INV_STATE_CONFIRMED:
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "* Call %s (%s) has been connected\n", pvt->call_id,
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "* Call %s (%s) has been connected\n", tech_pvt->call_id,
switch_channel_get_name( channel ) );
/* -> connected */
@@ -918,7 +918,7 @@
break;
case PJSIP_INV_STATE_EARLY:
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Call %s (%s), state %s\n", pvt->call_id,
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Call %s (%s), state %s\n", tech_pvt->call_id,
switch_channel_get_name( channel ),
pjsip_inv_state_name( inv->state ) );
@@ -934,7 +934,7 @@
break;
case PJSIP_INV_STATE_CONNECTING:
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Call %s (%s), state %s\n", pvt->call_id,
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Call %s (%s), state %s\n", tech_pvt->call_id,
switch_channel_get_name( channel ),
pjsip_inv_state_name( inv->state ) );
@@ -949,12 +949,12 @@
break;
case PJSIP_INV_STATE_CALLING:
case PJSIP_INV_STATE_INCOMING:
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Call %s (%s), state %s\n", pvt->call_id,
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Call %s (%s), state %s\n", tech_pvt->call_id,
switch_channel_get_name( channel ),
pjsip_inv_state_name( inv->state ) );
break;
default:
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Call %s (%s), UNHANDLED state %s\n", pvt->call_id,
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "* Call %s (%s), UNHANDLED state %s\n", tech_pvt->call_id,
switch_channel_get_name( channel ),
pjsip_inv_state_name( inv->state ) );
break;
@@ -965,7 +965,7 @@
static void call_on_media_update( pjsip_inv_session *inv,
pj_status_t status )
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
struct pjsip_profile *profile;
const pjmedia_sdp_session *remote_sdp, *local_sdp;
pj_pool_t *pool;
@@ -976,46 +976,46 @@
int ms, rate;
pj_sockaddr addr;
- pvt = inv->mod_data[globals.mod_app.id];
- assert( pvt != NULL );
+ tech_pvt = inv->mod_data[globals.mod_app.id];
+ assert( tech_pvt != NULL );
- profile = pvt->profile;
+ profile = tech_pvt->profile;
assert( profile != NULL );
pool = inv->dlg->pool;
assert( pool != NULL );
- session = pvt->session;
+ session = tech_pvt->session;
assert( session != NULL );
- channel = switch_core_session_get_channel( pvt->session );
+ channel = switch_core_session_get_channel( tech_pvt->session );
assert( channel != NULL );
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- SDP negotiation status change %s (state %s, status %d)\n", pvt->call_id,
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- SDP negotiation status change %s (state %s, status %d)\n", tech_pvt->call_id,
pjmedia_sdp_neg_state_str(pjmedia_sdp_neg_get_state( inv->neg )), status );
if( pjmedia_sdp_neg_get_state( inv->neg ) != PJMEDIA_SDP_NEG_STATE_DONE ) {
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "---- SDP negotiation still ongoing for call %s\n", pvt->call_id );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "---- SDP negotiation still ongoing for call %s\n", tech_pvt->call_id );
}
if( status != PJ_SUCCESS ) {
char tmp[1024];
pj_strerror( status, tmp, sizeof(tmp) );
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SDP negotiation failed for call %s, reason: %s\n", pvt->call_id, tmp );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SDP negotiation failed for call %s, reason: %s\n", tech_pvt->call_id, tmp );
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
return;
}
- if( pvt->rtp_session ) {
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SDP re-negotiation received %s\n", pvt->call_id );
+ if( tech_pvt->rtp_session ) {
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SDP re-negotiation received %s\n", tech_pvt->call_id );
- stop_rtp( pvt );
- switch_clear_flag( pvt, TFLAG_IO );
+ stop_rtp( tech_pvt );
+ switch_clear_flag( tech_pvt, TFLAG_IO );
/* destroy codecs */
- if ( switch_test_flag( pvt, TFLAG_USING_CODEC ) ) {
- switch_core_codec_destroy( &pvt->read_codec );
- switch_core_codec_destroy( &pvt->write_codec );
+ if ( switch_test_flag( tech_pvt, TFLAG_USING_CODEC ) ) {
+ switch_core_codec_destroy( &tech_pvt->read_codec );
+ switch_core_codec_destroy( &tech_pvt->write_codec );
}
}
@@ -1043,12 +1043,12 @@
}
/* retrieve stream (= codec) information */
- status = mod_pjsip_codec_from_sdp( pvt, pool, local_sdp, remote_sdp, 0, &codec, &imp );
+ status = mod_pjsip_codec_from_sdp( tech_pvt, pool, local_sdp, remote_sdp, 0, &codec, &imp );
if( status != PJ_SUCCESS ) {
/* No valid codec found */
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SDP negotation failed, codec unknown\n" );
- switch_set_flag( pvt, TFLAG_BYE );
- switch_clear_flag( pvt, TFLAG_IO );
+ switch_set_flag( tech_pvt, TFLAG_BYE );
+ switch_clear_flag( tech_pvt, TFLAG_IO );
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
return;
}
@@ -1060,7 +1060,7 @@
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec %s, rate: %d, ms per frame: %d\n", codec->iananame, rate, ms );
/* initialize codecs */
- ret = switch_core_codec_init(&pvt->read_codec, codec->iananame, rate, ms, 1,
+ ret = switch_core_codec_init(&tech_pvt->read_codec, codec->iananame, rate, ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool( session ));
@@ -1070,7 +1070,7 @@
return;
}
- ret = switch_core_codec_init(&pvt->write_codec, codec->iananame, rate, ms, 1,
+ ret = switch_core_codec_init(&tech_pvt->write_codec, codec->iananame, rate, ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool( session ));
@@ -1080,11 +1080,11 @@
return;
}
- pvt->read_frame.rate = rate;
- pvt->read_frame.codec = &pvt->read_codec;
+ tech_pvt->read_frame.rate = rate;
+ tech_pvt->read_frame.codec = &tech_pvt->read_codec;
- switch_core_session_set_read_codec( session, &pvt->read_codec );
- switch_core_session_set_write_codec( session, &pvt->write_codec );
+ switch_core_session_set_read_codec( session, &tech_pvt->read_codec );
+ switch_core_session_set_write_codec( session, &tech_pvt->write_codec );
/* update remote rtp IP and port, restart rtp */
status = mod_pjsip_addr_from_sdp( remote_sdp, 0, &addr );
@@ -1094,27 +1094,27 @@
} else {
pj_in_addr tmp_addr;
- pvt->remote_sdp_audio_port = pj_sockaddr_in_get_port( (pj_sockaddr_in *)&addr );
+ tech_pvt->remote_sdp_audio_port = pj_sockaddr_in_get_port( (pj_sockaddr_in *)&addr );
tmp_addr.s_addr = pj_htonl( pj_sockaddr_in_get_addr( (pj_sockaddr_in *)&addr ).s_addr );
- strncpy( pvt->remote_sdp_audio_addr, pj_inet_ntoa( tmp_addr ),
- sizeof(pvt->remote_sdp_audio_addr) );
+ strncpy( tech_pvt->remote_sdp_audio_addr, pj_inet_ntoa( tmp_addr ),
+ sizeof(tech_pvt->remote_sdp_audio_addr) );
}
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec %s, %s:%d\n", codec->iananame, pvt->remote_sdp_audio_addr, pvt->remote_sdp_audio_port );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec %s, %s:%d\n", codec->iananame, tech_pvt->remote_sdp_audio_addr, tech_pvt->remote_sdp_audio_port );
/* start rtp */
- start_rtp( pvt );
+ start_rtp( tech_pvt );
/* activate io */
- switch_set_flag( pvt, TFLAG_IO );
+ switch_set_flag( tech_pvt, TFLAG_IO );
}
static switch_status_t pjsip_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
{
- struct pjsip_tech_pvt *pvt;
+ struct private_object *tech_pvt;
switch_channel_t *channel;
- pvt = switch_core_session_get_private( session );
- assert( pvt != NULL );
+ tech_pvt = switch_core_session_get_private( session );
+ assert( tech_pvt != NULL );
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
@@ -1123,14 +1123,14 @@
{
case SWITCH_MESSAGE_INDICATE_BRIDGE:
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "MSG Indicate Bridge\n" );
- if( pvt->rtp_session && switch_test_flag( pvt, TFLAG_TIMER ) ) {
- switch_rtp_clear_flag( pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER );
+ if( tech_pvt->rtp_session && switch_test_flag( tech_pvt, TFLAG_TIMER ) ) {
+ switch_rtp_clear_flag( tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER );
}
break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "MSG Indicate Unbridge\n" );
- if( pvt->rtp_session && switch_test_flag( pvt, TFLAG_TIMER ) ) {
- switch_rtp_set_flag( pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER );
+ if( tech_pvt->rtp_session && switch_test_flag( tech_pvt, TFLAG_TIMER ) ) {
+ switch_rtp_set_flag( tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER );
}
break;
case SWITCH_MESSAGE_INDICATE_PROGRESS:
@@ -1139,19 +1139,19 @@
pjsip_tx_data *txdata;
/* Send 183 Session Progress */
- status = pjsip_inv_answer( pvt->sip_invite, 183, NULL, NULL, &txdata );
+ status = pjsip_inv_answer( tech_pvt->sip_invite, 183, NULL, NULL, &txdata );
if( status != PJ_SUCCESS ) {
- status = pjsip_inv_answer( pvt->sip_invite, PJSIP_SC_NOT_ACCEPTABLE, NULL, NULL, &txdata );
+ status = pjsip_inv_answer( tech_pvt->sip_invite, PJSIP_SC_NOT_ACCEPTABLE, NULL, NULL, &txdata );
if( status == PJ_SUCCESS )
- pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
else
- pjsip_inv_terminate( pvt->sip_invite, 500, PJ_FALSE );
+ pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_FALSE );
switch_core_session_destroy( &session );
return SWITCH_STATUS_GENERR;
}
- pjsip_inv_send_msg( pvt->sip_invite, txdata );
+ pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
}
switch_channel_set_flag( channel, CF_EARLY_MEDIA );
break;
@@ -1166,7 +1166,7 @@
/* BEGIN: mid-level functions */
static switch_status_t create_sdp( pj_pool_t *pool,
- struct pjsip_tech_pvt *pvt,
+ struct private_object *tech_pvt,
pjmedia_sdp_session **p_sdp,
pjmedia_sdp_session *ref_sdp )
{
@@ -1177,10 +1177,10 @@
pjmedia_sdp_rtpmap rtpmap;
int i;
- if( !pool || !pvt )
+ if( !pool || !tech_pvt )
return SWITCH_STATUS_GENERR;
- profile = pvt->profile;
+ profile = tech_pvt->profile;
assert( profile != NULL );
/* allocate and initialize new SDP var */
@@ -1210,34 +1210,34 @@
/* media info */
media->desc.media = pj_str( "audio" );
- media->desc.port = pvt->local_sdp_audio_port = switch_rtp_request_port();
+ media->desc.port = tech_pvt->local_sdp_audio_port = switch_rtp_request_port();
media->desc.port_count = 1;
media->desc.transport = pj_str( "RTP/AVP" );
- strncpy( pvt->local_sdp_audio_addr, profile->local_addr, sizeof(pvt->local_sdp_audio_addr) );
+ strncpy( tech_pvt->local_sdp_audio_addr, profile->local_addr, sizeof(tech_pvt->local_sdp_audio_addr) );
/* codec rtpmap list */
media->desc.fmt_count = 0;
media->attr_count = 0;
if( !ref_sdp ) {
- for( i = 0; i < pvt->num_codecs; i++ ) {
+ for( i = 0; i < tech_pvt->num_codecs; i++ ) {
const switch_codec_implementation_t *imp = NULL;
- imp = pvt->codecs[i];
+ imp = tech_pvt->codecs[i];
/* add all incarnations of this codec... */
while( imp != NULL ) {
char tmp[10];
/* copy codec id */
- sprintf( tmp, "%d", pvt->codecs[i]->ianacode );
+ sprintf( tmp, "%d", tech_pvt->codecs[i]->ianacode );
pj_strdup2( pool, &media->desc.fmt[media->desc.fmt_count], tmp );
/* other codec parameters */
rtpmap.pt = media->desc.fmt[media->desc.fmt_count];
rtpmap.clock_rate = imp->samples_per_second;
- rtpmap.enc_name = pj_str( pvt->codecs[i]->iananame );
+ rtpmap.enc_name = pj_str( tech_pvt->codecs[i]->iananame );
rtpmap.param.slen = 0;
/* add codec implementation to attr list */
@@ -1284,80 +1284,80 @@
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t start_rtp( struct pjsip_tech_pvt *pvt )
+static switch_status_t start_rtp( struct private_object *tech_pvt )
{
int rate, ms;
const char *err;
switch_rtp_flag_t flags = 0;
switch_channel_t *channel;
- assert( pvt != NULL );
+ assert( tech_pvt != NULL );
- channel = switch_core_session_get_channel( pvt->session );
+ channel = switch_core_session_get_channel( tech_pvt->session );
assert( channel != NULL );
- if( pvt->rtp_session ) {
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP already initialized %s\n", pvt->call_id );
+ if( tech_pvt->rtp_session ) {
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP already initialized %s\n", tech_pvt->call_id );
return SWITCH_STATUS_SUCCESS;
}
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting RTP for call %s\n", pvt->call_id );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting RTP for call %s\n", tech_pvt->call_id );
- rate = pvt->read_codec.implementation->bits_per_second;
- ms = pvt->read_codec.implementation->microseconds_per_frame;
+ rate = tech_pvt->read_codec.implementation->bits_per_second;
+ ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP parameters for call %s: src (%s:%d) -> dst (%s:%d), using codec %s @ %d b/s, framelen %d ms\n",
- pvt->call_id,
- pvt->local_sdp_audio_addr,
- pvt->local_sdp_audio_port,
- pvt->remote_sdp_audio_addr,
- pvt->remote_sdp_audio_port,
- pvt->read_codec.implementation->iananame,
+ tech_pvt->call_id,
+ tech_pvt->local_sdp_audio_addr,
+ tech_pvt->local_sdp_audio_port,
+ tech_pvt->remote_sdp_audio_addr,
+ tech_pvt->remote_sdp_audio_port,
+ tech_pvt->read_codec.implementation->iananame,
rate,
ms );
- pvt->rtp_session = switch_rtp_new( pvt->local_sdp_audio_addr,
- pvt->local_sdp_audio_port,
- pvt->remote_sdp_audio_addr,
- pvt->remote_sdp_audio_port,
- pvt->read_codec.implementation->ianacode,
- pvt->read_codec.implementation->encoded_bytes_per_frame,
- pvt->read_codec.implementation->microseconds_per_frame / 1000,
+ tech_pvt->rtp_session = switch_rtp_new( tech_pvt->local_sdp_audio_addr,
+ tech_pvt->local_sdp_audio_port,
+ tech_pvt->remote_sdp_audio_addr,
+ tech_pvt->remote_sdp_audio_port,
+ tech_pvt->read_codec.implementation->ianacode,
+ tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+ tech_pvt->read_codec.implementation->microseconds_per_frame / 1000,
flags,
NULL,
- &err, switch_core_session_get_pool( pvt->session ) );
+ &err, switch_core_session_get_pool( tech_pvt->session ) );
- if( !pvt->rtp_session ) {
+ if( !tech_pvt->rtp_session ) {
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
- switch_set_flag( pvt, TFLAG_BYE );
+ switch_set_flag( tech_pvt, TFLAG_BYE );
return SWITCH_STATUS_FALSE;
}
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting RTP done\n" );
- switch_set_flag( pvt, TFLAG_IO );
+ switch_set_flag( tech_pvt, TFLAG_IO );
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t stop_rtp( struct pjsip_tech_pvt *pvt )
+static switch_status_t stop_rtp( struct private_object *tech_pvt )
{
int loop = 0;
- if( !pvt->rtp_session )
+ if( !tech_pvt->rtp_session )
return SWITCH_STATUS_SUCCESS;
while( loop < 10 &&
- ( switch_test_flag( pvt, TFLAG_READING ) ||
- switch_test_flag( pvt, TFLAG_WRITING ) ) )
+ ( switch_test_flag( tech_pvt, TFLAG_READING ) ||
+ switch_test_flag( tech_pvt, TFLAG_WRITING ) ) )
{
switch_yield( 1000 );
loop++;
}
- switch_rtp_destroy( &pvt->rtp_session );
- pvt->rtp_session = NULL;
+ switch_rtp_destroy( &tech_pvt->rtp_session );
+ tech_pvt->rtp_session = NULL;
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.h
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.h (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip.h Tue Jul 18 15:20:28 2006
@@ -3,7 +3,7 @@
struct pjsip_profile;
-struct pjsip_tech_pvt {
+struct private_object {
/* switch */
struct pjsip_profile *profile;
switch_core_session_t *session;
@@ -40,7 +40,7 @@
/*
* Get the final codec from SDP after successfull negotiation
*/
-pj_status_t mod_pjsip_codec_from_sdp( struct pjsip_tech_pvt *pvt,
+pj_status_t mod_pjsip_codec_from_sdp( struct private_object *tech_pvt,
pj_pool_t *pool,
const pjmedia_sdp_session *local,
const pjmedia_sdp_session *remote,
Modified: freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip_sdp.c
==============================================================================
--- freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip_sdp.c (original)
+++ freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip/mod_pjsip_sdp.c Tue Jul 18 15:20:28 2006
@@ -43,7 +43,7 @@
static const pj_str_t STR_RECVONLY = { "recvonly", 8 };
static pj_status_t find_codec(
- struct pjsip_tech_pvt *pvt,
+ struct private_object *tech_pvt,
unsigned int pt,
unsigned int clock_rate,
const switch_codec_implementation_t **codec,
@@ -53,20 +53,20 @@
int i;
assert( codec != NULL );
- assert( pvt != NULL );
+ assert( tech_pvt != NULL );
assert( imp != NULL );
tmp_imp = NULL;
- for( i = 0; i < pvt->num_codecs; i++ ) {
- if( pvt->codecs[i]->ianacode == pt ) {
+ for( i = 0; i < tech_pvt->num_codecs; i++ ) {
+ if( tech_pvt->codecs[i]->ianacode == pt ) {
/* codec found, find implementation too */
- tmp_imp = pvt->codecs[i];
+ tmp_imp = tech_pvt->codecs[i];
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--- Codec %s found\n", pvt->codecs[i]->iananame );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--- Codec %s found\n", tech_pvt->codecs[i]->iananame );
while( tmp_imp != NULL ) {
if ( tmp_imp->samples_per_second == clock_rate ) {
- *codec = pvt->codecs[i];
+ *codec = tech_pvt->codecs[i];
*imp = tmp_imp;
return PJ_SUCCESS;
}
@@ -76,12 +76,12 @@
break;
}
}
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--- Codec not found\n", pvt->codecs[i]->iananame );
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--- Codec not found\n", tech_pvt->codecs[i]->iananame );
return PJ_ENOTFOUND;
}
pj_status_t mod_pjsip_codec_from_sdp(
- struct pjsip_tech_pvt *pvt,
+ struct private_object *tech_pvt,
pj_pool_t *pool,
const pjmedia_sdp_session *local,
const pjmedia_sdp_session *remote,
@@ -96,7 +96,7 @@
unsigned int pt;
pj_status_t status;
- assert( pvt != NULL );
+ assert( tech_pvt != NULL );
assert( pool != NULL );
assert( local != NULL );
assert( remote != NULL );
@@ -143,7 +143,7 @@
/* Build codec format info: */
if (has_rtpmap) {
- status = find_codec( pvt, pt, rtpmap->clock_rate, codec, imp );
+ status = find_codec( tech_pvt, pt, rtpmap->clock_rate, codec, imp );
if( status != PJ_SUCCESS ) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--- Hmm codec not found (with rtpmap)\n" );
return PJ_ENOTFOUND;
@@ -152,7 +152,7 @@
/*
* No rtpmap, use default clock_rate (8000 Hz)
*/
- status = find_codec( pvt, pt, 8000, codec, imp );
+ status = find_codec( tech_pvt, pt, 8000, codec, imp );
if( status != PJ_SUCCESS ) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--- Hmm codec not found (without rtpmap, 8KHz default)\n" );
return PJ_ENOTFOUND;
1
0
[commit] r1957 - in freeswitch/trunk/src: . mod/codecs/mod_speex mod/endpoints/mod_dingaling mod/endpoints/mod_exosip mod/endpoints/mod_iax
by Freeswitch SVN 18 Jul '06
by Freeswitch SVN 18 Jul '06
18 Jul '06
Author: anthm
Date: Tue Jul 18 14:34:42 2006
New Revision: 1957
Modified:
freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/trunk/src/switch_rtp.c
Log:
codec tweak
Modified: freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c Tue Jul 18 14:34:42 2006
@@ -202,8 +202,6 @@
}
-
-
speex_bits_pack(&context->encoder_bits, 15, 5);
*encoded_data_len = speex_bits_write(&context->encoder_bits, (char *) encoded_data, context->encoder_frame_size);
speex_bits_reset(&context->encoder_bits);
@@ -226,6 +224,7 @@
return SWITCH_STATUS_FALSE;
}
+
buf = decoded_data;
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
speex_decode_int(context->decoder_state, NULL, buf);
@@ -276,7 +275,7 @@
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 640,
/*.bytes_per_frame */ 1280,
- /*.encoded_bytes_per_frame */ 43,
+ /*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
@@ -295,7 +294,7 @@
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 320,
/*.bytes_per_frame */ 640,
- /*.encoded_bytes_per_frame */ 43,
+ /*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
@@ -315,7 +314,7 @@
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
- /*.encoded_bytes_per_frame */ 29,
+ /*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Tue Jul 18 14:34:42 2006
@@ -291,15 +291,15 @@
}
if (!(tech_pvt->rtp_session = switch_rtp_new(tech_pvt->profile->ip,
- tech_pvt->local_port,
- tech_pvt->remote_ip,
- tech_pvt->remote_port,
- tech_pvt->codec_num,
- tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
- tech_pvt->read_codec.implementation->microseconds_per_frame,
- flags,
- NULL,
- &err, switch_core_session_get_pool(tech_pvt->session)))) {
+ tech_pvt->local_port,
+ tech_pvt->remote_ip,
+ tech_pvt->remote_port,
+ tech_pvt->codec_num,
+ 0,
+ tech_pvt->read_codec.implementation->microseconds_per_frame,
+ flags,
+ NULL,
+ &err, switch_core_session_get_pool(tech_pvt->session)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return -1;
@@ -784,8 +784,12 @@
}
if (tech_pvt->read_frame.datalen > 0) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (tech_pvt->read_frame.datalen / bytes);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = (tech_pvt->read_frame.datalen / bytes);
+ } else {
+ frames = 1;
+ }
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
tech_pvt->timestamp_recv += (int32_t) samples;
@@ -841,9 +845,13 @@
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = ((int) frame->datalen / bytes);
+ } else {
+ frames = 1;
+ }
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = ((int) frame->datalen / bytes);
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
//printf("%s send %d bytes %d samples in %d frames ts=%d\n", switch_channel_get_name(channel), frame->datalen, samples, frames, tech_pvt->timestamp_send);
Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c Tue Jul 18 14:34:42 2006
@@ -562,7 +562,7 @@
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->read_codec.implementation->ianacode,
- tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+ 0, //tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
ms,
flags,
key,
@@ -718,8 +718,12 @@
if (tech_pvt->read_frame.datalen > 0) {
tech_pvt->last_read = switch_time_now();
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (tech_pvt->read_frame.datalen / bytes);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = (tech_pvt->read_frame.datalen / bytes);
+ } else {
+ frames = 1;
+ }
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
tech_pvt->timestamp_recv += (int32_t) samples;
@@ -776,8 +780,12 @@
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = ((int) frame->datalen / bytes);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = ((int) frame->datalen / bytes);
+ } else {
+ frames = 1;
+ }
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
} else {
assert(0);
Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c Tue Jul 18 14:34:42 2006
@@ -1099,8 +1099,12 @@
break;
}
- bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
- frames = (int) (tech_pvt->read_frame.datalen / bytes);
+ if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+ bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+ frames = (int) (tech_pvt->read_frame.datalen / bytes);
+ } else {
+ frames = 1;
+ }
tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Tue Jul 18 14:34:42 2006
@@ -796,10 +796,11 @@
switch_sockaddr_ip_get(&tx_host, rtp_session->from_addr);
switch_sockaddr_ip_get(&old_host, rtp_session->remote_addr);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
- old_host, old, tx_host, rtp_session->from_addr->port);
- switch_rtp_set_remote_address(rtp_session, tx_host, rtp_session->from_addr->port, &err);
+ if (!switch_strlen_zero(tx_host) && rtp_session->from_addr->port > 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
+ old_host, old, tx_host, rtp_session->from_addr->port);
+ switch_rtp_set_remote_address(rtp_session, tx_host, rtp_session->from_addr->port, &err);
+ }
}
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
}
@@ -1083,7 +1084,8 @@
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) &&
rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode &&
- datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) {
+ ((datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) ||
+ (datalen > SWITCH_RTP_CNG_PAYLOAD && rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame == 0))) {
int16_t decoded[SWITCH_RECCOMMENDED_BUFFER_SIZE/sizeof(int16_t)];
uint32_t rate;
uint32_t flags;
1
0
Author: sphere
Date: Tue Jul 18 14:09:55 2006
New Revision: 1956
Added:
freeswitch/branches/bgtroll/
Log:
Creating empty folder for bgtroll
1
0
Author: sphere
Date: Tue Jul 18 13:49:01 2006
New Revision: 1955
Added:
freeswitch/branches/gabrielz/
Log:
Creating empty folder for gabrielz
1
0