mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
ges: Add check sync/async discoverer
To support ges_{init/deinit} multiple times in a process, there should be a method for setting up internal object/table of GESUriClipAssetClass. because *_class_init() will be called only once in process lifecycle.
This commit is contained in:
parent
173badbccf
commit
702c298122
3 changed files with 78 additions and 56 deletions
|
@ -167,6 +167,8 @@ ges_effect_assect_id_get_type_and_bindesc (const char *id,
|
|||
|
||||
G_GNUC_INTERNAL void _ges_uri_asset_cleanup (void);
|
||||
|
||||
G_GNUC_INTERNAL gboolean _ges_uri_asset_ensure_setup (gpointer uriasset_class);
|
||||
|
||||
/* GESExtractable internall methods
|
||||
*
|
||||
* FIXME Check if that should be public later
|
||||
|
|
|
@ -206,9 +206,6 @@ ges_uri_clip_asset_dispose (GObject * object)
|
|||
static void
|
||||
ges_uri_clip_asset_class_init (GESUriClipAssetClass * klass)
|
||||
{
|
||||
GError *err;
|
||||
GstClockTime timeout;
|
||||
const gchar *timeout_str;
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->get_property = ges_uri_clip_asset_get_property;
|
||||
|
@ -231,59 +228,7 @@ ges_uri_clip_asset_class_init (GESUriClipAssetClass * klass)
|
|||
g_object_class_install_property (object_class, PROP_DURATION,
|
||||
properties[PROP_DURATION]);
|
||||
|
||||
timeout = DEFAULT_DISCOVERY_TIMEOUT;
|
||||
errno = 0;
|
||||
timeout_str = g_getenv ("GES_DISCOVERY_TIMEOUT");
|
||||
if (timeout_str)
|
||||
timeout = g_ascii_strtod (timeout_str, NULL) * GST_SECOND;
|
||||
else
|
||||
errno = 10;
|
||||
|
||||
if (errno)
|
||||
timeout = DEFAULT_DISCOVERY_TIMEOUT;
|
||||
|
||||
if (!discoverer) {
|
||||
discoverer = gst_discoverer_new (timeout, &err);
|
||||
if (!discoverer) {
|
||||
GST_ERROR ("Could not create discoverer: %s", err->message);
|
||||
g_error_free (err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* The class structure keeps weak pointers on the discoverers so they
|
||||
* can be properly cleaned up in _ges_uri_asset_cleanup(). */
|
||||
if (!klass->discoverer) {
|
||||
klass->discoverer = discoverer;
|
||||
g_object_add_weak_pointer (G_OBJECT (discoverer),
|
||||
(gpointer *) & klass->discoverer);
|
||||
}
|
||||
|
||||
if (!sync_discoverer) {
|
||||
sync_discoverer = gst_discoverer_new (timeout, &err);
|
||||
|
||||
if (!sync_discoverer) {
|
||||
GST_ERROR ("Could not create discoverer: %s", err->message);
|
||||
g_error_free (err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!klass->sync_discoverer) {
|
||||
klass->sync_discoverer = sync_discoverer;
|
||||
g_object_add_weak_pointer (G_OBJECT (sync_discoverer),
|
||||
(gpointer *) & klass->sync_discoverer);
|
||||
}
|
||||
|
||||
g_signal_connect (klass->discoverer, "discovered",
|
||||
G_CALLBACK (discoverer_discovered_cb), NULL);
|
||||
|
||||
/* We just start the discoverer and let it live */
|
||||
gst_discoverer_start (klass->discoverer);
|
||||
if (parent_newparent_table == NULL) {
|
||||
parent_newparent_table = g_hash_table_new_full (g_file_hash,
|
||||
(GEqualFunc) g_file_equal, g_object_unref, g_object_unref);
|
||||
}
|
||||
_ges_uri_asset_ensure_setup (klass);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -817,3 +762,72 @@ _ges_uri_asset_cleanup (void)
|
|||
parent_newparent_table = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
_ges_uri_asset_ensure_setup (gpointer uriasset_class)
|
||||
{
|
||||
GESUriClipAssetClass *klass;
|
||||
GError *err;
|
||||
GstClockTime timeout;
|
||||
const gchar *timeout_str;
|
||||
|
||||
g_return_val_if_fail (GES_IS_URI_CLIP_ASSET_CLASS (uriasset_class), FALSE);
|
||||
|
||||
klass = GES_URI_CLIP_ASSET_CLASS (uriasset_class);
|
||||
|
||||
timeout = DEFAULT_DISCOVERY_TIMEOUT;
|
||||
errno = 0;
|
||||
timeout_str = g_getenv ("GES_DISCOVERY_TIMEOUT");
|
||||
if (timeout_str)
|
||||
timeout = g_ascii_strtod (timeout_str, NULL) * GST_SECOND;
|
||||
else
|
||||
errno = 10;
|
||||
|
||||
if (errno)
|
||||
timeout = DEFAULT_DISCOVERY_TIMEOUT;
|
||||
|
||||
if (!discoverer) {
|
||||
discoverer = gst_discoverer_new (timeout, &err);
|
||||
if (!discoverer) {
|
||||
GST_ERROR ("Could not create discoverer: %s", err->message);
|
||||
g_error_free (err);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* The class structure keeps weak pointers on the discoverers so they
|
||||
* can be properly cleaned up in _ges_uri_asset_cleanup(). */
|
||||
if (!klass->discoverer) {
|
||||
klass->discoverer = discoverer;
|
||||
g_object_add_weak_pointer (G_OBJECT (discoverer),
|
||||
(gpointer *) & klass->discoverer);
|
||||
|
||||
g_signal_connect (klass->discoverer, "discovered",
|
||||
G_CALLBACK (discoverer_discovered_cb), NULL);
|
||||
}
|
||||
|
||||
if (!sync_discoverer) {
|
||||
sync_discoverer = gst_discoverer_new (timeout, &err);
|
||||
|
||||
if (!sync_discoverer) {
|
||||
GST_ERROR ("Could not create discoverer: %s", err->message);
|
||||
g_error_free (err);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!klass->sync_discoverer) {
|
||||
klass->sync_discoverer = sync_discoverer;
|
||||
g_object_add_weak_pointer (G_OBJECT (sync_discoverer),
|
||||
(gpointer *) & klass->sync_discoverer);
|
||||
}
|
||||
|
||||
/* We just start the discoverer and let it live */
|
||||
gst_discoverer_start (klass->discoverer);
|
||||
if (parent_newparent_table == NULL) {
|
||||
parent_newparent_table = g_hash_table_new_full (g_file_hash,
|
||||
(GEqualFunc) g_file_equal, g_object_unref, g_object_unref);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,12 @@ ges_init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
|
|||
}
|
||||
|
||||
uriasset_klass = g_type_class_ref (GES_TYPE_URI_CLIP_ASSET);
|
||||
|
||||
if (!_ges_uri_asset_ensure_setup (uriasset_klass)) {
|
||||
GST_ERROR ("cannot setup uri asset");
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (!uriasset_klass || !uriasset_klass->discoverer) {
|
||||
GST_ERROR ("missing uri asset class %p or discoverer %p", uriasset_klass,
|
||||
uriasset_klass ? uriasset_klass->discoverer : NULL);
|
||||
|
|
Loading…
Reference in a new issue