+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>
* docs/gst/gstreamer-sections.txt:
", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start),
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,
(gint64) start, (gint64) end, NULL, NULL))
goto dropping;
basesink->flushing = FALSE;
GST_OBJECT_UNLOCK (basesink);
/* 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_event_unref (event);
goto done;
}
- /* save last times seen. */
- if (GST_CLOCK_TIME_IS_VALID (end))
- gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
- (gint64) end);
- else
- gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
- (gint64) start);
+ if (basesink->segment.format == GST_FORMAT_TIME) {
+ /* save last times seen. */
+ if (GST_CLOCK_TIME_IS_VALID (end))
+ gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
+ (gint64) end);
+ else
+ gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
+ (gint64) start);
- /* clip */
- if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME,
- (gint64) start, (gint64) end, &cstart, &cend))
- goto out_of_segment;
+ /* clip */
+ if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME,
+ (gint64) start, (gint64) end, &cstart, &cend))
+ goto out_of_segment;
+ } else {
+ /* no clipping for formats different from GST_FORMAT_TIME */
+ cstart = start;
+ cend = end;
+ }
if (!basesink->sync) {
GST_DEBUG_OBJECT (basesink, "no need to sync");
}
/* 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;
GstClockTimeDiff stream_start, stream_end;
} else {
if (gst_pad_activate_pull (peer, 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
correct state for the new thread... */
GST_DEBUG_OBJECT (basesink, "READY to PAUSED, need preroll to FALSE");
basesink->need_preroll = TRUE;
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;
ret = GST_STATE_CHANGE_ASYNC;
break;
/* queue a commit_state */
basesink->need_preroll = TRUE;
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;
/* we know it's not waiting, no need to signal */
} else {
{
GstFlowReturn ret = GST_FLOW_OK;
GstIdentity *identity = GST_IDENTITY (trans);
- GstClockTime runtimestamp;
+ GstClockTime runtimestamp = 0LL;
if (identity->check_perfect)
gst_identity_check_perfect (identity, buf);
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf);
- runtimestamp = gst_segment_to_running_time (&trans->segment,
- GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf));
+ if (trans->segment.format == GST_FORMAT_TIME)
+ 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;
GST_OBJECT_LOCK (identity);
if (identity->sleep_time && ret == GST_FLOW_OK)
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;
return ret;
if (segment->format == GST_FORMAT_UNDEFINED)
segment->format = format;
- else
+ else if (segment->accum)
g_return_val_if_fail (segment->format == format, -1);
if (position != -1)
", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start),
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,
(gint64) start, (gint64) end, NULL, NULL))
goto dropping;
basesink->flushing = FALSE;
GST_OBJECT_UNLOCK (basesink);
/* 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_event_unref (event);
goto done;
}
- /* save last times seen. */
- if (GST_CLOCK_TIME_IS_VALID (end))
- gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
- (gint64) end);
- else
- gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
- (gint64) start);
+ if (basesink->segment.format == GST_FORMAT_TIME) {
+ /* save last times seen. */
+ if (GST_CLOCK_TIME_IS_VALID (end))
+ gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
+ (gint64) end);
+ else
+ gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_TIME,
+ (gint64) start);
- /* clip */
- if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME,
- (gint64) start, (gint64) end, &cstart, &cend))
- goto out_of_segment;
+ /* clip */
+ if (!gst_segment_clip (&basesink->segment, GST_FORMAT_TIME,
+ (gint64) start, (gint64) end, &cstart, &cend))
+ goto out_of_segment;
+ } else {
+ /* no clipping for formats different from GST_FORMAT_TIME */
+ cstart = start;
+ cend = end;
+ }
if (!basesink->sync) {
GST_DEBUG_OBJECT (basesink, "no need to sync");
}
/* 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;
GstClockTimeDiff stream_start, stream_end;
} else {
if (gst_pad_activate_pull (peer, 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
correct state for the new thread... */
GST_DEBUG_OBJECT (basesink, "READY to PAUSED, need preroll to FALSE");
basesink->need_preroll = TRUE;
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;
ret = GST_STATE_CHANGE_ASYNC;
break;
/* queue a commit_state */
basesink->need_preroll = TRUE;
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;
/* we know it's not waiting, no need to signal */
} else {
{
GstFlowReturn ret = GST_FLOW_OK;
GstIdentity *identity = GST_IDENTITY (trans);
- GstClockTime runtimestamp;
+ GstClockTime runtimestamp = 0LL;
if (identity->check_perfect)
gst_identity_check_perfect (identity, buf);
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf);
- runtimestamp = gst_segment_to_running_time (&trans->segment,
- GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf));
+ if (trans->segment.format == GST_FORMAT_TIME)
+ 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;
GST_OBJECT_LOCK (identity);
if (identity->sleep_time && ret == GST_FLOW_OK)
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;
return ret;