stream: return clock-rate from get_rtpinfo

And use it to correct the rtptime to the requested start-time.

See https://bugzilla.gnome.org/show_bug.cgi?id=712198
This commit is contained in:
Wim Taymans 2013-12-26 17:02:50 +01:00
parent 037e21b578
commit 8aaa432d58
4 changed files with 38 additions and 4 deletions

View file

@ -276,7 +276,7 @@ gst_rtsp_session_media_get_rtpinfo (GstRTSPSessionMedia * media)
} }
stream = gst_rtsp_stream_transport_get_stream (transport); stream = gst_rtsp_stream_transport_get_stream (transport);
if (!gst_rtsp_stream_get_rtpinfo (stream, NULL, NULL, &running_time)) if (!gst_rtsp_stream_get_rtpinfo (stream, NULL, NULL, NULL, &running_time))
continue; continue;
GST_LOG_OBJECT (media, "running time of %d stream: %" GST_TIME_FORMAT, i, GST_LOG_OBJECT (media, "running time of %d stream: %" GST_TIME_FORMAT, i,

View file

@ -327,15 +327,35 @@ gst_rtsp_stream_transport_get_rtpinfo (GstRTSPStreamTransport * trans,
GstRTSPStreamTransportPrivate *priv; GstRTSPStreamTransportPrivate *priv;
gchar *url_str; gchar *url_str;
GString *rtpinfo; GString *rtpinfo;
guint rtptime, seq; guint rtptime, seq, clock_rate;
GstClockTime running_time = GST_CLOCK_TIME_NONE;
g_return_val_if_fail (GST_IS_RTSP_STREAM_TRANSPORT (trans), NULL); g_return_val_if_fail (GST_IS_RTSP_STREAM_TRANSPORT (trans), NULL);
priv = trans->priv; priv = trans->priv;
if (!gst_rtsp_stream_get_rtpinfo (priv->stream, &rtptime, &seq, NULL)) if (!gst_rtsp_stream_get_rtpinfo (priv->stream, &rtptime, &seq, &clock_rate,
&running_time))
return NULL; return NULL;
GST_DEBUG ("RTP time %u, seq %u, rate %u, running-time %" GST_TIME_FORMAT,
rtptime, seq, clock_rate, GST_TIME_ARGS (running_time));
if (GST_CLOCK_TIME_IS_VALID (running_time)
&& GST_CLOCK_TIME_IS_VALID (start_time)) {
if (running_time > start_time) {
rtptime -=
gst_util_uint64_scale_int (running_time - start_time, clock_rate,
GST_SECOND);
} else {
rtptime +=
gst_util_uint64_scale_int (start_time - running_time, clock_rate,
GST_SECOND);
}
}
GST_DEBUG ("RTP time %u, for start-time %" GST_TIME_FORMAT,
rtptime, GST_TIME_ARGS (start_time));
rtpinfo = g_string_new (""); rtpinfo = g_string_new ("");
url_str = gst_rtsp_url_get_request_uri (trans->priv->url); url_str = gst_rtsp_url_get_request_uri (trans->priv->url);

View file

@ -1751,6 +1751,7 @@ was_not_joined:
* @stream: a #GstRTSPStream * @stream: a #GstRTSPStream
* @rtptime: (allow-none): result RTP timestamp * @rtptime: (allow-none): result RTP timestamp
* @seq: (allow-none): result RTP seqnum * @seq: (allow-none): result RTP seqnum
* @clock_rate: the clock rate
* @running_time: (allow-none): result running-time * @running_time: (allow-none): result running-time
* *
* Retrieve the current rtptime, seq and running-time. This is used to * Retrieve the current rtptime, seq and running-time. This is used to
@ -1760,7 +1761,8 @@ was_not_joined:
*/ */
gboolean gboolean
gst_rtsp_stream_get_rtpinfo (GstRTSPStream * stream, gst_rtsp_stream_get_rtpinfo (GstRTSPStream * stream,
guint * rtptime, guint * seq, GstClockTime * running_time) guint * rtptime, guint * seq, guint * clock_rate,
GstClockTime * running_time)
{ {
GstRTSPStreamPrivate *priv; GstRTSPStreamPrivate *priv;
GObjectClass *payobjclass; GObjectClass *payobjclass;
@ -1771,6 +1773,7 @@ gst_rtsp_stream_get_rtpinfo (GstRTSPStream * stream,
payobjclass = G_OBJECT_GET_CLASS (priv->payloader); payobjclass = G_OBJECT_GET_CLASS (priv->payloader);
g_mutex_lock (&priv->lock);
if (seq && g_object_class_find_property (payobjclass, "seqnum")) if (seq && g_object_class_find_property (payobjclass, "seqnum"))
g_object_get (priv->payloader, "seqnum", seq, NULL); g_object_get (priv->payloader, "seqnum", seq, NULL);
@ -1781,6 +1784,16 @@ gst_rtsp_stream_get_rtpinfo (GstRTSPStream * stream,
&& g_object_class_find_property (payobjclass, "running-time")) && g_object_class_find_property (payobjclass, "running-time"))
g_object_get (priv->payloader, "running-time", running_time, NULL); g_object_get (priv->payloader, "running-time", running_time, NULL);
if (clock_rate && priv->caps) {
GstStructure *s;
s = gst_caps_get_structure (priv->caps, 0);
if (!gst_structure_get_int (s, "clock-rate", (gint *) clock_rate))
if (running_time)
*running_time = GST_CLOCK_TIME_NONE;
}
g_mutex_unlock (&priv->lock);
return TRUE; return TRUE;
} }

View file

@ -119,6 +119,7 @@ void gst_rtsp_stream_get_ssrc (GstRTSPStream *stream,
gboolean gst_rtsp_stream_get_rtpinfo (GstRTSPStream *stream, gboolean gst_rtsp_stream_get_rtpinfo (GstRTSPStream *stream,
guint *rtptime, guint *seq, guint *rtptime, guint *seq,
guint *clock_rate,
GstClockTime *running_time); GstClockTime *running_time);
GstCaps * gst_rtsp_stream_get_caps (GstRTSPStream *stream); GstCaps * gst_rtsp_stream_get_caps (GstRTSPStream *stream);