From 312b4156c1248db554bbe7b3be9311f458059d62 Mon Sep 17 00:00:00 2001 From: Olivier Crete Date: Thu, 1 May 2008 18:25:54 +0000 Subject: [PATCH] [MOVED FROM GST-P-FARSIGHT] Create generic segment is none received and refuse non-time segments 20080501182554-3e2dc-ace5ca000414428d6d94478adc5927c9f91975df.gz --- gst/liveadder/liveadder.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gst/liveadder/liveadder.c b/gst/liveadder/liveadder.c index a91fe9a4bc..412cb6059a 100644 --- a/gst/liveadder/liveadder.c +++ b/gst/liveadder/liveadder.c @@ -806,6 +806,18 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer) if (!GST_BUFFER_TIMESTAMP_IS_VALID(buffer)) goto invalid_timestamp; + if (padprivate->segment.format == GST_FORMAT_UNDEFINED) + { + GST_WARNING_OBJECT (adder, "No new-segment received," + " initializing segment with time 0..-1"); + gst_segment_init (&padprivate->segment, GST_FORMAT_TIME); + gst_segment_set_newsegment (&padprivate->segment, + FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0); + } + + if (padprivate->segment.format == GST_FORMAT_TIME) + goto invalid_segment; + /* Just see if we receive invalid timestamp/durations */ if (GST_CLOCK_TIME_IS_VALID (padprivate->expected_timestamp) && !GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DISCONT) && @@ -983,6 +995,19 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer) ("Invalid timestamp received on buffer")); return GST_FLOW_ERROR; + + invalid_segment: + { + const gchar *format = gst_format_get_name (padprivate->segment.format); + GST_OBJECT_UNLOCK (adder); + gst_buffer_unref (buffer); + GST_ELEMENT_ERROR (adder, STREAM, FAILED, + ("This element only supports TIME segments, received other type"), + ("Received a segment of type %s, only support time segment", format)); + + return GST_FLOW_ERROR; + } + } /*