#include <Ecore.h>
#include <Elementary.h>
#include <appcore-efl.h>
+#include <tbm_surface.h>
/*-----------------------------------------------------------------------
| GLOBAL VARIABLE DEFINITIONS: |
static int g_camera_device_state_changed_cb_id;
static int g_camera_device_list_changed_cb_id;
static int g_camera_preview_cb_file_write;
+static int g_camera_mp_preview_cb_file_write;
static struct timeval previous_time;
static struct timeval current_time;
-----------------------------------------------------------------------*/
#define DEFAULT_FILE_PATH "/home/owner/media"
#define PREVIEW_CB_DUMP_FILE_NAME "preview.data"
+#define MP_PREVIEW_CB_DUMP_FILE_NAME "mp_preview.data"
#define MAX_FILE_NAME_LENGTH 256
#define MAX_FILE_PATH_LENGTH (MAX_FILE_NAME_LENGTH - 20)
void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
{
- if (g_camera_preview_cb_file_write) {
- char preview_dump[MAX_FILE_NAME_LENGTH] = {'\0',};
- FILE *fp = NULL;
-
- snprintf(preview_dump, MAX_FILE_NAME_LENGTH, "%s/%s", DEFAULT_FILE_PATH, PREVIEW_CB_DUMP_FILE_NAME);
-
- fp = fopen(preview_dump, "a");
- if (fp == NULL) {
- g_print("\n==== file[%s] open failed ====\n", preview_dump);
- return;
- }
-
- if (frame->format == CAMERA_PIXEL_FORMAT_RGBA ||
- frame->format == CAMERA_PIXEL_FORMAT_ARGB) {
- fwrite(frame->data.rgb_plane.data, 1, frame->data.rgb_plane.size, fp);
- } else if (frame->format == CAMERA_PIXEL_FORMAT_INVZ) {
- fwrite(frame->data.depth_plane.data, 1, frame->data.depth_plane.size, fp);
- } else if (frame->format == CAMERA_PIXEL_FORMAT_MJPEG) {
- fwrite(frame->data.encoded_plane.data, 1, frame->data.encoded_plane.size, fp);
- } else {
- switch (frame->num_of_planes) {
- case 1:
- fwrite(frame->data.single_plane.yuv, 1, frame->data.single_plane.size, fp);
- break;
- case 2:
- fwrite(frame->data.double_plane.y, 1, frame->data.double_plane.y_size, fp);
- fwrite(frame->data.double_plane.uv, 1, frame->data.double_plane.uv_size, fp);
- break;
- case 3:
- fwrite(frame->data.triple_plane.y, 1, frame->data.triple_plane.y_size, fp);
- fwrite(frame->data.triple_plane.u, 1, frame->data.triple_plane.u_size, fp);
- fwrite(frame->data.triple_plane.v, 1, frame->data.triple_plane.v_size, fp);
- break;
- default:
- break;
- }
- }
-
- g_print("==== file[%s] write done ====\n", preview_dump);
-
- fclose(fp);
+ char preview_dump[MAX_FILE_NAME_LENGTH] = {'\0',};
+ FILE *fp = NULL;
+ if (!frame) {
+ g_print("\n[PREVIEW_CB] NULL frame!\n");
return;
}
- g_print("----- preview callback - format %d, %dx%d, num plane %d\n",
+ g_print("[PREVIEW_CB] preview callback - format[%d] res[%dx%d] num plane[%d] ",
frame->format, frame->width, frame->height, frame->num_of_planes);
+
if (frame->num_of_planes == 1) {
- g_print("----- length YUV %d\n",
+ g_print("size YUV[%d]\n",
frame->data.single_plane.size);
} else if (frame->num_of_planes == 2) {
- g_print("----- length Y %d, UV %d\n",
+ g_print("size Y[%d] UV[%d]\n",
frame->data.double_plane.y_size,
frame->data.double_plane.uv_size);
} else if (frame->num_of_planes == 3) {
- g_print("----- length Y %d, U %d, V %d\n",
+ g_print("size Y[%d] U[%d] V[%d]\n",
frame->data.triple_plane.y_size,
frame->data.triple_plane.u_size,
frame->data.triple_plane.v_size);
+ }
+
+ if (!g_camera_preview_cb_file_write)
+ return;
+
+ snprintf(preview_dump, MAX_FILE_NAME_LENGTH, "%s/%s", DEFAULT_FILE_PATH, PREVIEW_CB_DUMP_FILE_NAME);
+
+ fp = fopen(preview_dump, "a");
+ if (fp == NULL) {
+ g_print("\n[PREVIEW_CB] file[%s] open failed\n", preview_dump);
+ return;
+ }
+
+ if (frame->format == CAMERA_PIXEL_FORMAT_RGBA ||
+ frame->format == CAMERA_PIXEL_FORMAT_ARGB) {
+ fwrite(frame->data.rgb_plane.data, 1, frame->data.rgb_plane.size, fp);
+ } else if (frame->format == CAMERA_PIXEL_FORMAT_INVZ) {
+ fwrite(frame->data.depth_plane.data, 1, frame->data.depth_plane.size, fp);
+ } else if (frame->format == CAMERA_PIXEL_FORMAT_MJPEG) {
+ fwrite(frame->data.encoded_plane.data, 1, frame->data.encoded_plane.size, fp);
} else {
- g_print("invalid num of planes %d\n", frame->num_of_planes);
+ switch (frame->num_of_planes) {
+ case 1:
+ fwrite(frame->data.single_plane.yuv, 1, frame->data.single_plane.size, fp);
+ break;
+ case 2:
+ fwrite(frame->data.double_plane.y, 1, frame->data.double_plane.y_size, fp);
+ fwrite(frame->data.double_plane.uv, 1, frame->data.double_plane.uv_size, fp);
+ break;
+ case 3:
+ fwrite(frame->data.triple_plane.y, 1, frame->data.triple_plane.y_size, fp);
+ fwrite(frame->data.triple_plane.u, 1, frame->data.triple_plane.u_size, fp);
+ fwrite(frame->data.triple_plane.v, 1, frame->data.triple_plane.v_size, fp);
+ break;
+ default:
+ break;
+ }
}
+
+ g_print("[PREVIEW_CB] file[%s] write done\n", preview_dump);
+
+ fclose(fp);
}
int ret = 0;
int width = 0;
int height = 0;
+ unsigned int i = 0;
+ char mp_preview_dump[MAX_FILE_NAME_LENGTH] = {'\0',};
+ FILE *fp = NULL;
media_format_h fmt = NULL;
media_format_mimetype_e type = MEDIA_FORMAT_I420;
+ tbm_surface_h surface = NULL;
+ tbm_surface_info_s s_info;
+
+ if (!pkt) {
+ g_print("\n[MP_PREVIEW_CB] NULL packet!\n");
+ return;
+ }
ret = media_packet_get_format(pkt, &fmt);
if (ret != MEDIA_PACKET_ERROR_NONE) {
- g_print("get media format failed[0x%x]", ret);
+ g_print("\n[MP_PREVIEW_CB] get media format failed[0x%x]", ret);
goto _MEDIA_PACKET_PREVIEW_CB_OUT;
}
ret = media_format_get_video_info(fmt, &type, &width, &height, NULL, NULL);
if (ret != MEDIA_FORMAT_ERROR_NONE) {
- g_print("get video info failed[0x%x]", ret);
+ g_print("\n[MP_PREVIEW_CB] get video info failed[0x%x]", ret);
+ goto _MEDIA_PACKET_PREVIEW_CB_OUT;
+ }
+
+ g_print("[MP_PREVIEW_CB] media_packet_preview_cb[mimetype:0x%x, %dx%d]\n", type, width, height);
+
+ ret = media_packet_get_tbm_surface(pkt, &surface);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ g_print("\n[MP_PREVIEW_CB] get tbm surface failed[0x%x] ====\n", ret);
+ goto _MEDIA_PACKET_PREVIEW_CB_OUT;
+ }
+
+ ret = tbm_surface_get_info(surface, &s_info);
+ if (ret != TBM_SURFACE_ERROR_NONE) {
+ g_print("\n[MP_PREVIEW_CB] get tbm surface info failed[0x%x] ====\n", ret);
goto _MEDIA_PACKET_PREVIEW_CB_OUT;
}
- g_print("==== media_packet_preview_cb[mimetype:0x%x, %dx%d]\n", type, width, height);
+ g_print(" tbm surface [%dx%d], total size[%u]\n",
+ s_info.width, s_info.height, s_info.size);
+
+ if (g_camera_mp_preview_cb_file_write) {
+ snprintf(mp_preview_dump, MAX_FILE_NAME_LENGTH, "%s/%s", DEFAULT_FILE_PATH, MP_PREVIEW_CB_DUMP_FILE_NAME);
+
+ fp = fopen(mp_preview_dump, "a");
+ if (fp == NULL) {
+ g_print("\n[MP_PREVIEW_CB] file[%s] open failed ====\n", mp_preview_dump);
+ goto _MEDIA_PACKET_PREVIEW_CB_OUT;
+ }
+ }
+
+ for (i = 0 ; i < s_info.num_planes ; i++) {
+ g_print(" plane[%d][%p] stride[%u] size[%u]\n",
+ i, s_info.planes[i].ptr, s_info.planes[i].stride, s_info.planes[i].size);
+ if (fp)
+ fwrite(s_info.planes[i].ptr, 1, s_info.planes[i].size, fp);
+ }
_MEDIA_PACKET_PREVIEW_CB_OUT:
+ if (fp)
+ fclose(fp);
+
media_packet_unref(pkt);
}
camera_unset_preview_cb(hcamcorder->camera);
break;
case '7':
+ g_print("\n\tWrite preview data to file(0:NO, Others:YES) : ");
+ err = scanf("%d", &g_camera_mp_preview_cb_file_write);
+ flush_stdin();
camera_set_media_packet_preview_cb(hcamcorder->camera, _camera_media_packet_preview_cb, hcamcorder->camera);
break;
case '8':