Name: libmm-camcorder
Summary: Camera and recorder library
-Version: 0.10.186
+Version: 0.10.187
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
guint64 _mmcamcorder_get_container_size(const guchar *size);
guint64 _mmcamcorder_get_container_size64(const guchar *size);
gboolean _mmcamcorder_update_composition_matrix(FILE *f, int orientation);
+void _mmcamcorder_adjust_recording_max_size(const char *filename, guint64 *max_size);
/* File system */
+int _mmcamcorder_get_storage_validity(MMHandleType handle, const char *filename, guint64 min_space, gboolean *storage_validity);
int _mmcamcorder_get_storage_info(const gchar *path, const gchar *root_directory, _MMCamcorderStorageInfo *storage_info);
int _mmcamcorder_get_freespace(storage_type_e type, guint64 *free_space);
int _mmcamcorder_get_file_size(const char *filename, guint64 *size);
{
int cmd = command;
int ret = MM_ERROR_NONE;
- int err = 0;
- guint64 free_space = 0;
char *err_attr_name = NULL;
GstElement *pipeline = NULL;
case _MMCamcorder_CMD_RECORD:
/* check status for resume case */
if (_mmcamcorder_get_state((MMHandleType)hcamcorder) != MM_CAMCORDER_STATE_PAUSED) {
+ gboolean storage_validity = FALSE;
guint imax_size = 0;
guint imax_time = 0;
- char *temp_filename = NULL;
- char *dir_name = NULL;
- int file_system_type = 0;
+ char *target_filename = NULL;
int filename_length = 0;
int root_directory_length = 0;
MMCAM_TARGET_MAX_SIZE, &imax_size,
MMCAM_TARGET_TIME_LIMIT, &imax_time,
MMCAM_FILE_FORMAT, &(info->fileformat),
- MMCAM_TARGET_FILENAME, &temp_filename, &filename_length,
+ MMCAM_TARGET_FILENAME, &target_filename, &filename_length,
MMCAM_ROOT_DIRECTORY, &hcamcorder->root_directory, &root_directory_length,
NULL);
if (ret != MM_ERROR_NONE) {
goto _ERR_CAMCORDER_AUDIO_COMMAND;
}
- if (!temp_filename && !hcamcorder->mstream_cb) {
+ if (!target_filename && !hcamcorder->mstream_cb) {
_mmcam_dbg_err("filename is not set and muxed stream cb is NULL");
ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
goto _ERR_CAMCORDER_AUDIO_COMMAND;
SAFE_G_FREE(info->filename);
- if (temp_filename) {
- info->filename = g_strdup(temp_filename);
+ if (target_filename) {
+ info->filename = g_strdup(target_filename);
if (!info->filename) {
- _mmcam_dbg_err("STRDUP was failed for [%s]", temp_filename);
+ _mmcam_dbg_err("STRDUP was failed for [%s]", target_filename);
goto _ERR_CAMCORDER_AUDIO_COMMAND;
}
else
info->max_time = ((guint64)imax_time) * 1000; /* to millisecond */
- /* TODO : check free space before recording start */
- dir_name = g_path_get_dirname(info->filename);
- if (dir_name) {
- err = _mmcamcorder_get_storage_info(dir_name, hcamcorder->root_directory, &hcamcorder->storage_info);
- if (err != 0) {
- _mmcam_dbg_err("get storage info failed");
- g_free(dir_name);
- dir_name = NULL;
- return MM_ERROR_OUT_OF_STORAGE;
- }
-
- err = _mmcamcorder_get_freespace(hcamcorder->storage_info.type, &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 %lu",
- 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");
- err = -1;
+ ret = _mmcamcorder_get_storage_validity(handle, info->filename,
+ _MMCAMCORDER_AUDIO_MINIMUM_SPACE, &storage_validity);
+ if (ret != MM_ERROR_NONE || !storage_validity) {
+ _mmcam_dbg_err("storage validation failed[0x%x]:%d", ret, storage_validity);
+ return ret;
}
- if (temp_filename &&
- (err == -1 || free_space <= _MMCAMCORDER_AUDIO_MINIMUM_SPACE)) {
- _mmcam_dbg_err("OUT of STORAGE [err:%d or free space [%" G_GUINT64_FORMAT "] is smaller than [%d]",
- err, free_space, _MMCAMCORDER_AUDIO_MINIMUM_SPACE);
- return MM_ERROR_OUT_OF_STORAGE;
- }
+ _mmcamcorder_adjust_recording_max_size(info->filename, &info->max_size);
}
ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING);
GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
{
GstBusSyncReply ret = GST_BUS_PASS;
- GstElement *element = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(data);
_MMCamcorderSubContext *sc = NULL;
}
+int _mmcamcorder_get_storage_validity(MMHandleType handle, const char *filename, guint64 min_space, gboolean *storage_validity)
+{
+ int ret = MM_ERROR_NONE;
+ int err = 0;
+ char *dir_name = NULL;
+ guint64 free_space = 0;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ mmf_return_val_if_fail(storage_validity, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ if (!filename) {
+ _mmcam_dbg_warn("NULL filename, but keep going...");
+ *storage_validity = TRUE;
+ return MM_ERROR_NONE;
+ }
+
+ dir_name = g_path_get_dirname(filename);
+ mmf_return_val_if_fail(dir_name, MM_ERROR_OUT_OF_STORAGE);
+
+ err = _mmcamcorder_get_storage_info(dir_name, hcamcorder->root_directory, &hcamcorder->storage_info);
+ if (err != 0) {
+ _mmcam_dbg_err("get storage info failed");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _CHECK_DONE;
+ }
+
+ err = _mmcamcorder_get_freespace(hcamcorder->storage_info.type, &free_space);
+ if (err != 0) {
+ _mmcam_dbg_err("get free space failed");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _CHECK_DONE;
+ }
+
+ _mmcam_dbg_warn("current free space - %s [%" G_GUINT64_FORMAT "]", dir_name, free_space);
+
+_CHECK_DONE:
+ g_free(dir_name);
+
+ if (ret == MM_ERROR_NONE && free_space > min_space) {
+ *storage_validity = TRUE;
+ _mmcam_dbg_log("validity and free space of storage : OK");
+ } else {
+ *storage_validity = FALSE;
+ _mmcam_dbg_err("OUT of STORAGE [err:%d or free space [%"G_GUINT64_FORMAT"] is smaller than [%"G_GUINT64_FORMAT"]",
+ err, free_space, min_space);
+ }
+
+ return ret;
+}
+
+
+void _mmcamcorder_adjust_recording_max_size(const char *filename, guint64 *max_size)
+{
+ int file_system_type = 0;
+ char *dir_name = NULL;
+
+ mmf_return_if_fail(max_size);
+ mmf_return_if_fail(filename);
+
+ dir_name = g_path_get_dirname(filename);
+ mmf_return_if_fail(dir_name);
+
+ if (_mmcamcorder_get_file_system_type(dir_name, &file_system_type) == 0) {
+ /* MSDOS_SUPER_MAGIC : 0x4d44 */
+ if (file_system_type == MSDOS_SUPER_MAGIC &&
+ (*max_size == 0 || *max_size > FAT32_FILE_SYSTEM_MAX_SIZE)) {
+ _mmcam_dbg_warn("FAT32 and too large max[%"G_GUINT64_FORMAT"], set max as %lu",
+ *max_size, FAT32_FILE_SYSTEM_MAX_SIZE);
+ *max_size = FAT32_FILE_SYSTEM_MAX_SIZE;
+ } else {
+ _mmcam_dbg_warn("file system 0x%x, max size %"G_GUINT64_FORMAT,
+ file_system_type, *max_size);
+ }
+ }
+
+ g_free(dir_name);
+}
+
+
int _mmcamcorder_get_storage_info(const gchar *path, const gchar *root_directory, _MMCamcorderStorageInfo *info)
{
int ret = 0;
int ret = MM_ERROR_NONE;
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
char *err_name = NULL;
- char *temp_filename = NULL;
+ char *target_filename = NULL;
GstCameraControl *CameraControl = NULL;
GstCameraControlChannel *CameraControlChannel = NULL;
const GList *controls = NULL;
/**
* start recording
*/
+ gboolean storage_validity = FALSE;
guint imax_size = 0;
guint imax_time = 0;
- int ret_free_space = 0;
- char *dir_name = NULL;
- guint64 free_space = 0;
- int file_system_type = 0;
int root_directory_length = 0;
/* Recording */
MMCAM_VIDEO_WIDTH, &(info->video_width),
MMCAM_VIDEO_HEIGHT, &(info->video_height),
MMCAM_FILE_FORMAT, &fileformat,
- MMCAM_TARGET_FILENAME, &temp_filename, &size,
+ MMCAM_TARGET_FILENAME, &target_filename, &size,
MMCAM_TARGET_MAX_SIZE, &imax_size,
MMCAM_TARGET_TIME_LIMIT, &imax_time,
MMCAM_FILE_FORMAT, &(info->fileformat),
goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
- if (!temp_filename && !hcamcorder->mstream_cb) {
+ if (!target_filename && !hcamcorder->mstream_cb) {
_mmcam_dbg_err("filename is not set and muxed stream cb is NULL");
ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
goto _ERR_CAMCORDER_VIDEO_COMMAND;
else
info->max_time = (guint64)((double)imax_time * (double)1000 * motion_rate); /* to millisecond */
- dir_name = g_path_get_dirname(temp_filename);
- if (dir_name) {
- ret = _mmcamcorder_get_storage_info(dir_name, hcamcorder->root_directory, &hcamcorder->storage_info);
- if (ret != 0) {
- _mmcam_dbg_err("get storage info failed");
- g_free(dir_name);
- dir_name = NULL;
- return MM_ERROR_OUT_OF_STORAGE;
- }
-
- ret_free_space = _mmcamcorder_get_freespace(hcamcorder->storage_info.type, &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 %lu",
- 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;
+ ret = _mmcamcorder_get_storage_validity(hcamcorder, target_filename,
+ _MMCAMCORDER_VIDEO_MINIMUM_SPACE, &storage_validity);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("storage validation failed[0x%x]:%d", ret, storage_validity);
+ return ret;
}
- if (temp_filename &&
- (ret_free_space == -1 || free_space <= _MMCAMCORDER_VIDEO_MINIMUM_SPACE)) {
- _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_VIDEO_MINIMUM_SPACE);
- return MM_ERROR_OUT_OF_STORAGE;
- }
+ _mmcamcorder_adjust_recording_max_size(target_filename, &info->max_size);
g_mutex_lock(&hcamcorder->task_thread_lock);
if (sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst == NULL &&