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

Call SipServer with sipsorcery and answered call but automatically hungup. #1091

Open
orhanyk opened this issue Mar 22, 2024 · 0 comments
Open

Comments

@orhanyk
Copy link

orhanyk commented Mar 22, 2024

Using the Sip Sorcery library, I create a voice call on the sip server and answer this call. After a while, the call closes automatically. What could be the reason for this? Do I need any extra configuration?

`var rtpSession = CreateRtpSession(userAgent, null);
var callResult = await userAgent.Call(DESTINATION, null, null, rtpSession);

if (callResult)
{
await rtpSession.Start();
//_calls.TryAdd(ua.Dialogue.CallId, ua);
}`

`private static VoIPMediaSession CreateRtpSession(SIPUserAgent ua, string dst)
{
List codecs = new List { AudioCodecsEnum.PCMU, AudioCodecsEnum.PCMA };

var audioSource = AudioSourcesEnum.SineWave;
if (string.IsNullOrEmpty(dst) || !Enum.TryParse(dst, out audioSource))
{
    audioSource = AudioSourcesEnum.Music;
}

_log.Info($"RTP audio session source set to {audioSource}.");

AudioExtrasSource audioExtrasSource = new AudioExtrasSource(new AudioEncoder(), new AudioSourceOptions { AudioSource = audioSource });
audioExtrasSource.RestrictFormats(formats => codecs.Contains(formats.Codec));
var rtpAudioSession = new VoIPMediaSession(new MediaEndPoints { AudioSource = audioExtrasSource });
rtpAudioSession.AcceptRtpFromAny = true;

// Wire up the event handler for RTP packets received from the remote party.
rtpAudioSession.OnRtpPacketReceived += (ep, type, rtp) => OnRtpPacketReceived(ua, type, rtp);
rtpAudioSession.OnTimeout += (mediaType) =>
{
    if (ua?.Dialogue != null)
    {
        _log.Info($"RTP timeout on call with {ua.Dialogue.RemoteTarget}, hanging up.");
    }
    else
    {
        _log.Info($"RTP timeout on incomplete call, closing RTP session.");
    }

    ua.Hangup();
};

return rtpAudioSession;

}`

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

1 participant