stream: add property to configure profiles

This commit is contained in:
Wim Taymans 2014-01-07 12:21:09 +01:00
parent 78c6648c96
commit ae1fe21436
4 changed files with 136 additions and 1 deletions

View file

@ -82,6 +82,7 @@ struct _GstRTSPMediaPrivate
gboolean shared; gboolean shared;
gboolean suspend_mode; gboolean suspend_mode;
gboolean reusable; gboolean reusable;
GstRTSPProfile profiles;
GstRTSPLowerTrans protocols; GstRTSPLowerTrans protocols;
gboolean reused; gboolean reused;
gboolean eos_shutdown; gboolean eos_shutdown;
@ -125,6 +126,7 @@ struct _GstRTSPMediaPrivate
#define DEFAULT_SHARED FALSE #define DEFAULT_SHARED FALSE
#define DEFAULT_SUSPEND_MODE GST_RTSP_SUSPEND_MODE_NONE #define DEFAULT_SUSPEND_MODE GST_RTSP_SUSPEND_MODE_NONE
#define DEFAULT_REUSABLE FALSE #define DEFAULT_REUSABLE FALSE
#define DEFAULT_PROFILES GST_RTSP_PROFILE_AVP
#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \ #define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \
GST_RTSP_LOWER_TRANS_TCP GST_RTSP_LOWER_TRANS_TCP
#define DEFAULT_EOS_SHUTDOWN FALSE #define DEFAULT_EOS_SHUTDOWN FALSE
@ -140,6 +142,7 @@ enum
PROP_SHARED, PROP_SHARED,
PROP_SUSPEND_MODE, PROP_SUSPEND_MODE,
PROP_REUSABLE, PROP_REUSABLE,
PROP_PROFILES,
PROP_PROTOCOLS, PROP_PROTOCOLS,
PROP_EOS_SHUTDOWN, PROP_EOS_SHUTDOWN,
PROP_BUFFER_SIZE, PROP_BUFFER_SIZE,
@ -237,6 +240,11 @@ gst_rtsp_media_class_init (GstRTSPMediaClass * klass)
"If this media pipeline can be reused after an unprepare", "If this media pipeline can be reused after an unprepare",
DEFAULT_REUSABLE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); DEFAULT_REUSABLE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PROFILES,
g_param_spec_flags ("profiles", "Profiles",
"Allowed transfer profiles", GST_TYPE_RTSP_PROFILE,
DEFAULT_PROFILES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PROTOCOLS, g_object_class_install_property (gobject_class, PROP_PROTOCOLS,
g_param_spec_flags ("protocols", "Protocols", g_param_spec_flags ("protocols", "Protocols",
"Allowed lower transport protocols", GST_TYPE_RTSP_LOWER_TRANS, "Allowed lower transport protocols", GST_TYPE_RTSP_LOWER_TRANS,
@ -314,6 +322,7 @@ gst_rtsp_media_init (GstRTSPMedia * media)
priv->shared = DEFAULT_SHARED; priv->shared = DEFAULT_SHARED;
priv->suspend_mode = DEFAULT_SUSPEND_MODE; priv->suspend_mode = DEFAULT_SUSPEND_MODE;
priv->reusable = DEFAULT_REUSABLE; priv->reusable = DEFAULT_REUSABLE;
priv->profiles = DEFAULT_PROFILES;
priv->protocols = DEFAULT_PROTOCOLS; priv->protocols = DEFAULT_PROTOCOLS;
priv->eos_shutdown = DEFAULT_EOS_SHUTDOWN; priv->eos_shutdown = DEFAULT_EOS_SHUTDOWN;
priv->buffer_size = DEFAULT_BUFFER_SIZE; priv->buffer_size = DEFAULT_BUFFER_SIZE;
@ -371,6 +380,9 @@ gst_rtsp_media_get_property (GObject * object, guint propid,
case PROP_REUSABLE: case PROP_REUSABLE:
g_value_set_boolean (value, gst_rtsp_media_is_reusable (media)); g_value_set_boolean (value, gst_rtsp_media_is_reusable (media));
break; break;
case PROP_PROFILES:
g_value_set_flags (value, gst_rtsp_media_get_profiles (media));
break;
case PROP_PROTOCOLS: case PROP_PROTOCOLS:
g_value_set_flags (value, gst_rtsp_media_get_protocols (media)); g_value_set_flags (value, gst_rtsp_media_get_protocols (media));
break; break;
@ -408,6 +420,9 @@ gst_rtsp_media_set_property (GObject * object, guint propid,
case PROP_REUSABLE: case PROP_REUSABLE:
gst_rtsp_media_set_reusable (media, g_value_get_boolean (value)); gst_rtsp_media_set_reusable (media, g_value_get_boolean (value));
break; break;
case PROP_PROFILES:
gst_rtsp_media_set_profiles (media, g_value_get_flags (value));
break;
case PROP_PROTOCOLS: case PROP_PROTOCOLS:
gst_rtsp_media_set_protocols (media, g_value_get_flags (value)); gst_rtsp_media_set_protocols (media, g_value_get_flags (value));
break; break;
@ -814,6 +829,59 @@ gst_rtsp_media_is_reusable (GstRTSPMedia * media)
return res; return res;
} }
static void
do_set_profiles (GstRTSPStream * stream, GstRTSPProfile * profiles)
{
gst_rtsp_stream_set_profiles (stream, *profiles);
}
/**
* gst_rtsp_media_set_profiles:
* @media: a #GstRTSPMedia
* @profiles: the new flags
*
* Configure the allowed lower transport for @media.
*/
void
gst_rtsp_media_set_profiles (GstRTSPMedia * media, GstRTSPProfile profiles)
{
GstRTSPMediaPrivate *priv;
g_return_if_fail (GST_IS_RTSP_MEDIA (media));
priv = media->priv;
g_mutex_lock (&priv->lock);
priv->profiles = profiles;
g_ptr_array_foreach (priv->streams, (GFunc) do_set_profiles, &profiles);
g_mutex_unlock (&priv->lock);
}
/**
* gst_rtsp_media_get_profiles:
* @media: a #GstRTSPMedia
*
* Get the allowed profiles of @media.
*
* Returns: a #GstRTSPProfile
*/
GstRTSPProfile
gst_rtsp_media_get_profiles (GstRTSPMedia * media)
{
GstRTSPMediaPrivate *priv;
GstRTSPProfile res;
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), GST_RTSP_PROFILE_UNKNOWN);
priv = media->priv;
g_mutex_lock (&priv->lock);
res = priv->profiles;
g_mutex_unlock (&priv->lock);
return res;
}
static void static void
do_set_protocols (GstRTSPStream * stream, GstRTSPLowerTrans * protocols) do_set_protocols (GstRTSPStream * stream, GstRTSPLowerTrans * protocols)
{ {

View file

@ -160,6 +160,9 @@ gboolean gst_rtsp_media_is_shared (GstRTSPMedia *media);
void gst_rtsp_media_set_reusable (GstRTSPMedia *media, gboolean reusable); void gst_rtsp_media_set_reusable (GstRTSPMedia *media, gboolean reusable);
gboolean gst_rtsp_media_is_reusable (GstRTSPMedia *media); gboolean gst_rtsp_media_is_reusable (GstRTSPMedia *media);
void gst_rtsp_media_set_profiles (GstRTSPMedia *media, GstRTSPProfile profiles);
GstRTSPProfile gst_rtsp_media_get_profiles (GstRTSPMedia *media);
void gst_rtsp_media_set_protocols (GstRTSPMedia *media, GstRTSPLowerTrans protocols); void gst_rtsp_media_set_protocols (GstRTSPMedia *media, GstRTSPLowerTrans protocols);
GstRTSPLowerTrans gst_rtsp_media_get_protocols (GstRTSPMedia *media); GstRTSPLowerTrans gst_rtsp_media_get_protocols (GstRTSPMedia *media);

View file

@ -68,6 +68,7 @@ struct _GstRTSPStreamPrivate
gboolean is_joined; gboolean is_joined;
gchar *control; gchar *control;
GstRTSPProfile profiles;
GstRTSPLowerTrans protocols; GstRTSPLowerTrans protocols;
/* pads on the rtpbin */ /* pads on the rtpbin */
@ -127,6 +128,7 @@ struct _GstRTSPStreamPrivate
}; };
#define DEFAULT_CONTROL NULL #define DEFAULT_CONTROL NULL
#define DEFAULT_PROFILES GST_RTSP_PROFILE_AVP
#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \ #define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \
GST_RTSP_LOWER_TRANS_TCP GST_RTSP_LOWER_TRANS_TCP
@ -134,6 +136,7 @@ enum
{ {
PROP_0, PROP_0,
PROP_CONTROL, PROP_CONTROL,
PROP_PROFILES,
PROP_PROTOCOLS, PROP_PROTOCOLS,
PROP_LAST PROP_LAST
}; };
@ -170,6 +173,11 @@ gst_rtsp_stream_class_init (GstRTSPStreamClass * klass)
"The control string for this stream", DEFAULT_CONTROL, "The control string for this stream", DEFAULT_CONTROL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PROFILES,
g_param_spec_flags ("profiles", "Profiles",
"Allowed transfer profiles", GST_TYPE_RTSP_PROFILE,
DEFAULT_PROFILES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PROTOCOLS, g_object_class_install_property (gobject_class, PROP_PROTOCOLS,
g_param_spec_flags ("protocols", "Protocols", g_param_spec_flags ("protocols", "Protocols",
"Allowed lower transport protocols", GST_TYPE_RTSP_LOWER_TRANS, "Allowed lower transport protocols", GST_TYPE_RTSP_LOWER_TRANS,
@ -191,6 +199,7 @@ gst_rtsp_stream_init (GstRTSPStream * stream)
priv->dscp_qos = -1; priv->dscp_qos = -1;
priv->control = g_strdup (DEFAULT_CONTROL); priv->control = g_strdup (DEFAULT_CONTROL);
priv->profiles = DEFAULT_PROFILES;
priv->protocols = DEFAULT_PROTOCOLS; priv->protocols = DEFAULT_PROTOCOLS;
g_mutex_init (&priv->lock); g_mutex_init (&priv->lock);
@ -238,6 +247,9 @@ gst_rtsp_stream_get_property (GObject * object, guint propid,
case PROP_CONTROL: case PROP_CONTROL:
g_value_take_string (value, gst_rtsp_stream_get_control (stream)); g_value_take_string (value, gst_rtsp_stream_get_control (stream));
break; break;
case PROP_PROFILES:
g_value_set_flags (value, gst_rtsp_stream_get_profiles (stream));
break;
case PROP_PROTOCOLS: case PROP_PROTOCOLS:
g_value_set_flags (value, gst_rtsp_stream_get_protocols (stream)); g_value_set_flags (value, gst_rtsp_stream_get_protocols (stream));
break; break;
@ -256,6 +268,9 @@ gst_rtsp_stream_set_property (GObject * object, guint propid,
case PROP_CONTROL: case PROP_CONTROL:
gst_rtsp_stream_set_control (stream, g_value_get_string (value)); gst_rtsp_stream_set_control (stream, g_value_get_string (value));
break; break;
case PROP_PROFILES:
gst_rtsp_stream_set_profiles (stream, g_value_get_flags (value));
break;
case PROP_PROTOCOLS: case PROP_PROTOCOLS:
gst_rtsp_stream_set_protocols (stream, g_value_get_flags (value)); gst_rtsp_stream_set_protocols (stream, g_value_get_flags (value));
break; break;
@ -568,7 +583,7 @@ gst_rtsp_stream_is_transport_supported (GstRTSPStream * stream,
if (transport->trans != GST_RTSP_TRANS_RTP) if (transport->trans != GST_RTSP_TRANS_RTP)
goto unsupported_transmode; goto unsupported_transmode;
if (transport->profile != GST_RTSP_PROFILE_AVP) if (!(transport->profile & priv->profiles))
goto unsupported_profile; goto unsupported_profile;
if (!(transport->lower_transport & priv->protocols)) if (!(transport->lower_transport & priv->protocols))
@ -596,6 +611,52 @@ unsupported_ltrans:
} }
} }
/**
* gst_rtsp_stream_set_profiles:
* @stream: a #GstRTSPStream
* @profiles: the new profiles
*
* Configure the allowed profiles for @stream.
*/
void
gst_rtsp_stream_set_profiles (GstRTSPStream * stream, GstRTSPProfile profiles)
{
GstRTSPStreamPrivate *priv;
g_return_if_fail (GST_IS_RTSP_STREAM (stream));
priv = stream->priv;
g_mutex_lock (&priv->lock);
priv->profiles = profiles;
g_mutex_unlock (&priv->lock);
}
/**
* gst_rtsp_stream_get_profiles:
* @stream: a #GstRTSPStream
*
* Get the allowed profiles of @stream.
*
* Returns: a #GstRTSPProfile
*/
GstRTSPProfile
gst_rtsp_stream_get_profiles (GstRTSPStream * stream)
{
GstRTSPStreamPrivate *priv;
GstRTSPProfile res;
g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), GST_RTSP_PROFILE_UNKNOWN);
priv = stream->priv;
g_mutex_lock (&priv->lock);
res = priv->profiles;
g_mutex_unlock (&priv->lock);
return res;
}
/** /**
* gst_rtsp_stream_set_protocols: * gst_rtsp_stream_set_protocols:
* @stream: a #GstRTSPStream * @stream: a #GstRTSPStream

View file

@ -85,6 +85,9 @@ gint gst_rtsp_stream_get_dscp_qos (GstRTSPStream *stream);
gboolean gst_rtsp_stream_is_transport_supported (GstRTSPStream *stream, gboolean gst_rtsp_stream_is_transport_supported (GstRTSPStream *stream,
GstRTSPTransport *transport); GstRTSPTransport *transport);
void gst_rtsp_stream_set_profiles (GstRTSPStream *stream, GstRTSPProfile profiles);
GstRTSPProfile gst_rtsp_stream_get_profiles (GstRTSPStream *stream);
void gst_rtsp_stream_set_protocols (GstRTSPStream *stream, GstRTSPLowerTrans protocols); void gst_rtsp_stream_set_protocols (GstRTSPStream *stream, GstRTSPLowerTrans protocols);
GstRTSPLowerTrans gst_rtsp_stream_get_protocols (GstRTSPStream *stream); GstRTSPLowerTrans gst_rtsp_stream_get_protocols (GstRTSPStream *stream);