mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
nlecomposition: Get overall pipeline position by recursing up
And handle NLEComposition inside NLEComposition Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/39
This commit is contained in:
parent
d8f2a406a7
commit
c596f80c63
3 changed files with 29 additions and 60 deletions
|
@ -58,8 +58,6 @@ typedef struct
|
||||||
GstPad *srcpad; /* Timeline source pad */
|
GstPad *srcpad; /* Timeline source pad */
|
||||||
GstPad *playsinkpad;
|
GstPad *playsinkpad;
|
||||||
GstPad *encodebinpad;
|
GstPad *encodebinpad;
|
||||||
|
|
||||||
guint query_position_id;
|
|
||||||
} OutputChain;
|
} OutputChain;
|
||||||
|
|
||||||
|
|
||||||
|
@ -753,18 +751,6 @@ no_track:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstClockTime
|
|
||||||
_query_position_cb (GstElement * composition, GESPipeline * self)
|
|
||||||
{
|
|
||||||
gint64 position;
|
|
||||||
|
|
||||||
if (gst_element_query_position (GST_ELEMENT (self), GST_FORMAT_TIME,
|
|
||||||
&position))
|
|
||||||
return position;
|
|
||||||
|
|
||||||
return GST_CLOCK_TIME_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_link_track (GESPipeline * self, GESTrack * track)
|
_link_track (GESPipeline * self, GESTrack * track)
|
||||||
{
|
{
|
||||||
|
@ -815,10 +801,6 @@ _link_track (GESPipeline * self, GESTrack * track)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chain->query_position_id =
|
|
||||||
g_signal_connect (ges_track_get_composition (track), "query-position",
|
|
||||||
G_CALLBACK (_query_position_cb), self);
|
|
||||||
|
|
||||||
chain->srcpad = pad;
|
chain->srcpad = pad;
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
|
|
||||||
|
@ -989,11 +971,6 @@ _unlink_track (GESPipeline * self, GESTrack * track)
|
||||||
|
|
||||||
gst_element_set_state (chain->tee, GST_STATE_NULL);
|
gst_element_set_state (chain->tee, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (self), chain->tee);
|
gst_bin_remove (GST_BIN (self), chain->tee);
|
||||||
if (chain->query_position_id) {
|
|
||||||
g_signal_handler_disconnect (ges_track_get_composition (track),
|
|
||||||
chain->query_position_id);
|
|
||||||
chain->query_position_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->priv->chains = g_list_remove (self->priv->chains, chain);
|
self->priv->chains = g_list_remove (self->priv->chains, chain);
|
||||||
g_free (chain);
|
g_free (chain);
|
||||||
|
|
|
@ -66,7 +66,6 @@ enum
|
||||||
{
|
{
|
||||||
COMMIT_SIGNAL,
|
COMMIT_SIGNAL,
|
||||||
COMMITED_SIGNAL,
|
COMMITED_SIGNAL,
|
||||||
QUERY_POSITION_SIGNAL,
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1006,22 +1005,6 @@ nle_composition_class_init (NleCompositionClass * klass)
|
||||||
0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
|
0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
|
||||||
G_TYPE_BOOLEAN);
|
G_TYPE_BOOLEAN);
|
||||||
|
|
||||||
/**
|
|
||||||
* NleComposition::query-position
|
|
||||||
* @comp: a #NleComposition
|
|
||||||
*
|
|
||||||
* A signal that *has* to be connected and which should return the current
|
|
||||||
* position of the pipeline.
|
|
||||||
*
|
|
||||||
* This signal is used in order to know the current position of the whole
|
|
||||||
* pipeline so it is user's responsability to give that answer as there
|
|
||||||
* is no other way to precisely know the position in the whole pipeline.
|
|
||||||
*/
|
|
||||||
_signals[QUERY_POSITION_SIGNAL] =
|
|
||||||
g_signal_new ("query-position", G_TYPE_FROM_CLASS (klass),
|
|
||||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
|
|
||||||
0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_UINT64, 0, NULL);
|
|
||||||
|
|
||||||
GST_DEBUG_REGISTER_FUNCPTR (_seek_pipeline_func);
|
GST_DEBUG_REGISTER_FUNCPTR (_seek_pipeline_func);
|
||||||
GST_DEBUG_REGISTER_FUNCPTR (_remove_object_func);
|
GST_DEBUG_REGISTER_FUNCPTR (_remove_object_func);
|
||||||
GST_DEBUG_REGISTER_FUNCPTR (_add_object_func);
|
GST_DEBUG_REGISTER_FUNCPTR (_add_object_func);
|
||||||
|
@ -1472,17 +1455,41 @@ get_current_position (NleComposition * comp)
|
||||||
NleCompositionPrivate *priv = comp->priv;
|
NleCompositionPrivate *priv = comp->priv;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
gint64 value = GST_CLOCK_TIME_NONE;
|
gint64 value = GST_CLOCK_TIME_NONE;
|
||||||
|
GstObject *parent, *tmp;
|
||||||
|
|
||||||
GstPad *peer;
|
GstPad *peer;
|
||||||
|
|
||||||
g_signal_emit (comp, _signals[QUERY_POSITION_SIGNAL], 0, &value);
|
parent = gst_object_get_parent (GST_OBJECT (comp));
|
||||||
|
while ((tmp = parent)) {
|
||||||
|
if (NLE_IS_COMPOSITION (parent)) {
|
||||||
|
GstClockTime parent_position =
|
||||||
|
get_current_position (NLE_COMPOSITION (parent));
|
||||||
|
|
||||||
if (value >= 0) {
|
if (parent_position > NLE_OBJECT_STOP (comp)
|
||||||
GST_DEBUG_OBJECT (comp, "Got position %" GST_TIME_FORMAT,
|
|| parent_position < NLE_OBJECT_START (comp)) {
|
||||||
GST_TIME_ARGS (value));
|
GST_INFO_OBJECT (comp,
|
||||||
|
"Global position outside of subcomposition, returning TIME_NONE");
|
||||||
|
|
||||||
|
return GST_CLOCK_TIME_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
value =
|
||||||
|
parent_position - NLE_OBJECT_START (comp) + NLE_OBJECT_INPOINT (comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GST_IS_PIPELINE (parent)) {
|
||||||
|
if (gst_element_query_position (GST_ELEMENT (parent), GST_FORMAT_TIME,
|
||||||
|
&value)) {
|
||||||
|
|
||||||
|
gst_object_unref (parent);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
parent = gst_object_get_parent (GST_OBJECT (parent));
|
||||||
|
gst_object_unref (tmp);
|
||||||
|
}
|
||||||
|
|
||||||
/* Try querying position downstream */
|
/* Try querying position downstream */
|
||||||
peer = gst_pad_get_peer (NLE_OBJECT (comp)->srcpad);
|
peer = gst_pad_get_peer (NLE_OBJECT (comp)->srcpad);
|
||||||
|
|
|
@ -196,18 +196,6 @@ GST_START_TEST (test_remove_invalid_object)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
static GstClockTime
|
|
||||||
_query_position_cb (GstElement * composition, GstPipeline * pipeline)
|
|
||||||
{
|
|
||||||
gint64 position;
|
|
||||||
|
|
||||||
if (gst_element_query_position (GST_ELEMENT (pipeline), GST_FORMAT_TIME,
|
|
||||||
&position))
|
|
||||||
return position;
|
|
||||||
|
|
||||||
return GST_CLOCK_TIME_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_START_TEST (test_remove_last_object)
|
GST_START_TEST (test_remove_last_object)
|
||||||
{
|
{
|
||||||
GstBin *composition;
|
GstBin *composition;
|
||||||
|
@ -227,9 +215,6 @@ GST_START_TEST (test_remove_last_object)
|
||||||
composition = GST_BIN (gst_element_factory_make ("nlecomposition",
|
composition = GST_BIN (gst_element_factory_make ("nlecomposition",
|
||||||
"composition"));
|
"composition"));
|
||||||
|
|
||||||
g_signal_connect (composition, "query-position",
|
|
||||||
G_CALLBACK (_query_position_cb), pipeline);
|
|
||||||
|
|
||||||
gst_element_set_state (GST_ELEMENT (composition), GST_STATE_READY);
|
gst_element_set_state (GST_ELEMENT (composition), GST_STATE_READY);
|
||||||
|
|
||||||
fakesink = gst_element_factory_make ("fakesink", NULL);
|
fakesink = gst_element_factory_make ("fakesink", NULL);
|
||||||
|
|
Loading…
Reference in a new issue