"FRONT",
};
+enum {
+ PREVIEW_CB_TYPE_NORMAL = 0,
+ PREVIEW_CB_TYPE_MEDIA_PACKET,
+ PREVIEW_CB_TYPE_EXTRA
+};
+
+typedef void (*preview_cb)(void);
+typedef int (*set_preview_cb)(camera_h, void *, void *);
+
/*---------------------------------------------------------------------------
| LOCAL FUNCTION PROTOTYPES: |
media_packet_unref(pkt);
}
+
+static int __set_preview_cb_common(int *preview_cb_dump, set_preview_cb set_cb, preview_cb callback)
+{
+ g_print("\n\tDump preview data to file - NO[0], YES[Others] : ");
+
+ if (scanf("%d", preview_cb_dump) <= 0)
+ g_print("\n\tscanf for preview_cb_dump failed[errno:%d]\n", errno);
+
+ flush_stdin();
+
+ return set_cb(hcamcorder->camera, callback, hcamcorder->camera);
+}
+
+
+static int _camera_set_preview_cb(int type)
+{
+ int set_cb = 0;
+
+ g_print("* Preview Callback[type:%d,0:NORMAL,1:MEDIAPACKET,2:EXTRA]\n", type);
+
+ g_print("\tUnset[0] / Set[Others] :");
+
+ if (scanf("%d", &set_cb) <= 0)
+ g_print("\n\tscanf failed[errno:%d]\n", errno);
+
+ flush_stdin();
+
+ switch (type) {
+ case PREVIEW_CB_TYPE_NORMAL:
+ if (set_cb == 0)
+ return camera_unset_preview_cb(hcamcorder->camera);
+ else
+ return __set_preview_cb_common(&g_camera_preview_cb_dump,
+ (set_preview_cb)camera_set_preview_cb,
+ (preview_cb)_camera_preview_cb);
+ case PREVIEW_CB_TYPE_MEDIA_PACKET:
+ if (set_cb == 0)
+ return camera_unset_media_packet_preview_cb(hcamcorder->camera);
+ else
+ return __set_preview_cb_common(&g_camera_mp_preview_cb_dump,
+ (set_preview_cb)camera_set_media_packet_preview_cb,
+ (preview_cb)_camera_media_packet_preview_cb);
+ case PREVIEW_CB_TYPE_EXTRA:
+ if (set_cb == 0)
+ return camera_unset_extra_preview_cb(hcamcorder->camera);
+ else
+ return __set_preview_cb_common(&g_camera_extra_preview_cb_dump,
+ (set_preview_cb)camera_set_extra_preview_cb,
+ (preview_cb)_camera_extra_preview_cb);
+ default:
+ g_print("\n\tUnknown type[%d]\n", type);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+}
+
+
static bool _resolution_cb(int width, int height, void *user_data)
{
resolution_stack *data = (resolution_stack *)user_data;
int err = 0;
int interval = 0;
int count = 0;
- int set_cb = 0;
switch (buf) {
case '1': /* Capture */
camera_start_preview(hcamcorder->camera);
break;
case '5':
- g_print("* Preview Callback\n");
- g_print("\tUnset[0] / Set[Others] :");
- err = scanf("%d", &set_cb);
- flush_stdin();
- if (set_cb) {
- g_print("\n\tDump preview data to file - NO[0], YES[Others] : ");
- err = scanf("%d", &g_camera_preview_cb_dump);
- flush_stdin();
- err = camera_set_preview_cb(hcamcorder->camera, _camera_preview_cb, hcamcorder->camera);
- } else {
- err = camera_unset_preview_cb(hcamcorder->camera);
- }
+ err = _camera_set_preview_cb(PREVIEW_CB_TYPE_NORMAL);
g_print("\tresult[0x%x]\n\n", err);
break;
case '6':
- g_print("* Extra Preview Callback\n");
- g_print("\tUnset[0] / Set[Others] :");
- err = scanf("%d", &set_cb);
- flush_stdin();
- if (set_cb) {
- g_print("\n\tDump extra preview data to file - NO[0], YES[Others] : ");
- err = scanf("%d", &g_camera_extra_preview_cb_dump);
- flush_stdin();
- err = camera_set_extra_preview_cb(hcamcorder->camera, _camera_extra_preview_cb, hcamcorder->camera);
- } else {
- err = camera_unset_extra_preview_cb(hcamcorder->camera);
- }
+ err = _camera_set_preview_cb(PREVIEW_CB_TYPE_EXTRA);
g_print("\tresult[0x%x]\n\n", err);
break;
case '7':
- g_print("* Media Packet Preview Callback\n");
- g_print("\tUnset[0] / Set[Others] :");
- err = scanf("%d", &set_cb);
- flush_stdin();
- if (set_cb) {
- g_print("\n\tDump media packet preview data to file - NO[0], YES[Others] : ");
- err = scanf("%d", &g_camera_mp_preview_cb_dump);
- flush_stdin();
- err = camera_set_media_packet_preview_cb(hcamcorder->camera, _camera_media_packet_preview_cb, hcamcorder->camera);
- } else {
- err = camera_unset_media_packet_preview_cb(hcamcorder->camera);
- }
+ err = _camera_set_preview_cb(PREVIEW_CB_TYPE_MEDIA_PACKET);
g_print("\tresult[0x%x]\n\n", err);
break;
case 'b': /* back */
/*camera_set_display_flip(hcamcorder->camera, CAMERA_FLIP_VERTICAL);*/
/*camera_set_preview_cb(hcamcorder->camera, _preview_cb, hcamcorder->camera);*/
+ if (_camera_set_preview_cb(PREVIEW_CB_TYPE_NORMAL) != CAMERA_ERROR_NONE)
+ g_print("\n\tpreview cb failed\n");
+
if (camera_is_supported_extra_preview(hcamcorder->camera)) {
g_print("\n\tEnable extra preview callback - NO[0], YES[Others] : ");
err = scanf("%d", (int *)&enable_extra_preview);