웹캠과 애뮬레이터를 연동시키는데는 성공을 했습니다.
근데 아래소스를 다운받아 성공을 시켰는데
애뮬레이터에 화면은 뜹니다
하지만 캡쳐를 두번 하고 멈추어 버립니다..

제가 워낙 초보라 소스를 어떻게 변경해야 정지화면이 아닌 동영상을 받아 올수 있는지 모르겠습니다.

고수님들.. 한수 가르쳐 주십시오(__)
[code]

========================================================
액티비티
========================================================
public class cameraTest01 extends Activity implements SurfaceHolder.Callback,Runnable {
/** Called when the activity is first created. */
private final String TAG = "Camera";
private SocketCamera mCamera;

private SurfaceView surface;
private SurfaceHolder holder;

private Thread thread = null;

 

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

surface = (SurfaceView)findViewById(R.id.surfaceView);
holder = surface.getHolder();

holder.addCallback(this);
//holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

}

 

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Log.i(TAG, "Surface Change F:" + format + " , W:" + width + " , H:" + height);

}

 

@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.i(TAG, "Camera opened");
mCamera = new SocketCamera("192.168.194.2", 9889, 320,240, true);

thread = new Thread(this);
thread.start();

}

 

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
mCamera.close();
mCamera = null;
Log.i(TAG, "Camera released");


}

 

@Override
public void run() {
while (true) {
Canvas canvas = null;
try {
canvas = holder.lockCanvas();

synchronized (holder) {
mCamera.capture(canvas);
Thread.sleep(50);
}

} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if (canvas != null) {
holder.unlockCanvasAndPost(canvas);
}
}
}
}
}

 

========================================================
소켓카메라
========================================================
public class SocketCamera implements CameraSource {


private static final int SOCKET_TIMEOUT = 1000;

private final String address;
private final int port;
private final Rect bounds;
private final boolean preserveAspectRatio;
private final Paint paint = new Paint();

public SocketCamera(String address, int port, int width, int height, boolean preserveAspectRatio) {
this.address = address;
this.port = port;
bounds = new Rect(0, 0, width, height);
this.preserveAspectRatio = preserveAspectRatio;

paint.setFilterBitmap(true);
paint.setAntiAlias(true);
}

@Override
public int getWidth() {
return bounds.right;
}

@Override
public int getHeight() {
return bounds.bottom;
}

@Override
public boolean open() {
/* nothing to do */
return true;
}


@Override
public boolean capture(Canvas canvas) {
if (canvas == null) throw new IllegalArgumentException("null canvas");
Socket socket = null;
try {
socket = new Socket();
socket.bind(null);
socket.setSoTimeout(SOCKET_TIMEOUT);
socket.connect(new InetSocketAddress(address, port), SOCKET_TIMEOUT);

//obtain the bitmap
InputStream in = socket.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(in);
//ex start
Paint whitePaint = new Paint();
whitePaint.setAntiAlias(true);
whitePaint.setARGB(255, 124, 0, 23);

canvas.drawCircle(10, 10, 10, whitePaint);
//ex end
//render it to canvas, scaling if necessary
if (
bounds.right == bitmap.getWidth() &&
bounds.bottom == bitmap.getHeight()) {
canvas.drawBitmap(bitmap, 0, 0, null);
} else {
Rect dest;
if (preserveAspectRatio) {
dest = new Rect(bounds);
dest.bottom = bitmap.getHeight() * bounds.right / bitmap.getWidth();
dest.offset(0, (bounds.bottom - dest.bottom)/2);
} else {
dest = bounds;
}
canvas.drawBitmap(bitmap, null, dest, paint);
}

} catch (RuntimeException e) {
Log.i(LOG_TAG, "Failed to obtain image over network", e);
return false;
} catch (IOException e) {
Log.i(LOG_TAG, "Failed to obtain image over network", e);
return false;
} finally {
try {
socket.close();
} catch (IOException e) {
/* ignore */
}
}
return true;
}

@Override
public void close() {
/* nothing to do */
}

}

========================================================
카메라인터페이스
========================================================
public interface CameraSource {

static final String LOG_TAG = "camera";

boolean open();
void close();

int getWidth();

int getHeight();

boolean capture(Canvas canvas);

}
[/code]