mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
discoverer: Add a signal to retrieve serialized GstDiscovererInfo
This allows user to serialize the GstDiscovererInfo in other places than the default folder, like a database when running web services for examples. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3911>
This commit is contained in:
parent
96e576a818
commit
9e994ea616
2 changed files with 73 additions and 21 deletions
|
@ -172,6 +172,7 @@ enum
|
||||||
SIGNAL_STARTING,
|
SIGNAL_STARTING,
|
||||||
SIGNAL_DISCOVERED,
|
SIGNAL_DISCOVERED,
|
||||||
SIGNAL_SOURCE_SETUP,
|
SIGNAL_SOURCE_SETUP,
|
||||||
|
SIGNAL_LOAD_SERIALIZED_INFO,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -215,6 +216,8 @@ static GVariant *gst_discoverer_info_to_variant_recurse (GstDiscovererStreamInfo
|
||||||
* sinfo, GstDiscovererSerializeFlags flags);
|
* sinfo, GstDiscovererSerializeFlags flags);
|
||||||
static GstDiscovererStreamInfo *_parse_discovery (GVariant * variant,
|
static GstDiscovererStreamInfo *_parse_discovery (GVariant * variant,
|
||||||
GstDiscovererInfo * info);
|
GstDiscovererInfo * info);
|
||||||
|
static GstDiscovererInfo *load_serialized_info (GstDiscoverer * dc,
|
||||||
|
gchar * uri);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_discoverer_class_init (GstDiscovererClass * klass)
|
gst_discoverer_class_init (GstDiscovererClass * klass)
|
||||||
|
@ -227,6 +230,8 @@ gst_discoverer_class_init (GstDiscovererClass * klass)
|
||||||
gobject_class->set_property = gst_discoverer_set_property;
|
gobject_class->set_property = gst_discoverer_set_property;
|
||||||
gobject_class->get_property = gst_discoverer_get_property;
|
gobject_class->get_property = gst_discoverer_get_property;
|
||||||
|
|
||||||
|
klass->load_serialize_info = load_serialized_info;
|
||||||
|
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
/**
|
/**
|
||||||
|
@ -323,6 +328,26 @@ gst_discoverer_class_init (GstDiscovererClass * klass)
|
||||||
g_signal_new ("source-setup", G_TYPE_FROM_CLASS (klass),
|
g_signal_new ("source-setup", G_TYPE_FROM_CLASS (klass),
|
||||||
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDiscovererClass, source_setup),
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDiscovererClass, source_setup),
|
||||||
NULL, NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
|
NULL, NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstDiscoverer::load-serialized-info:
|
||||||
|
* @discoverer: the #GstDiscoverer
|
||||||
|
* @uri: THe URI to load the serialized info for
|
||||||
|
*
|
||||||
|
* Retrieves information about a URI from and external source of information,
|
||||||
|
* like a cache file. This is used by the discoverer to speed up the
|
||||||
|
* discovery.
|
||||||
|
*
|
||||||
|
* Returns: (nullable) (transfer full): The #GstDiscovererInfo representing
|
||||||
|
* @uri, or %NULL if no information
|
||||||
|
*
|
||||||
|
* Since: 1.24
|
||||||
|
*/
|
||||||
|
gst_discoverer_signals[SIGNAL_LOAD_SERIALIZED_INFO] =
|
||||||
|
g_signal_new ("load-serialized-info", G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDiscovererClass,
|
||||||
|
load_serialize_info), g_signal_accumulator_first_wins, NULL, NULL,
|
||||||
|
GST_TYPE_DISCOVERER_INFO, 1, G_TYPE_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1836,40 +1861,53 @@ _get_info_from_cachefile (GstDiscoverer * dc, gchar * cachefile)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstDiscovererInfo *
|
||||||
|
load_serialized_info (GstDiscoverer * dc, gchar * uri)
|
||||||
|
{
|
||||||
|
GstDiscovererInfo *res = NULL;
|
||||||
|
|
||||||
|
if (dc->priv->use_cache) {
|
||||||
|
gchar *cachefile = _serialized_info_get_path (dc, uri);
|
||||||
|
|
||||||
|
if (cachefile) {
|
||||||
|
res = _get_info_from_cachefile (dc, cachefile);
|
||||||
|
g_free (cachefile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_setup_locked (GstDiscoverer * dc)
|
_setup_locked (GstDiscoverer * dc)
|
||||||
{
|
{
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
gchar *uri = (gchar *) dc->priv->pending_uris->data;
|
gchar *uri = (gchar *) dc->priv->pending_uris->data;
|
||||||
gchar *cachefile = NULL;
|
|
||||||
|
|
||||||
dc->priv->pending_uris =
|
dc->priv->pending_uris =
|
||||||
g_list_delete_link (dc->priv->pending_uris, dc->priv->pending_uris);
|
g_list_delete_link (dc->priv->pending_uris, dc->priv->pending_uris);
|
||||||
|
|
||||||
if (dc->priv->use_cache) {
|
|
||||||
cachefile = _serialized_info_get_path (dc, uri);
|
|
||||||
if (cachefile)
|
|
||||||
dc->priv->current_info = _get_info_from_cachefile (dc, cachefile);
|
|
||||||
|
|
||||||
|
GST_DEBUG ("Setting up");
|
||||||
|
|
||||||
|
g_signal_emit (dc, gst_discoverer_signals[SIGNAL_LOAD_SERIALIZED_INFO], 0,
|
||||||
|
uri, &dc->priv->current_info);
|
||||||
if (dc->priv->current_info) {
|
if (dc->priv->current_info) {
|
||||||
/* Make sure the URI is exactly what the user passed in */
|
/* Make sure the URI is exactly what the user passed in */
|
||||||
g_free (dc->priv->current_info->uri);
|
g_free (dc->priv->current_info->uri);
|
||||||
dc->priv->current_info->uri = uri;
|
dc->priv->current_info->uri = uri;
|
||||||
|
|
||||||
dc->priv->current_info->cachefile = cachefile;
|
|
||||||
dc->priv->processing = FALSE;
|
dc->priv->processing = FALSE;
|
||||||
dc->priv->target_state = GST_STATE_NULL;
|
dc->priv->target_state = GST_STATE_NULL;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG ("Setting up");
|
|
||||||
|
|
||||||
/* Pop URI off the pending URI list */
|
/* Pop URI off the pending URI list */
|
||||||
dc->priv->current_info =
|
dc->priv->current_info =
|
||||||
(GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
|
(GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
|
||||||
dc->priv->current_info->cachefile = cachefile;
|
if (dc->priv->use_cache)
|
||||||
|
dc->priv->current_info->cachefile = _serialized_info_get_path (dc, uri);
|
||||||
dc->priv->current_info->uri = uri;
|
dc->priv->current_info->uri = uri;
|
||||||
|
|
||||||
/* set uri on uridecodebin */
|
/* set uri on uridecodebin */
|
||||||
|
|
|
@ -386,8 +386,22 @@ struct _GstDiscovererClass {
|
||||||
const GError *err);
|
const GError *err);
|
||||||
void (*source_setup) (GstDiscoverer *discoverer,
|
void (*source_setup) (GstDiscoverer *discoverer,
|
||||||
GstElement *source);
|
GstElement *source);
|
||||||
|
/**
|
||||||
|
* GstDiscovererClass::load_serialize_info:
|
||||||
|
* @dc: the #GstDiscoverer
|
||||||
|
* @uri: the uri to load the info from
|
||||||
|
*
|
||||||
|
* Loads the serialized info from the given uri.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): the #GstDiscovererInfo or %NULL if it could not be loaded
|
||||||
|
*
|
||||||
|
* Since: 1.24
|
||||||
|
*/
|
||||||
|
GstDiscovererInfo *
|
||||||
|
(*load_serialize_info) (GstDiscoverer *dc,
|
||||||
|
gchar *uri);
|
||||||
|
|
||||||
gpointer _reserved[GST_PADDING];
|
gpointer _reserved[GST_PADDING - 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
GST_PBUTILS_API
|
GST_PBUTILS_API
|
||||||
|
|
Loading…
Reference in a new issue