首页 > 解决方案 > 如何确保 SDP 在 INVITE 的多部分消息正文中排在首位

问题描述

使用 pjsua2 拨打电话时,我想在邀请中包含其他信息。为此,我使用了 pjsip/pjsua2 的多部分功能。

但是,希望我的应用程序可以与不支持多部分的其他应用程序一起使用。因此,我希望 SDP 部分成为第一部分。

示例代码:

void MyAccount::makeCall(const std::string& dst_uri)
{
    auto call = std::make_shared<MyCall>(*this);
    pj::CallOpParam prm(true); // Use default call settings    
    prm.opt.audioCount = 1;
    prm.opt.videoCount = 0;


    pj::SipMultipartPart xmlDocMcptt;
    xmlDocMcptt.contentType.type = "application";
    xmlDocMcptt.contentType.subType = "whatever+xml";
    xmlDocMcptt.body = "<?xml version=\"1.0\"?>\
<sample-xml>\
<sample-params type=\"Test\"/>\
<sample-sub>\
<tt>Test</tt>\
</sample-sub>\
</sample-xml>";

    prm.txOption.multipartContentType.type = "multipart";
    prm.txOption.multipartContentType.subType = "mixed";

    prm.txOption.msgBody.clear();
    
    prm.txOption.multipartParts.emplace_back(xmlDocMcptt);
    

    pj::Endpoint::instance().utilLogWrite(1, "MyAccount", std::string("*** makeCall: headers.size()=") +  std::to_string(prm.txOption.headers.size()) + ", multiparts=" + std::to_string(prm.txOption.multipartParts.size()));

    call->makeCall(dst_uri, prm);
    calls_[call->getInfo().id] = call;
}

在消息正文中,我首先有附加数据,然后是 SDP 数据。 在此处输入图像描述 有没有办法先拥有 SDP 部分?

标签: pjsippjsua2

解决方案


推荐阅读