简体   繁体   中英

PJSIP Received Remote Sip Header

Let's asssume we've two phone and Phone1 & Phone2 they're both has custom sip header

[Phone1] ----calling----> [Phone2] (This is onIncomingCallState for Phone2 and it can read header of Phone1)

[Phone1] <----answer---- [Phone2] (This is answer for Phone2 and it send it's header with it's CallOpParam)

[Phone1] <----OnCallState----> [Phone2] (This is on call state for both, Phone2 has Phone1's header, now Phone1 need to get Phone2's header.)

I'm writing the code at the level of PjSua2 with C++, i can see the log, Phone1 has access the value of header and when i sniff also with the wireshark i can see as well. But how can i handle it at the level of pjsua2, is there any call back or something else?

Usually there are callbacks, in the on_call_media_state . Here is some bare minimum:

void SipApp::on_call_media_state(pjsua_call_id call_id)
{
    pjsua_call_info info;
    pjsua_call_get_info(call_id, &info);

    if (info.media_status == PJSUA_CALL_MEDIA_ACTIVE) {

        //pjsua_conf_connect(0, info.conf_slot);
        pjsua_conf_connect(info.conf_slot, g_recorder->getSlot());

        for(int i=0; i < g_players.count(); i++) {
            g_players.at(i)->setSrc(info.conf_slot);
        }

        g_recorder->setSrc(info.conf_slot);
        g_recorder->start();

        // rtsp setup - start streaming the conf to a remote IP
        if(1){
            if (p_rtsp->asServer()) {
                p_rtsp->setSrc(0);
                p_rtsp->start_streaming();
            } else {
                p_rtsp->setSrc(0);
                p_rtsp->start_recording();
            }
        }
     }
}

Taken from repositry https://github.com/heatblazer/asteriks-debugger/blob/master/Sip/sipapp.cpp

So can you provide more info on what exactly you are missing?

Actually, it is already implemented in the pjsua2 level.

virtual void onCallState(OnCallStatePrm &prm){
..
prm.e.body.tsxState.src.rdata.wholeMsg //this is what i want exactly.
..
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM