SIPUserAgent objSIPUserAgent = new SIPUserAgent();
WindowsAudioEndPoint objWindowsAudioEndPoint = new WindowsAudioEndPoint(new AudioEncoder());
VoIPMediaSession objVoIPMediaSession = new VoIPMediaSession(objWindowsAudioEndPoint.ToMediaEndPoints());
objVoIPMediaSession.AcceptRtpFromAny = true;
string strDestinationAddress = strDialledNumber + gblStrDomain;
bool blnCallResult = await objSIPUserAgent.Call(strDestinationAddress, gblStrExtentionNumber, gblStrExtentionPassword, objVoIPMediaSession);
I have two questions in this scenario.
bool result = objSIPUserAgent.HangUp();
This can be used to reject or cancel the outgoing call.
And Below, we can subscribe to the event OnCallRejected which gets fired the call is rejected by the server
objSIPUserAgent.OnCallRejected += (sender, args) => {
};
Also can OnCallTerminated event . This is fired when the call is cancelled by the server.
objSIPUserAgent.OnCallTerminated += (sender, args) => {
if (args.Reason == CallTerminationReason.LocalCanceled) {
// Handle call canceled event here
}
};
Hope this helps.
OnCallRejected and OnCallTerminated events are not available in version 6.0.12 of the library. These events were added in a later version, specifically version 7.0.0
For older version,
objSIPUserAgent.CallHungup += (uas, reason, lastResponse) =>
{
if (reason == SIPCallTerminateReasonsEnum.None)
{
// The call was terminated normally.
Console.WriteLine("Call Terminated.");
}
else if (reason ==
SIPCallTerminateReasonsEnum.RemoteCancel) {
Console.WriteLine("Cancelled by remote party")
}
};