diff options
author | Ognyan Tonchev <ognyan@axis.com> | 2014-07-09 14:19:10 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2014-07-09 16:17:00 +0200 |
commit | bfd498585a7fba9c9da91b18da8058204ce84afc (patch) | |
tree | 7f39ce7d358d41afc71042f69ad51a816371635c | |
parent | f78886e7cb6992a5d25098978e6edc62baeee32e (diff) |
client tests: send teardown to cleanup session
-rw-r--r-- | tests/check/gst/client.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/check/gst/client.c b/tests/check/gst/client.c index 6d8df97..1bbd67d 100644 --- a/tests/check/gst/client.c +++ b/tests/check/gst/client.c @@ -21,6 +21,7 @@ #include <rtsp-client.h> +static gchar * session_id; static gint cseq; static guint expected_session_timeout = 60; @@ -392,6 +393,10 @@ test_setup_response_200_multicast (GstRTSPClient * client, session = gst_rtsp_session_pool_find (session_pool, session_hdr_params[0]); g_strfreev (session_hdr_params); + /* remember session id to be able to send teardown */ + session_id = g_strdup (gst_rtsp_session_get_sessionid (session)); + fail_unless (session_id != NULL); + fail_unless (session != NULL); g_object_unref (session); @@ -401,6 +406,49 @@ test_setup_response_200_multicast (GstRTSPClient * client, return TRUE; } +static gboolean +test_teardown_response_200 (GstRTSPClient * client, + GstRTSPMessage * response, gboolean close, gpointer user_data) +{ + GstRTSPStatusCode code; + const gchar *reason; + GstRTSPVersion version; + + 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_OK); + fail_unless (g_str_equal (reason, "OK")); + fail_unless (version == GST_RTSP_VERSION_1_0); + + return TRUE; +} + +static void +send_teardown (GstRTSPClient * client) +{ + GstRTSPMessage request = { 0, }; + gchar *str; + + fail_unless (session_id != NULL); + fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_TEARDOWN, + "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_teardown_response_200, + NULL, NULL); + fail_unless (gst_rtsp_client_handle_message (client, + &request) == GST_RTSP_OK); + gst_rtsp_message_unset (&request); + g_free (session_id); + session_id = NULL; +} + static GstRTSPClient * setup_multicast_client (void) { @@ -503,6 +551,9 @@ GST_START_TEST (test_client_multicast_transport) gst_rtsp_message_unset (&request); expected_transport = NULL; expected_session_timeout = 60; + + send_teardown (client); + teardown_client (client); } @@ -534,6 +585,8 @@ GST_START_TEST (test_client_multicast_ignore_transport_specific) gst_rtsp_message_unset (&request); expected_transport = NULL; + send_teardown (client); + teardown_client (client); } @@ -699,6 +752,8 @@ GST_START_TEST (test_client_multicast_transport_specific) fail_unless (gst_rtsp_session_pool_get_n_sessions (session_pool) == 1); g_object_unref (session_pool); + send_teardown (client); + teardown_client (client); g_object_unref (ctx.auth); gst_rtsp_token_unref (ctx.token); |