int SecCamera::startSnapshot(size_t* captureSize)
{
    LOG_TIME_START(0);
    stopPreview();
    LOG_TIME_END(0);

    int ret;
    LOG_TIME_START(1); // prepare
    ret = _v4l2Cam->setupBufs(_snapshotWidth, _snapshotHeight, _snapshotPixfmt,
                              1, 1);
    CHECK_EQ(ret, 1);

    ret = _v4l2Cam->mapBuf(0);
    CHECK_EQ(ret, 0);

    _v4l2Cam->qBuf(0);
    _v4l2Cam->startStream(true);
    LOG_TIME_END(1);

    LOG_CAMERA("%s: stopPreview(%lu), prepare(%lu) us",
               __func__, LOG_TIME(0), LOG_TIME(1));

    _v4l2Cam->mapBufInfo(0, NULL, captureSize);

    return 0;
}
int SecCamera::getSnapshot(int xth)
{
    int index;
    int skipFirstNFrames = xth;

    LOG_TIME_START(0); // skip frames
    while (skipFirstNFrames) {
        LOGV("skipFrames %d", skipFirstNFrames);
        _v4l2Cam->waitFrame();
        index = _v4l2Cam->dqBuf();
        _v4l2Cam->qBuf(index);
        skipFirstNFrames--;
    }

    _v4l2Cam->waitFrame();
    index = _v4l2Cam->dqBuf();
    LOG_TIME_END(0);

    LOG_TIME_START(1);
    _v4l2Cam->startStream(false);
    LOG_TIME_END(1);

    LOG_CAMERA("%s: get frame after skip %d(%lu), stopStream(%lu)",
               __func__, xth, LOG_TIME(0), LOG_TIME(1));

    return 0;
}
示例#3
0
static void *surface_thread(void *arg)
{
	ASurface *surface = (ASurface *)arg;
	void *stream;
	AndroidSurfaceInfo src, dst;
	size_t size;
	LOG_TIME_DEFINE(buff);
	LOG_TIME_DEFINE(decode);

	running = 1;
	while(running == 1) {
		struct jpeg_frame *jpeg;
		LOG_TIME_START(buff);
		size = get_image_buffer(&stream);
		jpeg = stream;

		g_clear_screen_client = jpeg->encode_time;
		LOGD("Jerry: final g_clear_screen_client = %d",
				g_clear_screen_client);

		LOG_D("surface get buffer time delay: %d ms\n", (int)(timestamp() - jpeg->timestamp));
		src.bits = stream + sizeof(struct jpeg_frame);
		LOG_TIME_END(buff);

		if((size > 0) && running)
		{
			LOG_TIME_START(decode);
			lib_ASurface_lock(surface, &dst);
			lib_ASurface_scaleToFullScreen_skia(surface, &src, &dst, size - sizeof(struct jpeg_frame));
			lib_ASurface_unlockAndPost(surface);
			if(first_frame)
			{
				char msg[128];
				first_frame = 0;
				frame_count = 0;
				last_time = timestamp();
				sprintf(msg, "surface:%d:%d", jpeg->width, jpeg->height);
			}
			cal_fps();
			LOG_TIME_END(decode);
			LOG_D("surface display time delay: %d ms, decode and display = %ld ms\n", (int)(timestamp() - jpeg->timestamp), LOG_TIME(decode) / 1000);
			release_image_buffer();
		}

//		LOG_D("------get buff = %ld us, decode and display = %ld us-----\n",
//				LOG_TIME(buff), LOG_TIME(decode));
		g_clear_screen_client = 0;
	}

	return ((void *)0);
}