mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
identity: With sync=true, don't pre-roll
To act like a real live element, block the streaming when paused, and return NO_PREROLL. https://bugzilla.gnome.org/show_bug.cgi?id=601853
This commit is contained in:
parent
7807296afd
commit
5ea338907c
2 changed files with 27 additions and 0 deletions
|
@ -127,6 +127,7 @@ gst_identity_finalize (GObject * object)
|
||||||
identity = GST_IDENTITY (object);
|
identity = GST_IDENTITY (object);
|
||||||
|
|
||||||
g_free (identity->last_message);
|
g_free (identity->last_message);
|
||||||
|
g_cond_clear (&identity->blocked_cond);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -259,6 +260,7 @@ gst_identity_init (GstIdentity * identity)
|
||||||
identity->dump = DEFAULT_DUMP;
|
identity->dump = DEFAULT_DUMP;
|
||||||
identity->last_message = NULL;
|
identity->last_message = NULL;
|
||||||
identity->signal_handoffs = DEFAULT_SIGNAL_HANDOFFS;
|
identity->signal_handoffs = DEFAULT_SIGNAL_HANDOFFS;
|
||||||
|
g_cond_init (&identity->blocked_cond);
|
||||||
|
|
||||||
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM_CAST (identity), TRUE);
|
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM_CAST (identity), TRUE);
|
||||||
}
|
}
|
||||||
|
@ -568,6 +570,11 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
||||||
GstClock *clock;
|
GstClock *clock;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (identity);
|
GST_OBJECT_LOCK (identity);
|
||||||
|
|
||||||
|
while (identity->blocked)
|
||||||
|
g_cond_wait (&identity->blocked_cond, GST_OBJECT_GET_LOCK (identity));
|
||||||
|
|
||||||
|
|
||||||
if ((clock = GST_ELEMENT (identity)->clock)) {
|
if ((clock = GST_ELEMENT (identity)->clock)) {
|
||||||
GstClockReturn cret;
|
GstClockReturn cret;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
|
@ -840,13 +847,23 @@ gst_identity_change_state (GstElement * element, GstStateChange transition)
|
||||||
{
|
{
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstIdentity *identity = GST_IDENTITY (element);
|
GstIdentity *identity = GST_IDENTITY (element);
|
||||||
|
gboolean no_preroll = FALSE;
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
|
GST_OBJECT_LOCK (identity);
|
||||||
|
identity->blocked = TRUE;
|
||||||
|
GST_OBJECT_UNLOCK (identity);
|
||||||
|
if (identity->sync)
|
||||||
|
no_preroll = TRUE;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
|
GST_OBJECT_LOCK (identity);
|
||||||
|
identity->blocked = FALSE;
|
||||||
|
g_cond_broadcast (&identity->blocked_cond);
|
||||||
|
GST_OBJECT_UNLOCK (identity);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
GST_OBJECT_LOCK (identity);
|
GST_OBJECT_LOCK (identity);
|
||||||
|
@ -856,6 +873,8 @@ gst_identity_change_state (GstElement * element, GstStateChange transition)
|
||||||
gst_clock_id_unref (identity->clock_id);
|
gst_clock_id_unref (identity->clock_id);
|
||||||
identity->clock_id = NULL;
|
identity->clock_id = NULL;
|
||||||
}
|
}
|
||||||
|
identity->blocked = FALSE;
|
||||||
|
g_cond_broadcast (&identity->blocked_cond);
|
||||||
GST_OBJECT_UNLOCK (identity);
|
GST_OBJECT_UNLOCK (identity);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -868,7 +887,10 @@ gst_identity_change_state (GstElement * element, GstStateChange transition)
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||||
GST_OBJECT_LOCK (identity);
|
GST_OBJECT_LOCK (identity);
|
||||||
identity->upstream_latency = 0;
|
identity->upstream_latency = 0;
|
||||||
|
identity->blocked = TRUE;
|
||||||
GST_OBJECT_UNLOCK (identity);
|
GST_OBJECT_UNLOCK (identity);
|
||||||
|
if (identity->sync)
|
||||||
|
no_preroll = TRUE;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
break;
|
break;
|
||||||
|
@ -878,5 +900,8 @@ gst_identity_change_state (GstElement * element, GstStateChange transition)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (no_preroll && ret == GST_STATE_CHANGE_SUCCESS)
|
||||||
|
ret = GST_STATE_CHANGE_NO_PREROLL;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,8 @@ struct _GstIdentity {
|
||||||
guint64 offset;
|
guint64 offset;
|
||||||
gboolean signal_handoffs;
|
gboolean signal_handoffs;
|
||||||
GstClockTime upstream_latency;
|
GstClockTime upstream_latency;
|
||||||
|
GCond blocked_cond;
|
||||||
|
gboolean blocked;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstIdentityClass {
|
struct _GstIdentityClass {
|
||||||
|
|
Loading…
Reference in a new issue