mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
rtspserver: Add udp-mcast transport SETUP test
Refactor utility functions in the test file so they can handle more than UDP and TCP as lower transport. https://bugzilla.gnome.org/show_bug.cgi?id=756969
This commit is contained in:
parent
81ae320383
commit
2178a7c871
1 changed files with 88 additions and 105 deletions
|
@ -39,7 +39,6 @@
|
||||||
|
|
||||||
#define TEST_MOUNT_POINT "/test"
|
#define TEST_MOUNT_POINT "/test"
|
||||||
#define TEST_PROTO "RTP/AVP"
|
#define TEST_PROTO "RTP/AVP"
|
||||||
#define TEST_PROTO_TCP "RTP/AVP/TCP"
|
|
||||||
#define TEST_ENCODING "X-GST"
|
#define TEST_ENCODING "X-GST"
|
||||||
#define TEST_CLOCK_RATE "90000"
|
#define TEST_CLOCK_RATE "90000"
|
||||||
|
|
||||||
|
@ -155,6 +154,7 @@ start_server (void)
|
||||||
GstRTSPMountPoints *mounts;
|
GstRTSPMountPoints *mounts;
|
||||||
gchar *service;
|
gchar *service;
|
||||||
GstRTSPMediaFactory *factory;
|
GstRTSPMediaFactory *factory;
|
||||||
|
GstRTSPAddressPool *pool;
|
||||||
|
|
||||||
mounts = gst_rtsp_server_get_mount_points (server);
|
mounts = gst_rtsp_server_get_mount_points (server);
|
||||||
|
|
||||||
|
@ -165,6 +165,13 @@ start_server (void)
|
||||||
gst_rtsp_mount_points_add_factory (mounts, TEST_MOUNT_POINT, factory);
|
gst_rtsp_mount_points_add_factory (mounts, TEST_MOUNT_POINT, factory);
|
||||||
g_object_unref (mounts);
|
g_object_unref (mounts);
|
||||||
|
|
||||||
|
/* use an address pool for multicast */
|
||||||
|
pool = gst_rtsp_address_pool_new ();
|
||||||
|
gst_rtsp_address_pool_add_range (pool,
|
||||||
|
"224.3.0.0", "224.3.0.10", 5000, 5010, 16);
|
||||||
|
gst_rtsp_media_factory_set_address_pool (factory, pool);
|
||||||
|
gst_object_unref (pool);
|
||||||
|
|
||||||
/* set port to any */
|
/* set port to any */
|
||||||
gst_rtsp_server_set_service (server, "0");
|
gst_rtsp_server_set_service (server, "0");
|
||||||
|
|
||||||
|
@ -428,9 +435,9 @@ static GstSDPMessage *
|
||||||
do_describe (GstRTSPConnection * conn, const gchar * mount_point)
|
do_describe (GstRTSPConnection * conn, const gchar * mount_point)
|
||||||
{
|
{
|
||||||
GstSDPMessage *sdp_message;
|
GstSDPMessage *sdp_message;
|
||||||
gchar *content_type;
|
gchar *content_type = NULL;
|
||||||
gchar *content_base;
|
gchar *content_base = NULL;
|
||||||
gchar *body;
|
gchar *body = NULL;
|
||||||
gchar *address;
|
gchar *address;
|
||||||
gchar *expected_content_base;
|
gchar *expected_content_base;
|
||||||
|
|
||||||
|
@ -467,13 +474,13 @@ do_describe (GstRTSPConnection * conn, const gchar * mount_point)
|
||||||
* transport must be freed by the caller. */
|
* transport must be freed by the caller. */
|
||||||
static GstRTSPStatusCode
|
static GstRTSPStatusCode
|
||||||
do_setup_full (GstRTSPConnection * conn, const gchar * control,
|
do_setup_full (GstRTSPConnection * conn, const gchar * control,
|
||||||
gboolean use_tcp_transport, const GstRTSPRange * client_ports,
|
GstRTSPLowerTrans lower_transport, const GstRTSPRange * client_ports,
|
||||||
const gchar * require, gchar ** session, GstRTSPTransport ** transport,
|
const gchar * require, gchar ** session, GstRTSPTransport ** transport,
|
||||||
gchar ** unsupported)
|
gchar ** unsupported)
|
||||||
{
|
{
|
||||||
GstRTSPStatusCode code;
|
GstRTSPStatusCode code;
|
||||||
gchar *session_in = NULL;
|
gchar *session_in = NULL;
|
||||||
gchar *transport_string_in = NULL;
|
GString *transport_string_in = NULL;
|
||||||
gchar **session_out = NULL;
|
gchar **session_out = NULL;
|
||||||
gchar *transport_string_out = NULL;
|
gchar *transport_string_out = NULL;
|
||||||
|
|
||||||
|
@ -486,18 +493,35 @@ do_setup_full (GstRTSPConnection * conn, const gchar * control,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_tcp_transport) {
|
transport_string_in = g_string_new (TEST_PROTO);
|
||||||
transport_string_in = g_strdup_printf (TEST_PROTO_TCP ";unicast");
|
switch (lower_transport) {
|
||||||
} else {
|
case GST_RTSP_LOWER_TRANS_UDP:
|
||||||
transport_string_in =
|
transport_string_in =
|
||||||
g_strdup_printf (TEST_PROTO ";unicast;client_port=%d-%d",
|
g_string_append (transport_string_in, "/UDP;unicast");
|
||||||
|
break;
|
||||||
|
case GST_RTSP_LOWER_TRANS_UDP_MCAST:
|
||||||
|
transport_string_in =
|
||||||
|
g_string_append (transport_string_in, "/UDP;multicast");
|
||||||
|
break;
|
||||||
|
case GST_RTSP_LOWER_TRANS_TCP:
|
||||||
|
transport_string_in =
|
||||||
|
g_string_append (transport_string_in, "/TCP;unicast");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client_ports) {
|
||||||
|
g_string_append_printf (transport_string_in, ";client_port=%d-%d",
|
||||||
client_ports->min, client_ports->max);
|
client_ports->min, client_ports->max);
|
||||||
}
|
}
|
||||||
|
|
||||||
code =
|
code =
|
||||||
do_request_full (conn, GST_RTSP_SETUP, control, session_in,
|
do_request_full (conn, GST_RTSP_SETUP, control, session_in,
|
||||||
transport_string_in, NULL, require, NULL, NULL, NULL, session_out,
|
transport_string_in->str, NULL, require, NULL, NULL, NULL, session_out,
|
||||||
&transport_string_out, NULL, unsupported);
|
&transport_string_out, NULL, unsupported);
|
||||||
g_free (transport_string_in);
|
g_string_free (transport_string_in, TRUE);
|
||||||
|
|
||||||
if (transport_string_out) {
|
if (transport_string_out) {
|
||||||
/* create transport */
|
/* create transport */
|
||||||
|
@ -519,20 +543,8 @@ do_setup (GstRTSPConnection * conn, const gchar * control,
|
||||||
const GstRTSPRange * client_ports, gchar ** session,
|
const GstRTSPRange * client_ports, gchar ** session,
|
||||||
GstRTSPTransport ** transport)
|
GstRTSPTransport ** transport)
|
||||||
{
|
{
|
||||||
return do_setup_full (conn, control, FALSE, client_ports, NULL, session,
|
return do_setup_full (conn, control, GST_RTSP_LOWER_TRANS_UDP, client_ports,
|
||||||
transport, NULL);
|
NULL, session, transport, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
/* send a SETUP request and receive response. if *session is not NULL,
|
|
||||||
* it is used in the request. otherwise, *session is set to a returned
|
|
||||||
* session string that must be freed by the caller. the returned
|
|
||||||
* transport must be freed by the caller. */
|
|
||||||
static GstRTSPStatusCode
|
|
||||||
do_setup_tcp (GstRTSPConnection * conn, const gchar * control,
|
|
||||||
gchar ** session, GstRTSPTransport ** transport)
|
|
||||||
{
|
|
||||||
return do_setup_full (conn, control, TRUE, NULL, NULL, session, transport,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fixture setup function */
|
/* fixture setup function */
|
||||||
|
@ -670,14 +682,15 @@ GST_START_TEST (test_describe_non_existing_mount_point)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_setup)
|
static void
|
||||||
|
do_test_setup (GstRTSPLowerTrans lower_transport)
|
||||||
{
|
{
|
||||||
GstRTSPConnection *conn;
|
GstRTSPConnection *conn;
|
||||||
GstSDPMessage *sdp_message = NULL;
|
GstSDPMessage *sdp_message = NULL;
|
||||||
const GstSDPMedia *sdp_media;
|
const GstSDPMedia *sdp_media;
|
||||||
const gchar *video_control;
|
const gchar *video_control;
|
||||||
const gchar *audio_control;
|
const gchar *audio_control;
|
||||||
GstRTSPRange client_ports;
|
GstRTSPRange client_ports = { 0 };
|
||||||
gchar *session = NULL;
|
gchar *session = NULL;
|
||||||
GstRTSPTransport *video_transport = NULL;
|
GstRTSPTransport *video_transport = NULL;
|
||||||
GstRTSPTransport *audio_transport = NULL;
|
GstRTSPTransport *audio_transport = NULL;
|
||||||
|
@ -698,26 +711,28 @@ GST_START_TEST (test_setup)
|
||||||
get_client_ports (&client_ports);
|
get_client_ports (&client_ports);
|
||||||
|
|
||||||
/* send SETUP request for video */
|
/* send SETUP request for video */
|
||||||
fail_unless (do_setup (conn, video_control, &client_ports, &session,
|
fail_unless (do_setup_full (conn, video_control, lower_transport,
|
||||||
&video_transport) == GST_RTSP_STS_OK);
|
&client_ports, NULL, &session, &video_transport,
|
||||||
|
NULL) == GST_RTSP_STS_OK);
|
||||||
GST_DEBUG ("set up video %s, got session '%s'", video_control, session);
|
GST_DEBUG ("set up video %s, got session '%s'", video_control, session);
|
||||||
|
|
||||||
/* check response from SETUP */
|
/* check response from SETUP */
|
||||||
fail_unless (video_transport->trans == GST_RTSP_TRANS_RTP);
|
fail_unless (video_transport->trans == GST_RTSP_TRANS_RTP);
|
||||||
fail_unless (video_transport->profile == GST_RTSP_PROFILE_AVP);
|
fail_unless (video_transport->profile == GST_RTSP_PROFILE_AVP);
|
||||||
fail_unless (video_transport->lower_transport == GST_RTSP_LOWER_TRANS_UDP);
|
fail_unless (video_transport->lower_transport == lower_transport);
|
||||||
fail_unless (video_transport->mode_play);
|
fail_unless (video_transport->mode_play);
|
||||||
gst_rtsp_transport_free (video_transport);
|
gst_rtsp_transport_free (video_transport);
|
||||||
|
|
||||||
/* send SETUP request for audio */
|
/* send SETUP request for audio */
|
||||||
fail_unless (do_setup (conn, audio_control, &client_ports, &session,
|
fail_unless (do_setup_full (conn, audio_control, lower_transport,
|
||||||
&audio_transport) == GST_RTSP_STS_OK);
|
&client_ports, NULL, &session, &audio_transport,
|
||||||
|
NULL) == GST_RTSP_STS_OK);
|
||||||
GST_DEBUG ("set up audio %s with session '%s'", audio_control, session);
|
GST_DEBUG ("set up audio %s with session '%s'", audio_control, session);
|
||||||
|
|
||||||
/* check response from SETUP */
|
/* check response from SETUP */
|
||||||
fail_unless (audio_transport->trans == GST_RTSP_TRANS_RTP);
|
fail_unless (audio_transport->trans == GST_RTSP_TRANS_RTP);
|
||||||
fail_unless (audio_transport->profile == GST_RTSP_PROFILE_AVP);
|
fail_unless (audio_transport->profile == GST_RTSP_PROFILE_AVP);
|
||||||
fail_unless (audio_transport->lower_transport == GST_RTSP_LOWER_TRANS_UDP);
|
fail_unless (audio_transport->lower_transport == lower_transport);
|
||||||
fail_unless (audio_transport->mode_play);
|
fail_unless (audio_transport->mode_play);
|
||||||
gst_rtsp_transport_free (audio_transport);
|
gst_rtsp_transport_free (audio_transport);
|
||||||
|
|
||||||
|
@ -733,66 +748,23 @@ GST_START_TEST (test_setup)
|
||||||
iterate ();
|
iterate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_START_TEST (test_setup_udp)
|
||||||
|
{
|
||||||
|
do_test_setup (GST_RTSP_LOWER_TRANS_UDP);
|
||||||
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_setup_tcp)
|
GST_START_TEST (test_setup_tcp)
|
||||||
{
|
{
|
||||||
GstRTSPConnection *conn;
|
do_test_setup (GST_RTSP_LOWER_TRANS_TCP);
|
||||||
GstSDPMessage *sdp_message = NULL;
|
}
|
||||||
const GstSDPMedia *sdp_media;
|
|
||||||
const gchar *video_control;
|
|
||||||
const gchar *audio_control;
|
|
||||||
gchar *session = NULL;
|
|
||||||
GstRTSPTransport *video_transport = NULL;
|
|
||||||
GstRTSPTransport *audio_transport = NULL;
|
|
||||||
|
|
||||||
start_server ();
|
GST_END_TEST;
|
||||||
|
|
||||||
conn = connect_to_server (test_port, TEST_MOUNT_POINT);
|
GST_START_TEST (test_setup_udp_mcast)
|
||||||
|
{
|
||||||
sdp_message = do_describe (conn, TEST_MOUNT_POINT);
|
do_test_setup (GST_RTSP_LOWER_TRANS_UDP_MCAST);
|
||||||
|
|
||||||
/* get control strings from DESCRIBE response */
|
|
||||||
fail_unless (gst_sdp_message_medias_len (sdp_message) == 2);
|
|
||||||
sdp_media = gst_sdp_message_get_media (sdp_message, 0);
|
|
||||||
video_control = gst_sdp_media_get_attribute_val (sdp_media, "control");
|
|
||||||
sdp_media = gst_sdp_message_get_media (sdp_message, 1);
|
|
||||||
audio_control = gst_sdp_media_get_attribute_val (sdp_media, "control");
|
|
||||||
|
|
||||||
/* send SETUP request for video */
|
|
||||||
fail_unless (do_setup_tcp (conn, video_control, &session,
|
|
||||||
&video_transport) == GST_RTSP_STS_OK);
|
|
||||||
GST_DEBUG ("set up video %s, got session '%s'", video_control, session);
|
|
||||||
|
|
||||||
/* check response from SETUP */
|
|
||||||
fail_unless (video_transport->trans == GST_RTSP_TRANS_RTP);
|
|
||||||
fail_unless (video_transport->profile == GST_RTSP_PROFILE_AVP);
|
|
||||||
fail_unless (video_transport->lower_transport == GST_RTSP_LOWER_TRANS_TCP);
|
|
||||||
fail_unless (video_transport->mode_play);
|
|
||||||
gst_rtsp_transport_free (video_transport);
|
|
||||||
|
|
||||||
/* send SETUP request for audio */
|
|
||||||
fail_unless (do_setup_tcp (conn, audio_control, &session,
|
|
||||||
&audio_transport) == GST_RTSP_STS_OK);
|
|
||||||
GST_DEBUG ("set up audio %s with session '%s'", audio_control, session);
|
|
||||||
|
|
||||||
/* check response from SETUP */
|
|
||||||
fail_unless (audio_transport->trans == GST_RTSP_TRANS_RTP);
|
|
||||||
fail_unless (audio_transport->profile == GST_RTSP_PROFILE_AVP);
|
|
||||||
fail_unless (audio_transport->lower_transport == GST_RTSP_LOWER_TRANS_TCP);
|
|
||||||
fail_unless (audio_transport->mode_play);
|
|
||||||
gst_rtsp_transport_free (audio_transport);
|
|
||||||
|
|
||||||
/* send TEARDOWN request and check that we get 200 OK */
|
|
||||||
fail_unless (do_simple_request (conn, GST_RTSP_TEARDOWN,
|
|
||||||
session) == GST_RTSP_STS_OK);
|
|
||||||
|
|
||||||
/* clean up and iterate so the clean-up can finish */
|
|
||||||
g_free (session);
|
|
||||||
gst_sdp_message_free (sdp_message);
|
|
||||||
gst_rtsp_connection_free (conn);
|
|
||||||
stop_server ();
|
|
||||||
iterate ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
@ -894,17 +866,18 @@ GST_START_TEST (test_setup_with_require_header)
|
||||||
get_client_ports (&client_ports);
|
get_client_ports (&client_ports);
|
||||||
|
|
||||||
/* send SETUP request for video, with single Require header */
|
/* send SETUP request for video, with single Require header */
|
||||||
fail_unless_equals_int (do_setup_full (conn, video_control, FALSE,
|
fail_unless_equals_int (do_setup_full (conn, video_control,
|
||||||
&client_ports, "funky-feature", &session, &video_transport,
|
GST_RTSP_LOWER_TRANS_UDP, &client_ports, "funky-feature", &session,
|
||||||
&unsupported), GST_RTSP_STS_OPTION_NOT_SUPPORTED);
|
&video_transport, &unsupported), GST_RTSP_STS_OPTION_NOT_SUPPORTED);
|
||||||
fail_unless_equals_string (unsupported, "funky-feature");
|
fail_unless_equals_string (unsupported, "funky-feature");
|
||||||
g_free (unsupported);
|
g_free (unsupported);
|
||||||
unsupported = NULL;
|
unsupported = NULL;
|
||||||
|
|
||||||
/* send SETUP request for video, with multiple Require headers */
|
/* send SETUP request for video, with multiple Require headers */
|
||||||
fail_unless_equals_int (do_setup_full (conn, video_control, FALSE,
|
fail_unless_equals_int (do_setup_full (conn, video_control,
|
||||||
&client_ports, "funky-feature, foo-bar, superburst", &session,
|
GST_RTSP_LOWER_TRANS_UDP, &client_ports,
|
||||||
&video_transport, &unsupported), GST_RTSP_STS_OPTION_NOT_SUPPORTED);
|
"funky-feature, foo-bar, superburst", &session, &video_transport,
|
||||||
|
&unsupported), GST_RTSP_STS_OPTION_NOT_SUPPORTED);
|
||||||
fail_unless_equals_string (unsupported, "funky-feature, foo-bar, superburst");
|
fail_unless_equals_string (unsupported, "funky-feature, foo-bar, superburst");
|
||||||
g_free (unsupported);
|
g_free (unsupported);
|
||||||
unsupported = NULL;
|
unsupported = NULL;
|
||||||
|
@ -1034,7 +1007,7 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_test_play (const gchar * range)
|
do_test_play_full (const gchar * range, GstRTSPLowerTrans lower_transport)
|
||||||
{
|
{
|
||||||
GstRTSPConnection *conn;
|
GstRTSPConnection *conn;
|
||||||
GstSDPMessage *sdp_message = NULL;
|
GstSDPMessage *sdp_message = NULL;
|
||||||
|
@ -1062,10 +1035,12 @@ do_test_play (const gchar * range)
|
||||||
get_client_ports_full (&client_port, &rtp_socket, &rtcp_socket);
|
get_client_ports_full (&client_port, &rtp_socket, &rtcp_socket);
|
||||||
|
|
||||||
/* do SETUP for video and audio */
|
/* do SETUP for video and audio */
|
||||||
fail_unless (do_setup (conn, video_control, &client_port, &session,
|
fail_unless (do_setup_full (conn, video_control, lower_transport,
|
||||||
&video_transport) == GST_RTSP_STS_OK);
|
&client_port, NULL, &session, &video_transport,
|
||||||
fail_unless (do_setup (conn, audio_control, &client_port, &session,
|
NULL) == GST_RTSP_STS_OK);
|
||||||
&audio_transport) == GST_RTSP_STS_OK);
|
fail_unless (do_setup_full (conn, audio_control, lower_transport,
|
||||||
|
&client_port, NULL, &session, &audio_transport,
|
||||||
|
NULL) == GST_RTSP_STS_OK);
|
||||||
|
|
||||||
/* send PLAY request and check that we get 200 OK */
|
/* send PLAY request and check that we get 200 OK */
|
||||||
fail_unless (do_request (conn, GST_RTSP_PLAY, NULL, session, NULL, range,
|
fail_unless (do_request (conn, GST_RTSP_PLAY, NULL, session, NULL, range,
|
||||||
|
@ -1096,6 +1071,11 @@ do_test_play (const gchar * range)
|
||||||
gst_rtsp_connection_free (conn);
|
gst_rtsp_connection_free (conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_test_play (const gchar * range)
|
||||||
|
{
|
||||||
|
do_test_play_full (range, GST_RTSP_LOWER_TRANS_UDP);
|
||||||
|
}
|
||||||
|
|
||||||
GST_START_TEST (test_play)
|
GST_START_TEST (test_play)
|
||||||
{
|
{
|
||||||
|
@ -1329,10 +1309,12 @@ GST_START_TEST (test_play_multithreaded_timeout_client)
|
||||||
get_client_ports (&client_port);
|
get_client_ports (&client_port);
|
||||||
|
|
||||||
/* do SETUP for video and audio */
|
/* do SETUP for video and audio */
|
||||||
fail_unless (do_setup (conn, video_control, &client_port, &session,
|
fail_unless (do_setup_full (conn, video_control, GST_RTSP_LOWER_TRANS_UDP,
|
||||||
&video_transport) == GST_RTSP_STS_OK);
|
&client_port, NULL, &session, &video_transport,
|
||||||
fail_unless (do_setup (conn, audio_control, &client_port, &session,
|
NULL) == GST_RTSP_STS_OK);
|
||||||
&audio_transport) == GST_RTSP_STS_OK);
|
fail_unless (do_setup_full (conn, audio_control, GST_RTSP_LOWER_TRANS_UDP,
|
||||||
|
&client_port, NULL, &session, &audio_transport,
|
||||||
|
NULL) == GST_RTSP_STS_OK);
|
||||||
|
|
||||||
fail_unless (gst_rtsp_session_pool_get_n_sessions (pool) == 1);
|
fail_unless (gst_rtsp_session_pool_get_n_sessions (pool) == 1);
|
||||||
|
|
||||||
|
@ -1923,8 +1905,9 @@ rtspserver_suite (void)
|
||||||
tcase_add_test (tc, test_describe);
|
tcase_add_test (tc, test_describe);
|
||||||
tcase_add_test (tc, test_describe_non_existing_mount_point);
|
tcase_add_test (tc, test_describe_non_existing_mount_point);
|
||||||
tcase_add_test (tc, test_describe_record_media);
|
tcase_add_test (tc, test_describe_record_media);
|
||||||
tcase_add_test (tc, test_setup);
|
tcase_add_test (tc, test_setup_udp);
|
||||||
tcase_add_test (tc, test_setup_tcp);
|
tcase_add_test (tc, test_setup_tcp);
|
||||||
|
tcase_add_test (tc, test_setup_udp_mcast);
|
||||||
tcase_add_test (tc, test_setup_twice);
|
tcase_add_test (tc, test_setup_twice);
|
||||||
tcase_add_test (tc, test_setup_with_require_header);
|
tcase_add_test (tc, test_setup_with_require_header);
|
||||||
tcase_add_test (tc, test_setup_non_existing_stream);
|
tcase_add_test (tc, test_setup_non_existing_stream);
|
||||||
|
|
Loading…
Reference in a new issue