3

For streaming video over socket in Android, the following approach is adopted

String hostname = "your.host.name";
int port = 1234;
Socket socket = new Socket(InetAddress.getByName(hostname), port);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
MediaRecorder recorder = new MediaRecorder();
// Additional MediaRecorder setup (output format ... etc.) omitted
recorder.setOutputFile(pfd.getFileDescriptor());
recorder.prepare();
recorder.start();

I have created a TCP Server and I am able to receive messages at TCP Server by using the socket's object (code above) Output Stream. Also I am able to save a video by giving a path e.g. "/sdcard/video.mp4" in setOutFile(). With the mentioned code I don't receive anything at TCP Server and also see MediaRecorder﹕ start failed: -38 in the logs. Also I tried shutting all the running applications by going to Settings->Apps->Running.

Kamran
  • 152
  • 2
  • 13
  • OK the problem is with Android Lollipop. http://stackoverflow.com/questions/26990816/mediarecorder-issue-on-android-lollipop – Kamran May 19 '15 at 08:49
  • have you found a solution on how to bypass the limitation with `ParcelFileDescriptor` from the `Socket`? – Roman Samoilenko Sep 12 '17 at 10:56

0 Answers0