/*=======================================================================================
| INCLUDE FILES |
=======================================================================================*/
+#include <stdlib.h>
#include <sys/time.h>
#include <sys/times.h>
-#include <gst/interfaces/cameracontrol.h>
-#include <mm_sound.h>
#include "mm_camcorder_internal.h"
#include "mm_camcorder_stillshot.h"
#include "mm_camcorder_exifinfo.h"
#include "mm_camcorder_exifdef.h"
+#include <libexif/exif-loader.h>
+#include <libexif/exif-utils.h>
+#include <libexif/exif-data.h>
/*---------------------------------------------------------------------------------------
| GLOBAL VARIABLE DEFINITIONS for internal |
---------------------------------------------------------------------------------------*/
-#define EXIF_SET_ERR( return_type,tag_id) \
- _mmcam_dbg_err("error=%x,tag=%x",return_type,tag_id); \
- if (return_type == MM_ERROR_CAMCORDER_LOW_MEMORY) { \
+#define EXIF_SET_ERR(return_type, tag_id) \
+do { \
+ MMCAM_LOG_ERROR("error=%x,tag=%x", return_type, tag_id); \
+ if (return_type == (int)MM_ERROR_CAMCORDER_LOW_MEMORY) { \
goto exit; \
- }
+ } \
+} while (0)
/*---------------------------------------------------------------------------------------
| LOCAL VARIABLE DEFINITIONS for internal |
---------------------------------------------------------------------------------------*/
#define THUMBNAIL_WIDTH 320
#define THUMBNAIL_HEIGHT 240
-#define THUMBNAIL_DEFAULT_RATIO 1.34
-#define THUMBNAIL_JPEG_QUALITY 50
+#define THUMBNAIL_JPEG_QUALITY 90
#define TRY_LOCK_MAX_COUNT 100
-#define TRY_LOCK_TIME 50000 /* ms */
+#define TRY_LOCK_TIME 20000 /* ms */
+#define _MMCAMCORDER_MAKE_THUMBNAIL_INTERNAL_ENCODE
/*---------------------------------------------------------------------------------------
int _mmcamcorder_image_cmd_capture(MMHandleType handle);
int _mmcamcorder_image_cmd_preview_start(MMHandleType handle);
int _mmcamcorder_image_cmd_preview_stop(MMHandleType handle);
-static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffer1, GstBuffer *buffer2, GstBuffer *buffer3, gpointer u_data);
-
-/* Function for JPEG capture with Encode bin */
-static gboolean __mmcamcorder_encodesink_handoff_callback(GstElement *fakesink, GstBuffer *buffer, GstPad *pad, gpointer u_data);
+static void __mmcamcorder_image_capture_cb(GstElement *element, GstSample *sample1, GstSample *sample2, GstSample *sample3, gpointer u_data);
+static void __mmcamcorder_extra_preview_stream_cb(GstElement *element, int stream_id, GstSample *sample, gpointer u_data);
/* sound status changed callback */
static void __sound_status_changed_cb(keynode_t* node, void *data);
-static void __volume_level_changed_cb(void* user_data);
/*=======================================================================================
| FUNCTION DEFINITIONS |
---------------------------------------------------------------------------------------*/
-int _mmcamcorder_add_stillshot_pipeline(MMHandleType handle)
+int _mmcamcorder_create_stillshot_pipeline(MMHandleType handle)
{
int err = MM_ERROR_UNKNOWN;
-
GstPad *srcpad = NULL;
GstPad *sinkpad = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- _MMCamcorderImageInfo *info = NULL;
-
+
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc && sc->info_image && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- info = sc->info_image;
-
- _mmcam_dbg_log("");
-
- /* Check main pipeline */
- if (!sc->element[_MMCAMCORDER_MAIN_PIPE].gst) {
- _mmcam_dbg_err( "Main Pipeline is not existed." );
- return MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- }
+ MMCAM_LOG_INFO("");
/* Create gstreamer element */
- _mmcam_dbg_log("Using Encodebin for capturing");
+ MMCAM_LOG_INFO("Using Encodebin for capturing");
+
+ /* Create capture pipeline */
+ _MMCAMCORDER_PIPELINE_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCODE_MAIN_PIPE, "capture_pipeline", err);
- __ta__(" _mmcamcorder_create_encodesink_bin",
err = _mmcamcorder_create_encodesink_bin((MMHandleType)hcamcorder, MM_CAMCORDER_ENCBIN_PROFILE_IMAGE);
- );
- if (err != MM_ERROR_NONE) {
+ if (err != MM_ERROR_NONE)
return err;
- }
- gst_bin_add_many(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
- sc->element[_MMCAMCORDER_ENCSINK_BIN].gst,
- NULL);
+ /* add element and encodesink bin to encode main pipeline */
+ gst_bin_add_many(GST_BIN(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst),
+ sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst,
+ sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst,
+ sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst,
+ NULL);
+
+ /* Link each element : appsrc - capsfilter - encodesink bin */
+ srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, "src");
+ sinkpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst, "sink");
+ _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, pipeline_creation_error);
- /* Link each element */
- srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst, "src1");
- sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, "image_sink0");
- _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, element_link_error)
+ srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst, "src");
+ sinkpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, "image_sink0");
+ _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, pipeline_creation_error);
- MMCAMCORDER_SIGNAL_CONNECT(sc->element[_MMCAMCORDER_ENCSINK_SINK].gst,
- _MMCAMCORDER_HANDLER_STILLSHOT, "handoff",
- G_CALLBACK(__mmcamcorder_encodesink_handoff_callback),
- hcamcorder);
+ /* connect handoff signal to get capture data */
+ MMCAMCORDER_SIGNAL_CONNECT(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst,
+ _MMCAMCORDER_HANDLER_STILLSHOT, "handoff",
+ G_CALLBACK(__mmcamcorder_handoff_callback),
+ hcamcorder);
return MM_ERROR_NONE;
-element_link_error:
- _mmcam_dbg_err("Link encodebin failed!");
+pipeline_creation_error:
+ _mmcamcorder_remove_stillshot_pipeline(handle);
+ return err;
+}
+
+
+int _mmcamcorder_connect_capture_signal(MMHandleType handle)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderSubContext *sc = NULL;
- if (sc->element[_MMCAMCORDER_ENCSINK_BIN].gst != NULL) {
- int ret = MM_ERROR_NONE;
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- __ta__( " EncodeBin Set NULL",
- ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, GST_STATE_NULL);
- );
- _mmcam_dbg_log("encodebin _mmcamcorder_gst_set_state NULL ret[%d]", ret);
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- gst_bin_remove(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
- sc->element[_MMCAMCORDER_ENCSINK_BIN].gst);
+ mmf_return_val_if_fail(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcamcorder_remove_element_handle(handle, _MMCAMCORDER_ENCSINK_BIN, _MMCAMCORDER_ENCSINK_SINK);
+ MMCAM_LOG_INFO("connect capture signal to _MMCAMCORDER_VIDEOSRC_SRC");
- _mmcam_dbg_log("Encodebin removed");
- }
+ MMCAMCORDER_SIGNAL_CONNECT(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst,
+ _MMCAMCORDER_HANDLER_STILLSHOT, "still-capture",
+ G_CALLBACK(__mmcamcorder_image_capture_cb),
+ hcamcorder);
- return MM_ERROR_CAMCORDER_GST_LINK;
+ return MM_ERROR_NONE;
}
-int _mmcamcorder_connect_capture_signal(MMHandleType handle)
+int _mmcamcorder_initialize_extra_preview_stream(MMHandleType handle)
{
+ int i = 0;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
+ GstCameraControl *control = NULL;
+ _MMCamcorderExtraPreviewStreamFormat *e_fmt = NULL;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- /*set video source element*/
- if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "signal-still-capture", TRUE);
+ mmf_return_val_if_fail(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- MMCAMCORDER_SIGNAL_CONNECT(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst,
- _MMCAMCORDER_HANDLER_STILLSHOT, "still-capture",
- G_CALLBACK(__mmcamcorder_image_capture_cb),
- hcamcorder);
- return MM_ERROR_NONE;
- } else {
- _mmcam_dbg_err("videosrc element is not created yet");
- return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+ MMCAM_LOG_INFO("connect extra preview stream signal to _MMCAMCORDER_VIDEOSRC_SRC");
+
+ MMCAMCORDER_SIGNAL_CONNECT(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst,
+ _MMCAMCORDER_HANDLER_EXTRA_PREVIEW, "extra-preview-stream-cb",
+ G_CALLBACK(__mmcamcorder_extra_preview_stream_cb),
+ hcamcorder);
+
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!control) {
+ MMCAM_LOG_ERROR("no camera control");
+ return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ }
+
+ for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM ; i++) {
+ e_fmt = &hcamcorder->extra_preview_format[i];
+
+ if (e_fmt->need_to_set_format) {
+ if (!gst_camera_control_set_extra_preview_stream_format(control,
+ i, _mmcamcorder_get_pixel_format2(e_fmt->pixel_format),
+ e_fmt->width, e_fmt->height, e_fmt->fps))
+ MMCAM_LOG_WARNING("set format[%d,%dx%d,%d] failed for stream[%d]",
+ e_fmt->pixel_format, e_fmt->width, e_fmt->height, e_fmt->fps, i);
+
+ e_fmt->need_to_set_format = FALSE;
+ }
+
+ if (e_fmt->need_to_set_bitrate) {
+ if (!gst_camera_control_set_extra_preview_bitrate(control, i, e_fmt->bitrate))
+ MMCAM_LOG_WARNING("set bitrate[%d] failed for stream[%d]", e_fmt->bitrate, i);
+
+ e_fmt->need_to_set_bitrate = FALSE;
+ }
+
+ if (e_fmt->need_to_set_gop_interval) {
+ if (!gst_camera_control_set_extra_preview_gop_interval(control, i, e_fmt->gop_interval))
+ MMCAM_LOG_WARNING("set GOP interval[%d] failed for stream[%d]", e_fmt->gop_interval, i);
+
+ e_fmt->need_to_set_gop_interval = FALSE;
+ }
}
+
+ return MM_ERROR_NONE;
}
int _mmcamcorder_remove_stillshot_pipeline(MMHandleType handle)
{
+ int ret = MM_ERROR_NONE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- _MMCamcorderImageInfo *info = NULL;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc && sc->info_image && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- info = sc->info_image;
-
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* Check pipeline */
- if (sc->element[_MMCAMCORDER_MAIN_PIPE].gst) {
- _mmcamcorder_remove_all_handlers(handle, _MMCAMCORDER_HANDLER_STILLSHOT);
+ if (sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst) {
+ ret = _mmcamcorder_gst_set_state(handle, sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst, GST_STATE_NULL);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("Failed to change encode main pipeline state [0x%x]", ret);
+ return ret;
+ }
- if (sc->bencbin_capture) {
- GstPad *srcpad = NULL, *sinkpad = NULL;
- if (!sc->element[_MMCAMCORDER_ENCSINK_BIN].gst) {
- _mmcam_dbg_log("ENCSINK_BIN is already removed");
- } else {
- /* Unlink each element */
- srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst, "src1");
- sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, "image_sink0");
- _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad);
+ _mmcamcorder_remove_all_handlers(handle, _MMCAMCORDER_HANDLER_STILLSHOT | _MMCAMCORDER_HANDLER_VIDEOREC);
- gst_bin_remove(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
- sc->element[_MMCAMCORDER_ENCSINK_BIN].gst);
+ GstPad *reqpad = NULL;
- _mmcamcorder_remove_element_handle(handle, _MMCAMCORDER_ENCSINK_BIN, _MMCAMCORDER_ENCSINK_SINK);
- }
+ /* release request pad */
+ reqpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
+ if (reqpad) {
+ gst_element_release_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, reqpad);
+ gst_object_unref(reqpad);
+ reqpad = NULL;
}
+
+ /* release encode main pipeline */
+ gst_object_unref(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst);
+
+ MMCAM_LOG_INFO("Encoder pipeline removed");
} else {
- _mmcam_dbg_log("MAIN_PIPE is already removed");
+ MMCAM_LOG_INFO("encode main pipeline is already removed");
}
return MM_ERROR_NONE;
void _mmcamcorder_destroy_video_capture_pipeline(MMHandleType handle)
{
- GstPad *reqpad1 = NULL;
- GstPad *reqpad2 = NULL;
-
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
+ int display_reuse_hint = FALSE;
+ GstElement *sink_element = NULL;
+ MMHandleType attrs;
+ int attr_index = 0;
mmf_return_if_fail(hcamcorder);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_if_fail(sc && sc->element);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (sc->element[_MMCAMCORDER_MAIN_PIPE].gst) {
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
+
+ /* check reuse flag for display element */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_REUSE_HINT, &display_reuse_hint,
+ NULL);
+
+ MMCAM_LOG_INFO("display reuse hint %d", display_reuse_hint);
+
+ if (!display_reuse_hint)
+ goto _REUSE_CHECK_DONE;
+
+ sink_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
+ if (!sink_element) {
+ MMCAM_LOG_WARNING("sink element is NULL");
+ goto _REUSE_CHECK_DONE;
+ }
+
+ attrs = MMF_CAMCORDER_ATTRS(handle);
+ if (!attrs) {
+ MMCAM_LOG_WARNING("attribute is NULL");
+ goto _REUSE_CHECK_DONE;
+ }
+
+ MMCAM_LOG_INFO("REF sink element %p and set it to attribute", sink_element);
+
+ /* ref element before remove it from pipeline */
+ gst_object_ref(sink_element);
+
+ if (!gst_bin_remove(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst), sink_element))
+ MMCAM_LOG_WARNING("failed to remove sink element from pipeline");
+
+ /* reset floating reference flag to avoid leak after next use */
+ g_object_force_floating(G_OBJECT(sink_element));
+
+ /* set sink element pointer to attribute */
+ mm_attrs_get_index((MMHandleType)attrs, MMCAM_DISPLAY_REUSE_ELEMENT, &attr_index);
+ mm_attrs_set_data(attrs, attr_index, (void *)sink_element, sizeof(*sink_element));
+ mm_attrs_commit(attrs, attr_index);
+
+ /* remove notify callback */
+ g_object_weak_unref(G_OBJECT(sink_element), (GWeakNotify)_mmcamcorder_element_release_noti, sc);
+
+ sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst = NULL;
+ sc->element[_MMCAMCORDER_VIDEOSINK_SINK].id = _MMCAMCORDER_NONE;
+
+_REUSE_CHECK_DONE:
+ traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:UNREALIZE:SET_NULL_TO_PIPELINE");
+
_mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_NULL);
+ traceEnd(TTRACE_TAG_CAMERA);
+
_mmcamcorder_remove_all_handlers(handle, _MMCAMCORDER_HANDLER_CATEGORY_ALL);
- reqpad1 = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_TEE].gst, "src0");
- reqpad2 = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_TEE].gst, "src1");
- gst_element_release_request_pad(sc->element[_MMCAMCORDER_VIDEOSRC_TEE].gst, reqpad1);
- gst_element_release_request_pad(sc->element[_MMCAMCORDER_VIDEOSRC_TEE].gst, reqpad2);
- gst_object_unref(reqpad1);
- gst_object_unref(reqpad2);
+ traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:UNREALIZE:UNREF_PIPELINE");
gst_object_unref(sc->element[_MMCAMCORDER_MAIN_PIPE].gst);
+
+ traceEnd(TTRACE_TAG_CAMERA);
+
/* NULL initialization will be done in _mmcamcorder_element_release_noti */
}
+
+ return;
}
int width = 0;
int height = 0;
int fps = 0;
- int cap_format = MM_PIXEL_FORMAT_NV12;
int image_encoder = MM_IMAGE_CODEC_JPEG;
int strobe_mode = MM_CAMCORDER_STROBE_MODE_OFF;
+ int is_modified_size = FALSE;
+ int tag_orientation = 0;
unsigned int cap_fourcc = 0;
-
char *err_name = NULL;
- char *videosrc_name = NULL;
- GstElement *pipeline = NULL;
GstCameraControl *control = NULL;
- GstCaps *caps = NULL;
- GstClock *clock = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderImageInfo *info = NULL;
_MMCamcorderSubContext *sc = NULL;
- type_element *VideosrcElement = NULL;
MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc && sc->info_image && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
- pipeline = sc->element[_MMCAMCORDER_MAIN_PIPE].gst;
info = sc->info_image;
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_CAPTURE,
- "UseCaptureMode",
- &UseCaptureMode);
-
- _mmcamcorder_conf_get_element(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "VideosrcElement",
- &VideosrcElement);
-
- _mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
-
if (info->capturing) {
- ret = MM_ERROR_CAMCORDER_DEVICE_BUSY;
- goto cmd_error;
+ MMCAM_LOG_ERROR("already capturing");
+ return MM_ERROR_CAMCORDER_DEVICE_BUSY;
}
- MMTA_ACUM_ITEM_BEGIN("Real First Capture Start",false);
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_CAPTURE,
+ "UseCaptureMode",
+ &UseCaptureMode);
/* get current state */
mm_camcorder_get_state(handle, ¤t_state);
/* set capture flag */
info->capturing = TRUE;
- mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_IMAGE_ENCODER, &image_encoder,
- MMCAM_CAMERA_WIDTH, &width,
- MMCAM_CAMERA_HEIGHT, &height,
- MMCAM_CAMERA_FPS, &fps,
- MMCAM_CAMERA_HDR_CAPTURE, &info->hdr_capture_mode,
- MMCAM_CAPTURE_FORMAT, &cap_format,
- MMCAM_CAPTURE_WIDTH, &info->width,
- MMCAM_CAPTURE_HEIGHT, &info->height,
- MMCAM_CAPTURE_COUNT, &info->count,
- MMCAM_CAPTURE_INTERVAL, &info->interval,
- MMCAM_STROBE_MODE, &strobe_mode,
- NULL);
+ ret = mm_camcorder_get_attributes(handle, &err_name,
+ MMCAM_IMAGE_ENCODER, &image_encoder,
+ MMCAM_CAMERA_WIDTH, &width,
+ MMCAM_CAMERA_HEIGHT, &height,
+ MMCAM_CAMERA_FPS, &fps,
+ MMCAM_CAPTURE_FORMAT, &info->capture_format,
+ MMCAM_CAPTURE_WIDTH, &info->width,
+ MMCAM_CAPTURE_HEIGHT, &info->height,
+ MMCAM_CAPTURE_COUNT, &info->count,
+ MMCAM_CAPTURE_INTERVAL, &info->interval,
+ MMCAM_STROBE_MODE, &strobe_mode,
+ MMCAM_TAG_ORIENTATION, &tag_orientation,
+ NULL);
if (err_name) {
- _mmcam_dbg_warn("get_attributes err %s", err_name);
- free(err_name);
- err_name = NULL;
+ MMCAM_LOG_WARNING("get_attributes err %s, ret 0x%x", err_name, ret);
+ SAFE_FREE(err_name);
}
+ ret = MM_ERROR_NONE;
+
/* check capture count */
if (info->count < 1) {
- _mmcam_dbg_err("capture count[%d] is invalid", info->count);
+ MMCAM_LOG_ERROR("capture count[%d] is invalid", info->count);
ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
- goto cmd_error;
+ goto cmd_done;
} else if (info->count == 1) {
info->type = _MMCamcorder_SINGLE_SHOT;
} else {
info->next_shot_time = 0;
info->multi_shot_stop = FALSE;
- /* sound init to pause other session */
- __ta__(" _mmcamcorder_sound_init",
-#ifdef _MMCAMCORDER_UPLOAD_SAMPLE
- _mmcamcorder_sound_init(handle, _MMCAMCORDER_FILEPATH_CAPTURE2_SND);
-#else /* _MMCAMCORDER_UPLOAD_SAMPLE */
+ /* sound init */
_mmcamcorder_sound_init(handle);
-#endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
- );
}
- _mmcam_dbg_log("preview(%dx%d,fmt:%d), capture(%dx%d,fmt:%d), count(%d), hdr mode(%d)",
- width, height, info->preview_format,
- info->width, info->height, cap_format,
- info->count, info->hdr_capture_mode);
+ MMCAM_LOG_INFO("preview(%dx%d,fmt:%d), capture(%dx%d,fmt:%d), count(%d), hdr mode(%d), interval (%d)",
+ width, height, info->preview_format, info->width, info->height, info->capture_format,
+ info->count, info->hdr_capture_mode, info->interval);
/* check state */
if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
+ if (sc->bencbin_capture) {
+ MMCAM_LOG_ERROR("could not capture in this target while recording");
+ ret = MM_ERROR_CAMCORDER_INVALID_STATE;
+ goto cmd_done;
+ }
+
if (info->type == _MMCamcorder_MULTI_SHOT ||
- info->hdr_capture_mode != MM_CAMCORDER_HDR_OFF ||
- info->preview_format != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
- _mmcam_dbg_err("not support multi/HDR capture while recording or NOT ITLV format");
+ info->hdr_capture_mode != MM_CAMCORDER_HDR_OFF) {
+ MMCAM_LOG_ERROR("does not support multi/HDR capture while recording");
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
- goto cmd_error;
+ goto cmd_done;
+ }
+
+ /* check capture size if ZSL is not supported*/
+ if (hcamcorder->support_zsl_capture == FALSE) {
+ MMCAM_LOG_WARNING("Capture size should be same with preview size while recording");
+ MMCAM_LOG_WARNING("Capture size %dx%d -> %dx%d", info->width, info->height, width, height);
+
+ info->width = width;
+ info->height = height;
+
+ MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
+
+ is_modified_size = TRUE;
}
}
if (!sc->bencbin_capture) {
/* Check encoding method */
- if (cap_format == MM_PIXEL_FORMAT_ENCODED) {
- if (sc->SensorEncodedCapture && info->type == _MMCamcorder_SINGLE_SHOT) {
- cap_fourcc = _mmcamcorder_get_fourcc(cap_format, image_encoder, hcamcorder->use_zero_copy_format);
- _mmcam_dbg_log("Sensor JPEG Capture");
+ if (info->capture_format == MM_PIXEL_FORMAT_ENCODED) {
+ if ((sc->SensorEncodedCapture && info->type == _MMCamcorder_SINGLE_SHOT) ||
+ hcamcorder->support_zsl_capture || is_modified_size) {
+ cap_fourcc = _mmcamcorder_get_fourcc(info->capture_format, image_encoder, hcamcorder->use_zero_copy_format);
+ MMCAM_LOG_INFO("Sensor JPEG Capture [is_modified_size:%d]", is_modified_size);
} else {
/* no need to encode internally if ITLV format */
- if (info->preview_format != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
+ if (info->preview_format != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
sc->internal_encode = TRUE;
- }
cap_fourcc = _mmcamcorder_get_fourcc(info->preview_format, image_encoder, hcamcorder->use_zero_copy_format);
- _mmcam_dbg_log("MSL JPEG Capture : capture fourcc %c%c%c%c",
- cap_fourcc, cap_fourcc>>8, cap_fourcc>>16, cap_fourcc>>24);
+ MMCAM_LOG_INFO("MSL JPEG Capture : capture fourcc %c%c%c%c",
+ cap_fourcc, cap_fourcc>>8, cap_fourcc>>16, cap_fourcc>>24);
}
} else {
- cap_fourcc = _mmcamcorder_get_fourcc(cap_format, MM_IMAGE_CODEC_INVALID, hcamcorder->use_zero_copy_format);
- if (info->type == _MMCamcorder_SINGLE_SHOT && !strcmp(videosrc_name, "camerasrc")) {
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE );
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE );
- }
+ cap_fourcc = _mmcamcorder_get_fourcc(info->capture_format, MM_IMAGE_CODEC_INVALID, hcamcorder->use_zero_copy_format);
}
- _mmcam_dbg_log("capture format (%d)", cap_format);
+ MMCAM_LOG_INFO("capture format (%d)", info->capture_format);
/* Note: width/height of capture is set in commit function of attribute or in create function of pipeline */
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-fourcc", cap_fourcc);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-interval", info->interval);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-count", info->count);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", info->hdr_capture_mode);
if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- _mmcam_dbg_err("Can't cast Video source into camera control.");
- return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
+ ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ goto cmd_done;
}
control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
int set_height = 0;
int cap_jpeg_quality = 0;
- if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
- _mmcam_dbg_err("could not capture in this target while recording");
- ret = MM_ERROR_CAMCORDER_INVALID_STATE;
- goto cmd_error;
- }
-
if (UseCaptureMode) {
- if (width != MMFCAMCORDER_HIGHQUALITY_WIDTH || height != MMFCAMCORDER_HIGHQUALITY_HEIGHT) {
+ if (width != MMFCAMCORDER_HIGHQUALITY_WIDTH || height != MMFCAMCORDER_HIGHQUALITY_HEIGHT)
need_change = 1;
- }
} else {
- if (width != info->width || height != info->height) {
+ if (width != info->width || height != info->height)
need_change = 1;
- }
}
- /* make pipeline state as READY */
- ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to set state PAUSED %x", ret);
- return ret;
- }
+ if (need_change) {
+ int rotation = 0;
- /* add encodesinkbin */
- ret = _mmcamcorder_add_stillshot_pipeline((MMHandleType)hcamcorder);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to create encodesinkbin %x", ret);
- return ret;
- }
+ MMCAM_LOG_INFO("Need to change resolution");
- /* set JPEG quality */
- mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_IMAGE_ENCODER_QUALITY, &cap_jpeg_quality,
- NULL);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_IENC].gst, "quality", cap_jpeg_quality);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
- if (need_change) {
- _mmcam_dbg_log("Need to change resolution");
+ /* make pipeline state as READY */
+ ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
+
+ /* check decoder recreation */
+ if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
+ MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
+
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
+
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("failed to set state PAUSED %x", ret);
+ goto cmd_done;
+ }
if (UseCaptureMode) {
set_width = MMFCAMCORDER_HIGHQUALITY_WIDTH;
set_height = info->height;
}
- caps = gst_caps_new_simple("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, sc->fourcc,
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT, set_height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- "rotate", G_TYPE_INT, 0,
- NULL);
- if (caps == NULL) {
- _mmcam_dbg_err("failed to create caps");
- ret = MM_ERROR_CAMCORDER_LOW_MEMORY;
- goto cmd_error;
+ mm_camcorder_get_attributes(handle, &err_name,
+ MMCAM_CAMERA_ROTATION, &rotation,
+ NULL);
+ if (err_name) {
+ MMCAM_LOG_WARNING("get_attributes err %s", err_name);
+ SAFE_FREE(err_name);
+ }
+
+ /* set new caps */
+ ret = _mmcamcorder_set_videosrc_caps(handle, sc->fourcc, set_width, set_height, fps, rotation);
+ if (!ret) {
+ MMCAM_LOG_ERROR("_mmcamcorder_set_videosrc_caps failed");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto cmd_done;
}
info->resolution_change = TRUE;
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
- gst_caps_unref(caps);
- /*MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "num-buffers", info->count);*/
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "req-negotiation",TRUE);
+ /* set frame stability count for capture */
+ _mmcamcorder_video_frame_stabilize(handle, _MMCamcorder_CMD_CAPTURE);
- /* FIXME: consider delay */
- clock = gst_pipeline_get_clock(GST_PIPELINE(pipeline));
- sc->stillshot_time = gst_clock_get_time(clock) - gst_element_get_base_time(GST_ELEMENT(pipeline));
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", FALSE);
+ /* make pipeline state as PLAYING */
+ ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("failed to set state PLAYING %x", ret);
+ goto cmd_done;
+ }
- _mmcam_dbg_log("Change to target resolution(%d, %d)", set_width, set_height);
+ MMCAM_LOG_INFO("Change to target resolution(%d, %d)", set_width, set_height);
} else {
- _mmcam_dbg_log("No need to change resolution. Open toggle now.");
+ MMCAM_LOG_INFO("No need to change resolution. Open toggle now.");
+ info->resolution_change = FALSE;
+ }
+
+ /* add encodesinkbin */
+ ret = _mmcamcorder_create_stillshot_pipeline((MMHandleType)hcamcorder);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("failed to create encodesinkbin %x", ret);
+ goto cmd_done;
+ }
+
+ ret = mm_camcorder_get_attributes(handle, &err_name,
+ MMCAM_IMAGE_ENCODER_QUALITY, &cap_jpeg_quality,
+ NULL);
+ if (err_name) {
+ MMCAM_LOG_WARNING("get_attributes err %s, ret 0x%x", err_name, ret);
+ SAFE_FREE(err_name);
}
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_SINK].gst,"signal-handoffs", TRUE);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", FALSE);
+ /* set JPEG quality */
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_IENC].gst, "quality", cap_jpeg_quality);
+
+ /* set handoff signal as TRUE */
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "signal-handoffs", TRUE);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", FALSE);
+
+ /* Prepare for the shutter sound when it's the bencbin mode capture */
+ sc->info_video->is_first_frame = TRUE;
- /* make pipeline state as PLAYING */
- ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
+ /* set push encoding buffer as TRUE */
+ sc->info_video->push_encoding_buffer = PUSH_ENCODING_BUFFER_INIT;
+
+ /* make encode pipeline state as PLAYING */
+ ret = _mmcamcorder_gst_set_state(handle, sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst, GST_STATE_PLAYING);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to set state PLAYING %x", ret);
- return ret;
+ MMCAM_LOG_ERROR("failed to set state PLAYING %x", ret);
+ goto cmd_done;
}
}
/* Play capture sound here if single capture */
if ((info->type == _MMCamcorder_SINGLE_SHOT &&
- (info->preview_format != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY || strobe_mode == MM_CAMCORDER_STROBE_MODE_OFF)) ||
+ (hcamcorder->support_zsl_capture == FALSE ||
+ strobe_mode == MM_CAMCORDER_STROBE_MODE_OFF)) ||
info->hdr_capture_mode) {
- if (current_state < MM_CAMCORDER_STATE_RECORDING) {
- __ta__(" _mmcamcorder_sound_solo_play",
- _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_FILEPATH_CAPTURE_SND, FALSE);
- );
+ if (current_state < MM_CAMCORDER_STATE_RECORDING &&
+ hcamcorder->support_zsl_capture == TRUE &&
+ !info->hdr_capture_mode) {
+ _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE01, FALSE);
}
/* set flag */
info->played_capture_sound = FALSE;
}
- return ret;
+cmd_done:
+ if (ret != MM_ERROR_NONE) {
+ info->capturing = FALSE;
+
+ /* sound finalize */
+ if (info->type == _MMCamcorder_MULTI_SHOT)
+ _mmcamcorder_sound_finalize(handle);
+
+ /* send signal for task thread : It prevent unnecessary invalid operation error in task thread */
+ if (hcamcorder->capture_in_recording) {
+ hcamcorder->capture_in_recording = FALSE;
+
+ g_mutex_lock(&hcamcorder->task_thread_lock);
+
+ if (hcamcorder->task_thread_state == _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING) {
+ hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_NONE;
+ MMCAM_LOG_INFO("send signal for capture in recording");
+ g_cond_signal(&hcamcorder->task_thread_cond);
+ } else {
+ MMCAM_LOG_WARNING("unexpected task thread state : %d", hcamcorder->task_thread_state);
+ }
+
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
+ }
+ }
-cmd_error:
- info->capturing = FALSE;
return ret;
}
int width = 0;
int height = 0;
int fps = 0;
- int cap_width = 0;
- int cap_height = 0;
int rotation = 0;
- int set_width = 0;
- int set_height = 0;
- int set_rotate = 0;
- int current_framecount = 0;
+ int bitrate = 0;
+ int gop_interval = 0;
+ unsigned int current_framecount = 0;
int current_state = MM_CAMCORDER_STATE_NONE;
gboolean fps_auto = FALSE;
char *err_name = NULL;
- char *videosrc_name = NULL;
GstState state;
- GstCaps *caps = NULL;
GstElement *pipeline = NULL;
GstCameraControl *control = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderImageInfo *info = NULL;
_MMCamcorderSubContext *sc = NULL;
- type_element *VideosrcElement = NULL;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc && sc->info_image && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ /*MMCAM_LOG_INFO("");*/
pipeline = sc->element[_MMCAMCORDER_MAIN_PIPE].gst;
info = sc->info_image;
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
-
- _mmcamcorder_conf_get_element(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "VideosrcElement",
- &VideosrcElement);
-
- _mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
-
sc->display_interval = 0;
sc->previous_slot_time = 0;
info->multi_shot_stop = TRUE;
info->capturing = FALSE;
- _mmcamcorder_vframe_stablize(handle);
-
current_state = _mmcamcorder_get_state(handle);
- _mmcam_dbg_log("current state [%d]", current_state);
+ MMCAM_LOG_INFO("current state [%d]", current_state);
if (!sc->bencbin_capture) {
- _mmcam_dbg_log("Capture Preview start : avsysvideosrc - No need to set new caps.");
+ MMCAM_LOG_INFO("Preview start");
/* just set capture stop command if current state is CAPTURING */
if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- _mmcam_dbg_err("Can't cast Video source into camera control.");
+ MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
}
+ current_framecount = sc->kpi.video_framecount;
+
control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP);
- current_framecount = sc->kpi.video_framecount;
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
if (info->type == _MMCamcorder_SINGLE_SHOT) {
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
}
} else {
int focus_mode = 0;
+ MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
/* This case is starting of preview */
ret = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_CAMERA_FPS_AUTO, &fps_auto,
- MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
- NULL);
+ MMCAM_CAMERA_FPS_AUTO, &fps_auto,
+ MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
+ NULL);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, ret);
- SAFE_FREE (err_name);
+ MMCAM_LOG_WARNING("Get attrs fail. (%s:%x)", err_name, ret);
+ SAFE_FREE(err_name);
}
+ MMCAM_LOG_INFO("focus mode %d", focus_mode);
+
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "fps-auto", fps_auto);
/* set focus mode */
- mm_camcorder_set_attributes(handle, NULL,
- MMCAM_CAMERA_FOCUS_MODE, focus_mode,
- NULL);
- }
- } else {
- /* check if resolution need to rollback */
- mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_CAMERA_WIDTH, &width,
- MMCAM_CAMERA_HEIGHT, &height,
- MMCAM_CAMERA_FPS, &fps,
- MMCAM_CAMERA_FPS_AUTO, &fps_auto,
- MMCAM_CAMERA_ROTATION, &rotation,
- MMCAM_CAPTURE_WIDTH, &cap_width,
- MMCAM_CAPTURE_HEIGHT, &cap_height,
- NULL);
-
- if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
- switch (rotation) {
- case MM_VIDEO_INPUT_ROTATION_90:
- set_width = height;
- set_height = width;
- set_rotate = 90;
- break;
- case MM_VIDEO_INPUT_ROTATION_180:
- set_width = width;
- set_height = height;
- set_rotate = 180;
- break;
- case MM_VIDEO_INPUT_ROTATION_270:
- set_width = height;
- set_height = width;
- set_rotate = 270;
- break;
- case MM_VIDEO_INPUT_ROTATION_NONE:
- default:
- set_width = width;
- set_height = height;
- set_rotate = 0;
- break;
- }
-
- caps = gst_caps_new_simple("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, sc->fourcc,
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT,set_height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- "rotate", G_TYPE_INT, set_rotate,
- NULL);
- if (caps != NULL) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
- gst_caps_unref(caps);
- _mmcam_dbg_log("Rollback to original resolution(%d, %d)", width, height);
+ if (attrs) {
+ if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_CAMERA_FOCUS_MODE)) {
+ mm_attrs_set_modified(attrs, MM_CAM_CAMERA_FOCUS_MODE);
+ mm_attrs_commit(attrs, MM_CAM_CAMERA_FOCUS_MODE);
+
+ if (focus_mode == MM_CAMCORDER_FOCUS_MODE_MANUAL) {
+ mm_attrs_set_modified(attrs, MM_CAM_CAMERA_FOCUS_LEVEL);
+ mm_attrs_commit(attrs, MM_CAM_CAMERA_FOCUS_LEVEL);
+ }
+ } else {
+ MMCAM_LOG_INFO("focus mode is not supported");
+ }
} else {
- _mmcam_dbg_err("failed to create caps");
- ret = MM_ERROR_CAMCORDER_LOW_MEMORY;
- goto cmd_error;
+ MMCAM_LOG_ERROR("failed to get attributes");
}
}
}
+ /* init prev_time */
+ sc->info_video->prev_preview_ts = 0;
+
gst_element_get_state(pipeline, &state, NULL, -1);
if (state == GST_STATE_PLAYING) {
- if (!strcmp(videosrc_name, "avsysvideosrc") || !strcmp(videosrc_name, "camerasrc")) {
+ if (!sc->bencbin_capture) {
int try_count = 0;
- if (info->preview_format != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
- mmf_attrs_t *attr = (mmf_attrs_t *)MMF_CAMCORDER_ATTRS(handle);
+ if (hcamcorder->support_zsl_capture == FALSE) {
+ MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
- /* Set strobe mode - strobe mode can not be set to driver while captuing */
- if (attr) {
- __ta__(" Set strobe mode after capture",
- mmf_attribute_set_modified(&(attr->items[MM_CAM_STROBE_MODE]));
- if (mmf_attrs_commit((MMHandleType) attr) == -1) {
- _mmcam_dbg_warn("Failed to set strobe mode");
- }
- );
+ /* Set strobe mode - strobe mode can not be set to driver while capturing */
+ if (attrs) {
+ mm_attrs_set_modified(attrs, MM_CAM_STROBE_MODE);
+ if (mm_attrs_commit(attrs, MM_CAM_STROBE_MODE) == -1)
+ MMCAM_LOG_WARNING("Failed to set strobe mode");
}
- __ta__(" Wait preview frame after capture",
while (current_framecount >= sc->kpi.video_framecount &&
- try_count++ < _MMCAMCORDER_CAPTURE_STOP_CHECK_COUNT) {
+ try_count++ < _MMCAMCORDER_CAPTURE_STOP_CHECK_COUNT) {
usleep(_MMCAMCORDER_CAPTURE_STOP_CHECK_INTERVAL);
}
- );
}
if (info->type == _MMCamcorder_MULTI_SHOT) {
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
}
- _mmcam_dbg_log("Wait Frame Done. count before[%d],after[%d], try_count[%d]",
- current_framecount, sc->kpi.video_framecount, try_count);
+ MMCAM_LOG_INFO("Wait Frame Done. count before[%d],after[%d], try_count[%d]",
+ current_framecount, sc->kpi.video_framecount, try_count);
} else {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
- ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_READY);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", FALSE);
- if (ret != MM_ERROR_NONE) {
+ ret = _mmcamcorder_remove_stillshot_pipeline(handle);
+ if (ret != MM_ERROR_NONE)
goto cmd_error;
- }
- /* remove handoff signal handler */
- _mmcamcorder_remove_all_handlers(handle, _MMCAMCORDER_HANDLER_STILLSHOT);
+ if (info->resolution_change) {
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
- /* remove encodesinkbin after capture */
- if (!sc->element[_MMCAMCORDER_ENCSINK_BIN].gst) {
- _mmcam_dbg_log("ENCSINK_BIN is already removed");
- } else {
- GstPad *reqpad0 = NULL;
- GstPad *srcpad = NULL;
- GstPad *sinkpad = NULL;
-
- /* release requested pad */
- reqpad0 = gst_element_get_static_pad(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
- gst_element_release_request_pad(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, reqpad0);
- gst_object_unref(reqpad0);
+ ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_READY);
- /* Unlink each element */
- srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst, "src1");
- sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, "image_sink0");
- _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad);
+ /* check decoder recreation */
+ if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
+ MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
- /* make state of encodesinkbin as NULL */
- _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, GST_STATE_NULL);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
+
+ if (ret != MM_ERROR_NONE)
+ goto cmd_error;
+
+ /* check if resolution need to rollback */
+ mm_camcorder_get_attributes(handle, &err_name,
+ MMCAM_CAMERA_WIDTH, &width,
+ MMCAM_CAMERA_HEIGHT, &height,
+ MMCAM_CAMERA_FPS, &fps,
+ MMCAM_CAMERA_ROTATION, &rotation,
+ NULL);
+ if (err_name) {
+ MMCAM_LOG_WARNING("get_attributes err %s, ret 0x%x", err_name, ret);
+ SAFE_FREE(err_name);
+ }
- gst_bin_remove(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
- sc->element[_MMCAMCORDER_ENCSINK_BIN].gst);
+ /* set new caps */
+ ret = _mmcamcorder_set_videosrc_caps(handle, sc->fourcc, width, height, fps, rotation);
+ if (!ret) {
+ MMCAM_LOG_ERROR("_mmcamcorder_set_videosrc_caps failed");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto cmd_error;
+ }
- _mmcamcorder_remove_element_handle(handle, _MMCAMCORDER_ENCSINK_BIN, _MMCAMCORDER_ENCSINK_SINK);
- }
+ /* set frame stability count for preview */
+ _mmcamcorder_video_frame_stabilize(handle, _MMCamcorder_CMD_PREVIEW_START);
- ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING);
- if (ret != MM_ERROR_NONE) {
- goto cmd_error;
+ ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING);
+ if (ret != MM_ERROR_NONE)
+ goto cmd_error;
}
}
/* sound finalize */
- if (info->type == _MMCamcorder_MULTI_SHOT) {
- __ta__(" _mmcamcorder_sound_finalize",
+ if (info->type == _MMCamcorder_MULTI_SHOT)
_mmcamcorder_sound_finalize(handle);
- );
- }
} else {
- int cap_count = 0;
- int sound_ret = FALSE;
+ if (_mmcamcorder_is_encoded_preview_pixel_format(info->preview_format)) {
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_ENCODED_PREVIEW_BITRATE, &bitrate,
+ MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval,
+ NULL);
+
+ _mmcamcorder_set_encoded_preview_bitrate(handle, bitrate);
+ _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
+ }
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
- __ta__(" _MMCamcorder_CMD_PREVIEW_START:GST_STATE_PLAYING",
+ /* set frame stability count for preview */
+ _mmcamcorder_video_frame_stabilize(handle, _MMCamcorder_CMD_PREVIEW_START);
+
+ traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:START:SET_PLAYING_TO_PIPELINE");
+
ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING);
- );
- if (ret != MM_ERROR_NONE) {
+
+ traceEnd(TTRACE_TAG_CAMERA);
+
+ if (ret != MM_ERROR_NONE)
goto cmd_error;
- }
/* get sound status/volume level and register changed_cb */
if (hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_OFF &&
info->sound_status == _SOUND_STATUS_INIT) {
- _mmcam_dbg_log("get sound status/volume level and register vconf changed_cb");
-
- /* get sound status */
- __ta__(" GET:VCONFKEY_SETAPPL_SOUND_STATUS_BOOL",
- vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &(info->sound_status));
- );
-
- _mmcam_dbg_log("sound status %d", info->sound_status);
-
- /* get volume level */
- __ta__(" mm_sound_volume_get_value",
- mm_sound_volume_get_value(VOLUME_TYPE_MEDIA, &info->volume_level);
- );
-
- _mmcam_dbg_log("volume level %d", info->volume_level);
+ MMCAM_LOG_INFO("register vconf changed_cb and get sound status");
/* register changed_cb */
vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, __sound_status_changed_cb, hcamcorder);
- mm_sound_volume_add_callback(VOLUME_TYPE_MEDIA, __volume_level_changed_cb, hcamcorder);
- }
- mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_COUNT, &cap_count, NULL);
- if (cap_count > 1) {
- __ta__("_mmcamcorder_sound_init",
-#ifdef _MMCAMCORDER_UPLOAD_SAMPLE
- sound_ret = _mmcamcorder_sound_init(handle, _MMCAMCORDER_FILEPATH_CAPTURE2_SND);
-#else /* _MMCAMCORDER_UPLOAD_SAMPLE */
- sound_ret = _mmcamcorder_sound_init(handle);
-#endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
- );
+ /* get sound status */
+ vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &(info->sound_status));
+
+ MMCAM_LOG_INFO("sound status %d", info->sound_status);
}
}
int _mmcamcorder_image_cmd_preview_stop(MMHandleType handle)
{
int ret = MM_ERROR_NONE;
+ int strobe_mode = MM_CAMCORDER_STROBE_MODE_OFF;
+ int set_strobe = 0;
+ int display_reuse_hint = FALSE;
+ GstCameraControl *control = NULL;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
GstElement *pipeline = NULL;
_MMCamcorderSubContext *sc = NULL;
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
- mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ /* check strobe and set OFF if PERMANENT mode */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_STROBE_MODE, &strobe_mode,
+ NULL);
+ if (strobe_mode == MM_CAMCORDER_STROBE_MODE_PERMANENT &&
+ GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
+ MMCAM_LOG_INFO("current strobe mode is PERMANENT, set OFF");
+
+ /* get camera control */
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (control) {
+ /* convert MSL to sensor value */
+ set_strobe = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, MM_CAMCORDER_STROBE_MODE_OFF);
+
+ /* set strobe OFF */
+ gst_camera_control_set_strobe(control, GST_CAMERA_CONTROL_STROBE_MODE, set_strobe);
+
+ MMCAM_LOG_INFO("set strobe OFF done - value: %d", set_strobe);
+ } else {
+ MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
+ }
+ }
+
pipeline = sc->element[_MMCAMCORDER_MAIN_PIPE].gst;
+ if (sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst) {
+ MMCAM_LOG_INFO("pipeline is exist so need to remove pipeline and sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst=%p",
+ sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst);
+ _mmcamcorder_remove_recorder_pipeline(handle);
+ }
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_REUSE_HINT, &display_reuse_hint,
+ NULL);
+
+ MMCAM_LOG_INFO("display reuse hint %d", display_reuse_hint);
+
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "keep-camera-preview", display_reuse_hint);
+
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
+
+ traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:STOP:SET_READY_TO_PIPELINE");
+
ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_READY);
+
+ traceEnd(TTRACE_TAG_CAMERA);
+
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
+
+ if (display_reuse_hint)
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "keep-camera-preview", FALSE);
/* deregister sound status callback */
if (sc->info_image->sound_status != _SOUND_STATUS_INIT) {
- _mmcam_dbg_log("deregister sound status callback");
+ MMCAM_LOG_INFO("deregister sound status callback");
- __ta__(" vconf_ignore_key_changed",
vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, __sound_status_changed_cb);
- );
- __ta__(" mm_sound_volume_remove_callback",
- mm_sound_volume_remove_callback(VOLUME_TYPE_MEDIA);
- );
sc->info_image->sound_status = _SOUND_STATUS_INIT;
}
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("command %d", command);
+ MMCAM_LOG_INFO("command %d", command);
switch (command) {
case _MMCamcorder_CMD_CAPTURE:
break;
}
- if (ret != MM_ERROR_NONE && sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
- int op_status = 0;
- MMCAMCORDER_G_OBJECT_GET (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "operation-status", &op_status);
- _mmcam_dbg_err("Current Videosrc status[0x%x]", op_status);
- }
-
return ret;
}
-void __mmcamcorder_init_stillshot_info (MMHandleType handle)
+void __mmcamcorder_init_stillshot_info(MMHandleType handle)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
info = sc->info_image;
- _mmcam_dbg_log("capture type[%d], capture send count[%d]", info->type, info->capture_send_count);
+ MMCAM_LOG_INFO("capture type[%d], capture send count[%d]", info->type, info->capture_send_count);
- if (info->type ==_MMCamcorder_SINGLE_SHOT || info->capture_send_count == info->count) {
+ if (info->type == _MMCamcorder_SINGLE_SHOT || info->capture_send_count == info->count) {
info->capture_cur_count = 0;
info->capture_send_count = 0;
info->multi_shot_stop = TRUE;
}
-int __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureDataType *original, MMCamcorderCaptureDataType *thumbnail)
+int __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureDataType *original, MMCamcorderCaptureDataType *thumbnail, int provide_exif)
{
int ret = MM_ERROR_NONE;
unsigned char *data = NULL;
unsigned int datalen = 0;
-
+ _MMCamcorderSubContext *sc = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
mmf_return_val_if_fail(hcamcorder, FALSE);
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ mmf_return_val_if_fail(sc, FALSE);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!original || original->data == NULL || original->length == 0) {
- _mmcam_dbg_err("original=%p, data=%p, length=%d", original, original->data, original->length);
+ if (original) {
+ MMCAM_LOG_ERROR("data=%p, length=%d",
+ original->data, original->length);
+ } else {
+ MMCAM_LOG_ERROR("original is null");
+ }
+
return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
} else {
/* original is input/output param. save original values to local var. */
datalen = original->length;
}
- if (thumbnail) {
- if (thumbnail->data && thumbnail->length > 0) {
- _mmcam_dbg_log("thumbnail is added!thumbnail->data=%p thumbnail->width=%d ,thumbnail->height=%d",
- thumbnail->data, thumbnail->width, thumbnail->height);
+ if (provide_exif == FALSE) {
+ if (thumbnail) {
+ if (thumbnail->data && thumbnail->length > 0) {
+ MMCAM_LOG_INFO("thumbnail is added!thumbnail->data=%p thumbnail->width=%d ,thumbnail->height=%d",
+ thumbnail->data, thumbnail->width, thumbnail->height);
- /* add thumbnail exif info */
- __ta__(" mm_exif_add_thumbnail_info",
- ret = mm_exif_add_thumbnail_info(hcamcorder->exif_info,
- thumbnail->data,
- thumbnail->width,
- thumbnail->height,
- thumbnail->length);
- );
- } else {
- _mmcam_dbg_err("Skip adding thumbnail (data=%p, length=%d)",
- thumbnail->data, thumbnail->length);
+ /* add thumbnail exif info */
+ ret = mm_exif_add_thumbnail_info(hcamcorder->exif_info,
+ thumbnail->data,
+ thumbnail->width,
+ thumbnail->height,
+ thumbnail->length);
+ } else {
+ MMCAM_LOG_ERROR("Skip adding thumbnail (data=%p, length=%d)",
+ thumbnail->data, thumbnail->length);
+ }
}
+ } else {
+ ret = MM_ERROR_NONE;
}
if (ret == MM_ERROR_NONE) {
/* write jpeg with exif */
- __ta__(" mm_exif_write_exif_jpeg_to_memory",
- ret = mm_exif_write_exif_jpeg_to_memory(&original->data, &original->length ,hcamcorder->exif_info, data, datalen);
- );
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_exif_write_exif_jpeg_to_memory error! [0x%x]",ret);
- }
+ ret = mm_exif_write_exif_jpeg_to_memory(&original->data, &original->length, hcamcorder->exif_info, data, datalen);
+ if (ret != MM_ERROR_NONE)
+ MMCAM_LOG_ERROR("mm_exif_write_exif_jpeg_to_memory error! [0x%x]", ret);
}
- _mmcam_dbg_log("END ret 0x%x", ret);
+ MMCAM_LOG_INFO("END ret 0x%x", ret);
return ret;
}
-void __mmcamcorder_get_capture_data_from_buffer(MMCamcorderCaptureDataType *capture_data, int pixtype, GstBuffer *buffer)
+void __mmcamcorder_get_capture_data_from_buffer(MMCamcorderCaptureDataType *capture_data, int pixtype, GstSample *sample)
{
GstCaps *caps = NULL;
+ GstMapInfo mapinfo;
const GstStructure *structure;
- mmf_return_if_fail(capture_data && buffer);
+ mmf_return_if_fail(capture_data && sample);
- caps = gst_buffer_get_caps(buffer);
+ caps = gst_sample_get_caps(sample);
if (caps == NULL) {
- _mmcam_dbg_err("failed to get caps");
+ MMCAM_LOG_ERROR("failed to get caps");
goto GET_FAILED;
}
structure = gst_caps_get_structure(caps, 0);
- if (caps == NULL) {
- _mmcam_dbg_err("failed to get structure");
+ if (structure == NULL) {
+ MMCAM_LOG_ERROR("failed to get structure");
goto GET_FAILED;
}
- capture_data->data = GST_BUFFER_DATA(buffer);
+ memset(&mapinfo, 0x0, sizeof(GstMapInfo));
+
+ gst_buffer_map(gst_sample_get_buffer(sample), &mapinfo, GST_MAP_READ);
+ capture_data->data = mapinfo.data;
capture_data->format = pixtype;
- gst_structure_get_int(structure, "width", &capture_data->width);
- gst_structure_get_int(structure, "height", &capture_data->height);
- capture_data->length = GST_BUFFER_SIZE(buffer);
-
- _mmcam_dbg_warn("buffer data[%p],size[%dx%d],length[%d],format[%d]",
- capture_data->data, capture_data->width, capture_data->height,
- capture_data->length, capture_data->format);
- gst_caps_unref(caps);
- caps = NULL;
-
- return;
+ gst_structure_get(structure,
+ "width", G_TYPE_INT, &capture_data->width,
+ "height", G_TYPE_INT, &capture_data->height,
+ NULL);
+ capture_data->length = mapinfo.size;
+ gst_buffer_unmap(gst_sample_get_buffer(sample), &mapinfo);
+
+ MMCAM_LOG_WARNING("buffer data[%p],size[%dx%d],length[%d],format[%d]",
+ capture_data->data, capture_data->width, capture_data->height,
+ capture_data->length, capture_data->format);
+ return;
GET_FAILED:
capture_data->data = NULL;
}
-int __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, MMCamcorderCaptureDataType *thumbnail)
+int __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, MMCamcorderCaptureDataType *thumbnail, int provide_exif)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* if tag enable and doesn't provide exif, we make it */
- _mmcam_dbg_log("Add exif information if existed(thumbnail[%p])", thumbnail);
- if (thumbnail && thumbnail->data) {
- return __mmcamcorder_capture_save_exifinfo(handle, dest, thumbnail);
- } else {
- return __mmcamcorder_capture_save_exifinfo(handle, dest, NULL);
- }
+ MMCAM_LOG_INFO("Add exif information if existed(thumbnail[%p])", thumbnail);
+ if (thumbnail && thumbnail->data)
+ return __mmcamcorder_capture_save_exifinfo(handle, dest, thumbnail, provide_exif);
+ else
+ return __mmcamcorder_capture_save_exifinfo(handle, dest, NULL, provide_exif);
}
-void __mmcamcorder_release_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest)
+void __mmcamcorder_release_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, int tag_enable, int provide_exif)
{
- int tag_enable = 0;
- int provide_exif = FALSE;
-
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
mmf_return_if_fail(sc);
- _mmcam_dbg_log("");
-
- __ta__( " Get:MMCAM_TAG_ENABLE and \"provide-exif\"",
- mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_ENABLE, &tag_enable, NULL);
- MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "provide-exif", &provide_exif);
- );
+ MMCAM_LOG_INFO("tag : %d, provide exif : %d", tag_enable, provide_exif);
/* if dest->data is allocated in MSL, release it */
if (tag_enable && !provide_exif) {
if (dest->data) {
- __ta__( " Free data",
free(dest->data);
- );
dest->length = 0;
dest->data = NULL;
- _mmcam_dbg_log("Jpeg is released!");
+ MMCAM_LOG_INFO("Jpeg is released!");
}
} else {
- _mmcam_dbg_log("No need to release");
+ MMCAM_LOG_INFO("No need to release");
}
return;
}
-static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffer1, GstBuffer *buffer2, GstBuffer *buffer3, gpointer u_data)
+static void __mmcamcorder_image_capture_cb(GstElement *element, GstSample *sample1, GstSample *sample2, GstSample *sample3, gpointer u_data)
{
int ret = MM_ERROR_NONE;
- int pixtype = MM_PIXEL_FORMAT_INVALID;
- int pixtype_sub = MM_PIXEL_FORMAT_INVALID;
+ int pixtype_main = MM_PIXEL_FORMAT_INVALID;
+ int pixtype_thumb = MM_PIXEL_FORMAT_INVALID;
+ int pixtype_scrnl = MM_PIXEL_FORMAT_INVALID;
int codectype = MM_IMAGE_CODEC_JPEG;
- int attr_index = 0;
int count = 0;
int stop_cont_shot = FALSE;
int tag_enable = FALSE;
int try_lock_count = 0;
gboolean send_captured_message = FALSE;
unsigned char *exif_raw_data = NULL;
+ unsigned char *internal_main_data = NULL;
+ unsigned int internal_main_length = 0;
+ unsigned char *internal_thumb_data = NULL;
+ unsigned int internal_thumb_length = 0;
+ unsigned char *compare_data = NULL;
MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
MMCamcorderCaptureDataType dest = {0,};
MMCamcorderCaptureDataType thumb = {0,};
MMCamcorderCaptureDataType scrnail = {0,};
+ MMCamcorderCaptureDataType encode_src = {0,};
+ GstMapInfo mapinfo1;
+ GstMapInfo mapinfo2;
+ GstMapInfo mapinfo3;
- mmf_attrs_t *attrs = NULL;
- mmf_attribute_t *item_screennail = NULL;
- mmf_attribute_t *item_exif_raw_data = NULL;
+ MMHandleType attrs;
+ int attr_index_for_screennail = 0;
+ int attr_index_for_exif = 0;
mmf_return_if_fail(hcamcorder);
info = sc->info_image;
+ memset(&mapinfo1, 0x0, sizeof(GstMapInfo));
+ memset(&mapinfo2, 0x0, sizeof(GstMapInfo));
+ memset(&mapinfo3, 0x0, sizeof(GstMapInfo));
+
/* get current state */
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- _mmcam_dbg_err("START - current state %d", current_state);
-
- MMTA_ACUM_ITEM_BEGIN(" MSL capture callback", FALSE);
+ MMCAM_LOG_ERROR("START - current state %d", current_state);
/* check capture state */
- if (info->type == _MMCamcorder_MULTI_SHOT && info->capture_send_count > 0) {
- mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL, "capture-break-cont-shot", &stop_cont_shot, NULL);
- }
+ if (info->type == _MMCamcorder_MULTI_SHOT && info->capture_send_count > 0)
+ mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
+ MMCAM_CAPTURE_BREAK_CONTINUOUS_SHOT, &stop_cont_shot,
+ NULL);
if (!info->capturing || stop_cont_shot) {
- _mmcam_dbg_warn("stop command[%d] or not capturing state[%d]. skip this...",
- stop_cont_shot, info->capturing);
+ MMCAM_LOG_WARNING("stop command[%d] or not capturing state[%d]. skip this...", stop_cont_shot, info->capturing);
- MMTA_ACUM_ITEM_END(" MSL capture callback", FALSE);
+ /* set FALSE here for the case that info->capturing is still FALSE
+ (== capture_send_count is 0 at the time _mmcamcorder_commit_capture_break_cont_shot is called) */
+ info->capturing = FALSE;
/*free GstBuffer*/
- if (buffer1) {
- gst_buffer_unref(buffer1);
- }
- if (buffer2) {
- gst_buffer_unref(buffer2);
- }
- if (buffer3) {
- gst_buffer_unref(buffer3);
- }
+ if (sample1)
+ gst_sample_unref(sample1);
+
+ if (sample2)
+ gst_sample_unref(sample2);
+
+ if (sample3)
+ gst_sample_unref(sample3);
return;
}
wait for 2 seconds at worst case */
try_lock_count = 0;
do {
- _mmcam_dbg_log("Try command LOCK");
+ MMCAM_LOG_INFO("Try command LOCK");
if (_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_log("command LOCK OK");
+ MMCAM_LOG_INFO("command LOCK OK");
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
break;
}
if (try_lock_count++ < TRY_LOCK_MAX_COUNT) {
- _mmcam_dbg_warn("command LOCK Failed, retry...[count %d]", try_lock_count);
+ MMCAM_LOG_WARNING("command LOCK Failed, retry...[count %d]", try_lock_count);
usleep(TRY_LOCK_TIME);
} else {
- _mmcam_dbg_err("failed to lock command LOCK");
+ MMCAM_LOG_ERROR("failed to lock command LOCK");
break;
}
} while (TRUE);
/* play capture sound here if multi capture
or preview format is ITLV(because of AF and flash control in plugin) */
if (info->type == _MMCamcorder_MULTI_SHOT) {
- __ta__(" _mmcamcorder_sound_play",
- _mmcamcorder_sound_play((MMHandleType)hcamcorder);
- );
+ g_mutex_lock(&hcamcorder->task_thread_lock);
+ MMCAM_LOG_INFO("send signal for sound play");
+ hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START;
+ g_cond_signal(&hcamcorder->task_thread_cond);
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
} else if (!info->played_capture_sound) {
- __ta__(" _mmcamcorder_sound_solo_play",
- _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_FILEPATH_CAPTURE_SND, FALSE);
- );
+ _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE01, FALSE);
}
}
memset((void *)&scrnail, 0x0, sizeof(MMCamcorderCaptureDataType));
/* Prepare main, thumbnail buffer */
- pixtype = _mmcamcorder_get_pixel_format(buffer1);
- if (pixtype == MM_PIXEL_FORMAT_INVALID) {
- _mmcam_dbg_err("Unsupported pixel type");
-
+ pixtype_main = _mmcamcorder_get_pixel_format(gst_sample_get_caps(sample1));
+ if (pixtype_main == MM_PIXEL_FORMAT_INVALID) {
+ MMCAM_LOG_ERROR("Unsupported pixel type");
MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INTERNAL);
-
goto error;
}
/* Main image buffer */
- if (buffer1 && GST_BUFFER_DATA(buffer1) && (GST_BUFFER_SIZE(buffer1) !=0)) {
- __mmcamcorder_get_capture_data_from_buffer(&dest, pixtype, buffer1);
- } else {
- _mmcam_dbg_err("buffer1 has wrong pointer. (buffer1=%p)",buffer1);
+ if (!sample1 || !gst_buffer_map(gst_sample_get_buffer(sample1), &mapinfo1, GST_MAP_READ)) {
+ MMCAM_LOG_ERROR("sample1[%p] is NULL or gst_buffer_map failed", sample1);
MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INTERNAL);
goto error;
+ } else {
+ if ((mapinfo1.data == NULL) && (mapinfo1.size == 0)) {
+ MMCAM_LOG_ERROR("mapinfo1 is wrong (%p, size %zu)", mapinfo1.data, mapinfo1.size);
+ MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INTERNAL);
+ gst_buffer_unmap(gst_sample_get_buffer(sample1), &mapinfo1);
+ goto error;
+ } else {
+ __mmcamcorder_get_capture_data_from_buffer(&dest, pixtype_main, sample1);
+ }
}
- /* Encode JPEG */
- if (sc->internal_encode) {
-#ifdef _MMCAMCORDER_MAKE_THUMBNAIL_INTERNAL_ENCODE
- int thumb_width = 0;
- int thumb_height = 0;
- int thumb_length = 0;
- unsigned char *thumb_raw_data = NULL;
-#endif /* _MMCAMCORDER_MAKE_THUMBNAIL_INTERNAL_ENCODE */
+ if (!sample2 || !gst_buffer_map(gst_sample_get_buffer(sample2), &mapinfo2, GST_MAP_READ))
+ MMCAM_LOG_INFO("sample2[%p] is NULL or gst_buffer_map failed. Not Error.", sample2);
- mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
- MMCAM_IMAGE_ENCODER_QUALITY, &capture_quality,
- NULL);
- _mmcam_dbg_log("Start Internal Encode - capture_quality %d", capture_quality);
-
- __ta__(" _mmcamcorder_encode_jpeg:MAIN",
- ret = _mmcamcorder_encode_jpeg(GST_BUFFER_DATA(buffer1), dest.width, dest.height,
- pixtype, dest.length, capture_quality, &(dest.data), &(dest.length));
- );
- if (!ret) {
- _mmcam_dbg_err("_mmcamcorder_encode_jpeg failed");
+ if (!sample3 || !gst_buffer_map(gst_sample_get_buffer(sample3), &mapinfo3, GST_MAP_READ))
+ MMCAM_LOG_INFO("sample3[%p] is NULL or gst_buffer_map failed. Not Error.", sample3);
- MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INTERNAL);
+ /* Screennail image buffer */
+ attrs = MMF_CAMCORDER_ATTRS(hcamcorder);
+ mm_attrs_get_index(attrs, MMCAM_CAPTURED_SCREENNAIL, &attr_index_for_screennail);
- goto error;
- }
+ if (sample3 && mapinfo3.data && mapinfo3.size != 0) {
+ MMCAM_LOG_INFO("Screennail (sample3=%p,size=%zu)", sample3, mapinfo3.size);
- /* set format */
- dest.format = MM_PIXEL_FORMAT_ENCODED;
+ pixtype_scrnl = _mmcamcorder_get_pixel_format(gst_sample_get_caps(sample3));
+ __mmcamcorder_get_capture_data_from_buffer(&scrnail, pixtype_scrnl, sample3);
- _mmcam_dbg_log("Done Internal Encode - data %p, length %d", dest.data, dest.length);
+ /* Set screennail attribute for application */
+ ret = mm_attrs_set_data(attrs, attr_index_for_screennail, &scrnail, sizeof(scrnail));
+ MMCAM_LOG_INFO("Screennail set attribute data %p, size %zu, ret %x", &scrnail, sizeof(scrnail), ret);
+ } else {
+ MMCAM_LOG_INFO("Sample3 has wrong pointer. Not Error. (sample3=%p)", sample3);
+ mm_attrs_set_data(attrs, attr_index_for_screennail, NULL, 0);
+ }
-#ifdef _MMCAMCORDER_MAKE_THUMBNAIL_INTERNAL_ENCODE
- /* make thumbnail image */
- _mmcam_dbg_log("Make thumbnail image");
+ /* commit screennail data */
+ mm_attrs_commit(attrs, attr_index_for_screennail);
- if (dest.width > THUMBNAIL_WIDTH) {
- float img_ratio = (float)dest.width / (float)dest.height;
+ /* init thumb data */
+ memset(&encode_src, 0x0, sizeof(MMCamcorderCaptureDataType));
- _mmcam_dbg_log("image ratio %f , default ratio %f", img_ratio, THUMBNAIL_DEFAULT_RATIO);
+ /* get provide-exif */
+ MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "provide-exif", &provide_exif);
- if (img_ratio > THUMBNAIL_DEFAULT_RATIO) {
- thumb_height = THUMBNAIL_HEIGHT;
- thumb_width = (thumb_height * dest.width) / dest.height;
+ /* Thumbnail image buffer */
+ if (sample2 && mapinfo2.data && (mapinfo2.size != 0)) {
+ MMCAM_LOG_INFO("Thumbnail (buffer2=%p)", gst_sample_get_buffer(sample2));
+ pixtype_thumb = _mmcamcorder_get_pixel_format(gst_sample_get_caps(sample2));
+ __mmcamcorder_get_capture_data_from_buffer(&thumb, pixtype_thumb, sample2);
+ } else {
+ MMCAM_LOG_INFO("Sample2 has wrong pointer. Not Error. (sample2 %p)", sample2);
+
+ if (pixtype_main == MM_PIXEL_FORMAT_ENCODED && provide_exif) {
+ ExifLoader *l;
+ /* get thumbnail from EXIF */
+ l = exif_loader_new();
+ if (l) {
+ ExifData *ed;
+ char width[10];
+ char height[10];
+ ExifEntry *entry = NULL;
+
+ exif_loader_write(l, dest.data, dest.length);
+
+ /* Get a pointer to the EXIF data */
+ ed = exif_loader_get_data(l);
+
+ /* The loader is no longer needed--free it */
+ exif_loader_unref(l);
+ l = NULL;
+ if (ed) {
+ entry = exif_content_get_entry(ed->ifd[EXIF_IFD_1], EXIF_TAG_IMAGE_WIDTH);
+ if (entry != NULL)
+ exif_entry_get_value(entry, width, 10);
+
+ entry = NULL;
+ entry = exif_content_get_entry(ed->ifd[EXIF_IFD_1], EXIF_TAG_IMAGE_LENGTH);
+ if (entry != NULL)
+ exif_entry_get_value(entry, height, 10);
+
+ entry = NULL;
+ /* Make sure the image had a thumbnail before trying to write it */
+ if (ed->data && ed->size) {
+ thumb.data = malloc(ed->size);
+ if (thumb.data) {
+ memcpy(thumb.data, ed->data, ed->size);
+ thumb.length = ed->size;
+ thumb.format = MM_PIXEL_FORMAT_ENCODED;
+ thumb.width = atoi(width);
+ thumb.height = atoi(height);
+ internal_thumb_data = thumb.data;
+ } else {
+ MMCAM_LOG_ERROR("failed to alloc thumbnail data");
+ }
+ }
+ exif_data_unref(ed);
+ ed = NULL;
+ } else {
+ MMCAM_LOG_WARNING("failed to get exif data");
+ }
} else {
- thumb_width = THUMBNAIL_WIDTH;
- thumb_height = (thumb_width * dest.height) / dest.width;
+ MMCAM_LOG_WARNING("failed to create exif loader");
}
+ }
- _mmcam_dbg_log("need to resize : thumbnail size %dx%d", thumb_width, thumb_height);
-
- if (!_mmcamcorder_resize_frame(GST_BUFFER_DATA(buffer1), dest.width, dest.height, GST_BUFFER_SIZE(buffer1), pixtype,
- &thumb_raw_data, &thumb_width, &thumb_height, &thumb_length)) {
- thumb_raw_data = NULL;
- _mmcam_dbg_warn("_mmcamcorder_resize_frame failed. skip thumbnail making...");
+ if (thumb.data == NULL) {
+ if (pixtype_main == MM_PIXEL_FORMAT_ENCODED &&
+ scrnail.data && scrnail.length != 0) {
+ /* make thumbnail image with screennail data */
+ memcpy(&encode_src, &scrnail, sizeof(MMCamcorderCaptureDataType));
+ } else if (sc->internal_encode) {
+ /* make thumbnail image with main data, this is raw data */
+ memcpy(&encode_src, &dest, sizeof(MMCamcorderCaptureDataType));
}
- } else {
- thumb_width = dest.width;
- thumb_height = dest.height;
-
- _mmcam_dbg_log("NO need to resize : thumbnail size %dx%d", thumb_width, thumb_height);
-
- thumb_raw_data = GST_BUFFER_DATA(buffer1);
}
- if (thumb_raw_data) {
- __ta__(" _mmcamcorder_encode_jpeg:THUMBNAIL",
- ret = _mmcamcorder_encode_jpeg(thumb_raw_data, thumb_width, thumb_height,
- pixtype, thumb_length, THUMBNAIL_JPEG_QUALITY, &(thumb.data), &(thumb.length));
- );
- if (ret) {
- _mmcam_dbg_log("encode THUMBNAIL done - data %p, length %d", thumb.data, thumb.length);
+ /* encode thumbnail */
+ if (encode_src.data) {
+ size_t thumb_length = 0;
+ unsigned int thumb_width = 0;
+ unsigned int thumb_height = 0;
+ unsigned char *thumb_raw_data = NULL;
- thumb.width = thumb_width;
- thumb.height = thumb_height;
- thumb.format = MM_PIXEL_FORMAT_ENCODED;
+ /* encode image */
+ MMCAM_LOG_INFO("Encode Thumbnail");
+
+ if (encode_src.width > THUMBNAIL_WIDTH) {
+ /* calculate thumbnail size */
+ thumb_width = THUMBNAIL_WIDTH;
+ thumb_height = (thumb_width * encode_src.height) / encode_src.width;
+ if (thumb_height % 2 != 0)
+ thumb_height += 1;
+
+ MMCAM_LOG_INFO("need to resize : thumbnail size %dx%d, format %d",
+ thumb_width, thumb_height, encode_src.format);
+
+ if ((encode_src.format == MM_PIXEL_FORMAT_UYVY ||
+ encode_src.format == MM_PIXEL_FORMAT_YUYV) &&
+ encode_src.width % thumb_width == 0 &&
+ encode_src.height % thumb_height == 0) {
+ if (!_mmcamcorder_downscale_UYVYorYUYV(encode_src.data, encode_src.width, encode_src.height,
+ &thumb_raw_data, thumb_width, thumb_height)) {
+ thumb_raw_data = NULL;
+ MMCAM_LOG_WARNING("_mmcamcorder_downscale_UYVYorYUYV failed. skip thumbnail making...");
+ }
+ } else {
+ if (!_mmcamcorder_resize_frame(encode_src.data, encode_src.width, encode_src.height,
+ encode_src.length, encode_src.format,
+ &thumb_raw_data, &thumb_width, &thumb_height, &thumb_length)) {
+ thumb_raw_data = NULL;
+ MMCAM_LOG_WARNING("_mmcamcorder_resize_frame failed. skip thumbnail making...");
+ }
+ }
} else {
- _mmcam_dbg_warn("failed to encode THUMBNAIL");
- }
+ thumb_width = encode_src.width;
+ thumb_height = encode_src.height;
+
+ MMCAM_LOG_INFO("NO need to resize : thumbnail size %dx%d", thumb_width, thumb_height);
- if (thumb_raw_data != GST_BUFFER_DATA(buffer1)) {
- free(thumb_raw_data);
- thumb_raw_data = NULL;
- _mmcam_dbg_log("release thumb_raw_data");
+ thumb_raw_data = encode_src.data;
+ thumb_length = encode_src.length;
}
- } else {
- _mmcam_dbg_warn("thumb_raw_data is NULL");
- }
-#endif /* _MMCAMCORDER_MAKE_THUMBNAIL_INTERNAL_ENCODE */
- } else {
- /* Thumbnail image buffer */
- if (buffer2 && GST_BUFFER_DATA(buffer2) && (GST_BUFFER_SIZE(buffer2) !=0)) {
- _mmcam_dbg_log("Thumnail (buffer2=%p)",buffer2);
- pixtype_sub = _mmcamcorder_get_pixel_format(buffer2);
- __mmcamcorder_get_capture_data_from_buffer(&thumb, pixtype_sub, buffer2);
+ if (thumb_raw_data) {
+ ret = _mmcamcorder_encode_jpeg(thumb_raw_data, thumb_width, thumb_height,
+ encode_src.format, thumb_length, THUMBNAIL_JPEG_QUALITY,
+ (void **)&internal_thumb_data, &internal_thumb_length);
+ if (ret) {
+ MMCAM_LOG_INFO("encode THUMBNAIL done - data %p, length %d", internal_thumb_data, internal_thumb_length);
+
+ thumb.data = internal_thumb_data;
+ thumb.length = internal_thumb_length;
+ thumb.width = thumb_width;
+ thumb.height = thumb_height;
+ thumb.format = MM_PIXEL_FORMAT_ENCODED;
+ } else {
+ MMCAM_LOG_WARNING("failed to encode THUMBNAIL");
+ }
+
+ /* release allocated raw data memory */
+ if (thumb_raw_data != encode_src.data) {
+ free(thumb_raw_data);
+ thumb_raw_data = NULL;
+ MMCAM_LOG_INFO("release thumb_raw_data");
+ }
+ } else {
+ MMCAM_LOG_WARNING("thumb_raw_data is NULL");
+ }
} else {
- _mmcam_dbg_log("buffer2 has wrong pointer. Not Error. (buffer2=%p)",buffer2);
+ /* no raw data src for thumbnail */
+ MMCAM_LOG_INFO("no need to encode thumbnail");
}
}
- /* Screennail image buffer */
- attrs = (mmf_attrs_t*)MMF_CAMCORDER_ATTRS(hcamcorder);
- mm_attrs_get_index((MMHandleType)attrs, MMCAM_CAPTURED_SCREENNAIL, &attr_index);
- item_screennail = &attrs->items[attr_index];
+ /* Encode JPEG */
+ if (sc->internal_encode && pixtype_main != MM_PIXEL_FORMAT_ENCODED) {
+ mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
+ MMCAM_IMAGE_ENCODER_QUALITY, &capture_quality,
+ NULL);
+ MMCAM_LOG_INFO("Start Internal Encode - capture_quality %d", capture_quality);
- if (buffer3 && GST_BUFFER_DATA(buffer3) && GST_BUFFER_SIZE(buffer3) != 0) {
- _mmcam_dbg_log("Screennail (buffer3=%p,size=%d)", buffer3, GST_BUFFER_SIZE(buffer3));
+ ret = _mmcamcorder_encode_jpeg(mapinfo1.data, dest.width, dest.height,
+ pixtype_main, dest.length, capture_quality,
+ (void **)&internal_main_data, &internal_main_length);
+ if (!ret) {
+ MMCAM_LOG_ERROR("_mmcamcorder_encode_jpeg failed");
- pixtype_sub = _mmcamcorder_get_pixel_format(buffer3);
- __mmcamcorder_get_capture_data_from_buffer(&scrnail, pixtype_sub, buffer3);
+ MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INTERNAL);
- /* Set screennail attribute for application */
- ret = mmf_attribute_set_data(item_screennail, &scrnail, sizeof(scrnail));
- _mmcam_dbg_log("Screennail set attribute data %p, size %d, ret %x", &scrnail, sizeof(scrnail), ret);
- } else {
- _mmcam_dbg_log("buffer3 has wrong pointer. Not Error. (buffer3=%p)",buffer3);
- mmf_attribute_set_data(item_screennail, NULL, 0);
+ goto error;
+ }
+
+ /* set format */
+ dest.data = internal_main_data;
+ dest.length = internal_main_length;
+ dest.format = MM_PIXEL_FORMAT_ENCODED;
+
+ MMCAM_LOG_INFO("Done Internal Encode - data %p, length %d", dest.data, dest.length);
}
- /* commit screennail data */
- mmf_attribute_commit(item_screennail);
+ if (info->capture_format != MM_PIXEL_FORMAT_ENCODED) {
+ MMCAM_LOG_INFO("not encoded format, skip exif related sequence");
+ goto _CAPTURE_CB_EXIF_DONE;
+ }
/* create EXIF info */
- __ta__(" mm_exif_create_exif_info",
- ret = mm_exif_create_exif_info(&(hcamcorder->exif_info));
- );
+ if (!provide_exif) { /* make new exif */
+ ret = mm_exif_create_exif_info(&(hcamcorder->exif_info));
+ } else { /* load from jpeg buffer dest.data */
+ ret = mm_exif_load_exif_info(&(hcamcorder->exif_info), dest.data, dest.length);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("Failed to load exif_info [%x], try to create EXIF", ret);
+ provide_exif = FALSE;
+ ret = mm_exif_create_exif_info(&(hcamcorder->exif_info));
+ }
+ }
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("Failed to create exif_info [%x], but keep going...", ret);
+ MMCAM_LOG_ERROR("Failed to create exif_info [%x], but keep going...", ret);
} else {
/* add basic exif info */
- _mmcam_dbg_log("add basic exif info");
- __ta__(" __mmcamcorder_set_exif_basic_info",
- ret = __mmcamcorder_set_exif_basic_info((MMHandleType)hcamcorder, dest.width, dest.height);
- );
+ if (!provide_exif) {
+ MMCAM_LOG_INFO("add basic exif info");
+ ret = __mmcamcorder_set_exif_basic_info((MMHandleType)hcamcorder, dest.width, dest.height);
+ } else {
+ MMCAM_LOG_INFO("update exif info");
+ ret = __mmcamcorder_update_exif_info((MMHandleType)hcamcorder, dest.data, dest.length);
+ }
+
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Failed set_exif_basic_info [%x], but keep going...", ret);
+ MMCAM_LOG_WARNING("Failed set_exif_basic_info [%x], but keep going...", ret);
ret = MM_ERROR_NONE;
}
}
/* get attribute item for EXIF data */
- mm_attrs_get_index((MMHandleType)attrs, MMCAM_CAPTURED_EXIF_RAW_DATA, &attr_index);
- item_exif_raw_data = &attrs->items[attr_index];
+ mm_attrs_get_index((MMHandleType)attrs, MMCAM_CAPTURED_EXIF_RAW_DATA, &attr_index_for_exif);
/* set EXIF data to attribute */
if (hcamcorder->exif_info && hcamcorder->exif_info->data) {
exif_raw_data = (unsigned char *)malloc(hcamcorder->exif_info->size);
if (exif_raw_data) {
memcpy(exif_raw_data, hcamcorder->exif_info->data, hcamcorder->exif_info->size);
- mmf_attribute_set_data(item_exif_raw_data, exif_raw_data, hcamcorder->exif_info->size);
- _mmcam_dbg_log("set EXIF raw data %p, size %d", exif_raw_data, hcamcorder->exif_info->size);
+ mm_attrs_set_data(attrs, attr_index_for_exif, exif_raw_data, hcamcorder->exif_info->size);
+ MMCAM_LOG_INFO("set EXIF raw data %p, size %d", exif_raw_data, hcamcorder->exif_info->size);
} else {
- _mmcam_dbg_warn("failed to alloc for EXIF, size %d", hcamcorder->exif_info->size);
+ MMCAM_LOG_WARNING("failed to alloc for EXIF, size %d", hcamcorder->exif_info->size);
}
} else {
- _mmcam_dbg_warn("failed to create EXIF. set EXIF as NULL");
- mmf_attribute_set_data(item_exif_raw_data, NULL, 0);
+ MMCAM_LOG_WARNING("failed to create EXIF. set EXIF as NULL");
+ mm_attrs_set_data(attrs, attr_index_for_exif, NULL, 0);
}
/* commit EXIF data */
- mmf_attribute_commit(item_exif_raw_data);
+ mm_attrs_commit(attrs, attr_index_for_exif);
- /* get tag-enable and provide-exif */
+ /* get tag-enable */
mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL, MMCAM_TAG_ENABLE, &tag_enable, NULL);
- MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "provide-exif", &provide_exif);
/* Set extra data for JPEG if tag enabled and doesn't provide EXIF */
- if (dest.format == MM_PIXEL_FORMAT_ENCODED &&
- tag_enable && !provide_exif) {
+ if (tag_enable) {
mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
- MMCAM_IMAGE_ENCODER, &codectype,
- NULL);
- _mmcam_dbg_log("codectype %d", codectype);
+ MMCAM_IMAGE_ENCODER, &codectype,
+ NULL);
+ MMCAM_LOG_INFO("codectype %d", codectype);
switch (codectype) {
case MM_IMAGE_CODEC_JPEG:
case MM_IMAGE_CODEC_SRW:
case MM_IMAGE_CODEC_JPEG_SRW:
- __ta__( " __mmcamcorder_set_jpeg_data",
- ret = __mmcamcorder_set_jpeg_data((MMHandleType)hcamcorder, &dest, &thumb);
- );
+ ret = __mmcamcorder_set_jpeg_data((MMHandleType)hcamcorder, &dest, &thumb, provide_exif);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("Error on setting extra data to jpeg");
+ MMCAM_LOG_ERROR("Error on setting extra data to jpeg");
MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, ret);
goto error;
}
break;
default:
- _mmcam_dbg_err("The codectype is not supported. (%d)", codectype);
-
+ MMCAM_LOG_ERROR("The codectype is not supported. (%d)", codectype);
MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INTERNAL);
-
goto error;
}
}
+_CAPTURE_CB_EXIF_DONE:
+
/* Handle Capture Callback */
_MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(hcamcorder);
if (hcamcorder->vcapture_cb) {
- _mmcam_dbg_log("APPLICATION CALLBACK START");
- MMTA_ACUM_ITEM_BEGIN(" Application capture callback", 0);
- if (thumb.data) {
+ MMCAM_LOG_INFO("APPLICATION CALLBACK START");
+ if (thumb.data)
ret = hcamcorder->vcapture_cb(&dest, &thumb, hcamcorder->vcapture_cb_param);
- } else {
+ else
ret = hcamcorder->vcapture_cb(&dest, NULL, hcamcorder->vcapture_cb_param);
- }
- MMTA_ACUM_ITEM_END(" Application capture callback", 0);
- _mmcam_dbg_log("APPLICATION CALLBACK END");
+
+ MMCAM_LOG_INFO("APPLICATION CALLBACK END");
} else {
- _mmcam_dbg_err("Capture callback is NULL.");
+ MMCAM_LOG_ERROR("Capture callback is NULL.");
MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
_MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(hcamcorder);
/* init screennail and EXIF raw data */
- __ta__(" init attributes:scrnl and EXIF",
- mmf_attribute_set_data(item_screennail, NULL, 0);
- mmf_attribute_commit(item_screennail);
+ mm_attrs_set_data(attrs, attr_index_for_screennail, NULL, 0);
+ mm_attrs_commit(attrs, attr_index_for_screennail);
if (exif_raw_data) {
free(exif_raw_data);
exif_raw_data = NULL;
- mmf_attribute_set_data(item_exif_raw_data, NULL, 0);
- mmf_attribute_commit(item_exif_raw_data);
+ mm_attrs_set_data(attrs, attr_index_for_exif, NULL, 0);
+ mm_attrs_commit(attrs, attr_index_for_exif);
}
- );
/* Release jpeg data */
- if (pixtype == MM_PIXEL_FORMAT_ENCODED) {
- __ta__(" __mmcamcorder_release_jpeg_data",
- __mmcamcorder_release_jpeg_data((MMHandleType)hcamcorder, &dest);
- );
- }
+ if (pixtype_main == MM_PIXEL_FORMAT_ENCODED)
+ __mmcamcorder_release_jpeg_data((MMHandleType)hcamcorder, &dest, tag_enable, provide_exif);
error:
/* Check end condition and set proper value */
}
/* release internal allocated data */
- if (sc->internal_encode) {
- if (dest.data) {
- free(dest.data);
- dest.data = NULL;
- dest.length = 0;
- _mmcam_dbg_log("release internal encoded data MAIN");
- }
- if (thumb.data) {
- free(thumb.data);
- thumb.data = NULL;
- thumb.length = 0;
- _mmcam_dbg_log("release internal encoded data THUMB");
- }
+ if (sc->internal_encode)
+ compare_data = internal_main_data;
+ else
+ compare_data = mapinfo1.data;
+
+ if (dest.data && compare_data &&
+ dest.data != compare_data) {
+ MMCAM_LOG_INFO("release internal allocated data %p", dest.data);
+ free(dest.data);
+ dest.data = NULL;
+ dest.length = 0;
+ }
+ if (internal_main_data) {
+ MMCAM_LOG_INFO("release internal main data %p", internal_main_data);
+ free(internal_main_data);
+ internal_main_data = NULL;
}
+ if (internal_thumb_data) {
+ MMCAM_LOG_INFO("release internal thumb data %p", internal_thumb_data);
+ free(internal_thumb_data);
+ internal_thumb_data = NULL;
+ }
+
+ /* reset compare_data */
+ compare_data = NULL;
/*free GstBuffer*/
- if (buffer1) {
- gst_buffer_unref(buffer1);
+ if (sample1) {
+ gst_buffer_unmap(gst_sample_get_buffer(sample1), &mapinfo1);
+ gst_sample_unref(sample1);
}
- if (buffer2) {
- gst_buffer_unref(buffer2);
+ if (sample2) {
+ gst_buffer_unmap(gst_sample_get_buffer(sample2), &mapinfo2);
+ gst_sample_unref(sample2);
}
- if (buffer3) {
- gst_buffer_unref(buffer3);
+ if (sample3) {
+ gst_buffer_unmap(gst_sample_get_buffer(sample3), &mapinfo3);
+ gst_sample_unref(sample3);
}
/* destroy exif info */
- __ta__(" mm_exif_destory_exif_info",
mm_exif_destory_exif_info(hcamcorder->exif_info);
- );
hcamcorder->exif_info = NULL;
/* send captured message */
if (send_captured_message) {
- MMTA_ACUM_ITEM_BEGIN(" CAPTURED MESSAGE DELAY", FALSE);
-
if (info->hdr_capture_mode != MM_CAMCORDER_HDR_ON_AND_ORIGINAL) {
- MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
-
- mm_camcorder_get_state((MMHandleType)hcamcorder, ¤t_state);
-
/* Send CAPTURED message and count - capture success */
- if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
+ if (current_state >= MM_CAMCORDER_STATE_RECORDING)
MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED, count);
- } else {
+ else
MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_CAPTURED, count);
- }
} else if (info->hdr_capture_mode == MM_CAMCORDER_HDR_ON_AND_ORIGINAL && count == 2) {
/* send captured message only once in HDR and Original Capture mode */
MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_CAPTURED, 1);
}
}
- MMTA_ACUM_ITEM_END( " MSL capture callback", FALSE );
+ if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
+ /* Handle capture in recording case */
+ hcamcorder->capture_in_recording = FALSE;
+
+ g_mutex_lock(&hcamcorder->task_thread_lock);
+
+ if (hcamcorder->task_thread_state == _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING) {
+ MMCAM_LOG_INFO("send signal for capture in recording");
+ g_cond_signal(&hcamcorder->task_thread_cond);
+ } else {
+ MMCAM_LOG_WARNING("unexpected task thread state : %d", hcamcorder->task_thread_state);
+ }
+
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
+
+ _MMCAMCORDER_CMD_SIGNAL(hcamcorder);
+ }
- _mmcam_dbg_err("END");
+ MMCAM_LOG_ERROR("END");
return;
}
-static gboolean __mmcamcorder_encodesink_handoff_callback(GstElement *fakesink, GstBuffer *buffer, GstPad *pad, gpointer u_data)
+static void __mmcamcorder_extra_preview_stream_cb(GstElement *element, int stream_id, GstSample *sample, gpointer u_data)
+{
+ if (!sample) {
+ MMCAM_LOG_ERROR("NULL sample for extra preview[id:%d]", stream_id);
+ return;
+ }
+
+ /* no need to check return value here */
+ _mmcamcorder_invoke_video_stream_cb((MMHandleType)u_data, sample, TRUE, stream_id);
+
+ gst_sample_unref(sample);
+}
+
+
+gboolean __mmcamcorder_handoff_callback(GstElement *fakesink, GstBuffer *buffer, GstPad *pad, gpointer u_data)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
_MMCamcorderSubContext *sc = NULL;
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
mmf_return_val_if_fail(sc && sc->element, FALSE);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* FIXME. How could you get a thumbnail? */
- __mmcamcorder_image_capture_cb(fakesink, buffer, NULL, NULL, u_data);
+ __mmcamcorder_image_capture_cb(fakesink, gst_sample_new(buffer, gst_pad_get_current_caps(pad), NULL, NULL), NULL, NULL, u_data);
- if (sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_SINK].gst, "signal-handoffs", FALSE);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", TRUE);
+ if (sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst) {
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "signal-handoffs", FALSE);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", TRUE);
+ sc->info_video->push_encoding_buffer = PUSH_ENCODING_BUFFER_STOP;
}
return TRUE;
}
-/* Take a picture with capture mode */
-int _mmcamcorder_set_resize_property(MMHandleType handle, int capture_width, int capture_height)
+static ExifData *__mmcamcorder_update_exif_orientation(MMHandleType handle, ExifData *ed)
{
- int ELEMENT_CROP = 0;
- int ELEMENT_FILTER = 0;
-
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _MMCamcorderSubContext *sc = NULL;
-
- _mmcam_dbg_log("");
-
- mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
-
- sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ int value = 0;
+ ExifShort eshort = 0;
+ int ret = MM_ERROR_NONE;
- ELEMENT_CROP = _MMCAMCORDER_ENCSINK_ICROP;
- ELEMENT_FILTER = _MMCAMCORDER_ENCSINK_IFILT;
+ mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_ORIENTATION, &value, NULL);
+ MMCAM_LOG_INFO("get orientation [%d]", value);
+ if (value == 0)
+ value = MM_EXIF_ORIENTATION;
- /*TODO: this is not needed now. */
+ exif_set_short((unsigned char *)&eshort, exif_data_get_byte_order(ed), value);
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_ORIENTATION,
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_MAKER_NOTE);
- return MM_ERROR_NONE;
+exit:
+ return ed;
}
-int __mmcamcorder_set_exif_basic_info(MMHandleType handle, int image_width, int image_height)
+static ExifData *__mmcamcorder_update_exif_make(MMHandleType handle, ExifData *ed)
{
int ret = MM_ERROR_NONE;
- int value;
- int str_val_len = 0;
- int gps_enable = TRUE;
- int cntl = 0;
- int cnts = 0;
- double f_latitude = INVALID_GPS_VALUE;
- double f_longitude = INVALID_GPS_VALUE;
- double f_altitude = INVALID_GPS_VALUE;
- char *str_value = NULL;
-#ifdef WRITE_EXIF_MAKER_INFO /* FIXME */
- char *maker = NULL;
-#endif
- char *user_comment = NULL;
- char *err_name = NULL;
- ExifData *ed = NULL;
- ExifLong config;
- ExifLong ExifVersion;
- static ExifShort eshort[20];
- static ExifLong elong[10];
+ char *make = strdup(MM_MAKER_NAME);
- GstCameraControl *control = NULL;
- GstCameraControlExifInfo avsys_exif_info;
+ if (make) {
+ MMCAM_LOG_INFO("maker [%s]", make);
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_MAKE,
+ EXIF_FORMAT_ASCII, strlen(make)+1, (const char *)make);
+ free(make);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_MAKE);
+ } else {
+ MMCAM_LOG_ERROR("strdup failed [%s]", MM_MAKER_NAME);
+ }
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _MMCamcorderSubContext *sc = NULL;
+exit:
+ return ed;
+}
- _mmcam_dbg_log("");
- mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+static ExifData *__mmcamcorder_update_exif_software(MMHandleType handle, ExifData *ed)
+{
+ int ret = MM_ERROR_NONE;
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)handle;
- sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ if (hcamcorder == NULL || ed == NULL) {
+ MMCAM_LOG_ERROR("NULL parameter %p,%p", hcamcorder, ed);
+ return NULL;
+ }
- CLEAR(avsys_exif_info);
+ if (hcamcorder->software_version) {
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_SOFTWARE, EXIF_FORMAT_ASCII,
+ strlen(hcamcorder->software_version)+1, (const char *)hcamcorder->software_version);
- if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- _mmcam_dbg_err("Can't cast Video source into camera control. Skip camera control values...");
+ MMCAM_LOG_INFO("set software_version[%s] ret[0x%x]",
+ hcamcorder->software_version, ret);
} else {
- control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
- /* get device information */
- __ta__(" gst_camera_control_get_exif_info",
- gst_camera_control_get_exif_info(control, &avsys_exif_info);
- );
+ MMCAM_LOG_ERROR("model_name is NULL");
}
- /* get ExifData from exif info */
- __ta__(" mm_exif_get_exif_from_info",
- ed = mm_exif_get_exif_from_info(hcamcorder->exif_info);
- );
- if (ed == NULL || ed->ifd == NULL) {
- _mmcam_dbg_err("get exif data error!!(%p, %p)", ed, (ed ? ed->ifd : NULL));
- return MM_ERROR_INVALID_HANDLE;
- }
+ return ed;
+}
- /* Receive attribute info */
- /* START INSERT IFD_0 */
+static ExifData *__mmcamcorder_update_exif_model(MMHandleType handle, ExifData *ed)
+{
+ int ret = MM_ERROR_NONE;
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)handle;
- /*0. EXIF_TAG_EXIF_VERSION */
- ExifVersion = MM_EXIF_VERSION;
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_EXIF_VERSION,
- EXIF_FORMAT_UNDEFINED, 4, (unsigned char *)&ExifVersion);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_EXIF_VERSION);
+ if (hcamcorder == NULL || ed == NULL) {
+ MMCAM_LOG_ERROR("NULL parameter %p,%p", hcamcorder, ed);
+ return NULL;
}
- /*1. EXIF_TAG_IMAGE_WIDTH */ /*EXIF_TAG_PIXEL_X_DIMENSION*/
- value = image_width;
-
- exif_set_long((unsigned char *)&elong[cntl], exif_data_get_byte_order(ed), value);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_WIDTH,
- EXIF_FORMAT_LONG, 1, (unsigned char *)&elong[cntl]);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_IMAGE_WIDTH);
- }
+ if (hcamcorder->model_name) {
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_MODEL, EXIF_FORMAT_ASCII,
+ strlen(hcamcorder->model_name)+1, (const char *)hcamcorder->model_name);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION,
- EXIF_FORMAT_LONG, 1, (unsigned char *)&elong[cntl++]);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_PIXEL_X_DIMENSION);
+ MMCAM_LOG_ERROR("set model name[%s] ret[0x%x]",
+ hcamcorder->model_name, ret);
+ } else {
+ MMCAM_LOG_ERROR("model_name is NULL");
}
- _mmcam_dbg_log("width[%d]", value);
- /*2. EXIF_TAG_IMAGE_LENGTH*/ /*EXIF_TAG_PIXEL_Y_DIMENSION*/
- value = image_height;
-
- exif_set_long((unsigned char *)&elong[cntl], exif_data_get_byte_order (ed), value);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_LENGTH,
- EXIF_FORMAT_LONG, 1, (unsigned char *)&elong[cntl]);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_IMAGE_LENGTH);
- }
+ return ed;
+}
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION,
- EXIF_FORMAT_LONG, 1, (unsigned char *)&elong[cntl++]);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_PIXEL_Y_DIMENSION);
- }
- _mmcam_dbg_log("height[%d]", value);
+static ExifData *__mmcamcorder_update_exif_gps(MMHandleType handle, ExifData *ed)
+{
+ int ret = MM_ERROR_NONE;
+ int gps_enable = TRUE;
+ char *err_name = NULL;
+ double latitude = INVALID_GPS_VALUE;
+ double longitude = INVALID_GPS_VALUE;
+ double altitude = INVALID_GPS_VALUE;
- /*4. EXIF_TAG_DATE_TIME */
+ ret = mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_GPS_ENABLE, &gps_enable, NULL);
+ if (ret == MM_ERROR_NONE && gps_enable) {
+ ExifByte GpsVersion[4] = {2, 2, 0, 0};
- /*12. EXIF_TAG_DATE_TIME_ORIGINAL */
+ MMCAM_LOG_INFO("Tag for GPS is ENABLED.");
- /*13. EXIF_TAG_DATE_TIME_DIGITIZED*/
- {
- unsigned char *b;
- time_t t;
- struct tm tm;
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_VERSION_ID,
+ EXIF_FORMAT_BYTE, 4, (const char *)&GpsVersion);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_VERSION_ID);
- b = malloc(20 * sizeof(unsigned char));
- if (b == NULL) {
- _mmcam_dbg_err("failed to alloc b");
- ret = MM_ERROR_CAMCORDER_LOW_MEMORY;
- EXIF_SET_ERR(ret, EXIF_TAG_DATE_TIME);
+ ret = mm_camcorder_get_attributes(handle, &err_name,
+ MMCAM_TAG_LATITUDE, &latitude,
+ MMCAM_TAG_LONGITUDE, &longitude,
+ MMCAM_TAG_ALTITUDE, &altitude, NULL);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("failed to get gps info [%x][%s]", ret, err_name);
+ SAFE_FREE(err_name);
+ goto exit;
}
- memset(b, '\0', 20);
-
- t = time(NULL);
- tzset();
- localtime_r(&t, &tm);
+ MMCAM_LOG_INFO("latitude [%f]", latitude);
+ if (latitude != INVALID_GPS_VALUE) {
+ unsigned char *b = NULL;
+ unsigned int deg;
+ unsigned int min;
+ unsigned int sec;
+ ExifRational rData;
- snprintf((char *)b, 20, "%04i:%02i:%02i %02i:%02i:%02i",
- tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec);
+ if (latitude < 0) {
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF,
+ EXIF_FORMAT_ASCII, 2, "S");
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_LATITUDE_REF);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, 20, b);
- if (ret != MM_ERROR_NONE) {
- if (ret == MM_ERROR_CAMCORDER_LOW_MEMORY) {
- free(b);
+ latitude = -latitude;
+ } else if (latitude > 0) {
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF,
+ EXIF_FORMAT_ASCII, 2, "N");
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_LATITUDE_REF);
}
- EXIF_SET_ERR(ret, EXIF_TAG_DATE_TIME);
- }
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL, EXIF_FORMAT_ASCII, 20, b);
- if (ret != MM_ERROR_NONE) {
- if (ret == MM_ERROR_CAMCORDER_LOW_MEMORY) {
- free(b);
- }
- EXIF_SET_ERR(ret, EXIF_TAG_DATE_TIME_ORIGINAL);
+ deg = (unsigned int)(latitude);
+ min = (unsigned int)((latitude-deg) * 60);
+ sec = (unsigned int)(((latitude-deg) * 3600) - min * 60);
+
+ MMCAM_LOG_INFO("f_latitude deg[%d], min[%d], sec[%d]", deg, min, sec);
+ b = malloc(3 * sizeof(ExifRational));
+ if (b) {
+ rData.numerator = deg;
+ rData.denominator = 1;
+ exif_set_rational(b, exif_data_get_byte_order(ed), rData);
+ rData.numerator = min;
+ exif_set_rational(b + 8, exif_data_get_byte_order(ed), rData);
+ rData.numerator = sec;
+ exif_set_rational(b + 16, exif_data_get_byte_order(ed), rData);
+
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE,
+ EXIF_FORMAT_RATIONAL, 3, (const char *)b);
+ free(b);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_LATITUDE);
+ } else {
+ MMCAM_LOG_WARNING("malloc failed");
+ }
}
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_DIGITIZED, EXIF_FORMAT_ASCII, 20, b);
- if (ret != MM_ERROR_NONE) {
- if (ret == MM_ERROR_CAMCORDER_LOW_MEMORY) {
+ MMCAM_LOG_INFO("longitude [%f]", longitude);
+ if (longitude != INVALID_GPS_VALUE) {
+ unsigned char *b = NULL;
+ unsigned int deg;
+ unsigned int min;
+ unsigned int sec;
+ ExifRational rData;
+
+ if (longitude < 0) {
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF,
+ EXIF_FORMAT_ASCII, 2, "W");
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_LONGITUDE_REF);
+
+ longitude = -longitude;
+ } else if (longitude > 0) {
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF,
+ EXIF_FORMAT_ASCII, 2, "E");
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_LONGITUDE_REF);
+ }
+
+ deg = (unsigned int)(longitude);
+ min = (unsigned int)((longitude-deg) * 60);
+ sec = (unsigned int)(((longitude-deg) * 3600) - min * 60);
+
+ MMCAM_LOG_INFO("longitude deg[%d], min[%d], sec[%d]", deg, min, sec);
+ b = malloc(3 * sizeof(ExifRational));
+ if (b) {
+ rData.numerator = deg;
+ rData.denominator = 1;
+ exif_set_rational(b, exif_data_get_byte_order(ed), rData);
+ rData.numerator = min;
+ exif_set_rational(b+8, exif_data_get_byte_order(ed), rData);
+ rData.numerator = sec;
+ exif_set_rational(b+16, exif_data_get_byte_order(ed), rData);
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE,
+ EXIF_FORMAT_RATIONAL, 3, (const char *)b);
free(b);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_LONGITUDE);
+ } else {
+ MMCAM_LOG_WARNING("malloc failed");
}
- EXIF_SET_ERR(ret, EXIF_TAG_DATE_TIME_DIGITIZED);
}
- free(b);
- }
+ MMCAM_LOG_INFO("f_altitude [%f]", altitude);
+ if (altitude != INVALID_GPS_VALUE) {
+ ExifByte alt_ref = 0;
+ unsigned char *b = NULL;
+ ExifRational rData;
+ b = malloc(sizeof(ExifRational));
+ if (b) {
+ if (altitude < 0) {
+ alt_ref = 1;
+ altitude = -altitude;
+ }
-#ifdef WRITE_EXIF_MAKER_INFO /* FIXME */
- /*5. EXIF_TAG_MAKE */
- maker = strdup(MM_MAKER_NAME);
- if (maker) {
- _mmcam_dbg_log("maker [%s]", maker);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_MAKE,
- EXIF_FORMAT_ASCII, strlen(maker), (unsigned char *)maker);
- free(maker);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_MAKE);
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_ALTITUDE_REF,
+ EXIF_FORMAT_BYTE, 1, (const char *)&alt_ref);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("error [%x], tag [%x]", ret, EXIF_TAG_GPS_ALTITUDE_REF);
+ if (ret == (int)MM_ERROR_CAMCORDER_LOW_MEMORY) {
+ free(b);
+ b = NULL;
+ goto exit;
+ }
+ }
+
+ rData.numerator = (unsigned int)(altitude + 0.5)*100;
+ rData.denominator = 100;
+ exif_set_rational(b, exif_data_get_byte_order(ed), rData);
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_ALTITUDE,
+ EXIF_FORMAT_RATIONAL, 1, (const char *)b);
+ free(b);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_ALTITUDE);
+ } else {
+ MMCAM_LOG_WARNING("malloc failed");
+ }
+ }
+
+ {
+ double gps_timestamp = INVALID_GPS_VALUE;
+ mm_camcorder_get_attributes(handle, NULL, "tag-gps-time-stamp", &gps_timestamp, NULL);
+ MMCAM_LOG_INFO("Gps timestamp [%f]", gps_timestamp);
+ if (gps_timestamp > 0.0) {
+ unsigned char *b = NULL;
+ unsigned int hour;
+ unsigned int min;
+ unsigned int microsec;
+ ExifRational rData;
+
+ hour = (unsigned int)(gps_timestamp / 3600);
+ min = (unsigned int)((gps_timestamp - 3600 * hour) / 60);
+ microsec = (unsigned int)(((double)((double)gps_timestamp -(double)(3600 * hour)) -(double)(60 * min)) * 1000000);
+
+ MMCAM_LOG_INFO("Gps timestamp hour[%d], min[%d], microsec[%d]", hour, min, microsec);
+ b = malloc(3 * sizeof(ExifRational));
+ if (b) {
+ rData.numerator = hour;
+ rData.denominator = 1;
+ exif_set_rational(b, exif_data_get_byte_order(ed), rData);
+
+ rData.numerator = min;
+ rData.denominator = 1;
+ exif_set_rational(b + 8, exif_data_get_byte_order(ed), rData);
+
+ rData.numerator = microsec;
+ rData.denominator = 1000000;
+ exif_set_rational(b + 16, exif_data_get_byte_order(ed), rData);
+
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_TIME_STAMP,
+ EXIF_FORMAT_RATIONAL, 3, (const char *)b);
+ free(b);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_TIME_STAMP);
+ } else {
+ MMCAM_LOG_WARNING("malloc failed.");
+ }
+ }
+ }
+
+ {
+ unsigned char *date_stamp = NULL;
+ int date_stamp_len = 0;
+
+ mm_camcorder_get_attributes(handle, NULL, "tag-gps-date-stamp", &date_stamp, &date_stamp_len, NULL);
+
+ if (date_stamp) {
+ MMCAM_LOG_INFO("Date stamp [%s]", date_stamp);
+
+ /* cause it should include NULL char */
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_DATE_STAMP,
+ EXIF_FORMAT_ASCII, date_stamp_len + 1, (const char *)date_stamp);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_DATE_STAMP);
+ }
+ }
+
+ {
+ unsigned char *processing_method = NULL;
+ int processing_method_len = 0;
+
+ mm_camcorder_get_attributes(handle, NULL, "tag-gps-processing-method", &processing_method, &processing_method_len, NULL);
+
+ if (processing_method) {
+ MMCAM_LOG_INFO("Processing method [%s]", processing_method);
+
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_PROCESSING_METHOD,
+ EXIF_FORMAT_UNDEFINED, processing_method_len, (const char *)processing_method);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_GPS_PROCESSING_METHOD);
+ }
}
} else {
- ret = MM_ERROR_CAMCORDER_LOW_MEMORY;
- EXIF_SET_ERR(ret, EXIF_TAG_MAKE);
+ MMCAM_LOG_INFO("Tag for GPS is DISABLED.");
}
- /*6. EXIF_TAG_MODEL */
- _mmcamcorder_conf_get_value_string(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_GENERAL,
- "ModelName",
- &str_value);
- _mmcam_dbg_log("model_name [%s]", str_value);
- if (str_value) {
- char *model = strdup(str_value);
- mm_exif_set_add_entry(ed,EXIF_IFD_0,EXIF_TAG_MODEL,EXIF_FORMAT_ASCII,strlen(model)+1, (unsigned char*)model);
- free(model);
- str_value = NULL;
+exit:
+ return ed;
+}
+
+
+int __mmcamcorder_update_exif_info(MMHandleType handle, void* imagedata, int imgln)
+{
+ int ret = MM_ERROR_NONE;
+ mmf_camcorder_t *hcamcorder = NULL;
+ ExifData *ed = NULL;
+
+ hcamcorder = MMF_CAMCORDER(handle);
+
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+ ed = exif_data_new_from_data(imagedata, imgln);
+ /*ed = mm_exif_get_exif_from_info(hcamcorder->exif_info);*/
+
+ if (ed == NULL) {
+ MMCAM_LOG_ERROR("get exif data error!!");
+ return MM_ERROR_INVALID_HANDLE;
+ }
+
+ /* update necessary */
+
+ __mmcamcorder_update_exif_make(handle, ed);
+ __mmcamcorder_update_exif_software(handle, ed);
+ __mmcamcorder_update_exif_model(handle, ed);
+ __mmcamcorder_update_exif_orientation(handle, ed);
+ __mmcamcorder_update_exif_gps(handle, ed);
+ ret = mm_exif_set_exif_to_info(hcamcorder->exif_info, ed);
+ if (ret != MM_ERROR_NONE)
+ MMCAM_LOG_ERROR("mm_exif_set_exif_to_info err!! [%x]", ret);
+
+ exif_data_unref(ed);
+ ed = NULL;
+ return ret;
+}
+
+int __mmcamcorder_set_exif_basic_info(MMHandleType handle, int image_width, int image_height)
+{
+ int ret = MM_ERROR_NONE;
+ int value;
+ int str_val_len = 0;
+ int cntl = 0;
+ int cnts = 0;
+ char *str_value = NULL;
+ char *user_comment = NULL;
+ ExifData *ed = NULL;
+ ExifLong config;
+ ExifLong ExifVersion;
+ static ExifShort eshort[20];
+ static ExifLong elong[10];
+
+ GstCameraControl *control = NULL;
+ GstCameraControlExifInfo avsys_exif_info;
+
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderSubContext *sc = NULL;
+
+ MMCAM_LOG_INFO("");
+
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+ CLEAR(avsys_exif_info);
+
+ if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
+ MMCAM_LOG_ERROR("Can't cast Video source into camera control. Skip camera control values...");
+ } else {
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ /* get device information */
+ gst_camera_control_get_exif_info(control, &avsys_exif_info);
+ }
+
+ /* get ExifData from exif info */
+ ed = mm_exif_get_exif_from_info(hcamcorder->exif_info);
+ if (ed == NULL) {
+ MMCAM_LOG_ERROR("get exif data error!!");
+ return MM_ERROR_INVALID_HANDLE;
+ }
+
+ /* Receive attribute info */
+
+ /* START INSERT IFD_0 */
+
+ /*0. EXIF_TAG_EXIF_VERSION */
+ ExifVersion = MM_EXIF_VERSION;
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_EXIF_VERSION,
+ EXIF_FORMAT_UNDEFINED, 4, (const char *)&ExifVersion);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_EXIF_VERSION);
+
+ /*1. EXIF_TAG_IMAGE_WIDTH */ /*EXIF_TAG_PIXEL_X_DIMENSION*/
+ value = image_width;
+
+ exif_set_long((unsigned char *)&elong[cntl], exif_data_get_byte_order(ed), value);
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_WIDTH,
+ EXIF_FORMAT_LONG, 1, (const char *)&elong[cntl]);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_IMAGE_WIDTH);
+
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION,
+ EXIF_FORMAT_LONG, 1, (const char *)&elong[cntl++]);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_PIXEL_X_DIMENSION);
+
+ MMCAM_LOG_INFO("width[%d]", value);
+
+ /*2. EXIF_TAG_IMAGE_LENGTH*/ /*EXIF_TAG_PIXEL_Y_DIMENSION*/
+ value = image_height;
+
+ exif_set_long((unsigned char *)&elong[cntl], exif_data_get_byte_order(ed), value);
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_LENGTH,
+ EXIF_FORMAT_LONG, 1, (const char *)&elong[cntl]);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_IMAGE_LENGTH);
+
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION,
+ EXIF_FORMAT_LONG, 1, (const char *)&elong[cntl++]);
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_PIXEL_Y_DIMENSION);
+
+ MMCAM_LOG_INFO("height[%d]", value);
+
+ /*4. EXIF_TAG_DATE_TIME */
+
+ /*12. EXIF_TAG_DATE_TIME_ORIGINAL */
+
+ /*13. EXIF_TAG_DATE_TIME_DIGITIZED*/
+ {
+ gchar *b = NULL;
+ time_t t;
+ struct tm tm;
+
+ t = time(NULL);
+ tzset();
+ localtime_r(&t, &tm);
+
+ b = g_strdup_printf("%04i:%02i:%02i %02i:%02i:%02i",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, 20, (const char *)b);
if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_MODEL);
+ if (ret == (int)MM_ERROR_CAMCORDER_LOW_MEMORY)
+ g_free(b);
+
+ EXIF_SET_ERR(ret, EXIF_TAG_DATE_TIME);
}
- } else {
- _mmcam_dbg_warn("failed to get model name");
+
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL, EXIF_FORMAT_ASCII, 20, (const char *)b);
+ if (ret != MM_ERROR_NONE) {
+ if (ret == (int)MM_ERROR_CAMCORDER_LOW_MEMORY)
+ g_free(b);
+
+ EXIF_SET_ERR(ret, EXIF_TAG_DATE_TIME_ORIGINAL);
+ }
+
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_DIGITIZED, EXIF_FORMAT_ASCII, 20, (const char *)b);
+ if (ret != MM_ERROR_NONE) {
+ if (ret == (int)MM_ERROR_CAMCORDER_LOW_MEMORY)
+ g_free(b);
+
+ EXIF_SET_ERR(ret, EXIF_TAG_DATE_TIME_DIGITIZED);
+ }
+
+ g_free(b);
}
+
+ /*5. EXIF_TAG_MAKE */
+ __mmcamcorder_update_exif_make(handle, ed);
+
+#ifdef WRITE_EXIF_MAKER_INFO /* FIXME */
+
+ /*6. EXIF_TAG_MODEL */
+ __mmcamcorder_update_exif_model(handle, ed);
+
#endif
/*6. EXIF_TAG_IMAGE_DESCRIPTION */
mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_IMAGE_DESCRIPTION, &str_value, &str_val_len, NULL);
- _mmcam_dbg_log("desctiption [%s]", str_value);
if (str_value && str_val_len > 0) {
char *description = strdup(str_value);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION,
- EXIF_FORMAT_ASCII, strlen(description), (unsigned char *)description);
- free(description);
- str_value = NULL;
- str_val_len = 0;
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_IMAGE_DESCRIPTION);
+
+ MMCAM_LOG_INFO("description [%s]", str_value);
+
+ if (description) {
+ ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION,
+ EXIF_FORMAT_ASCII, strlen(description), (const char *)description);
+ free(description);
+ str_value = NULL;
+ str_val_len = 0;
+ if (ret != MM_ERROR_NONE)
+ EXIF_SET_ERR(ret, EXIF_TAG_IMAGE_DESCRIPTION);
+ } else {
+ MMCAM_LOG_ERROR("strdup failed for [%s]", str_value);
}
} else {
- _mmcam_dbg_warn("failed to get description");
+ MMCAM_LOG_WARNING("failed to get description");
}
/*7. EXIF_TAG_SOFTWARE*/
+ __mmcamcorder_update_exif_software(handle, ed);
+
/*
if (control != NULL) {
char software[50] = {0,};
unsigned int len = 0;
- len = snprintf(software, sizeof(software), "%x.%x ", avsys_exif_info.software_used>>8,(avsys_exif_info.software_used & 0xff));
- _mmcam_dbg_log("software [%s], len [%d]", software, len);
+ len = snprintf(software, sizeof(software), "%x.%x ", avsys_exif_info.software_used>>8, (avsys_exif_info.software_used & 0xff));
+ MMCAM_LOG_INFO("software [%s], len [%d]", software, len);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_SOFTWARE,
- EXIF_FORMAT_ASCII, len, software);
+ EXIF_FORMAT_ASCII, len, (const char *)software);
if (ret != MM_ERROR_NONE) {
EXIF_SET_ERR(ret, EXIF_TAG_SOFTWARE);
}
}
*/
- /*8. EXIF_TAG_ORIENTATION */
- mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_ORIENTATION, &value, NULL);
- _mmcam_dbg_log("get orientation [%d]",value);
- if (value == 0) {
- value = MM_EXIF_ORIENTATION;
- }
-
- exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), value);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_ORIENTATION,
- EXIF_FORMAT_SHORT, 1, (unsigned char*)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_ORIENTATION);
- }
+ __mmcamcorder_update_exif_orientation(handle, ed);
/* START INSERT EXIF_IFD */
/*FIXME : get user comment from real user */
user_comment = strdup(MM_USER_COMMENT);
if (user_comment) {
- _mmcam_dbg_log("user_comment=%s",user_comment);
+ MMCAM_LOG_INFO("user_comment=%s", user_comment);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_USER_COMMENT,
- EXIF_FORMAT_ASCII, strlen(user_comment), (unsigned char *)user_comment);
+ EXIF_FORMAT_ASCII, strlen(user_comment), (const char *)user_comment);
free(user_comment);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_USER_COMMENT);
- }
} else {
ret = MM_ERROR_CAMCORDER_LOW_MEMORY;
EXIF_SET_ERR(ret, EXIF_TAG_USER_COMMENT);
if (control != NULL) {
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), avsys_exif_info.colorspace);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_COLOR_SPACE,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_COLOR_SPACE);
- }
}
/*10. EXIF_TAG_COMPONENTS_CONFIGURATION */
if (control != NULL) {
config = avsys_exif_info.component_configuration;
- _mmcam_dbg_log("EXIF_TAG_COMPONENTS_CONFIGURATION [%4x] ",config);
+ MMCAM_LOG_INFO("EXIF_TAG_COMPONENTS_CONFIGURATION [%4x] ", config);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_COMPONENTS_CONFIGURATION,
- EXIF_FORMAT_UNDEFINED, 4, (unsigned char *)&config);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_UNDEFINED, 4, (const char *)&config);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_COMPONENTS_CONFIGURATION);
- }
}
/*11. EXIF_TAG_COMPRESSED_BITS_PER_PIXEL */
unsigned char *b = NULL;
ExifRational rData;
- _mmcam_dbg_log("EXIF_TAG_EXPOSURE_TIME numerator [%d], denominator [%d]",
- avsys_exif_info.exposure_time_numerator, avsys_exif_info.exposure_time_denominator)
+ MMCAM_LOG_INFO("EXIF_TAG_EXPOSURE_TIME numerator [%d], denominator [%d]",
+ avsys_exif_info.exposure_time_numerator, avsys_exif_info.exposure_time_denominator);
b = malloc(sizeof(ExifRational));
if (b) {
exif_set_rational(b, exif_data_get_byte_order(ed), rData);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_TIME,
- EXIF_FORMAT_RATIONAL, 1, b);
+ EXIF_FORMAT_RATIONAL, 1, (const char *)b);
free(b);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_EXPOSURE_TIME);
- }
} else {
- _mmcam_dbg_warn("malloc failed.");
+ MMCAM_LOG_WARNING("malloc failed.");
}
} else {
- _mmcam_dbg_log("Skip set EXIF_TAG_EXPOSURE_TIME numerator [%d], denominator [%d]",
- avsys_exif_info.exposure_time_numerator, avsys_exif_info.exposure_time_denominator);
+ MMCAM_LOG_INFO("Skip set EXIF_TAG_EXPOSURE_TIME numerator [%d], denominator [%d]",
+ avsys_exif_info.exposure_time_numerator, avsys_exif_info.exposure_time_denominator);
}
/*15. EXIF_TAG_FNUMBER */
unsigned char *b = NULL;
ExifRational rData;
- _mmcam_dbg_log("EXIF_TAG_FNUMBER numerator [%d], denominator [%d]",
- avsys_exif_info.aperture_f_num_numerator, avsys_exif_info.aperture_f_num_denominator);
+ MMCAM_LOG_INFO("EXIF_TAG_FNUMBER numerator [%d], denominator [%d]",
+ avsys_exif_info.aperture_f_num_numerator, avsys_exif_info.aperture_f_num_denominator);
b = malloc(sizeof(ExifRational));
if (b) {
rData.denominator = avsys_exif_info.aperture_f_num_denominator;
exif_set_rational(b, exif_data_get_byte_order(ed), rData);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_FNUMBER,
- EXIF_FORMAT_RATIONAL, 1, b);
+ EXIF_FORMAT_RATIONAL, 1, (const char *)b);
free(b);
- if(ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_FNUMBER);
- }
} else {
- _mmcam_dbg_warn( "malloc failed." );
+ MMCAM_LOG_WARNING("malloc failed.");
}
} else {
- _mmcam_dbg_log("Skip set EXIF_TAG_FNUMBER numerator [%d], denominator [%d]",
- avsys_exif_info.aperture_f_num_numerator, avsys_exif_info.aperture_f_num_denominator);
+ MMCAM_LOG_INFO("Skip set EXIF_TAG_FNUMBER numerator [%d], denominator [%d]",
+ avsys_exif_info.aperture_f_num_numerator, avsys_exif_info.aperture_f_num_denominator);
}
/*16. EXIF_TAG_EXPOSURE_PROGRAM*/
value = MM_EXPOSURE_PROGRAM;
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_PROGRAM,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_EXPOSURE_PROGRAM);
- }
/*17. EXIF_TAG_ISO_SPEED_RATINGS*/
if (avsys_exif_info.iso) {
- _mmcam_dbg_log("EXIF_TAG_ISO_SPEED_RATINGS [%d]", avsys_exif_info.iso);
+ MMCAM_LOG_INFO("EXIF_TAG_ISO_SPEED_RATINGS [%d]", avsys_exif_info.iso);
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), avsys_exif_info.iso);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_ISO_SPEED_RATINGS,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_ISO_SPEED_RATINGS);
- }
}
/*18. EXIF_TAG_SHUTTER_SPEED_VALUE*/
unsigned char *b = NULL;
ExifSRational rsData;
- _mmcam_dbg_log("EXIF_TAG_SHUTTER_SPEED_VALUE numerator [%d], denominator [%d]",
- avsys_exif_info.shutter_speed_numerator, avsys_exif_info.shutter_speed_denominator);
+ MMCAM_LOG_INFO("EXIF_TAG_SHUTTER_SPEED_VALUE numerator [%d], denominator [%d]",
+ avsys_exif_info.shutter_speed_numerator, avsys_exif_info.shutter_speed_denominator);
b = malloc(sizeof(ExifSRational));
if (b) {
rsData.denominator = avsys_exif_info.shutter_speed_denominator;
exif_set_srational(b, exif_data_get_byte_order(ed), rsData);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_SHUTTER_SPEED_VALUE,
- EXIF_FORMAT_SRATIONAL, 1, b);
+ EXIF_FORMAT_SRATIONAL, 1, (const char *)b);
free(b);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_SHUTTER_SPEED_VALUE);
- }
} else {
- _mmcam_dbg_warn("malloc failed.");
+ MMCAM_LOG_WARNING("malloc failed.");
}
} else {
- _mmcam_dbg_log("Skip set EXIF_TAG_SHUTTER_SPEED_VALUE numerator [%d], denominator [%d]",
- avsys_exif_info.shutter_speed_numerator, avsys_exif_info.shutter_speed_denominator);
+ MMCAM_LOG_INFO("Skip set EXIF_TAG_SHUTTER_SPEED_VALUE numerator [%d], denominator [%d]",
+ avsys_exif_info.shutter_speed_numerator, avsys_exif_info.shutter_speed_denominator);
}
/*19. EXIF_TAG_APERTURE_VALUE*/
unsigned char *b = NULL;
ExifRational rData;
- _mmcam_dbg_log("EXIF_TAG_APERTURE_VALUE [%d]", avsys_exif_info.aperture_in_APEX);
+ MMCAM_LOG_INFO("EXIF_TAG_APERTURE_VALUE [%d]", avsys_exif_info.aperture_in_APEX);
b = malloc(sizeof(ExifRational));
if (b) {
rData.denominator = 1;
exif_set_rational(b, exif_data_get_byte_order(ed), rData);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_APERTURE_VALUE,
- EXIF_FORMAT_RATIONAL, 1, b);
+ EXIF_FORMAT_RATIONAL, 1, (const char *)b);
free(b);
- if(ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_APERTURE_VALUE);
- }
} else {
- _mmcam_dbg_warn("malloc failed.");
+ MMCAM_LOG_WARNING("malloc failed.");
}
} else {
- _mmcam_dbg_log("Skip set EXIF_TAG_APERTURE_VALUE [%d]", avsys_exif_info.aperture_in_APEX);
+ MMCAM_LOG_INFO("Skip set EXIF_TAG_APERTURE_VALUE [%d]", avsys_exif_info.aperture_in_APEX);
}
/*20. EXIF_TAG_BRIGHTNESS_VALUE*/
unsigned char *b = NULL;
ExifSRational rsData;
- _mmcam_dbg_log("EXIF_TAG_BRIGHTNESS_VALUE numerator [%d], denominator [%d]",
- avsys_exif_info.brigtness_numerator, avsys_exif_info.brightness_denominator);
+ MMCAM_LOG_INFO("EXIF_TAG_BRIGHTNESS_VALUE numerator [%d], denominator [%d]",
+ avsys_exif_info.brigtness_numerator, avsys_exif_info.brightness_denominator);
b = malloc(sizeof(ExifSRational));
if (b) {
rsData.denominator = avsys_exif_info.brightness_denominator;
exif_set_srational(b, exif_data_get_byte_order(ed), rsData);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_BRIGHTNESS_VALUE,
- EXIF_FORMAT_SRATIONAL, 1, b);
+ EXIF_FORMAT_SRATIONAL, 1, (const char *)b);
free(b);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_BRIGHTNESS_VALUE);
- }
} else {
- _mmcam_dbg_warn( "malloc failed." );
+ MMCAM_LOG_WARNING("malloc failed.");
}
} else {
- _mmcam_dbg_log("Skip set EXIF_TAG_BRIGHTNESS_VALUE numerator [%d], denominatorr [%d]",
- avsys_exif_info.brigtness_numerator, avsys_exif_info.brightness_denominator);
+ MMCAM_LOG_INFO("Skip set EXIF_TAG_BRIGHTNESS_VALUE numerator [%d], denominatorr [%d]",
+ avsys_exif_info.brigtness_numerator, avsys_exif_info.brightness_denominator);
}
/*21. EXIF_TAG_EXPOSURE_BIAS_VALUE*/
unsigned char *b = NULL;
ExifSRational rsData;
- _mmcam_dbg_log("EXIF_TAG_BRIGHTNESS_VALUE %d",value);
+ MMCAM_LOG_INFO("EXIF_TAG_BRIGHTNESS_VALUE %d, default %d, step denominator %d",
+ value, hcamcorder->brightness_default, hcamcorder->brightness_step_denominator);
b = malloc(sizeof(ExifSRational));
if (b) {
- rsData.numerator = value - 5;
- rsData.denominator = 10;
+ rsData.numerator = value - hcamcorder->brightness_default;
+ if (hcamcorder->brightness_step_denominator != 0) {
+ rsData.denominator = hcamcorder->brightness_step_denominator;
+ } else {
+ MMCAM_LOG_WARNING("brightness_step_denominator is ZERO, so set 1");
+ rsData.denominator = 1;
+ }
exif_set_srational(b, exif_data_get_byte_order(ed), rsData);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_BIAS_VALUE,
- EXIF_FORMAT_SRATIONAL, 1, b);
+ EXIF_FORMAT_SRATIONAL, 1, (const char *)b);
free(b);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_EXPOSURE_BIAS_VALUE);
- }
} else {
- _mmcam_dbg_warn("malloc failed.");
+ MMCAM_LOG_WARNING("malloc failed.");
}
} else {
- _mmcam_dbg_log("failed to get MMCAM_FILTER_BRIGHTNESS [%x]", ret);
+ MMCAM_LOG_INFO("failed to get MMCAM_FILTER_BRIGHTNESS [%x]", ret);
}
/*22 EXIF_TAG_MAX_APERTURE_VALUE*/
unsigned char *b = NULL;
ExifRational rData;
- _mmcam_dbg_log("EXIF_TAG_MAX_APERTURE_VALUE [%d]", avsys_exif_info.max_lens_aperture_in_APEX);
+ MMCAM_LOG_INFO("EXIF_TAG_MAX_APERTURE_VALUE [%d]", avsys_exif_info.max_lens_aperture_in_APEX);
b = malloc(sizeof(ExifRational));
if (b) {
rData.denominator = 1;
exif_set_rational(b, exif_data_get_byte_order(ed), rData);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_MAX_APERTURE_VALUE,
- EXIF_FORMAT_RATIONAL, 1, b);
+ EXIF_FORMAT_RATIONAL, 1, b);
free(b);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_MAX_APERTURE_VALUE);
- }
} else {
- _mmcam_dbg_warn("failed to alloc for MAX aperture value");
+ MMCAM_LOG_WARNING("failed to alloc for MAX aperture value");
}
}
*/
/*23. EXIF_TAG_SUBJECT_DISTANCE*/
- /* defualt : none */
+ /* default : none */
/*24. EXIF_TAG_METERING_MODE */
if (control != NULL) {
- exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed),avsys_exif_info.metering_mode);
- _mmcam_dbg_log("EXIF_TAG_METERING_MODE [%d]", avsys_exif_info.metering_mode);
+ exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), avsys_exif_info.metering_mode);
+ MMCAM_LOG_INFO("EXIF_TAG_METERING_MODE [%d]", avsys_exif_info.metering_mode);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_METERING_MODE,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_METERING_MODE);
- }
}
/*25. EXIF_TAG_LIGHT_SOURCE*/
/*26. EXIF_TAG_FLASH*/
if (control != NULL) {
- exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order (ed),avsys_exif_info.flash);
- _mmcam_dbg_log("EXIF_TAG_FLASH [%d]", avsys_exif_info.flash);
+ exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), avsys_exif_info.flash);
+ MMCAM_LOG_INFO("EXIF_TAG_FLASH [%d]", avsys_exif_info.flash);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_FLASH);
- }
}
/*27. EXIF_TAG_FOCAL_LENGTH*/
unsigned char *b = NULL;
ExifRational rData;
- _mmcam_dbg_log("EXIF_TAG_FOCAL_LENGTH numerator [%d], denominator [%d]",
- avsys_exif_info.focal_len_numerator, avsys_exif_info.focal_len_denominator);
+ MMCAM_LOG_INFO("EXIF_TAG_FOCAL_LENGTH numerator [%d], denominator [%d]",
+ avsys_exif_info.focal_len_numerator, avsys_exif_info.focal_len_denominator);
b = malloc(sizeof(ExifRational));
if (b) {
rData.denominator = avsys_exif_info.focal_len_denominator;
exif_set_rational(b, exif_data_get_byte_order(ed), rData);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH,
- EXIF_FORMAT_RATIONAL, 1, b);
+ EXIF_FORMAT_RATIONAL, 1, (const char *)b);
free(b);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_FOCAL_LENGTH);
- }
} else {
- _mmcam_dbg_warn("malloc failed.");
+ MMCAM_LOG_WARNING("malloc failed.");
}
} else {
- _mmcam_dbg_log("Skip set EXIF_TAG_FOCAL_LENGTH numerator [%d], denominator [%d]",
- avsys_exif_info.focal_len_numerator, avsys_exif_info.focal_len_denominator);
+ MMCAM_LOG_INFO("Skip set EXIF_TAG_FOCAL_LENGTH numerator [%d], denominator [%d]",
+ avsys_exif_info.focal_len_numerator, avsys_exif_info.focal_len_denominator);
}
/*28. EXIF_TAG_SENSING_METHOD*/
/*FIXME*/
value = MM_SENSING_MODE;
- exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order (ed),value);
+ exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_SENSING_METHOD,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_SENSING_METHOD);
- }
/*29. EXIF_TAG_FILE_SOURCE*/
/*
value = MM_FILE_SOURCE;
exif_set_long(&elong[cntl], exif_data_get_byte_order(ed),value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_FILE_SOURCE,
- EXIF_FORMAT_UNDEFINED, 4, (unsigned char *)&elong[cntl++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_UNDEFINED, 4, (const char *)&elong[cntl++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_FILE_SOURCE);
- }
*/
/*30. EXIF_TAG_SCENE_TYPE*/
value = MM_SCENE_TYPE;
exif_set_long(&elong[cntl], exif_data_get_byte_order(ed),value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_SCENE_TYPE,
- EXIF_FORMAT_UNDEFINED, 4, (unsigned char *)&elong[cntl++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_UNDEFINED, 4, (const char *)&elong[cntl++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_SCENE_TYPE);
- }
*/
/*31. EXIF_TAG_EXPOSURE_MODE*/
/*FIXME*/
value = MM_EXPOSURE_MODE;
- exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed),value);
+ exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_MODE,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_EXPOSURE_MODE);
- }
-
/*32. EXIF_TAG_WHITE_BALANCE*/
ret = mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_WB, &value, NULL);
if (ret == MM_ERROR_NONE) {
int set_value = 0;
- _mmcam_dbg_log("WHITE BALANCE [%d]", value);
-
- if (value == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
+ MMCAM_LOG_INFO("WHITE BALANCE [%d]", value);
+
+ if (value == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC)
set_value = 0;
- } else {
+ else
set_value = 1;
- }
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), set_value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_WHITE_BALANCE,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_WHITE_BALANCE);
- }
} else {
- _mmcam_dbg_warn("failed to get white balance [%x]", ret);
+ MMCAM_LOG_WARNING("failed to get white balance [%x]", ret);
}
/*33. EXIF_TAG_DIGITAL_ZOOM_RATIO*/
/*
ret = mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_DIGITAL_ZOOM, &value, NULL);
if (ret == MM_ERROR_NONE) {
- _mmcam_dbg_log("DIGITAL ZOOM [%d]", value);
+ MMCAM_LOG_INFO("DIGITAL ZOOM [%d]", value);
exif_set_long(&elong[cntl], exif_data_get_byte_order(ed), value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_DIGITAL_ZOOM_RATIO,
- EXIF_FORMAT_LONG, 1, (unsigned char *)&elong[cntl++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_LONG, 1, (const char *)&elong[cntl++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_DIGITAL_ZOOM_RATIO);
- }
} else {
- _mmcam_dbg_warn("failed to get digital zoom [%x]", ret);
+ MMCAM_LOG_WARNING("failed to get digital zoom [%x]", ret);
}
*/
value = MM_FOCAL_LENGTH_35MMFILM;
exif_set_short(&eshort[cnts], exif_data_get_byte_order(ed),value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM);
- }
*/
/*35. EXIF_TAG_SCENE_CAPTURE_TYPE*/
ret = mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &value, NULL);
if (ret == MM_ERROR_NONE) {
- _mmcam_dbg_log("Scene mode(program mode) [%d]", value);
+ MMCAM_LOG_INFO("Scene mode(program mode) [%d]", value);
- if (value == MM_CAMCORDER_SCENE_MODE_NORMAL) {
+ switch (value) {
+ case MM_CAMCORDER_SCENE_MODE_NORMAL:
scene_capture_type = 0; /* standard */
- } else if (value == MM_CAMCORDER_SCENE_MODE_PORTRAIT) {
+ break;
+ case MM_CAMCORDER_SCENE_MODE_PORTRAIT:
scene_capture_type = 2; /* portrait */
- } else if (value == MM_CAMCORDER_SCENE_MODE_LANDSCAPE) {
+ break;
+ case MM_CAMCORDER_SCENE_MODE_LANDSCAPE:
scene_capture_type = 1; /* landscape */
- } else if (value == MM_CAMCORDER_SCENE_MODE_NIGHT_SCENE) {
+ break;
+ case MM_CAMCORDER_SCENE_MODE_NIGHT_SCENE:
scene_capture_type = 3; /* night scene */
- } else {
+ break;
+ default:
scene_capture_type = 4; /* Others */
+ break;
}
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), scene_capture_type);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_SCENE_CAPTURE_TYPE,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_SCENE_CAPTURE_TYPE);
- }
} else {
- _mmcam_dbg_warn("failed to get scene mode [%x]", ret);
+ MMCAM_LOG_WARNING("failed to get scene mode [%x]", ret);
}
}
value = MM_GAIN_CONTROL;
exif_set_long(&elong[cntl], exif_data_get_byte_order(ed), value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_GAIN_CONTROL,
- EXIF_FORMAT_LONG, 1, (unsigned char *)&elong[cntl++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_LONG, 1, (const char *)&elong[cntl++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_GAIN_CONTROL);
- }
*/
int level = 0;
_mmcamcorder_conf_get_value_int_range(hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_EFFECT,
- "Contrast",
- &irange);
+ CONFIGURE_CATEGORY_CTRL_EFFECT,
+ "Contrast",
+ &irange);
if (irange != NULL) {
mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_CONTRAST, &value, NULL);
- _mmcam_dbg_log("CONTRAST currentt [%d], default [%d]", value, irange->default_value);
+ MMCAM_LOG_INFO("CONTRAST current [%d], default [%d]", value, irange->default_value);
- if (value == irange->default_value) {
+ if (value == irange->default_value)
level = MM_VALUE_NORMAL;
- } else if (value < irange->default_value) {
+ else if (value < irange->default_value)
level = MM_VALUE_LOW;
- } else {
+ else
level = MM_VALUE_HARD;
- }
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), level);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_CONTRAST,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_CONTRAST);
- }
} else {
- _mmcam_dbg_warn("failed to get range of contrast");
+ MMCAM_LOG_WARNING("failed to get range of contrast");
}
}
int level = 0;
_mmcamcorder_conf_get_value_int_range(hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_EFFECT,
- "Saturation",
- &irange);
+ CONFIGURE_CATEGORY_CTRL_EFFECT,
+ "Saturation",
+ &irange);
if (irange != NULL) {
mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SATURATION, &value, NULL);
- _mmcam_dbg_log("SATURATION current [%d], default [%d]", value, irange->default_value);
+ MMCAM_LOG_INFO("SATURATION current [%d], default [%d]", value, irange->default_value);
- if (value == irange->default_value) {
+ if (value == irange->default_value)
level = MM_VALUE_NORMAL;
- } else if (value < irange->default_value) {
+ else if (value < irange->default_value)
level = MM_VALUE_LOW;
- } else {
- level=MM_VALUE_HARD;
- }
+ else
+ level = MM_VALUE_HARD;
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), level);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_SATURATION,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_SATURATION);
- }
} else {
- _mmcam_dbg_warn("failed to get range of saturation");
+ MMCAM_LOG_WARNING("failed to get range of saturation");
}
}
int level = 0;
_mmcamcorder_conf_get_value_int_range(hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_EFFECT,
- "Sharpness",
- &irange);
+ CONFIGURE_CATEGORY_CTRL_EFFECT,
+ "Sharpness",
+ &irange);
if (irange != NULL) {
mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SHARPNESS, &value, NULL);
- _mmcam_dbg_log("SHARPNESS current [%d], default [%d]", value, irange->default_value);
+ MMCAM_LOG_INFO("SHARPNESS current [%d], default [%d]", value, irange->default_value);
- if (value == irange->default_value) {
+ if (value == irange->default_value)
level = MM_VALUE_NORMAL;
- } else if (value < irange->default_value) {
+ else if (value < irange->default_value)
level = MM_VALUE_LOW;
- } else {
+ else
level = MM_VALUE_HARD;
- }
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), level);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_SHARPNESS,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_SHARPNESS);
- }
} else {
- _mmcam_dbg_warn("failed to get range of sharpness");
+ MMCAM_LOG_WARNING("failed to get range of sharpness");
}
}
/*40. EXIF_TAG_SUBJECT_DISTANCE_RANGE*/
/*FIXME*/
value = MM_SUBJECT_DISTANCE_RANGE;
- _mmcam_dbg_log("DISTANCE_RANGE [%d]", value);
+ MMCAM_LOG_INFO("DISTANCE_RANGE [%d]", value);
exif_set_short((unsigned char *)&eshort[cnts], exif_data_get_byte_order(ed), value);
ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_SUBJECT_DISTANCE_RANGE,
- EXIF_FORMAT_SHORT, 1, (unsigned char *)&eshort[cnts++]);
- if (ret != MM_ERROR_NONE) {
+ EXIF_FORMAT_SHORT, 1, (const char *)&eshort[cnts++]);
+ if (ret != MM_ERROR_NONE)
EXIF_SET_ERR(ret, EXIF_TAG_SUBJECT_DISTANCE_RANGE);
- }
/* GPS information */
- ret = mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_GPS_ENABLE, &gps_enable, NULL);
- if (ret == MM_ERROR_NONE && gps_enable) {
- ExifByte GpsVersion[4]={2,2,0,0};
+ __mmcamcorder_update_exif_gps(handle, ed);
- _mmcam_dbg_log("Tag for GPS is ENABLED.");
-
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_VERSION_ID,
- EXIF_FORMAT_BYTE, 4, (unsigned char *)&GpsVersion);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_VERSION_ID);
- }
+ MMCAM_LOG_INFO("");
- /*41. Latitude*/
- ret = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_TAG_LATITUDE, &f_latitude,
- MMCAM_TAG_LONGITUDE, &f_longitude,
- MMCAM_TAG_ALTITUDE, &f_altitude, NULL);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to get gps info [%x][%s]", ret, err_name);
- SAFE_FREE(err_name);
- goto exit;
- }
+ ret = mm_exif_set_exif_to_info(hcamcorder->exif_info, ed);
+ if (ret != MM_ERROR_NONE)
+ MMCAM_LOG_ERROR("mm_exif_set_exif_to_info err!! [%x]", ret);
- _mmcam_dbg_log("f_latitude [%f]", f_latitude);
- if (f_latitude != INVALID_GPS_VALUE) {
- unsigned char *b = NULL;
- unsigned int deg;
- unsigned int min;
- unsigned int sec;
- ExifRational rData;
+exit:
+ MMCAM_LOG_INFO("finished!! [%x]", ret);
- if (f_latitude < 0) {
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF,
- EXIF_FORMAT_ASCII, 2, (unsigned char *)"S");
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_LATITUDE_REF);
- }
- f_latitude = -f_latitude;
- } else if (f_latitude > 0) {
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF,
- EXIF_FORMAT_ASCII, 2, (unsigned char *)"N");
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_LATITUDE_REF);
- }
- }
+ if (ed)
+ exif_data_unref(ed);
- deg = (unsigned int)(f_latitude);
- min = (unsigned int)((f_latitude-deg)*60);
- sec = (unsigned int)(((f_latitude-deg)*3600)-min*60);
+ return ret;
+}
- _mmcam_dbg_log("f_latitude deg[%d], min[%d], sec[%d]", deg, min, sec);
- b = malloc(3 * sizeof(ExifRational));
- if (b) {
- rData.numerator = deg;
- rData.denominator = 1;
- exif_set_rational(b, exif_data_get_byte_order(ed), rData);
- rData.numerator = min;
- exif_set_rational(b+8, exif_data_get_byte_order(ed), rData);
- rData.numerator = sec;
- exif_set_rational(b+16, exif_data_get_byte_order(ed), rData);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE,
- EXIF_FORMAT_RATIONAL, 3, (unsigned char *)b);
- free(b);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_LATITUDE);
- }
- } else {
- _mmcam_dbg_warn("malloc failed");
- }
- }
+static void __sound_status_changed_cb(keynode_t* node, void *data)
+{
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)data;
+ _MMCamcorderImageInfo *info = NULL;
- /*42. Longitude*/
- _mmcam_dbg_log("f_longitude [%f]", f_longitude);
- if (f_longitude != INVALID_GPS_VALUE) {
- unsigned char *b = NULL;
- unsigned int deg;
- unsigned int min;
- unsigned int sec;
- ExifRational rData;
+ mmf_return_if_fail(hcamcorder && hcamcorder->sub_context && hcamcorder->sub_context->info_image);
- if (f_longitude < 0) {
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF,
- EXIF_FORMAT_ASCII, 2, (unsigned char *)"W");
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_LONGITUDE_REF);
- }
- f_longitude = -f_longitude;
- } else if (f_longitude > 0) {
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF,
- EXIF_FORMAT_ASCII, 2, (unsigned char *)"E");
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_LONGITUDE_REF);
- }
- }
+ MMCAM_LOG_INFO("START");
- deg = (unsigned int)(f_longitude);
- min = (unsigned int)((f_longitude-deg)*60);
- sec = (unsigned int)(((f_longitude-deg)*3600)-min*60);
+ info = hcamcorder->sub_context->info_image;
- _mmcam_dbg_log("f_longitude deg[%d], min[%d], sec[%d]", deg, min, sec);
- b = malloc(3 * sizeof(ExifRational));
- if (b) {
- rData.numerator = deg;
- rData.denominator = 1;
- exif_set_rational(b, exif_data_get_byte_order(ed), rData);
- rData.numerator = min;
- exif_set_rational(b+8, exif_data_get_byte_order(ed), rData);
- rData.numerator = sec;
- exif_set_rational(b+16, exif_data_get_byte_order(ed), rData);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE,
- EXIF_FORMAT_RATIONAL, 3, (unsigned char *)b);
- free(b);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_LONGITUDE);
- }
- } else {
- _mmcam_dbg_warn("malloc failed");
- }
- }
+ vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &(info->sound_status));
- /*43. Altitude*/
- _mmcam_dbg_log("f_altitude [%f]", f_altitude);
- if (f_altitude != INVALID_GPS_VALUE) {
- ExifByte alt_ref = 0;
- unsigned char *b = NULL;
- ExifRational rData;
- b = malloc(sizeof(ExifRational));
- if (b) {
- if (f_altitude < 0) {
- alt_ref = 1;
- f_altitude = -f_altitude;
- }
+ MMCAM_LOG_INFO("DONE : sound status %d", info->sound_status);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_ALTITUDE_REF,
- EXIF_FORMAT_BYTE, 1, (unsigned char *)&alt_ref);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("error [%x], tag [%x]", ret, EXIF_TAG_GPS_ALTITUDE_REF);
- if (ret == MM_ERROR_CAMCORDER_LOW_MEMORY) {
- free(b);
- b = NULL;
- goto exit;
- }
- }
+ return;
+}
- rData.numerator = (unsigned int)(f_altitude + 0.5)*100;
- rData.denominator = 100;
- exif_set_rational(b, exif_data_get_byte_order(ed), rData);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_ALTITUDE,
- EXIF_FORMAT_RATIONAL, 1, (unsigned char *)b);
- free(b);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_ALTITUDE);
- }
- } else {
- _mmcam_dbg_warn("malloc failed");
- }
- }
- /*44. EXIF_TAG_GPS_TIME_STAMP*/
- {
- double gps_timestamp = INVALID_GPS_VALUE;
- mm_camcorder_get_attributes(handle, NULL, "tag-gps-time-stamp", &gps_timestamp, NULL);
- _mmcam_dbg_log("Gps timestamp [%f]", gps_timestamp);
- if (gps_timestamp > 0.0) {
- unsigned char *b = NULL;
- unsigned int hour;
- unsigned int min;
- unsigned int microsec;
- ExifRational rData;
+int _mmcamcorder_set_extra_preview_stream_format(MMHandleType camcorder, int stream_id, int pixel_format, int width, int height, int fps)
+{
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)camcorder;
+ MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
+ GstCameraControl *control = NULL;
+ _MMCamcorderSubContext *sc = NULL;
- hour = (unsigned int)(gps_timestamp / 3600);
- min = (unsigned int)((gps_timestamp - 3600 * hour) / 60);
- microsec = (unsigned int)(((double)((double)gps_timestamp -(double)(3600 * hour)) -(double)(60 * min)) * 1000000);
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(hcamcorder->support_extra_preview, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
+ mmf_return_val_if_fail(stream_id >= 0 && stream_id < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM,
+ MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(pixel_format > MM_PIXEL_FORMAT_INVALID && pixel_format < MM_PIXEL_FORMAT_NUM,
+ MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(width > 0 && height > 0 && fps >= 0, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- _mmcam_dbg_log("Gps timestamp hour[%d], min[%d], microsec[%d]", hour, min, microsec);
- b = malloc(3 * sizeof(ExifRational));
- if (b) {
- rData.numerator = hour;
- rData.denominator = 1;
- exif_set_rational(b, exif_data_get_byte_order(ed), rData);
+ mm_camcorder_get_state(camcorder, ¤t_state);
- rData.numerator = min;
- rData.denominator = 1;
- exif_set_rational(b + 8, exif_data_get_byte_order(ed), rData);
+ MMCAM_LOG_INFO("state[%d] stream_id[%d],fmt[%d],res[%dx%d],fps[%d]",
+ current_state, stream_id, pixel_format, width, height, fps);
- rData.numerator = microsec;
- rData.denominator = 1000000;
- exif_set_rational(b + 16, exif_data_get_byte_order(ed), rData);
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ sc = MMF_CAMCORDER_SUBCONTEXT(camcorder);
+ mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_TIME_STAMP,
- EXIF_FORMAT_RATIONAL, 3, b);
- free(b);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_TIME_STAMP);
- }
- } else {
- _mmcam_dbg_warn( "malloc failed." );
- }
- }
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!gst_camera_control_set_extra_preview_stream_format(control,
+ stream_id, _mmcamcorder_get_camera_control_image_format(pixel_format), width, height, fps)) {
+ MMCAM_LOG_ERROR("camera control failed");
+ return MM_ERROR_CAMCORDER_INTERNAL;
}
+ } else {
+ MMCAM_LOG_INFO("It will be set when start preview");
+ hcamcorder->extra_preview_format[stream_id].need_to_set_format = TRUE;
+ }
- /*45. EXIF_TAG_GPS_DATE_STAMP*/
- {
- unsigned char *date_stamp = NULL;
- int date_stamp_len = 0;
+ hcamcorder->extra_preview_format[stream_id].pixel_format = pixel_format;
+ hcamcorder->extra_preview_format[stream_id].width = width;
+ hcamcorder->extra_preview_format[stream_id].height = height;
+ hcamcorder->extra_preview_format[stream_id].fps = fps;
- mm_camcorder_get_attributes(handle, NULL, "tag-gps-date-stamp", &date_stamp, &date_stamp_len, NULL);
+ return MM_ERROR_NONE;
+}
- if (date_stamp) {
- _mmcam_dbg_log("Date stamp [%s]", date_stamp);
- /* cause it should include NULL char */
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_DATE_STAMP,
- EXIF_FORMAT_ASCII, date_stamp_len + 1, date_stamp);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_DATE_STAMP);
- }
- }
- }
+int _mmcamcorder_get_extra_preview_stream_format(MMHandleType camcorder, int stream_id, int *pixel_format, int *width, int *height, int *fps)
+{
+ int _width = 0;
+ int _height = 0;
+ int _fps = 0;
+ GstCameraControlImageFormat _img_fmt = GST_CAMERA_CONTROL_IMAGE_FORMAT_NV12;
+ GstCameraControl *control = NULL;
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)camcorder;
+ MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
+ _MMCamcorderSubContext *sc = NULL;
- /*46. EXIF_TAG_GPS_PROCESSING_METHOD */
- {
- unsigned char *processing_method = NULL;
- int processing_method_len = 0;
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(hcamcorder->support_extra_preview, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
+ mmf_return_val_if_fail(pixel_format && width && height && fps, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- mm_camcorder_get_attributes(handle, NULL, "tag-gps-processing-method", &processing_method, &processing_method_len, NULL);
+ mm_camcorder_get_state(camcorder, ¤t_state);
- if (processing_method) {
- _mmcam_dbg_log("Processing method [%s]", processing_method);
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ sc = MMF_CAMCORDER_SUBCONTEXT(camcorder);
+ mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_PROCESSING_METHOD,
- EXIF_FORMAT_UNDEFINED, processing_method_len, processing_method);
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_GPS_PROCESSING_METHOD);
- }
- }
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!gst_camera_control_get_extra_preview_stream_format(control,
+ stream_id, &_img_fmt, &_width, &_height, &_fps)) {
+ MMCAM_LOG_ERROR("extra preview stream format get failed");
+ return MM_ERROR_CAMCORDER_INTERNAL;
}
+
+ *pixel_format = _mmcamcorder_get_pixel_format2(_img_fmt);
+ *width = _width;
+ *height = _height;
+ *fps = _fps;
} else {
- _mmcam_dbg_log( "Tag for GPS is DISABLED." );
+ *pixel_format = hcamcorder->extra_preview_format[stream_id].pixel_format;
+ *width = hcamcorder->extra_preview_format[stream_id].width;
+ *height = hcamcorder->extra_preview_format[stream_id].height;
+ *fps = hcamcorder->extra_preview_format[stream_id].fps;
}
+ MMCAM_LOG_INFO("get result[fmt:%d(%d),res:%dx%d,fps:%d][state:%d]",
+ *pixel_format, _img_fmt, *width, *height, *fps, current_state);
- /*47. EXIF_TAG_MAKER_NOTE*/
- ret = mm_exif_set_add_entry(ed, EXIF_IFD_EXIF, EXIF_TAG_MAKER_NOTE,
- EXIF_FORMAT_UNDEFINED, 8, (unsigned char *)"SAMSUNG");
- if (ret != MM_ERROR_NONE) {
- EXIF_SET_ERR(ret, EXIF_TAG_MAKER_NOTE);
- }
+ return MM_ERROR_NONE;
+}
- /* create and link samsung maker note */
- ret = mm_exif_mnote_create(ed);
- if (ret != MM_ERROR_NONE){
- EXIF_SET_ERR(ret, EXIF_TAG_MAKER_NOTE);
- } else {
- _mmcam_dbg_log("Samsung makernote created");
- /* add samsung maker note entries (param : data, tag, index, subtag index1, subtag index2) */
- ret = mm_exif_mnote_set_add_entry(ed, MNOTE_SAMSUNG_TAG_MNOTE_VERSION, 0, _MNOTE_VALUE_NONE, _MNOTE_VALUE_NONE);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_exif_mnote_set_add_entry error! [%x]", ret);
- }
- /*
- ret = mm_exif_mnote_set_add_entry(ed, MNOTE_SAMSUNG_TAG_DEVICE_ID, 2, _MNOTE_VALUE_NONE, _MNOTE_VALUE_NONE);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_exif_mnote_set_add_entry error! [%x]", ret);
- }
+int _mmcamcorder_set_extra_preview_bitrate(MMHandleType camcorder, int stream_id, int bitrate)
+{
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)camcorder;
+ MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
+ GstCameraControl *control = NULL;
+ _MMCamcorderSubContext *sc = NULL;
- ret = mm_exif_mnote_set_add_entry(ed, MNOTE_SAMSUNG_TAG_SERIAL_NUM, _MNOTE_VALUE_NONE, _MNOTE_VALUE_NONE, _MNOTE_VALUE_NONE);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_exif_mnote_set_add_entry error! [%x]", ret);
- }
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(hcamcorder->support_extra_preview, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
+ mmf_return_val_if_fail(stream_id >= 0 && stream_id < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM,
+ MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(bitrate > 0, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- ret = mm_exif_mnote_set_add_entry(ed, MNOTE_SAMSUNG_TAG_COLOR_SPACE, 1, _MNOTE_VALUE_NONE, _MNOTE_VALUE_NONE);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_exif_mnote_set_add_entry error! [%x]", ret);
- }
- */
- ret = mm_exif_mnote_set_add_entry(ed, MNOTE_SAMSUNG_TAG_FACE_DETECTION, 0, _MNOTE_VALUE_NONE, _MNOTE_VALUE_NONE);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_exif_mnote_set_add_entry error! ret=%x", ret);
- }
- /*
- ret = mm_exif_mnote_set_add_entry(ed, MNOTE_SAMSUNG_TAG_MODEL_ID, _MNOTE_VALUE_NONE, 3, 2);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_exif_mnote_set_add_entry error! [%x]", ret);
+ mm_camcorder_get_state(camcorder, ¤t_state);
+
+ MMCAM_LOG_INFO("state[%d] stream[%d], bitrate[%d]", current_state, stream_id, bitrate);
+
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ sc = MMF_CAMCORDER_SUBCONTEXT(camcorder);
+ mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!gst_camera_control_set_extra_preview_bitrate(control, stream_id, bitrate)) {
+ MMCAM_LOG_ERROR("set bitrate[%d] for stream[%d] failed", bitrate, stream_id);
+ return MM_ERROR_CAMCORDER_INTERNAL;
}
- */
+ } else {
+ MMCAM_LOG_INFO("It will be set when start preview");
+ hcamcorder->extra_preview_format[stream_id].need_to_set_bitrate = TRUE;
}
- _mmcam_dbg_log("");
+ hcamcorder->extra_preview_format[stream_id].bitrate = bitrate;
- ret = mm_exif_set_exif_to_info(hcamcorder->exif_info, ed);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_exif_set_exif_to_info err!! [%x]", ret);
- }
+ return MM_ERROR_NONE;
+}
-exit:
- _mmcam_dbg_log("finished!! [%x]", ret);
- if (ed) {
- exif_data_unref (ed);
+int _mmcamcorder_get_extra_preview_bitrate(MMHandleType camcorder, int stream_id, int *bitrate)
+{
+ int _bitrate = 0;
+ GstCameraControl *control = NULL;
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)camcorder;
+ MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
+ _MMCamcorderSubContext *sc = NULL;
+
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(hcamcorder->support_extra_preview, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
+ mmf_return_val_if_fail(stream_id >= 0 && stream_id < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM,
+ MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(bitrate, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ mm_camcorder_get_state(camcorder, ¤t_state);
+
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ sc = MMF_CAMCORDER_SUBCONTEXT(camcorder);
+ mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!gst_camera_control_get_extra_preview_bitrate(control, stream_id, &_bitrate)) {
+ MMCAM_LOG_ERROR("get bitrate for stream[%d] failed", stream_id);
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
+
+ *bitrate = _bitrate;
+ } else {
+ *bitrate = hcamcorder->extra_preview_format[stream_id].bitrate;
}
- return ret;
+ MMCAM_LOG_INFO("get bitrate[%d] for stream[%d][state:%d]",
+ *bitrate, stream_id, current_state);
+
+ return MM_ERROR_NONE;
}
-static void __sound_status_changed_cb(keynode_t* node, void *data)
+int _mmcamcorder_set_extra_preview_gop_interval(MMHandleType camcorder, int stream_id, int interval)
{
- mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)data;
- _MMCamcorderImageInfo *info = NULL;
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)camcorder;
+ MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
+ GstCameraControl *control = NULL;
+ _MMCamcorderSubContext *sc = NULL;
- mmf_return_if_fail(hcamcorder && hcamcorder->sub_context && hcamcorder->sub_context->info_image);
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(hcamcorder->support_extra_preview, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
+ mmf_return_val_if_fail(stream_id >= 0 && stream_id < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM,
+ MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- _mmcam_dbg_log("START");
+ mm_camcorder_get_state(camcorder, ¤t_state);
- info = hcamcorder->sub_context->info_image;
+ MMCAM_LOG_INFO("state[%d] stream[%d], interval[%d]", current_state, stream_id, interval);
- __ta__(" GET_IN_CB:VCONFKEY_SETAPPL_SOUND_STATUS_BOOL",
- vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &(info->sound_status));
- );
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ sc = MMF_CAMCORDER_SUBCONTEXT(camcorder);
+ mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- _mmcam_dbg_log("DONE : sound status %d", info->sound_status);
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!gst_camera_control_set_extra_preview_gop_interval(control, stream_id, interval)) {
+ MMCAM_LOG_ERROR("set GOP interval[%d] for stream[%d] failed", interval, stream_id);
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
+ } else {
+ MMCAM_LOG_INFO("It will be set when start preview");
+ hcamcorder->extra_preview_format[stream_id].need_to_set_gop_interval = TRUE;
+ }
- return;
+ hcamcorder->extra_preview_format[stream_id].gop_interval = interval;
+
+ return MM_ERROR_NONE;
}
-static void __volume_level_changed_cb(void *data)
+int _mmcamcorder_get_extra_preview_gop_interval(MMHandleType camcorder, int stream_id, int *interval)
{
- mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)data;
- _MMCamcorderImageInfo *info = NULL;
+ int _interval = 0;
+ GstCameraControl *control = NULL;
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *)camcorder;
+ MMCamcorderStateType current_state = MM_CAMCORDER_STATE_NONE;
+ _MMCamcorderSubContext *sc = NULL;
- mmf_return_if_fail(hcamcorder && hcamcorder->sub_context && hcamcorder->sub_context->info_image);
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(hcamcorder->support_extra_preview, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
+ mmf_return_val_if_fail(stream_id >= 0 && stream_id < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM,
+ MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ mmf_return_val_if_fail(interval, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- _mmcam_dbg_log("START");
+ mm_camcorder_get_state(camcorder, ¤t_state);
- info = hcamcorder->sub_context->info_image;
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ sc = MMF_CAMCORDER_SUBCONTEXT(camcorder);
+ mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!gst_camera_control_get_extra_preview_gop_interval(control, stream_id, &_interval)) {
+ MMCAM_LOG_ERROR("get GOP interval for stream[%d] failed", stream_id);
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
- __ta__(" GET_IN_CB:mm_sound_volume_get_value",
- mm_sound_volume_get_value(VOLUME_TYPE_MEDIA, &info->volume_level);
- );
+ *interval = _interval;
+ } else {
+ *interval = hcamcorder->extra_preview_format[stream_id].gop_interval;
+ }
- _mmcam_dbg_log("DONE : volume level %d", info->volume_level);
+ MMCAM_LOG_INFO("get GOP interval[%d] for stream[%d][state:%d]",
+ *interval, stream_id, current_state);
- return;
+ return MM_ERROR_NONE;
}