int startRdi(int cam_id)
{
    int rc = MM_CAMERA_OK;

    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    CDBG("%s: Start Preview",__func__);

    if (pme->cam_mode == ZSL_MODE || pme->cam_mode == RECORDER_MODE || pme->cam_mode == CAMERA_MODE) {
        switch (pme->cam_state) {
        case CAMERA_STATE_RECORD:
            if (MM_CAMERA_OK != mm_app_stop_video(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_open_rdi(cam_id)) {
                CDBG_ERROR("%s: Cannot switch to camera mode=%d\n", __func__);
                return -1;
            }
        case CAMERA_STATE_SNAPSHOT:
        default:
            break;
        }
    }
    mm_app_start_rdi(cam_id);
    return rc;
}
int stopRecording(int cam_id)
{

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

	if(pme->cam_mode != RECORDER_MODE || pme->cam_state != CAMERA_STATE_RECORD) {
		return rc;
	}
	if(MM_CAMERA_OK != mm_app_stop_video(cam_id)){
		CDBG_ERROR("%s:stop video err=%d\n", __func__, rc);
		return -1;
	}
	return rc;
}
int mm_app_take_raw(int cam_id)
{
    int rc = 0;

    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    CDBG("%s:BEGIN, cam_id=%d\n",__func__,cam_id);

    if (pme->cam_mode == RECORDER_MODE) {
        switch (pme->cam_state) {
        case CAMERA_STATE_RECORD:
            if (MM_CAMERA_OK != mm_app_stop_video(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_open_camera(cam_id)) {
                CDBG_ERROR("%s: Cannot switch to camera mode=%d\n", __func__,rc);
                return -1;
            }
            break;
        case CAMERA_STATE_SNAPSHOT:
        default:
            CDBG("%s: Cannot normal pciture in record mode\n", __func__);
            break;
        }
    } else if (pme->cam_mode == ZSL_MODE) {
        switch (pme->cam_state) {
        case CAMERA_STATE_PREVIEW:
            mm_app_open_camera(cam_id);
            break;

        case CAMERA_STATE_SNAPSHOT:
        case CAMERA_STATE_RECORD:
        default:
            CDBG("%s: Cannot normal pciture in record mode\n", __func__);
            break;
        }
    }

    CDBG("%s : Takepicture RAW: mode = %d state = %d, rc = %d",__func__,pme->cam_mode,pme->cam_state,rc);
    if (pme->cam_mode == CAMERA_MODE && pme->cam_state == CAMERA_STATE_PREVIEW) {
        mm_app_take_picture_raw(cam_id);
    }
    return rc;
}