9

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?

Vinod Maurya
  • 4,167
  • 11
  • 50
  • 81
  • Hello Vinod, could you release the source code of the android app? I try to do the same thing, but the video freeze, and I don't know why... Thanks. – Rob May 03 '11 at 06:12
  • Hi, Sorry I can't release the code as it is from a commercial project. If you could send me your code, I will try to fix the issue. Thanks – Vinod Maurya May 03 '11 at 07:33
  • I basically do the same thing than you, but I'm struggling on the format... I receive something, but without the good header I think. My problem is really well described here (http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system) but I dont know how to deal with. Could you just show that small part? Thanks. – Rob May 05 '11 at 07:37
  • Hi Vinod, I am also facing a problem in recording. My server side is working fine but from my android client I am not able to send the data. So, if possible can you please provide some of sample source code. – Murtz May 21 '13 at 07:52

1 Answers1

5

There was problem in my server code.

I had to use TcpListener in place of TcpClient.

Following is the correct code:

TcpListener listener = new TcpListener(ipAddress, 8210);
Socket s = listener.AcceptSocket();
NetworkStream ns = new NetworkStream(s);
.
.
.
//reading the data from stream
.
.
.
Vinod Maurya
  • 4,167
  • 11
  • 50
  • 81