-base: port to new SEGMENT API

This commit is contained in:
Wim Taymans 2011-05-16 13:48:11 +02:00
parent c81b1b8019
commit 94dfe80f71
37 changed files with 372 additions and 709 deletions

View file

@ -208,25 +208,23 @@ gst_gio_base_sink_event (GstBaseSink * base_sink, GstEvent * event)
return TRUE;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
if (G_IS_OUTPUT_STREAM (sink->stream)) {
GstFormat format;
gint64 offset;
GstSegment segment;
gst_event_parse_new_segment (event, NULL, NULL, NULL, &format, &offset,
NULL, NULL);
gst_event_parse_segment (event, &segment);
if (format != GST_FORMAT_BYTES) {
GST_WARNING_OBJECT (sink, "ignored NEWSEGMENT event in %s format",
gst_format_get_name (format));
if (segment.format != GST_FORMAT_BYTES) {
GST_WARNING_OBJECT (sink, "ignored SEGMENT event in %s format",
gst_format_get_name (segment.format));
break;
}
if (GST_GIO_STREAM_IS_SEEKABLE (sink->stream)) {
ret = gst_gio_seek (sink, G_SEEKABLE (sink->stream), offset,
ret = gst_gio_seek (sink, G_SEEKABLE (sink->stream), segment.start,
sink->cancel);
if (ret == GST_FLOW_OK)
sink->position = offset;
sink->position = segment.start;
} else {
ret = GST_FLOW_NOT_SUPPORTED;
}

View file

@ -440,29 +440,29 @@ gst_gnome_vfs_sink_handle_event (GstBaseSink * basesink, GstEvent * event)
GST_DEBUG_OBJECT (sink, "processing %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:{
case GST_EVENT_SEGMENT:{
GnomeVFSResult res;
GstFormat format;
gint64 offset;
GstSegment segment;
gst_event_parse_new_segment (event, NULL, NULL, NULL, &format, &offset,
NULL, NULL);
gst_event_parse_segment (event, &segment);
if (format != GST_FORMAT_BYTES) {
if (segment.format != GST_FORMAT_BYTES) {
GST_WARNING_OBJECT (sink, "ignored NEWSEGMENT event in %s format",
gst_format_get_name (format));
gst_format_get_name (segment.format));
break;
}
GST_LOG_OBJECT (sink, "seeking to offset %" G_GINT64_FORMAT, offset);
res = gnome_vfs_seek (sink->handle, GNOME_VFS_SEEK_START, offset);
GST_LOG_OBJECT (sink, "seeking to offset %" G_GINT64_FORMAT,
segment.start);
res = gnome_vfs_seek (sink->handle, GNOME_VFS_SEEK_START, segment.start);
if (res != GNOME_VFS_OK) {
GST_ERROR_OBJECT (sink, "Failed to seek to offset %"
G_GINT64_FORMAT ": %s", offset, gnome_vfs_result_to_string (res));
G_GINT64_FORMAT ": %s", segment.start,
gnome_vfs_result_to_string (res));
ret = FALSE;
} else {
sink->current_pos = offset;
sink->current_pos = segment.start;
}
break;

View file

@ -500,22 +500,12 @@ gst_visual_sink_event (GstPad * pad, GstEvent * event)
res = gst_visual_sink_setcaps (pad, caps);
break;
}
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
GstFormat format;
gdouble rate, arate;
gint64 start, stop, time;
gboolean update;
/* the newsegment values are used to clip the input samples
* and to convert the incomming timestamps to running time so
* we can do QoS */
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
/* now configure the values */
gst_segment_set_newsegment (&visual->segment, update,
rate, arate, format, start, stop, time);
gst_event_parse_segment (event, &visual->segment);
/* and forward */
res = gst_pad_push_event (visual->srcpad, event);

View file

@ -158,7 +158,7 @@ gst_ogg_pad_init (GstOggPad * pad)
pad->start_time = GST_CLOCK_TIME_NONE;
pad->last_stop = GST_CLOCK_TIME_NONE;
pad->position = GST_CLOCK_TIME_NONE;
pad->have_type = FALSE;
pad->continued = NULL;
@ -412,7 +412,7 @@ gst_ogg_pad_reset (GstOggPad * pad)
pad->continued = NULL;
pad->last_ret = GST_FLOW_OK;
pad->last_stop = GST_CLOCK_TIME_NONE;
pad->position = GST_CLOCK_TIME_NONE;
pad->current_granule = -1;
pad->keyframe_granule = -1;
pad->is_eos = FALSE;
@ -594,7 +594,7 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
pad->discont = FALSE;
}
pad->last_stop = ogg->segment.last_stop;
pad->position = ogg->segment.position;
/* don't push the header packets when we are asked to skip them */
if (!packet->b_o_s || push_headers) {
@ -611,7 +611,7 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
/* check if valid granulepos, then we can calculate the current
* position. We know the granule for each packet but we only want to update
* the last_stop when we have a valid granulepos on the packet because else
* the position when we have a valid granulepos on the packet because else
* our time jumps around for the different streams. */
if (packet->granulepos < 0)
goto done;
@ -631,7 +631,7 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
}
/* and store as the current position */
gst_segment_set_last_stop (&ogg->segment, GST_FORMAT_TIME, current_time);
ogg->segment.position = current_time;
GST_DEBUG_OBJECT (ogg, "ogg current time %" GST_TIME_FORMAT,
GST_TIME_ARGS (current_time));
@ -865,6 +865,7 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet)
if (start_time != G_MAXUINT64) {
gint64 segment_time;
GstSegment segment;
GST_DEBUG_OBJECT (ogg, "start_time: %" GST_TIME_FORMAT,
GST_TIME_ARGS (start_time));
@ -876,9 +877,13 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet)
segment_time = chain->begin_time;
/* create the newsegment event we are going to send out */
event = gst_event_new_new_segment (FALSE, ogg->segment.rate,
ogg->segment.applied_rate,
GST_FORMAT_TIME, start_time, chain->segment_stop, segment_time);
gst_segment_init (&segment, GST_FORMAT_TIME);
segment.rate = ogg->segment.rate;
segment.applied_rate = ogg->segment.applied_rate;
segment.start = start_time;
segment.stop = chain->segment_stop;
segment.time = segment_time;
event = gst_event_new_segment (&segment);
ogg->resync = FALSE;
}
@ -886,6 +891,7 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet)
/* see if we have enough info to activate the chain, we have enough info
* when all streams have a valid start time. */
if (gst_ogg_demux_collect_chain_info (ogg, chain)) {
GstSegment segment;
GST_DEBUG_OBJECT (ogg, "segment_start: %" GST_TIME_FORMAT,
GST_TIME_ARGS (chain->segment_start));
@ -895,10 +901,13 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet)
GST_TIME_ARGS (chain->begin_time));
/* create the newsegment event we are going to send out */
event = gst_event_new_new_segment (FALSE, ogg->segment.rate,
ogg->segment.applied_rate,
GST_FORMAT_TIME, chain->segment_start, chain->segment_stop,
chain->begin_time);
gst_segment_init (&segment, GST_FORMAT_TIME);
segment.rate = ogg->segment.rate;
segment.applied_rate = ogg->segment.applied_rate;
segment.start = chain->segment_start;
segment.stop = chain->segment_stop;
segment.time = chain->begin_time;
event = gst_event_new_segment (&segment);
}
}
@ -1369,7 +1378,7 @@ gst_ogg_demux_sink_event (GstPad * pad, GstEvent * event)
res = gst_ogg_demux_send_event (ogg, event);
gst_ogg_demux_reset_streams (ogg);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
GST_DEBUG_OBJECT (ogg, "got a new segment event");
gst_event_unref (event);
res = TRUE;
@ -2046,7 +2055,7 @@ gst_ogg_demux_do_seek (GstOggDemux * ogg, GstSegment * segment,
gint i, pending, len;
gboolean first_parsed_page = TRUE;
position = segment->last_stop;
position = segment->position;
/* first find the chain to search in */
total = ogg->total_time;
@ -2200,7 +2209,7 @@ done:
if (keyframe) {
if (segment->rate > 0.0)
segment->time = keytarget;
segment->last_stop = keytarget - begintime;
segment->position = keytarget - begintime;
}
*rchain = chain;
@ -2298,29 +2307,8 @@ gst_ogg_demux_perform_seek_pull (GstOggDemux * ogg, GstEvent * event)
* forever. */
GST_PAD_STREAM_LOCK (ogg->sinkpad);
if (ogg->segment_running && !flush) {
/* create the segment event to close the current segment */
if ((chain = ogg->current_chain)) {
GstEvent *newseg;
gint64 chain_start = 0;
if (chain->segment_start != GST_CLOCK_TIME_NONE)
chain_start = chain->segment_start;
newseg = gst_event_new_new_segment (TRUE, ogg->segment.rate,
ogg->segment.applied_rate,
GST_FORMAT_TIME, ogg->segment.start + chain_start,
ogg->segment.last_stop + chain_start, ogg->segment.time);
/* set the seqnum of the running segment */
gst_event_set_seqnum (newseg, ogg->seqnum);
/* send segment on old chain, FIXME, must be sent from streaming thread. */
gst_ogg_demux_send_event (ogg, newseg);
}
}
if (event) {
gst_segment_set_seek (&ogg->segment, rate, format, flags,
gst_segment_do_seek (&ogg->segment, rate, format, flags,
cur_type, cur, stop_type, stop, &update);
}
@ -2367,7 +2355,8 @@ gst_ogg_demux_perform_seek_pull (GstOggDemux * ogg, GstEvent * event)
GstEvent *event;
gint64 stop;
gint64 start;
gint64 last_stop, begin_time;
gint64 position, begin_time;
GstSegment segment;
/* we have to send the flush to the old chain, not the new one */
if (flush) {
@ -2404,20 +2393,21 @@ gst_ogg_demux_perform_seek_pull (GstOggDemux * ogg, GstEvent * event)
stop = MIN (stop, chain->segment_stop);
}
last_stop = ogg->segment.last_stop;
position = ogg->segment.position;
if (chain->segment_start != GST_CLOCK_TIME_NONE)
last_stop += chain->segment_start;
position += chain->segment_start;
gst_segment_copy_into (&ogg->segment, &segment);
/* create the segment event we are going to send out */
if (ogg->segment.rate >= 0.0)
event = gst_event_new_new_segment (FALSE, ogg->segment.rate,
ogg->segment.applied_rate,
ogg->segment.format, last_stop, stop, ogg->segment.time);
else
event = gst_event_new_new_segment (FALSE, ogg->segment.rate,
ogg->segment.applied_rate,
ogg->segment.format, start, last_stop, ogg->segment.time);
if (ogg->segment.rate >= 0.0) {
segment.start = position;
segment.stop = stop;
} else {
segment.start = start;
segment.stop = position;
}
event = gst_event_new_segment (&segment);
gst_event_set_seqnum (event, seqnum);
if (chain != ogg->current_chain) {
@ -2437,13 +2427,12 @@ gst_ogg_demux_perform_seek_pull (GstOggDemux * ogg, GstEvent * event)
GstMessage *message;
message = gst_message_new_segment_start (GST_OBJECT (ogg),
GST_FORMAT_TIME, ogg->segment.last_stop);
GST_FORMAT_TIME, ogg->segment.position);
gst_message_set_seqnum (message, seqnum);
gst_element_post_message (GST_ELEMENT (ogg), message);
}
ogg->segment_running = TRUE;
ogg->seqnum = seqnum;
/* restart our task since it might have been stopped when we did the
* flush. */
@ -2943,7 +2932,7 @@ gst_ogg_demux_collect_info (GstOggDemux * ogg)
ogg->total_time += chain->total_time;
}
gst_segment_set_duration (&ogg->segment, GST_FORMAT_TIME, ogg->total_time);
ogg->segment.duration = ogg->total_time;
}
/* find all the chains in the ogg file, this reads the first and
@ -3066,14 +3055,17 @@ gst_ogg_demux_handle_page (GstOggDemux * ogg, ogg_page * page)
if (chain) {
GstEvent *event;
gint64 start = 0;
GstSegment segment;
if (chain->segment_start != GST_CLOCK_TIME_NONE)
start = chain->segment_start;
/* create the newsegment event we are going to send out */
event = gst_event_new_new_segment (FALSE, ogg->segment.rate,
ogg->segment.applied_rate,
GST_FORMAT_TIME, start, chain->segment_stop, chain->begin_time);
gst_segment_copy_into (&ogg->segment, &segment);
segment.start = start;
segment.stop = chain->segment_stop;
segment.time = chain->begin_time;
event = gst_event_new_segment (&segment);
gst_event_set_seqnum (event, ogg->seqnum);
GST_DEBUG_OBJECT (ogg,
@ -3094,7 +3086,7 @@ gst_ogg_demux_handle_page (GstOggDemux * ogg, ogg_page * page)
if (ogg->pullmode)
goto unknown_chain;
current_time = ogg->segment.last_stop;
current_time = ogg->segment.position;
/* time of new chain is current time */
chain_time = current_time;
@ -3351,7 +3343,7 @@ gst_ogg_demux_sync_streams (GstOggDemux * ogg)
guint i;
chain = ogg->current_chain;
cur = ogg->segment.last_stop;
cur = ogg->segment.position;
if (chain == NULL || cur == -1)
return;
@ -3361,19 +3353,24 @@ gst_ogg_demux_sync_streams (GstOggDemux * ogg)
/* Theoretically, we should be doing this for all streams, but we're only
* doing it for known-to-be-sparse streams at the moment in order not to
* break things for wrongly-muxed streams (like we used to produce once) */
if (stream->map.is_sparse && stream->last_stop != GST_CLOCK_TIME_NONE) {
if (stream->map.is_sparse && stream->position != GST_CLOCK_TIME_NONE) {
/* Does this stream lag? Random threshold of 2 seconds */
if (GST_CLOCK_DIFF (stream->last_stop, cur) > (2 * GST_SECOND)) {
if (GST_CLOCK_DIFF (stream->position, cur) > (2 * GST_SECOND)) {
GST_DEBUG_OBJECT (stream, "synchronizing stream with others by "
"advancing time from %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT,
GST_TIME_ARGS (stream->last_stop), GST_TIME_ARGS (cur));
stream->last_stop = cur;
GST_TIME_ARGS (stream->position), GST_TIME_ARGS (cur));
stream->position = cur;
#if 0
ogg->segment.base += cur - stream->position;
/* advance stream time (FIXME: is this right, esp. time_pos?) */
gst_pad_push_event (GST_PAD_CAST (stream),
gst_event_new_new_segment (TRUE, ogg->segment.rate,
ogg->segment.applied_rate,
GST_FORMAT_TIME, stream->last_stop, -1, stream->last_stop));
GST_FORMAT_TIME, stream->position, -1, stream->position));
#endif
}
}
}
@ -3451,7 +3448,6 @@ pause:
GstEvent *event = NULL;
GST_LOG_OBJECT (ogg, "pausing task, reason %s", reason);
ogg->segment_running = FALSE;
gst_pad_pause_task (ogg->sinkpad);
if (ret == GST_FLOW_UNEXPECTED) {
@ -3585,7 +3581,6 @@ gst_ogg_demux_change_state (GstElement * element, GstStateChange transition)
ogg_sync_reset (&ogg->sync);
ogg->running = FALSE;
ogg->bitrate = 0;
ogg->segment_running = FALSE;
ogg->total_time = -1;
gst_segment_init (&ogg->segment, GST_FORMAT_TIME);
break;
@ -3604,7 +3599,6 @@ gst_ogg_demux_change_state (GstElement * element, GstStateChange transition)
gst_ogg_demux_clear_chains (ogg);
GST_OBJECT_LOCK (ogg);
ogg->running = FALSE;
ogg->segment_running = FALSE;
GST_OBJECT_UNLOCK (ogg);
break;
case GST_STATE_CHANGE_READY_TO_NULL:

View file

@ -103,7 +103,7 @@ struct _GstOggPad
gint64 first_granule; /* the granulepos of first page == first sample in next page */
GstClockTime first_time; /* the timestamp of the second page or granuletime of first page */
GstClockTime last_stop; /* last_stop when last push occured; used to detect when we
GstClockTime position; /* position when last push occured; used to detect when we
* need to send a newsegment update event for sparse streams */
GList *continued;
@ -152,7 +152,6 @@ struct _GstOggDemux
/* playback start/stop positions */
GstSegment segment;
gboolean segment_running;
guint32 seqnum;
GstEvent *event;

View file

@ -281,26 +281,20 @@ gst_ogg_mux_sink_event (GstPad * pad, GstEvent * event)
GST_DEBUG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:{
gboolean update;
gdouble rate;
gdouble applied_rate;
GstFormat format;
gint64 start, stop, position;
case GST_EVENT_SEGMENT:
{
GstSegment segment;
gst_event_parse_new_segment (event, &update, &rate,
&applied_rate, &format, &start, &stop, &position);
gst_event_parse_segment (event, &segment);
/* We don't support non time NEWSEGMENT events */
if (format != GST_FORMAT_TIME) {
if (segment.format != GST_FORMAT_TIME) {
gst_event_unref (event);
event = NULL;
break;
}
gst_segment_set_newsegment (&ogg_pad->segment, update, rate,
applied_rate, format, start, stop, position);
gst_segment_copy_into (&segment, &ogg_pad->segment);
break;
}
case GST_EVENT_FLUSH_STOP:{

View file

@ -2121,21 +2121,17 @@ gst_base_text_overlay_text_event (GstPad * pad, GstEvent * event)
GST_LOG_OBJECT (pad, "received event %s", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:{
GstFormat fmt;
gboolean update;
gdouble rate, applied_rate;
gint64 cur, stop, time;
case GST_EVENT_SEGMENT:
{
GstSegment segment;
overlay->text_eos = FALSE;
gst_event_parse_new_segment (event, &update, &rate, &applied_rate,
&fmt, &cur, &stop, &time);
gst_event_parse_segment (event, &segment);
if (fmt == GST_FORMAT_TIME) {
if (segment.format == GST_FORMAT_TIME) {
GST_OBJECT_LOCK (overlay);
gst_segment_set_newsegment (&overlay->text_segment, update, rate,
applied_rate, GST_FORMAT_TIME, cur, stop, time);
gst_segment_copy_into (&segment, &overlay->text_segment);
GST_DEBUG_OBJECT (overlay, "TEXT SEGMENT now: %" GST_SEGMENT_FORMAT,
&overlay->text_segment);
GST_OBJECT_UNLOCK (overlay);
@ -2206,24 +2202,19 @@ gst_base_text_overlay_video_event (GstPad * pad, GstEvent * event)
GST_DEBUG_OBJECT (pad, "received event %s", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
GstFormat format;
gdouble rate, arate;
gint64 start, stop, time;
gboolean update;
GstSegment segment;
GST_DEBUG_OBJECT (overlay, "received new segment");
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
gst_event_parse_segment (event, &segment);
if (format == GST_FORMAT_TIME) {
if (segment.format == GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (overlay, "VIDEO SEGMENT now: %" GST_SEGMENT_FORMAT,
&overlay->segment);
gst_segment_set_newsegment (&overlay->segment, update, rate, arate,
format, start, stop, time);
gst_segment_copy_into (&segment, &overlay->segment);
} else {
GST_ELEMENT_WARNING (overlay, STREAM, MUX, (NULL),
("received non-TIME newsegment event on video input"));
@ -2292,7 +2283,7 @@ gst_base_text_overlay_text_chain (GstPad * pad, GstBuffer * buffer)
GstFlowReturn ret = GST_FLOW_OK;
GstBaseTextOverlay *overlay = NULL;
gboolean in_seg = FALSE;
gint64 clip_start = 0, clip_stop = 0;
guint64 clip_start = 0, clip_stop = 0;
overlay = GST_BASE_TEXT_OVERLAY (GST_PAD_PARENT (pad));
@ -2352,8 +2343,7 @@ gst_base_text_overlay_text_chain (GstPad * pad, GstBuffer * buffer)
}
if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
gst_segment_set_last_stop (&overlay->text_segment, GST_FORMAT_TIME,
clip_start);
overlay->text_segment.position = clip_start;
overlay->text_buffer = buffer;
/* That's a new text buffer we need to render */
@ -2377,7 +2367,7 @@ gst_base_text_overlay_video_chain (GstPad * pad, GstBuffer * buffer)
GstBaseTextOverlay *overlay;
GstFlowReturn ret = GST_FLOW_OK;
gboolean in_seg = FALSE;
gint64 start, stop, clip_start = 0, clip_stop = 0;
guint64 start, stop, clip_start = 0, clip_stop = 0;
gchar *text = NULL;
overlay = GST_BASE_TEXT_OVERLAY (GST_PAD_PARENT (pad));
@ -2457,8 +2447,8 @@ wait_for_text_buf:
GST_OBJECT_UNLOCK (overlay);
ret = gst_pad_push (overlay->srcpad, buffer);
/* Update last_stop */
gst_segment_set_last_stop (&overlay->segment, GST_FORMAT_TIME, clip_start);
/* Update position */
overlay->segment.position = clip_start;
return ret;
}
@ -2614,7 +2604,7 @@ wait_for_text_buf:
/* Text pad linked, but no text buffer available - what now? */
if (overlay->text_segment.format == GST_FORMAT_TIME) {
GstClockTime text_start_running_time, text_last_stop_running_time;
GstClockTime text_start_running_time, text_position_running_time;
GstClockTime vid_running_time;
vid_running_time =
@ -2623,14 +2613,14 @@ wait_for_text_buf:
text_start_running_time =
gst_segment_to_running_time (&overlay->text_segment,
GST_FORMAT_TIME, overlay->text_segment.start);
text_last_stop_running_time =
text_position_running_time =
gst_segment_to_running_time (&overlay->text_segment,
GST_FORMAT_TIME, overlay->text_segment.last_stop);
GST_FORMAT_TIME, overlay->text_segment.position);
if ((GST_CLOCK_TIME_IS_VALID (text_start_running_time) &&
vid_running_time < text_start_running_time) ||
(GST_CLOCK_TIME_IS_VALID (text_last_stop_running_time) &&
vid_running_time < text_last_stop_running_time)) {
(GST_CLOCK_TIME_IS_VALID (text_position_running_time) &&
vid_running_time < text_position_running_time)) {
wait_for_text_buf = FALSE;
}
}
@ -2651,8 +2641,8 @@ wait_for_text_buf:
g_free (text);
/* Update last_stop */
gst_segment_set_last_stop (&overlay->segment, GST_FORMAT_TIME, clip_start);
/* Update position */
overlay->segment.position = clip_start;
return ret;

View file

@ -630,29 +630,20 @@ theora_dec_sink_event (GstPad * pad, GstEvent * event)
case GST_EVENT_EOS:
ret = gst_pad_push_event (dec->srcpad, event);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
gboolean update;
GstFormat format;
gdouble rate, arate;
gint64 start, stop, time;
GstSegment segment;
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
gst_event_parse_segment (event, &segment);
/* we need TIME format */
if (format != GST_FORMAT_TIME)
if (segment.format != GST_FORMAT_TIME)
goto newseg_wrong_format;
GST_DEBUG_OBJECT (dec,
"newsegment: update %d, rate %g, arate %g, start %" GST_TIME_FORMAT
", stop %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
update, rate, arate, GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
GST_TIME_ARGS (time));
GST_DEBUG_OBJECT (dec, "segment: %" GST_SEGMENT_FORMAT, &segment);
/* now configure the values */
gst_segment_set_newsegment (&dec->segment, update,
rate, arate, format, start, stop, time);
gst_segment_copy_into (&segment, &dec->segment);
dec->seqnum = gst_event_get_seqnum (event);
/* We don't forward this unless/until the decoder is initialised */
@ -1044,7 +1035,7 @@ clip_buffer (GstTheoraDec * dec, GstBuffer * buf)
{
gboolean res = TRUE;
GstClockTime in_ts, in_dur, stop;
gint64 cstart, cstop;
guint64 cstart, cstop;
in_ts = GST_BUFFER_TIMESTAMP (buf);
in_dur = GST_BUFFER_DURATION (buf);

View file

@ -820,18 +820,9 @@ theora_enc_sink_event (GstPad * pad, GstEvent * event)
enc = GST_THEORA_ENC (GST_PAD_PARENT (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
gboolean update;
gdouble rate, applied_rate;
GstFormat format;
gint64 start, stop, time;
gst_event_parse_new_segment (event, &update, &rate, &applied_rate,
&format, &start, &stop, &time);
gst_segment_set_newsegment (&enc->segment, update, rate,
applied_rate, format, start, stop, time);
gst_event_parse_segment (event, &enc->segment);
res = gst_pad_push_event (enc->srcpad, event);
break;

View file

@ -489,29 +489,20 @@ vorbis_dec_sink_event (GstPad * pad, GstEvent * event)
gst_vorbis_dec_reset (dec);
ret = gst_pad_push_event (dec->srcpad, event);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
GstFormat format;
gdouble rate, arate;
gint64 start, stop, time;
gboolean update;
GstSegment segment;
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
gst_event_parse_segment (event, &segment);
/* we need time for now */
if (format != GST_FORMAT_TIME)
if (segment.format != GST_FORMAT_TIME)
goto newseg_wrong_format;
GST_DEBUG_OBJECT (dec,
"newsegment: update %d, rate %g, arate %g, start %" GST_TIME_FORMAT
", stop %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
update, rate, arate, GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
GST_TIME_ARGS (time));
GST_DEBUG_OBJECT (dec, "segment: %" GST_SEGMENT_FORMAT, &segment);
/* now configure the values */
gst_segment_set_newsegment (&dec->segment, update,
rate, arate, format, start, stop, time);
gst_segment_copy_into (&segment, &dec->segment);
dec->seqnum = gst_event_get_seqnum (event);
if (dec->initialized)

View file

@ -832,8 +832,7 @@ gst_vorbis_enc_buffer_from_packet (GstVorbisEnc * vorbisenc,
/* update the next timestamp, taking granulepos_offset and subgranule offset
* into account */
vorbisenc->next_ts =
granulepos_to_timestamp_offset (vorbisenc, packet->granulepos) +
vorbisenc->initial_ts;
granulepos_to_timestamp_offset (vorbisenc, packet->granulepos);
GST_BUFFER_DURATION (outbuf) =
vorbisenc->next_ts - GST_BUFFER_TIMESTAMP (outbuf);
@ -965,23 +964,14 @@ gst_vorbis_enc_sink_event (GstPad * pad, GstEvent * event)
}
res = gst_pad_push_event (vorbisenc->srcpad, event);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
gboolean update;
gdouble rate, applied_rate;
GstFormat format;
gint64 start, stop, position;
GstSegment segment;
gst_event_parse_new_segment (event, &update, &rate, &applied_rate,
&format, &start, &stop, &position);
if (format == GST_FORMAT_TIME) {
gst_segment_set_newsegment (&vorbisenc->segment, update, rate,
applied_rate, format, start, stop, position);
if (vorbisenc->initial_ts == GST_CLOCK_TIME_NONE) {
GST_DEBUG_OBJECT (vorbisenc, "Initial segment %" GST_SEGMENT_FORMAT,
&vorbisenc->segment);
vorbisenc->initial_ts = start;
}
gst_event_parse_segment (event, &segment);
if (segment.format == GST_FORMAT_TIME) {
gst_segment_copy_into (&segment, &vorbisenc->segment);
}
}
/* fall through */
@ -1056,10 +1046,9 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
running_time =
gst_segment_to_running_time (&vorbisenc->segment, GST_FORMAT_TIME,
GST_BUFFER_TIMESTAMP (buffer));
timestamp = running_time + vorbisenc->initial_ts;
GST_DEBUG_OBJECT (vorbisenc, "Initial ts is %" GST_TIME_FORMAT
" timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (vorbisenc->initial_ts), GST_TIME_ARGS (timestamp));
timestamp = running_time;
GST_DEBUG_OBJECT (vorbisenc, " timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
if (!vorbisenc->header_sent) {
/* Vorbis streams begin with three headers; the initial header (with
most of the codec setup parameters) which is mandated by the Ogg
@ -1118,8 +1107,7 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
(running_time, vorbisenc->frequency, GST_SECOND);
vorbisenc->subgranule_offset = 0;
vorbisenc->subgranule_offset =
(vorbisenc->next_ts - vorbisenc->initial_ts) -
granulepos_to_timestamp_offset (vorbisenc, 0);
vorbisenc->next_ts - granulepos_to_timestamp_offset (vorbisenc, 0);
vorbisenc->header_sent = TRUE;
first = TRUE;
@ -1390,7 +1378,6 @@ gst_vorbis_enc_change_state (GstElement * element, GstStateChange transition)
vorbisenc->next_discont = FALSE;
vorbisenc->header_sent = FALSE;
gst_segment_init (&vorbisenc->segment, GST_FORMAT_TIME);
vorbisenc->initial_ts = GST_CLOCK_TIME_NONE;
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;

View file

@ -81,7 +81,6 @@ struct _GstVorbisEnc {
guint64 granulepos_offset;
gint64 subgranule_offset;
GstSegment segment;
GstClockTime initial_ts;
GstTagList * tags;

View file

@ -836,7 +836,7 @@ gst_app_src_do_seek (GstBaseSrc * src, GstSegment * segment)
gint64 desired_position;
gboolean res = FALSE;
desired_position = segment->last_stop;
desired_position = segment->position;
GST_DEBUG_OBJECT (appsrc, "seeking to %" G_GINT64_FORMAT ", format %s",
desired_position, gst_format_get_name (segment->format));
@ -934,7 +934,7 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
GST_DEBUG_OBJECT (appsrc,
"Size changed from %" G_GINT64_FORMAT " to %" G_GINT64_FORMAT,
bsrc->segment.duration, priv->size);
gst_segment_set_duration (&bsrc->segment, GST_FORMAT_BYTES, priv->size);
bsrc->segment.duration = priv->size;
GST_OBJECT_UNLOCK (appsrc);
gst_element_post_message (GST_ELEMENT (appsrc),

View file

@ -351,7 +351,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
if (segment->format == GST_FORMAT_TIME) {
/* Handle clipping for GST_FORMAT_TIME */
gint64 start, stop, cstart, cstop, diff;
guint64 start, stop, cstart, cstop, diff;
start = timestamp;
stop = timestamp + duration;
@ -389,7 +389,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
}
} else {
/* Handle clipping for GST_FORMAT_DEFAULT */
gint64 start, stop, cstart, cstop, diff;
guint64 start, stop, cstart, cstop, diff;
g_return_val_if_fail (GST_BUFFER_OFFSET_IS_VALID (buffer), buffer);

View file

@ -863,17 +863,6 @@ gst_base_audio_sink_event (GstBaseSink * bsink, GstEvent * event)
/* now wait till we played everything */
gst_base_audio_sink_drain (sink);
break;
case GST_EVENT_NEWSEGMENT:
{
gdouble rate;
/* we only need the rate */
gst_event_parse_new_segment (event, NULL, &rate, NULL, NULL,
NULL, NULL, NULL);
GST_DEBUG_OBJECT (sink, "new segment rate of %f", rate);
break;
}
default:
break;
}
@ -1358,7 +1347,8 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
GstClockTimeDiff sync_offset, ts_offset;
GstBaseAudioSink *sink;
GstRingBuffer *ringbuf;
gint64 diff, align, ctime, cstop;
gint64 diff, align;
guint64 ctime, cstop;
gsize offset;
guint8 *data;
gsize size;
@ -1764,7 +1754,7 @@ gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
GST_LOG_OBJECT (basesink, "pulling %d bytes offset %" G_GUINT64_FORMAT
" to fill audio buffer", len, basesink->offset);
ret =
gst_pad_pull_range (basesink->sinkpad, basesink->segment.last_stop, len,
gst_pad_pull_range (basesink->sinkpad, basesink->segment.position, len,
&buf);
if (ret != GST_FLOW_OK) {
@ -1791,7 +1781,7 @@ gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
len = MIN (size, len);
}
basesink->segment.last_stop += len;
basesink->segment.position += len;
gst_buffer_extract (buf, 0, data, len);
GST_BASE_SINK_PREROLL_UNLOCK (basesink);

View file

@ -1087,12 +1087,10 @@ gst_cdda_base_src_update_duration (GstCddaBaseSrc * src)
basesrc = GST_BASE_SRC (src);
format = GST_FORMAT_TIME;
if (gst_pad_query_duration (GST_BASE_SRC_PAD (src), &format, &duration)) {
gst_segment_set_duration (&basesrc->segment, GST_FORMAT_TIME, duration);
} else {
gst_segment_set_duration (&basesrc->segment, GST_FORMAT_TIME, -1);
if (!gst_pad_query_duration (GST_BASE_SRC_PAD (src), &format, &duration)) {
duration = GST_CLOCK_TIME_NONE;
}
basesrc->segment.duration = duration;
gst_element_post_message (GST_ELEMENT (src),
gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_TIME, -1));

View file

@ -31,15 +31,6 @@
#include "gstbasertpdepayload.h"
#ifdef GST_DISABLE_DEPRECATED
#define QUEUE_LOCK_INIT(base) (g_static_rec_mutex_init(&base->queuelock))
#define QUEUE_LOCK_FREE(base) (g_static_rec_mutex_free(&base->queuelock))
#define QUEUE_LOCK(base) (g_static_rec_mutex_lock(&base->queuelock))
#define QUEUE_UNLOCK(base) (g_static_rec_mutex_unlock(&base->queuelock))
#else
/* otherwise it's already been defined in the header (FIXME 0.11)*/
#endif
GST_DEBUG_CATEGORY_STATIC (basertpdepayload_debug);
#define GST_CAT_DEFAULT (basertpdepayload_debug)
@ -69,12 +60,9 @@ enum
LAST_SIGNAL
};
#define DEFAULT_QUEUE_DELAY 0
enum
{
PROP_0,
PROP_QUEUE_DELAY,
PROP_LAST
};
@ -131,7 +119,6 @@ gst_base_rtp_depayload_get_type (void)
return base_rtp_depayload_type;
}
static void
gst_base_rtp_depayload_class_init (GstBaseRTPDepayloadClass * klass)
{
@ -148,21 +135,6 @@ gst_base_rtp_depayload_class_init (GstBaseRTPDepayloadClass * klass)
gobject_class->set_property = gst_base_rtp_depayload_set_property;
gobject_class->get_property = gst_base_rtp_depayload_get_property;
/**
* GstBaseRTPDepayload::queue-delay
*
* Control the amount of packets to buffer.
*
* Deprecated: Use a jitterbuffer or RTP session manager to delay packet
* playback. This property has no effect anymore since 0.10.15.
*/
#ifndef GST_REMOVE_DEPRECATED
g_object_class_install_property (gobject_class, PROP_QUEUE_DELAY,
g_param_spec_uint ("queue-delay", "Queue Delay",
"Amount of ms to queue/buffer, deprecated", 0, G_MAXUINT,
DEFAULT_QUEUE_DELAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#endif
gstelement_class->change_state = gst_base_rtp_depayload_change_state;
klass->set_gst_timestamp = gst_base_rtp_depayload_set_gst_timestamp;
@ -203,19 +175,12 @@ gst_base_rtp_depayload_init (GstBaseRTPDepayload * filter,
gst_pad_use_fixed_caps (filter->srcpad);
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
filter->queue = g_queue_new ();
filter->queue_delay = DEFAULT_QUEUE_DELAY;
gst_segment_init (&filter->segment, GST_FORMAT_UNDEFINED);
}
static void
gst_base_rtp_depayload_finalize (GObject * object)
{
GstBaseRTPDepayload *filter = GST_BASE_RTP_DEPAYLOAD (object);
g_queue_free (filter->queue);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -440,19 +405,9 @@ gst_base_rtp_depayload_handle_event (GstBaseRTPDepayload * filter,
filter->need_newsegment = TRUE;
filter->priv->next_seqnum = -1;
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
gboolean update;
gdouble rate, arate;
GstFormat fmt;
gint64 start, stop, position;
gst_event_parse_new_segment (event, &update, &rate, &arate, &fmt, &start,
&stop, &position);
gst_segment_set_newsegment (&filter->segment, update, rate, arate, fmt,
start, stop, position);
gst_event_parse_segment (event, &filter->segment);
/* don't pass the event downstream, we generate our own segment including
* the NTP time and other things we receive in caps */
forward = FALSE;
@ -523,6 +478,7 @@ create_segment_event (GstBaseRTPDepayload * filter, gboolean update,
GstEvent *event;
GstClockTime stop;
GstBaseRTPDepayloadPrivate *priv;
GstSegment segment;
priv = filter->priv;
@ -531,9 +487,15 @@ create_segment_event (GstBaseRTPDepayload * filter, gboolean update,
else
stop = -1;
event = gst_event_new_new_segment (update, priv->play_speed,
priv->play_scale, GST_FORMAT_TIME, position, stop,
position + priv->npt_start);
gst_segment_init (&segment, GST_FORMAT_TIME);
segment.rate = priv->play_speed;
segment.applied_rate = priv->play_scale;
segment.start = 0;
segment.stop = stop;
segment.time = priv->npt_start;
segment.position = position;
event = gst_event_new_segment (&segment);
return event;
}
@ -794,9 +756,6 @@ gst_base_rtp_depayload_set_property (GObject * object, guint prop_id,
filter = GST_BASE_RTP_DEPAYLOAD (object);
switch (prop_id) {
case PROP_QUEUE_DELAY:
filter->queue_delay = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -812,9 +771,6 @@ gst_base_rtp_depayload_get_property (GObject * object, guint prop_id,
filter = GST_BASE_RTP_DEPAYLOAD (object);
switch (prop_id) {
case PROP_QUEUE_DELAY:
g_value_set_uint (value, filter->queue_delay);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

View file

@ -40,15 +40,6 @@ G_BEGIN_DECLS
#define GST_BASE_RTP_DEPAYLOAD_SINKPAD(depayload) (GST_BASE_RTP_DEPAYLOAD (depayload)->sinkpad)
#define GST_BASE_RTP_DEPAYLOAD_SRCPAD(depayload) (GST_BASE_RTP_DEPAYLOAD (depayload)->srcpad)
#ifndef GST_DISABLE_DEPRECATED
/* this was presumably never meant to be public API, or should at least
* have been prefixed if it was. Don't use. (FIXME: remove in 0.11) */
#define QUEUE_LOCK_INIT(base) (g_static_rec_mutex_init(&base->queuelock))
#define QUEUE_LOCK_FREE(base) (g_static_rec_mutex_free(&base->queuelock))
#define QUEUE_LOCK(base) (g_static_rec_mutex_lock(&base->queuelock))
#define QUEUE_UNLOCK(base) (g_static_rec_mutex_unlock(&base->queuelock))
#endif
typedef struct _GstBaseRTPDepayload GstBaseRTPDepayload;
typedef struct _GstBaseRTPDepayloadClass GstBaseRTPDepayloadClass;
typedef struct _GstBaseRTPDepayloadPrivate GstBaseRTPDepayloadPrivate;
@ -59,30 +50,9 @@ struct _GstBaseRTPDepayload
GstPad *sinkpad, *srcpad;
#ifndef GST_REMOVE_DEPRECATED
/* lock to protect the queue, deprecated */
GStaticRecMutex queuelock;
/* deprecated */
gboolean thread_running;
/* the releaser thread, deprecated */
GThread *thread;
#endif
/* this attribute must be set by the child */
guint clock_rate;
#ifndef GST_REMOVE_DEPRECATED
/* this value can be modified by the child if needed, deprecated */
guint queue_delay;
#endif
/* we will queue up to RTP_QUEUEDELAY ms of packets,
* reordering them if necessary
* dropping any packets that are more than
* RTP_QUEUEDELAY ms late, deprecated */
GQueue *queue;
GstSegment segment;
gboolean need_newsegment;
@ -99,10 +69,6 @@ struct _GstBaseRTPDepayloadClass
/* virtuals, inform the subclass of the caps. */
gboolean (*set_caps) (GstBaseRTPDepayload *filter, GstCaps *caps);
/* non-pure function, default implementation in base class
* this does buffering, reordering and dropping, deprecated */
GstFlowReturn (*add_to_queue) (GstBaseRTPDepayload *filter, GstBuffer *in);
/* pure virtual function, child must use this to process incoming
* rtp packets. If the child returns a buffer without a valid timestamp,
* the timestamp of @in will be applied to the result buffer and the

View file

@ -403,28 +403,15 @@ gst_basertppayload_event (GstPad * pad, GstEvent * event)
res = gst_pad_event_default (pad, event);
gst_segment_init (&basertppayload->segment, GST_FORMAT_UNDEFINED);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
gboolean update;
gdouble rate, arate;
GstFormat fmt;
gint64 start, stop, position;
GstSegment *segment;
segment = &basertppayload->segment;
gst_event_parse_new_segment (event, &update, &rate, &arate, &fmt,
&start, &stop, &position);
gst_segment_set_newsegment (segment, update, rate, arate, fmt, start,
stop, position);
gst_event_parse_segment (event, segment);
GST_DEBUG_OBJECT (basertppayload,
"configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
"format %d, "
"%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
G_GINT64_FORMAT ", accum %" G_GINT64_FORMAT, update, rate, arate,
segment->format, segment->start, segment->stop, segment->time,
segment->accum);
"configured SEGMENT %" GST_SEGMENT_FORMAT, segment);
/* fallthrough */
}
default:

View file

@ -111,7 +111,6 @@ struct _GstTagDemuxPrivate
GstSegment segment;
gboolean need_newseg;
gboolean newseg_update;
GList *pending_events;
};
@ -271,7 +270,6 @@ gst_tag_demux_reset (GstTagDemux * tagdemux)
gst_segment_init (&tagdemux->priv->segment, GST_FORMAT_UNDEFINED);
tagdemux->priv->need_newseg = TRUE;
tagdemux->priv->newseg_update = FALSE;
g_list_foreach (tagdemux->priv->pending_events,
(GFunc) gst_mini_object_unref, NULL);
@ -587,16 +585,16 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf)
size = gst_buffer_get_size (buf);
/* Update our segment last_stop info */
/* Update our segment position info */
if (demux->priv->segment.format == GST_FORMAT_BYTES) {
if (GST_BUFFER_OFFSET_IS_VALID (buf))
demux->priv->segment.last_stop = GST_BUFFER_OFFSET (buf);
demux->priv->segment.last_stop += size;
demux->priv->segment.position = GST_BUFFER_OFFSET (buf);
demux->priv->segment.position += size;
} else if (demux->priv->segment.format == GST_FORMAT_TIME) {
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf))
demux->priv->segment.last_stop = GST_BUFFER_TIMESTAMP (buf);
demux->priv->segment.position = GST_BUFFER_TIMESTAMP (buf);
if (GST_BUFFER_DURATION_IS_VALID (buf))
demux->priv->segment.last_stop += GST_BUFFER_DURATION (buf);
demux->priv->segment.position += GST_BUFFER_DURATION (buf);
}
if (demux->priv->collect == NULL) {
@ -738,18 +736,10 @@ gst_tag_demux_sink_event (GstPad * pad, GstEvent * event)
}
ret = gst_pad_event_default (pad, event);
break;
case GST_EVENT_NEWSEGMENT:{
gboolean update;
gdouble rate, arate;
GstFormat format;
gint64 start, stop, position;
case GST_EVENT_SEGMENT:
{
gst_event_parse_segment (event, &demux->priv->segment);
gst_event_parse_new_segment (event, &update, &rate, &arate,
&format, &start, &stop, &position);
gst_segment_set_newsegment (&demux->priv->segment, update, rate,
arate, format, start, stop, position);
demux->priv->newseg_update = update;
demux->priv->need_newseg = TRUE;
gst_event_unref (event);
ret = TRUE;
@ -1481,20 +1471,19 @@ gst_tag_demux_send_new_segment (GstTagDemux * tagdemux)
GstEvent *event;
gint64 start, stop, position;
GstSegment *seg = &tagdemux->priv->segment;
GstSegment newseg;
if (seg->format == GST_FORMAT_UNDEFINED) {
GST_LOG_OBJECT (tagdemux,
"No new segment received before first buffer. Using default");
gst_segment_set_newsegment (seg, FALSE, 1.0, 1.0,
GST_FORMAT_BYTES, tagdemux->priv->strip_start, -1,
tagdemux->priv->strip_start);
gst_segment_init (seg, GST_FORMAT_BYTES);
seg->start = tagdemux->priv->strip_start;
seg->time = tagdemux->priv->strip_start;
}
/* Can't adjust segments in non-BYTES formats */
if (tagdemux->priv->segment.format != GST_FORMAT_BYTES) {
event = gst_event_new_new_segment (tagdemux->priv->newseg_update,
seg->rate, seg->applied_rate, seg->format, seg->start,
seg->stop, seg->time);
event = gst_event_new_segment (seg);
return gst_pad_push_event (tagdemux->priv->srcpad, event);
}
@ -1544,13 +1533,13 @@ gst_tag_demux_send_new_segment (GstTagDemux * tagdemux)
}
}
GST_DEBUG_OBJECT (tagdemux,
"Sending new segment update %d, rate %g, format %d, "
"start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT ", position %"
G_GINT64_FORMAT, tagdemux->priv->newseg_update, seg->rate, seg->format,
start, stop, position);
GST_DEBUG_OBJECT (tagdemux, "Sending segment %" GST_SEGMENT_FORMAT, seg);
gst_segment_copy_into (seg, &newseg);
newseg.start = start;
newseg.stop = stop;
newseg.position = position;
event = gst_event_new_segment (&newseg);
event = gst_event_new_new_segment (tagdemux->priv->newseg_update,
seg->rate, seg->applied_rate, seg->format, start, stop, position);
return gst_pad_push_event (tagdemux->priv->srcpad, event);
}

View file

@ -541,7 +541,7 @@ gst_adder_query (GstPad * pad, GstQuery ** query)
switch (format) {
case GST_FORMAT_TIME:
/* FIXME, bring to stream time, might be tricky */
gst_query_set_position (*query, format, adder->timestamp);
gst_query_set_position (*query, format, adder->segment.position);
res = TRUE;
break;
case GST_FORMAT_DEFAULT:
@ -665,12 +665,13 @@ gst_adder_src_event (GstPad * pad, GstEvent * event)
case GST_EVENT_SEEK:
{
GstSeekFlags flags;
gdouble rate;
GstSeekType curtype, endtype;
gint64 cur, end;
gboolean flush;
/* parse the seek parameters */
gst_event_parse_seek (event, &adder->segment_rate, NULL, &flags, &curtype,
gst_event_parse_seek (event, &rate, NULL, &flags, &curtype,
&cur, &endtype, &end);
if ((curtype != GST_SEEK_TYPE_NONE) && (curtype != GST_SEEK_TYPE_SET)) {
@ -711,14 +712,15 @@ gst_adder_src_event (GstPad * pad, GstEvent * event)
* segment. After we have the lock, no collect function is running and no
* new collect function will be called for as long as we're flushing. */
GST_OBJECT_LOCK (adder->collect);
adder->segment.rate = rate;
if (curtype == GST_SEEK_TYPE_SET)
adder->segment_start = cur;
adder->segment.start = cur;
else
adder->segment_start = 0;
adder->segment.start = 0;
if (endtype == GST_SEEK_TYPE_SET)
adder->segment_end = end;
adder->segment.stop = end;
else
adder->segment_end = GST_CLOCK_TIME_NONE;
adder->segment.stop = GST_CLOCK_TIME_NONE;
/* make sure we push a new segment, to inform about new basetime
* see FIXME in gst_adder_collected() */
adder->segment_pending = TRUE;
@ -1179,20 +1181,19 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
* event. We also adjust offset & timestamp acordingly.
* This basically ignores all newsegments sent by upstream.
*/
event = gst_event_new_new_segment (FALSE, adder->segment_rate,
1.0, GST_FORMAT_TIME, adder->segment_start, adder->segment_end,
adder->segment_start);
if (adder->segment_rate > 0.0) {
adder->timestamp = adder->segment_start;
event = gst_event_new_segment (&adder->segment);
if (adder->segment.rate > 0.0) {
adder->segment.position = adder->segment.start;
} else {
adder->timestamp = adder->segment_end;
adder->segment.position = adder->segment.stop;
}
adder->offset = gst_util_uint64_scale (adder->timestamp,
adder->offset = gst_util_uint64_scale (adder->segment.position,
adder->rate, GST_SECOND);
GST_INFO_OBJECT (adder, "seg_start %" G_GUINT64_FORMAT ", seg_end %"
G_GUINT64_FORMAT, adder->segment_start, adder->segment_end);
G_GUINT64_FORMAT, adder->segment.start, adder->segment.stop);
GST_INFO_OBJECT (adder, "timestamp %" G_GINT64_FORMAT ",new offset %"
G_GINT64_FORMAT, adder->timestamp, adder->offset);
G_GINT64_FORMAT, adder->segment.position, adder->offset);
if (event) {
if (!gst_pad_push_event (adder->srcpad, event)) {
@ -1203,7 +1204,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
} else {
GST_WARNING_OBJECT (adder->srcpad, "Creating new segment event for "
"start:%" G_GINT64_FORMAT " end:%" G_GINT64_FORMAT " failed",
adder->segment_start, adder->segment_end);
adder->segment.start, adder->segment.stop);
}
}
@ -1222,7 +1223,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
/* for the next timestamp, use the sample counter, which will
* never accumulate rounding errors */
if (adder->segment_rate > 0.0) {
if (adder->segment.rate > 0.0) {
next_offset = adder->offset + outsize / adder->bps;
} else {
next_offset = adder->offset - outsize / adder->bps;
@ -1231,20 +1232,20 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
/* set timestamps on the output buffer */
if (adder->segment_rate > 0.0) {
GST_BUFFER_TIMESTAMP (outbuf) = adder->timestamp;
if (adder->segment.rate > 0.0) {
GST_BUFFER_TIMESTAMP (outbuf) = adder->segment.position;
GST_BUFFER_OFFSET (outbuf) = adder->offset;
GST_BUFFER_OFFSET_END (outbuf) = next_offset;
GST_BUFFER_DURATION (outbuf) = next_timestamp - adder->timestamp;
GST_BUFFER_DURATION (outbuf) = next_timestamp - adder->segment.position;
} else {
GST_BUFFER_TIMESTAMP (outbuf) = next_timestamp;
GST_BUFFER_OFFSET (outbuf) = next_offset;
GST_BUFFER_OFFSET_END (outbuf) = adder->offset;
GST_BUFFER_DURATION (outbuf) = adder->timestamp - next_timestamp;
GST_BUFFER_DURATION (outbuf) = adder->segment.position - next_timestamp;
}
adder->offset = next_offset;
adder->timestamp = next_timestamp;
adder->segment.position = next_timestamp;
/* send it out */
GST_LOG_OBJECT (adder, "pushing outbuf %p, timestamp %" GST_TIME_FORMAT
@ -1284,14 +1285,11 @@ gst_adder_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
adder->timestamp = 0;
adder->segment.position = 0;
adder->offset = 0;
adder->flush_stop_pending = FALSE;
adder->segment_pending = TRUE;
adder->segment_start = 0;
adder->segment_end = GST_CLOCK_TIME_NONE;
adder->segment_rate = 1.0;
gst_segment_init (&adder->segment, GST_FORMAT_UNDEFINED);
gst_segment_init (&adder->segment, GST_FORMAT_TIME);
gst_collect_pads_start (adder->collect);
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:

View file

@ -79,15 +79,12 @@ struct _GstAdder {
GstAdderFunction func;
/* counters to keep track of timestamps */
gint64 timestamp;
gint64 offset;
/* sink event handling */
GstPadEventFunction collect_event;
GstSegment segment;
gboolean segment_pending;
guint64 segment_start, segment_end;
gdouble segment_rate;
/* src event handling */
gboolean flush_stop_pending;

View file

@ -314,41 +314,35 @@ gst_audio_rate_sink_event (GstPad * pad, GstEvent * event)
gst_audio_rate_reset (audiorate);
res = gst_pad_push_event (audiorate->srcpad, event);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
GstFormat format;
gdouble rate, arate;
gint64 start, stop, time;
gboolean update;
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
gst_event_parse_segment (event, &audiorate->sink_segment);
GST_DEBUG_OBJECT (audiorate, "handle NEWSEGMENT");
#if 0
/* FIXME: bad things will likely happen if rate < 0 ... */
if (!update) {
/* a new segment starts. We need to figure out what will be the next
* sample offset. We mark the offsets as invalid so that the _chain
* function will perform this calculation. */
gst_audio_rate_fill_to_time (audiorate, audiorate->src_segment.stop);
#endif
audiorate->next_offset = -1;
audiorate->next_ts = -1;
#if 0
} else {
gst_audio_rate_fill_to_time (audiorate, audiorate->src_segment.start);
}
/* we accept all formats */
gst_segment_set_newsegment (&audiorate->sink_segment, update, rate,
arate, format, start, stop, time);
#endif
GST_DEBUG_OBJECT (audiorate, "updated segment: %" GST_SEGMENT_FORMAT,
&audiorate->sink_segment);
if (format == GST_FORMAT_TIME) {
if (audiorate->sink_segment.format == GST_FORMAT_TIME) {
/* TIME formats can be copied to src and forwarded */
res = gst_pad_push_event (audiorate->srcpad, event);
memcpy (&audiorate->src_segment, &audiorate->sink_segment,
sizeof (GstSegment));
gst_segment_copy_into (&audiorate->sink_segment,
&audiorate->src_segment);
} else {
/* other formats will be handled in the _chain function */
gst_event_unref (event);
@ -393,7 +387,7 @@ gst_audio_rate_src_event (GstPad * pad, GstEvent * event)
static gboolean
gst_audio_rate_convert (GstAudioRate * audiorate,
GstFormat src_fmt, gint64 src_val, GstFormat dest_fmt, gint64 * dest_val)
GstFormat src_fmt, guint64 src_val, GstFormat dest_fmt, guint64 * dest_val)
{
if (src_fmt == dest_fmt) {
*dest_val = src_val;
@ -466,8 +460,8 @@ gst_audio_rate_convert_segments (GstAudioRate * audiorate)
CONVERT_VAL (start);
CONVERT_VAL (stop);
CONVERT_VAL (time);
CONVERT_VAL (accum);
CONVERT_VAL (last_stop);
CONVERT_VAL (base);
CONVERT_VAL (position);
#undef CONVERT_VAL
return TRUE;
@ -717,8 +711,8 @@ send:
}
/* set last_stop on segment */
gst_segment_set_last_stop (&audiorate->src_segment, GST_FORMAT_TIME,
GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf));
audiorate->src_segment.position =
GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf);
ret = gst_pad_push (audiorate->srcpad, buf);
buf = NULL;

View file

@ -926,7 +926,7 @@ gst_audio_resample_event (GstBaseTransform * base, GstEvent * event)
resample->samples_out = 0;
resample->need_discont = TRUE;
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
if (resample->state) {
guint latency = resample->funcs->get_input_latency (resample->state);
gst_audio_resample_push_drain (resample, latency);

View file

@ -961,7 +961,7 @@ gst_audio_test_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment)
GST_DEBUG_OBJECT (src, "seeking %" GST_SEGMENT_FORMAT, segment);
time = segment->last_stop;
time = segment->position;
src->reverse = (segment->rate < 0.0);
/* now move to the time indicated */

View file

@ -242,7 +242,7 @@ gst_smart_encoder_reencode_gop (GstSmartEncoder * smart_encoder)
static GstFlowReturn
gst_smart_encoder_push_pending_gop (GstSmartEncoder * smart_encoder)
{
gint64 cstart, cstop;
guint64 cstart, cstop;
GList *tmp;
GstFlowReturn res = GST_FLOW_OK;
@ -350,28 +350,16 @@ smart_encoder_sink_event (GstPad * pad, GstEvent * event)
case GST_EVENT_FLUSH_STOP:
smart_encoder_reset (smart_encoder);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
GstFormat format;
gdouble rate, arate;
gint64 start, stop, time;
gboolean update;
gst_event_parse_segment (event, smart_encoder->segment);
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
GST_DEBUG_OBJECT (smart_encoder,
"newsegment: update %d, rate %g, arate %g, start %" GST_TIME_FORMAT
", stop %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
update, rate, arate, GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
GST_TIME_ARGS (time));
if (format != GST_FORMAT_TIME)
GST_DEBUG_OBJECT (smart_encoder, "segment: %" GST_SEGMENT_FORMAT,
smart_encoder->segment);
if (smart_encoder->segment->format != GST_FORMAT_TIME)
GST_ERROR
("smart_encoder can not handle streams not specified in GST_FORMAT_TIME");
/* now configure the values */
gst_segment_set_newsegment (smart_encoder->segment, update,
rate, arate, format, start, stop, time);
/* And keep a copy for further usage */
if (smart_encoder->newsegment)
gst_event_unref (smart_encoder->newsegment);

View file

@ -163,7 +163,7 @@ gst_gdp_depay_sink_event (GstPad * pad, GstEvent * event)
/* after EOS, we don't expect to output anything anymore */
res = gst_pad_push_event (this->srcpad, event);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
case GST_EVENT_TAG:
case GST_EVENT_BUFFERSIZE:
default:

View file

@ -455,8 +455,12 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
/* if these are our first ever buffers, send out new_segment first */
if (!this->sent_streamheader) {
GstEvent *event =
gst_event_new_new_segment (TRUE, 1.0, 1.0, GST_FORMAT_BYTES, 0, -1, 0);
GstEvent *event;
GstSegment segment;
gst_segment_init (&segment, GST_FORMAT_BYTES);
event = gst_event_new_segment (&segment);
GST_DEBUG_OBJECT (this, "Sending out new_segment event %p", event);
if (!gst_pad_push_event (this->srcpad, event)) {
GST_WARNING_OBJECT (this, "pushing new segment failed");
@ -561,11 +565,12 @@ gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer)
* fake one in that case */
if (!this->new_segment_buf) {
GstEvent *event;
GstSegment segment;
GST_WARNING_OBJECT (this,
"did not receive new-segment before first buffer");
event =
gst_event_new_new_segment (TRUE, 1.0, 1.0, GST_FORMAT_BYTES, 0, -1, 0);
gst_segment_init (&segment, GST_FORMAT_BYTES);
event = gst_event_new_segment (&segment);
outbuffer = gst_gdp_buffer_from_event (this, event);
gst_event_unref (event);
@ -689,7 +694,7 @@ gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event)
/* if we got a new segment or tag event, we should put it on our streamheader,
* and not send it on */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
GST_DEBUG_OBJECT (this, "Storing in caps buffer %p as new_segment_buf",
outbuffer);

View file

@ -2379,7 +2379,7 @@ stream_changed_data_probe (GstPad * pad, GstMiniObject * object, gpointer data)
}
if (GST_IS_EVENT (object)
&& GST_EVENT_TYPE (GST_EVENT_CAST (object)) == GST_EVENT_NEWSEGMENT) {
&& GST_EVENT_TYPE (GST_EVENT_CAST (object)) == GST_EVENT_SEGMENT) {
/* push the event first, then send the delayed one */
gst_event_ref (GST_EVENT_CAST (object));
gst_pad_send_event (pad, GST_EVENT_CAST (object));

View file

@ -237,24 +237,12 @@ gst_selector_pad_event (GstPad * pad, GstEvent * event)
case GST_EVENT_FLUSH_STOP:
gst_selector_pad_reset (selpad);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
gboolean update;
GstFormat format;
gdouble rate, arate;
gint64 start, stop, time;
gst_event_parse_segment (event, &selpad->segment);
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
GST_DEBUG_OBJECT (selpad,
"configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
"format %d, "
"%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
G_GINT64_FORMAT, update, rate, arate, format, start, stop, time);
gst_segment_set_newsegment (&selpad->segment, update,
rate, arate, format, start, stop, time);
GST_DEBUG_OBJECT (selpad, "configured SEGMENT %" GST_SEGMENT_FORMAT,
&selpad->segment);
/* if we are not going to forward the segment, mark the segment as
* pending */
if (!forward)
@ -330,7 +318,7 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
GST_DEBUG_OBJECT (sel, "received timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
gst_segment_set_last_stop (seg, seg->format, timestamp);
seg->position = timestamp;
}
/* Ignore buffers from pads except the selected one */
@ -339,10 +327,7 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
/* if we have a pending segment, push it out now */
if (selpad->segment_pending) {
gst_pad_push_event (sel->srcpad, gst_event_new_new_segment (FALSE,
seg->rate, seg->applied_rate, seg->format, seg->start, seg->stop,
seg->time));
gst_pad_push_event (sel->srcpad, gst_event_new_segment (seg));
selpad->segment_pending = FALSE;
}

View file

@ -311,29 +311,29 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstEvent * event)
break;
}
if (all_wait) {
gint64 last_stop = 0;
gint64 position = 0;
GST_DEBUG_OBJECT (self, "All streams have changed -- unblocking");
for (l = self->streams; l; l = l->next) {
GstStream *ostream = l->data;
gint64 stop_running_time;
gint64 last_stop_running_time;
gint64 position_running_time;
ostream->wait = FALSE;
stop_running_time =
gst_segment_to_running_time (&ostream->segment,
GST_FORMAT_TIME, ostream->segment.stop);
last_stop_running_time =
position_running_time =
gst_segment_to_running_time (&ostream->segment,
GST_FORMAT_TIME, ostream->segment.last_stop);
last_stop =
MAX (last_stop, MAX (stop_running_time,
last_stop_running_time));
GST_FORMAT_TIME, ostream->segment.position);
position =
MAX (position, MAX (stop_running_time,
position_running_time));
}
last_stop = MAX (0, last_stop);
self->group_start_time = MAX (self->group_start_time, last_stop);
position = MAX (0, position);
self->group_start_time = MAX (self->group_start_time, position);
GST_DEBUG_OBJECT (self, "New group start time: %" GST_TIME_FORMAT,
GST_TIME_ARGS (self->group_start_time));
@ -346,15 +346,11 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstEvent * event)
gst_message_unref (message);
break;
}
case GST_EVENT_NEWSEGMENT:{
case GST_EVENT_SEGMENT:{
GstStream *stream;
gboolean update;
gdouble rate, applied_rate;
GstFormat format;
gint64 start, stop, position;
GstSegment segment;
gst_event_parse_new_segment (event,
&update, &rate, &applied_rate, &format, &start, &stop, &position);
gst_event_parse_segment (event, &segment);
GST_STREAM_SYNCHRONIZER_LOCK (self);
stream = gst_pad_get_element_private (pad);
@ -374,41 +370,35 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstEvent * event)
goto done;
}
if (stream && format == GST_FORMAT_TIME) {
if (stream && segment.format == GST_FORMAT_TIME) {
if (stream->new_stream) {
gint64 last_stop_running_time = 0;
gint64 position_running_time = 0;
gint64 stop_running_time = 0;
if (stream->segment.format == GST_FORMAT_TIME) {
last_stop_running_time =
position_running_time =
gst_segment_to_running_time (&stream->segment, GST_FORMAT_TIME,
stream->segment.last_stop);
last_stop_running_time = MAX (last_stop_running_time, 0);
stream->segment.position);
position_running_time = MAX (position_running_time, 0);
stop_running_time =
gst_segment_to_running_time (&stream->segment, GST_FORMAT_TIME,
stream->segment.stop);
stop_running_time = MAX (last_stop_running_time, 0);
stop_running_time = MAX (position_running_time, 0);
if (stop_running_time != last_stop_running_time) {
if (stop_running_time != position_running_time) {
GST_WARNING_OBJECT (pad,
"Gap between last_stop and segment stop: %" GST_TIME_FORMAT
"Gap between position and segment stop: %" GST_TIME_FORMAT
" != %" GST_TIME_FORMAT, GST_TIME_ARGS (stop_running_time),
GST_TIME_ARGS (last_stop_running_time));
GST_TIME_ARGS (position_running_time));
}
if (stop_running_time < last_stop_running_time) {
if (stop_running_time < position_running_time) {
GST_DEBUG_OBJECT (pad, "Updating stop position");
stream->segment.stop = stream->segment.position;
gst_pad_push_event (stream->srcpad,
gst_event_new_new_segment (TRUE, stream->segment.rate,
stream->segment.applied_rate, GST_FORMAT_TIME,
stream->segment.start, stream->segment.last_stop,
stream->segment.time));
gst_segment_set_newsegment (&stream->segment, TRUE,
stream->segment.rate, stream->segment.applied_rate,
GST_FORMAT_TIME, stream->segment.start,
stream->segment.last_stop, stream->segment.time);
gst_event_new_segment (&stream->segment));
}
stop_running_time = MAX (stop_running_time, last_stop_running_time);
stop_running_time = MAX (stop_running_time, position_running_time);
GST_DEBUG_OBJECT (pad,
"Stop running time of last group: %" GST_TIME_FORMAT,
GST_TIME_ARGS (stop_running_time));
@ -422,27 +412,23 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstEvent * event)
GST_DEBUG_OBJECT (pad,
"Advancing running time for other streams by: %"
GST_TIME_FORMAT, GST_TIME_ARGS (diff));
gst_pad_push_event (stream->srcpad,
gst_event_new_new_segment (FALSE, 1.0, 1.0,
GST_FORMAT_TIME, 0, diff, 0));
gst_segment_set_newsegment (&stream->segment, FALSE, 1.0, 1.0,
GST_FORMAT_TIME, 0, diff, 0);
segment.base += diff;
}
}
GST_DEBUG_OBJECT (pad, "Segment was: %" GST_SEGMENT_FORMAT,
&stream->segment);
gst_segment_set_newsegment (&stream->segment, update, rate,
applied_rate, format, start, stop, position);
gst_segment_copy_into (&segment, &stream->segment);
GST_DEBUG_OBJECT (pad, "Segment now is: %" GST_SEGMENT_FORMAT,
&stream->segment);
GST_DEBUG_OBJECT (pad, "Stream start running time: %" GST_TIME_FORMAT,
GST_TIME_ARGS (stream->segment.accum));
stream->running_time_diff = stream->segment.accum;
GST_TIME_ARGS (stream->segment.base));
stream->running_time_diff = stream->segment.base;
} else if (stream) {
GST_WARNING_OBJECT (pad, "Non-TIME segment: %s",
gst_format_get_name (format));
gst_format_get_name (segment.format));
gst_segment_init (&stream->segment, GST_FORMAT_UNDEFINED);
}
GST_STREAM_SYNCHRONIZER_UNLOCK (self);
@ -601,8 +587,8 @@ gst_stream_synchronizer_sink_chain (GstPad * pad, GstBuffer * buffer)
&& GST_CLOCK_TIME_IS_VALID (timestamp)) {
GST_LOG_OBJECT (pad,
"Updating last-stop from %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT,
GST_TIME_ARGS (stream->segment.last_stop), GST_TIME_ARGS (timestamp));
gst_segment_set_last_stop (&stream->segment, GST_FORMAT_TIME, timestamp);
GST_TIME_ARGS (stream->segment.position), GST_TIME_ARGS (timestamp));
stream->segment.position = timestamp;
}
GST_STREAM_SYNCHRONIZER_UNLOCK (self);
@ -622,28 +608,27 @@ gst_stream_synchronizer_sink_chain (GstPad * pad, GstBuffer * buffer)
&& GST_CLOCK_TIME_IS_VALID (timestamp_end)) {
GST_LOG_OBJECT (pad,
"Updating last-stop from %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT,
GST_TIME_ARGS (stream->segment.last_stop),
GST_TIME_ARGS (stream->segment.position),
GST_TIME_ARGS (timestamp_end));
gst_segment_set_last_stop (&stream->segment, GST_FORMAT_TIME,
timestamp_end);
stream->segment.position = timestamp_end;
}
/* Advance EOS streams if necessary. For non-EOS
* streams the demuxers should already do this! */
for (l = self->streams; l; l = l->next) {
GstStream *ostream = l->data;
gint64 last_stop;
gint64 position;
if (!ostream->is_eos || ostream->segment.format != GST_FORMAT_TIME)
continue;
if (ostream->segment.last_stop != -1)
last_stop = ostream->segment.last_stop;
if (ostream->segment.position != -1)
position = ostream->segment.position;
else
last_stop = ostream->segment.start;
position = ostream->segment.start;
/* Is there a 1 second lag? */
if (last_stop != -1 && last_stop + GST_SECOND < timestamp_end) {
if (position != -1 && position + GST_SECOND < timestamp_end) {
gint64 new_start, new_stop;
new_start = timestamp_end - GST_SECOND;
@ -654,18 +639,16 @@ gst_stream_synchronizer_sink_chain (GstPad * pad, GstBuffer * buffer)
GST_DEBUG_OBJECT (ostream->sinkpad,
"Advancing stream %u from %" GST_TIME_FORMAT " to %"
GST_TIME_FORMAT, ostream->stream_number, GST_TIME_ARGS (last_stop),
GST_TIME_FORMAT, ostream->stream_number, GST_TIME_ARGS (position),
GST_TIME_ARGS (new_start));
ostream->segment.start = new_start;
ostream->segment.stop = new_stop;
ostream->segment.time = new_start;
ostream->segment.position = new_start;
gst_pad_push_event (ostream->srcpad,
gst_event_new_new_segment (TRUE, ostream->segment.rate,
ostream->segment.applied_rate, ostream->segment.format,
new_start, new_stop, new_start));
gst_segment_set_newsegment (&ostream->segment, TRUE,
ostream->segment.rate, ostream->segment.applied_rate,
ostream->segment.format, new_start, new_stop, new_start);
gst_segment_set_last_stop (&ostream->segment, GST_FORMAT_TIME,
new_start);
gst_event_new_segment (&ostream->segment));
}
}
GST_STREAM_SYNCHRONIZER_UNLOCK (self);
@ -777,15 +760,15 @@ gst_stream_synchronizer_release_stream (GstStreamSynchronizer * self,
if (stream->segment.format == GST_FORMAT_TIME) {
gint64 stop_running_time;
gint64 last_stop_running_time;
gint64 position_running_time;
stop_running_time =
gst_segment_to_running_time (&stream->segment, GST_FORMAT_TIME,
stream->segment.stop);
last_stop_running_time =
position_running_time =
gst_segment_to_running_time (&stream->segment, GST_FORMAT_TIME,
stream->segment.last_stop);
stop_running_time = MAX (stop_running_time, last_stop_running_time);
stream->segment.position);
stop_running_time = MAX (stop_running_time, position_running_time);
GST_DEBUG_OBJECT (stream->sinkpad,
"Stop running time was: %" GST_TIME_FORMAT,

View file

@ -495,29 +495,16 @@ _remove_element (GstSubtitleOverlay * self, GstElement ** element)
}
static void
_generate_update_newsegment_event (GstSegment * segment, GstEvent ** event1,
GstEvent ** event2)
_generate_update_segment_event (GstSegment * segment, GstEvent ** event1)
{
GstEvent *event;
GstStructure *structure;
*event1 = NULL;
*event2 = NULL;
event = gst_event_new_new_segment (FALSE, segment->rate,
segment->applied_rate, segment->format, 0, segment->accum, 0);
structure = (GstStructure *) gst_event_get_structure (event);
event = gst_event_new_segment (segment);
structure = gst_event_writable_structure (event);
gst_structure_id_set (structure, _subtitle_overlay_event_marker_id,
G_TYPE_BOOLEAN, TRUE, NULL);
*event1 = event;
event = gst_event_new_new_segment (FALSE, segment->rate,
segment->applied_rate, segment->format,
segment->start, segment->stop, segment->time);
structure = (GstStructure *) gst_event_get_structure (event);
gst_structure_id_set (structure, _subtitle_overlay_event_marker_id,
G_TYPE_BOOLEAN, TRUE, NULL);
*event2 = event;
}
static gboolean
@ -581,15 +568,12 @@ _setup_passthrough (GstSubtitleOverlay * self)
/* Send segment to the identity. This is dropped because identity
* is not linked downstream yet */
if (self->video_segment.format != GST_FORMAT_UNDEFINED) {
GstEvent *event1, *event2;
GstEvent *event1;
_generate_update_newsegment_event (&self->video_segment, &event1, &event2);
_generate_update_segment_event (&self->video_segment, &event1);
GST_DEBUG_OBJECT (self,
"Pushing video accumulate newsegment event: %" GST_PTR_FORMAT, event1);
GST_DEBUG_OBJECT (self,
"Pushing video update newsegment event: %" GST_PTR_FORMAT, event2);
"Pushing video segment event: %" GST_PTR_FORMAT, event1);
gst_pad_send_event (sink, event1);
gst_pad_send_event (sink, event2);
}
/* Link sink ghostpads to identity */
@ -991,7 +975,7 @@ _pad_blocked_cb (GstPad * pad, gboolean blocked, gpointer user_data)
/* Send segments to the parser/overlay if necessary. These are not sent
* outside this element because of the proxy pad event function */
if (self->video_segment.format != GST_FORMAT_UNDEFINED) {
GstEvent *event1, *event2;
GstEvent *event1;
sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
if (G_UNLIKELY (!sink)) {
@ -999,21 +983,16 @@ _pad_blocked_cb (GstPad * pad, gboolean blocked, gpointer user_data)
continue;
}
_generate_update_newsegment_event (&self->video_segment, &event1,
&event2);
_generate_update_segment_event (&self->video_segment, &event1);
GST_DEBUG_OBJECT (self,
"Pushing video accumulate newsegment event: %" GST_PTR_FORMAT,
event1);
GST_DEBUG_OBJECT (self,
"Pushing video update newsegment event: %" GST_PTR_FORMAT, event2);
"Pushing video segment event: %" GST_PTR_FORMAT, event1);
gst_pad_send_event (sink, event1);
gst_pad_send_event (sink, event2);
gst_object_unref (sink);
}
if (self->subtitle_segment.format != GST_FORMAT_UNDEFINED) {
GstEvent *event1, *event2;
GstEvent *event1;
sink = gst_element_get_static_pad (element, "sink");
if (G_UNLIKELY (!sink)) {
@ -1021,16 +1000,10 @@ _pad_blocked_cb (GstPad * pad, gboolean blocked, gpointer user_data)
continue;
}
_generate_update_newsegment_event (&self->subtitle_segment, &event1,
&event2);
_generate_update_segment_event (&self->subtitle_segment, &event1);
GST_DEBUG_OBJECT (self,
"Pushing subtitle accumulate newsegment event: %" GST_PTR_FORMAT,
event1);
GST_DEBUG_OBJECT (self,
"Pushing subtitle update newsegment event: %" GST_PTR_FORMAT,
event2);
"Pushing subtitle segment event: %" GST_PTR_FORMAT, event1);
gst_pad_send_event (sink, event1);
gst_pad_send_event (sink, event2);
gst_object_unref (sink);
}
@ -1159,7 +1132,7 @@ _pad_blocked_cb (GstPad * pad, gboolean blocked, gpointer user_data)
/* Send segments to the renderer if necessary. These are not sent
* outside this element because of the proxy pad event handler */
if (self->video_segment.format != GST_FORMAT_UNDEFINED) {
GstEvent *event1, *event2;
GstEvent *event1;
sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
if (G_UNLIKELY (!sink)) {
@ -1167,20 +1140,15 @@ _pad_blocked_cb (GstPad * pad, gboolean blocked, gpointer user_data)
continue;
}
_generate_update_newsegment_event (&self->video_segment, &event1,
&event2);
_generate_update_segment_event (&self->video_segment, &event1);
GST_DEBUG_OBJECT (self,
"Pushing video accumulate newsegment event: %" GST_PTR_FORMAT,
event1);
GST_DEBUG_OBJECT (self,
"Pushing video update newsegment event: %" GST_PTR_FORMAT, event2);
"Pushing video segment event: %" GST_PTR_FORMAT, event1);
gst_pad_send_event (sink, event1);
gst_pad_send_event (sink, event2);
gst_object_unref (sink);
}
if (self->subtitle_segment.format != GST_FORMAT_UNDEFINED) {
GstEvent *event1, *event2;
GstEvent *event1;
sink = _get_sub_pad (element);
if (G_UNLIKELY (!sink)) {
@ -1188,16 +1156,10 @@ _pad_blocked_cb (GstPad * pad, gboolean blocked, gpointer user_data)
continue;
}
_generate_update_newsegment_event (&self->subtitle_segment, &event1,
&event2);
_generate_update_segment_event (&self->subtitle_segment, &event1);
GST_DEBUG_OBJECT (self,
"Pushing subtitle accumulate newsegment event: %" GST_PTR_FORMAT,
event1);
GST_DEBUG_OBJECT (self,
"Pushing subtitle update newsegment event: %" GST_PTR_FORMAT,
event2);
"Pushing subtitle segment event: %" GST_PTR_FORMAT, event1);
gst_pad_send_event (sink, event1);
gst_pad_send_event (sink, event2);
gst_object_unref (sink);
}
@ -1679,30 +1641,18 @@ gst_subtitle_overlay_video_sink_event (GstPad * pad, GstEvent * event)
ret = self->video_sink_event (pad, gst_event_ref (event));
if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
gboolean update;
gdouble rate, applied_rate;
GstFormat format;
gint64 start, stop, position;
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
GST_DEBUG_OBJECT (pad, "Newsegment event: %" GST_PTR_FORMAT, event);
gst_event_parse_new_segment (event, &update, &rate, &applied_rate,
&format, &start, &stop, &position);
GST_DEBUG_OBJECT (pad, "segment event: %" GST_PTR_FORMAT, event);
gst_event_parse_segment (event, &self->video_segment);
if (format != GST_FORMAT_TIME) {
if (self->video_segment.format != GST_FORMAT_TIME) {
GST_ERROR_OBJECT (pad, "Newsegment event in non-time format: %s",
gst_format_get_name (format));
gst_format_get_name (self->video_segment.format));
gst_object_unref (event);
gst_object_unref (self);
return FALSE;
}
GST_DEBUG_OBJECT (pad, "Old video segment: %" GST_SEGMENT_FORMAT,
&self->video_segment);
gst_segment_set_newsegment (&self->video_segment, update, rate,
applied_rate, format, start, stop, position);
GST_DEBUG_OBJECT (pad, "New video segment: %" GST_SEGMENT_FORMAT,
&self->video_segment);
}
gst_event_unref (event);
@ -1922,7 +1872,6 @@ gst_subtitle_overlay_subtitle_sink_event (GstPad * pad, GstEvent * event)
{
GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (gst_pad_get_parent (pad));
gboolean ret;
GstFormat format;
if (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_DOWNSTREAM_OOB &&
gst_event_has_name (event, "subtitleoverlay-flush-subtitle")) {
@ -1944,16 +1893,6 @@ gst_subtitle_overlay_subtitle_sink_event (GstPad * pad, GstEvent * event)
event = NULL;
ret = TRUE;
goto out;
} else if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
gst_event_parse_new_segment (event, NULL, NULL, NULL,
&format, NULL, NULL, NULL);
if (self->subtitle_segment.format != GST_FORMAT_UNDEFINED &&
self->subtitle_segment.format != format) {
GST_DEBUG_OBJECT (pad, "Subtitle segment format changed: %s -> %s",
gst_format_get_name (self->subtitle_segment.format),
gst_format_get_name (format));
gst_segment_init (&self->subtitle_segment, GST_FORMAT_UNDEFINED);
}
}
switch (GST_EVENT_TYPE (event)) {
@ -1963,7 +1902,7 @@ gst_subtitle_overlay_subtitle_sink_event (GstPad * pad, GstEvent * event)
gst_segment_init (&self->subtitle_segment, GST_FORMAT_UNDEFINED);
/* fall through */
case GST_EVENT_FLUSH_START:
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
case GST_EVENT_EOS:
{
GstStructure *structure;
@ -1983,26 +1922,9 @@ gst_subtitle_overlay_subtitle_sink_event (GstPad * pad, GstEvent * event)
ret = self->subtitle_sink_event (pad, gst_event_ref (event));
if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
gboolean update;
gdouble rate, applied_rate;
gint64 start, stop, position;
GST_DEBUG_OBJECT (pad, "Newsegment event: %" GST_PTR_FORMAT, event);
gst_event_parse_new_segment (event, &update, &rate, &applied_rate,
&format, &start, &stop, &position);
GST_DEBUG_OBJECT (pad, "Old subtitle segment: %" GST_SEGMENT_FORMAT,
&self->subtitle_segment);
if (self->subtitle_segment.format != format) {
GST_DEBUG_OBJECT (pad, "Subtitle segment format changed: %s -> %s",
gst_format_get_name (self->subtitle_segment.format),
gst_format_get_name (format));
gst_segment_init (&self->subtitle_segment, format);
}
gst_segment_set_newsegment (&self->subtitle_segment, update, rate,
applied_rate, format, start, stop, position);
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
GST_DEBUG_OBJECT (pad, "segment event: %" GST_PTR_FORMAT, event);
gst_event_parse_segment (event, &self->subtitle_segment);
GST_DEBUG_OBJECT (pad, "New subtitle segment: %" GST_SEGMENT_FORMAT,
&self->subtitle_segment);
}

View file

@ -324,10 +324,13 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf)
ret = gst_ssa_parse_push_line (parse, txt, ts, GST_BUFFER_DURATION (buf));
if (ret != GST_FLOW_OK && GST_CLOCK_TIME_IS_VALID (ts)) {
GstSegment segment;
/* just advance time without sending anything */
gst_pad_push_event (parse->srcpad,
gst_event_new_new_segment (TRUE, 1.0, 1.0, GST_FORMAT_TIME, ts, -1,
ts));
gst_segment_init (&segment, GST_FORMAT_TIME);
segment.start = ts;
segment.time = ts;
gst_pad_push_event (parse->srcpad, gst_event_new_segment (&segment));
ret = GST_FLOW_OK;
}

View file

@ -226,7 +226,7 @@ gst_sub_parse_src_query (GstPad * pad, GstQuery ** query)
} else {
ret = TRUE;
gst_query_set_position (*query, GST_FORMAT_TIME,
self->segment.last_stop);
self->segment.position);
}
}
case GST_QUERY_SEEKING:
@ -272,12 +272,13 @@ gst_sub_parse_src_event (GstPad * pad, GstEvent * event)
case GST_EVENT_SEEK:
{
GstFormat format;
GstSeekFlags flags;
GstSeekType start_type, stop_type;
gint64 start, stop;
gdouble rate;
gboolean update;
gst_event_parse_seek (event, &rate, &format, &self->segment_flags,
gst_event_parse_seek (event, &rate, &format, &flags,
&start_type, &start, &stop_type, &stop);
if (format != GST_FORMAT_TIME) {
@ -289,12 +290,12 @@ gst_sub_parse_src_event (GstPad * pad, GstEvent * event)
/* Convert that seek to a seeking in bytes at position 0,
FIXME: could use an index */
ret = gst_pad_push_event (self->sinkpad,
gst_event_new_seek (rate, GST_FORMAT_BYTES, self->segment_flags,
gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, 0));
if (ret) {
/* Apply the seek to our segment */
gst_segment_set_seek (&self->segment, rate, format, self->segment_flags,
gst_segment_do_seek (&self->segment, rate, format, flags,
start_type, start, stop_type, stop, &update);
GST_DEBUG_OBJECT (self, "segment after seek: %" GST_SEGMENT_FORMAT,
@ -553,7 +554,7 @@ parse_mdvdsub (ParserState * state, const gchar * line)
const gchar *line_split;
gchar *line_chunk;
guint start_frame, end_frame;
gint64 clip_start = 0, clip_stop = 0;
guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
GString *markup;
gchar *ret;
@ -906,7 +907,7 @@ parse_subrip (ParserState * state, const gchar * line)
case 2:
{
/* No need to parse that text if it's out of segment */
gint64 clip_start = 0, clip_stop = 0;
guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
/* Check our segment start/stop */
@ -995,7 +996,7 @@ parse_subviewer (ParserState * state, const gchar * line)
case 1:
{
/* No need to parse that text if it's out of segment */
gint64 clip_start = 0, clip_stop = 0;
guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
/* Check our segment start/stop */
@ -1047,7 +1048,7 @@ parse_mpsub (ParserState * state, const gchar * line)
return NULL;
case 1:
{ /* No need to parse that text if it's out of segment */
gint64 clip_start = 0, clip_stop = 0;
guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
/* Check our segment start/stop */
@ -1111,7 +1112,7 @@ parse_dks (ParserState * state, const gchar * line)
return NULL;
case 1:
{
gint64 clip_start = 0, clip_stop = 0;
guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg;
gchar *ret;
@ -1502,8 +1503,7 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
GST_BUFFER_DURATION (buf) = self->state.max_duration;
}
gst_segment_set_last_stop (&self->segment, GST_FORMAT_TIME,
self->state.start_time);
self->segment.position = self->state.start_time;
GST_DEBUG_OBJECT (self, "Sending text '%s', %" GST_TIME_FORMAT " + %"
GST_TIME_FORMAT, subtitle, GST_TIME_ARGS (self->state.start_time),
@ -1541,10 +1541,7 @@ gst_sub_parse_chain (GstPad * sinkpad, GstBuffer * buf)
GST_LOG_OBJECT (self, "pushing newsegment event with %" GST_SEGMENT_FORMAT,
&self->segment);
gst_pad_push_event (self->srcpad, gst_event_new_new_segment (FALSE,
self->segment.rate, self->segment.applied_rate,
self->segment.format, self->segment.last_stop, self->segment.stop,
self->segment.time));
gst_pad_push_event (self->srcpad, gst_event_new_segment (&self->segment));
self->need_segment = FALSE;
}
@ -1582,32 +1579,20 @@ gst_sub_parse_sink_event (GstPad * pad, GstEvent * event)
ret = gst_pad_event_default (pad, event);
break;
}
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
GstFormat format;
gdouble rate, arate;
gint64 start, stop, time;
gboolean update;
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
GST_DEBUG_OBJECT (self, "newsegment (%s)", gst_format_get_name (format));
if (format == GST_FORMAT_TIME) {
gst_segment_set_newsegment (&self->segment, update, rate, arate, format,
start, stop, time);
} else {
/* if not time format, we'll either start with a 0 timestamp anyway or
* it's following a seek in which case we'll have saved the requested
* seek segment and don't want to overwrite it (remember that on a seek
* we always just seek back to the start in BYTES format and just throw
* away all text that's before the requested position; if the subtitles
* come from an upstream demuxer, it won't be able to handle our BYTES
* seek request and instead send us a newsegment from the seek request
* it received via its video pads instead, so all is fine then too) */
}
gst_event_parse_segment (event, &self->segment);
GST_DEBUG_OBJECT (self, "newsegment (%s)",
gst_format_get_name (self->segment.format));
/* if not time format, we'll either start with a 0 timestamp anyway or
* it's following a seek in which case we'll have saved the requested
* seek segment and don't want to overwrite it (remember that on a seek
* we always just seek back to the start in BYTES format and just throw
* away all text that's before the requested position; if the subtitles
* come from an upstream demuxer, it won't be able to handle our BYTES
* seek request and instead send us a newsegment from the seek request
* it received via its video pads instead, so all is fine then too) */
ret = TRUE;
gst_event_unref (event);
break;

View file

@ -95,7 +95,6 @@ struct _GstSubParse {
/* Segment */
GstSegment segment;
GstSeekFlags segment_flags;
gboolean need_segment;
gboolean flushing;

View file

@ -488,7 +488,7 @@ gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate)
if (videorate->to_rate_numerator) {
/* interpolate next expected timestamp in the segment */
videorate->next_ts =
videorate->segment.accum + videorate->segment.start +
videorate->segment.base + videorate->segment.start +
videorate->base_ts + gst_util_uint64_scale (videorate->out_frame_count,
videorate->to_rate_denominator * GST_SECOND,
videorate->to_rate_numerator);
@ -496,7 +496,7 @@ gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate)
}
/* adapt for looping, bring back to time in current segment. */
GST_BUFFER_TIMESTAMP (outbuf) = push_ts - videorate->segment.accum;
GST_BUFFER_TIMESTAMP (outbuf) = push_ts - videorate->segment.base;
GST_LOG_OBJECT (videorate,
"old is best, dup, pushing buffer outgoing ts %" GST_TIME_FORMAT,
@ -555,23 +555,19 @@ gst_video_rate_event (GstPad * pad, GstEvent * event)
videorate = GST_VIDEO_RATE (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
gint64 start, stop, time;
gdouble rate, arate;
gboolean update;
GstFormat format;
GstSegment segment;
gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
&start, &stop, &time);
gst_event_parse_segment (event, &segment);
if (format != GST_FORMAT_TIME)
if (segment.format != GST_FORMAT_TIME)
goto format_error;
GST_DEBUG_OBJECT (videorate, "handle NEWSEGMENT");
/* close up the previous segment, if appropriate */
if (!update && videorate->prevbuf) {
if (videorate->prevbuf) {
gint count = 0;
GstFlowReturn res;
@ -581,7 +577,7 @@ gst_video_rate_event (GstPad * pad, GstEvent * event)
* regardless, prevent going loopy in strange cases */
while (res == GST_FLOW_OK && count <= MAGIC_LIMIT &&
((GST_CLOCK_TIME_IS_VALID (videorate->segment.stop) &&
videorate->next_ts - videorate->segment.accum
videorate->next_ts - videorate->segment.base
< videorate->segment.stop)
|| count < 1)) {
res = gst_video_rate_flush_prev (videorate, count > 0);
@ -604,8 +600,7 @@ gst_video_rate_event (GstPad * pad, GstEvent * event)
}
/* We just want to update the accumulated stream_time */
gst_segment_set_newsegment (&videorate->segment, update, rate, arate,
format, start, stop, time);
gst_segment_copy_into (&segment, &videorate->segment);
GST_DEBUG_OBJECT (videorate, "updated segment: %" GST_SEGMENT_FORMAT,
&videorate->segment);
@ -623,7 +618,7 @@ gst_video_rate_event (GstPad * pad, GstEvent * event)
* or only send out the stored buffer if there is no specific stop.
* regardless, prevent going loopy in strange cases */
while (res == GST_FLOW_OK && count <= MAGIC_LIMIT &&
((videorate->next_ts - videorate->segment.accum <
((videorate->next_ts - videorate->segment.base <
videorate->segment.stop)
|| count < 1)) {
res = gst_video_rate_flush_prev (videorate, count > 0);
@ -637,7 +632,7 @@ gst_video_rate_event (GstPad * pad, GstEvent * event)
videorate->next_ts + GST_BUFFER_DURATION (videorate->prevbuf);
while (res == GST_FLOW_OK && count <= MAGIC_LIMIT &&
((videorate->next_ts - videorate->segment.accum < end_ts)
((videorate->next_ts - videorate->segment.base < end_ts)
|| count < 1)) {
res = gst_video_rate_flush_prev (videorate, count > 0);
count++;
@ -783,7 +778,7 @@ gst_video_rate_chain (GstPad * pad, GstBuffer * buffer)
/* the input time is the time in the segment + all previously accumulated
* segments */
intime = in_ts + videorate->segment.accum;
intime = in_ts + videorate->segment.base;
/* we need to have two buffers to compare */
if (videorate->prevbuf == NULL) {
@ -797,8 +792,7 @@ gst_video_rate_chain (GstPad * pad, GstBuffer * buffer)
videorate->base_ts = in_ts - videorate->segment.start;
videorate->out_frame_count = 0;
} else {
videorate->next_ts =
videorate->segment.start + videorate->segment.accum;
videorate->next_ts = videorate->segment.start + videorate->segment.base;
}
}
} else {

View file

@ -834,17 +834,17 @@ gst_video_test_src_get_times (GstBaseSrc * basesrc, GstBuffer * buffer,
static gboolean
gst_video_test_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
{
GstClockTime time;
GstClockTime position;
GstVideoTestSrc *src;
src = GST_VIDEO_TEST_SRC (bsrc);
segment->time = segment->start;
time = segment->last_stop;
position = segment->position;
/* now move to the time indicated */
/* now move to the position indicated */
if (src->rate_numerator) {
src->n_frames = gst_util_uint64_scale (time,
src->n_frames = gst_util_uint64_scale (position,
src->rate_numerator, src->rate_denominator * GST_SECOND);
} else {
src->n_frames = 0;
@ -857,7 +857,7 @@ gst_video_test_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
src->running_time = 0;
}
g_assert (src->running_time <= time);
g_assert (src->running_time <= position);
return TRUE;
}