mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
media-factory: complete DSCP QoS setting support
add dscp_qos setting support at factory and media level to setup IP DSCP field of bounded UDP sinks. Fixes https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/issues/6 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/120>
This commit is contained in:
parent
5d8abd9bfd
commit
6459a61e8f
4 changed files with 164 additions and 1 deletions
|
@ -58,6 +58,7 @@ struct _GstRTSPMediaFactoryPrivate
|
|||
GstRTSPProfile profiles;
|
||||
GstRTSPLowerTrans protocols;
|
||||
guint buffer_size;
|
||||
gint dscp_qos;
|
||||
GstRTSPAddressPool *pool;
|
||||
GstRTSPTransportMode transport_mode;
|
||||
gboolean stop_on_disconnect;
|
||||
|
@ -93,6 +94,7 @@ struct _GstRTSPMediaFactoryPrivate
|
|||
#define DEFAULT_TRANSPORT_MODE GST_RTSP_TRANSPORT_MODE_PLAY
|
||||
#define DEFAULT_STOP_ON_DISCONNECT TRUE
|
||||
#define DEFAULT_DO_RETRANSMISSION FALSE
|
||||
#define DEFAULT_DSCP_QOS (-1)
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -110,6 +112,7 @@ enum
|
|||
PROP_CLOCK,
|
||||
PROP_MAX_MCAST_TTL,
|
||||
PROP_BIND_MCAST_ADDRESS,
|
||||
PROP_DSCP_QOS,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
|
@ -244,6 +247,11 @@ gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass)
|
|||
DEFAULT_BIND_MCAST_ADDRESS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_DSCP_QOS,
|
||||
g_param_spec_int ("dscp-qos", "DSCP QoS",
|
||||
"The IP DSCP field to use", -1, 63,
|
||||
DEFAULT_DSCP_QOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONSTRUCTED] =
|
||||
g_signal_new ("media-constructed", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPMediaFactoryClass,
|
||||
|
@ -287,6 +295,7 @@ gst_rtsp_media_factory_init (GstRTSPMediaFactory * factory)
|
|||
priv->do_retransmission = DEFAULT_DO_RETRANSMISSION;
|
||||
priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL;
|
||||
priv->bind_mcast_address = DEFAULT_BIND_MCAST_ADDRESS;
|
||||
priv->dscp_qos = DEFAULT_DSCP_QOS;
|
||||
|
||||
g_mutex_init (&priv->lock);
|
||||
g_mutex_init (&priv->medias_lock);
|
||||
|
@ -369,6 +378,9 @@ gst_rtsp_media_factory_get_property (GObject * object, guint propid,
|
|||
g_value_set_boolean (value,
|
||||
gst_rtsp_media_factory_is_bind_mcast_address (factory));
|
||||
break;
|
||||
case PROP_DSCP_QOS:
|
||||
g_value_set_int (value, gst_rtsp_media_factory_get_dscp_qos (factory));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
||||
}
|
||||
|
@ -427,6 +439,9 @@ gst_rtsp_media_factory_set_property (GObject * object, guint propid,
|
|||
gst_rtsp_media_factory_set_bind_mcast_address (factory,
|
||||
g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_DSCP_QOS:
|
||||
gst_rtsp_media_factory_set_dscp_qos (factory, g_value_get_int (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
||||
}
|
||||
|
@ -813,6 +828,62 @@ gst_rtsp_media_factory_get_buffer_size (GstRTSPMediaFactory * factory)
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_factory_set_dscp_qos:
|
||||
* @factory: a #GstRTSPMediaFactory
|
||||
* @dscp_qos: a new dscp qos value (0-63, or -1 to disable)
|
||||
*
|
||||
* Configure the media dscp qos to @dscp_qos.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
void
|
||||
gst_rtsp_media_factory_set_dscp_qos (GstRTSPMediaFactory * factory,
|
||||
gint dscp_qos)
|
||||
{
|
||||
GstRTSPMediaFactoryPrivate *priv;
|
||||
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
||||
|
||||
if (dscp_qos < -1 || dscp_qos > 63) {
|
||||
GST_WARNING_OBJECT (factory, "trying to set illegal dscp qos %d", dscp_qos);
|
||||
return;
|
||||
}
|
||||
|
||||
priv = factory->priv;
|
||||
|
||||
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
||||
priv->dscp_qos = dscp_qos;
|
||||
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_factory_get_dscp_qos:
|
||||
* @factory: a #GstRTSPMediaFactory
|
||||
*
|
||||
* Get the configured media DSCP QoS.
|
||||
*
|
||||
* Returns: the media DSCP QoS value or -1 if disabled.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
gint
|
||||
gst_rtsp_media_factory_get_dscp_qos (GstRTSPMediaFactory * factory)
|
||||
{
|
||||
GstRTSPMediaFactoryPrivate *priv;
|
||||
guint result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
|
||||
|
||||
priv = factory->priv;
|
||||
|
||||
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
||||
result = priv->dscp_qos;
|
||||
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_factory_set_address_pool:
|
||||
* @factory: a #GstRTSPMediaFactory
|
||||
|
@ -1754,6 +1825,7 @@ default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
|
|||
GstRTSPMediaFactoryPrivate *priv = factory->priv;
|
||||
gboolean shared, eos_shutdown, stop_on_disconnect;
|
||||
guint size;
|
||||
gint dscp_qos;
|
||||
GstRTSPSuspendMode suspend_mode;
|
||||
GstRTSPProfile profiles;
|
||||
GstRTSPLowerTrans protocols;
|
||||
|
@ -1774,6 +1846,7 @@ default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
|
|||
shared = priv->shared;
|
||||
eos_shutdown = priv->eos_shutdown;
|
||||
size = priv->buffer_size;
|
||||
dscp_qos = priv->dscp_qos;
|
||||
profiles = priv->profiles;
|
||||
protocols = priv->protocols;
|
||||
rtx_time = priv->rtx_time;
|
||||
|
@ -1790,6 +1863,7 @@ default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
|
|||
gst_rtsp_media_set_shared (media, shared);
|
||||
gst_rtsp_media_set_eos_shutdown (media, eos_shutdown);
|
||||
gst_rtsp_media_set_buffer_size (media, size);
|
||||
gst_rtsp_media_set_dscp_qos (media, dscp_qos);
|
||||
gst_rtsp_media_set_profiles (media, profiles);
|
||||
gst_rtsp_media_set_protocols (media, protocols);
|
||||
gst_rtsp_media_set_retransmission_time (media, rtx_time);
|
||||
|
|
|
@ -252,6 +252,12 @@ void gst_rtsp_media_factory_set_bind_mcast_address (GstRTSPMedi
|
|||
GST_RTSP_SERVER_API
|
||||
gboolean gst_rtsp_media_factory_is_bind_mcast_address (GstRTSPMediaFactory * factory);
|
||||
|
||||
GST_RTSP_SERVER_API
|
||||
void gst_rtsp_media_factory_set_dscp_qos (GstRTSPMediaFactory * factory,
|
||||
gint dscp_qos);
|
||||
GST_RTSP_SERVER_API
|
||||
gint gst_rtsp_media_factory_get_dscp_qos (GstRTSPMediaFactory * factory);
|
||||
|
||||
/* creating the media from the factory and a url */
|
||||
|
||||
GST_RTSP_SERVER_API
|
||||
|
|
|
@ -106,6 +106,7 @@ struct _GstRTSPMediaPrivate
|
|||
gboolean reused;
|
||||
gboolean eos_shutdown;
|
||||
guint buffer_size;
|
||||
gint dscp_qos;
|
||||
GstRTSPAddressPool *pool;
|
||||
gchar *multicast_iface;
|
||||
guint max_mcast_ttl;
|
||||
|
@ -169,6 +170,7 @@ struct _GstRTSPMediaPrivate
|
|||
GST_RTSP_LOWER_TRANS_TCP
|
||||
#define DEFAULT_EOS_SHUTDOWN FALSE
|
||||
#define DEFAULT_BUFFER_SIZE 0x80000
|
||||
#define DEFAULT_DSCP_QOS (-1)
|
||||
#define DEFAULT_TIME_PROVIDER FALSE
|
||||
#define DEFAULT_LATENCY 200
|
||||
#define DEFAULT_TRANSPORT_MODE GST_RTSP_TRANSPORT_MODE_PLAY
|
||||
|
@ -200,6 +202,7 @@ enum
|
|||
PROP_CLOCK,
|
||||
PROP_MAX_MCAST_TTL,
|
||||
PROP_BIND_MCAST_ADDRESS,
|
||||
PROP_DSCP_QOS,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
|
@ -410,6 +413,11 @@ gst_rtsp_media_class_init (GstRTSPMediaClass * klass)
|
|||
DEFAULT_BIND_MCAST_ADDRESS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_DSCP_QOS,
|
||||
g_param_spec_int ("dscp-qos", "DSCP QoS",
|
||||
"The IP DSCP field to use for each related stream", -1, 63,
|
||||
DEFAULT_DSCP_QOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_rtsp_media_signals[SIGNAL_NEW_STREAM] =
|
||||
g_signal_new ("new-stream", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GstRTSPMediaClass, new_stream), NULL, NULL, NULL,
|
||||
|
@ -483,6 +491,7 @@ gst_rtsp_media_init (GstRTSPMedia * media)
|
|||
priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL;
|
||||
priv->bind_mcast_address = DEFAULT_BIND_MCAST_ADDRESS;
|
||||
priv->do_rate_control = DEFAULT_DO_RATE_CONTROL;
|
||||
priv->dscp_qos = DEFAULT_DSCP_QOS;
|
||||
priv->expected_async_done = FALSE;
|
||||
}
|
||||
|
||||
|
@ -577,6 +586,9 @@ gst_rtsp_media_get_property (GObject * object, guint propid,
|
|||
case PROP_BIND_MCAST_ADDRESS:
|
||||
g_value_set_boolean (value, gst_rtsp_media_is_bind_mcast_address (media));
|
||||
break;
|
||||
case PROP_DSCP_QOS:
|
||||
g_value_set_int (value, gst_rtsp_media_get_dscp_qos (media));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
||||
}
|
||||
|
@ -637,6 +649,9 @@ gst_rtsp_media_set_property (GObject * object, guint propid,
|
|||
gst_rtsp_media_set_bind_mcast_address (media,
|
||||
g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_DSCP_QOS:
|
||||
gst_rtsp_media_set_dscp_qos (media, g_value_get_int (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
||||
}
|
||||
|
@ -1411,6 +1426,70 @@ gst_rtsp_media_get_buffer_size (GstRTSPMedia * media)
|
|||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
do_set_dscp_qos (GstRTSPStream * stream, gint * dscp_qos)
|
||||
{
|
||||
gst_rtsp_stream_set_dscp_qos (stream, *dscp_qos);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_set_dscp_qos:
|
||||
* @media: a #GstRTSPMedia
|
||||
* @dscp_qos: a new dscp qos value (0-63, or -1 to disable)
|
||||
*
|
||||
* Configure the dscp qos of attached streams to @dscp_qos.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
void
|
||||
gst_rtsp_media_set_dscp_qos (GstRTSPMedia * media, gint dscp_qos)
|
||||
{
|
||||
GstRTSPMediaPrivate *priv;
|
||||
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA (media));
|
||||
|
||||
GST_LOG_OBJECT (media, "set DSCP QoS %d", dscp_qos);
|
||||
|
||||
if (dscp_qos < -1 || dscp_qos > 63) {
|
||||
GST_WARNING_OBJECT (media, "trying to set illegal dscp qos %d", dscp_qos);
|
||||
return;
|
||||
}
|
||||
|
||||
priv = media->priv;
|
||||
|
||||
g_mutex_lock (&priv->lock);
|
||||
priv->dscp_qos = dscp_qos;
|
||||
g_ptr_array_foreach (priv->streams, (GFunc) do_set_dscp_qos, &dscp_qos);
|
||||
g_mutex_unlock (&priv->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_get_dscp_qos:
|
||||
* @media: a #GstRTSPMedia
|
||||
*
|
||||
* Get the configured DSCP QoS of attached media.
|
||||
*
|
||||
* Returns: the DSCP QoS value of attached streams or -1 if disabled.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
gint
|
||||
gst_rtsp_media_get_dscp_qos (GstRTSPMedia * media)
|
||||
{
|
||||
GstRTSPMediaPrivate *priv;
|
||||
gint res;
|
||||
|
||||
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
|
||||
|
||||
priv = media->priv;
|
||||
|
||||
g_mutex_unlock (&priv->lock);
|
||||
res = priv->dscp_qos;
|
||||
g_mutex_unlock (&priv->lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_set_stop_on_disconnect:
|
||||
* @media: a #GstRTSPMedia
|
||||
|
|
|
@ -307,7 +307,6 @@ GstNetTimeProvider * gst_rtsp_media_get_time_provider (GstRTSPMedia *media,
|
|||
GST_RTSP_SERVER_API
|
||||
void gst_rtsp_media_set_clock (GstRTSPMedia *media, GstClock * clock);
|
||||
|
||||
|
||||
GST_RTSP_SERVER_API
|
||||
void gst_rtsp_media_set_publish_clock_mode (GstRTSPMedia * media, GstRTSPPublishClockMode mode);
|
||||
|
||||
|
@ -325,6 +324,11 @@ void gst_rtsp_media_set_bind_mcast_address (GstRTSPMedia *medi
|
|||
GST_RTSP_SERVER_API
|
||||
gboolean gst_rtsp_media_is_bind_mcast_address (GstRTSPMedia *media);
|
||||
|
||||
GST_RTSP_SERVER_API
|
||||
void gst_rtsp_media_set_dscp_qos (GstRTSPMedia * media, gint dscp_qos);
|
||||
GST_RTSP_SERVER_API
|
||||
gint gst_rtsp_media_get_dscp_qos (GstRTSPMedia * media);
|
||||
|
||||
/* prepare the media for playback */
|
||||
|
||||
GST_RTSP_SERVER_API
|
||||
|
|
Loading…
Reference in a new issue