ges-launcher: add option to forward tags

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/265>
This commit is contained in:
Mathieu Duponchelle 2021-08-10 23:54:47 +02:00
parent 148c751bc0
commit 5ca6576f5b
4 changed files with 89 additions and 5 deletions

View file

@ -139,6 +139,18 @@
} }
}, },
"properties": { "properties": {
"drop-tags": {
"blurb": "Whether the composition should drop tags from its children",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "true",
"mutable": "playing",
"readable": true,
"type": "gboolean",
"writable": true
},
"id": { "id": {
"blurb": "The stream-id of the composition", "blurb": "The stream-id of the composition",
"conditionally-available": false, "conditionally-available": false,

View file

@ -50,9 +50,12 @@ enum
{ {
PROP_0, PROP_0,
PROP_ID, PROP_ID,
PROP_DROP_TAGS,
PROP_LAST, PROP_LAST,
}; };
#define DEFAULT_DROP_TAGS TRUE
/* Properties from NleObject */ /* Properties from NleObject */
enum enum
{ {
@ -204,7 +207,9 @@ struct _NleCompositionPrivate
guint seek_seqnum; guint seek_seqnum;
/* Both protected with object lock */
gchar *id; gchar *id;
gboolean drop_tags;
}; };
#define ACTION_CALLBACK(__action) (((GCClosure*) (__action))->callback) #define ACTION_CALLBACK(__action) (((GCClosure*) (__action))->callback)
@ -1041,6 +1046,11 @@ nle_composition_get_property (GObject * object, guint property_id,
g_value_set_string (value, comp->priv->id); g_value_set_string (value, comp->priv->id);
GST_OBJECT_UNLOCK (comp); GST_OBJECT_UNLOCK (comp);
break; break;
case PROP_DROP_TAGS:
GST_OBJECT_LOCK (comp);
g_value_set_boolean (value, comp->priv->drop_tags);
GST_OBJECT_UNLOCK (comp);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (comp, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (comp, property_id, pspec);
} }
@ -1059,6 +1069,11 @@ nle_composition_set_property (GObject * object, guint property_id,
comp->priv->id = g_value_dup_string (value); comp->priv->id = g_value_dup_string (value);
GST_OBJECT_UNLOCK (comp); GST_OBJECT_UNLOCK (comp);
break; break;
case PROP_DROP_TAGS:
GST_OBJECT_LOCK (comp);
comp->priv->drop_tags = g_value_get_boolean (value);
GST_OBJECT_UNLOCK (comp);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (comp, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (comp, property_id, pspec);
} }
@ -1114,6 +1129,20 @@ nle_composition_class_init (NleCompositionClass * klass)
g_param_spec_string ("id", "Id", "The stream-id of the composition", g_param_spec_string ("id", "Id", "The stream-id of the composition",
NULL, NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_DOC_SHOW_DEFAULT); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_DOC_SHOW_DEFAULT);
/**
* NleComposition:drop-tags:
*
* Whether the composition should drop tags from its children
*
* Since: 1.20
*/
properties[PROP_DROP_TAGS] =
g_param_spec_boolean ("drop-tags", "Drop tags",
"Whether the composition should drop tags from its children",
DEFAULT_DROP_TAGS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_DOC_SHOW_DEFAULT |
GST_PARAM_MUTABLE_PLAYING);
g_object_class_install_properties (gobject_class, PROP_LAST, properties); g_object_class_install_properties (gobject_class, PROP_LAST, properties);
_signals[COMMITED_SIGNAL] = _signals[COMMITED_SIGNAL] =
@ -1168,6 +1197,7 @@ nle_composition_init (NleComposition * comp)
priv->id = gst_pad_create_stream_id (NLE_OBJECT_SRC (comp), priv->id = gst_pad_create_stream_id (NLE_OBJECT_SRC (comp),
GST_ELEMENT (comp), NULL); GST_ELEMENT (comp), NULL);
priv->drop_tags = DEFAULT_DROP_TAGS;
priv->nle_event_pad_func = GST_PAD_EVENTFUNC (NLE_OBJECT_SRC (comp)); priv->nle_event_pad_func = GST_PAD_EVENTFUNC (NLE_OBJECT_SRC (comp));
gst_pad_set_event_function (NLE_OBJECT_SRC (comp), gst_pad_set_event_function (NLE_OBJECT_SRC (comp),
GST_DEBUG_FUNCPTR (nle_composition_event_handler)); GST_DEBUG_FUNCPTR (nle_composition_event_handler));
@ -1490,7 +1520,10 @@ ghost_event_probe_handler (GstPad * ghostpad G_GNUC_UNUSED,
break; break;
case GST_EVENT_TAG: case GST_EVENT_TAG:
GST_DEBUG_OBJECT (comp, "Dropping tag: %" GST_PTR_FORMAT, info->data); GST_DEBUG_OBJECT (comp, "Dropping tag: %" GST_PTR_FORMAT, info->data);
GST_OBJECT_LOCK (comp);
if (comp->priv->drop_tags)
retval = GST_PAD_PROBE_DROP; retval = GST_PAD_PROBE_DROP;
GST_OBJECT_UNLOCK (comp);
break; break;
case GST_EVENT_EOS: case GST_EVENT_EOS:
{ {

View file

@ -356,6 +356,39 @@ _set_restriction_caps (GESTimeline * timeline, GESLauncherParsedOptions * opts)
} }
static void
_set_track_forward_tags (const GValue * item, gpointer unused)
{
GstElement *comp = g_value_get_object (item);
g_object_set (comp, "drop-tags", FALSE, NULL);
}
static void
_set_tracks_forward_tags (GESTimeline * timeline,
GESLauncherParsedOptions * opts)
{
GList *tmp, *tracks;
if (!opts->forward_tags)
return;
tracks = ges_timeline_get_tracks (timeline);
for (tmp = tracks; tmp; tmp = tmp->next) {
GstIterator *it =
gst_bin_iterate_all_by_element_factory_name (GST_BIN (tmp->data),
"nlecomposition");
gst_iterator_foreach (it,
(GstIteratorForeachFunction) _set_track_forward_tags, NULL);
gst_iterator_free (it);
}
g_list_free_full (tracks, gst_object_unref);
}
static void static void
_check_has_audio_video (GESLauncher * self, gint * n_audio, gint * n_video) _check_has_audio_video (GESLauncher * self, gint * n_audio, gint * n_video)
{ {
@ -547,8 +580,8 @@ _set_rendering_details (GESLauncher * self)
} }
proj = proj =
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (self-> GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (self->priv->
priv->timeline))); timeline)));
/* Setup profile/encoding if needed */ /* Setup profile/encoding if needed */
if (opts->outputuri) { if (opts->outputuri) {
@ -748,6 +781,8 @@ retry:
_set_restriction_caps (timeline, opts); _set_restriction_caps (timeline, opts);
} }
_set_tracks_forward_tags (timeline, opts);
return TRUE; return TRUE;
} }
@ -987,8 +1022,8 @@ _save_timeline (GESLauncher * self)
if (opts->embed_nesteds) { if (opts->embed_nesteds) {
GList *tmp, *assets; GList *tmp, *assets;
GESProject *proj = GESProject *proj =
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (self->priv-> GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (self->
timeline))); priv->timeline)));
assets = ges_project_list_assets (proj, GES_TYPE_URI_CLIP); assets = ges_project_list_assets (proj, GES_TYPE_URI_CLIP);
for (tmp = assets; tmp; tmp = tmp->next) { for (tmp = assets; tmp; tmp = tmp->next) {
@ -1239,6 +1274,9 @@ ges_launcher_get_rendering_option_group (GESLauncherParsedOptions * opts)
"of the rendered output. This will have no effect if no outputuri " "of the rendered output. This will have no effect if no outputuri "
"has been specified.", "has been specified.",
"<clip-name>"}, "<clip-name>"},
{"forward-tags", 0, 0, G_OPTION_ARG_NONE, &opts->forward_tags,
"Forward tags from input files to the output",
NULL},
{"smart-rendering", 0, 0, G_OPTION_ARG_NONE, &opts->smartrender, {"smart-rendering", 0, 0, G_OPTION_ARG_NONE, &opts->smartrender,
"Avoid reencoding when rendering. This option implies --disable-mixing.", "Avoid reencoding when rendering. This option implies --disable-mixing.",
NULL}, NULL},

View file

@ -51,6 +51,7 @@ typedef struct
gboolean ignore_eos; gboolean ignore_eos;
gboolean interactive; gboolean interactive;
gboolean forward_tags;
} GESLauncherParsedOptions; } GESLauncherParsedOptions;
gchar * sanitize_timeline_description (gchar **args, GESLauncherParsedOptions *opts); gchar * sanitize_timeline_description (gchar **args, GESLauncherParsedOptions *opts);