Exemplo n.º 1
0
static int returnFrame(AWCameraDevice *p, int id)
{
	AWCameraDevice* camera_dev = (AWCameraDevice *)(p);
	AWCameraContext* CameraCtx = NULL;
	int err = 0;
	
	if(!camera_dev)
		return -1;

	CameraCtx = (AWCameraContext *)(camera_dev->context);

	CameraReturnOneframe(CameraCtx->v4l2ctx, id);
	
	return 0;
}
Exemplo n.º 2
0
int main()
{
	int ret = 0;
	void * mV4l2_ctx = NULL;
	int mCaptureFormat;
	int width = 1280;
	int height = 720;

	int number = 0;

	struct v4l2_buffer buf;
	memset(&buf, 0, sizeof(buf));
	
	mV4l2_ctx = CreateV4l2Context();

	setV4L2DeviceName(mV4l2_ctx, "/dev/video1");

	// open v4l2 camera device
	ret = OpenCamera(mV4l2_ctx);

	if (ret != 0)
	{
		LOGE("openCameraDevice failed\n");
		return ret;
	}

	StartCamera(mV4l2_ctx, &width, &height);

	while(number < 300) {

		CameraGetOneframe(mV4l2_ctx,&buf);
		CameraReturnOneframe(mV4l2_ctx,buf.index);
		LOGD("test, number: %d",number);

		number ++;
	}
	
	StopCamera(mV4l2_ctx);

	CloseCamera(mV4l2_ctx);
	DestroyV4l2Context(mV4l2_ctx);
	mV4l2_ctx = NULL;

	return 0;
}
Exemplo n.º 3
0
static void* CameraThread(void* pThreadData) {
	
	int result;
	int state = 1;

	AWCameraDevice* camera_dev = (AWCameraDevice *)(pThreadData);
	AWCameraContext* CameraCtx = NULL;
	int err = 0;
	struct v4l2_buffer buf;
	
	CameraCtx = (AWCameraContext*)(camera_dev->context);
	
	while(1) {

		state = get_state(CameraCtx);
		if(state == 0) {
			
			goto EXIT;
		}

		result = CameraGetOneframe(CameraCtx->v4l2ctx, &buf);

		if(result== 0) {

			if( CameraCtx->callback.cookie == NULL) {
				LOGE("the callback isn't register");
				CameraReturnOneframe(CameraCtx->v4l2ctx, buf.index);
			}else {
//				LOGD("CALL Callback");
				CameraCtx->callback.callback(CameraCtx->callback.cookie, &buf);
			}
		}else {
			LOGE("get frame error");
			//goto EXIT;
		}
	}
EXIT:
	set_state(CameraCtx,0);
	return (void *)0;
}