diff options
author | Joshua Colp <jcolp@digium.com> | 2013-07-23 12:27:03 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2013-07-23 12:27:03 +0000 |
commit | 16885ffda50a03bc4b5420d8a5d550dd377e4dc8 (patch) | |
tree | a4d67d2db832c4873b1f03c122f352ab78711b96 /res | |
parent | b4c2eecca65f60d518affc2eb5b48aa21701deb6 (diff) |
Expose the chan_pjsip implementation pvt and session in a defined manner.
This allows modules outside of chan_pjsip itself to get the session given
only an Asterisk channel.
Review: https://reviewboard.asterisk.org/r/2674/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395102 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r-- | res/res_sip_session.c | 25 | ||||
-rw-r--r-- | res/res_sip_session.exports.in | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/res/res_sip_session.c b/res/res_sip_session.c index 8532a5a09..7028e0d06 100644 --- a/res/res_sip_session.c +++ b/res/res_sip_session.c @@ -901,6 +901,31 @@ static int add_session_media(void *obj, void *arg, int flags) return 0; } +/*! \brief Destructor for SIP channel */ +static void sip_channel_destroy(void *obj) +{ + struct ast_sip_channel_pvt *channel = obj; + + ao2_cleanup(channel->pvt); + ao2_cleanup(channel->session); +} + +struct ast_sip_channel_pvt *ast_sip_channel_pvt_alloc(void *pvt, struct ast_sip_session *session) +{ + struct ast_sip_channel_pvt *channel = ao2_alloc(sizeof(*channel), sip_channel_destroy); + + if (!channel) { + return NULL; + } + + ao2_ref(pvt, +1); + channel->pvt = pvt; + ao2_ref(session, +1); + channel->session = session; + + return channel; +} + struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, pjsip_inv_session *inv_session) { RAII_VAR(struct ast_sip_session *, session, ao2_alloc(sizeof(*session), session_destructor), ao2_cleanup); diff --git a/res/res_sip_session.exports.in b/res/res_sip_session.exports.in index 28ed0b239..a7afb1c30 100644 --- a/res/res_sip_session.exports.in +++ b/res/res_sip_session.exports.in @@ -16,6 +16,7 @@ LINKER_SYMBOL_PREFIXast_sip_session_create_invite; LINKER_SYMBOL_PREFIXast_sip_session_create_outgoing; LINKER_SYMBOL_PREFIXast_sip_dialog_get_session; + LINKER_SYMBOL_PREFIXast_sip_channel_pvt_alloc; local: *; }; |