Как создать rtp сессию на xamarin
Используя этот код у меня получается дозваниваться, от абонента А до абонента В, но мне не удается передать голос. Если я правильно понял мне надо отправить rtp session в запросе при звонке другому абоненту. Но я не понимаю как это сделать на Xamarin. библиотека которой я пользуюсь sipsorcery, это единственная библиотека которая подошла для xamamrin , ее поддерживают , и она бесплатная. Я около недели пробывал различные библиотеки и остановился на этой. Единственная ее проблема , в том что она ориентирована на Windows. Я читал ответ разработчиков на этот вопрос и на сколько я понял с xamamrin возможно передать голос и позвонить, вот их ответ на подобный вопрос https://github.com/sipsorcery-org/sipsorcery/issues/220 .
В итоге я пришел к тому, что у меня не получается на xamarin сформировать RTP Session но удается позвонить.
Как показана в примере разработчиков:
IPTransport sipTransport = new SIPTransport();
SIPUDPChannel udpChannel = new SIPUDPChannel(new IPEndPoint(IPAddress.Any, 0));
sipTransport.AddSIPChannel(udpChannel);
SIPUserAgent ua = new SIPUserAgent(sipTransport, null);
IMediaSession dummySession = new RtpAudioSession(new DummyAudioOptions { AudioSource = DummyAudioSourcesEnum.SineWave }, new List<SDPMediaFormatsEnum> { SDPMediaFormatsEnum.PCMU });
Task.Run(async () => await ua.Call("[email protected]", null, null, dummySession));
Вот мой код:
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);
// 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);
SIPCallDescriptor callDescriptor = new SIPCallDescriptor("1001", "1234", "sip:[email protected]", "<sip:[email protected]>", null, null, null, null, SIPCallDirection.Out, "application/sdp", null, null);
uac.Call(callDescriptor);
}
private void Success(SIPURI obj)
{
throw new NotImplementedException();
}
private void RegRemove(SIPURI obj)
{
throw new NotImplementedException();
}
private void Failure(SIPURI arg1, string arg2)
{
throw new NotImplementedException();
}
private void Failed(SIPURI arg1, string arg2)
{
throw new NotImplementedException();
}