+ dir_name = g_path_get_dirname(temp_filename);
+ if (dir_name) {
+ ret_free_space = _mmcamcorder_get_freespace(dir_name, hcamcorder->root_directory, &free_space);
+
+ _mmcam_dbg_warn("current space - %s [%" G_GUINT64_FORMAT "]", dir_name, free_space);
+
+ if (_mmcamcorder_get_file_system_type(dir_name, &file_system_type) == 0) {
+ /* MSDOS_SUPER_MAGIC : 0x4d44 */
+ if (file_system_type == MSDOS_SUPER_MAGIC &&
+ (info->max_size == 0 || info->max_size > FAT32_FILE_SYSTEM_MAX_SIZE)) {
+ _mmcam_dbg_warn("FAT32 and too large max[%"G_GUINT64_FORMAT"], set max as %"G_GUINT64_FORMAT,
+ info->max_size, FAT32_FILE_SYSTEM_MAX_SIZE);
+ info->max_size = FAT32_FILE_SYSTEM_MAX_SIZE;
+ } else {
+ _mmcam_dbg_warn("file system 0x%x, max size %"G_GUINT64_FORMAT,
+ file_system_type, info->max_size);
+ }
+ } else {
+ _mmcam_dbg_warn("_mmcamcorder_get_file_system_type failed");
+ }
+
+ g_free(dir_name);
+ dir_name = NULL;
+ } else {
+ _mmcam_dbg_err("failed to get directory name");
+ ret_free_space = -1;
+ }
+
+ if ((ret_free_space == -1) || free_space <= (_MMCAMCORDER_MINIMUM_SPACE<<1)) {
+ _mmcam_dbg_err("OUT of STORAGE [ret_free_space:%d or free space [%" G_GUINT64_FORMAT "] is smaller than [%d]",
+ ret_free_space, free_space, (_MMCAMCORDER_MINIMUM_SPACE<<1));
+ return MM_ERROR_OUT_OF_STORAGE;
+ }
+
+ g_mutex_lock(&hcamcorder->task_thread_lock);
+ if (sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst == NULL &&
+ hcamcorder->task_thread_state == _MMCAMCORDER_TASK_THREAD_STATE_NONE) {
+ /* Play record start sound */
+ _mmcamcorder_sound_solo_play(handle, _MMCAMCORDER_SAMPLE_SOUND_NAME_REC_START, FALSE);
+ }
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
+
+ _mmcam_dbg_warn("video size [%dx%d]", info->video_width, info->video_height);
+
+ if (info->video_width == 0 || info->video_height == 0) {
+ _mmcam_dbg_warn("video size is invalid [%dx%d] use preview size [%dx%d]",
+ info->video_width, info->video_height, info->preview_width, info->preview_height);
+ info->video_width = info->preview_width;
+ info->video_height = info->preview_height;
+ }
+
+ if (info->support_dual_stream) {
+ _mmcam_dbg_warn("DUAL STREAM MODE");
+
+ info->record_dual_stream = TRUE;
+
+ /* No need to restart preview */
+ info->restart_preview = FALSE;
+
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "video-width", info->video_width);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "video-height", info->video_height);
+ } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264 &&
+ info->preview_width == info->video_width &&
+ info->preview_height == info->video_height) {
+ _mmcam_dbg_log("H264 preview mode and same resolution");
+
+ /* No need to restart preview */
+ info->restart_preview = FALSE;
+ } else {
+ /* always need to restart preview */
+ info->restart_preview = TRUE;
+ }
+
+ /* set recording hint */
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "recording-hint", TRUE);
+
+ if (info->restart_preview) {
+ /* stop preview and set new size */
+ _mmcam_dbg_log("restart preview");
+
+ 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);
+
+ ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_READY);
+
+ /* check decoder recreation */
+ if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
+ _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
+ }
+
+ 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) {
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
+ }
+
+ if (!_mmcamcorder_set_camera_resolution(handle, info->video_width, info->video_height)) {
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
+ }
+
+ /* Start preview again with new setting */
+ ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING);
+ if (ret != MM_ERROR_NONE) {
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
+ }
+
+ if (motion_rate < 1.0) {
+ _mmcam_dbg_warn("wait for stabilization of frame");
+ usleep(300000);
+ }
+ } else {
+ _mmcam_dbg_log("no need to restart preview");
+ }
+
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "DropVideoFrame",
+ &(sc->drop_vframe));
+
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "PassFirstVideoFrame",
+ &(sc->pass_first_vframe));
+
+ _mmcam_dbg_log("Drop video frame count[%d], Pass fisrt video frame count[%d]",
+ sc->drop_vframe, sc->pass_first_vframe);
+
+ info->record_drop_count = (guint)motion_rate;
+ info->record_motion_rate = motion_rate;