hi TreKing,
               This is my whole code, Where is the appropriate place to close 
the stream. or may i have to add a loop or thread to control this. please give 
me the  clear road map to handle this.
 
Thanks,
 
 public void surfaceCreated(SurfaceHolder holder) 
{  
    // The Surface has been created, acquire the camera and tell it where
    // to draw.
 
      try {
        socket = new Socket("192.168.1.220", 8888);
        obj = new ObjectOutputStream(socket.getOutputStream());
    } catch (UnknownHostException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
      
      
    camera = Camera.open(); 
    try {
        
        
      camera.setPreviewDisplay(holder);  

      camera.setPreviewCallback(new PreviewCallback() {
        // Called for each frame previewed
        @SuppressWarnings("null")
        public void onPreviewFrame(byte[] data, Camera camera) { 
            
            
            Camera.Parameters parameters = camera.getParameters();
            int format = parameters.getPreviewFormat();

             //YUV formats require more conversion
            if (format == ImageFormat.NV21 /*|| format == ImageFormat.YUY2 || 
format == ImageFormat.NV16*/)
            {
                int w = parameters.getPreviewSize().width;
                int h = parameters.getPreviewSize().height;
                // Get the YuV image
                YuvImage yuv_image = new YuvImage(data, format, w, h, null);
                // Convert YuV to Jpeg
                Rect rect = new Rect(0, 0, w, h);
                ByteArrayOutputStream output_stream = new 
ByteArrayOutputStream();
                yuv_image.compressToJpeg(rect, 100, output_stream);
                byte[] byt=output_stream.toByteArray();
                
              
                 try {
                      
                          obj.writeObject(byt);
                          obj.flush();
                         // obj.close();
                       
                         
                     Log.d(TAG, "onPictureTaken - wrote bytes: " + data.length);
                      } catch (FileNotFoundException e) { 
                        e.printStackTrace();
                     } catch (IOException e) {
                        e.printStackTrace();
                     } finally {
                     }
               
                Preview.this.invalidate();

            }
     
        }
      });
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
From: [email protected]
Date: Thu, 5 Jan 2012 14:56:11 -0600
Subject: Re: [android-developers] onPreviewFrame
To: [email protected]


On Thu, Jan 5, 2012 at 2:23 PM, Muhammad UMER <[email protected]> 
wrote:


 Thanks for your reply, Sorry i have not clearly mention that "obj" is the 
object of the  ObjectOutputStream, this stream send only the first image to 
server not any other what's the reason.


Without more code to look at, the fact that you're closing the stream in the 
function might be a factor.

-------------------------------------------------------------------------------------------------


TreKing - Chicago transit tracking app for Android-powered devices





-- 

You received this message because you are subscribed to the Google

Groups "Android Developers" group.

To post to this group, send email to [email protected]

To unsubscribe from this group, send email to

[email protected]

For more options, visit this group at

http://groups.google.com/group/android-developers?hl=en                         
                  

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to