urisourcebin: Remove auto-plugging signals

They were never used and we need a better system
This commit is contained in:
Edward Hervey 2017-11-09 10:52:38 +01:00 committed by Edward Hervey
parent e5157ca400
commit 1717e33da5

View file

@ -167,23 +167,6 @@ struct _GstURISourceBinClass
{
GstBinClass parent_class;
/* signal fired to know if we continue trying to decode the given caps */
gboolean (*autoplug_continue) (GstElement * element, GstPad * pad,
GstCaps * caps);
/* signal fired to get a list of factories to try to autoplug */
GValueArray *(*autoplug_factories) (GstElement * element, GstPad * pad,
GstCaps * caps);
/* signal fired to sort the factories */
GValueArray *(*autoplug_sort) (GstElement * element, GstPad * pad,
GstCaps * caps, GValueArray * factories);
/* signal fired to select from the proposed list of factories */
GstAutoplugSelectResult (*autoplug_select) (GstElement * element,
GstPad * pad, GstCaps * caps, GstElementFactory * factory);
/* signal fired when a autoplugged element that is not linked downstream
* or exposed wants to query something */
gboolean (*autoplug_query) (GstElement * element, GstPad * pad,
GstQuery * query);
/* emitted when all data is decoded */
void (*drained) (GstElement * element);
};
@ -201,11 +184,6 @@ GST_DEBUG_CATEGORY_STATIC (gst_uri_source_bin_debug);
/* signals */
enum
{
SIGNAL_AUTOPLUG_CONTINUE,
SIGNAL_AUTOPLUG_FACTORIES,
SIGNAL_AUTOPLUG_SELECT,
SIGNAL_AUTOPLUG_SORT,
SIGNAL_AUTOPLUG_QUERY,
SIGNAL_DRAINED,
SIGNAL_SOURCE_SETUP,
LAST_SIGNAL
@ -267,172 +245,6 @@ static void free_output_slot_async (GstURISourceBin * urisrc,
static GstPad *create_output_pad (GstURISourceBin * urisrc, GstPad * pad);
static void remove_buffering_msgs (GstURISourceBin * bin, GstObject * src);
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);
/* stop emission if FALSE */
return myboolean;
}
static gboolean
_gst_boolean_or_accumulator (GSignalInvocationHint * ihint,
GValue * return_accu, const GValue * handler_return, gpointer dummy)
{
gboolean myboolean;
gboolean retboolean;
myboolean = g_value_get_boolean (handler_return);
retboolean = g_value_get_boolean (return_accu);
if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
g_value_set_boolean (return_accu, myboolean || retboolean);
return TRUE;
}
static gboolean
_gst_array_accumulator (GSignalInvocationHint * ihint,
GValue * return_accu, const GValue * handler_return, gpointer dummy)
{
gpointer array;
array = g_value_get_boxed (handler_return);
if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
g_value_set_boxed (return_accu, array);
return FALSE;
}
static gboolean
_gst_select_accumulator (GSignalInvocationHint * ihint,
GValue * return_accu, const GValue * handler_return, gpointer dummy)
{
GstAutoplugSelectResult res;
res = g_value_get_enum (handler_return);
if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
g_value_set_enum (return_accu, res);
/* Call the next handler in the chain (if any) when the current callback
* returns TRY. This makes it possible to register separate autoplug-select
* handlers that implement different TRY/EXPOSE/SKIP strategies.
*/
if (res == GST_AUTOPLUG_SELECT_TRY)
return TRUE;
return FALSE;
}
static gboolean
_gst_array_hasvalue_accumulator (GSignalInvocationHint * ihint,
GValue * return_accu, const GValue * handler_return, gpointer dummy)
{
gpointer array;
array = g_value_get_boxed (handler_return);
if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
g_value_set_boxed (return_accu, array);
if (array != NULL)
return FALSE;
return TRUE;
}
static gboolean
gst_uri_source_bin_autoplug_continue (GstElement * element, GstPad * pad,
GstCaps * caps)
{
/* by default we always continue */
return TRUE;
}
/* Must be called with factories lock! */
static void
gst_uri_source_bin_update_factories_list (GstURISourceBin * dec)
{
guint32 cookie;
cookie = gst_registry_get_feature_list_cookie (gst_registry_get ());
if (!dec->factories || dec->factories_cookie != cookie) {
if (dec->factories)
gst_plugin_feature_list_free (dec->factories);
dec->factories =
gst_element_factory_list_get_elements
(GST_ELEMENT_FACTORY_TYPE_DECODABLE, GST_RANK_MARGINAL);
dec->factories =
g_list_sort (dec->factories, gst_playback_utils_compare_factories_func);
dec->factories_cookie = cookie;
}
}
static GValueArray *
gst_uri_source_bin_autoplug_factories (GstElement * element, GstPad * pad,
GstCaps * caps)
{
GList *list, *tmp;
GValueArray *result;
GstURISourceBin *dec = GST_URI_SOURCE_BIN_CAST (element);
GST_DEBUG_OBJECT (element, "finding factories");
/* return all compatible factories for caps */
g_mutex_lock (&dec->factories_lock);
gst_uri_source_bin_update_factories_list (dec);
list =
gst_element_factory_list_filter (dec->factories, caps, GST_PAD_SINK,
gst_caps_is_fixed (caps));
g_mutex_unlock (&dec->factories_lock);
result = g_value_array_new (g_list_length (list));
for (tmp = list; tmp; tmp = tmp->next) {
GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (tmp->data);
GValue val = { 0, };
g_value_init (&val, G_TYPE_OBJECT);
g_value_set_object (&val, factory);
g_value_array_append (result, &val);
g_value_unset (&val);
}
gst_plugin_feature_list_free (list);
GST_DEBUG_OBJECT (element, "autoplug-factories returns %p", result);
return result;
}
static GValueArray *
gst_uri_source_bin_autoplug_sort (GstElement * element, GstPad * pad,
GstCaps * caps, GValueArray * factories)
{
return NULL;
}
static GstAutoplugSelectResult
gst_uri_source_bin_autoplug_select (GstElement * element, GstPad * pad,
GstCaps * caps, GstElementFactory * factory)
{
GST_DEBUG_OBJECT (element, "default autoplug-select returns TRY");
/* Try factory. */
return GST_AUTOPLUG_SELECT_TRY;
}
static gboolean
gst_uri_source_bin_autoplug_query (GstElement * element, GstPad * pad,
GstQuery * query)
{
/* No query handled here */
return FALSE;
}
static void
gst_uri_source_bin_class_init (GstURISourceBinClass * klass)
{
@ -513,155 +325,6 @@ gst_uri_source_bin_class_init (GstURISourceBinClass * klass)
0, G_MAXUINT, DEFAULT_RING_BUFFER_MAX_SIZE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstURISourceBin::autoplug-continue:
* @bin: The urisourcebin.
* @pad: The #GstPad.
* @caps: The #GstCaps found.
*
* This signal is emitted whenever urisourcebin finds a new stream. It is
* emitted before looking for any elements that can handle that stream.
*
* > Invocation of signal handlers stops after the first signal handler
* > returns %FALSE. Signal handlers are invoked in the order they were
* > connected in.
*
* Returns: %TRUE if you wish urisourcebin to look for elements that can
* handle the given @caps. If %FALSE, those caps will be considered as
* final and the pad will be exposed as such (see 'pad-added' signal of
* #GstElement).
*/
gst_uri_source_bin_signals[SIGNAL_AUTOPLUG_CONTINUE] =
g_signal_new ("autoplug-continue", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstURISourceBinClass,
autoplug_continue), _gst_boolean_accumulator, NULL,
g_cclosure_marshal_generic, G_TYPE_BOOLEAN, 2, GST_TYPE_PAD,
GST_TYPE_CAPS);
/**
* GstURISourceBin::autoplug-factories:
* @bin: The urisourcebin.
* @pad: The #GstPad.
* @caps: The #GstCaps found.
*
* This function is emitted when an array of possible factories for @caps on
* @pad is needed. urisourcebin will by default return an array with all
* compatible factories, sorted by rank.
*
* If this function returns NULL, @pad will be exposed as a final caps.
*
* If this function returns an empty array, the pad will be considered as
* having an unhandled type media type.
*
* > Only the signal handler that is connected first will ever by invoked.
* > Don't connect signal handlers with the #G_CONNECT_AFTER flag to this
* > signal, they will never be invoked!
*
* Returns: a #GValueArray* with a list of factories to try. The factories are
* by default tried in the returned order or based on the index returned by
* "autoplug-select".
*/
gst_uri_source_bin_signals[SIGNAL_AUTOPLUG_FACTORIES] =
g_signal_new ("autoplug-factories", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstURISourceBinClass,
autoplug_factories), _gst_array_accumulator, NULL,
g_cclosure_marshal_generic, G_TYPE_VALUE_ARRAY, 2,
GST_TYPE_PAD, GST_TYPE_CAPS);
/**
* GstURISourceBin::autoplug-sort:
* @bin: The urisourcebin.
* @pad: The #GstPad.
* @caps: The #GstCaps.
* @factories: A #GValueArray of possible #GstElementFactory to use.
*
* Once decodebin has found the possible #GstElementFactory objects to try
* for @caps on @pad, this signal is emited. The purpose of the signal is for
* the application to perform additional sorting or filtering on the element
* factory array.
*
* The callee should copy and modify @factories or return %NULL if the
* order should not change.
*
* > Invocation of signal handlers stops after one signal handler has
* > returned something else than %NULL. Signal handlers are invoked in
* > the order they were connected in.
* > Don't connect signal handlers with the #G_CONNECT_AFTER flag to this
* > signal, they will never be invoked!
*
* Returns: A new sorted array of #GstElementFactory objects.
*
* Since: 0.10.33
*/
gst_uri_source_bin_signals[SIGNAL_AUTOPLUG_SORT] =
g_signal_new ("autoplug-sort", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstURISourceBinClass, autoplug_sort),
_gst_array_hasvalue_accumulator, NULL,
g_cclosure_marshal_generic, G_TYPE_VALUE_ARRAY, 3, GST_TYPE_PAD,
GST_TYPE_CAPS, G_TYPE_VALUE_ARRAY | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* GstURISourceBin::autoplug-select:
* @bin: The urisourcebin.
* @pad: The #GstPad.
* @caps: The #GstCaps.
* @factory: A #GstElementFactory to use.
*
* This signal is emitted once urisourcebin has found all the possible
* #GstElementFactory that can be used to handle the given @caps. For each of
* those factories, this signal is emitted.
*
* The signal handler should return a #GST_TYPE_AUTOPLUG_SELECT_RESULT enum
* value indicating what decodebin should do next.
*
* A value of #GST_AUTOPLUG_SELECT_TRY will try to autoplug an element from
* @factory.
*
* A value of #GST_AUTOPLUG_SELECT_EXPOSE will expose @pad without plugging
* any element to it.
*
* A value of #GST_AUTOPLUG_SELECT_SKIP will skip @factory and move to the
* next factory.
*
* > The signal handler will not be invoked if any of the previously
* > registered signal handlers (if any) return a value other than
* > GST_AUTOPLUG_SELECT_TRY. Which also means that if you return
* > GST_AUTOPLUG_SELECT_TRY from one signal handler, handlers that get
* > registered next (again, if any) can override that decision.
*
* Returns: a #GST_TYPE_AUTOPLUG_SELECT_RESULT that indicates the required
* operation. The default handler will always return
* #GST_AUTOPLUG_SELECT_TRY.
*/
gst_uri_source_bin_signals[SIGNAL_AUTOPLUG_SELECT] =
g_signal_new ("autoplug-select", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstURISourceBinClass,
autoplug_select), _gst_select_accumulator, NULL,
g_cclosure_marshal_generic,
GST_TYPE_AUTOPLUG_SELECT_RESULT, 3, GST_TYPE_PAD, GST_TYPE_CAPS,
GST_TYPE_ELEMENT_FACTORY);
/**
* GstDecodeBin::autoplug-query:
* @bin: The decodebin.
* @child: The child element doing the query
* @pad: The #GstPad.
* @query: The #GstQuery.
*
* This signal is emitted whenever an autoplugged element that is
* not linked downstream yet and not exposed does a query. It can
* be used to tell the element about the downstream supported caps
* for example.
*
* Returns: %TRUE if the query was handled, %FALSE otherwise.
*/
gst_uri_source_bin_signals[SIGNAL_AUTOPLUG_QUERY] =
g_signal_new ("autoplug-query", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstURISourceBinClass, autoplug_query),
_gst_boolean_or_accumulator, NULL, g_cclosure_marshal_generic,
G_TYPE_BOOLEAN, 3, GST_TYPE_PAD, GST_TYPE_ELEMENT,
GST_TYPE_QUERY | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* GstURISourceBin::drained:
*
@ -703,15 +366,6 @@ gst_uri_source_bin_class_init (GstURISourceBinClass * klass)
GST_DEBUG_FUNCPTR (gst_uri_source_bin_change_state);
gstbin_class->handle_message = GST_DEBUG_FUNCPTR (handle_message);
klass->autoplug_continue =
GST_DEBUG_FUNCPTR (gst_uri_source_bin_autoplug_continue);
klass->autoplug_factories =
GST_DEBUG_FUNCPTR (gst_uri_source_bin_autoplug_factories);
klass->autoplug_sort = GST_DEBUG_FUNCPTR (gst_uri_source_bin_autoplug_sort);
klass->autoplug_select =
GST_DEBUG_FUNCPTR (gst_uri_source_bin_autoplug_select);
klass->autoplug_query = GST_DEBUG_FUNCPTR (gst_uri_source_bin_autoplug_query);
}
static void