[asterisk-dev] Questions before I wrap up res_pjsip_header_funcs

George Joseph george.joseph at fairview5.com
Thu Sep 12 16:55:38 CDT 2013


On Thu, Sep 12, 2013 at 3:41 PM, Mark Michelson <mmichelson at digium.com> wrote:
> On 09/12/2013 03:56 PM, George Joseph wrote:
>>
>> To recap...  This module implements PJSIP_HEADER, PJSIPAddHeader and
>> PJSIPRemoveHeader.
>>
>> If you don't like the module name, let me know now. :)
>>
>> Questions...
>>
>> Is there really no way to read the string value of an arbitrary pjsip
>> header?  There's pjsip_generic_string_header which has a hvalue, but
>> that's only a parent for the non-frequent headers.  All the more
>> frequent ones have their own structures which you have to know at
>> compile time.  I.E.  You're asking for the "From" header so you know
>> the structure is going to be a pjsip_from_hdr.   For arbitrary
>> headers, my only option seems to be to call the header's print_to
>> function (which they all implement) to a buffer then trim off the
>> leading header name and ': '.  Any other ideas?
>
>
> Hm, I'm not able to think of anything off the top of my head. I think the
> method you've come up with is the best way to go without writing individual
> cases for each type of header supported in PJSIP.
>

Cool.  Pretty simple.

>>
>> Also, is there any way to get the pj_pool from the ast_channel passed
>> to an app or function implementation?  I'm using a pjsip_msg structure
>> to accumulate the outgoing headers and most of the helper functions
>> for pjsip need the pool.
>
>
> The best option here is to use the pjsip_dialog's pool. You can get there
> like so, assuming that "chan" is an ast_channel:
>
> struct ast_sip_channel_pvt *chan_pvt = ast_channel_tech_pvt(chan);
> pj_pool *pool = chan_pvt->session->inv_session->dlg->pool;
>
> And there you have a pool!

Ah, that's where it is.  Didn't think to look all the way down in dlg.

Thanks Mark.



More information about the asterisk-dev mailing list