From 8d996af140b86a3df126d4bf799fabe5a7c97061 Mon Sep 17 00:00:00 2001 From: Eunhye Choi Date: Mon, 13 Apr 2020 13:17:20 +0900 Subject: [PATCH] decodebin3: add request resource signal - decodebin3 does not export the candidate decoder information to application. so request-resource signal is added to acquire resource before creating hw decoder. Change-Id: Iecbd4667bdc9c47106843e2f181e8cf310278231 --- gst/playback/gstdecodebin3.c | 64 +++++++++++++++++++++++++++++++++++++++-- packaging/gst-plugins-base.spec | 2 ++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/gst/playback/gstdecodebin3.c b/gst/playback/gstdecodebin3.c index c004407..e3791aa 100644 --- a/gst/playback/gstdecodebin3.c +++ b/gst/playback/gstdecodebin3.c @@ -277,8 +277,13 @@ struct _GstDecodebin3Class { GstBinClass class; - gint (*select_stream) (GstDecodebin3 * dbin, - GstStreamCollection * collection, GstStream * stream); + gint (*select_stream) (GstDecodebin3 * dbin, + GstStreamCollection * collection, GstStream * stream); + +#ifdef TIZEN_FEATURE_RESOURCE_MANAGER + gboolean (*request_resource) (GstDecodebin3 * dbin, + GstStreamCollection * collection, GstStream * stream); +#endif }; /* Input of decodebin, controls input pad and parsebin */ @@ -391,6 +396,9 @@ enum { SIGNAL_SELECT_STREAM, SIGNAL_ABOUT_TO_FINISH, +#ifdef TIZEN_FEATURE_RESOURCE_MANAGER + SIGNAL_REQUEST_RESOURCE, +#endif LAST_SIGNAL }; static guint gst_decodebin3_signals[LAST_SIGNAL] = { 0 }; @@ -477,6 +485,10 @@ static void gst_decodebin3_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_decodebin3_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +#ifdef TIZEN_FEATURE_RESOURCE_MANAGER +static gboolean gst_decodebin3_request_resource (GstElement * element, + GstStreamCollection * collection, GstStream * stream); +#endif static gboolean parsebin_autoplug_continue_cb (GstElement * parsebin, GstPad * pad, GstCaps * caps, GstDecodebin3 * dbin); @@ -533,6 +545,28 @@ static void update_requested_selection (GstDecodebin3 * dbin); /* FIXME: Really make all the parser stuff a self-contained helper object */ #include "gstdecodebin3-parse.c" +#ifdef TIZEN_FEATURE_RESOURCE_MANAGER +static gboolean gst_decodebin3_request_resource (GstElement * element, + GstStreamCollection * collection, GstStream * stream) +{ + /* do not consider the resource limit */ + return TRUE; +} + +static gboolean +_gst_boolean_accumulator (GSignalInvocationHint * ihint, + GValue * return_accu, const GValue * handler_return, gpointer dummy) +{ + gboolean myboolean; + + myboolean = g_value_get_boolean (handler_return); + if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP)) + g_value_set_boolean (return_accu, myboolean); + + return myboolean; +} +#endif + static gboolean _gst_int_accumulator (GSignalInvocationHint * ihint, GValue * return_accu, const GValue * handler_return, gpointer dummy) @@ -620,6 +654,13 @@ gst_decodebin3_class_init (GstDecodebin3Class * klass) G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 0, G_TYPE_NONE); +#ifdef TIZEN_FEATURE_RESOURCE_MANAGER + gst_decodebin3_signals[SIGNAL_REQUEST_RESOURCE] = + g_signal_new ("request-resource", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDecodebin3Class, request_resource), + _gst_boolean_accumulator, NULL, g_cclosure_marshal_generic, + G_TYPE_BOOLEAN, 2, GST_TYPE_STREAM_COLLECTION, GST_TYPE_STREAM); +#endif element_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_decodebin3_request_new_pad); @@ -647,6 +688,10 @@ gst_decodebin3_class_init (GstDecodebin3Class * klass) bin_klass->handle_message = gst_decodebin3_handle_message; klass->select_stream = gst_decodebin3_select_stream; + +#ifdef TIZEN_FEATURE_RESOURCE_MANAGER + klass->request_resource = gst_decodebin3_request_resource; +#endif } static void @@ -2176,6 +2221,21 @@ create_element (GstDecodebin3 * dbin, GstStream * stream, g_mutex_unlock (&dbin->factories_lock); if (res) { +#ifdef TIZEN_FEATURE_RESOURCE_MANAGER + if (gst_element_factory_list_is_type (res->data, + GST_ELEMENT_FACTORY_TYPE_HARDWARE)) { + gboolean result = FALSE; + g_signal_emit (G_OBJECT (dbin), + gst_decodebin3_signals[SIGNAL_REQUEST_RESOURCE], 0, dbin->collection, stream, + &result); + if (!result) { + GST_WARNING_OBJECT (dbin, "Failed to get HW resource."); + gst_plugin_feature_list_free (res); + gst_caps_unref (caps); + return NULL; + } + } +#endif element = gst_element_factory_create ((GstElementFactory *) res->data, NULL); GST_DEBUG ("Created element '%s'", GST_ELEMENT_NAME (element)); diff --git a/packaging/gst-plugins-base.spec b/packaging/gst-plugins-base.spec index 7f8e31f..ea75ab4 100644 --- a/packaging/gst-plugins-base.spec +++ b/packaging/gst-plugins-base.spec @@ -94,6 +94,8 @@ export CFLAGS="%{optflags} -fno-strict-aliasing\ %if "%{tizen_profile_name}" == "tv" -DTIZEN_PROFILE_TV\ -DTIZEN_FEATURE_TRUSTZONE\ +%else + -DTIZEN_FEATURE_RESOURCE_MANAGER\ %endif -fstack-protector-strong\ -Wl,-z,relro\ -- 2.7.4