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

Ringback sound #91

Open
Lanista12 opened this issue Jun 28, 2018 · 19 comments
Open

Ringback sound #91

Lanista12 opened this issue Jun 28, 2018 · 19 comments

Comments

@Lanista12
Copy link

Hello, Siniypin.
I have the same problem as in issue #39.
I used pjsip4net in my c# project and it works just fine. Quality is good, no interference or noise(other libraries had some problems with that), but there is one major problem: if someone calls me, the one does not hear any ringback sounds.
In issue #39 you gave an example how to solve this problem using conference bridge and WavPlayer.
https://gist.github.com/siniypin/47326a9fd78af95a3ff7
I tried to do that and I worked well, the caller heard every sound it played, but it worked only after I answered the call, and I need it to be played before I pick up the phone.
If I execute this code on CallManager_Ring event _ua.CallManager.Calls.First().ConferenceSlotId return -1(I assume it is because I din't aswer the call yet, so connection is not established and ther is no media stream and sound port binded to it).
If I execute the code anythere after _call.Answer() it return 1 and it works properly.

P.S: Sorry for bad grammar. English is not my native language.

@siniypin
Copy link
Collaborator

siniypin commented Jun 29, 2018

Hi, if I get you right, you want to stream a sound to a speaker device on a calling side before the call has been answered. For that you just have to create a sound player that will stream your audiofile to the speaker device and interconnect them via a ConferenceBridge. I'll stress that once again, you have to interconnect player and a speaker device, a call has nothing to do with the ringtone playback. A CallManager provides necessary callbacks for you to properly start and stop the playback at the right moments.

@siniypin
Copy link
Collaborator

siniypin commented Jul 2, 2018

@Lanista12 did it help? Did you figure this stuff out?

@Lanista12
Copy link
Author

@siniypin, no. Still trying figure that out.

@siniypin
Copy link
Collaborator

siniypin commented Jul 3, 2018

So what's the problem? Did you understand the suggestion?

@Lanista12
Copy link
Author

Lanista12 commented Jul 3, 2018

Yeah, I understood, but I realised that my approach was wrong from the begining. I found out that you don't need to send ringback tone at all.
I used Wireshark to analyse traffic and I found that when you have incoming call, you have these packets if you use another sip-library(ozeki in my case):
--> Request :INVITE sip:[email protected]:32001;transport=TCP;rinstance=9887998e21ce5942 SIP/2.0
<-- Status: SIP/2.0 100 Trying
<-- Status: SIP/2.0 180 Ringing
And caller hear pingback sounds.
But then I used pjsip4net, it had not got last packet with status code 180:
--> Request :INVITE sip:[email protected]:32001;transport=TCP;rinstance=9887998e21ce5942 SIP/2.0
<-- Status: SIP/2.0 100 Trying

it seems like this is the issue.

@siniypin
Copy link
Collaborator

siniypin commented Jul 3, 2018

Check out this comment: #62 (comment)

@Lanista12
Copy link
Author

It didn't help.
I did as it said in #62:
var cfg = Configure.Pjsip4Net().With(x => x.Config.Require100Rel = true);
But I have the same problem.

@siniypin
Copy link
Collaborator

siniypin commented Jul 3, 2018

Can you post your code here?

@Lanista12
Copy link
Author

This is how I initialize UserAgent:

                var cfg = Configure.Pjsip4Net().With(x => x.Config.Require100Rel = true);
                _ua = cfg.Build().Start();//build and start
                _ua.ImManager.IncomingMessage += IncomingMessage;
                _ua.CallManager.CallRedirected += CallRedirected;
                _ua.CallManager.IncomingDtmfDigit += IncomingDtmfDigit;
                _ua.ImManager.NatDetected += OnNatDetected;
                _ua.CallManager.IncomingCall += CallManager_IncomingCall;
                _ua.CallManager.Ring += CallManager_Ring;
                _ua.CallManager.CallStateChanged += CallManager_CallStateChanged;

@siniypin
Copy link
Collaborator

siniypin commented Jul 4, 2018

I assume a CallManager_Ring callback is never executed, correct?

@siniypin
Copy link
Collaborator

siniypin commented Jul 4, 2018

Can you post a CallManager_Ring implementation here as well?

@Lanista12
Copy link
Author

Lanista12 commented Jul 4, 2018

Here is my implementation of CallManager_Ring

        private void CallManager_Ring(object sender, RingEventArgs e)
        {
            // start ringtones
            if (e.RingOn)
            {
                if (e.IsRingback)
                {
                    MediaHandlers.StartRingback();
                }
                else
                {
                    MediaHandlers.StartRingtone();
                }
            }
            else
            {
                MediaHandlers.DetachAudio();

                RechangeCurrentSpeaker();
            }
        }

StartRingBack and StartRingTone is methods to play ringtones localy.

@siniypin
Copy link
Collaborator

siniypin commented Jul 4, 2018

So it is never executed, am I right?

@siniypin
Copy link
Collaborator

siniypin commented Jul 4, 2018

OK, I think I understand your problem a bit better now. Whenever you call a pjsip4net based app, the callee (basically any SIP-client) doesn't hear any ringback, because the app just never replies with 180.
That is a missing feature in pjsip4net. I'd need some time to add it and publish a new version of pjsip4net. Alternatively, you can fork the project, fix it and send me a pull request. Then I could quickly include it and publish to the nuget.

@Lanista12
Copy link
Author

Ok. Roughly speaking, how long will it take for you to add this changes?

@siniypin
Copy link
Collaborator

siniypin commented Jul 5, 2018

I won't promise you anything. You have to understand that I voluntarily maintain this library and support you guys in my spare time.

@Lanista12
Copy link
Author

Lanista12 commented Jul 5, 2018

Ok. Not trying to compel you or something like that. Just trying to understand if you find it an easy task, so you can fix it super fast, or should I try to do that. Nothing else.

@siniypin
Copy link
Collaborator

@Lanista12 please do a favor, fix it and send me a pull request back. I'm currently overloaded. My idea was to track if the ring event has been handled by the app code and call a downstream API with proper params (http://www.pjsip.org/docs/latest-1/pjsip/docs/html/group__PJSUA__LIB__CALL.htm#ga6dd4a80bd96c319398e218bbffda5153) to tell pjsip to send 180 back .

@Lanista12
Copy link
Author

Ok. I'll do my best.

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

No branches or pull requests

2 participants