title: Live Video Stream between two Android Phones
body: <p>I am currently working on video streaming between two Android Phone. 
  I wrote an application which is able to record the video to the sd file (Using MediaRecorder); and I wrote another application which is able to display the video of the file. Both applications work perfectly.</p>
  
  <p>I found a website about "Broadcasting video with Android - without writing to local files" in following website. It is exactly what I wanted to do.</p>
  
  <p><a href="http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system">http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system</a></p>
  
  <p>I modified my code.</p>
  
  <p>For the video recorder, 
  it is:</p>
  
  <pre><code>socket=severSocket.accept();
  ParcelFileDescriptor=pfd;
  recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
  recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
  recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
  recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
  recorder.setVideoFrameRate(15);
  recorder.setVideoSize(320, 240);
  recorder.setPreviewDisplay(holder.getSurface());
  pfd = ParcelFileDescriptor.fromSocket(socket);
  recorder.setOutputFile(pfd.getFileDescriptor());
  recorder.prepare(); 
  recorder.start();
  </code></pre>
  
  <p>For Video Player:</p>
  
  <pre><code>Socket socket = new Socket(IP,PORT);
  mMediaPlayer = new MediaPlayer();
  pfd = ParcelFileDescriptor.fromSocket(socket);
  mMediaPlayer.setDataSource(pfd.getFileDescriptor()); // &lt;-- here is the problem
  mMediaPlayer.setDisplay(holder); 
  mMediaPlayer.prepare();
  mMediaPlayer.setOnBufferingUpdateListener(this);            
  mMediaPlayer.setOnCompletionListener(this);            
  mMediaPlayer.setOnPreparedListener(this);            
  mMediaPlayer.setOnVideoSizeChangedListener(this);
  mMediaPlayer.start();
  </code></pre>
  
  <p>Program crush on <strong><code>mMediaPlayer.setDataSource(pfd.getFileDescriptor());</code></strong> on MediaPlayer
  I know I didnt setup the DataSource correctly. There must be additional setups for <strong>ParcelFileDescriptor</strong> to put into MediaPlayer.</p>
  
  <p>Does anyone know how to use <strong>ParcelFileDescriptor</strong> for MediaPlayer?
  Any helpful advise or tips would be nice......</p>
  
  <p>Thank You</p>
  
  <p>Will</p>