[commit] r1958 - freeswitch/branches/stkn/src/mod/endpoints/mod_pjsip
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;
participants (1)
-
Freeswitch SVN