dscp qos support in gst-rtsp-stream
authorAlexander Schrab <alexas@axis.com>
Mon, 24 Jun 2013 08:43:59 +0000 (10:43 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 24 Jun 2013 12:51:44 +0000 (14:51 +0200)
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=702645

gst/rtsp-server/rtsp-stream.c
gst/rtsp-server/rtsp-stream.h

index 8b8aa31..11486e5 100644 (file)
@@ -84,6 +84,8 @@ struct _GstRTSPStreamPrivate
   /* transports we stream to */
   guint n_active;
   GList *transports;
+
+  gint dscp_qos;
 };
 
 
@@ -127,6 +129,8 @@ gst_rtsp_stream_init (GstRTSPStream * stream)
 
   stream->priv = priv;
 
+  stream->priv->dscp_qos = -1;
+
   g_mutex_init (&priv->lock);
 }
 
@@ -265,6 +269,76 @@ gst_rtsp_stream_get_mtu (GstRTSPStream * stream)
   return mtu;
 }
 
+/* Update the dscp qos property on the udp sinks */
+static void
+update_dscp_qos (GstRTSPStream *stream)
+{
+  GstRTSPStreamPrivate *priv;
+
+  g_return_if_fail (GST_IS_RTSP_STREAM (stream));
+
+  priv = stream->priv;
+
+  if (priv->udpsink[0]) {
+    g_object_set (G_OBJECT (priv->udpsink[0]), "qos-dscp", priv->dscp_qos,
+        NULL);
+  }
+
+  if (priv->udpsink[1]) {
+    g_object_set (G_OBJECT (priv->udpsink[1]), "qos-dscp", priv->dscp_qos,
+        NULL);
+  }
+}
+
+/**
+ * gst_rtsp_stream_set_dscp_qos:
+ * @stream: a #GstRTSPStream
+ * @dscp_qos: a new dscp qos value (0-63, or -1 to disable)
+ *
+ * Configure the dscp qos of the outgoing sockets to @dscp_qos.
+ */
+void
+gst_rtsp_stream_set_dscp_qos (GstRTSPStream *stream, gint dscp_qos)
+{
+  GstRTSPStreamPrivate *priv;
+
+  g_return_if_fail (GST_IS_RTSP_STREAM (stream));
+
+  priv = stream->priv;
+
+  GST_LOG_OBJECT (stream, "set DSCP QoS %d", dscp_qos);
+
+  if (dscp_qos < -1 || dscp_qos > 63) {
+    GST_WARNING_OBJECT (stream, "trying to set illegal dscp qos %d", dscp_qos);
+    return;
+  }
+
+  priv->dscp_qos = dscp_qos;
+
+  update_dscp_qos (stream);
+}
+
+/**
+ * gst_rtsp_stream_get_dscp_qos:
+ * @stream: a #GstRTSPStream
+ *
+ * Get the configured DSCP QoS in of the outgoing sockets.
+ *
+ * Returns: the DSCP QoS value of the outgoing sockets, or -1 if disbled.
+ */
+gint
+gst_rtsp_stream_get_dscp_qos (GstRTSPStream *stream)
+{
+  GstRTSPStreamPrivate *priv;
+
+  g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), -1);
+
+  priv = stream->priv;
+
+  return priv->dscp_qos;
+}
+
+
 /**
  * gst_rtsp_stream_set_address_pool:
  * @stream: a #GstRTSPStream
@@ -1018,6 +1092,9 @@ gst_rtsp_stream_join_bin (GstRTSPStream * stream, GstBin * bin,
   if (!alloc_ports (stream))
     goto no_ports;
 
+  /* update the dscp qos field in the sinks */
+  update_dscp_qos (stream);
+
   /* get a pad for sending RTP */
   name = g_strdup_printf ("send_rtp_sink_%u", idx);
   priv->send_rtp_sink = gst_element_get_request_pad (rtpbin, name);
index f6507a9..4b8e53e 100644 (file)
@@ -70,6 +70,9 @@ GstPad *          gst_rtsp_stream_get_srcpad       (GstRTSPStream *stream);
 void              gst_rtsp_stream_set_mtu          (GstRTSPStream *stream, guint mtu);
 guint             gst_rtsp_stream_get_mtu          (GstRTSPStream *stream);
 
+void              gst_rtsp_stream_set_dscp_qos     (GstRTSPStream *stream, gint dscp_qos);
+gint              gst_rtsp_stream_get_dscp_qos     (GstRTSPStream *stream);
+
 void              gst_rtsp_stream_set_address_pool (GstRTSPStream *stream, GstRTSPAddressPool *pool);
 GstRTSPAddressPool *
                   gst_rtsp_stream_get_address_pool (GstRTSPStream *stream);