@ -20,15 +20,15 @@
*
* \ author Joshua Colp < jcolp @ digium . com >
*
* \ brief Gulp SIP Channel Driver
* \ brief PSJIP SIP Channel Driver
*
* \ ingroup channel_drivers
*/
/*** MODULEINFO
< depend > pjproject < / depend >
< depend > res_ sip< / depend >
< depend > res_ sip_session< / depend >
< depend > res_ pj sip< / depend >
< depend > res_ pj sip_session< / depend >
< support_level > core < / support_level >
* * */
@ -58,11 +58,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
# include "asterisk/stasis_channels.h"
# include "asterisk/indications.h"
# include "asterisk/res_ sip.h"
# include "asterisk/res_ sip_session.h"
# include "asterisk/res_ pj sip.h"
# include "asterisk/res_ pj sip_session.h"
/*** DOCUMENTATION
< function name = " GUL P_DIAL_CONTACTS" language = " en_US " >
< function name = " PJSI P_DIAL_CONTACTS" language = " en_US " >
< synopsis >
Return a dial string for dialing all contacts on an AOR .
< / synopsis >
@ -81,7 +81,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
< para > Returns a properly formatted dial string for dialing all contacts on an AOR . < / para >
< / description >
< / function >
< function name = " GUL P_MEDIA_OFFER" language = " en_US " >
< function name = " PJSI P_MEDIA_OFFER" language = " en_US " >
< synopsis >
Media and codec offerings to be set on an outbound SIP channel prior to dialing .
< / synopsis >
@ -96,8 +96,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
< / function >
* * */
static const char desc [ ] = " Gulp SIP Channel" ;
static const char channel_type [ ] = " Gulp " ;
static const char desc [ ] = " PJ SIP Channel" ;
static const char channel_type [ ] = " PJSIP " ;
static unsigned int chan_idx ;
@ -113,13 +113,13 @@ enum sip_session_media_position {
SIP_MEDIA_SIZE ,
} ;
struct gul p_pvt {
struct chan_pjsi p_pvt {
struct ast_sip_session_media * media [ SIP_MEDIA_SIZE ] ;
} ;
static void gul p_pvt_dtor( void * obj )
static void chan_pjsi p_pvt_dtor( void * obj )
{
struct gul p_pvt * pvt = obj ;
struct chan_pjsi p_pvt * pvt = obj ;
int i ;
for ( i = 0 ; i < SIP_MEDIA_SIZE ; + + i ) {
@ -129,70 +129,70 @@ static void gulp_pvt_dtor(void *obj)
}
/* \brief Asterisk core interaction functions */
static struct ast_channel * gul p_request( const char * type , struct ast_format_cap * cap , const struct ast_channel * requestor , const char * data , int * cause ) ;
static int gul p_sendtext( struct ast_channel * ast , const char * text ) ;
static int gul p_digit_begin( struct ast_channel * ast , char digit ) ;
static int gul p_digit_end( struct ast_channel * ast , char digit , unsigned int duration ) ;
static int gul p_call( struct ast_channel * ast , const char * dest , int timeout ) ;
static int gul p_hangup( struct ast_channel * ast ) ;
static int gul p_answer( struct ast_channel * ast ) ;
static struct ast_frame * gul p_read( struct ast_channel * ast ) ;
static int gul p_write( struct ast_channel * ast , struct ast_frame * f ) ;
static int gul p_indicate( struct ast_channel * ast , int condition , const void * data , size_t datalen ) ;
static int gul p_transfer( struct ast_channel * ast , const char * target ) ;
static int gul p_fixup( struct ast_channel * oldchan , struct ast_channel * newchan ) ;
static int gul p_devicestate( const char * data ) ;
static int gul p_queryoption( struct ast_channel * ast , int option , void * data , int * datalen ) ;
static struct ast_channel * chan_pjsi p_request( const char * type , struct ast_format_cap * cap , const struct ast_channel * requestor , const char * data , int * cause ) ;
static int chan_pjsi p_sendtext( struct ast_channel * ast , const char * text ) ;
static int chan_pjsi p_digit_begin( struct ast_channel * ast , char digit ) ;
static int chan_pjsi p_digit_end( struct ast_channel * ast , char digit , unsigned int duration ) ;
static int chan_pjsi p_call( struct ast_channel * ast , const char * dest , int timeout ) ;
static int chan_pjsi p_hangup( struct ast_channel * ast ) ;
static int chan_pjsi p_answer( struct ast_channel * ast ) ;
static struct ast_frame * chan_pjsi p_read( struct ast_channel * ast ) ;
static int chan_pjsi p_write( struct ast_channel * ast , struct ast_frame * f ) ;
static int chan_pjsi p_indicate( struct ast_channel * ast , int condition , const void * data , size_t datalen ) ;
static int chan_pjsi p_transfer( struct ast_channel * ast , const char * target ) ;
static int chan_pjsi p_fixup( struct ast_channel * oldchan , struct ast_channel * newchan ) ;
static int chan_pjsi p_devicestate( const char * data ) ;
static int chan_pjsi p_queryoption( struct ast_channel * ast , int option , void * data , int * datalen ) ;
/*! \brief PBX interface structure for channel registration */
static struct ast_channel_tech gul p_tech = {
static struct ast_channel_tech chan_pjsi p_tech = {
. type = channel_type ,
. description = " Gulp SIP Channel Driver" ,
. requester = gul p_request,
. send_text = gul p_sendtext,
. send_digit_begin = gul p_digit_begin,
. send_digit_end = gul p_digit_end,
. call = gul p_call,
. hangup = gul p_hangup,
. answer = gul p_answer,
. read = gul p_read,
. write = gul p_write,
. write_video = gul p_write,
. exception = gul p_read,
. indicate = gul p_indicate,
. transfer = gul p_transfer,
. fixup = gul p_fixup,
. devicestate = gul p_devicestate,
. queryoption = gul p_queryoption,
. description = " PJ SIP Channel Driver" ,
. requester = chan_pjsi p_request,
. send_text = chan_pjsi p_sendtext,
. send_digit_begin = chan_pjsi p_digit_begin,
. send_digit_end = chan_pjsi p_digit_end,
. call = chan_pjsi p_call,
. hangup = chan_pjsi p_hangup,
. answer = chan_pjsi p_answer,
. read = chan_pjsi p_read,
. write = chan_pjsi p_write,
. write_video = chan_pjsi p_write,
. exception = chan_pjsi p_read,
. indicate = chan_pjsi p_indicate,
. transfer = chan_pjsi p_transfer,
. fixup = chan_pjsi p_fixup,
. devicestate = chan_pjsi p_devicestate,
. queryoption = chan_pjsi p_queryoption,
. properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER
} ;
/*! \brief SIP session interaction functions */
static void gul p_session_begin( struct ast_sip_session * session ) ;
static void gul p_session_end( struct ast_sip_session * session ) ;
static int gul p_incoming_request( struct ast_sip_session * session , struct pjsip_rx_data * rdata ) ;
static void gul p_incoming_response( struct ast_sip_session * session , struct pjsip_rx_data * rdata ) ;
static void chan_pjsi p_session_begin( struct ast_sip_session * session ) ;
static void chan_pjsi p_session_end( struct ast_sip_session * session ) ;
static int chan_pjsi p_incoming_request( struct ast_sip_session * session , struct pjsip_rx_data * rdata ) ;
static void chan_pjsi p_incoming_response( struct ast_sip_session * session , struct pjsip_rx_data * rdata ) ;
/*! \brief SIP session supplement structure */
static struct ast_sip_session_supplement gul p_supplement = {
static struct ast_sip_session_supplement chan_pjsi p_supplement = {
. method = " INVITE " ,
. priority = AST_SIP_SESSION_SUPPLEMENT_PRIORITY_CHANNEL ,
. session_begin = gul p_session_begin,
. session_end = gul p_session_end,
. incoming_request = gul p_incoming_request,
. incoming_response = gul p_incoming_response,
. session_begin = chan_pjsi p_session_begin,
. session_end = chan_pjsi p_session_end,
. incoming_request = chan_pjsi p_incoming_request,
. incoming_response = chan_pjsi p_incoming_response,
} ;
static int gul p_incoming_ack( struct ast_sip_session * session , struct pjsip_rx_data * rdata ) ;
static int chan_pjsi p_incoming_ack( struct ast_sip_session * session , struct pjsip_rx_data * rdata ) ;
static struct ast_sip_session_supplement gul p_ack_supplement = {
static struct ast_sip_session_supplement chan_pjsi p_ack_supplement = {
. method = " ACK " ,
. priority = AST_SIP_SESSION_SUPPLEMENT_PRIORITY_CHANNEL ,
. incoming_request = gul p_incoming_ack,
. incoming_request = chan_pjsi p_incoming_ack,
} ;
/*! \brief Dialplan function for constructing a dial string for calling all contacts */
static int gul p_dial_contacts( struct ast_channel * chan , const char * cmd , char * data , char * buf , size_t len )
static int chan_pjsi p_dial_contacts( struct ast_channel * chan , const char * cmd , char * data , char * buf , size_t len )
{
RAII_VAR ( struct ast_sip_endpoint * , endpoint , NULL , ao2_cleanup ) ;
RAII_VAR ( struct ast_str * , dial , NULL , ast_free_ptr ) ;
@ -247,7 +247,7 @@ static int gulp_dial_contacts(struct ast_channel *chan, const char *cmd, char *d
it_contacts = ao2_iterator_init ( contacts , 0 ) ;
for ( ; ( contact = ao2_iterator_next ( & it_contacts ) ) ; ao2_ref ( contact , - 1 ) ) {
ast_str_append ( & dial , - 1 , " Gulp /" ) ;
ast_str_append ( & dial , - 1 , " PJSIP /" ) ;
if ( ! ast_strlen_zero ( args . request_user ) ) {
ast_str_append ( & dial , - 1 , " %s@ " , args . request_user ) ;
@ -265,9 +265,9 @@ static int gulp_dial_contacts(struct ast_channel *chan, const char *cmd, char *d
return 0 ;
}
static struct ast_custom_function gul p_dial_contacts_function = {
. name = " GUL P_DIAL_CONTACTS" ,
. read = gul p_dial_contacts,
static struct ast_custom_function chan_pjsi p_dial_contacts_function = {
. name = " PJSI P_DIAL_CONTACTS" ,
. read = chan_pjsi p_dial_contacts,
} ;
static int media_offer_read_av ( struct ast_sip_session * session , char * buf ,
@ -285,7 +285,7 @@ static int media_offer_read_av(struct ast_sip_session *session, char *buf,
name = ast_getformatname ( & fmt ) ;
if ( ast_strlen_zero ( name ) ) {
ast_log ( LOG_WARNING , " GUL P_MEDIA_OFFER unrecognized format %s\n " , name ) ;
ast_log ( LOG_WARNING , " PJSI P_MEDIA_OFFER unrecognized format %s\n " , name ) ;
continue ;
}
@ -364,16 +364,16 @@ static int media_offer_write(struct ast_channel *chan, const char *cmd, char *da
}
static struct ast_custom_function media_offer_function = {
. name = " GUL P_MEDIA_OFFER" ,
. name = " PJSI P_MEDIA_OFFER" ,
. read = media_offer_read ,
. write = media_offer_write
} ;
/*! \brief Function called by RTP engine to get local audio RTP peer */
static enum ast_rtp_glue_result gul p_get_rtp_peer( struct ast_channel * chan , struct ast_rtp_instance * * instance )
static enum ast_rtp_glue_result chan_pjsi p_get_rtp_peer( struct ast_channel * chan , struct ast_rtp_instance * * instance )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( chan ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_sip_endpoint * endpoint ;
if ( ! pvt | | ! channel - > session | | ! pvt - > media [ SIP_MEDIA_AUDIO ] - > rtp ) {
@ -398,10 +398,10 @@ static enum ast_rtp_glue_result gulp_get_rtp_peer(struct ast_channel *chan, stru
}
/*! \brief Function called by RTP engine to get local video RTP peer */
static enum ast_rtp_glue_result gul p_get_vrtp_peer( struct ast_channel * chan , struct ast_rtp_instance * * instance )
static enum ast_rtp_glue_result chan_pjsi p_get_vrtp_peer( struct ast_channel * chan , struct ast_rtp_instance * * instance )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( chan ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_sip_endpoint * endpoint ;
if ( ! pvt | | ! channel - > session | | ! pvt - > media [ SIP_MEDIA_VIDEO ] - > rtp ) {
@ -422,7 +422,7 @@ static enum ast_rtp_glue_result gulp_get_vrtp_peer(struct ast_channel *chan, str
}
/*! \brief Function called by RTP engine to get peer capabilities */
static void gul p_get_codec( struct ast_channel * chan , struct ast_format_cap * result )
static void chan_pjsi p_get_codec( struct ast_channel * chan , struct ast_format_cap * result )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( chan ) ;
@ -492,7 +492,7 @@ static int check_for_rtp_changes(struct ast_channel *chan, struct ast_rtp_instan
}
/*! \brief Function called by RTP engine to change where the remote party should send media */
static int gul p_set_rtp_peer( struct ast_channel * chan ,
static int chan_pjsi p_set_rtp_peer( struct ast_channel * chan ,
struct ast_rtp_instance * rtp ,
struct ast_rtp_instance * vrtp ,
struct ast_rtp_instance * tpeer ,
@ -500,7 +500,7 @@ static int gulp_set_rtp_peer(struct ast_channel *chan,
int nat_active )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( chan ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_sip_session * session = channel - > session ;
int changed = 0 ;
struct ast_channel * bridge_peer ;
@ -545,32 +545,32 @@ static int gulp_set_rtp_peer(struct ast_channel *chan,
}
/*! \brief Local glue for interacting with the RTP engine core */
static struct ast_rtp_glue gul p_rtp_glue = {
. type = " Gulp " ,
. get_rtp_info = gul p_get_rtp_peer,
. get_vrtp_info = gul p_get_vrtp_peer,
. get_codec = gul p_get_codec,
. update_peer = gul p_set_rtp_peer,
static struct ast_rtp_glue chan_pjsi p_rtp_glue = {
. type = " PJSIP " ,
. get_rtp_info = chan_pjsi p_get_rtp_peer,
. get_vrtp_info = chan_pjsi p_get_vrtp_peer,
. get_codec = chan_pjsi p_get_codec,
. update_peer = chan_pjsi p_set_rtp_peer,
} ;
/*! \brief Function called to create a new Gulp Asterisk channel */
static struct ast_channel * gul p_new( struct ast_sip_session * session , int state , const char * exten , const char * title , const char * linkedid , const char * cid_name )
/*! \brief Function called to create a new PJSIP Asterisk channel */
static struct ast_channel * chan_pjsi p_new( struct ast_sip_session * session , int state , const char * exten , const char * title , const char * linkedid , const char * cid_name )
{
struct ast_channel * chan ;
struct ast_format fmt ;
RAII_VAR ( struct gul p_pvt * , pvt , NULL , ao2_cleanup ) ;
RAII_VAR ( struct chan_pjsi p_pvt * , pvt , NULL , ao2_cleanup ) ;
struct ast_sip_channel_pvt * channel ;
if ( ! ( pvt = ao2_alloc ( sizeof ( * pvt ) , gul p_pvt_dtor) ) ) {
if ( ! ( pvt = ao2_alloc ( sizeof ( * pvt ) , chan_pjsi p_pvt_dtor) ) ) {
return NULL ;
}
if ( ! ( chan = ast_channel_alloc ( 1 , state , S_OR ( session - > id . number . str , " " ) , S_OR ( session - > id . name . str , " " ) , " " , " " , " " , linkedid , 0 , " Gulp /%s-%08x" , ast_sorcery_object_get_id ( session - > endpoint ) ,
if ( ! ( chan = ast_channel_alloc ( 1 , state , S_OR ( session - > id . number . str , " " ) , S_OR ( session - > id . name . str , " " ) , " " , " " , " " , linkedid , 0 , " PJSIP /%s-%08x" , ast_sorcery_object_get_id ( session - > endpoint ) ,
ast_atomic_fetchadd_int ( ( int * ) & chan_idx , + 1 ) ) ) ) {
return NULL ;
}
ast_channel_tech_set ( chan , & gul p_tech) ;
ast_channel_tech_set ( chan , & chan_pjsi p_tech) ;
if ( ! ( channel = ast_sip_channel_pvt_alloc ( pvt , session ) ) ) {
ast_hangup ( chan ) ;
@ -650,8 +650,8 @@ static int answer(void *data)
return ( status = = PJ_SUCCESS ) ? 0 : - 1 ;
}
/*! \brief Function called by core when we should answer a Gulp session */
static int gul p_answer( struct ast_channel * ast )
/*! \brief Function called by core when we should answer a PJSIP session */
static int chan_pjsi p_answer( struct ast_channel * ast )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
@ -672,7 +672,7 @@ static int gulp_answer(struct ast_channel *ast)
}
/*! \brief Internal helper function called when CNG tone is detected */
static struct ast_frame * gul p_cng_tone_detected( struct ast_sip_session * session , struct ast_frame * f )
static struct ast_frame * chan_pjsi p_cng_tone_detected( struct ast_sip_session * session , struct ast_frame * f )
{
const char * target_context ;
int exists ;
@ -721,10 +721,10 @@ static struct ast_frame *gulp_cng_tone_detected(struct ast_sip_session *session,
}
/*! \brief Function called by core to read any waiting frames */
static struct ast_frame * gul p_read( struct ast_channel * ast )
static struct ast_frame * chan_pjsi p_read( struct ast_channel * ast )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_frame * f ;
struct ast_sip_session_media * media = NULL ;
int rtcp = 0 ;
@ -772,7 +772,7 @@ static struct ast_frame *gulp_read(struct ast_channel *ast)
if ( f & & ( f - > frametype = = AST_FRAME_DTMF ) ) {
if ( f - > subclass . integer = = ' f ' ) {
ast_debug ( 3 , " Fax CNG detected on %s \n " , ast_channel_name ( ast ) ) ;
f = gul p_cng_tone_detected( channel - > session , f ) ;
f = chan_pjsi p_cng_tone_detected( channel - > session , f ) ;
} else {
ast_debug ( 3 , " * Detected inband DTMF '%c' on '%s' \n " , f - > subclass . integer ,
ast_channel_name ( ast ) ) ;
@ -784,10 +784,10 @@ static struct ast_frame *gulp_read(struct ast_channel *ast)
}
/*! \brief Function called by core to write frames */
static int gul p_write( struct ast_channel * ast , struct ast_frame * frame )
static int chan_pjsi p_write( struct ast_channel * ast , struct ast_frame * frame )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_sip_session_media * media ;
int res = 0 ;
@ -821,7 +821,7 @@ static int gulp_write(struct ast_channel *ast, struct ast_frame *frame)
case AST_FRAME_MODEM :
break ;
default :
ast_log ( LOG_WARNING , " Can't send %d type frames with Gulp \n " , frame - > frametype ) ;
ast_log ( LOG_WARNING , " Can't send %d type frames with PJSIP \n " , frame - > frametype ) ;
break ;
}
@ -837,7 +837,7 @@ static int fixup(void *data)
{
struct fixup_data * fix_data = data ;
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( fix_data - > chan ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
channel - > session - > channel = fix_data - > chan ;
if ( pvt - > media [ SIP_MEDIA_AUDIO ] & & pvt - > media [ SIP_MEDIA_AUDIO ] - > rtp ) {
@ -851,7 +851,7 @@ static int fixup(void *data)
}
/*! \brief Function called by core to change the underlying owner channel */
static int gul p_fixup( struct ast_channel * oldchan , struct ast_channel * newchan )
static int chan_pjsi p_fixup( struct ast_channel * oldchan , struct ast_channel * newchan )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( newchan ) ;
struct fixup_data fix_data ;
@ -872,7 +872,7 @@ static int gulp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
}
/*! \brief Function called to get the device state of an endpoint */
static int gul p_devicestate( const char * data )
static int chan_pjsi p_devicestate( const char * data )
{
RAII_VAR ( struct ast_sip_endpoint * , endpoint , ast_sorcery_retrieve_by_id ( ast_sip_get_sorcery ( ) , " endpoint " , data ) , ao2_cleanup ) ;
enum ast_device_state state = AST_DEVICE_UNKNOWN ;
@ -934,7 +934,7 @@ static int gulp_devicestate(const char *data)
}
/*! \brief Function called to query options on a channel */
static int gul p_queryoption( struct ast_channel * ast , int option , void * data , int * datalen )
static int chan_pjsi p_queryoption( struct ast_channel * ast , int option , void * data , int * datalen )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
struct ast_sip_session * session = channel - > session ;
@ -1099,10 +1099,10 @@ static int update_connected_line_information(void *data)
}
/*! \brief Function called by core to ask the channel to indicate some sort of condition */
static int gul p_indicate( struct ast_channel * ast , int condition , const void * data , size_t datalen )
static int chan_pjsi p_indicate( struct ast_channel * ast , int condition , const void * data , size_t datalen )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_sip_session_media * media ;
int response_code = 0 ;
int res = 0 ;
@ -1119,7 +1119,7 @@ static int gulp_indicate(struct ast_channel *ast, int condition, const void *dat
} else {
res = - 1 ;
}
ast_devstate_changed ( AST_DEVICE_UNKNOWN , AST_DEVSTATE_CACHABLE , " Gulp /%s" , ast_sorcery_object_get_id ( channel - > session - > endpoint ) ) ;
ast_devstate_changed ( AST_DEVICE_UNKNOWN , AST_DEVSTATE_CACHABLE , " PJSIP /%s" , ast_sorcery_object_get_id ( channel - > session - > endpoint ) ) ;
break ;
case AST_CONTROL_BUSY :
if ( ast_channel_state ( ast ) ! = AST_STATE_UP ) {
@ -1335,7 +1335,7 @@ static int transfer(void *data)
}
/*! \brief Function called by core for Asterisk initiated transfer */
static int gul p_transfer( struct ast_channel * chan , const char * target )
static int chan_pjsi p_transfer( struct ast_channel * chan , const char * target )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( chan ) ;
struct transfer_data * trnf_data = transfer_data_alloc ( channel - > session , target ) ;
@ -1354,10 +1354,10 @@ static int gulp_transfer(struct ast_channel *chan, const char *target)
}
/*! \brief Function called by core to start a DTMF digit */
static int gul p_digit_begin( struct ast_channel * chan , char digit )
static int chan_pjsi p_digit_begin( struct ast_channel * chan , char digit )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( chan ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_sip_session_media * media = pvt - > media [ SIP_MEDIA_AUDIO ] ;
int res = 0 ;
@ -1442,10 +1442,10 @@ static int transmit_info_dtmf(void *data)
}
/*! \brief Function called by core to stop a DTMF digit */
static int gul p_digit_end( struct ast_channel * ast , char digit , unsigned int duration )
static int chan_pjsi p_digit_end( struct ast_channel * ast , char digit , unsigned int duration )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_sip_session_media * media = pvt - > media [ SIP_MEDIA_AUDIO ] ;
int res = 0 ;
@ -1498,7 +1498,7 @@ static int call(void *data)
}
/*! \brief Function called by core to actually start calling a remote party */
static int gul p_call( struct ast_channel * ast , const char * dest , int timeout )
static int chan_pjsi p_call( struct ast_channel * ast , const char * dest , int timeout )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
@ -1587,7 +1587,7 @@ static struct hangup_data *hangup_data_alloc(int cause, struct ast_channel *chan
}
/*! \brief Clear a channel from a session along with its PVT */
static void clear_session_and_channel ( struct ast_sip_session * session , struct ast_channel * ast , struct gul p_pvt * pvt )
static void clear_session_and_channel ( struct ast_sip_session * session , struct ast_channel * ast , struct chan_pjsi p_pvt * pvt )
{
session - > channel = NULL ;
if ( pvt - > media [ SIP_MEDIA_AUDIO ] & & pvt - > media [ SIP_MEDIA_AUDIO ] - > rtp ) {
@ -1606,7 +1606,7 @@ static int hangup(void *data)
struct hangup_data * h_data = data ;
struct ast_channel * ast = h_data - > chan ;
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
struct ast_sip_session * session = channel - > session ;
int cause = h_data - > cause ;
@ -1626,11 +1626,11 @@ static int hangup(void *data)
return 0 ;
}
/*! \brief Function called by core to hang up a Gulp session */
static int gul p_hangup( struct ast_channel * ast )
/*! \brief Function called by core to hang up a PJSIP session */
static int chan_pjsi p_hangup( struct ast_channel * ast )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
struct gul p_pvt * pvt = channel - > pvt ;
struct chan_pjsi p_pvt * pvt = channel - > pvt ;
int cause = hangup_cause2sip ( ast_channel_hangupcause ( channel - > session - > channel ) ) ;
struct hangup_data * h_data = hangup_data_alloc ( cause , ast ) ;
@ -1676,7 +1676,7 @@ static int request(void *obj)
) ;
if ( ast_strlen_zero ( tmp ) ) {
ast_log ( LOG_ERROR , " Unable to create Gulp channel with empty destination\n " ) ;
ast_log ( LOG_ERROR , " Unable to create PJSIP channel with empty destination\n " ) ;
req_data - > cause = AST_CAUSE_CHANNEL_UNACCEPTABLE ;
return - 1 ;
}
@ -1692,10 +1692,10 @@ static int request(void *obj)
}
if ( ast_strlen_zero ( endpoint_name ) ) {
ast_log ( LOG_ERROR , " Unable to create Gulp channel with empty endpoint name\n " ) ;
ast_log ( LOG_ERROR , " Unable to create PJSIP channel with empty endpoint name\n " ) ;
req_data - > cause = AST_CAUSE_CHANNEL_UNACCEPTABLE ;
} else if ( ! ( endpoint = ast_sorcery_retrieve_by_id ( ast_sip_get_sorcery ( ) , " endpoint " , endpoint_name ) ) ) {
ast_log ( LOG_ERROR , " Unable to create Gulp channel - endpoint '%s' was not found\n " , endpoint_name ) ;
ast_log ( LOG_ERROR , " Unable to create PJSIP channel - endpoint '%s' was not found\n " , endpoint_name ) ;
req_data - > cause = AST_CAUSE_NO_ROUTE_DESTINATION ;
return - 1 ;
}
@ -1710,8 +1710,8 @@ static int request(void *obj)
return 0 ;
}
/*! \brief Function called by core to create a new outgoing Gulp session */
static struct ast_channel * gul p_request( const char * type , struct ast_format_cap * cap , const struct ast_channel * requestor , const char * data , int * cause )
/*! \brief Function called by core to create a new outgoing PJSIP session */
static struct ast_channel * chan_pjsi p_request( const char * type , struct ast_format_cap * cap , const struct ast_channel * requestor , const char * data , int * cause )
{
struct request_data req_data ;
RAII_VAR ( struct ast_sip_session * , session , NULL , ao2_cleanup ) ;
@ -1726,7 +1726,7 @@ static struct ast_channel *gulp_request(const char *type, struct ast_format_cap
session = req_data . session ;
if ( ! ( session - > channel = gul p_new( session , AST_STATE_DOWN , NULL , NULL , requestor ? ast_channel_linkedid ( requestor ) : NULL , NULL ) ) ) {
if ( ! ( session - > channel = chan_pjsi p_new( session , AST_STATE_DOWN , NULL , NULL , requestor ? ast_channel_linkedid ( requestor ) : NULL , NULL ) ) ) {
/* Session needs to be terminated prematurely */
return NULL ;
}
@ -1784,8 +1784,8 @@ static int sendtext(void *obj)
return 0 ;
}
/*! \brief Function called by core to send text on Gulp session */
static int gul p_sendtext( struct ast_channel * ast , const char * text )
/*! \brief Function called by core to send text on PJSIP session */
static int chan_pjsi p_sendtext( struct ast_channel * ast , const char * text )
{
struct ast_sip_channel_pvt * channel = ast_channel_tech_pvt ( ast ) ;
struct sendtext_data * data = sendtext_data_create ( channel - > session , text ) ;
@ -1888,7 +1888,7 @@ static int hangup_sip2cause(int cause)
return 0 ;
}
static void gul p_session_begin( struct ast_sip_session * session )
static void chan_pjsi p_session_begin( struct ast_sip_session * session )
{
RAII_VAR ( struct ast_datastore * , datastore , NULL , ao2_cleanup ) ;
@ -1908,7 +1908,7 @@ static void gulp_session_begin(struct ast_sip_session *session)
}
/*! \brief Function called when the session ends */
static void gul p_session_end( struct ast_sip_session * session )
static void chan_pjsi p_session_end( struct ast_sip_session * session )
{
if ( ! session - > channel ) {
return ;
@ -1924,7 +1924,7 @@ static void gulp_session_end(struct ast_sip_session *session)
}
/*! \brief Function called when a request is received on the session */
static int gul p_incoming_request( struct ast_sip_session * session , struct pjsip_rx_data * rdata )
static int chan_pjsi p_incoming_request( struct ast_sip_session * session , struct pjsip_rx_data * rdata )
{
pjsip_tx_data * packet = NULL ;
@ -1932,12 +1932,12 @@ static int gulp_incoming_request(struct ast_sip_session *session, struct pjsip_r
return 0 ;
}
if ( ! ( session - > channel = gul p_new( session , AST_STATE_RING , session - > exten , NULL , NULL , NULL ) ) ) {
if ( ! ( session - > channel = chan_pjsi p_new( session , AST_STATE_RING , session - > exten , NULL , NULL , NULL ) ) ) {
if ( pjsip_inv_end_session ( session - > inv_session , 503 , NULL , & packet ) = = PJ_SUCCESS ) {
ast_sip_session_send_response ( session , packet ) ;
}
ast_log ( LOG_ERROR , " Failed to allocate new GUL P channel on incoming SIP INVITE\n " ) ;
ast_log ( LOG_ERROR , " Failed to allocate new PJSI P channel on incoming SIP INVITE\n " ) ;
return - 1 ;
}
/* channel gets created on incoming request, but we wait to call start
@ -1967,7 +1967,7 @@ static int pbx_start_incoming_request(struct ast_sip_session *session, pjsip_rx_
break ;
}
ast_debug ( 3 , " Started PBX on new GUL P channel %s\n " , ast_channel_name ( session - > channel ) ) ;
ast_debug ( 3 , " Started PBX on new PJSI P channel %s\n " , ast_channel_name ( session - > channel ) ) ;
return ( res = = AST_PBX_SUCCESS ) ? 0 : - 1 ;
}
@ -1979,7 +1979,7 @@ static struct ast_sip_session_supplement pbx_start_supplement = {
} ;
/*! \brief Function called when a response is received on the session */
static void gul p_incoming_response( struct ast_sip_session * session , struct pjsip_rx_data * rdata )
static void chan_pjsi p_incoming_response( struct ast_sip_session * session , struct pjsip_rx_data * rdata )
{
struct pjsip_status_line status = rdata - > msg_info . msg - > line . status ;
@ -2005,7 +2005,7 @@ static void gulp_incoming_response(struct ast_sip_session *session, struct pjsip
}
}
static int gul p_incoming_ack( struct ast_sip_session * session , struct pjsip_rx_data * rdata )
static int chan_pjsi p_incoming_ack( struct ast_sip_session * session , struct pjsip_rx_data * rdata )
{
if ( rdata - > msg_info . msg - > line . req . method . id = = PJSIP_ACK_METHOD ) {
if ( session - > endpoint - > media . direct_media . enabled ) {
@ -2027,43 +2027,43 @@ static int gulp_incoming_ack(struct ast_sip_session *session, struct pjsip_rx_da
*/
static int load_module ( void )
{
if ( ! ( gul p_tech. capabilities = ast_format_cap_alloc ( ) ) ) {
if ( ! ( chan_pjsi p_tech. capabilities = ast_format_cap_alloc ( ) ) ) {
return AST_MODULE_LOAD_DECLINE ;
}
ast_format_cap_add_all_by_type ( gul p_tech. capabilities , AST_FORMAT_TYPE_AUDIO ) ;
ast_format_cap_add_all_by_type ( chan_pjsi p_tech. capabilities , AST_FORMAT_TYPE_AUDIO ) ;
ast_rtp_glue_register ( & gul p_rtp_glue) ;
ast_rtp_glue_register ( & chan_pjsi p_rtp_glue) ;
if ( ast_channel_register ( & gul p_tech) ) {
if ( ast_channel_register ( & chan_pjsi p_tech) ) {
ast_log ( LOG_ERROR , " Unable to register channel class %s \n " , channel_type ) ;
goto end ;
}
if ( ast_custom_function_register ( & gul p_dial_contacts_function) ) {
ast_log ( LOG_ERROR , " Unable to register GUL P_DIAL_CONTACTS dialplan function\n " ) ;
if ( ast_custom_function_register ( & chan_pjsi p_dial_contacts_function) ) {
ast_log ( LOG_ERROR , " Unable to register PJSI P_DIAL_CONTACTS dialplan function\n " ) ;
goto end ;
}
if ( ast_custom_function_register ( & media_offer_function ) ) {
ast_log ( LOG_WARNING , " Unable to register GUL P_MEDIA_OFFER dialplan function\n " ) ;
ast_log ( LOG_WARNING , " Unable to register PJSI P_MEDIA_OFFER dialplan function\n " ) ;
}
if ( ast_sip_session_register_supplement ( & gul p_supplement) ) {
ast_log ( LOG_ERROR , " Unable to register Gulp supplement\n " ) ;
if ( ast_sip_session_register_supplement ( & chan_pjsi p_supplement) ) {
ast_log ( LOG_ERROR , " Unable to register PJSIP supplement\n " ) ;
goto end ;
}
if ( ast_sip_session_register_supplement ( & pbx_start_supplement ) ) {
ast_log ( LOG_ERROR , " Unable to register Gulp pbx start supplement\n " ) ;
ast_sip_session_unregister_supplement ( & gul p_supplement) ;
ast_log ( LOG_ERROR , " Unable to register PJSIP pbx start supplement\n " ) ;
ast_sip_session_unregister_supplement ( & chan_pjsi p_supplement) ;
goto end ;
}
if ( ast_sip_session_register_supplement ( & gul p_ack_supplement) ) {
ast_log ( LOG_ERROR , " Unable to register Gulp ACK supplement\n " ) ;
if ( ast_sip_session_register_supplement ( & chan_pjsi p_ack_supplement) ) {
ast_log ( LOG_ERROR , " Unable to register PJSIP ACK supplement\n " ) ;
ast_sip_session_unregister_supplement ( & pbx_start_supplement ) ;
ast_sip_session_unregister_supplement ( & gul p_supplement) ;
ast_sip_session_unregister_supplement ( & chan_pjsi p_supplement) ;
goto end ;
}
@ -2071,9 +2071,9 @@ static int load_module(void)
end :
ast_custom_function_unregister ( & media_offer_function ) ;
ast_custom_function_unregister ( & gul p_dial_contacts_function) ;
ast_channel_unregister ( & gul p_tech) ;
ast_rtp_glue_unregister ( & gul p_rtp_glue) ;
ast_custom_function_unregister ( & chan_pjsi p_dial_contacts_function) ;
ast_channel_unregister ( & chan_pjsi p_tech) ;
ast_rtp_glue_unregister ( & chan_pjsi p_rtp_glue) ;
return AST_MODULE_LOAD_FAILURE ;
}
@ -2084,22 +2084,22 @@ static int reload(void)
return - 1 ;
}
/*! \brief Unload the Gulp channel from Asterisk */
/*! \brief Unload the PJSIP channel from Asterisk */
static int unload_module ( void )
{
ast_custom_function_unregister ( & media_offer_function ) ;
ast_sip_session_unregister_supplement ( & gul p_supplement) ;
ast_sip_session_unregister_supplement ( & chan_pjsi p_supplement) ;
ast_sip_session_unregister_supplement ( & pbx_start_supplement ) ;
ast_custom_function_unregister ( & gul p_dial_contacts_function) ;
ast_channel_unregister ( & gul p_tech) ;
ast_rtp_glue_unregister ( & gul p_rtp_glue) ;
ast_custom_function_unregister ( & chan_pjsi p_dial_contacts_function) ;
ast_channel_unregister ( & chan_pjsi p_tech) ;
ast_rtp_glue_unregister ( & chan_pjsi p_rtp_glue) ;
return 0 ;
}
AST_MODULE_INFO ( ASTERISK_GPL_KEY , AST_MODFLAG_LOAD_ORDER , " Gulp SIP Channel Driver" ,
AST_MODULE_INFO ( ASTERISK_GPL_KEY , AST_MODFLAG_LOAD_ORDER , " PJ SIP Channel Driver" ,
. load = load_module ,
. unload = unload_module ,
. reload = reload ,