I am developing an Android app that should be capable of streaming video to a local server on my network without storing it on SD card.
For this I have made simple socket application in C# that listens to the specific IP:PORT
On Android part, I had set the setOutputFile()
to this IP:PORT using socket.
This application starts perfectly on Android phone but it does not display preview and when I start recording it exits without any exception. It also do not send any data stream to the network.
When I set the setOutPutFile()
to SD card, it works perfectly and records video also.
For the server part, when I send the data from any other app (from PC) to the same IP:PORT, it receives the data.
In short, I want to establish the communication channel between PC and Android using socket for streaming.
Here is my Android code:
Socket soc=new Socket("192.168.1.3",8210);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(soc);
...
...
// other Recorder setup steps
...
...
Recorder.setOutputFile(pfd.getFileDescriptor()); // working fine for sdcard
Recorder.setPreviewDisplay(holder.getSurface());
Recorder.prepare();
Here is my server app that is in C# and runs on PC:
socketForServer = new TcpClient("192.168.1.3", 8210);
NetworkStream networkStream = socketForServer.GetStream();
byte[] rData = new byte[1024];
networkStream.Read(rData, 0, 1024);
...
...
// process rData
...
...
I am not able to understand the problem that is occurring here. Am I going in right direction?