mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
composition: Add an enum to define why we update the stack
Making the code simpler to follow Co-Authored by: Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
This commit is contained in:
parent
ccf9a3e3d7
commit
fe5ca968d0
1 changed files with 54 additions and 26 deletions
|
@ -74,6 +74,18 @@ enum
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COMP_UPDATE_STACK_INITIALIZE,
|
||||||
|
COMP_UPDATE_STACK_ON_COMMIT,
|
||||||
|
COMP_UPDATE_STACK_ON_EOS,
|
||||||
|
COMP_UPDATE_STACK_ON_SEEK
|
||||||
|
} GnlUpdateStackReason;
|
||||||
|
|
||||||
|
static const char *UPDATE_PIPELINE_REASONS[] = {
|
||||||
|
"Initialize", "Commit", "EOS", "Seek"
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _GnlCompositionEntry GnlCompositionEntry;
|
typedef struct _GnlCompositionEntry GnlCompositionEntry;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -212,14 +224,13 @@ gnl_composition_change_state (GstElement * element, GstStateChange transition);
|
||||||
static inline void gnl_composition_reset_target_pad (GnlComposition * comp);
|
static inline void gnl_composition_reset_target_pad (GnlComposition * comp);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
seek_handling (GnlComposition * comp, gboolean initial, gboolean update,
|
seek_handling (GnlComposition * comp, GnlUpdateStackReason update_stack_reason);
|
||||||
gboolean flush_downstream);
|
|
||||||
static gint objects_start_compare (GnlObject * a, GnlObject * b);
|
static gint objects_start_compare (GnlObject * a, GnlObject * b);
|
||||||
static gint objects_stop_compare (GnlObject * a, GnlObject * b);
|
static gint objects_stop_compare (GnlObject * a, GnlObject * b);
|
||||||
static GstClockTime get_current_position (GnlComposition * comp);
|
static GstClockTime get_current_position (GnlComposition * comp);
|
||||||
|
|
||||||
static gboolean update_pipeline (GnlComposition * comp,
|
static gboolean update_pipeline (GnlComposition * comp,
|
||||||
GstClockTime currenttime, gboolean initial, gboolean modify);
|
GstClockTime currenttime, GnlUpdateStackReason update_stack_reason);
|
||||||
static gboolean gnl_composition_commit_func (GnlObject * object,
|
static gboolean gnl_composition_commit_func (GnlObject * object,
|
||||||
gboolean recurse);
|
gboolean recurse);
|
||||||
static void update_start_stop_duration (GnlComposition * comp);
|
static void update_start_stop_duration (GnlComposition * comp);
|
||||||
|
@ -243,11 +254,10 @@ static gboolean
|
||||||
_gnl_composition_remove_entry (GnlComposition * comp, GnlObject * object);
|
_gnl_composition_remove_entry (GnlComposition * comp, GnlObject * object);
|
||||||
static void _deactivate_stack (GnlComposition * comp,
|
static void _deactivate_stack (GnlComposition * comp,
|
||||||
gboolean flush_downstream);
|
gboolean flush_downstream);
|
||||||
static GstPadProbeReturn _add_emit_commited_and_restart_task (GnlComposition *
|
|
||||||
comp);
|
|
||||||
static gboolean _set_real_eos_seqnum_from_seek (GnlComposition * comp,
|
static gboolean _set_real_eos_seqnum_from_seek (GnlComposition * comp,
|
||||||
GstEvent * event);
|
GstEvent * event);
|
||||||
static gboolean _emit_commited_signal_func (GnlComposition * comp);
|
static gboolean _emit_commited_signal_func (GnlComposition * comp);
|
||||||
|
static void _restart_task (GnlComposition * comp, gboolean emit_commit);
|
||||||
|
|
||||||
|
|
||||||
/* COMP_REAL_START: actual position to start current playback at. */
|
/* COMP_REAL_START: actual position to start current playback at. */
|
||||||
|
@ -481,7 +491,7 @@ _seek_pipeline_func (SeekData * seekd)
|
||||||
priv->next_base_time = 0;
|
priv->next_base_time = 0;
|
||||||
|
|
||||||
priv->reset_time = TRUE;
|
priv->reset_time = TRUE;
|
||||||
seek_handling (seekd->comp, TRUE, FALSE, TRUE);
|
seek_handling (seekd->comp, COMP_UPDATE_STACK_ON_SEEK);
|
||||||
priv->reset_time = FALSE;
|
priv->reset_time = FALSE;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
|
@ -529,7 +539,8 @@ _initialize_stack_func (GnlComposition * comp)
|
||||||
|
|
||||||
/* set ghostpad target */
|
/* set ghostpad target */
|
||||||
COMP_OBJECTS_LOCK (comp);
|
COMP_OBJECTS_LOCK (comp);
|
||||||
if (!(update_pipeline (comp, COMP_REAL_START (comp), TRUE, FALSE))) {
|
if (!(update_pipeline (comp, COMP_REAL_START (comp),
|
||||||
|
COMP_UPDATE_STACK_INITIALIZE))) {
|
||||||
COMP_OBJECTS_UNLOCK (comp);
|
COMP_OBJECTS_UNLOCK (comp);
|
||||||
GST_FIXME_OBJECT (comp, "PLEASE signal state change failure ASYNC");
|
GST_FIXME_OBJECT (comp, "PLEASE signal state change failure ASYNC");
|
||||||
|
|
||||||
|
@ -1326,10 +1337,14 @@ priority_comp (GnlObject * a, GnlObject * b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
have_to_update_pipeline (GnlComposition * comp)
|
have_to_update_pipeline (GnlComposition * comp,
|
||||||
|
GnlUpdateStackReason update_stack_reason)
|
||||||
{
|
{
|
||||||
GnlCompositionPrivate *priv = comp->priv;
|
GnlCompositionPrivate *priv = comp->priv;
|
||||||
|
|
||||||
|
if (update_stack_reason == COMP_UPDATE_STACK_ON_EOS)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (comp,
|
GST_DEBUG_OBJECT (comp,
|
||||||
"segment[%" GST_TIME_FORMAT "--%" GST_TIME_FORMAT "] current[%"
|
"segment[%" GST_TIME_FORMAT "--%" GST_TIME_FORMAT "] current[%"
|
||||||
GST_TIME_FORMAT "--%" GST_TIME_FORMAT "]",
|
GST_TIME_FORMAT "--%" GST_TIME_FORMAT "]",
|
||||||
|
@ -1526,10 +1541,10 @@ _seek_current_stack (GnlComposition * comp, GstEvent * event)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
seek_handling (GnlComposition * comp, gboolean initial, gboolean update,
|
seek_handling (GnlComposition * comp, GnlUpdateStackReason update_stack_reason)
|
||||||
gboolean flush_downstream)
|
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (comp, "initial:%d, update:%d", initial, update);
|
GST_DEBUG_OBJECT (comp, "Seek hnalding update pipeline reason: %s",
|
||||||
|
UPDATE_PIPELINE_REASONS[update_stack_reason]);
|
||||||
|
|
||||||
COMP_FLUSHING_LOCK (comp);
|
COMP_FLUSHING_LOCK (comp);
|
||||||
GST_DEBUG_OBJECT (comp, "Setting flushing to TRUE");
|
GST_DEBUG_OBJECT (comp, "Setting flushing to TRUE");
|
||||||
|
@ -1537,13 +1552,11 @@ seek_handling (GnlComposition * comp, gboolean initial, gboolean update,
|
||||||
COMP_FLUSHING_UNLOCK (comp);
|
COMP_FLUSHING_UNLOCK (comp);
|
||||||
|
|
||||||
COMP_OBJECTS_LOCK (comp);
|
COMP_OBJECTS_LOCK (comp);
|
||||||
if (update || have_to_update_pipeline (comp)) {
|
if (have_to_update_pipeline (comp, update_stack_reason)) {
|
||||||
if (comp->priv->segment->rate >= 0.0)
|
if (comp->priv->segment->rate >= 0.0)
|
||||||
update_pipeline (comp, comp->priv->segment->start, initial,
|
update_pipeline (comp, comp->priv->segment->start, update_stack_reason);
|
||||||
flush_downstream);
|
|
||||||
else
|
else
|
||||||
update_pipeline (comp, comp->priv->segment->stop, initial,
|
update_pipeline (comp, comp->priv->segment->stop, update_stack_reason);
|
||||||
flush_downstream);
|
|
||||||
} else {
|
} else {
|
||||||
GstEvent *toplevel_seek = get_new_seek_event (comp, FALSE, FALSE);
|
GstEvent *toplevel_seek = get_new_seek_event (comp, FALSE, FALSE);
|
||||||
|
|
||||||
|
@ -2283,7 +2296,7 @@ _commit_func (GnlComposition * comp)
|
||||||
/* And update the pipeline at current position if needed */
|
/* And update the pipeline at current position if needed */
|
||||||
|
|
||||||
update_start_stop_duration (comp);
|
update_start_stop_duration (comp);
|
||||||
update_pipeline (comp, curpos, TRUE, TRUE);
|
update_pipeline (comp, curpos, COMP_UPDATE_STACK_ON_COMMIT);
|
||||||
|
|
||||||
if (!priv->current) {
|
if (!priv->current) {
|
||||||
COMP_OBJECTS_UNLOCK (comp);
|
COMP_OBJECTS_UNLOCK (comp);
|
||||||
|
@ -2321,7 +2334,7 @@ update_pipeline_func (GnlComposition * comp)
|
||||||
priv->segment->stop = priv->segment_start;
|
priv->segment->stop = priv->segment_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
seek_handling (comp, TRUE, TRUE, FALSE);
|
seek_handling (comp, COMP_UPDATE_STACK_ON_EOS);
|
||||||
|
|
||||||
/* Post segment done if last seek was a segment seek */
|
/* Post segment done if last seek was a segment seek */
|
||||||
if (!priv->current && (priv->segment->flags & GST_SEEK_FLAG_SEGMENT)) {
|
if (!priv->current && (priv->segment->flags & GST_SEEK_FLAG_SEGMENT)) {
|
||||||
|
@ -2887,13 +2900,21 @@ _set_real_eos_seqnum_from_seek (GnlComposition * comp, GstEvent * event)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_flush_downstream (GnlUpdateStackReason update_reason)
|
||||||
|
{
|
||||||
|
if (update_reason == COMP_UPDATE_STACK_ON_COMMIT ||
|
||||||
|
update_reason == COMP_UPDATE_STACK_ON_SEEK)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* update_pipeline:
|
* update_pipeline:
|
||||||
* @comp: The #GnlComposition
|
* @comp: The #GnlComposition
|
||||||
* @currenttime: The #GstClockTime to update at, can be GST_CLOCK_TIME_NONE.
|
* @currenttime: The #GstClockTime to update at, can be GST_CLOCK_TIME_NONE.
|
||||||
* @initial: TRUE if this is the first setup
|
* @update_reason: Reason why we are updating the pipeline
|
||||||
* @change_state: Change the state of the (de)activated objects if TRUE.
|
|
||||||
* @modify: Flush downstream if TRUE. Needed for modified timelines.
|
|
||||||
*
|
*
|
||||||
* Updates the internal pipeline and properties. If @currenttime is
|
* Updates the internal pipeline and properties. If @currenttime is
|
||||||
* GST_CLOCK_TIME_NONE, it will not modify the current pipeline
|
* GST_CLOCK_TIME_NONE, it will not modify the current pipeline
|
||||||
|
@ -2904,7 +2925,7 @@ _set_real_eos_seqnum_from_seek (GnlComposition * comp, GstEvent * event)
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
update_pipeline (GnlComposition * comp, GstClockTime currenttime,
|
update_pipeline (GnlComposition * comp, GstClockTime currenttime,
|
||||||
gboolean initial, gboolean flush_downstream)
|
GnlUpdateStackReason update_reason)
|
||||||
{
|
{
|
||||||
|
|
||||||
gint stack_seqnum;
|
gint stack_seqnum;
|
||||||
|
@ -2925,8 +2946,8 @@ update_pipeline (GnlComposition * comp, GstClockTime currenttime,
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (comp,
|
GST_DEBUG_OBJECT (comp,
|
||||||
"currenttime:%" GST_TIME_FORMAT
|
"currenttime:%" GST_TIME_FORMAT
|
||||||
" initial:%d , flushing downstream:%d", GST_TIME_ARGS (currenttime),
|
" Reason: %s", GST_TIME_ARGS (currenttime),
|
||||||
initial, flush_downstream);
|
UPDATE_PIPELINE_REASONS[update_reason]);
|
||||||
|
|
||||||
if (!GST_CLOCK_TIME_IS_VALID (currenttime))
|
if (!GST_CLOCK_TIME_IS_VALID (currenttime))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2980,7 +3001,7 @@ update_pipeline (GnlComposition * comp, GstClockTime currenttime,
|
||||||
|
|
||||||
/* If stacks are different, unlink/relink objects */
|
/* If stacks are different, unlink/relink objects */
|
||||||
if (!samestack) {
|
if (!samestack) {
|
||||||
_deactivate_stack (comp, flush_downstream);
|
_deactivate_stack (comp, _flush_downstream (update_reason));
|
||||||
_relink_new_stack (comp, stack, toplevel_seek);
|
_relink_new_stack (comp, stack, toplevel_seek);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2991,14 +3012,21 @@ update_pipeline (GnlComposition * comp, GstClockTime currenttime,
|
||||||
priv->current = stack;
|
priv->current = stack;
|
||||||
|
|
||||||
if (priv->current) {
|
if (priv->current) {
|
||||||
|
GstPadProbeCallback _stack_setup_done;
|
||||||
|
|
||||||
GST_INFO_OBJECT (comp, "New stack set and ready to run, probing src pad"
|
GST_INFO_OBJECT (comp, "New stack set and ready to run, probing src pad"
|
||||||
" and stopping children thread until we are actually ready with"
|
" and stopping children thread until we are actually ready with"
|
||||||
" that new stack");
|
" that new stack");
|
||||||
|
|
||||||
|
if (update_reason == COMP_UPDATE_STACK_ON_COMMIT)
|
||||||
|
_stack_setup_done = (GstPadProbeCallback) _commit_done_cb;
|
||||||
|
else
|
||||||
|
_stack_setup_done = (GstPadProbeCallback) _stack_setup_done_cb;
|
||||||
|
|
||||||
comp->priv->awaited_caps_seqnum = stack_seqnum;
|
comp->priv->awaited_caps_seqnum = stack_seqnum;
|
||||||
priv->commited_probeid = gst_pad_add_probe (GNL_OBJECT_SRC (comp),
|
priv->commited_probeid = gst_pad_add_probe (GNL_OBJECT_SRC (comp),
|
||||||
GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
|
GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
|
||||||
(GstPadProbeCallback) _commit_done_cb, comp, NULL);
|
(GstPadProbeCallback) _stack_setup_done, comp, NULL);
|
||||||
|
|
||||||
gst_task_pause (comp->task);
|
gst_task_pause (comp->task);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue