title: Error opening android camera for streaming video
body: <p>I'm trying to write video stream from my Galaxy Tab to server. 
  according to <a href="http://developer.android.com/guide/topics/media/camera.html#capture-video" rel="nofollow">this manual</a> i should do something like this:</p>
  
  <pre><code>        frontCamera = getFrontCamera();
          if((socket!= null)&amp;&amp;(frontCamera!=null))
          {
              try {
                  frontCamera.setPreviewDisplay(cameraPreview.getHolder());
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  Log.e("","",e1);
  
              }
              frontCamera.startPreview();
              recorder =  new MediaRecorder();
              frontCamera.unlock();
              recorder.setCamera(frontCamera);
              recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
              recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
              recorder.setProfile(CamcorderProfile.get( CamcorderProfile.QUALITY_HIGH));
              pfd = ParcelFileDescriptor.fromSocket(socket);
              recorder.setOutputFile(pfd.getFileDescriptor());
              recorder.setPreviewDisplay(cameraPreview.getHolder().getSurface());
              try {
                  recorder.prepare();
                  recorder.start();
  } catch (IllegalStateException e) {
                  // TODO Auto-generated catch block
                  Log.e("","",e);
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  Log.e("","",e);
              }
  </code></pre>
  
  <p>but all fails on step <code>recorder.start();</code> with strange error</p>
  
  <pre><code>02-01 19:03:39.265: E/MediaRecorder(11922): start failed: -19
  </code></pre>
  
  <p>what does that mean and  what should I do to start recorder? </p>
  
  <p>UPD:
   Trouble happens because of my getFrontCamera method. when I replace it with camera.open() all works correct.</p>
  
  <pre><code>protected Camera getFrontCamera()
  {
      Camera.CameraInfo inf = new Camera.CameraInfo();
      for(int i = 0; i&lt; Camera.getNumberOfCameras(); i++)
      {
  
          Camera.getCameraInfo(i, inf);
          if(inf.facing==Camera.CameraInfo.CAMERA_FACING_FRONT)
          {
              return Camera.open(i);
          }
      }
      return null;
  }
  </code></pre>
  
  <p>Upd2 - yes, explicit setting of format and encoders solved the trouble -</p>
  
  <pre><code>        recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
          recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
          recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
  </code></pre>
  
  <p>Maybe because of pre-build formats are for back camera... But strange anyway. </p>