From 85feae3715c542dc6b021a6ee040a9a5ccf0756f Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Wed, 12 Aug 2015 19:27:03 +0900 Subject: [PATCH] Fixed bug that can't apply duration Change-Id: I6a802e0ef9bdd5e81dcb32115935b7a75fc6b345 Signed-off-by: Gilbok Lee --- packaging/libmm-transcode.spec | 2 +- transcode/Makefile.am | 38 +++++----- transcode/include/mm_transcode_internal.h | 4 +- transcode/mm_transcode_pipeline.c | 29 +++++++- transcode/mm_transcode_seek.c | 86 +++++++++++++---------- 5 files changed, 97 insertions(+), 62 deletions(-) diff --git a/packaging/libmm-transcode.spec b/packaging/libmm-transcode.spec index 8c956f3..4339df1 100644 --- a/packaging/libmm-transcode.spec +++ b/packaging/libmm-transcode.spec @@ -1,7 +1,7 @@ Name: libmm-transcode Summary: Multimedia Framework Video Transcode Library Version: 0.9 -Release: 4 +Release: 5 Group: System/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/transcode/Makefile.am b/transcode/Makefile.am index 4a0b6c2..68de0c9 100755 --- a/transcode/Makefile.am +++ b/transcode/Makefile.am @@ -12,27 +12,27 @@ libmm_transcode_la_SOURCES = mm_transcode.c \ mm_transcode_codec.c libmm_transcode_la_CFLAGS = -I$(srcdir)/include \ - $(MMCOMMON_CFLAGS) \ - $(MMFILEINFO_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(GST_CFLAGS) \ - $(GSTAPP_CFLAGS) \ - $(GST_PLUGIN_BASE_CFLAGS) \ - $(GST_INTERFACE_CFLAGS) \ - $(GSTPBUTILS_CFLAGS) \ - $(GST_VIDEO_LIBS) \ - $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x300000 -DMMF_DEBUG_PREFIX=\"MMF-VIDEOEDIT\" + $(MMCOMMON_CFLAGS) \ + $(MMFILEINFO_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GST_CFLAGS) \ + $(GSTAPP_CFLAGS) \ + $(GST_PLUGIN_BASE_CFLAGS) \ + $(GST_INTERFACE_CFLAGS) \ + $(GSTPBUTILS_CFLAGS) \ + $(GST_VIDEO_LIBS) \ + $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x300000 -DMMF_DEBUG_PREFIX=\"MMF-VIDEOEDIT\" libmm_transcode_la_LIBADD = $(MMCOMMON_LIBS) \ - $(MMFILEINFO_LIBS) \ - $(GLIB_LIBS) \ - $(GST_LIBS) \ - $(GSTAPP_LIBS) \ - $(GST_VIDEO_LIBS) \ - $(GST_PLUGIN_BASE_LIBS) \ - $(GST_INTERFACE_LIBS) \ - $(GSTPBUTILS_LIBS) \ - $(MMLOG_LIBS) + $(MMFILEINFO_LIBS) \ + $(GLIB_LIBS) \ + $(GST_LIBS) \ + $(GSTAPP_LIBS) \ + $(GST_VIDEO_LIBS) \ + $(GST_PLUGIN_BASE_LIBS) \ + $(GST_INTERFACE_LIBS) \ + $(GSTPBUTILS_LIBS) \ + $(MMLOG_LIBS) pcfiles = mm-transcode.pc pkgconfigdir = $(libdir)/pkgconfig diff --git a/transcode/include/mm_transcode_internal.h b/transcode/include/mm_transcode_internal.h index 39efe7e..932c539 100644 --- a/transcode/include/mm_transcode_internal.h +++ b/transcode/include/mm_transcode_internal.h @@ -147,8 +147,8 @@ typedef struct _handle_encode_s GstPad *encaudiopad; GstPad *encvideopad; GstElement *ffmux; - int use_vencqueue; - int use_aencqueue; + GstElement *vencqueue; + GstElement *aencqueue; GstElement *encodepad; GstElement *encodevideo; int encodebin_profile; diff --git a/transcode/mm_transcode_pipeline.c b/transcode/mm_transcode_pipeline.c index 8806768..3a4a765 100755 --- a/transcode/mm_transcode_pipeline.c +++ b/transcode/mm_transcode_pipeline.c @@ -241,6 +241,27 @@ _mm_cleanup_pipeline(handle_s *handle) return ret; } +static void +_mm_decode_add_sink(handle_s *handle , GstElement* sink_elements) +{ + + if (!handle) { + debug_error("[ERROR] - handle"); + return; + } + + if (!handle->property) { + debug_error("[ERROR] - handle property"); + return; + } + + if(sink_elements) { + handle->property->sink_elements = g_list_append(handle->property->sink_elements, sink_elements); + debug_log("g_list_append"); + } + +} + static int _mm_decode_audio_output_create(handle_s *handle) @@ -274,6 +295,8 @@ _mm_decode_audio_output_create(handle_s *handle) return MM_ERROR_TRANSCODE_INTERNAL; } + _mm_decode_add_sink(handle, handle->decoder_audp->decsinkaudioqueue); + handle->decoder_audp->decaudiosinkpad = gst_element_get_static_pad (handle->decoder_audp->decsinkaudioqueue, "sink"); if (!handle->decoder_audp->decaudiosinkpad) { debug_error("decaudiosinkpad could not be created"); @@ -409,6 +432,8 @@ _mm_decode_video_output_create(handle_s *handle) return MM_ERROR_TRANSCODE_INTERNAL; } + _mm_decode_add_sink(handle, handle->decoder_vidp->decsinkvideoqueue); + handle->decoder_vidp->decvideosinkpad = gst_element_get_static_pad(handle->decoder_vidp->decsinkvideoqueue,"sink"); if (!handle->decoder_vidp->decvideosinkpad) { debug_error("decvideosinkpad element could not be created. Exiting"); @@ -777,8 +802,8 @@ _mm_encodebin_set_audio_property(handle_s* handle) g_object_set(G_OBJECT(gst_bin_get_by_name(GST_BIN(handle->encodebin->encbin), "audio_encode")), AACCOMPLIANCE, AACCOMPLIANCELEVEL, NULL); } - g_object_get(G_OBJECT(handle->encodebin->encbin), "use-aenc-queue", &(handle->encodebin->use_aencqueue), NULL); - debug_log("use_aencqueue : %d", handle->encodebin->use_aencqueue); + g_object_get(G_OBJECT(handle->encodebin->encbin), "use-aenc-queue", &(handle->encodebin->aencqueue), NULL); + debug_log("aencqueue : %s", GST_ELEMENT_NAME(handle->encodebin->aencqueue)); } return ret; diff --git a/transcode/mm_transcode_seek.c b/transcode/mm_transcode_seek.c index 8a8b883..7510d25 100755 --- a/transcode/mm_transcode_seek.c +++ b/transcode/mm_transcode_seek.c @@ -21,7 +21,6 @@ #include "mm_transcode.h" #include "mm_transcode_internal.h" -static void _mm_transcode_add_sink(handle_s *handle, GstElement* sink_elements); static void _mm_transcode_audio_capsfilter(GstCaps *caps, handle_s *handle); static void _mm_transcode_video_capsfilter(GstCaps *caps, handle_s *handle); static void _mm_transcode_video_capsfilter_call(handle_s *handle); @@ -48,19 +47,61 @@ _mm_cb_audio_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer us gint64 start_pos_ts = handle->param->start_pos * G_GINT64_CONSTANT(1000000); - if (GST_BUFFER_TIMESTAMP_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) { + if (GST_BUFFER_PTS_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) { if (0 == handle->property->AUDFLAG++) { - _mm_transcode_audio_capsfilter(gst_pad_get_current_caps (pad), handle); /* Need to audio caps converting when amrnbenc*/ /* Not drop buffer with 'return FALSE'*/ + GstCaps *current_caps = gst_pad_get_current_caps (pad); + /* Need to audio caps converting when amrnbenc*/ + /* Not drop buffer with 'return FALSE'*/ + _mm_transcode_audio_capsfilter(current_caps, handle); + + if (current_caps) + gst_caps_unref(current_caps); if (handle->param->seeking) { debug_log("[AUDIO BUFFER TIMESTAMP] ([%"G_GUINT64_FORMAT"])", start_pos_ts); - GST_BUFFER_TIMESTAMP (GST_PAD_PROBE_INFO_BUFFER(info)) = start_pos_ts; + GST_BUFFER_PTS (GST_PAD_PROBE_INFO_BUFFER(info)) = start_pos_ts; + } + } + } + return GST_PAD_PROBE_OK; +} + +GstPadProbeReturn +_mm_cb_video_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data) +{ + handle_s *handle = (handle_s*) user_data; + + if (!handle) { + debug_error("[ERROR] - handle"); + return GST_PAD_PROBE_REMOVE; + } + + if (!handle->property) { + debug_error("[ERROR] - handle property"); + return GST_PAD_PROBE_REMOVE; + } + + gint64 start_pos_ts = handle->param->start_pos * G_GINT64_CONSTANT(1000000); + + if (GST_BUFFER_PTS_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) { + if (0 == handle->property->VIDFLAG++) { + GstCaps *current_caps = gst_pad_get_current_caps (pad); + /* Not drop buffer with 'return FALSE'*/ + _mm_transcode_video_capsfilter(current_caps, handle); + + if (current_caps) + gst_caps_unref(current_caps); + + if(handle->param->seeking) { + debug_log("[VIDEO BUFFER TIMESTAMP] ([%"G_GUINT64_FORMAT"])", start_pos_ts); + GST_BUFFER_PTS (GST_PAD_PROBE_INFO_BUFFER(info)) = start_pos_ts; } } } return GST_PAD_PROBE_OK; } + GstAutoplugSelectResult _mm_cb_decode_bin_autoplug_select(GstElement * element, GstPad * pad, GstCaps * caps, GstElementFactory * factory, handle_s *handle) { @@ -85,12 +126,12 @@ _mm_cb_decode_bin_autoplug_select(GstElement * element, GstPad * pad, GstCaps * return GST_AUTOPLUG_SELECT_TRY; } memset(handle->property->audiodecodename, 0, ENC_BUFFER_SIZE); - strncpy(handle->property->audiodecodename, feature_name, ENC_BUFFER_SIZE-1); + strncpy(handle->property->audiodecodename, feature_name, strlen(feature_name)); debug_log ("[audio decode name %s : %s]", caps_str, handle->property->audiodecodename); } if(g_strrstr(caps_str, "video")) { - if(g_strrstr(feature_name, "omx")) { + if(g_strrstr(feature_name, "omx") || g_strrstr(feature_name, "sprd")) { /* emit autoplug-select to see what we should do with it. */ debug_log("SKIP HW Codec"); return GST_AUTOPLUG_SELECT_SKIP; @@ -101,7 +142,7 @@ _mm_cb_decode_bin_autoplug_select(GstElement * element, GstPad * pad, GstCaps * return GST_AUTOPLUG_SELECT_TRY; } memset(handle->property->videodecodename, 0, ENC_BUFFER_SIZE); - strncpy(handle->property->videodecodename, feature_name, ENC_BUFFER_SIZE-1); + strncpy(handle->property->videodecodename, feature_name, strlen(feature_name)); debug_log ("[video decode name %s : %s]", caps_str, handle->property->videodecodename); } @@ -232,36 +273,6 @@ _mm_cb_print_position(handle_s *handle) return TRUE; } -GstPadProbeReturn -_mm_cb_video_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data) -{ - handle_s *handle = (handle_s*) user_data; - - if (!handle) { - debug_error("[ERROR] - handle"); - return GST_PAD_PROBE_REMOVE; - } - - if (!handle->property) { - debug_error("[ERROR] - handle property"); - return GST_PAD_PROBE_REMOVE; - } - - gint64 start_pos_ts = handle->param->start_pos * G_GINT64_CONSTANT(1000000); - - if (GST_BUFFER_TIMESTAMP_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) { - if (0 == handle->property->VIDFLAG++) { - _mm_transcode_video_capsfilter(gst_pad_get_current_caps (pad), handle); /* Not drop buffer with 'return FALSE'*/ - - if(handle->param->seeking) { - debug_log("[VIDEO BUFFER TIMESTAMP] ([%"G_GUINT64_FORMAT"])", start_pos_ts); - GST_BUFFER_TIMESTAMP (GST_PAD_PROBE_INFO_BUFFER(info)) = start_pos_ts; - } - } - } - return GST_PAD_PROBE_OK; -} - gboolean _mm_cb_transcode_bus(GstBus * bus, GstMessage * message, gpointer userdata) { @@ -968,7 +979,6 @@ _mm_transcode_set_handle_parameter(handle_param_s *param, unsigned int resolutio memset(param->outputfile, 0, BUFFER_SIZE); strncpy(param->outputfile, out_Filename, strlen (out_Filename)); debug_log("%s(%d)", param->outputfile, strlen (out_Filename)); - debug_log("output file name: %s", param->outputfile); } else { debug_error("out_Filename error"); return MM_ERROR_INVALID_ARGUMENT; -- 2.34.1