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

OnDtmfTone event when incomingcall #1251

Open
lihaoru opened this issue Dec 3, 2024 · 4 comments
Open

OnDtmfTone event when incomingcall #1251

lihaoru opened this issue Dec 3, 2024 · 4 comments

Comments

@lihaoru
Copy link

lihaoru commented Dec 3, 2024

If the OnDtmfTone event is not triggered after an incoming call, the ONDTMFTONE event is triggered after an outgoing call.
`var audioSource = AudioSourcesEnum.None;
var codecs = new List { AudioCodecsEnum.PCMU, AudioCodecsEnum.PCMA, AudioCodecsEnum.G722 };
var audioExtrasSource = new AudioExtrasSource(new AudioEncoder(), new AudioSourceOptions { AudioSource = audioSource });

audioExtrasSource.RestrictFormats(formats => codecs.Contains(formats.Codec));
sipChannel.MediaSession = new VoIPMediaSession(new MediaEndPoints { AudioSource = audioExtrasSource, AudioSink = null });
sipChannel.MediaSession.AcceptRtpFromAny = true;

sipChannel.ServerUserAgent = sipChannel.UserAgent.AcceptCall(req);
sipChannel.State = ChannelStates.RINGING;
sipChannel.DestNo = req.Header.From.FromURI.User;
sipChannel.DestName = req.Header.From.FromName;

sipChannel.UserAgent.OnDtmfTone += (k, du) =>
{
//untriggered
};`

@lihaoru
Copy link
Author

lihaoru commented Dec 4, 2024

OnRtpEvent is not triggered:
mediaSession.OnRtpEvent += (ep, events, had) =>
{
//untriggered
};

@sipsorcery
Copy link
Member

Will take a look at this in the next few days.

@sipsorcery
Copy link
Member

You can use the SIPCallServer and SendDtmf examples to see how to receive DTMF.

sipsorcery\examples\SIPExamples\SIPCallServer>dotnet run
SIPSorcery SIP Call Server example.
Press 'c' to place a call to the default destination.
Press 'd' to send a random DTMF tone to the newest call.
Press 'h' to hangup the oldest call.
Press 'H' to hangup all calls.
Press 'l' to list current calls.
Press 'r' to list current registrations.
Press 't' to transfer the newest call to the default destination.
Press 'q' to quit.
[19:07:26 DBG] CreateBoundSocket attempting to create and bind socket(s) on 0.0.0.0:5060 using protocol Udp.
[19:07:26 DBG] CreateBoundSocket successfully bound on 0.0.0.0:5060.
[19:07:26 INF] SIP UDP Channel created for udp:0.0.0.0:5060.
[19:07:26 DBG] CreateBoundSocket attempting to create and bind socket(s) on [::]:5060 using protocol Udp.
[19:07:26 DBG] CreateBoundSocket successfully bound on [::]:5060, dual mode False.
[19:07:26 INF] SIP UDP Channel created for udp:[::]:5060.
[19:07:26 INF] SIP TCP Channel created for tcp:0.0.0.0:5060.
[19:07:26 DBG] SIP TCP Channel socket on tcp:0.0.0.0:5060 accept connections thread started.
[19:07:26 INF] SIP TLS Channel created for tls:0.0.0.0:5061.
[19:07:26 DBG] SIP TLS Channel socket on tls:0.0.0.0:5061 accept connections thread started.
[19:07:26 INF] SIP TLS Channel ready for tls:0.0.0.0:5061 and certificate CN=localhost.
[19:08:01 DBG] Request received: udp:0.0.0.0:5060<-udp:127.0.0.1:49370 INVITE sip:[email protected]:5060 SIP/2.0
[19:08:01 INF] Incoming call request: udp:0.0.0.0:5060<-udp:127.0.0.1:49370 sip:[email protected]:5060.
[19:08:01 DBG] UAS call progressing with Trying.
[19:08:01 DBG] Response sent: udp:127.0.0.1:5060->udp:127.0.0.1:49370 INVITE 100 Trying
[19:08:01 DBG] UAS call progressing with Ringing.
[19:08:01 INF] RTP audio session source set to Music.
[19:08:01 DBG] CreateRtpSocket attempting to create and bind RTP socket(s) on [::]:0.
[19:08:01 DBG] CreateBoundSocket attempting to create and bind socket(s) on [::]:0 using protocol Udp.
[19:08:01 DBG] CreateBoundSocket even port required, closing socket on [::]:49373 and retrying on 49374.
[19:08:01 DBG] CreateBoundSocket attempting to create and bind socket(s) on [::]:49375 using protocol Udp.
[19:08:01 DBG] CreateBoundSocket successfully bound on [::]:49375, dual mode True.
[19:08:01 DBG] Successfully bound RTP socket [::]:49374 (dual mode True) and control socket [::]:49375 (dual mode True).
[19:08:01 DBG] RTPChannel for [::]:49374 started.
[19:08:01 DBG] Response sent: udp:127.0.0.1:5060->udp:127.0.0.1:49370 INVITE 180 Ringing
[19:08:01 DBG] Request received: udp:0.0.0.0:5060<-udp:127.0.0.1:49370 PRACK sip:[email protected]:5060 SIP/2.0
[19:08:01 DBG] PRACK request matched the current outstanding provisional response, setting as delivered.
[19:08:01 DBG] Response sent: udp:127.0.0.1:5060->udp:127.0.0.1:49370 PRACK 200 Ok
[19:08:02 DBG] Setting audio source format to 0:PCMU 8000 (RTP clock rate 8000).
[19:08:02 DBG] Response sent: udp:127.0.0.1:5060->udp:127.0.0.1:49370 INVITE 200 Ok
[19:08:02 DBG] Request received: udp:0.0.0.0:5060<-udp:127.0.0.1:49370 ACK sip:127.0.0.1:5060 SIP/2.0
[19:08:02 DBG] Set remote track (audio - index=0) SSRC to 1393960093.
[19:08:03 DBG] rtp event 5, duration 400, end of event False, timestamp 7680, marker 1.
[19:08:03 INF] Call 80e5320988954fe684fd27b59106ed4b received DTMF tone 5, duration 400ms.
[19:08:03 DBG] rtp event 5, duration 400, end of event False, timestamp 7680, marker 0.
[19:08:03 DBG] rtp event 5, duration 400, end of event False, timestamp 7680, marker 0.
[19:08:03 DBG] rtp event 5, duration 800, end of event False, timestamp 7680, marker 0.
[19:08:03 DBG] rtp event 5, duration 1200, end of event True, timestamp 7680, marker 0.
[19:08:03 DBG] rtp event 5, duration 1200, end of event True, timestamp 7680, marker 0.
[19:08:03 DBG] rtp event 5, duration 1200, end of event True, timestamp 7680, marker 0.
[19:08:05 DBG] rtp event 9, duration 400, end of event False, timestamp 25040, marker 1.
[19:08:05 INF] Call 80e5320988954fe684fd27b59106ed4b received DTMF tone 9, duration 400ms.
[19:08:05 DBG] rtp event 9, duration 400, end of event False, timestamp 25040, marker 0.
[19:08:05 DBG] rtp event 9, duration 400, end of event False, timestamp 25040, marker 0.
[19:08:05 DBG] rtp event 9, duration 800, end of event False, timestamp 25040, marker 0.
[19:08:05 DBG] rtp event 9, duration 1200, end of event True, timestamp 25040, marker 0.
[19:08:05 DBG] rtp event 9, duration 1200, end of event True, timestamp 25040, marker 0.
[19:08:05 DBG] rtp event 9, duration 1200, end of event True, timestamp 25040, marker 0.
[19:08:07 DBG] rtp event 2, duration 400, end of event False, timestamp 42400, marker 1.
[19:08:07 INF] Call 80e5320988954fe684fd27b59106ed4b received DTMF tone 2, duration 400ms.
[19:08:07 DBG] rtp event 2, duration 400, end of event False, timestamp 42400, marker 0.
[19:08:07 DBG] rtp event 2, duration 400, end of event False, timestamp 42400, marker 0.
[19:08:07 DBG] rtp event 2, duration 800, end of event False, timestamp 42400, marker 0.
[19:08:07 DBG] rtp event 2, duration 1200, end of event True, timestamp 42400, marker 0.
[19:08:07 DBG] rtp event 2, duration 1200, end of event True, timestamp 42400, marker 0.
[19:08:07 DBG] rtp event 2, duration 1200, end of event True, timestamp 42400, marker 0.
[19:08:09 DBG] Request received: udp:0.0.0.0:5060<-udp:127.0.0.1:49370 BYE sip:127.0.0.1:5060 SIP/2.0
[19:08:09 INF] Remote call party hungup BYE sip:127.0.0.1:5060 SIP/2.0.
[19:08:09 DBG] Response sent: udp:127.0.0.1:5060->udp:127.0.0.1:49370 BYE 200 Ok
[19:08:09 WRN] SocketException SIPUDPChannel EndReceiveFrom (10054). An existing connection was forcibly closed by the remote host.
[19:08:09 DBG] RTPChannel closing, RTP receiver on port 49374, Control receiver on port 49375. Reason: normal.

@lihaoru
Copy link
Author

lihaoru commented Dec 9, 2024

I retested it, because the registration terminal is on the alcatel oxe switch, there is a DTMF type setting on the switch, if set to 101, it can receive incoming calls, but if set to 97, it canno
image

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