gst/base/gstbasesink.c: Properly handle non GST_FORMAT_TIME segment

Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_change_state):
Properly handle non GST_FORMAT_TIME segment
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
Properly handle non GST_FORMAT_TIME segment
* gst/gstsegment.c:
This function is valid if the accumulator is 0 and the format
is different from the requested format.
This commit is contained in:
Edward Hervey 2005-11-29 17:13:44 +00:00
parent aeb51703b4
commit c4d1ffa5c7
6 changed files with 79 additions and 45 deletions

View file

@ -1,3 +1,15 @@
2005-11-29 Edward Hervey <edward@fluendo.com>
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_change_state):
Properly handle non GST_FORMAT_TIME segment
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
Properly handle non GST_FORMAT_TIME segment
* gst/gstsegment.c:
This function is valid if the accumulator is 0 and the format
is different from the requested format.
2005-11-29 Jan Schmidt <thaytan@mad.scientist.com> 2005-11-29 Jan Schmidt <thaytan@mad.scientist.com>
* docs/gst/gstreamer-sections.txt: * docs/gst/gstreamer-sections.txt:

View file

@ -620,7 +620,8 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start), ", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start),
GST_TIME_ARGS (end)); GST_TIME_ARGS (end));
if (GST_CLOCK_TIME_IS_VALID (start)) { if (GST_CLOCK_TIME_IS_VALID (start) &&
(basesink->segment.format == GST_FORMAT_TIME)) {
if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME, if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME,
(gint64) start, (gint64) end, NULL, NULL)) (gint64) start, (gint64) end, NULL, NULL))
goto dropping; goto dropping;
@ -827,7 +828,7 @@ gst_base_sink_event (GstPad * pad, GstEvent * event)
basesink->flushing = FALSE; basesink->flushing = FALSE;
GST_OBJECT_UNLOCK (basesink); GST_OBJECT_UNLOCK (basesink);
/* we need new segment info after the flush. */ /* we need new segment info after the flush. */
gst_segment_init (&basesink->segment, GST_FORMAT_TIME); gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
GST_DEBUG_OBJECT (basesink, "event unref %p %p", basesink, event); GST_DEBUG_OBJECT (basesink, "event unref %p %p", basesink, event);
gst_event_unref (event); gst_event_unref (event);
@ -925,18 +926,24 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
goto done; goto done;
} }
/* save last times seen. */ if (basesink->segment.format == GST_FORMAT_TIME) {
if (GST_CLOCK_TIME_IS_VALID (end)) /* save last times seen. */
gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME, if (GST_CLOCK_TIME_IS_VALID (end))
(gint64) end); gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
else (gint64) end);
gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME, else
(gint64) start); gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
(gint64) start);
/* clip */ /* clip */
if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME, if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME,
(gint64) start, (gint64) end, &cstart, &cend)) (gint64) start, (gint64) end, &cstart, &cend))
goto out_of_segment; goto out_of_segment;
} else {
/* no clipping for formats different from GST_FORMAT_TIME */
cstart = start;
cend = end;
}
if (!basesink->sync) { if (!basesink->sync) {
GST_DEBUG_OBJECT (basesink, "no need to sync"); GST_DEBUG_OBJECT (basesink, "no need to sync");
@ -944,7 +951,9 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
} }
/* now do clocking */ /* now do clocking */
if (GST_ELEMENT_CLOCK (basesink)) { if (GST_ELEMENT_CLOCK (basesink)
&& ((basesink->segment.format == GST_FORMAT_TIME)
|| (basesink->segment.accum == 0))) {
GstClockTime base_time; GstClockTime base_time;
GstClockTimeDiff stream_start, stream_end; GstClockTimeDiff stream_start, stream_end;
@ -1261,7 +1270,7 @@ gst_base_sink_activate_pull (GstPad * pad, gboolean active)
} else { } else {
if (gst_pad_activate_pull (peer, TRUE)) { if (gst_pad_activate_pull (peer, TRUE)) {
basesink->have_newsegment = TRUE; basesink->have_newsegment = TRUE;
gst_segment_init (&basesink->segment, GST_FORMAT_TIME); gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
/* set the pad mode before starting the task so that it's in the /* set the pad mode before starting the task so that it's in the
correct state for the new thread... */ correct state for the new thread... */
@ -1460,7 +1469,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
GST_DEBUG_OBJECT (basesink, "READY to PAUSED, need preroll to FALSE"); GST_DEBUG_OBJECT (basesink, "READY to PAUSED, need preroll to FALSE");
basesink->need_preroll = TRUE; basesink->need_preroll = TRUE;
GST_PAD_PREROLL_UNLOCK (basesink->sinkpad); GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
gst_segment_init (&basesink->segment, GST_FORMAT_TIME); gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
basesink->have_newsegment = FALSE; basesink->have_newsegment = FALSE;
ret = GST_STATE_CHANGE_ASYNC; ret = GST_STATE_CHANGE_ASYNC;
break; break;
@ -1490,7 +1499,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
/* queue a commit_state */ /* queue a commit_state */
basesink->need_preroll = TRUE; basesink->need_preroll = TRUE;
GST_DEBUG_OBJECT (basesink, GST_DEBUG_OBJECT (basesink,
"PAUSED to PLAYING, !eos, !have_preroll, need preroll to FALSE"); "PAUSED to PLAYING, !eos, !have_preroll, need preroll to TRUE");
ret = GST_STATE_CHANGE_ASYNC; ret = GST_STATE_CHANGE_ASYNC;
/* we know it's not waiting, no need to signal */ /* we know it's not waiting, no need to signal */
} else { } else {

View file

@ -339,7 +339,7 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
{ {
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
GstIdentity *identity = GST_IDENTITY (trans); GstIdentity *identity = GST_IDENTITY (trans);
GstClockTime runtimestamp; GstClockTime runtimestamp = 0LL;
if (identity->check_perfect) if (identity->check_perfect)
gst_identity_check_perfect (identity, buf); gst_identity_check_perfect (identity, buf);
@ -403,10 +403,11 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0, g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf); buf);
runtimestamp = gst_segment_to_running_time (&trans->segment, if (trans->segment.format == GST_FORMAT_TIME)
GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf)); runtimestamp = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf));
if (identity->sync) { if ((identity->sync) && (trans->segment.format == GST_FORMAT_TIME)) {
GstClock *clock; GstClock *clock;
GST_OBJECT_LOCK (identity); GST_OBJECT_LOCK (identity);
@ -439,7 +440,8 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
if (identity->sleep_time && ret == GST_FLOW_OK) if (identity->sleep_time && ret == GST_FLOW_OK)
g_usleep (identity->sleep_time); g_usleep (identity->sleep_time);
if (identity->single_segment && ret == GST_FLOW_OK) if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME)
&& (ret == GST_FLOW_OK))
GST_BUFFER_TIMESTAMP (buf) = runtimestamp; GST_BUFFER_TIMESTAMP (buf) = runtimestamp;
return ret; return ret;

View file

@ -404,7 +404,7 @@ gst_segment_to_running_time (GstSegment * segment, GstFormat format,
if (segment->format == GST_FORMAT_UNDEFINED) if (segment->format == GST_FORMAT_UNDEFINED)
segment->format = format; segment->format = format;
else else if (segment->accum)
g_return_val_if_fail (segment->format == format, -1); g_return_val_if_fail (segment->format == format, -1);
if (position != -1) if (position != -1)

View file

@ -620,7 +620,8 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start), ", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start),
GST_TIME_ARGS (end)); GST_TIME_ARGS (end));
if (GST_CLOCK_TIME_IS_VALID (start)) { if (GST_CLOCK_TIME_IS_VALID (start) &&
(basesink->segment.format == GST_FORMAT_TIME)) {
if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME, if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME,
(gint64) start, (gint64) end, NULL, NULL)) (gint64) start, (gint64) end, NULL, NULL))
goto dropping; goto dropping;
@ -827,7 +828,7 @@ gst_base_sink_event (GstPad * pad, GstEvent * event)
basesink->flushing = FALSE; basesink->flushing = FALSE;
GST_OBJECT_UNLOCK (basesink); GST_OBJECT_UNLOCK (basesink);
/* we need new segment info after the flush. */ /* we need new segment info after the flush. */
gst_segment_init (&basesink->segment, GST_FORMAT_TIME); gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
GST_DEBUG_OBJECT (basesink, "event unref %p %p", basesink, event); GST_DEBUG_OBJECT (basesink, "event unref %p %p", basesink, event);
gst_event_unref (event); gst_event_unref (event);
@ -925,18 +926,24 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
goto done; goto done;
} }
/* save last times seen. */ if (basesink->segment.format == GST_FORMAT_TIME) {
if (GST_CLOCK_TIME_IS_VALID (end)) /* save last times seen. */
gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME, if (GST_CLOCK_TIME_IS_VALID (end))
(gint64) end); gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
else (gint64) end);
gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME, else
(gint64) start); gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
(gint64) start);
/* clip */ /* clip */
if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME, if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME,
(gint64) start, (gint64) end, &cstart, &cend)) (gint64) start, (gint64) end, &cstart, &cend))
goto out_of_segment; goto out_of_segment;
} else {
/* no clipping for formats different from GST_FORMAT_TIME */
cstart = start;
cend = end;
}
if (!basesink->sync) { if (!basesink->sync) {
GST_DEBUG_OBJECT (basesink, "no need to sync"); GST_DEBUG_OBJECT (basesink, "no need to sync");
@ -944,7 +951,9 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
} }
/* now do clocking */ /* now do clocking */
if (GST_ELEMENT_CLOCK (basesink)) { if (GST_ELEMENT_CLOCK (basesink)
&& ((basesink->segment.format == GST_FORMAT_TIME)
|| (basesink->segment.accum == 0))) {
GstClockTime base_time; GstClockTime base_time;
GstClockTimeDiff stream_start, stream_end; GstClockTimeDiff stream_start, stream_end;
@ -1261,7 +1270,7 @@ gst_base_sink_activate_pull (GstPad * pad, gboolean active)
} else { } else {
if (gst_pad_activate_pull (peer, TRUE)) { if (gst_pad_activate_pull (peer, TRUE)) {
basesink->have_newsegment = TRUE; basesink->have_newsegment = TRUE;
gst_segment_init (&basesink->segment, GST_FORMAT_TIME); gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
/* set the pad mode before starting the task so that it's in the /* set the pad mode before starting the task so that it's in the
correct state for the new thread... */ correct state for the new thread... */
@ -1460,7 +1469,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
GST_DEBUG_OBJECT (basesink, "READY to PAUSED, need preroll to FALSE"); GST_DEBUG_OBJECT (basesink, "READY to PAUSED, need preroll to FALSE");
basesink->need_preroll = TRUE; basesink->need_preroll = TRUE;
GST_PAD_PREROLL_UNLOCK (basesink->sinkpad); GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
gst_segment_init (&basesink->segment, GST_FORMAT_TIME); gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
basesink->have_newsegment = FALSE; basesink->have_newsegment = FALSE;
ret = GST_STATE_CHANGE_ASYNC; ret = GST_STATE_CHANGE_ASYNC;
break; break;
@ -1490,7 +1499,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
/* queue a commit_state */ /* queue a commit_state */
basesink->need_preroll = TRUE; basesink->need_preroll = TRUE;
GST_DEBUG_OBJECT (basesink, GST_DEBUG_OBJECT (basesink,
"PAUSED to PLAYING, !eos, !have_preroll, need preroll to FALSE"); "PAUSED to PLAYING, !eos, !have_preroll, need preroll to TRUE");
ret = GST_STATE_CHANGE_ASYNC; ret = GST_STATE_CHANGE_ASYNC;
/* we know it's not waiting, no need to signal */ /* we know it's not waiting, no need to signal */
} else { } else {

View file

@ -339,7 +339,7 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
{ {
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
GstIdentity *identity = GST_IDENTITY (trans); GstIdentity *identity = GST_IDENTITY (trans);
GstClockTime runtimestamp; GstClockTime runtimestamp = 0LL;
if (identity->check_perfect) if (identity->check_perfect)
gst_identity_check_perfect (identity, buf); gst_identity_check_perfect (identity, buf);
@ -403,10 +403,11 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0, g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf); buf);
runtimestamp = gst_segment_to_running_time (&trans->segment, if (trans->segment.format == GST_FORMAT_TIME)
GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf)); runtimestamp = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf));
if (identity->sync) { if ((identity->sync) && (trans->segment.format == GST_FORMAT_TIME)) {
GstClock *clock; GstClock *clock;
GST_OBJECT_LOCK (identity); GST_OBJECT_LOCK (identity);
@ -439,7 +440,8 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
if (identity->sleep_time && ret == GST_FLOW_OK) if (identity->sleep_time && ret == GST_FLOW_OK)
g_usleep (identity->sleep_time); g_usleep (identity->sleep_time);
if (identity->single_segment && ret == GST_FLOW_OK) if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME)
&& (ret == GST_FLOW_OK))
GST_BUFFER_TIMESTAMP (buf) = runtimestamp; GST_BUFFER_TIMESTAMP (buf) = runtimestamp;
return ret; return ret;