From: Sebastian Dröge Date: Tue, 14 Aug 2018 11:25:42 +0000 (+0300) Subject: Revert "Add new API for setting/getting maximum multicast ttl value" X-Git-Tag: 1.16.2~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=443c2b73e5526999a424a96950e14828fdced591;p=platform%2Fupstream%2Fgst-rtsp-server.git Revert "Add new API for setting/getting maximum multicast ttl value" This reverts commit 7f0ae77e400fb8a0462a76a5dd2e63e12c4a2e52. Commits where accidentially squashed together --- diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c index 8f39ccd..92135f2 100644 --- a/gst/rtsp-server/rtsp-client.c +++ b/gst/rtsp-server/rtsp-client.c @@ -1981,27 +1981,26 @@ default_configure_client_transport (GstRTSPClient * client, */ /* FIXME: could be more adequately solved by making it possible * to set a socket on multiudpsink after it has already been started */ - if (!gst_rtsp_stream_allocate_udp_sockets (ctx->stream, - G_SOCKET_FAMILY_IPV4, ct, use_client_settings) - && family == G_SOCKET_FAMILY_IPV4) + if (!gst_rtsp_stream_allocate_udp_sockets (ctx->stream, G_SOCKET_FAMILY_IPV4, ct, + use_client_settings) && family == G_SOCKET_FAMILY_IPV4) goto error_allocating_ports; - if (!gst_rtsp_stream_allocate_udp_sockets (ctx->stream, - G_SOCKET_FAMILY_IPV6, ct, use_client_settings) - && family == G_SOCKET_FAMILY_IPV6) + if (!gst_rtsp_stream_allocate_udp_sockets (ctx->stream, G_SOCKET_FAMILY_IPV6, ct, + use_client_settings) && family == G_SOCKET_FAMILY_IPV6) goto error_allocating_ports; if (ct->lower_transport == GST_RTSP_LOWER_TRANS_UDP_MCAST) { - /* FIXME: the address has been successfully allocated, however, in - * the use_client_settings case we need to verify that the allocated - * address is the one requested by the client and if this address is - * an allowed destination. Verifying this via the address pool in not - * the proper way as the address pool should only be used for choosing - * the server-selected address/port pairs. */ + GstRTSPAddress *addr = NULL; - if (!use_client_settings) { - GstRTSPAddress *addr = NULL; + if (use_client_settings) { + /* the address has been successfully allocated, let's check if it's + * the one requested by the client */ + addr = gst_rtsp_stream_reserve_address (ctx->stream, ct->destination, + ct->port.min, ct->port.max - ct->port.min + 1, ct->ttl); + if (addr == NULL) + goto no_address; + } else { g_free (ct->destination); addr = gst_rtsp_stream_get_multicast_address (ctx->stream, family); if (addr == NULL) @@ -2010,8 +2009,9 @@ default_configure_client_transport (GstRTSPClient * client, ct->port.min = addr->port; ct->port.max = addr->port + addr->n_ports - 1; ct->ttl = addr->ttl; - gst_rtsp_address_free (addr); } + + gst_rtsp_address_free (addr); } else { GstRTSPUrl *url; diff --git a/gst/rtsp-server/rtsp-media-factory.c b/gst/rtsp-server/rtsp-media-factory.c index 53bce3e..a4f10dd 100644 --- a/gst/rtsp-server/rtsp-media-factory.c +++ b/gst/rtsp-server/rtsp-media-factory.c @@ -59,7 +59,6 @@ struct _GstRTSPMediaFactoryPrivate GstRTSPTransportMode transport_mode; gboolean stop_on_disconnect; gchar *multicast_iface; - guint max_mcast_ttl; GstClockTime rtx_time; guint latency; @@ -84,7 +83,6 @@ struct _GstRTSPMediaFactoryPrivate GST_RTSP_LOWER_TRANS_TCP #define DEFAULT_BUFFER_SIZE 0x80000 #define DEFAULT_LATENCY 200 -#define DEFAULT_MAX_MCAST_TTL 255 #define DEFAULT_TRANSPORT_MODE GST_RTSP_TRANSPORT_MODE_PLAY #define DEFAULT_STOP_ON_DISCONNECT TRUE #define DEFAULT_DO_RETRANSMISSION FALSE @@ -103,7 +101,6 @@ enum PROP_TRANSPORT_MODE, PROP_STOP_ON_DISCONNECT, PROP_CLOCK, - PROP_MAX_MCAST_TTL, PROP_LAST }; @@ -225,12 +222,6 @@ gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass) "medias of this factory", GST_TYPE_CLOCK, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_MAX_MCAST_TTL, - g_param_spec_uint ("max-mcast-ttl", "Maximum multicast ttl", - "The maximum time-to-live value of outgoing multicast packets", 1, - 255, DEFAULT_MAX_MCAST_TTL, - 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, @@ -272,7 +263,6 @@ gst_rtsp_media_factory_init (GstRTSPMediaFactory * factory) priv->stop_on_disconnect = DEFAULT_STOP_ON_DISCONNECT; priv->publish_clock_mode = GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK; priv->do_retransmission = DEFAULT_DO_RETRANSMISSION; - priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL; g_mutex_init (&priv->lock); g_mutex_init (&priv->medias_lock); @@ -347,9 +337,6 @@ gst_rtsp_media_factory_get_property (GObject * object, guint propid, case PROP_CLOCK: g_value_take_object (value, gst_rtsp_media_factory_get_clock (factory)); break; - case PROP_MAX_MCAST_TTL: - g_value_set_uint (value, - gst_rtsp_media_factory_get_max_mcast_ttl (factory)); default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec); } @@ -400,9 +387,6 @@ gst_rtsp_media_factory_set_property (GObject * object, guint propid, case PROP_CLOCK: gst_rtsp_media_factory_set_clock (factory, g_value_get_object (value)); break; - case PROP_MAX_MCAST_TTL: - gst_rtsp_media_factory_set_max_mcast_ttl (factory, - g_value_get_uint (value)); default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec); } @@ -1479,62 +1463,6 @@ gst_rtsp_media_factory_get_publish_clock_mode (GstRTSPMediaFactory * factory) return ret; } -/** - * gst_rtsp_media_factory_set_max_mcast_ttl: - * @factory: a #GstRTSPMedia - * @ttl: the new multicast ttl value - * - * Set the maximum time-to-live value of outgoing multicast packets. - * - * Returns: %TRUE if the requested ttl has been set successfully. - */ -gboolean -gst_rtsp_media_factory_set_max_mcast_ttl (GstRTSPMediaFactory * factory, - guint ttl) -{ - GstRTSPMediaFactoryPrivate *priv; - - g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE); - - priv = factory->priv; - - GST_RTSP_MEDIA_FACTORY_LOCK (factory); - if (ttl == 0 || ttl > DEFAULT_MAX_MCAST_TTL) { - GST_WARNING_OBJECT (factory, "The requested mcast TTL value is not valid."); - GST_RTSP_MEDIA_FACTORY_UNLOCK (factory); - return FALSE; - } - priv->max_mcast_ttl = ttl; - GST_RTSP_MEDIA_FACTORY_UNLOCK (factory); - - return TRUE; -} - -/** - * gst_rtsp_media_factory_get_max_mcast_ttl: - * @factory: a #GstRTSPMedia - * - * Get the the maximum time-to-live value of outgoing multicast packets. - * - * Returns: the maximum time-to-live value of outgoing multicast packets. - */ -guint -gst_rtsp_media_factory_get_max_mcast_ttl (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->max_mcast_ttl; - GST_RTSP_MEDIA_FACTORY_UNLOCK (factory); - - return result; -} - static gchar * default_gen_key (GstRTSPMediaFactory * factory, const GstRTSPUrl * url) { @@ -1685,7 +1613,6 @@ default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media) GstClock *clock; gchar *multicast_iface; GstRTSPPublishClockMode publish_clock_mode; - guint ttl; /* configure the sharedness */ GST_RTSP_MEDIA_FACTORY_LOCK (factory); @@ -1701,7 +1628,6 @@ default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media) stop_on_disconnect = priv->stop_on_disconnect; clock = priv->clock ? gst_object_ref (priv->clock) : NULL; publish_clock_mode = priv->publish_clock_mode; - ttl = priv->max_mcast_ttl; GST_RTSP_MEDIA_FACTORY_UNLOCK (factory); gst_rtsp_media_set_suspend_mode (media, suspend_mode); @@ -1716,7 +1642,6 @@ default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media) gst_rtsp_media_set_transport_mode (media, transport_mode); gst_rtsp_media_set_stop_on_disconnect (media, stop_on_disconnect); gst_rtsp_media_set_publish_clock_mode (media, publish_clock_mode); - gst_rtsp_media_set_max_mcast_ttl (media, ttl); if (clock) { gst_rtsp_media_set_clock (media, clock); diff --git a/gst/rtsp-server/rtsp-media-factory.h b/gst/rtsp-server/rtsp-media-factory.h index 46d7d55..7fb7fcc 100644 --- a/gst/rtsp-server/rtsp-media-factory.h +++ b/gst/rtsp-server/rtsp-media-factory.h @@ -239,13 +239,6 @@ void gst_rtsp_media_factory_set_publish_clock_mode (GstRTSPMe GST_RTSP_SERVER_API GstRTSPPublishClockMode gst_rtsp_media_factory_get_publish_clock_mode (GstRTSPMediaFactory * factory); -GST_RTSP_SERVER_API -gboolean gst_rtsp_media_factory_set_max_mcast_ttl (GstRTSPMediaFactory * factory, - guint ttl); - -GST_RTSP_SERVER_API -guint gst_rtsp_media_factory_get_max_mcast_ttl (GstRTSPMediaFactory * factory); - /* creating the media from the factory and a url */ GST_RTSP_SERVER_API diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 1073b89..f23b4c5 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -98,7 +98,6 @@ struct _GstRTSPMediaPrivate guint buffer_size; GstRTSPAddressPool *pool; gchar *multicast_iface; - guint max_mcast_ttl; gboolean blocked; GstRTSPTransportMode transport_mode; gboolean stop_on_disconnect; @@ -159,7 +158,6 @@ struct _GstRTSPMediaPrivate #define DEFAULT_LATENCY 200 #define DEFAULT_TRANSPORT_MODE GST_RTSP_TRANSPORT_MODE_PLAY #define DEFAULT_STOP_ON_DISCONNECT TRUE -#define DEFAULT_MAX_MCAST_TTL 255 #define DEFAULT_DO_RETRANSMISSION FALSE @@ -182,7 +180,6 @@ enum PROP_TRANSPORT_MODE, PROP_STOP_ON_DISCONNECT, PROP_CLOCK, - PROP_MAX_MCAST_TTL, PROP_LAST }; @@ -378,12 +375,6 @@ gst_rtsp_media_class_init (GstRTSPMediaClass * klass) "Clock to be used by the media pipeline", GST_TYPE_CLOCK, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_MAX_MCAST_TTL, - g_param_spec_uint ("max-mcast-ttl", "Maximum multicast ttl", - "The maximum time-to-live value of outgoing multicast packets", 1, - 255, DEFAULT_MAX_MCAST_TTL, - 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, @@ -454,7 +445,6 @@ gst_rtsp_media_init (GstRTSPMedia * media) priv->stop_on_disconnect = DEFAULT_STOP_ON_DISCONNECT; priv->publish_clock_mode = GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK; priv->do_retransmission = DEFAULT_DO_RETRANSMISSION; - priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL; } static void @@ -541,9 +531,6 @@ gst_rtsp_media_get_property (GObject * object, guint propid, case PROP_CLOCK: g_value_take_object (value, gst_rtsp_media_get_clock (media)); break; - case PROP_MAX_MCAST_TTL: - g_value_set_uint (value, gst_rtsp_media_get_max_mcast_ttl (media)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec); } @@ -597,9 +584,6 @@ gst_rtsp_media_set_property (GObject * object, guint propid, case PROP_CLOCK: gst_rtsp_media_set_clock (media, g_value_get_object (value)); break; - case PROP_MAX_MCAST_TTL: - gst_rtsp_media_set_max_mcast_ttl (media, g_value_get_uint (value)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec); } @@ -1839,70 +1823,6 @@ gst_rtsp_media_get_multicast_iface (GstRTSPMedia * media) return result; } -/** - * gst_rtsp_media_set_max_mcast_ttl: - * @media: a #GstRTSPMedia - * @ttl: the new multicast ttl value - * - * Set the maximum time-to-live value of outgoing multicast packets. - * - * Returns: %TRUE if the requested ttl has been set successfully. - */ -gboolean -gst_rtsp_media_set_max_mcast_ttl (GstRTSPMedia * media, guint ttl) -{ - GstRTSPMediaPrivate *priv; - guint i; - - g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE); - - GST_LOG_OBJECT (media, "set max mcast ttl %u", ttl); - - priv = media->priv; - - g_mutex_lock (&priv->lock); - - if (ttl == 0 || ttl > DEFAULT_MAX_MCAST_TTL) { - GST_WARNING_OBJECT (media, "The reqested mcast TTL value is not valid."); - g_mutex_unlock (&priv->lock); - return FALSE; - } - priv->max_mcast_ttl = ttl; - - for (i = 0; i < priv->streams->len; i++) { - GstRTSPStream *stream = g_ptr_array_index (priv->streams, i); - gst_rtsp_stream_set_max_mcast_ttl (stream, ttl); - } - g_mutex_unlock (&priv->lock); - - return TRUE; -} - -/** - * gst_rtsp_media_get_max_mcast_ttl: - * @media: a #GstRTSPMedia - * - * Get the the maximum time-to-live value of outgoing multicast packets. - * - * Returns: the maximum time-to-live value of outgoing multicast packets. - */ -guint -gst_rtsp_media_get_max_mcast_ttl (GstRTSPMedia * media) -{ - GstRTSPMediaPrivate *priv; - guint res; - - g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE); - - priv = media->priv; - - g_mutex_lock (&priv->lock); - res = priv->max_mcast_ttl; - g_mutex_unlock (&priv->lock); - - return res; -} - static GList * _find_payload_types (GstRTSPMedia * media) { @@ -2220,7 +2140,6 @@ gst_rtsp_media_create_stream (GstRTSPMedia * media, GstElement * payloader, if (priv->pool) gst_rtsp_stream_set_address_pool (stream, priv->pool); gst_rtsp_stream_set_multicast_iface (stream, priv->multicast_iface); - gst_rtsp_stream_set_max_mcast_ttl (stream, priv->max_mcast_ttl); gst_rtsp_stream_set_profiles (stream, priv->profiles); gst_rtsp_stream_set_protocols (stream, priv->protocols); gst_rtsp_stream_set_retransmission_time (stream, priv->rtx_time); diff --git a/gst/rtsp-server/rtsp-media.h b/gst/rtsp-server/rtsp-media.h index 92b3866..84dfb14 100644 --- a/gst/rtsp-server/rtsp-media.h +++ b/gst/rtsp-server/rtsp-media.h @@ -314,12 +314,6 @@ void gst_rtsp_media_set_publish_clock_mode (GstRTSPMedia * me GST_RTSP_SERVER_API GstRTSPPublishClockMode gst_rtsp_media_get_publish_clock_mode (GstRTSPMedia * media); -GST_RTSP_SERVER_API -gboolean gst_rtsp_media_set_max_mcast_ttl (GstRTSPMedia *media, guint ttl); - -GST_RTSP_SERVER_API -guint gst_rtsp_media_get_max_mcast_ttl (GstRTSPMedia *media); - /* prepare the media for playback */ GST_RTSP_SERVER_API diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c index 1a68fd5..b95ead9 100644 --- a/gst/rtsp-server/rtsp-stream.c +++ b/gst/rtsp-server/rtsp-stream.c @@ -145,7 +145,6 @@ struct _GstRTSPStreamPrivate GstRTSPAddress *mcast_addr_v6; gchar *multicast_iface; - guint max_mcast_ttl; /* the caps of the stream */ gulong caps_sig; @@ -182,7 +181,6 @@ struct _GstRTSPStreamPrivate #define DEFAULT_PROFILES GST_RTSP_PROFILE_AVP #define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \ GST_RTSP_LOWER_TRANS_TCP -#define DEFAULT_MAX_MCAST_TTL 255 enum { @@ -282,7 +280,6 @@ gst_rtsp_stream_init (GstRTSPStream * stream) priv->allowed_protocols = DEFAULT_PROTOCOLS; priv->configured_protocols = 0; priv->publish_clock_mode = GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK; - priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL; g_mutex_init (&priv->lock); @@ -1887,54 +1884,6 @@ gst_rtsp_stream_get_buffer_size (GstRTSPStream * stream) return buffer_size; } -/** - * gst_rtsp_stream_set_max_mcast_ttl: - * @stream: a #GstRTSPStream - * @ttl: the new multicast ttl value - * - * Set the maximum time-to-live value of outgoing multicast packets. - * - * Returns: %TRUE if the requested ttl has been set successfully. - * - */ -gboolean -gst_rtsp_stream_set_max_mcast_ttl (GstRTSPStream * stream, guint ttl) -{ - g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), FALSE); - - g_mutex_lock (&stream->priv->lock); - if (ttl == 0 || ttl > DEFAULT_MAX_MCAST_TTL) { - GST_WARNING_OBJECT (stream, "The reqested mcast TTL value is not valid."); - g_mutex_unlock (&stream->priv->lock); - return FALSE; - } - stream->priv->max_mcast_ttl = ttl; - g_mutex_unlock (&stream->priv->lock); - - return TRUE; -} - -/** - * gst_rtsp_stream_get_max_mcast_ttl: - * @stream: a #GstRTSPStream - * - * Get the the maximum time-to-live value of outgoing multicast packets. - * - * Returns: the maximum time-to-live value of outgoing multicast packets. - * - */ -guint -gst_rtsp_stream_get_max_mcast_ttl (GstRTSPStream * stream) -{ - guint ttl; - - g_mutex_lock (&stream->priv->lock); - ttl = stream->priv->max_mcast_ttl; - g_mutex_unlock (&stream->priv->lock); - - return ttl; -} - /* executed from streaming thread */ static void caps_notify (GstPad * pad, GParamSpec * unused, GstRTSPStream * stream) diff --git a/gst/rtsp-server/rtsp-stream.h b/gst/rtsp-server/rtsp-stream.h index 1ee146d..1f527a4 100644 --- a/gst/rtsp-server/rtsp-stream.h +++ b/gst/rtsp-server/rtsp-stream.h @@ -293,12 +293,6 @@ GST_RTSP_SERVER_API GstRTSPPublishClockMode gst_rtsp_stream_get_publish_clock_mode (GstRTSPStream * stream); GST_RTSP_SERVER_API -gboolean gst_rtsp_stream_set_max_mcast_ttl (GstRTSPStream *stream, guint ttl); - -GST_RTSP_SERVER_API -guint gst_rtsp_stream_get_max_mcast_ttl (GstRTSPStream *stream); - -GST_RTSP_SERVER_API gboolean gst_rtsp_stream_complete_stream (GstRTSPStream * stream, const GstRTSPTransport * transport); GST_RTSP_SERVER_API diff --git a/tests/check/gst/client.c b/tests/check/gst/client.c index ab95509..4adf3d1 100644 --- a/tests/check/gst/client.c +++ b/tests/check/gst/client.c @@ -525,6 +525,7 @@ test_setup_response_200_multicast (GstRTSPClient * client, session_pool = gst_rtsp_client_get_session_pool (client); fail_unless (session_pool != NULL); + fail_unless (gst_rtsp_session_pool_get_n_sessions (session_pool) == 1); session = gst_rtsp_session_pool_find (session_pool, session_hdr_params[0]); g_strfreev (session_hdr_params); @@ -726,6 +727,117 @@ GST_START_TEST (test_client_multicast_ignore_transport_specific) GST_END_TEST; +static gboolean +test_setup_response_461 (GstRTSPClient * client, + GstRTSPMessage * response, gboolean close, gpointer user_data) +{ + GstRTSPStatusCode code; + const gchar *reason; + GstRTSPVersion version; + gchar *str; + + fail_unless (expected_transport == NULL); + + fail_unless (gst_rtsp_message_get_type (response) == + GST_RTSP_MESSAGE_RESPONSE); + + fail_unless (gst_rtsp_message_parse_response (response, &code, &reason, + &version) + == GST_RTSP_OK); + fail_unless (code == GST_RTSP_STS_UNSUPPORTED_TRANSPORT); + fail_unless (g_str_equal (reason, "Unsupported transport")); + fail_unless (version == GST_RTSP_VERSION_1_0); + + fail_unless (gst_rtsp_message_get_header (response, GST_RTSP_HDR_CSEQ, &str, + 0) == GST_RTSP_OK); + fail_unless (atoi (str) == cseq++); + + + return TRUE; +} + +GST_START_TEST (test_client_multicast_invalid_transport_specific) +{ + GstRTSPClient *client; + GstRTSPMessage request = { 0, }; + gchar *str; + GstRTSPSessionPool *session_pool; + GstRTSPContext ctx = { NULL }; + + client = setup_multicast_client (); + + ctx.client = client; + ctx.auth = gst_rtsp_auth_new (); + ctx.token = + gst_rtsp_token_new (GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS, + G_TYPE_BOOLEAN, TRUE, GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING, + "user", NULL); + gst_rtsp_context_push_current (&ctx); + + /* simple SETUP with a valid URI and multicast, but an invalid ip */ + fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_SETUP, + "rtsp://localhost/test/stream=0") == GST_RTSP_OK); + str = g_strdup_printf ("%d", cseq); + gst_rtsp_message_take_header (&request, GST_RTSP_HDR_CSEQ, str); + gst_rtsp_message_add_header (&request, GST_RTSP_HDR_TRANSPORT, + "RTP/AVP;multicast;destination=233.252.0.2;ttl=1;port=5000-5001;"); + + gst_rtsp_client_set_send_func (client, test_setup_response_461, NULL, NULL); + fail_unless (gst_rtsp_client_handle_message (client, + &request) == GST_RTSP_OK); + gst_rtsp_message_unset (&request); + + session_pool = gst_rtsp_client_get_session_pool (client); + fail_unless (session_pool != NULL); + fail_unless (gst_rtsp_session_pool_get_n_sessions (session_pool) == 0); + g_object_unref (session_pool); + + + /* simple SETUP with a valid URI and multicast, but an invalid prt */ + fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_SETUP, + "rtsp://localhost/test/stream=0") == GST_RTSP_OK); + str = g_strdup_printf ("%d", cseq); + gst_rtsp_message_take_header (&request, GST_RTSP_HDR_CSEQ, str); + gst_rtsp_message_add_header (&request, GST_RTSP_HDR_TRANSPORT, + "RTP/AVP;multicast;destination=233.252.0.1;ttl=1;port=6000-6001;"); + + gst_rtsp_client_set_send_func (client, test_setup_response_461, NULL, NULL); + fail_unless (gst_rtsp_client_handle_message (client, + &request) == GST_RTSP_OK); + gst_rtsp_message_unset (&request); + + session_pool = gst_rtsp_client_get_session_pool (client); + fail_unless (session_pool != NULL); + fail_unless (gst_rtsp_session_pool_get_n_sessions (session_pool) == 0); + g_object_unref (session_pool); + + + /* simple SETUP with a valid URI and multicast, but an invalid ttl */ + fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_SETUP, + "rtsp://localhost/test/stream=0") == GST_RTSP_OK); + str = g_strdup_printf ("%d", cseq); + gst_rtsp_message_take_header (&request, GST_RTSP_HDR_CSEQ, str); + gst_rtsp_message_add_header (&request, GST_RTSP_HDR_TRANSPORT, + "RTP/AVP;multicast;destination=233.252.0.1;ttl=2;port=5000-5001;"); + + gst_rtsp_client_set_send_func (client, test_setup_response_461, NULL, NULL); + fail_unless (gst_rtsp_client_handle_message (client, + &request) == GST_RTSP_OK); + gst_rtsp_message_unset (&request); + + session_pool = gst_rtsp_client_get_session_pool (client); + fail_unless (session_pool != NULL); + fail_unless (gst_rtsp_session_pool_get_n_sessions (session_pool) == 0); + g_object_unref (session_pool); + + teardown_client (client); + g_object_unref (ctx.auth); + gst_rtsp_token_unref (ctx.token); + gst_rtsp_context_pop_current (&ctx); +} + +GST_END_TEST; + GST_START_TEST (test_client_multicast_transport_specific) { GstRTSPClient *client; @@ -747,7 +859,7 @@ GST_START_TEST (test_client_multicast_transport_specific) expected_transport = "RTP/AVP;multicast;destination=233.252.0.1;" "ttl=1;port=5000-5001;mode=\"PLAY\""; - /* simple SETUP with a valid URI */ + /* simple SETUP with a valid URI and multicast, but an invalid ip */ fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_SETUP, "rtsp://localhost/test/stream=0") == GST_RTSP_OK); str = g_strdup_printf ("%d", cseq); @@ -919,156 +1031,6 @@ GST_START_TEST (test_client_sdp_with_no_bitrate_tags) GST_END_TEST; -static void -mcast_transport_specific_two_clients (gboolean shared) -{ - GstRTSPClient *client, *client2; - GstRTSPMessage request = { 0, }; - gchar *str; - GstRTSPSessionPool *session_pool; - GstRTSPContext ctx = { NULL }; - GstRTSPContext ctx2 = { NULL }; - GstRTSPMountPoints *mount_points; - GstRTSPMediaFactory *factory; - GstRTSPAddressPool *address_pool; - GstRTSPThreadPool *thread_pool; - gchar *session_id1; - - mount_points = gst_rtsp_mount_points_new (); - factory = gst_rtsp_media_factory_new (); - if (shared) - gst_rtsp_media_factory_set_shared (factory, TRUE); - gst_rtsp_media_factory_set_max_mcast_ttl (factory, 5); - gst_rtsp_media_factory_set_launch (factory, - "audiotestsrc ! audio/x-raw,rate=44100 ! audioconvert ! rtpL16pay name=pay0"); - address_pool = gst_rtsp_address_pool_new (); - fail_unless (gst_rtsp_address_pool_add_range (address_pool, - "233.252.0.1", "233.252.0.1", 5000, 5001, 1)); - gst_rtsp_media_factory_set_address_pool (factory, address_pool); - gst_rtsp_media_factory_add_role (factory, "user", - "media.factory.access", G_TYPE_BOOLEAN, TRUE, - "media.factory.construct", G_TYPE_BOOLEAN, TRUE, NULL); - gst_rtsp_mount_points_add_factory (mount_points, "/test", factory); - session_pool = gst_rtsp_session_pool_new (); - thread_pool = gst_rtsp_thread_pool_new (); - - /* first multicast client with transport specific request */ - client = gst_rtsp_client_new (); - gst_rtsp_client_set_session_pool (client, session_pool); - gst_rtsp_client_set_mount_points (client, mount_points); - gst_rtsp_client_set_thread_pool (client, thread_pool); - - ctx.client = client; - ctx.auth = gst_rtsp_auth_new (); - ctx.token = - gst_rtsp_token_new (GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS, - G_TYPE_BOOLEAN, TRUE, GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING, - "user", NULL); - gst_rtsp_context_push_current (&ctx); - - expected_transport = "RTP/AVP;multicast;destination=233.252.0.1;" - "ttl=1;port=5000-5001;mode=\"PLAY\""; - - /* send SETUP request */ - fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_SETUP, - "rtsp://localhost/test/stream=0") == GST_RTSP_OK); - str = g_strdup_printf ("%d", cseq); - gst_rtsp_message_take_header (&request, GST_RTSP_HDR_CSEQ, str); - gst_rtsp_message_add_header (&request, GST_RTSP_HDR_TRANSPORT, - expected_transport); - - gst_rtsp_client_set_send_func (client, test_setup_response_200_multicast, - NULL, NULL); - fail_unless (gst_rtsp_client_handle_message (client, - &request) == GST_RTSP_OK); - gst_rtsp_message_unset (&request); - expected_transport = NULL; - - /* send PLAY request */ - fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_PLAY, - "rtsp://localhost/test") == GST_RTSP_OK); - str = g_strdup_printf ("%d", cseq); - gst_rtsp_message_take_header (&request, GST_RTSP_HDR_CSEQ, str); - gst_rtsp_message_add_header (&request, GST_RTSP_HDR_SESSION, session_id); - gst_rtsp_client_set_send_func (client, test_response_200, NULL, NULL); - fail_unless (gst_rtsp_client_handle_message (client, - &request) == GST_RTSP_OK); - gst_rtsp_message_unset (&request); - gst_rtsp_context_pop_current (&ctx); - session_id1 = session_id; - - /* second multicast client with transport specific request */ - cseq = 0; - client2 = gst_rtsp_client_new (); - gst_rtsp_client_set_session_pool (client2, session_pool); - gst_rtsp_client_set_mount_points (client2, mount_points); - gst_rtsp_client_set_thread_pool (client2, thread_pool); - - ctx2.client = client2; - ctx2.auth = gst_rtsp_auth_new (); - ctx2.token = - gst_rtsp_token_new (GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS, - G_TYPE_BOOLEAN, TRUE, GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING, - "user", NULL); - gst_rtsp_context_push_current (&ctx2); - - expected_transport = "RTP/AVP;multicast;destination=233.252.0.2;" - "ttl=1;port=5002-5003;mode=\"PLAY\""; - - /* send SETUP request */ - fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_SETUP, - "rtsp://localhost/test/stream=0") == GST_RTSP_OK); - str = g_strdup_printf ("%d", cseq); - gst_rtsp_message_take_header (&request, GST_RTSP_HDR_CSEQ, str); - gst_rtsp_message_add_header (&request, GST_RTSP_HDR_TRANSPORT, - expected_transport); - - gst_rtsp_client_set_send_func (client2, test_setup_response_200_multicast, - NULL, NULL); - fail_unless (gst_rtsp_client_handle_message (client2, - &request) == GST_RTSP_OK); - gst_rtsp_message_unset (&request); - expected_transport = NULL; - - /* send PLAY request */ - fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_PLAY, - "rtsp://localhost/test") == GST_RTSP_OK); - str = g_strdup_printf ("%d", cseq); - gst_rtsp_message_take_header (&request, GST_RTSP_HDR_CSEQ, str); - gst_rtsp_message_add_header (&request, GST_RTSP_HDR_SESSION, session_id); - gst_rtsp_client_set_send_func (client2, test_response_200, NULL, NULL); - fail_unless (gst_rtsp_client_handle_message (client2, - &request) == GST_RTSP_OK); - gst_rtsp_message_unset (&request); - - send_teardown (client2); - gst_rtsp_context_pop_current (&ctx2); - - gst_rtsp_context_push_current (&ctx); - session_id = session_id1; - send_teardown (client); - gst_rtsp_context_pop_current (&ctx); - - teardown_client (client); - teardown_client (client2); - g_object_unref (ctx.auth); - g_object_unref (ctx2.auth); - gst_rtsp_token_unref (ctx.token); - gst_rtsp_token_unref (ctx2.token); - g_object_unref (mount_points); - g_object_unref (session_pool); - g_object_unref (address_pool); - g_object_unref (thread_pool); -} - -/* test if two multicast clients can choose different transport settings */ -GST_START_TEST - (test_client_multicast_transport_specific_two_clients_shared_media) { - mcast_transport_specific_two_clients (TRUE); -} - -GST_END_TEST; - static Suite * rtspclient_suite (void) { @@ -1084,13 +1046,12 @@ rtspclient_suite (void) tcase_add_test (tc, test_client_multicast_transport_404); tcase_add_test (tc, test_client_multicast_transport); tcase_add_test (tc, test_client_multicast_ignore_transport_specific); + tcase_add_test (tc, test_client_multicast_invalid_transport_specific); tcase_add_test (tc, test_client_multicast_transport_specific); tcase_add_test (tc, test_client_sdp_with_max_bitrate_tag); tcase_add_test (tc, test_client_sdp_with_bitrate_tag); tcase_add_test (tc, test_client_sdp_with_max_bitrate_and_bitrate_tags); tcase_add_test (tc, test_client_sdp_with_no_bitrate_tags); - tcase_add_test (tc, - test_client_multicast_transport_specific_two_clients_shared_media); return s; } diff --git a/tests/check/gst/mediafactory.c b/tests/check/gst/mediafactory.c index ba1719e..b6b250b 100644 --- a/tests/check/gst/mediafactory.c +++ b/tests/check/gst/mediafactory.c @@ -314,63 +314,6 @@ GST_START_TEST (test_reset) GST_END_TEST; -GST_START_TEST (test_mcast_ttl) -{ - GstRTSPMediaFactory *factory; - GstElement *element; - GstRTSPMedia *media; - GstRTSPUrl *url; - GstRTSPStream *stream; - - factory = gst_rtsp_media_factory_new (); - gst_rtsp_media_factory_set_shared (factory, TRUE); - fail_unless (gst_rtsp_url_parse ("rtsp://localhost:8554/test", - &url) == GST_RTSP_OK); - - gst_rtsp_media_factory_set_launch (factory, - "( videotestsrc ! rtpvrawpay pt=96 name=pay0 " - " audiotestsrc ! audioconvert ! rtpL16pay name=pay1 )"); - - /* try to set an invalid ttl and make sure that the default ttl value (255) is - * set */ - gst_rtsp_media_factory_set_max_mcast_ttl (factory, 0); - fail_unless (gst_rtsp_media_factory_get_max_mcast_ttl (factory) == 255); - gst_rtsp_media_factory_set_max_mcast_ttl (factory, 300); - fail_unless (gst_rtsp_media_factory_get_max_mcast_ttl (factory) == 255); - - /* set a valid ttl value */ - gst_rtsp_media_factory_set_max_mcast_ttl (factory, 3); - fail_unless (gst_rtsp_media_factory_get_max_mcast_ttl (factory) == 3); - - element = gst_rtsp_media_factory_create_element (factory, url); - fail_unless (GST_IS_BIN (element)); - fail_if (GST_IS_PIPELINE (element)); - gst_object_unref (element); - - media = gst_rtsp_media_factory_construct (factory, url); - fail_unless (GST_IS_RTSP_MEDIA (media)); - - fail_unless (gst_rtsp_media_n_streams (media) == 2); - fail_unless (gst_rtsp_media_get_max_mcast_ttl (media) == 3); - - /* verify that the correct ttl value has been propageted to the media - * streams */ - stream = gst_rtsp_media_get_stream (media, 0); - fail_unless (stream != NULL); - fail_unless (gst_rtsp_stream_get_max_mcast_ttl (stream) == 3); - - stream = gst_rtsp_media_get_stream (media, 1); - fail_unless (stream != NULL); - fail_unless (gst_rtsp_stream_get_max_mcast_ttl (stream) == 3); - - g_object_unref (media); - - gst_rtsp_url_free (url); - g_object_unref (factory); -} - -GST_END_TEST; - static Suite * rtspmediafactory_suite (void) { @@ -386,7 +329,6 @@ rtspmediafactory_suite (void) tcase_add_test (tc, test_addresspool); tcase_add_test (tc, test_permissions); tcase_add_test (tc, test_reset); - tcase_add_test (tc, test_mcast_ttl); return s; }