sipsorcery
sipsorcery copied to clipboard
How to make calls using xamarin.froms?
@sipsorcery Hello, I am working on an application on Xamamrin.Frorms platform, could you please share some code or solution? now i am using the library (sipsorcery), i can call, but cant transfer my voice
my code:
public class CallViewModel
{
string USERNAME = "1001";
string PASSWORD = "1234";
string DOMAIN = "192.168.0.105";
int EXPIRY = 120;
protected MediaRecorder recorder;
SIPTransport sipTransport = new SIPTransport();
public CallViewModel()
{
SIPRegistrationUserAgent regUserAgent = new SIPRegistrationUserAgent(sipTransport, USERNAME, PASSWORD, DOMAIN, EXPIRY);
regUserAgent.RegistrationFailed += Failed;
regUserAgent.RegistrationTemporaryFailure += Failure;
regUserAgent.RegistrationRemoved += RegRemove;
regUserAgent.RegistrationSuccessful += Success;
regUserAgent.Start();
myCall();
}
public async Task myCall()
{
string DESTINATION = "192.168.0.105";
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString();
System.Net.IPAddress ipaddress = System.Net.IPAddress.Parse(myIP);
var userAgent = new SIPUserAgent(sipTransport, null);
var rtpSession = new RTPSession(true, true,true, ipaddress);
// Create a SIP user agent client that can be used to initiate calls to external SIP devices and place a call.
SIPUDPChannel udpChannel = new SIPUDPChannel(new IPEndPoint(IPAddress.Any, 0));
sipTransport.AddSIPChannel(udpChannel);
SIPClientUserAgent uac = new SIPClientUserAgent(sipTransport);
_ = rtpSession.Start();
SIPCallDescriptor callDescriptor = new SIPCallDescriptor("1001", "1234", "sip:[email protected]", "<sip:[email protected]>", null, null, null, null, SIPCallDirection.Out, "RDP/UDP", null, null);
uac.Call(callDescriptor);
}
}
i can call, but cant transfer my voice
Do you mean you get no audio?
I think you may have already come across some other posts where the lack of audio support witn Xamarin and .NET is discussed.
If so, then libvlcsharp seems like the most likely candidate to get access to audio devices with Xamarin but I have never tested it myself.
Yes, I have no sound. Do you have examples of work with this library? libvlcsharp, I cannot figure out how to combine it with your library
Do you have examples of work with this library? libvlcsharp, I cannot figure out how to combine it with your library
No, I don't. You could try asking on the libvlcsharp repo. There was some activity a while ago where that repo was looking into how to intgerate with the sipsorcery library.
I found the FFMpeg library, could you show an example for xamarin at least explain how to use it so that I can capture the microphone and speakers
I've never used the FFMpeg library on Xamarin so can't help, sorry.
Hi,
You can get two-way audio using libvlc for an audio sink, I've used Plugin.AudioRecorder as the recording source. It does take quite a bit of work to wire it all up. When tested and tidied I see what I can share back.
As suggested elsewhere you need to wire up a XamarinAudioEndpoint. I also had to write up a buffer / stream that can be both written to by GotAudioRtp and read from by libvlc. I also found that I needed to write the wav header to my buffer before libvlc could understand the format and add some options to the media to set the format as per the codecs.
Ali.
@Ali-Russell , I have little experience for this, but I really need it, please share the code . PLEASE I will be very grateful to you!!!
@DS2107,
I created a new package ( SIPSorcery.SDL2 ) which permits to have Audio End Point and Audio Source using SDL2
SDL2 is multiplatform.
I have already tested on Windows, MacOs and Linux the integration of SIPSorcery and SIPSorcery.SDL2
I didn't have tested yet on Xamarin.Forms but it should work too.
If you could try and let us know it will be great :)
@ChristopheI , Good day, thank you very much for the opportunity, at the moment I'm not working on the project where I needed this library. But I will soon finish this project and soon I will return to its development, it will be (maybe) within a month
@ChristopheI , would you show some example of how this library works For SIP calls, it is possible on windows?
@DS2107 , For the moment, I'm using SIPSorcery using WebRTC only.
But you have a lot of samples
You can find specific samples of SIPSorcery.SDL2 and SIPSorceryMedia.FFmpeg in their own repositories.
Don't forget that Audio/Video Sink and Audio/Video End Point are all defined using interfaces declared here: MediaEndPoints (from the repository SIPSorceryMedia.Abstractions)
So what ever the implementation you want to use ( SIPSorcery.SDL2, SIPSorceryMedia.FFmpeg or SIPSorceryMedia.Windows ) it's nearly the same thing to use one of them