VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
ryder86 at googlemail.com Guest
|
Posted: Tue May 26, 2009 9:42 am Post subject: [Freeswitch-users] Unicast isn't working |
|
|
Hi,
I am trying to setup ASR in FreeSwitch using Nuance ASR server and MRCP. Both FreeSwitch and Nuance installed on Windows Server 2003. FreeSwitch version is 1.0.3 (12567M)
I found an example in Perl at http://www.softivr.com/wiki/index.php/FreeSWITCH_MRCP_in_Perl and decided to do the same in C#.
It establishes connection with Nuance and loads the grammar, everything works fine. The next step is to capture audio from FS and tramsmit it to ASR. This can be done with unicast. We must create an outbound socket and issue "unicast" command. Here it goes:
private void SetupAudioTransmission()
{
EventSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
EventSocket.SendTimeout = Config.Timeout;
int ESPort = SearchESPort(EventSocket);
Thread thrESListener = new Thread(new ThreadStart(ListenerThreadStart));
thrESListener.Start();
WriteLog(LogLevel.Info, "Creating outbound event socket");
Session.Execute("socket", "127.0.0.1:" + ESPort); //main thread stops, listener thread listens for outbound socket connection.
WriteLog(LogLevel.Info, "Outbound event socket disconnected");
EventSocket.Close();
}
//here we accept outbound socket and transmit unicast command through it
private void ListenerThreadStart()
{
Socket sockHandler = EventSocket.Accept();
WriteLog(LogLevel.Info, "Incoming connection");
sockHandler.Send(MessageEncoding.GetBytes("Connect\n\n"));
WriteLog(LogLevel.Info, GetServerResponse(sockHandler));
int rtpPort = (RTPSocket.RemoteEndPoint as IPEndPoint).Port;
string command = string.Format("sendmsg\r\ncall-command: unicast\r\nlocal-ip: {0}\r\nlocal-port: {1}\r\nremote-ip: {2}\r\n" +
"remote-port: {3}\r\ntransport: udp\r\nflags: native\r\n\r\n", Config.LocalIP, rtpPort + 1, Config.LocalIP, rtpPort);
WriteLog(LogLevel.Info, command);
sockHandler.Send(MessageEncoding.GetBytes(command));
WriteLog(LogLevel.Info, GetServerResponse(sockHandler));
sockHandler.Disconnect(false);
sockHandler.Close();
}
After this, FS writes that unicast has been created on corresponding IPs and ports. It really creates an UDP socket, but doesn't transmit any data through it. I tested it with Wireshark and from my application, nothing was detected.
Also, if we specify "transport:tcp" in unicast command, it uses UDP anyway, that's strange.
Here is how I listen UDP packets.
private void DetectSpeech()
{
WriteLog(LogLevel.Info, "Reading audio");
byte[] FSRecvBuf = new byte[2048];
IPEndPoint epFS = new IPEndPoint(IPAddress.Loopback, (RTPSocket.RemoteEndPoint as IPEndPoint).Port);
FSSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
FSSocket.ReceiveTimeout = 100000;
FSSocket.SendTimeout = 100000;
WriteLog(LogLevel.Info, "Binding socket to " + epFS.Port);
FSSocket.Bind(epFS);
FSSocket.Connect(new IPEndPoint(IPAddress.Loopback, epFS.Port + 1));
while (Session.Ready())
{
int recvCount = FSSocket.Receive(FSRecvBuf);
WriteLog(LogLevel.Info, "Received bytes: " + recvCount);
}
}
Can someone help me to solve this? Do I do something wrong or I forgot something or it doesn't work at all?
Best regards.
Artem |
|
Back to top |
|
|
dave at 3c.co.uk Guest
|
Posted: Tue May 26, 2009 10:29 am Post subject: [Freeswitch-users] Unicast isn't working |
|
|
Hi Artem, Please to see that some of the stuff I wrote is useful to someone..! I've written an FS module which will send the audio over - it's more efficient than using unicast. Let me know if you'd like a copy. Cheers -- Dave ----- Original Message ----- From: Артем Васильев (ryder86@googlemail.com) To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org) Sent: Tuesday, May 26, 2009 9:27 AM Subject: [Freeswitch-users] Unicast isn't working Hi,I am trying to setup ASR in FreeSwitch using Nuance ASR server and MRCP. Both FreeSwitch and Nuance installed on Windows Server 2003. FreeSwitch version is 1.0.3 (12567M)I found an example in Perl at http://www.softivr.com/wiki/index.php/FreeSWITCH_MRCP_in_Perl and decided to do the same in C#.It establishes connection with Nuance and loads the grammar, everything works fine. The next step is to capture audio from FS and tramsmit it to ASR. This can be done with unicast. We must create an outbound socket and issue "unicast" command. Here it goes:private void SetupAudioTransmission(){ EventSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); EventSocket.SendTimeout = Config.Timeout; int ESPort = SearchESPort(EventSocket); Thread thrESListener = new Thread(new ThreadStart(ListenerThreadStart)); thrESListener.Start(); WriteLog(LogLevel.Info, "Creating outbound event socket"); Session.Execute("socket", "127.0.0.1:" + ESPort); //main thread stops, listener thread listens for outbound socket connection. WriteLog(LogLevel.Info, "Outbound event socket disconnected"); EventSocket.Close();} //here we accept outbound socket and transmit unicast command through itprivate void ListenerThreadStart(){ Socket sockHandler = EventSocket.Accept(); WriteLog(LogLevel.Info, "Incoming connection"); sockHandler.Send(MessageEncoding.GetBytes("Connect\n\n")); WriteLog(LogLevel.Info, GetServerResponse(sockHandler)); int rtpPort = (RTPSocket.RemoteEndPoint as IPEndPoint).Port; string command = string.Format("sendmsg\r\ncall-command: unicast\r\nlocal-ip: {0}\r\nlocal-port: {1}\r\nremote-ip: {2}\r\n" + "remote-port: {3}\r\ntransport: udp\r\nflags: native\r\n\r\n", Config.LocalIP, rtpPort + 1, Config.LocalIP, rtpPort); WriteLog(LogLevel.Info, command); sockHandler.Send(MessageEncoding.GetBytes(command)); WriteLog(LogLevel.Info, GetServerResponse(sockHandler)); sockHandler.Disconnect(false); sockHandler.Close(); }After this, FS writes that unicast has been created on corresponding IPs and ports. It really creates an UDP socket, but doesn't transmit any data through it. I tested it with Wireshark and from my application, nothing was detected.Also, if we specify "transport:tcp" in unicast command, it uses UDP anyway, that's strange.Here is how I listen UDP packets.private void DetectSpeech(){ WriteLog(LogLevel.Info, "Reading audio"); byte[] FSRecvBuf = new byte[2048]; IPEndPoint epFS = new IPEndPoint(IPAddress.Loopback, (RTPSocket.RemoteEndPoint as IPEndPoint).Port); FSSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); FSSocket.ReceiveTimeout = 100000; FSSocket.SendTimeout = 100000; WriteLog(LogLevel.Info, "Binding socket to " + epFS.Port); FSSocket.Bind(epFS); FSSocket.Connect(new IPEndPoint(IPAddress.Loopback, epFS.Port + 1)); while (Session.Ready()) { int recvCount = FSSocket.Receive(FSRecvBuf); WriteLog(LogLevel.Info, "Received bytes: " + recvCount); }}Can someone help me to solve this? Do I do something wrong or I forgot something or it doesn't work at all?Best regards.Artem _______________________________________________Freeswitch-users mailing listFreeswitch-users@lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-usersUNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org |
|
Back to top |
|
|
ryder86 at googlemail.com Guest
|
Posted: Wed May 27, 2009 1:19 am Post subject: [Freeswitch-users] Unicast isn't working |
|
|
Of course, it will be useful to try it.
Artem
Quote: | Hi Artem,
Please to see that some of the stuff I wrote is useful to someone..!
I've written an FS module which will send the audio over - it's more efficient than using unicast. Let me know if you'd like a copy.
Cheers --
Dave
|
|
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|