mmf_return_val_if_fail(item, FALSE);
hstreamrecorder = MMF_STREAMRECORDER(item->handle);
- mmf_return_val_if_fail(hstreamrecorder, FALSE);
+ if (hstreamrecorder == NULL) {
+ _mmstreamrec_dbg_warn("msg id:0x%x, item:%p, handle is NULL", item->id, item);
+ goto MSG_CALLBACK_DONE;
+ }
+
+ _MMSTREAMRECORDER_LOCK((MMHandleType) hstreamrecorder);
+ if (hstreamrecorder->msg_data)
+ hstreamrecorder->msg_data = g_list_remove(hstreamrecorder->msg_data, item);
+
+ _MMSTREAMRECORDER_UNLOCK((MMHandleType) hstreamrecorder);
/* _mmstreamrec_dbg_log("msg id:%x, msg_cb:%p, msg_data:%p, item:%p", item->id, hstreamrecorder->msg_cb, hstreamrecorder->msg_data, item); */
_MMSTREAMRECORDER_LOCK_MESSAGE_CALLBACK(hstreamrecorder);
_MMSTREAMRECORDER_UNLOCK_MESSAGE_CALLBACK(hstreamrecorder);
- _MMSTREAMRECORDER_LOCK((MMHandleType) hstreamrecorder);
- if (hstreamrecorder->msg_data)
- hstreamrecorder->msg_data = g_list_remove(hstreamrecorder->msg_data, item);
+MSG_CALLBACK_DONE:
+ /* release allocated memory */
+ if (item->id == MM_MESSAGE_STREAMRECORDER_VIDEO_CAPTURED ||
+ item->id == MM_MESSAGE_STREAMRECORDER_AUDIO_CAPTURED) {
+ MMStreamRecordingReport *report = (MMStreamRecordingReport *)item->param.data;
+ if (report) {
+ SAFE_FREE(report->recording_filename);
+ SAFE_FREE(report);
+ item->param.data = NULL;
+ }
+ }
+ SAFE_FREE(item);
- free(item);
- item = NULL;
- _MMSTREAMRECORDER_UNLOCK((MMHandleType) hstreamrecorder);
/* For not being called again */
return FALSE;
}
hstreamrecorder->msg_data = NULL;
}
- /* remove idle function for playing capture sound */
- do {
- ret = g_idle_remove_by_data(hstreamrecorder);
- _mmstreamrec_dbg_log("remove idle function for playing capture sound. ret[%d]", ret);
- } while (ret);
_MMSTREAMRECORDER_UNLOCK(handle);
sc = MMF_STREAMRECORDER_SUBCONTEXT(hstreamrecorder);
mmf_return_val_if_fail(sc, TRUE);
- /*if (hstreamrecorder->type != MM_STREAMRECORDER_MODE_AUDIO) { */
mmf_return_val_if_fail(sc->info_video, TRUE);
- if (sc->info_video->b_commiting) {
+ if (sc->info_video->b_commiting)
_mmstreamrecorder_video_handle_eos((MMHandleType) hstreamrecorder);
- }
- /*} else {
- mmf_return_val_if_fail(sc->info_audio, TRUE);
- if (sc->info_audio->b_commiting) {
- _mmstreamrecorder_audio_handle_eos((MMHandleType)hstreamrecorder);
- }
- } */
sc->bget_eos = TRUE;
vnewstate = (GValue *) gst_structure_get_value(gst_message_get_structure(message), "new-state");
newstate = (GstState) vnewstate->data[0].v_int;
_mmstreamrec_dbg_log("GST_MESSAGE_STATE_CHANGED[%s]", gst_element_state_get_name(newstate));
+ if (newstate == GST_STATE_PLAYING) {
+ if (hstreamrecorder->ini.generate_dot) {
+ GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(sc->encode_element[_MMSTREAMRECORDER_ENCODE_MAIN_PIPE].gst), GST_DEBUG_GRAPH_SHOW_ALL, "streamrecorder_pipeline");
+ }
+ }
}
}
}
}
/* get trailer size */
- if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) {
+ if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4)
MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst, "expected-trailer-size", &trailer_size);
- } else {
+ else
trailer_size = 0;
- }
/* to minimizing free space check overhead */
count = count % _MMSTREAMRECORDER_FREE_SPACE_CHECK_INTERVAL;
if (sc->ferror_count == 2 && sc->ferror_send == FALSE) {
sc->ferror_send = TRUE;
msg.id = MM_MESSAGE_STREAMRECORDER_ERROR;
- if (ret == -2) {
+ if (ret == -2)
msg.param.code = MM_ERROR_FILE_NOT_FOUND;
- } else {
+ else
msg.param.code = MM_ERROR_FILE_READ;
- }
+
_mmstreamrecorder_send_message((MMHandleType) hstreamrecorder, &msg);
} else {
sc->ferror_count++;
default: /* succeeded to get free space */
/* check free space for recording */
/* get queued buffer size */
- if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC_QUE].gst) {
+ if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC_QUE].gst)
MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AENC_QUE].gst, "current-level-bytes", &aq_size);
- }
- if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC_QUE].gst) {
+
+ if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC_QUE].gst)
MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC_QUE].gst, "current-level-bytes", &vq_size);
- }
queued_buffer = aq_size + vq_size;
rec_pipe_time = GST_TIME_AS_MSECONDS(b_time);
- if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) {
+ if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4)
MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst, "expected-trailer-size", &trailer_size);
- } else {
+ else
trailer_size = 0;
- }
/* check max time */
if (videoinfo->max_time > 0 && rec_pipe_time > videoinfo->max_time) {
rec_pipe_time = GST_TIME_AS_MSECONDS(GST_BUFFER_TIMESTAMP(buffer));
- if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4) {
+ if (finfo->fileformat == MM_FILE_FORMAT_3GP || finfo->fileformat == MM_FILE_FORMAT_MP4)
MMSTREAMRECORDER_G_OBJECT_GET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_MUX].gst, "expected-trailer-size", &trailer_size);
- } else {
+ else
trailer_size = 0;
- }
if (videoinfo->max_time > 0 && videoinfo->max_time < (remained_time + rec_pipe_time))
remained_time = videoinfo->max_time - rec_pipe_time;
_mmstreamrec_dbg_log("ENTER(%s)", GST_PAD_NAME(pad));
/* FIXME : the name of audio sink pad of wavparse, oggmux doesn't have 'audio'. How could I handle the name? */
- if ((strstr(GST_PAD_NAME(pad), "audio")) || (strstr(GST_PAD_NAME(pad), "sink"))) {
+ if ((strstr(GST_PAD_NAME(pad), "audio")) || (strstr(GST_PAD_NAME(pad), "sink")))
MMSTREAMRECORDER_ADD_BUFFER_PROBE(pad, _MMSTREAMRECORDER_HANDLER_AUDIOREC, __mmstreamrecorder_audio_dataprobe_record, hstreamrecorder);
- } else {
+ else
_mmstreamrec_dbg_warn("Unknow pad is added, check it : [%s]", GST_PAD_NAME(pad));
- }
return;
}
buffer_size = gst_buffer_get_size(buffer);
if (audioinfo->filesize == 0) {
- if (finfo->fileformat == MM_FILE_FORMAT_WAV) {
+ if (finfo->fileformat == MM_FILE_FORMAT_WAV)
audioinfo->filesize += 44; /* wave header size */
- } else if (finfo->fileformat == MM_FILE_FORMAT_AMR) {
+ else if (finfo->fileformat == MM_FILE_FORMAT_AMR)
audioinfo->filesize += 6; /* amr header size */
- }
audioinfo->filesize += buffer_size;
return GST_PAD_PROBE_OK;
if (sc->ferror_count == 2 && sc->ferror_send == FALSE) {
sc->ferror_send = TRUE;
msg.id = MM_MESSAGE_STREAMRECORDER_ERROR;
- if (free_space_ret == -2) {
+ if (free_space_ret == -2)
msg.param.code = MM_ERROR_FILE_NOT_FOUND;
- } else {
+ else
msg.param.code = MM_ERROR_FILE_READ;
- }
+
_mmstreamrecorder_send_message((MMHandleType) hstreamrecorder, &msg);
} else {
sc->ferror_count++;
_mmstreamrec_dbg_warn("No more space for recording!!!");
_mmstreamrec_dbg_warn("Free Space : [%" G_GUINT64_FORMAT "], file size : [%" G_GUINT64_FORMAT "]", free_space, audioinfo->filesize);
- if (audioinfo->bMuxing) {
+ if (audioinfo->bMuxing)
MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "block", TRUE);
- } else {
+ else
MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, "empty-buffers", TRUE);
- }
sc->isMaxsizePausing = TRUE;
msg.id = MM_MESSAGE_STREAMRECORDER_NO_FREE_SPACE;
if (audioinfo->max_time > 0 && rec_pipe_time > audioinfo->max_time) {
_mmstreamrec_dbg_warn("Current time : [%" G_GUINT64_FORMAT "], Maximum time : [%" G_GUINT64_FORMAT "]", rec_pipe_time, audioinfo->max_time);
- if (audioinfo->bMuxing) {
+ if (audioinfo->bMuxing)
MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_ENCBIN].gst, "block", TRUE);
- } else {
+ else
MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_AQUE].gst, "empty-buffers", TRUE);
- }
sc->isMaxtimePausing = TRUE;
msg.id = MM_MESSAGE_STREAMRECORDER_TIME_LIMIT;