drachtio / drachtio-srf

drachtio signaling resource framework
https://drachtio.org
MIT License
166 stars 58 forks source link

how to place a call with asterisk #141

Open B-R-Bender opened 1 year ago

B-R-Bender commented 1 year ago

Hello guys!

Can some, please, clarify/help with workflow on the following script:

Let's assume I have RTP stream on a local device, and what I'm trying to accomplish is to place a call from asterisk (I've got sip identity with credentials) using drachtio-srf and use that RTP stream as an audio for the initiated call.

I'm assuming I should you UAC from srf instance, and I'm building local SDP for it but the call seems to be dropping my test code (which is not working) is

let uac = srf.createUAC(`sip:${requstedPhone}@${asteriskHost}`, {
    noAck: true,
    headers: {
        From: `sip:${myAsteriskIdUser}@${asteriskHost}`,
        "User-Agent": "drachtio-srf",
    },
    auth: {
        username: myAsteriskIdUser,
        password: myAsteriskIdPass,
    },
}).then(async (obj) => {
    console.log(`received sdp offer ${obj.sdp} from B party`);
    // get local rtp stream meta
    let ip, port, pType;
    // SDP to send back to the peer
    let sdp =
        "v=0\r\n" +
        "o=sip2ab " + new Date().getTime() + " 1 IN IP4 1.1.1.1\r\n" +
        "s=-\r\n" +
        "t=0 0\r\n" +
        "m=audio " + port + " RTP/AVP " + pType + "\r\n" +
        "c=IN IP4 " + ip + "\r\n" +
        "a=rtpmap:" + pType + " opus/48000/2\r\n" +
        "a=fmtp:" + pType + " maxplaybackrate=48000;stereo=1\r\n";
    return obj.ack(sdp);
}).then((dialog) => {
    dialog.on("destroy", async () => {
        console.log("called party ended call");
    });
});

thank you in advance!

B-R-Bender commented 1 year ago

now I'm thinking I'm doing it wrong (obviously, as it's now working :-) ) as I wan't to be able to place a call to my phone number from asterisk using my sip id/credentials so there in no such thing sip:${requstedPhone}@${asteriskHost}

davehorton commented 1 year ago

That code looks correct to me at first glance. Are you saying it is working now? If so please close the issue, it not please provide sip traces

B-R-Bender commented 1 year ago

Nope it's not working :( I'll get you a sip trace for sure meanwhile I've added some logging to my code, and getting that after I've got dialog in my hand and destroy handler is called

'CSeq: 24347 BYE\r\n' +
'Reason: Q.850;cause=44\r\n' +