And use it to correct the rtptime to the requested start-time.
See https://bugzilla.gnome.org/show_bug.cgi?id=712198
}
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;
GST_LOG_OBJECT (media, "running time of %d stream: %" GST_TIME_FORMAT, i,
GstRTSPStreamTransportPrivate *priv;
gchar *url_str;
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);
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;
+ 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 ("");
url_str = gst_rtsp_url_get_request_uri (trans->priv->url);
* @stream: a #GstRTSPStream
* @rtptime: (allow-none): result RTP timestamp
* @seq: (allow-none): result RTP seqnum
+ * @clock_rate: the clock rate
* @running_time: (allow-none): result running-time
*
* Retrieve the current rtptime, seq and running-time. This is used to
*/
gboolean
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;
GObjectClass *payobjclass;
payobjclass = G_OBJECT_GET_CLASS (priv->payloader);
+ g_mutex_lock (&priv->lock);
if (seq && g_object_class_find_property (payobjclass, "seqnum"))
g_object_get (priv->payloader, "seqnum", seq, NULL);
&& g_object_class_find_property (payobjclass, "running-time"))
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;
}
gboolean gst_rtsp_stream_get_rtpinfo (GstRTSPStream *stream,
guint *rtptime, guint *seq,
+ guint *clock_rate,
GstClockTime *running_time);
GstCaps * gst_rtsp_stream_get_caps (GstRTSPStream *stream);