Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to place a call with asterisk #141

Open
B-R-Bender opened this issue Mar 22, 2023 · 3 comments
Open

how to place a call with asterisk #141

B-R-Bender opened this issue Mar 22, 2023 · 3 comments

Comments

@B-R-Bender
Copy link

B-R-Bender commented Mar 22, 2023

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

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' +

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants