basedepayload: Fix generated segment

This fixes playback position in RTSP.

https://bugzilla.gnome.org/show_bug.cgi?id=635701
This commit is contained in:
Nicolas Dufresne 2015-03-25 18:40:25 -04:00
parent d54d51d0d2
commit 802ad73103
2 changed files with 26 additions and 8 deletions

View file

@ -563,24 +563,31 @@ static GstEvent *
create_segment_event (GstRTPBaseDepayload * filter, GstClockTime position) create_segment_event (GstRTPBaseDepayload * filter, GstClockTime position)
{ {
GstEvent *event; GstEvent *event;
GstClockTime stop; GstClockTime stop, running_time;
GstRTPBaseDepayloadPrivate *priv; GstRTPBaseDepayloadPrivate *priv;
GstSegment segment; GstSegment segment;
priv = filter->priv; priv = filter->priv;
if (priv->npt_stop != -1) if (priv->npt_stop != -1)
stop = priv->npt_stop - priv->npt_start; stop = position + priv->npt_stop - priv->npt_start;
else else
stop = -1; stop = -1;
if (position == -1)
position = 0;
running_time = gst_segment_to_running_time (&filter->segment,
GST_FORMAT_TIME, position);
gst_segment_init (&segment, GST_FORMAT_TIME); gst_segment_init (&segment, GST_FORMAT_TIME);
segment.rate = priv->play_speed; segment.rate = priv->play_speed;
segment.applied_rate = priv->play_scale; segment.applied_rate = priv->play_scale;
segment.start = 0; segment.start = position;
segment.stop = stop; segment.stop = stop;
segment.time = priv->npt_start; segment.time = priv->npt_start;
segment.position = position; segment.position = position;
segment.base = running_time;
event = gst_event_new_segment (&segment); event = gst_event_new_segment (&segment);
@ -649,8 +656,19 @@ gst_rtp_base_depayload_prepare_push (GstRTPBaseDepayload * filter,
/* if this is the first buffer send a NEWSEGMENT */ /* if this is the first buffer send a NEWSEGMENT */
if (G_UNLIKELY (filter->need_newsegment)) { if (G_UNLIKELY (filter->need_newsegment)) {
GstEvent *event; GstEvent *event;
GstClockTime pts;
event = create_segment_event (filter, 0); if (is_list) {
GstBufferList **blist = obj;
GstBuffer *buf = gst_buffer_list_get (*blist, 0);
pts = GST_BUFFER_PTS (buf);
} else {
GstBuffer **buf = obj;
set_headers (buf, 0, &data);
pts = GST_BUFFER_PTS (*buf);
}
event = create_segment_event (filter, pts);
gst_pad_push_event (filter->srcpad, event); gst_pad_push_event (filter->srcpad, event);

View file

@ -933,8 +933,8 @@ GST_START_TEST (rtp_base_depayload_npt_test)
validate_event (6, "segment", validate_event (6, "segment",
"time", G_GUINT64_CONSTANT (1234), "time", G_GUINT64_CONSTANT (1234),
"start", G_GUINT64_CONSTANT (0), "start", GST_SECOND,
"stop", G_GUINT64_CONSTANT (4321 - 1234), NULL); "stop", GST_SECOND + G_GUINT64_CONSTANT (4321 - 1234), NULL);
destroy_depayloader (state); destroy_depayloader (state);
} }
@ -994,7 +994,7 @@ GST_START_TEST (rtp_base_depayload_play_scale_test)
validate_event (6, "segment", validate_event (6, "segment",
"time", G_GUINT64_CONSTANT (0), "time", G_GUINT64_CONSTANT (0),
"start", G_GUINT64_CONSTANT (0), "start", GST_SECOND,
"stop", G_MAXUINT64, "rate", 1.0, "applied-rate", 2.0, NULL); "stop", G_MAXUINT64, "rate", 1.0, "applied-rate", 2.0, NULL);
destroy_depayloader (state); destroy_depayloader (state);
@ -1055,7 +1055,7 @@ GST_START_TEST (rtp_base_depayload_play_speed_test)
validate_event (6, "segment", validate_event (6, "segment",
"time", G_GUINT64_CONSTANT (0), "time", G_GUINT64_CONSTANT (0),
"start", G_GUINT64_CONSTANT (0), "start", GST_SECOND,
"stop", G_MAXUINT64, "rate", 2.0, "applied-rate", 1.0, NULL); "stop", G_MAXUINT64, "rate", 2.0, "applied-rate", 1.0, NULL);
destroy_depayloader (state); destroy_depayloader (state);