diff options
author | Ji Yong Min <jiyong.min@samsung.com> | 2015-07-30 14:14:24 +0900 |
---|---|---|
committer | Ji Yong Min <jiyong.min@samsung.com> | 2015-07-30 14:16:47 +0900 |
commit | dca71e9fcf424024a5156177f241f18f60385462 (patch) | |
tree | d5537baf16ab39c5c3e8a325c684f6a74dfa8954 | |
parent | 034c8fcd1d9e5c26a0c1633da90d1395a1635857 (diff) | |
download | libmm-imgp-gstcs-dca71e9fcf424024a5156177f241f18f60385462.tar.gz libmm-imgp-gstcs-dca71e9fcf424024a5156177f241f18f60385462.tar.bz2 libmm-imgp-gstcs-dca71e9fcf424024a5156177f241f18f60385462.zip |
Fix to get wrong result before gstream change state is donetizen_3.0.m1_tv_releasetizen_3.0.m1_mobile_releasesubmit/tizen_common/20151026.085049submit/tizen_common/20151023.083358submit/tizen/20150803.020941accepted/tizen/wearable/20150803.042513accepted/tizen/tv/20150803.042504accepted/tizen/mobile/20150803.042454tizen_3.0.m1_tvtizen_3.0.m1_mobile
Change-Id: Ic70286b48c8b77fdb33f2c55a973e77e2212a9a7
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
-rwxr-xr-x[-rw-r--r--] | gstcs/include/mm_util_gstcs_internal.h | 1 | ||||
-rwxr-xr-x | gstcs/mm_util_gstcs.c | 106 | ||||
-rwxr-xr-x[-rw-r--r--] | packaging/libmm-imgp-gstcs.spec | 5 |
3 files changed, 41 insertions, 71 deletions
diff --git a/gstcs/include/mm_util_gstcs_internal.h b/gstcs/include/mm_util_gstcs_internal.h index 8e8f1e1..d113904 100644..100755 --- a/gstcs/include/mm_util_gstcs_internal.h +++ b/gstcs/include/mm_util_gstcs_internal.h @@ -56,6 +56,7 @@ typedef struct _gstreamer_s GstElement *videoflip; GstElement *appsink; GstBuffer *output_buffer; + gboolean outbuf_available; } gstreamer_s; #ifdef __cplusplus diff --git a/gstcs/mm_util_gstcs.c b/gstcs/mm_util_gstcs.c index 1724e25..57b1c58 100755 --- a/gstcs/mm_util_gstcs.c +++ b/gstcs/mm_util_gstcs.c @@ -28,6 +28,8 @@ #define MM_UTIL_ROUND_UP_8(num) (((num)+7)&~7) #define MM_UTIL_ROUND_UP_16(num) (((num)+15)&~15) +#define MAX_GET_STATE_COUNT 2000 + #define setup_image_size_I420(width, height) { \ int size=0; \ size = (MM_UTIL_ROUND_UP_4 (width) * MM_UTIL_ROUND_UP_2 (height) + MM_UTIL_ROUND_UP_8 (width) * MM_UTIL_ROUND_UP_2 (height) /2); \ @@ -107,57 +109,13 @@ _mm_sink_sample (GstElement * appsink, gpointer user_data) } else { debug_error("ERROR -Input Prepare Buffer! Check createoutput buffer function"); } - gst_buffer_ref (pGstreamer_s->output_buffer); /* when you want to avoid flushing */ - gst_sample_unref(_sample); -} -static void -_mm_sink_preroll (GstElement * appsink, gpointer user_data) -{ - GstSample *_sample = NULL; - GstBuffer *_buf=NULL; - gstreamer_s * pGstreamer_s = (gstreamer_s*) user_data; - _buf = gst_app_sink_pull_preroll((GstAppSink*)appsink); + pGstreamer_s->outbuf_available = TRUE; - pGstreamer_s->output_buffer = _buf; - /* pGstreamer_s->output_image_format_s->caps = GST_BUFFER_CAPS(_buf); */ - if(pGstreamer_s->output_buffer != NULL) { - GstMapInfo mapinfo = GST_MAP_INFO_INIT; - gst_buffer_map(pGstreamer_s->output_buffer, &mapinfo, GST_MAP_READ); - debug_log("Create Output Buffer: GST_BUFFER_DATA: %p\t GST_BUFFER_SIZE: %d", mapinfo.data, mapinfo.size); - gst_buffer_unmap(pGstreamer_s->output_buffer, &mapinfo); - } else { - debug_error("ERROR -Input Prepare Buffer! Check createoutput buffer function"); - } - - gst_buffer_ref (pGstreamer_s->output_buffer); /* when you want to avoid flushings */ + gst_buffer_ref (pGstreamer_s->output_buffer); /* when you want to avoid flushing */ gst_sample_unref(_sample); } -static gboolean -_mm_on_sink_message (GstBus * bus, GstMessage * message, gstreamer_s * pGstreamer_s) -{ - switch (GST_MESSAGE_TYPE (message)) { - case GST_MESSAGE_EOS: - debug_log("Finished playback\n"); /* g_main_loop_quit (pGstreamer_s->loop); */ - break; - case GST_MESSAGE_ERROR: - debug_error("Received error\n"); /* g_main_loop_quit (pGstreamer_s->loop); */ - break; - case GST_MESSAGE_STATE_CHANGED: - debug_log("[%s] %s(%d) \n", GST_MESSAGE_SRC_NAME(message), GST_MESSAGE_TYPE_NAME(message), GST_MESSAGE_TYPE(message)); - break; - case GST_MESSAGE_STREAM_STATUS: - debug_log("[%s] %s(%d) \n", GST_MESSAGE_SRC_NAME(message), GST_MESSAGE_TYPE_NAME(message), GST_MESSAGE_TYPE(message)); - break; - default: - debug_log("[%s] %s(%d) \n", GST_MESSAGE_SRC_NAME(message), GST_MESSAGE_TYPE_NAME(message), GST_MESSAGE_TYPE(message)); - break; - } - return TRUE; -} - - static int _mm_create_pipeline( gstreamer_s* pGstreamer_s) { @@ -182,7 +140,7 @@ _mm_create_pipeline( gstreamer_s* pGstreamer_s) debug_error("videoscale could not be created. Exiting.\n"); ret = MM_ERROR_IMAGE_INVALID_VALUE; } - pGstreamer_s->videoflip=gst_element_factory_make( "videoflip", "flip" ); + pGstreamer_s->videoflip=gst_element_factory_make("videoflip", "flip"); if (!pGstreamer_s->videoflip) { debug_error("videoflip could not be created. Exiting.\n"); ret = MM_ERROR_IMAGE_INVALID_VALUE; @@ -192,6 +150,7 @@ _mm_create_pipeline( gstreamer_s* pGstreamer_s) debug_error("appsink could not be created. Exiting.\n"); ret = MM_ERROR_IMAGE_INVALID_VALUE; } + pGstreamer_s->outbuf_available = FALSE; return ret; } @@ -306,9 +265,9 @@ _mm_set_image_format_s_capabilities(image_format_s* __format) /*_format_label: I || strcmp(__format->format_label,"YV12") == 0 || strcmp(__format->format_label,"NV12") == 0 || strcmp(__format->format_label,"UYVY") == 0) { - strcpy(_format_name, __format->format_label); + strncpy(_format_name, __format->format_label, sizeof(GST_VIDEO_FORMATS_ALL)-1); }else if(strcmp(__format->format_label,"YUYV") == 0) { - strcpy(_format_name, "YVYU"); + strncpy(_format_name, "YVYU", sizeof(GST_VIDEO_FORMATS_ALL)-1); } __format->caps = gst_caps_new_simple ("video/x-raw", @@ -509,6 +468,7 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign GstBus *bus = NULL; GstStateChangeReturn ret_state; int ret = MM_ERROR_NONE; + int i = 0; if(src== NULL || dst == NULL) { debug_error("src || dst is NULL"); @@ -521,11 +481,11 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign debug_error("ERROR - mm_create_pipeline "); } + /* Make appsink emit the "new-preroll" and "new-sample" signals. This option is by default disabled because signal emission is expensive and unneeded when the application prefers to operate in pull mode. */ gst_app_sink_set_emit_signals ((GstAppSink*)pGstreamer_s->appsink, TRUE); bus = gst_pipeline_get_bus (GST_PIPELINE (pGstreamer_s->pipeline)); /* GST_PIPELINE (pipeline)); */ - /* gst_bus_add_watch (bus, (GstBusFunc) _mm_on_sink_message, pGstreamer_s); thow to appplicaton */ gst_object_unref(bus); debug_log("Start mm_push_buffer_into_pipeline"); @@ -549,30 +509,34 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign debug_log("Start GST_STATE_PLAYING"); ret_state = gst_element_set_state (pGstreamer_s->pipeline, GST_STATE_PLAYING); debug_log("End GST_STATE_PLAYING ret_state: %d", ret_state); - ret_state = gst_element_get_state (pGstreamer_s->pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); - debug_log("Success Get GST_STATE_PLAYING ret_state: %d", ret_state); - #if 0 - /* Conecting to the new-sample signal emited by the appsink*/ - debug_log("Start G_CALLBACK (mm_sink_buffer)"); - g_signal_connect (pGstreamer_s->appsink, "new-sample", G_CALLBACK (_mm_sink_buffer), pGstreamer_s); - debug_log("End G_CALLBACK (mm_sink_buffer)"); - #endif - if(ret_state == 1) { - debug_log("GST_STATE_PLAYING ret = %d( GST_STATE_CHANGE_SUCCESS)", ret_state); - }else if( ret_state == 2) { - debug_log("GST_STATE_PLAYING ret = %d( GST_STATE_CHANGE_ASYNC)", ret_state); + + do { + ret_state = gst_element_get_state (pGstreamer_s->pipeline, NULL, NULL, 10*GST_MSECOND); + debug_error("gst_element_get_state ret_state: %d [%d, %d]", ret_state, ++i, pGstreamer_s->outbuf_available); + if ((ret_state == GST_STATE_CHANGE_SUCCESS) && (pGstreamer_s->outbuf_available)) { + debug_log("available output buffer & success state chnage"); + break; + } + } while (i < MAX_GET_STATE_COUNT); + + if (i == MAX_GET_STATE_COUNT) { + debug_error("Fail GST_STATE_CHANGE"); + gst_object_unref (pGstreamer_s->pipeline); + g_free (pGstreamer_s); + + return MM_ERROR_IMAGE_INVALID_VALUE; } debug_log("Sucess GST_STATE_CHANGE"); /* error */ - if (ret_state == 0) { + if (ret_state == GST_STATE_CHANGE_FAILURE) { debug_error("GST_STATE_CHANGE_FAILURE"); + gst_object_unref (pGstreamer_s->pipeline); + g_free (pGstreamer_s); + return MM_ERROR_IMAGE_INVALID_VALUE; }else { - #if 0 - g_main_loop_run (pGstreamer_s->loop); - #endif debug_log("Set GST_STATE_NULL"); /*GST_STATE_NULL*/ @@ -583,15 +547,15 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign ret_state = gst_element_get_state (pGstreamer_s->pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); - if(ret_state == 1) { + if(ret_state == GST_STATE_CHANGE_SUCCESS) { debug_log("GST_STATE_NULL ret_state = %d (GST_STATE_CHANGE_SUCCESS)\n", ret_state); - }else if( ret_state == 2) { + }else if( ret_state == GST_STATE_CHANGE_ASYNC) { debug_log("GST_STATE_NULL ret_state = %d (GST_STATE_CHANGE_ASYNC)\n", ret_state); } debug_log("Success gst_element_get_state\n"); - if (ret_state == 0) { + if (ret_state == GST_STATE_CHANGE_FAILURE) { debug_error("GST_STATE_CHANGE_FAILURE"); }else { if(pGstreamer_s->output_buffer != NULL) { @@ -609,11 +573,13 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign debug_log("pGstreamer_s->output_buffer is NULL"); } } + gst_buffer_unref (pGstreamer_s->output_buffer); + debug_log("unref output buffer"); gst_object_unref (pGstreamer_s->pipeline); pGstreamer_s->output_buffer = NULL; g_free (pGstreamer_s); - debug_log("End gstreamer processing \n"); + debug_log("End gstreamer processing"); } debug_log("dst: %p", dst); return ret; diff --git a/packaging/libmm-imgp-gstcs.spec b/packaging/libmm-imgp-gstcs.spec index fcfe062..9baf256 100644..100755 --- a/packaging/libmm-imgp-gstcs.spec +++ b/packaging/libmm-imgp-gstcs.spec @@ -1,7 +1,7 @@ #sbs-git:slp/pkgs/l/libmm-imgp-gstcs libmm-imgp-gstcs 0.1 62b62e6d483557fc5750d1b4986e9a98323f1194 Name: libmm-imgp-gstcs Summary: Multimedia Framework Utility Library -Version: 0.4 +Version: 0.5 Release: 16 Group: System/Libraries License: Apache-2.0 @@ -36,6 +36,9 @@ cp %{SOURCE1001} . %build ./autogen.sh +export CFLAGS+=" -Wextra -Wno-array-bounds" +export CFLAGS+=" -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow" +export CFLAGS+=" -Wwrite-strings -Wswitch-default" CFLAGS="$CFLAGS -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" -D_MM_PROJECT_FLOATER" \ LDFLAGS+="-Wl,--rpath=%{_libdir} -Wl,--hash-style=both -Wl,--as-needed" \ %configure |