PJSIP自定义注册标题 [英] PJSIP Custom Registration Header

查看:553
本文介绍了PJSIP自定义注册标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置与内部服务器进行 SIP 通信(使用PJSIP库),但是,该服务器需要一个自定义标题字段,其中注册呼叫。例如,我们将调用这个必需的头 MyHeader



根据我的发现, pjsua_acc_add()函数将添加一个帐户并将其注册到服务器一个配置结构



结构的参数 reg_hdr_list 具有以下描述:


可选的自定义SIP头部将被放入注册请求中。


这听起来正是我所需要的,但是对调用本身没有任何影响。



以下是我到目前为止的内容:

  pjsua_acc_config cfg; 
pjsua_acc_config_default(& cfg);

// ...一些与服务器相关的其他配置...

pjsip_hdr test;
test.name = pj_str(MyHeader);
test.sname = pj_str(MyHdr);
test.type = PJSIP_H_OTHER;
test.prev = cfg.reg_hdr_list.prev;
test.next = cfg.reg_hdr_list.next;
cfg.reg_hdr_list = test;

pj_status_t status;
status = pjsua_acc_add(& cfg,PJ_TRUE,& acc_id);

从服务器端来看,没有额外的头域或任何东西。而用于定义头部的结构( pjsua_hdr )没有或等效字段,所以即使它如何创建标题,它是如何设置值的?



这里是标题列表定义和参考 for the header struct。



编辑:我发现解决方案要感谢同事:

  struct pjsip_generic_string_hdr CustomHeader; 
pj_str_t name = pj_str(MyHeader);
pj_str_t value = pj_str(HeaderValue);
pjsip_generic_string_hdr_init2(& CustomHeader,& name,& value);

pj_list_push_back(& cfg.reg_hdr_list,& CustomHeader);

这似乎按预期工作。

解决方案

只要将OP引用为,他就找到了解决方案,但忘记将其添加为答案:

< blockquote>

编辑:我发现解决方案要感谢同事:

  struct pjsip_generic_string_hdr CustomHeader; 
pj_str_t name = pj_str(MyHeader);
pj_str_t value = pj_str(HeaderValue);
pjsip_generic_string_hdr_init2(& CustomHeader,& name,& value);

pj_list_push_back(& cfg.reg_hdr_list,& CustomHeader);

这似乎按预期工作。


I am attempting to setup SIP communication with an internal server (using the PJSIP library), however, this server requires a custom header field with a specified header value for the REGISTRATION call. For example's sake we'll call this required header MyHeader.

From what I have found, the pjsua_acc_add() function will add an account and register it to the server using a config struct.

The parameter reg_hdr_list of the config struct has the description:

The optional custom SIP headers to be put in the registration request.

Which sounds like exactly what I need, however doesn't seem to have any effect on the call itself.

Here's what I have so far:

    pjsua_acc_config cfg;
    pjsua_acc_config_default(&cfg);

    //...Some other config stuff related to the server...

    pjsip_hdr test;
    test.name = pj_str("MyHeader");
    test.sname = pj_str("MyHdr");
    test.type = PJSIP_H_OTHER;
    test.prev = cfg.reg_hdr_list.prev;
    test.next = cfg.reg_hdr_list.next;
    cfg.reg_hdr_list = test;

    pj_status_t status;
    status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);

From the server side, there are no extra header fields or anything. And the struct that is used to define the header (pjsua_hdr) has no value or equivalent field, so even if it did create the header, how does it set the value?

Here is the refrence for the header list definition and the reference for the header struct.

Edit: I found the solution thanks to a co-worker:

    struct pjsip_generic_string_hdr CustomHeader;
    pj_str_t name = pj_str("MyHeader");
    pj_str_t value = pj_str("HeaderValue");
    pjsip_generic_string_hdr_init2(&CustomHeader, &name, &value);

    pj_list_push_back(&cfg.reg_hdr_list, &CustomHeader);

This seems to work as expected.

解决方案

Just quoting the OP as he found the solution, but forgot to add it as an answer:

Edit: I found the solution thanks to a co-worker:

struct pjsip_generic_string_hdr CustomHeader;
pj_str_t name = pj_str("MyHeader");
pj_str_t value = pj_str("HeaderValue");
pjsip_generic_string_hdr_init2(&CustomHeader, &name, &value);

pj_list_push_back(&cfg.reg_hdr_list, &CustomHeader);

This seems to work as expected.

这篇关于PJSIP自定义注册标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆