2 * Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include <gst/check/gstcheck.h>
22 #include <rtsp-client.h>
27 test_option_response (GstRTSPClient * client, GstRTSPMessage * response,
28 gboolean close, gpointer user_data)
30 GstRTSPStatusCode code;
32 GstRTSPVersion version;
34 GstRTSPMethod methods;
36 fail_unless (gst_rtsp_message_get_type (response) ==
37 GST_RTSP_MESSAGE_RESPONSE);
39 gst_rtsp_message_dump (response);
40 fail_unless (gst_rtsp_message_parse_response (response, &code, &reason,
43 fail_unless (code == GST_RTSP_STS_OK);
44 fail_unless (g_str_equal (reason, "OK"));
45 fail_unless (version == GST_RTSP_VERSION_1_0);
47 fail_unless (gst_rtsp_message_get_header (response, GST_RTSP_HDR_CSEQ, &str,
49 fail_unless (atoi (str) == cseq++);
51 fail_unless (gst_rtsp_message_get_header (response, GST_RTSP_HDR_PUBLIC, &str,
54 methods = gst_rtsp_options_from_text (str);
55 fail_if (methods == 0);
56 fail_unless (methods == (GST_RTSP_DESCRIBE |
61 GST_RTSP_GET_PARAMETER | GST_RTSP_SET_PARAMETER | GST_RTSP_TEARDOWN));
66 GST_START_TEST (test_options)
68 GstRTSPClient *client;
69 GstRTSPMessage request = { 0, };
72 client = gst_rtsp_client_new ();
74 fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_OPTIONS,
75 "rtsp://localhost/test") == GST_RTSP_OK);
76 str = g_strdup_printf ("%d", cseq);
77 gst_rtsp_message_add_header (&request, GST_RTSP_HDR_CSEQ, str);
80 gst_rtsp_client_set_send_func (client, test_option_response, NULL, NULL);
81 gst_rtsp_message_dump (&request);
82 fail_unless (gst_rtsp_client_handle_message (client,
83 &request) == GST_RTSP_OK);
85 gst_rtsp_message_unset (&request);
87 g_object_unref (client);
93 rtspclient_suite (void)
95 Suite *s = suite_create ("rtspclient");
96 TCase *tc = tcase_create ("general");
98 suite_add_tcase (s, tc);
99 tcase_set_timeout (tc, 20);
100 tcase_add_test (tc, test_options);
105 GST_CHECK_MAIN (rtspclient);