X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmm_streamrecorder_gstdispatch.c;h=e2f898fe694174423c4922212a750c1f8818c250;hb=refs%2Fheads%2Faccepted%2Ftizen_6.0_unified;hp=45b42f125cbb2ece559a02c305c7b3ea53dc63ee;hpb=ec26bef8c238b9a97feb8ecd831d8f16a9ee6882;p=platform%2Fcore%2Fmultimedia%2Flibmm-streamrecorder.git diff --git a/src/mm_streamrecorder_gstdispatch.c b/src/mm_streamrecorder_gstdispatch.c index 45b42f1..e2f898f 100644 --- a/src/mm_streamrecorder_gstdispatch.c +++ b/src/mm_streamrecorder_gstdispatch.c @@ -297,7 +297,16 @@ gboolean _mmstreamrecorder_msg_callback(void *data) 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); @@ -307,13 +316,19 @@ gboolean _mmstreamrecorder_msg_callback(void *data) _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; } @@ -420,11 +435,6 @@ gboolean _mmstreamrecorder_remove_message_all(MMHandleType handle) 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); @@ -742,17 +752,9 @@ gboolean _mmstreamrecorder_pipeline_cb_message(GstBus *bus, GstMessage *message, 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; @@ -810,6 +812,11 @@ gboolean _mmstreamrecorder_pipeline_cb_message(GstBus *bus, GstMessage *message, 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"); + } + } } } } @@ -1008,11 +1015,10 @@ GstPadProbeReturn __mmstreamrecorder_video_dataprobe_record(GstPad *pad, GstPadP } /* 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; @@ -1029,11 +1035,11 @@ GstPadProbeReturn __mmstreamrecorder_video_dataprobe_record(GstPad *pad, GstPadP 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++; @@ -1044,12 +1050,11 @@ GstPadProbeReturn __mmstreamrecorder_video_dataprobe_record(GstPad *pad, GstPadP 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; @@ -1111,11 +1116,10 @@ GstPadProbeReturn __mmstreamrecorder_video_dataprobe_audio_disable(GstPad *pad, 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) { @@ -1186,11 +1190,10 @@ GstPadProbeReturn __mmstreamrecorder_audioque_dataprobe(GstPad *pad, GstPadProbe 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; @@ -1236,11 +1239,10 @@ void __mmstreamrecorder_audiorec_pad_added_cb(GstElement *element, GstPad *pad, _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; } @@ -1278,11 +1280,10 @@ GstPadProbeReturn __mmstreamrecorder_audio_dataprobe_record(GstPad *pad, GstPadP 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; @@ -1317,11 +1318,11 @@ GstPadProbeReturn __mmstreamrecorder_audio_dataprobe_record(GstPad *pad, GstPadP 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++; @@ -1335,11 +1336,10 @@ GstPadProbeReturn __mmstreamrecorder_audio_dataprobe_record(GstPad *pad, GstPadP _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; @@ -1367,11 +1367,10 @@ GstPadProbeReturn __mmstreamrecorder_audio_dataprobe_record(GstPad *pad, GstPadP 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;