static void mm_app_snapshot_notify_cb(mm_camera_super_buf_t *bufs, void *user_data) { #if 0 mm_camera_app_obj_t *pme = user_data; int rc; CDBG("%s: BEGIN\n", __func__); snapshot_cnt++; mm_app_dump_snapshot_frame(bufs->snapshot.main.frame, pme->snapshot_buf.frame_len, TRUE, 0); mm_app_dump_snapshot_frame(bufs->snapshot.thumbnail.frame, pme->thumbnail_buf.frame_len, FALSE, 0); #ifndef DISABLE_JPEG_ENCODING /* The recvd_frame structre we receive from lower library is a local variable. So we'll need to save this structure so that we won't be later pointing to garbage data when that variable goes out of scope */ mm_camera_ch_data_buf_t* frame = (mm_camera_ch_data_buf_t *)malloc(sizeof(mm_camera_ch_data_buf_t)); if (frame == NULL) { CDBG_ERROR("%s: Error allocating memory to save received_frame structure.", __func__); goto error1; } memcpy(frame, bufs, sizeof(mm_camera_ch_data_buf_t)); rc = encodeDisplayAndSave(frame, 0, pme); if (!rc) { CDBG_ERROR("%s: Error encoding buffer.", __func__); goto error; } #endif //DISABLE_JPEG_ENCODING /* return buffer back for taking next snapshot */ pme->cam->evt->buf_done(pme->cam, bufs); mm_app_snapshot_done(); /* CDBG("%s: calling mm_app_snapshot_done()\n", __func__); mm_app_snapshot_done(); */ CDBG("%s: END\n", __func__); return; error: /*if (frame != NULL) free(frame);*/ error1: pme->cam->evt->buf_done(pme->cam, bufs); mm_app_snapshot_done(); #endif return; }
static void mm_app_raw_snapshot_notify_cb(mm_camera_super_buf_t *bufs, void *user_data) { #if 0 mm_camera_app_obj_t *pme = user_data; static int loop = 0; CDBG("%s: BEGIN\n", __func__); raw_snapshot_cnt++; mm_app_dump_snapshot_frame(bufs->def.frame, pme->raw_snapshot_buf.frame_len, TRUE, 1); /* return buffer back for taking next snapshot */ pme->cam->evt->buf_done(pme->cam, bufs); CDBG("%s: calling mm_app_snapshot_done()\n", __func__); mm_app_snapshot_done(); CDBG("%s: END\n", __func__); #endif }
/* This callback is received once the complete JPEG encoding is done */ static void jpeg_encode_cb(jpeg_job_status_t status, uint8_t thumbnailDroppedFlag, uint32_t client_hdl, uint32_t jobId, uint8_t* out_data, uint32_t data_size, void *userData) { int rc; int i = 0; mm_camera_buf_def_t *main_frame = NULL; mm_camera_buf_def_t *thumb_frame = NULL; mm_camera_app_obj_t *pme = NULL; CDBG("%s: BEGIN\n", __func__); pme = (mm_camera_app_obj_t *)userData; if (jobId != pme->current_job_id || !pme->current_job_frames) { CDBG_ERROR("%s: NULL current job frames or not matching job ID (%d, %d)", __func__, jobId, pme->current_job_id); return; } /* dump jpeg img */ CDBG_ERROR("%s: job %d, status=%d, thumbnail_dropped=%d", __func__, jobId, status, thumbnailDroppedFlag); if (status == JPEG_JOB_STATUS_DONE) { mm_app_dump_jpeg_frame(out_data, data_size, "jpeg_dump", "jpg", pme->my_id); } /* buf done current encoding frames */ pme->current_job_id = 0; for (i=0; i<pme->current_job_frames->num_bufs; i++) { if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->current_job_frames->camera_handle, pme->current_job_frames->ch_id, pme->current_job_frames->bufs[i])) { CDBG_ERROR("%s: Failed in Qbuf\n", __func__); } } free(pme->current_job_frames); pme->current_job_frames = NULL; /* signal snapshot is done */ mm_app_snapshot_done(); }
/* This callback is received once the complete JPEG encoding is done */ static void snapshot_raw_cb(mm_camera_super_buf_t *bufs, void *user_data) { int rc; int i = 0; mm_camera_buf_def_t *main_frame = NULL; mm_camera_buf_def_t *thumb_frame = NULL; mm_camera_app_obj_t *pme = NULL; CDBG("%s: BEGIN\n", __func__); pme = (mm_camera_app_obj_t *)user_data; CDBG("%s : total streams = %d",__func__,bufs->num_bufs); main_frame = bufs->bufs[0]; thumb_frame = bufs->bufs[1]; CDBG("mainframe frame_idx = %d fd = %d frame length = %d",main_frame->frame_idx,main_frame->fd,main_frame->frame_len); CDBG("thumnail frame_idx = %d fd = %d frame length = %d",thumb_frame->frame_idx,thumb_frame->fd,thumb_frame->frame_len); //dumpFrameToFile(main_frame->frame,pme->dim.picture_width,pme->dim.picture_height,"main", 1); //dumpFrameToFile(thumb_frame->frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"thumb", 1); dumpFrameToFile(main_frame,pme->dim.picture_width,pme->dim.picture_height,"main", 1); dumpFrameToFile(thumb_frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"thumb", 1); if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,main_frame)) { CDBG_ERROR("%s: Failed in thumbnail Qbuf\n", __func__); } if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,thumb_frame)) { CDBG_ERROR("%s: Failed in thumbnail Qbuf\n", __func__); } mm_app_snapshot_done(); CDBG("%s: END\n", __func__); }
static void snapshot_raw_cb(mm_camera_super_buf_t *recvd_frame, void *user_data) { int rc; int i = 0; mm_camera_buf_def_t *main_frame = NULL; mm_camera_app_obj_t *pme = NULL; CDBG("%s: BEGIN\n", __func__); pme = (mm_camera_app_obj_t *)user_data; if (pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id == recvd_frame->bufs[i]->stream_id) { main_frame = recvd_frame->bufs[i]; CDBG("mainframe frame_idx = %d fd = %d frame length = %d",main_frame->frame_idx,main_frame->fd,main_frame->frame_len); dumpFrameToFile(main_frame,pme->dim.raw_picture_width,pme->dim.raw_picture_height,"raw_main", 1,"raw"); } if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id, main_frame)) { CDBG_ERROR("%s: Failed in Qbuf\n", __func__); } mm_app_snapshot_done(); }
static void snapshot_yuv_cb(mm_camera_super_buf_t *bufs, void *user_data) { int rc; int i = 0; mm_camera_buf_def_t *main_frame = NULL; mm_camera_buf_def_t *thumb_frame = NULL; mm_camera_app_obj_t *pme = NULL; char* cmd = "This is a private cmd from test app"; CDBG("%s: BEGIN\n", __func__); pme = (mm_camera_app_obj_t *)user_data; CDBG("%s: send private ioctl here", __func__); pme->cam->ops->send_command(bufs->camera_handle, MM_CAMERA_CMD_TYPE_PRIVATE, 0, strlen(cmd) + 1, (void *)cmd); /* start jpeg encoding job */ rc = encodeData(pme, bufs); /* buf done rcvd frames in error case */ if ( 0 != rc ) { for (i=0; i<bufs->num_bufs; i++) { if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, bufs->ch_id, bufs->bufs[i])) { CDBG_ERROR("%s: Failed in Qbuf\n", __func__); } mm_stream_invalid_cache(pme,bufs->bufs[i]); } } #ifdef TEST_ABORT_JPEG_ENCODE else { if (aborted_flag) { aborted_flag = 0; /* abort the job */ CDBG("%s: abort jpeg encode job here", __func__); rc = pme->jpeg_ops.abort_job(pme->jpeg_hdl, pme->current_job_id); if (NULL != pme->current_job_frames) { free(pme->current_job_frames); pme->current_job_frames = NULL; } CDBG("%s: abort jpeg encode job returns %d", __func__, rc); for (i=0; i<bufs->num_bufs; i++) { if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, bufs->ch_id, bufs->bufs[i])) { CDBG_ERROR("%s: Failed in Qbuf\n", __func__); } mm_stream_invalid_cache(pme,bufs->bufs[i]); } /* signal snapshot is done */ mm_app_snapshot_done(); } } #endif CDBG("%s: END\n", __func__); }