| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------------------*/
/* STATIC INTERNAL FUNCTION */
-static void __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data);
+static gboolean __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data);
static GstPadProbeReturn __mmcamcorder_audio_dataprobe_check(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
static GstPadProbeReturn __mmcamcorder_audioque_dataprobe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
static GstPadProbeReturn __mmcamcorder_video_dataprobe_audio_disable(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
static GstPadProbeReturn __mmcamcorder_audio_dataprobe_audio_mute(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
-static gboolean __mmcamcorder_add_locationinfo(MMHandleType handle, int fileformat);
-static gboolean __mmcamcorder_add_locationinfo_mp4(MMHandleType handle);
+static gboolean __mmcamcorder_add_metadata(MMHandleType handle, int fileformat);
+static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle);
static GstPadProbeReturn __mmcamcorder_eventprobe_monitor(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
/*=======================================================================================
/*---------------------------------------------------------------------------------------
| GLOBAL FUNCTION DEFINITIONS: |
---------------------------------------------------------------------------------------*/
-static void __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data)
+static gboolean __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
_MMCamcorderSubContext *sc = NULL;
GstBuffer *buffer = gst_sample_get_buffer(sample);
- mmf_return_if_fail(buffer);
- mmf_return_if_fail(gst_buffer_n_memory(buffer));
- mmf_return_if_fail(hcamcorder);
+ mmf_return_val_if_fail(buffer, FALSE);
+ mmf_return_val_if_fail(gst_buffer_n_memory(buffer), FALSE);
+ mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
- mmf_return_if_fail(sc);
+ mmf_return_val_if_fail(sc, FALSE);
/*
_mmcam_dbg_log("ENTER - push_encoding_buffer %d, buffer %p, MALLOCDATA %p, size %d",
sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst) {
GstFlowReturn ret = 0;
GstClock *pipe_clock = NULL;
- GstPad *capsfilter_pad = NULL;
if(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
if(sc->info_video->is_firstframe) {
GST_BUFFER_PTS(buffer) = GST_BUFFER_PTS (buffer) - sc->info_video->base_video_ts;
- capsfilter_pad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst, "src");
-// gst_buffer_set_caps(buffer, gst_pad_get_current_caps(capsfilter_pad));
- gst_object_unref(capsfilter_pad);
- capsfilter_pad = NULL;
-
ret = gst_app_src_push_buffer((GstAppSrc *)sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, buffer);
if (ret != GST_FLOW_OK &&
ret != GST_FLOW_FLUSHING) {
buffer = NULL;
}
- return;
+ return TRUE;
}
{
int size = 0;
int fileformat = 0;
+ int count = 0;
int ret = MM_ERROR_NONE;
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
char *err_name = NULL;
char *dir_name = NULL;
guint64 free_space = 0;
int file_system_type = 0;
+ int root_directory_length = 0;
/* Recording */
_mmcam_dbg_log("Record Start - dual stream %d", info->support_dual_stream);
MMCAM_TARGET_TIME_LIMIT, &imax_time,
MMCAM_FILE_FORMAT, &(info->fileformat),
MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
+ MMCAM_ROOT_DIRECTORY, &hcamcorder->root_directory, &root_directory_length,
NULL);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, ret);
dir_name = g_path_get_dirname(temp_filename);
if (dir_name) {
- ret_free_space = _mmcamcorder_get_freespace(dir_name, &free_space);
+ 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);
return MM_ERROR_OUT_OF_STORAGE;
}
- pthread_mutex_lock(&(hcamcorder->task_thread_lock));
+ 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_FILEPATH_REC_START_SND, FALSE);
+ _mmcamcorder_sound_solo_play(handle, _MMCAMCORDER_SAMPLE_SOUND_NAME_REC_START, FALSE);
}
- pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
_mmcam_dbg_warn("video size [%dx%d]", info->video_width, info->video_height);
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");
/* start video stream */
if (info->record_dual_stream) {
- GstCameraControl *control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
- if (control) {
+ CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (CameraControl) {
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE);
-#ifdef LATEST_CAMERA_CONTROL
+
_mmcam_dbg_log("GST_CAMERA_CONTROL_RECORD_COMMAND_START");
- gst_camera_control_set_record_command(control, GST_CAMERA_CONTROL_RECORD_COMMAND_START);
-#endif /* LATEST_CAMERA_CONTROL */
+ gst_camera_control_set_record_command(CameraControl, GST_CAMERA_CONTROL_RECORD_COMMAND_START);
+
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
} else {
_mmcam_dbg_err("could not get camera control");
}
/* check pre-created encode pipeline */
- pthread_mutex_lock(&(hcamcorder->task_thread_lock));
+ 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) {
/* create encoding pipeline */
ret =_mmcamcorder_video_prepare_record((MMHandleType)hcamcorder);
if (ret != MM_ERROR_NONE) {
- pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
}
- pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
/* check recording start sound */
_mmcamcorder_sound_solo_play_wait(handle);
info->filesize = 0;
sc->ferror_send = FALSE;
sc->ferror_count = 0;
- sc->error_occurs = FALSE;
+ hcamcorder->error_occurs = FALSE;
sc->bget_eos = FALSE;
ret = _mmcamcorder_gst_set_state(handle, sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst, GST_STATE_PLAYING);
if (ret != MM_ERROR_NONE) {
/* stop video stream */
if (info->record_dual_stream) {
- GstCameraControl *control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
- if (control) {
+ CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (CameraControl) {
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE);
-#ifdef LATEST_CAMERA_CONTROL
+
_mmcam_dbg_log("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
- gst_camera_control_set_record_command(control, GST_CAMERA_CONTROL_RECORD_COMMAND_STOP);
-#endif /* LATEST_CAMERA_CONTROL */
+ gst_camera_control_set_record_command(CameraControl, GST_CAMERA_CONTROL_RECORD_COMMAND_STOP);
+
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
} else {
_mmcam_dbg_err("failed to get camera control");
break;
case _MMCamcorder_CMD_PAUSE:
{
- int count = 0;
-
if (info->b_commiting) {
_mmcam_dbg_warn("now on commiting previous file!!(command : %d)", command);
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME) {
break;
} else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
- _mmcam_dbg_err("Pause fail, frame count %" G_GUINT64_FORMAT "",
+ _mmcam_dbg_err("Pause fail, frame count %llu",
info->video_frame_count);
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
} else {
- _mmcam_dbg_warn("Waiting for enough video frame, retrial[%d], frame %" G_GUINT64_FORMAT "",
+ _mmcam_dbg_warn("Waiting for enough video frame, retrial[%d], frame %llu",
count, info->video_frame_count);
}
if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME && info->audio_frame_count) {
break;
} else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
- _mmcam_dbg_err("Pause fail, frame count VIDEO[%" G_GUINT64_FORMAT "], AUDIO [%" G_GUINT64_FORMAT "]",
+ _mmcam_dbg_err("Pause fail, frame count VIDEO[%llu], AUDIO [%llu]",
info->video_frame_count, info->audio_frame_count);
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
} else {
- _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%" G_GUINT64_FORMAT "], AUDIO [%" G_GUINT64_FORMAT "]",
+ _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%llu], AUDIO [%llu]",
count, info->video_frame_count, info->audio_frame_count);
}
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
}
+ for (count = 0 ; count <= _MMCAMCORDER_RETRIAL_COUNT ; count++) {
+ /* capturing */
+ if (hcamcorder->capture_in_recording == FALSE) {
+ break;
+ } else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
+ _mmcam_dbg_err("Failed to Wait capture data");
+ hcamcorder->capture_in_recording = FALSE;
+ break;
+ } else {
+ _mmcam_dbg_warn("Waiting for capture data - retrial [%d]", count);
+ }
+
+ usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
+ }
+
/* block push buffer */
info->push_encoding_buffer = PUSH_ENCODING_BUFFER_STOP;
goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
+ /* set recording hint */
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "recording-hint", FALSE);
+
/* stop video stream */
if (info->record_dual_stream) {
- GstCameraControl *control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
- if (control) {
+ CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (CameraControl) {
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE);
-#ifdef LATEST_CAMERA_CONTROL
+
_mmcam_dbg_log("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
- gst_camera_control_set_record_command(control, GST_CAMERA_CONTROL_RECORD_COMMAND_STOP);
-#endif /* LATEST_CAMERA_CONTROL */
+ gst_camera_control_set_record_command(CameraControl, GST_CAMERA_CONTROL_RECORD_COMMAND_STOP);
+
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
} else {
_mmcam_dbg_err("failed to get camera control");
/* reset restart_preview for inset window layout */
info->restart_preview = FALSE;
- ret = _mmcamcorder_set_camera_resolution(handle, info->preview_width, info->preview_height);
- if (ret != MM_ERROR_NONE) {
+ if (!_mmcamcorder_set_camera_resolution(handle, info->preview_width, info->preview_height)) {
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
info->video_frame_count = 0;
info->audio_frame_count = 0;
info->filesize = 0;
+ hcamcorder->capture_in_recording = FALSE;
break;
}
case _MMCamcorder_CMD_COMMIT:
{
- int count = 0;
-
if (info->b_commiting) {
_mmcam_dbg_err("now on commiting previous file!!(command : %d)", command);
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
for (count = 0 ; count <= _MMCAMCORDER_RETRIAL_COUNT ; count++) {
if (sc->audio_disable) {
/* check only video frame */
- if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME) {
+ if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME &&
+ hcamcorder->capture_in_recording == FALSE) {
break;
} else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
- _mmcam_dbg_err("Commit fail, frame count is %" G_GUINT64_FORMAT "",
- info->video_frame_count);
- info->b_commiting = FALSE;
- return MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ _mmcam_dbg_err("Commit fail, frame count is %llu, capturing %d",
+ info->video_frame_count, hcamcorder->capture_in_recording);
+
+ if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME) {
+ _mmcam_dbg_warn("video frames are enough. keep going...");
+ } else {
+ info->b_commiting = FALSE;
+ return MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ }
} else {
- _mmcam_dbg_warn("Waiting for enough video frame, retrial [%d], frame %" G_GUINT64_FORMAT "",
- count, info->video_frame_count);
+ _mmcam_dbg_warn("Waiting for enough video frame, retrial [%d], frame %llu, capturing %d",
+ count, info->video_frame_count, hcamcorder->capture_in_recording);
}
-
- usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
} else {
/* check both of video and audio frame */
- if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME && info->audio_frame_count) {
+ if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME &&
+ info->audio_frame_count &&
+ hcamcorder->capture_in_recording == FALSE) {
break;
} else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
- _mmcam_dbg_err("Commit fail, VIDEO[%" G_GUINT64_FORMAT "], AUDIO [%" G_GUINT64_FORMAT "]",
- info->video_frame_count, info->audio_frame_count);
+ _mmcam_dbg_err("Commit fail, VIDEO[%llu], AUDIO [%llu], capturing %d",
+ info->video_frame_count, info->audio_frame_count, hcamcorder->capture_in_recording);
+
+ if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME && info->audio_frame_count) {
+ _mmcam_dbg_warn("video/audio frames are enough. keep going...");
+ } else {
+ info->b_commiting = FALSE;
+ return MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ }
- info->b_commiting = FALSE;
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
} else {
- _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%" G_GUINT64_FORMAT "], AUDIO [%" G_GUINT64_FORMAT "]",
- count, info->video_frame_count, info->audio_frame_count);
+ _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%llu], AUDIO [%llu], capturing %d",
+ count, info->video_frame_count, info->audio_frame_count, hcamcorder->capture_in_recording);
}
-
- usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
}
+
+ usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
}
/* block push buffer */
_mmcam_dbg_log("block push buffer to appsrc");
if (sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst != NULL) {
- ret = gst_element_send_event(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, gst_event_new_eos());
- _mmcam_dbg_warn("send eos to appsrc result : %d", ret);
+ if (gst_element_send_event(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, gst_event_new_eos())) {
+ _mmcam_dbg_warn("VIDEO: send eos to appsrc done");
+ } else {
+ _mmcam_dbg_err("VIDEO: send EOS failed");
+ info->b_commiting = FALSE;
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
+ }
+ } else {
+ _mmcam_dbg_err("No video stream source");
+ info->b_commiting = FALSE;
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst != NULL) {
- ret = gst_element_send_event(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, gst_event_new_eos());
- _mmcam_dbg_warn("send eos to audiosrc result : %d", ret);
+ if (gst_element_send_event(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, gst_event_new_eos())) {
+ _mmcam_dbg_warn("AUDIO: send eos to audiosrc done");
+ } else {
+ _mmcam_dbg_err("AUDIO: send EOS failed");
+ info->b_commiting = FALSE;
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
+ }
+ } else {
+ _mmcam_dbg_log("No audio stream");
}
/* sc */
info->b_commiting = FALSE;
goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
+
+ /* reset flag */
+ hcamcorder->capture_in_recording = FALSE;
}
break;
default:
if (hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_ASM) {
/* Play record stop sound */
- _mmcamcorder_sound_solo_play(handle, _MMCAMCORDER_FILEPATH_REC_STOP_SND, FALSE);
+ _mmcamcorder_sound_solo_play(handle, _MMCAMCORDER_SAMPLE_SOUND_NAME_REC_STOP, FALSE);
} else {
_mmcam_dbg_warn("Play stop sound through pulseaudio");
-#ifdef _MMCAMCORDER_UPLOAD_SAMPLE
- _mmcamcorder_sound_init(handle, _MMCAMCORDER_FILEPATH_REC_STOP_SND);
-#else /* _MMCAMCORDER_UPLOAD_SAMPLE */
_mmcamcorder_sound_init(handle);
-#endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
_mmcamcorder_sound_play((MMHandleType)hcamcorder, _MMCAMCORDER_SAMPLE_SOUND_NAME_REC_STOP, TRUE);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", FALSE);
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_TAG_ENABLE, &enabletag,
+ MMCAM_RECORDER_TAG_ENABLE, &enabletag,
NULL);
ret = _mmcamcorder_remove_recorder_pipeline((MMHandleType)hcamcorder);
_mmcam_dbg_warn("_MMCamcorder_CMD_COMMIT:__mmcamcorder_remove_recorder_pipeline failed. error[%x]", ret);
}
+ /* set recording hint */
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "recording-hint", FALSE);
+
/* stop video stream */
if (info->record_dual_stream) {
GstCameraControl *control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control) {
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE);
-#ifdef LATEST_CAMERA_CONTROL
+
_mmcam_dbg_log("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
gst_camera_control_set_record_command(control, GST_CAMERA_CONTROL_RECORD_COMMAND_STOP);
-#endif /* LATEST_CAMERA_CONTROL */
+
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
} else {
_mmcam_dbg_err("failed to get camera control");
}
if (enabletag && !(sc->ferror_send)) {
- ret = __mmcamcorder_add_locationinfo((MMHandleType)hcamcorder, info->fileformat);
+ ret = __mmcamcorder_add_metadata((MMHandleType)hcamcorder, info->fileformat);
if (ret) {
_mmcam_dbg_log("Writing location information SUCCEEDED !!");
} else {
_mmcam_dbg_err("File size is greater than max size !!");
message.id = MM_MESSAGE_CAMCORDER_ERROR;
message.param.code = MM_ERROR_CAMCORDER_FILE_SIZE_OVER;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &message);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &message);
}
}
if (ret != MM_ERROR_NONE) {
msg.id = MM_MESSAGE_CAMCORDER_ERROR;
msg.param.code = ret;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
_mmcam_dbg_err("Failed to set state READY[%x]", ret);
}
if (ret != MM_ERROR_NONE) {
msg.id = MM_MESSAGE_CAMCORDER_ERROR;
msg.param.code = ret;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
_mmcam_dbg_err("Failed to set state PLAYING[%x]", ret);
}
} else {
/* Send recording report to application */
msg.id = MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED;
- report = (MMCamRecordingReport *)malloc(sizeof(MMCamRecordingReport));
+ report = (MMCamRecordingReport *)g_malloc(sizeof(MMCamRecordingReport));
if (!report) {
_mmcam_dbg_err("Recording report fail(%s). Out of memory.", info->filename);
} else {
- report->recording_filename = strdup(info->filename);
+ report->recording_filename = g_strdup(info->filename);
msg.param.data= report;
msg.param.code = 1;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
/* Finishing */
sc->pause_time = 0;
sc->isMaxsizePausing = FALSE; /*In async function, this variable should set in callback function. */
sc->isMaxtimePausing = FALSE;
- sc->error_occurs = FALSE;
+ hcamcorder->error_occurs = FALSE;
info->video_frame_count = 0;
info->audio_frame_count = 0;
/*_mmcam_dbg_err("[%" GST_TIME_FORMAT "]", GST_TIME_ARGS(GST_BUFFER_PTS(buffer)));*/
- pthread_mutex_lock(&(videoinfo->size_check_lock));
+ g_mutex_lock(&videoinfo->size_check_lock);
if (videoinfo->audio_frame_count == 0) {
videoinfo->filesize += buffer_size;
videoinfo->audio_frame_count++;
- pthread_mutex_unlock(&(videoinfo->size_check_lock));
+ g_mutex_unlock(&videoinfo->size_check_lock);
return GST_PAD_PROBE_OK;
}
if (sc->ferror_send || sc->isMaxsizePausing) {
_mmcam_dbg_warn("Recording is paused, drop frames");
- pthread_mutex_unlock(&(videoinfo->size_check_lock));
+ g_mutex_unlock(&videoinfo->size_check_lock);
return GST_PAD_PROBE_DROP;
}
}
msg.id = MM_MESSAGE_CAMCORDER_MAX_SIZE;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
- pthread_mutex_unlock(&(videoinfo->size_check_lock));
+ g_mutex_unlock(&videoinfo->size_check_lock);
return FALSE;
}
videoinfo->filesize += buffer_size;
videoinfo->audio_frame_count++;
- pthread_mutex_unlock(&(videoinfo->size_check_lock));
+ g_mutex_unlock(&videoinfo->size_check_lock);
return GST_PAD_PROBE_OK;
}
guint64 buffer_size = 0;
guint64 trailer_size = 0;
guint64 queued_buffer = 0;
- char *filename = NULL;
+ char *dir_name = NULL;
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
GstMapInfo mapinfo;
if (videoinfo->video_frame_count <= (guint64)_MMCAMCORDER_MINIMUM_FRAME) {
/* _mmcam_dbg_log("Pass minimum frame: info->video_frame_count: %" G_GUINT64_FORMAT " ",
info->video_frame_count); */
- pthread_mutex_lock(&(videoinfo->size_check_lock));
+ g_mutex_lock(&videoinfo->size_check_lock);
videoinfo->filesize += buffer_size;
- pthread_mutex_unlock(&(videoinfo->size_check_lock));
+ g_mutex_unlock(&videoinfo->size_check_lock);
return GST_PAD_PROBE_OK;
}
trailer_size = 0;
}
- filename = videoinfo->filename;
- ret = _mmcamcorder_get_freespace(filename, &free_space);
+ dir_name = g_path_get_dirname(videoinfo->filename);
+ if (dir_name) {
+ ret = _mmcamcorder_get_freespace(dir_name, hcamcorder->root_directory, &free_space);
+ g_free(dir_name);
+ dir_name = NULL;
+ } else {
+ _mmcam_dbg_err("failed to get dir name from [%s]", videoinfo->filename);
+ ret = -1;
+ }
/*_mmcam_dbg_log("check free space for recording");*/
} else {
msg.param.code = MM_ERROR_FILE_READ;
}
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
} else {
sc->ferror_count++;
}
sc->isMaxsizePausing = TRUE;
msg.id = MM_MESSAGE_CAMCORDER_NO_FREE_SPACE;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
return GST_PAD_PROBE_DROP;
break;
}
- pthread_mutex_lock(&(videoinfo->size_check_lock));
+ g_mutex_lock(&videoinfo->size_check_lock);
/* check max size of recorded file */
if (videoinfo->max_size > 0 &&
}
msg.id = MM_MESSAGE_CAMCORDER_MAX_SIZE;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
- pthread_mutex_unlock(&(videoinfo->size_check_lock));
+ g_mutex_unlock(&videoinfo->size_check_lock);
return GST_PAD_PROBE_DROP;
}
_mmcam_dbg_log("filesize %lld Byte, ", videoinfo->filesize);
*/
- pthread_mutex_unlock(&(videoinfo->size_check_lock));
+ g_mutex_unlock(&videoinfo->size_check_lock);
return GST_PAD_PROBE_OK;
}
msg.param.recording_status.elapsed = (unsigned long long)rec_pipe_time;
msg.param.recording_status.filesize = (unsigned long long)((videoinfo->filesize + trailer_size) >> 10);
msg.param.recording_status.remained_time = 0;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
msg.id = MM_MESSAGE_CAMCORDER_TIME_LIMIT;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
return GST_PAD_PROBE_DROP;
msg.param.recording_status.elapsed = (unsigned long long)rec_pipe_time;
msg.param.recording_status.filesize = (unsigned long long)((videoinfo->filesize + trailer_size) >> 10);
msg.param.recording_status.remained_time = remained_time;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
/*
_mmcam_dbg_log("time [%" GST_TIME_FORMAT "], size [%d]",
msg.param.recording_status.elapsed = (unsigned long long)rec_pipe_time;
msg.param.recording_status.filesize = (unsigned long long)((videoinfo->filesize + trailer_size) >> 10);
msg.param.recording_status.remained_time = 0;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
msg.id = MM_MESSAGE_CAMCORDER_TIME_LIMIT;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
return GST_PAD_PROBE_DROP;
msg.param.recording_status.elapsed = (unsigned long long)rec_pipe_time;
msg.param.recording_status.filesize = (unsigned long long)((videoinfo->filesize + trailer_size) >> 10);
msg.param.recording_status.remained_time = remained_time;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
/*
_mmcam_dbg_log("audio data probe :: time [%" GST_TIME_FORMAT "], size [%lld KB]",
int err = MM_ERROR_UNKNOWN;
char *err_name = NULL;
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
- GstMapInfo mapinfo = GST_MAP_INFO_INIT;
+ GstMapInfo mapinfo;
mmf_return_val_if_fail(buffer, GST_PAD_PROBE_DROP);
mmf_return_val_if_fail(hcamcorder, GST_PAD_PROBE_DROP);
SAFE_FREE(err_name);
return err;
}
+
+ memset(&mapinfo, 0x0, sizeof(GstMapInfo));
+
gst_buffer_map(buffer, &mapinfo, GST_MAP_READWRITE);
/* Set audio stream NULL */
}
-static gboolean __mmcamcorder_add_locationinfo(MMHandleType handle, int fileformat)
+static gboolean __mmcamcorder_add_metadata(MMHandleType handle, int fileformat)
{
gboolean bret = FALSE;
switch (fileformat) {
case MM_FILE_FORMAT_3GP:
case MM_FILE_FORMAT_MP4:
- bret = __mmcamcorder_add_locationinfo_mp4(handle);
+ bret = __mmcamcorder_add_metadata_mp4(handle);
break;
default:
_mmcam_dbg_warn("Unsupported fileformat to insert location info (%d)", fileformat);
}
-static gboolean __mmcamcorder_add_locationinfo_mp4(MMHandleType handle)
+static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
{
FILE *f = NULL;
guchar buf[4];
int gps_enable = 0;
char *err_name = NULL;
char err_msg[MAX_ERROR_MESSAGE_LEN] = {'\0',};
- _MMCamcorderLocationInfo location_info = {0,};
+ _MMCamcorderLocationInfo location_info = {0,0,0};
+ _MMCamcorderLocationInfo geo_info = {0,0,0};
_MMCamcorderVideoInfo *info = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
info = sc->info_video;
- f = fopen(info->filename, "rb+");
+ f = fopen64(info->filename, "rb+");
if (f == NULL) {
strerror_r(errno, err_msg, MAX_ERROR_MESSAGE_LEN);
_mmcam_dbg_err("file open failed [%s]", err_msg);
location_info.longitude = _mmcamcorder_double_to_fix(longitude);
location_info.latitude = _mmcamcorder_double_to_fix(latitude);
location_info.altitude = _mmcamcorder_double_to_fix(altitude);
-
+ geo_info.longitude = longitude *10000;
+ geo_info.latitude = latitude *10000;
+ geo_info.altitude = altitude *10000;
/* find udta container.
if, there are udta container, write loci box after that
else, make udta container and write loci box. */
- if (_mmcamcorder_find_tag(f, MMCAM_FOURCC('u','d','t','a'), TRUE)) {
+ if (_mmcamcorder_find_fourcc(f, MMCAM_FOURCC('u','d','t','a'), TRUE)) {
size_t nread = 0;
_mmcam_dbg_log("find udta container");
goto fail;
}
- udta_pos = ftell(f);
+ udta_pos = ftello(f);
if (udta_pos < 0) {
goto ftell_fail;
}
if (gps_enable) {
if (!_mmcamcorder_write_loci(f, location_info)) {
+ _mmcam_dbg_err("failed to write loci");
+ goto fail;
+ }
+
+ if (!_mmcamcorder_write_geodata(f, geo_info)) {
+ _mmcam_dbg_err("failed to write geodata");
goto fail;
}
}
- current_pos = ftell(f);
+ current_pos = ftello(f);
if (current_pos < 0) {
goto ftell_fail;
}
goto fail;
}
- if (!_mmcamcorder_write_udta(f, location_info)) {
+ if (!_mmcamcorder_write_udta(f, gps_enable, location_info, geo_info)) {
+ _mmcam_dbg_err("failed to write udta");
goto fail;
}
}
/* find moov container.
update moov container size. */
- if((current_pos = ftell(f))<0)
+ if((current_pos = ftello(f))<0)
goto ftell_fail;
if (_mmcamcorder_find_tag(f, MMCAM_FOURCC('m','o','o','v'), TRUE)) {
- gint64 internal_pos = ftell(f);
+ gint64 internal_pos = ftello(f);
_mmcam_dbg_log("found moov container");
if (fseek(f, -8L, SEEK_CUR) !=0) {
goto fail;
}
- moov_pos = ftell(f);
+ moov_pos = ftello(f);
if (moov_pos < 0) {
goto ftell_fail;
}
}
/* add orientation info */
- fseek(f, internal_pos, SEEK_SET);
+ if (fseeko(f, internal_pos, SEEK_SET) < 0) {
+ _mmcam_dbg_err("fseek failed : errno %d", errno);
+ goto fail;
+ }
+
if (!_mmcamcorder_find_tag(f, MMCAM_FOURCC('t','r','a','k'), FALSE)) {
_mmcam_dbg_err("failed to find [trak] tag");
goto fail;
MMCAM_TARGET_FILENAME, &temp_filename, &size,
NULL);
if (temp_filename) {
- info->filename = strdup(temp_filename);
+ info->filename = g_strdup(temp_filename);
}
if (!info->filename) {
_mmcam_dbg_log("Record file name [%s]", info->filename);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "location", info->filename);
+ MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "location", info->filename);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", 0);
/* Adjust display FPS */