Update code for encoded preview setting
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_stillshot.c
index 1cab27e..5fc9c95 100644 (file)
@@ -53,8 +53,6 @@ do { \
 #define THUMBNAIL_JPEG_QUALITY  90
 #define TRY_LOCK_MAX_COUNT      100
 #define TRY_LOCK_TIME           20000   /* ms */
-#define H264_PREVIEW_BITRATE    1024*10 /* kbps */
-#define H264_PREVIEW_NEWGOP_INTERVAL    1000 /* ms */
 #define _MMCAMCORDER_MAKE_THUMBNAIL_INTERNAL_ENCODE
 
 
@@ -300,7 +298,6 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle)
        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;
@@ -355,7 +352,7 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle)
                MMCAM_CAMERA_WIDTH, &width,
                MMCAM_CAMERA_HEIGHT, &height,
                MMCAM_CAMERA_FPS, &fps,
-               MMCAM_CAPTURE_FORMAT, &cap_format,
+               MMCAM_CAPTURE_FORMAT, &info->capture_format,
                MMCAM_CAPTURE_WIDTH, &info->width,
                MMCAM_CAPTURE_HEIGHT, &info->height,
                MMCAM_CAPTURE_COUNT, &info->count,
@@ -387,7 +384,7 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle)
        }
 
        _mmcam_dbg_log("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, cap_format,
+               width, height, info->preview_format, info->width, info->height, info->capture_format,
                info->count, info->hdr_capture_mode, info->interval);
 
        /* check state */
@@ -428,10 +425,10 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle)
 
        if (!sc->bencbin_capture) {
                /* Check encoding method */
-               if (cap_format == MM_PIXEL_FORMAT_ENCODED) {
+               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(cap_format, image_encoder, hcamcorder->use_zero_copy_format);
+                               cap_fourcc = _mmcamcorder_get_fourcc(info->capture_format, image_encoder, hcamcorder->use_zero_copy_format);
                                _mmcam_dbg_log("Sensor JPEG Capture [is_modified_size:%d]", is_modified_size);
                        } else {
                                /* no need to encode internally if ITLV format */
@@ -444,10 +441,10 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle)
                                        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);
+                       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_dbg_log("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);
@@ -634,6 +631,8 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
        int height = 0;
        int fps = 0;
        int rotation = 0;
+       int bitrate = 0;
+       int gop_interval = 0;
        unsigned int current_framecount = 0;
        int current_state = MM_CAMCORDER_STATE_NONE;
        gboolean fps_auto = FALSE;
@@ -687,10 +686,11 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
                                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);
@@ -817,8 +817,16 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
                        _mmcamcorder_sound_finalize(handle);
        } else {
                if (info->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-                       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "bitrate", H264_PREVIEW_BITRATE);
-                       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "newgop-interval", H264_PREVIEW_NEWGOP_INTERVAL);
+                       ret = mm_camcorder_get_attributes(handle, NULL,
+                               MMCAM_ENCODED_PREVIEW_BITRATE, &bitrate,
+                               MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval,
+                               NULL);
+                       if (ret == MM_ERROR_NONE) {
+                               _mmcamcorder_set_encoded_preview_bitrate(handle, bitrate);
+                               _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
+                       } else {
+                               _mmcam_dbg_err("failed to get encoded preview setting");
+                       }
                }
 
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
@@ -1523,8 +1531,8 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstSample *sampl
                _mmcam_dbg_log("Done Internal Encode - data %p, length %d", dest.data, dest.length);
        }
 
-       if (pixtype_main < MM_PIXEL_FORMAT_ENCODED) {
-               _mmcam_dbg_log("raw capture, skip EXIF related functions");
+       if (info->capture_format != MM_PIXEL_FORMAT_ENCODED) {
+               _mmcam_dbg_log("not encoded format, skip exif related sequence");
                goto _CAPTURE_CB_EXIF_DONE;
        }