* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
+/**
+ * SECTION:rtsp-stream-transport
+ * @short_description: A media stream transport configuration
+ * @see_also: #GstRTSPStream, #GstRTSPSessionMedia
+ *
+ * The #GstRTSPStreamTransport configures the transport used by a
+ * #GstRTSPStream. It is usually manages by a #GstRTSPSessionMedia object.
+ *
+ * With gst_rtsp_stream_transport_set_callbacks(), callbacks can be configured
+ * to handle the RTP and RTCP packets from the stream, for example when they
+ * need to be sent over TCP.
+ *
+ * With gst_rtsp_stream_transport_set_active() the transports are added and
+ * removed from the stream.
+ *
+ * A #GstRTSPStream will call gst_rtsp_stream_transport_keep_alive() when RTCP
+ * is received from the client. It will also call
+ * gst_rtsp_stream_transport_set_timed_out() when a receiver has timed out.
+ *
+ * Last reviewed on 2013-07-16 (1.0.0)
+ */
#include <string.h>
#include <stdlib.h>
gboolean timed_out;
GstRTSPTransport *transport;
+ GstRTSPUrl *url;
GObject *rtpsource;
};
if (priv->transport)
gst_rtsp_transport_free (priv->transport);
+ if (priv->url)
+ gst_rtsp_url_free (priv->url);
+
G_OBJECT_CLASS (gst_rtsp_stream_transport_parent_class)->finalize (obj);
}
}
/**
+ * gst_rtsp_stream_transport_set_url:
+ * @trans: a #GstRTSPStreamTransport
+ * @url: (transfer none): a client #GstRTSPUrl
+ *
+ * Set @url as the client url.
+ */
+void
+gst_rtsp_stream_transport_set_url (GstRTSPStreamTransport * trans,
+ const GstRTSPUrl * url)
+{
+ GstRTSPStreamTransportPrivate *priv;
+
+ g_return_if_fail (GST_IS_RTSP_STREAM_TRANSPORT (trans));
+
+ priv = trans->priv;
+
+ /* keep track of the transports in the stream. */
+ if (priv->url)
+ gst_rtsp_url_free (priv->url);
+ priv->url = (url ? gst_rtsp_url_copy (url) : NULL);
+}
+
+/**
+ * gst_rtsp_stream_transport_get_url:
+ * @trans: a #GstRTSPStreamTransport
+ *
+ * Get the url configured in @trans.
+ *
+ * Returns: (transfer none): the url configured in @trans. It remains
+ * valid for as long as @trans is valid.
+ */
+const GstRTSPUrl *
+gst_rtsp_stream_transport_get_url (GstRTSPStreamTransport * trans)
+{
+ g_return_val_if_fail (GST_IS_RTSP_STREAM_TRANSPORT (trans), NULL);
+
+ return trans->priv->url;
+}
+
+ /**
+ * gst_rtsp_stream_transport_get_rtpinfo:
+ * @trans: a #GstRTSPStreamTransport
+ * @start_time: a star time
+ *
+ * Get the RTP-Info string for @trans and @start_time.
+ *
+ * Returns: the RTPInfo string for @trans and @start_time or %NULL when
+ * the RTP-Info could not be determined. g_free() after usage.
+ */
+gchar *
+gst_rtsp_stream_transport_get_rtpinfo (GstRTSPStreamTransport * trans,
+ GstClockTime start_time)
+{
+ GstRTSPStreamTransportPrivate *priv;
+ gchar *url_str;
+ GString *rtpinfo;
+ 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, &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);
+ g_string_append_printf (rtpinfo, "url=%s;seq=%u;rtptime=%u",
+ url_str, seq, rtptime);
+ g_free (url_str);
+
+ return g_string_free (rtpinfo, FALSE);
+}
+
+/**
* gst_rtsp_stream_transport_set_active:
* @trans: a #GstRTSPStreamTransport
* @active: new state of @trans