mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-29 23:32:33 +00:00
identity: Add ts-offset property.
Add a property to delay or advance sync time when sync=true, with the same behaviour as the ts-offset property in basesink
This commit is contained in:
parent
0a1baf6d07
commit
0528645f7c
2 changed files with 24 additions and 0 deletions
|
@ -72,6 +72,7 @@ enum
|
||||||
#define DEFAULT_CHECK_IMPERFECT_TIMESTAMP FALSE
|
#define DEFAULT_CHECK_IMPERFECT_TIMESTAMP FALSE
|
||||||
#define DEFAULT_CHECK_IMPERFECT_OFFSET FALSE
|
#define DEFAULT_CHECK_IMPERFECT_OFFSET FALSE
|
||||||
#define DEFAULT_SIGNAL_HANDOFFS TRUE
|
#define DEFAULT_SIGNAL_HANDOFFS TRUE
|
||||||
|
#define DEFAULT_TS_OFFSET 0
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -86,6 +87,7 @@ enum
|
||||||
PROP_LAST_MESSAGE,
|
PROP_LAST_MESSAGE,
|
||||||
PROP_DUMP,
|
PROP_DUMP,
|
||||||
PROP_SYNC,
|
PROP_SYNC,
|
||||||
|
PROP_TS_OFFSET,
|
||||||
PROP_CHECK_IMPERFECT_TIMESTAMP,
|
PROP_CHECK_IMPERFECT_TIMESTAMP,
|
||||||
PROP_CHECK_IMPERFECT_OFFSET,
|
PROP_CHECK_IMPERFECT_OFFSET,
|
||||||
PROP_SIGNAL_HANDOFFS
|
PROP_SIGNAL_HANDOFFS
|
||||||
|
@ -197,6 +199,11 @@ gst_identity_class_init (GstIdentityClass * klass)
|
||||||
g_param_spec_boolean ("sync", "Synchronize",
|
g_param_spec_boolean ("sync", "Synchronize",
|
||||||
"Synchronize to pipeline clock", DEFAULT_SYNC,
|
"Synchronize to pipeline clock", DEFAULT_SYNC,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
g_object_class_install_property (gobject_class, PROP_TS_OFFSET,
|
||||||
|
g_param_spec_int64 ("ts-offset", "Timestamp offset for synchronisation",
|
||||||
|
"Timestamp offset in nanoseconds for synchronisation, negative for earlier sync",
|
||||||
|
G_MININT64, G_MAXINT64, DEFAULT_TS_OFFSET,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_CHECK_IMPERFECT_TIMESTAMP,
|
PROP_CHECK_IMPERFECT_TIMESTAMP,
|
||||||
g_param_spec_boolean ("check-imperfect-timestamp",
|
g_param_spec_boolean ("check-imperfect-timestamp",
|
||||||
|
@ -274,6 +281,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;
|
||||||
|
identity->ts_offset = DEFAULT_TS_OFFSET;
|
||||||
g_cond_init (&identity->blocked_cond);
|
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);
|
||||||
|
@ -303,9 +311,18 @@ gst_identity_do_sync (GstIdentity * identity, GstClockTime running_time)
|
||||||
if ((clock = GST_ELEMENT (identity)->clock)) {
|
if ((clock = GST_ELEMENT (identity)->clock)) {
|
||||||
GstClockReturn cret;
|
GstClockReturn cret;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
|
GstClockTimeDiff ts_offset = identity->ts_offset;
|
||||||
|
|
||||||
timestamp = running_time + GST_ELEMENT (identity)->base_time +
|
timestamp = running_time + GST_ELEMENT (identity)->base_time +
|
||||||
identity->upstream_latency;
|
identity->upstream_latency;
|
||||||
|
if (ts_offset < 0) {
|
||||||
|
ts_offset = -ts_offset;
|
||||||
|
if (ts_offset < timestamp)
|
||||||
|
timestamp -= ts_offset;
|
||||||
|
else
|
||||||
|
timestamp = 0;
|
||||||
|
} else
|
||||||
|
timestamp += ts_offset;
|
||||||
|
|
||||||
/* save id if we need to unlock */
|
/* save id if we need to unlock */
|
||||||
identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp);
|
identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp);
|
||||||
|
@ -715,6 +732,9 @@ gst_identity_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_SYNC:
|
case PROP_SYNC:
|
||||||
identity->sync = g_value_get_boolean (value);
|
identity->sync = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_TS_OFFSET:
|
||||||
|
identity->ts_offset = g_value_get_int64 (value);
|
||||||
|
break;
|
||||||
case PROP_CHECK_IMPERFECT_TIMESTAMP:
|
case PROP_CHECK_IMPERFECT_TIMESTAMP:
|
||||||
identity->check_imperfect_timestamp = g_value_get_boolean (value);
|
identity->check_imperfect_timestamp = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
@ -775,6 +795,9 @@ gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
case PROP_SYNC:
|
case PROP_SYNC:
|
||||||
g_value_set_boolean (value, identity->sync);
|
g_value_set_boolean (value, identity->sync);
|
||||||
break;
|
break;
|
||||||
|
case PROP_TS_OFFSET:
|
||||||
|
identity->ts_offset = g_value_get_int64 (value);
|
||||||
|
break;
|
||||||
case PROP_CHECK_IMPERFECT_TIMESTAMP:
|
case PROP_CHECK_IMPERFECT_TIMESTAMP:
|
||||||
g_value_set_boolean (value, identity->check_imperfect_timestamp);
|
g_value_set_boolean (value, identity->check_imperfect_timestamp);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct _GstIdentity {
|
||||||
GstClockTime upstream_latency;
|
GstClockTime upstream_latency;
|
||||||
GCond blocked_cond;
|
GCond blocked_cond;
|
||||||
gboolean blocked;
|
gboolean blocked;
|
||||||
|
GstClockTimeDiff ts_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstIdentityClass {
|
struct _GstIdentityClass {
|
||||||
|
|
Loading…
Reference in a new issue