int stopPreview(int cam_id)
{
    int rc = MM_CAMERA_OK;
    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    CDBG("%s : pme->cam_mode = %d, pme->cam_state = %d",__func__,pme->cam_mode,pme->cam_state);

    if (pme->cam_mode == CAMERA_MODE && pme->cam_state == CAMERA_STATE_PREVIEW) {
        if (MM_CAMERA_OK != (rc = mm_app_stop_preview(cam_id))) {
            CDBG("%s:streamoff preview err=%d\n", __func__, rc);
            goto end;
        }
    } else if (pme->cam_mode == ZSL_MODE && pme->cam_state == CAMERA_STATE_PREVIEW) {
        if (MM_CAMERA_OK != (rc = mm_app_stop_preview_zsl(cam_id))) {
            CDBG("%s:streamoff preview err=%d\n", __func__, rc);
            goto end;
        }
    } else if (pme->cam_mode == RECORDER_MODE && pme->cam_state == CAMERA_STATE_PREVIEW) {
        if (MM_CAMERA_OK != (rc = mm_app_stop_preview(cam_id))) {
            CDBG("%s:streamoff preview err=%d\n", __func__, rc);
            goto end;
        }
        mm_app_unprepare_video(cam_id);
    }
    end:
    return rc;
}
Exemplo n.º 2
0
void switchCamera(int cam_id)
{
    int rc = MM_CAMERA_OK;
    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    if(my_cam_app.cam_open == cam_id){
        return;
    }

    switch(pme->cam_state) {
        case CAMERA_STATE_RECORD:
            if(MM_CAMERA_OK != stopRecording(cam_id)){
                CDBG_ERROR("%s:Cannot stop video err=%d\n", __func__, rc);
                return -1;
            }
        case CAMERA_STATE_PREVIEW:
            if(MM_CAMERA_OK !=  mm_app_stop_preview(cam_id)){
                CDBG_ERROR("%s: Cannot switch to camera mode=%d\n", __func__);
                return -1;
            }
            break;
        case CAMERA_STATE_SNAPSHOT:
        default:
            break;
    }

    mm_app_close(my_cam_app.cam_open);
    mm_app_open(cam_id);
}
Exemplo n.º 3
0
int mm_app_take_raw_picture(int cam_id)
{
    int rc;
#if 0
    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    CDBG("%s:BEGIN, cam_id=%d\n",__func__,cam_id);
    g_status = FALSE;
    if (MM_CAMERA_OK != (rc = pme->cam->ops->action(pme->cam, TRUE, MM_CAMERA_OPS_PREPARE_SNAPSHOT, 0))) {
        CDBG("%s:prepare snapshot err=%d\n", __func__, rc);
        goto end;
    }
    if (MM_CAMERA_OK != (rc = mm_app_stop_preview(cam_id))) {
        CDBG("%s:mm_app_stop_preview err=%d\n", __func__, rc);
        goto end;
    }
    if (MM_CAMERA_OK != mm_app_start_raw_snapshot(cam_id))
        goto preview;
    CDBG("%s:waiting images\n",__func__);
    mm_app_snapshot_wait(cam_id);
    CDBG("%s:calling mm_app_stop_snapshot() \n",__func__);
    mm_app_stop_raw_snapshot(cam_id);
preview:
    mm_app_start_preview(cam_id);
end:
    CDBG("%s:END, cam_id=%d\n",__func__,cam_id);
#endif
    return rc;
}
int mm_app_open_zsl(int cam_id)
{
    int rc = MM_CAMERA_OK;
    int value = 0;
    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    if (pme->cam_mode == ZSL_MODE) {
        return rc;
    }

    if (MM_CAMERA_OK != (rc = mm_app_stop_preview(cam_id))) {
        CDBG_ERROR("%s:Stop preview err=%d\n", __func__, rc);
        goto end;
    }

    pme->cam->ops->set_parm(pme->cam->camera_handle,MM_CAMERA_PARM_RECORDING_HINT, &value);

    if (MM_CAMERA_OK != (rc = mm_app_start_preview_zsl(cam_id))) {
        CDBG_ERROR("%s:stream on preview err=%d\n", __func__, rc);
        goto end;
    }
    pme->cam_mode = ZSL_MODE;
    end:
    CDBG("%s: END, rc=%d\n", __func__, rc);
    return rc;
}
Exemplo n.º 5
0
int mm_app_start_snapshot(int cam_id)
{
    int rc = MM_CAMERA_OK;
    int stream[2];
    int op_mode = 0;
    uint8_t initial_reg_flag;
    mm_camera_frame_len_offset frame_offset_info;

    mm_camera_bundle_attr_t attr;


    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    if (MM_CAMERA_OK != mm_app_stop_preview(cam_id)) {
        CDBG_ERROR("%s: Stop preview Failed cam_id=%d\n",__func__,cam_id);
        return -1;
    }
    op_mode = MM_CAMERA_OP_MODE_CAPTURE;
    mm_app_set_snapshot_mode(cam_id,op_mode);
    usleep(20*1000);
//    pme->cam->ops->prepare_snapshot(pme->cam->camera_handle,pme->ch_id,0);

    if (MM_CAMERA_OK != (rc = mm_app_add_snapshot_stream(cam_id))) {
        CDBG_ERROR("%s : Add Snapshot stream err",__func__);
        return rc;
    }

    if (MM_CAMERA_OK != (rc = mm_app_config_snapshot_format(cam_id))) {
        CDBG_ERROR("%s : Config Snapshot stream err",__func__);
        return rc;
    }

    if (MM_CAMERA_OK != (rc = mm_app_streamon_snapshot(cam_id))) {
        CDBG_ERROR("%s : Stream on Snapshot stream err",__func__);
        return rc;
    }

    /* init jpeg buf */
    pme->cam->ops->get_stream_parm(pme->cam->camera_handle,
                                   pme->ch_id,
                                   pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id,
                                   MM_CAMERA_STREAM_OFFSET,
                                   &frame_offset_info);
    CDBG_ERROR("%s : alloc jpeg buf (len=%d)",__func__, frame_offset_info.frame_len);
    rc = mm_stream_alloc_bufs(pme,
                              &pme->jpeg_buf,
                              &frame_offset_info,
                              1);
    if (0 != rc) {
        CDBG_ERROR("%s : mm_stream_alloc_bufs err",__func__);
        return rc;
    }

    CDBG("%s: END, rc=%d\n", __func__, rc);
    return rc;
}
int mm_app_open_recorder(int cam_id)
{
	int rc = MM_CAMERA_OK;
	int value = 1;
	int powermode = 1;

	mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

	CDBG("%s: mm_app_open_recorder",__func__);
	if(pme->cam_mode == RECORDER_MODE) {
		CDBG("%s : Already in record mode",__func__);
		return rc;
	}

	if(MM_CAMERA_OK != (rc = mm_app_stop_preview(cam_id))){
		CDBG_ERROR("%s:Stop preview err=%d\n", __func__, rc);
		goto end;
	}

	if(MM_CAMERA_OK != initDisplay())
	{
		CDBG_ERROR("%s : Could not initalize display",__func__);
		goto end;
	}

	pme->cam->ops->set_parm(pme->cam->camera_handle,MM_CAMERA_PARM_RECORDING_HINT, &value);

	pme->cam->ops->set_parm(pme->cam->camera_handle,MM_CAMERA_PARM_LOW_POWER_MODE, &powermode);


	if(MM_CAMERA_OK != (rc = mm_app_prepare_preview(cam_id))){
		CDBG_ERROR("%s:stream on preview err=%d\n", __func__, rc);
		goto end;
	}

	if(MM_CAMERA_OK != (rc = mm_app_prepare_video(cam_id))){
		CDBG_ERROR("%s:stream on video err=%d\n", __func__, rc);
		goto end;
	}

	if(MM_CAMERA_OK != (rc = mm_app_streamon_preview(cam_id))){
		CDBG_ERROR("%s:start preview err=%d\n", __func__, rc);
		goto end;
	}
	pme->cam_mode = RECORDER_MODE;
end:
	CDBG("%s: END, rc=%d\n", __func__, rc);
	return rc;
}
int mm_app_tc_start_stop_preview(mm_camera_app_t *cam_app)
{
    int rc = MM_CAMERA_OK;
    int i, j;
    mm_camera_test_obj_t test_obj;

    printf("\n Verifying start/stop preview...\n");
    for (i = 0; i < cam_app->num_cameras; i++) {
        memset(&test_obj, 0, sizeof(mm_camera_test_obj_t));
        rc = mm_app_open(cam_app, i, &test_obj);
        if (rc != MM_CAMERA_OK) {
            CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n",
                       __func__, i, rc);
            break;
        }

        for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) {
            rc = mm_app_start_preview(&test_obj);
            if (rc != MM_CAMERA_OK) {
                CDBG_ERROR("%s: mm_app_start_preview() cam_idx=%d, err=%d\n",
                           __func__, i, rc);
                break;
            }
            sleep(1);
            rc = mm_app_stop_preview(&test_obj);
            if (rc != MM_CAMERA_OK) {
                CDBG_ERROR("%s: mm_app_stop_preview() cam_idx=%d, err=%d\n",
                           __func__, i, rc);
                break;
            }
        }

        rc |= mm_app_close(&test_obj);
        if (rc != MM_CAMERA_OK) {
            CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n",
                       __func__, i, rc);
            break;
        }
    }
    if (rc == MM_CAMERA_OK) {
        printf("\nPassed\n");
    } else {
        printf("\nFailed\n");
    }
    CDBG("%s:END, rc = %d\n", __func__, rc);
    return rc;
}
Exemplo n.º 8
0
int mm_app_start_snapshot(int cam_id)
{
    int rc = MM_CAMERA_OK;
    int stream[2];
    int op_mode = 0;

    mm_camera_bundle_attr_t attr;


    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    if (MM_CAMERA_OK != mm_app_stop_preview(cam_id)) {
        CDBG_ERROR("%s: Stop preview Failed cam_id=%d\n",__func__,cam_id);
        return -1;
    }

    op_mode = MM_CAMERA_OP_MODE_CAPTURE;
    mm_app_set_snapshot_mode(cam_id,op_mode);

    pme->cam->ops->prepare_snapshot(pme->cam->camera_handle,pme->ch_id,0);

    if (MM_CAMERA_OK != (rc = mm_app_add_snapshot_stream(cam_id))) {
        CDBG_ERROR("%s : Add Snapshot stream err",__func__);
    }

    if (MM_CAMERA_OK != (rc = mm_app_config_snapshot_format(cam_id))) {
        CDBG_ERROR("%s : Config Snapshot stream err",__func__);
    }

    if (MM_CAMERA_OK != (rc = mm_app_streamon_snapshot(cam_id))) {
        CDBG_ERROR("%s : Stream on Snapshot stream err",__func__);
    }

#if 0
    /*start OMX Jpeg encoder*/
#ifndef DISABLE_JPEG_ENCODING
    my_cam_app.hal_lib.omxJpegOpen();
#endif

#endif
end:
    CDBG("%s: END, rc=%d\n", __func__, rc);

    return rc;
}
Exemplo n.º 9
0
int mm_app_start_raw(int cam_id)
{
    int rc = MM_CAMERA_OK;
    int op_mode = 0;

    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    if (MM_CAMERA_OK != mm_app_stop_preview(cam_id)) {
        CDBG_ERROR("%s: Stop preview Failed cam_id=%d\n",__func__,cam_id);
        return -1;
    }
    op_mode = MM_CAMERA_OP_MODE_RAW;
    pme->cam->ops->set_parm(pme->cam->camera_handle,MM_CAMERA_PARM_OP_MODE, &op_mode);
    usleep(20*1000);

    pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id = pme->cam->ops->add_stream(pme->cam->camera_handle,pme->ch_id,
            NULL,pme,
            MM_CAMERA_SNAPSHOT_MAIN, 0);

    CDBG("Add RAW main is successfull stream ID = %d",pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id);
    if (!pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id) {
        CDBG_ERROR("%s:Raw main streaming err=%d\n", __func__, rc);
        rc = -1;
        return rc;
    }

    if (MM_CAMERA_OK != (rc = mm_app_config_raw_format(cam_id))) {
        CDBG_ERROR("%s : Config Raw Snapshot stream err",__func__);
        return rc;
    }

    if (MM_CAMERA_OK != (rc = mm_app_streamon_raw(cam_id))) {
        CDBG_ERROR("%s : Stream on Raw Snapshot stream err",__func__);
        return rc;
    }

    CDBG("%s: END, rc=%d\n", __func__, rc);
    return rc;
}
Exemplo n.º 10
0
int mm_app_take_picture(mm_camera_test_obj_t *test_obj, uint8_t is_burst_mode)
{
    LOGH("\nEnter %s!!\n");
    int rc = MM_CAMERA_OK;
    uint8_t num_snapshot = 1;
    int num_rcvd_snapshot = 0;

    if (is_burst_mode)
       num_snapshot = 6;

    //stop preview before starting capture.
    rc = mm_app_stop_preview(test_obj);
    if (rc != MM_CAMERA_OK) {
        LOGE(" stop preview failed before capture!!, err=%d\n", rc);
        return rc;
    }

    rc = mm_app_start_capture(test_obj, num_snapshot);
    if (rc != MM_CAMERA_OK) {
        LOGE(" mm_app_start_capture(), err=%d\n", rc);
        return rc;
    }
    while (num_rcvd_snapshot < num_snapshot) {
        LOGH("\nWaiting mm_camera_app_wait !!\n");
        mm_camera_app_wait();
        num_rcvd_snapshot++;
    }
    rc = mm_app_stop_capture(test_obj);
    if (rc != MM_CAMERA_OK) {
       LOGE(" mm_app_stop_capture(), err=%d\n", rc);
       return rc;
    }
    //start preview after capture.
    rc = mm_app_start_preview(test_obj);
    if (rc != MM_CAMERA_OK) {
        LOGE(" start preview failed after capture!!, err=%d\n",rc);
    }
    return rc;
}