mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-24 16:18:16 +00:00
gst/base/gstbasesink.c: 0 segment values are 0 in any format.
Original commit message from CVS: * gst/base/gstbasesink.c: (gst_base_sink_handle_object): 0 segment values are 0 in any format. * gst/base/gstbasetransform.c: (gst_base_transform_event): * gst/base/gstbasetransform.h: Parse newsegment correctly in basetransform * gst/elements/gstidentity.c: (gst_identity_transform_ip): Sync to clock using updated segment values.
This commit is contained in:
parent
a594b62809
commit
eb29555a92
9 changed files with 174 additions and 44 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2005-11-15 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/base/gstbasesink.c: (gst_base_sink_handle_object):
|
||||||
|
0 segment values are 0 in any format.
|
||||||
|
|
||||||
|
* gst/base/gstbasetransform.c: (gst_base_transform_event):
|
||||||
|
* gst/base/gstbasetransform.h:
|
||||||
|
Parse newsegment correctly in basetransform
|
||||||
|
|
||||||
|
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
|
||||||
|
Sync to clock using updated segment values.
|
||||||
|
|
||||||
2005-11-15 Andy Wingo <wingo@pobox.com>
|
2005-11-15 Andy Wingo <wingo@pobox.com>
|
||||||
|
|
||||||
* check/gst/gstpipeline.c (test_base_time): Add check that the
|
* check/gst/gstpipeline.c (test_base_time): Add check that the
|
||||||
|
|
|
@ -584,7 +584,6 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
|
||||||
gint64 segment_time;
|
gint64 segment_time;
|
||||||
GstClockTime duration;
|
GstClockTime duration;
|
||||||
|
|
||||||
|
|
||||||
/* the newsegment event is needed to bring the buffer timestamps to the
|
/* the newsegment event is needed to bring the buffer timestamps to the
|
||||||
* stream time and to drop samples outside of the playback segment. */
|
* stream time and to drop samples outside of the playback segment. */
|
||||||
gst_event_parse_newsegment (event, &update, &rate, &format,
|
gst_event_parse_newsegment (event, &update, &rate, &format,
|
||||||
|
@ -598,8 +597,10 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
|
||||||
GST_DEBUG_OBJECT (basesink,
|
GST_DEBUG_OBJECT (basesink,
|
||||||
"non-time newsegment with start 0, coaxing into FORMAT_TIME");
|
"non-time newsegment with start 0, coaxing into FORMAT_TIME");
|
||||||
format = GST_FORMAT_TIME;
|
format = GST_FORMAT_TIME;
|
||||||
segment_stop = -1;
|
if (segment_stop != 0)
|
||||||
segment_time = -1;
|
segment_stop = -1;
|
||||||
|
if (segment_time != 0)
|
||||||
|
segment_time = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format != GST_FORMAT_TIME) {
|
if (format != GST_FORMAT_TIME) {
|
||||||
|
|
|
@ -1054,6 +1054,14 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
GST_STREAM_LOCK (pad);
|
GST_STREAM_LOCK (pad);
|
||||||
unlock = TRUE;
|
unlock = TRUE;
|
||||||
|
/* we need new segment info after the flush. */
|
||||||
|
trans->segment_rate = 1.0;
|
||||||
|
trans->segment_start = -1;
|
||||||
|
trans->segment_stop = -1;
|
||||||
|
trans->segment_base = -1;
|
||||||
|
GST_DEBUG_OBJECT (trans, "reset accum %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (trans->segment_accum));
|
||||||
|
trans->segment_accum = 0;
|
||||||
break;
|
break;
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
GST_STREAM_LOCK (pad);
|
GST_STREAM_LOCK (pad);
|
||||||
|
@ -1067,26 +1075,69 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstFormat format;
|
GstFormat format;
|
||||||
gdouble rate;
|
gdouble rate;
|
||||||
gint64 start, stop, time;
|
gint64 start, stop, time, duration;
|
||||||
gboolean update;
|
gboolean update;
|
||||||
|
|
||||||
GST_STREAM_LOCK (pad);
|
GST_STREAM_LOCK (pad);
|
||||||
unlock = TRUE;
|
unlock = TRUE;
|
||||||
gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop,
|
gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop,
|
||||||
&time);
|
&time);
|
||||||
|
|
||||||
|
/* any other format with 0 also gives time 0, the other values are
|
||||||
|
* invalid as time though. */
|
||||||
|
if (format != GST_FORMAT_TIME) {
|
||||||
|
GST_DEBUG_OBJECT (trans,
|
||||||
|
"non-time newsegment with start 0, coaxing into FORMAT_TIME");
|
||||||
|
format = GST_FORMAT_TIME;
|
||||||
|
if (start != 0)
|
||||||
|
start = -1;
|
||||||
|
if (stop != 0)
|
||||||
|
stop = -1;
|
||||||
|
if (time != 0)
|
||||||
|
time = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if we really have a new segment or the previous one is
|
||||||
|
* closed */
|
||||||
|
if (!update) {
|
||||||
|
/* the new segment has to be aligned with the old segment.
|
||||||
|
* We first update the accumulated time of the previous
|
||||||
|
* segment. the accumulated time is used when syncing to the
|
||||||
|
* clock. A flush event sets the accumulated time back to 0
|
||||||
|
*/
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (trans->segment_stop)) {
|
||||||
|
duration = trans->segment_stop - trans->segment_start;
|
||||||
|
} else {
|
||||||
|
duration = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (start))
|
||||||
|
duration = start - trans->segment_start;
|
||||||
|
else
|
||||||
|
duration = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
trans->have_newsegment = TRUE;
|
||||||
|
|
||||||
|
trans->segment_accum += gst_gdouble_to_guint64 (
|
||||||
|
(gst_guint64_to_gdouble (duration) / ABS (trans->segment_rate)));;
|
||||||
|
trans->segment_rate = rate;
|
||||||
|
trans->segment_start = start;
|
||||||
|
trans->segment_stop = stop;
|
||||||
|
trans->segment_base = time;
|
||||||
|
|
||||||
if (format == GST_FORMAT_TIME) {
|
if (format == GST_FORMAT_TIME) {
|
||||||
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT
|
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT
|
||||||
" -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
|
" -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (time));
|
GST_TIME_ARGS (trans->segment_start),
|
||||||
trans->have_newsegment = TRUE;
|
GST_TIME_ARGS (trans->segment_start),
|
||||||
trans->segment_start = start;
|
GST_TIME_ARGS (trans->segment_base));
|
||||||
trans->segment_stop = stop;
|
|
||||||
trans->segment_base = time;
|
|
||||||
trans->segment_rate = rate;
|
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (trans,
|
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" G_GINT64_FORMAT
|
||||||
"received NEW_SEGMENT in non-time format, ignoring");
|
" -- %" G_GINT64_FORMAT ", time %" G_GINT64_FORMAT,
|
||||||
|
trans->segment_start, trans->segment_stop, trans->segment_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -78,14 +78,17 @@ struct _GstBaseTransform {
|
||||||
gint64 segment_stop;
|
gint64 segment_stop;
|
||||||
gint64 segment_base;
|
gint64 segment_base;
|
||||||
|
|
||||||
/* FIXME: When adjusting the padding, move this to a nice place in the structure */
|
union {
|
||||||
/* Set if caps on each pad are equal */
|
/* FIXME: When adjusting the padding, move this to a nice place in the structure */
|
||||||
gboolean have_same_caps;
|
/* Set if caps on each pad are equal */
|
||||||
|
struct {
|
||||||
GMutex *transform_lock;
|
gboolean have_same_caps;
|
||||||
|
GMutex *transform_lock;
|
||||||
/*< private >*/
|
gint64 segment_accum;
|
||||||
gpointer _gst_reserved[GST_PADDING - 2];
|
};
|
||||||
|
/*< private >*/
|
||||||
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -374,11 +374,15 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
||||||
GST_LOCK (identity);
|
GST_LOCK (identity);
|
||||||
if ((clock = GST_ELEMENT (identity)->clock)) {
|
if ((clock = GST_ELEMENT (identity)->clock)) {
|
||||||
GstClockReturn cret;
|
GstClockReturn cret;
|
||||||
|
GstClockTime timestamp;
|
||||||
|
|
||||||
|
timestamp = GST_BUFFER_TIMESTAMP (buf) - trans->segment_start;
|
||||||
|
timestamp += trans->segment_accum;
|
||||||
|
timestamp += GST_ELEMENT (identity)->base_time;
|
||||||
|
|
||||||
/* save id if we need to unlock */
|
/* save id if we need to unlock */
|
||||||
/* FIXME: actually unlock this somewhere in the state changes */
|
/* FIXME: actually unlock this somewhere in the state changes */
|
||||||
identity->clock_id = gst_clock_new_single_shot_id (clock,
|
identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp);
|
||||||
GST_BUFFER_TIMESTAMP (buf) + GST_ELEMENT (identity)->base_time);
|
|
||||||
GST_UNLOCK (identity);
|
GST_UNLOCK (identity);
|
||||||
|
|
||||||
cret = gst_clock_id_wait (identity->clock_id, NULL);
|
cret = gst_clock_id_wait (identity->clock_id, NULL);
|
||||||
|
|
|
@ -584,7 +584,6 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
|
||||||
gint64 segment_time;
|
gint64 segment_time;
|
||||||
GstClockTime duration;
|
GstClockTime duration;
|
||||||
|
|
||||||
|
|
||||||
/* the newsegment event is needed to bring the buffer timestamps to the
|
/* the newsegment event is needed to bring the buffer timestamps to the
|
||||||
* stream time and to drop samples outside of the playback segment. */
|
* stream time and to drop samples outside of the playback segment. */
|
||||||
gst_event_parse_newsegment (event, &update, &rate, &format,
|
gst_event_parse_newsegment (event, &update, &rate, &format,
|
||||||
|
@ -598,8 +597,10 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
|
||||||
GST_DEBUG_OBJECT (basesink,
|
GST_DEBUG_OBJECT (basesink,
|
||||||
"non-time newsegment with start 0, coaxing into FORMAT_TIME");
|
"non-time newsegment with start 0, coaxing into FORMAT_TIME");
|
||||||
format = GST_FORMAT_TIME;
|
format = GST_FORMAT_TIME;
|
||||||
segment_stop = -1;
|
if (segment_stop != 0)
|
||||||
segment_time = -1;
|
segment_stop = -1;
|
||||||
|
if (segment_time != 0)
|
||||||
|
segment_time = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format != GST_FORMAT_TIME) {
|
if (format != GST_FORMAT_TIME) {
|
||||||
|
|
|
@ -1054,6 +1054,14 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
GST_STREAM_LOCK (pad);
|
GST_STREAM_LOCK (pad);
|
||||||
unlock = TRUE;
|
unlock = TRUE;
|
||||||
|
/* we need new segment info after the flush. */
|
||||||
|
trans->segment_rate = 1.0;
|
||||||
|
trans->segment_start = -1;
|
||||||
|
trans->segment_stop = -1;
|
||||||
|
trans->segment_base = -1;
|
||||||
|
GST_DEBUG_OBJECT (trans, "reset accum %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (trans->segment_accum));
|
||||||
|
trans->segment_accum = 0;
|
||||||
break;
|
break;
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
GST_STREAM_LOCK (pad);
|
GST_STREAM_LOCK (pad);
|
||||||
|
@ -1067,26 +1075,69 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstFormat format;
|
GstFormat format;
|
||||||
gdouble rate;
|
gdouble rate;
|
||||||
gint64 start, stop, time;
|
gint64 start, stop, time, duration;
|
||||||
gboolean update;
|
gboolean update;
|
||||||
|
|
||||||
GST_STREAM_LOCK (pad);
|
GST_STREAM_LOCK (pad);
|
||||||
unlock = TRUE;
|
unlock = TRUE;
|
||||||
gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop,
|
gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop,
|
||||||
&time);
|
&time);
|
||||||
|
|
||||||
|
/* any other format with 0 also gives time 0, the other values are
|
||||||
|
* invalid as time though. */
|
||||||
|
if (format != GST_FORMAT_TIME) {
|
||||||
|
GST_DEBUG_OBJECT (trans,
|
||||||
|
"non-time newsegment with start 0, coaxing into FORMAT_TIME");
|
||||||
|
format = GST_FORMAT_TIME;
|
||||||
|
if (start != 0)
|
||||||
|
start = -1;
|
||||||
|
if (stop != 0)
|
||||||
|
stop = -1;
|
||||||
|
if (time != 0)
|
||||||
|
time = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if we really have a new segment or the previous one is
|
||||||
|
* closed */
|
||||||
|
if (!update) {
|
||||||
|
/* the new segment has to be aligned with the old segment.
|
||||||
|
* We first update the accumulated time of the previous
|
||||||
|
* segment. the accumulated time is used when syncing to the
|
||||||
|
* clock. A flush event sets the accumulated time back to 0
|
||||||
|
*/
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (trans->segment_stop)) {
|
||||||
|
duration = trans->segment_stop - trans->segment_start;
|
||||||
|
} else {
|
||||||
|
duration = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (start))
|
||||||
|
duration = start - trans->segment_start;
|
||||||
|
else
|
||||||
|
duration = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
trans->have_newsegment = TRUE;
|
||||||
|
|
||||||
|
trans->segment_accum += gst_gdouble_to_guint64 (
|
||||||
|
(gst_guint64_to_gdouble (duration) / ABS (trans->segment_rate)));;
|
||||||
|
trans->segment_rate = rate;
|
||||||
|
trans->segment_start = start;
|
||||||
|
trans->segment_stop = stop;
|
||||||
|
trans->segment_base = time;
|
||||||
|
|
||||||
if (format == GST_FORMAT_TIME) {
|
if (format == GST_FORMAT_TIME) {
|
||||||
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT
|
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT
|
||||||
" -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
|
" -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (time));
|
GST_TIME_ARGS (trans->segment_start),
|
||||||
trans->have_newsegment = TRUE;
|
GST_TIME_ARGS (trans->segment_start),
|
||||||
trans->segment_start = start;
|
GST_TIME_ARGS (trans->segment_base));
|
||||||
trans->segment_stop = stop;
|
|
||||||
trans->segment_base = time;
|
|
||||||
trans->segment_rate = rate;
|
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (trans,
|
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" G_GINT64_FORMAT
|
||||||
"received NEW_SEGMENT in non-time format, ignoring");
|
" -- %" G_GINT64_FORMAT ", time %" G_GINT64_FORMAT,
|
||||||
|
trans->segment_start, trans->segment_stop, trans->segment_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -78,14 +78,17 @@ struct _GstBaseTransform {
|
||||||
gint64 segment_stop;
|
gint64 segment_stop;
|
||||||
gint64 segment_base;
|
gint64 segment_base;
|
||||||
|
|
||||||
/* FIXME: When adjusting the padding, move this to a nice place in the structure */
|
union {
|
||||||
/* Set if caps on each pad are equal */
|
/* FIXME: When adjusting the padding, move this to a nice place in the structure */
|
||||||
gboolean have_same_caps;
|
/* Set if caps on each pad are equal */
|
||||||
|
struct {
|
||||||
GMutex *transform_lock;
|
gboolean have_same_caps;
|
||||||
|
GMutex *transform_lock;
|
||||||
/*< private >*/
|
gint64 segment_accum;
|
||||||
gpointer _gst_reserved[GST_PADDING - 2];
|
};
|
||||||
|
/*< private >*/
|
||||||
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -374,11 +374,15 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
||||||
GST_LOCK (identity);
|
GST_LOCK (identity);
|
||||||
if ((clock = GST_ELEMENT (identity)->clock)) {
|
if ((clock = GST_ELEMENT (identity)->clock)) {
|
||||||
GstClockReturn cret;
|
GstClockReturn cret;
|
||||||
|
GstClockTime timestamp;
|
||||||
|
|
||||||
|
timestamp = GST_BUFFER_TIMESTAMP (buf) - trans->segment_start;
|
||||||
|
timestamp += trans->segment_accum;
|
||||||
|
timestamp += GST_ELEMENT (identity)->base_time;
|
||||||
|
|
||||||
/* save id if we need to unlock */
|
/* save id if we need to unlock */
|
||||||
/* FIXME: actually unlock this somewhere in the state changes */
|
/* FIXME: actually unlock this somewhere in the state changes */
|
||||||
identity->clock_id = gst_clock_new_single_shot_id (clock,
|
identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp);
|
||||||
GST_BUFFER_TIMESTAMP (buf) + GST_ELEMENT (identity)->base_time);
|
|
||||||
GST_UNLOCK (identity);
|
GST_UNLOCK (identity);
|
||||||
|
|
||||||
cret = gst_clock_id_wait (identity->clock_id, NULL);
|
cret = gst_clock_id_wait (identity->clock_id, NULL);
|
||||||
|
|
Loading…
Reference in a new issue