summaryrefslogtreecommitdiff
path: root/tests/check/libs/rtsp.c
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2015-02-09 17:49:12 +0000
committerTim-Philipp Müller <tim@centricular.com>2015-02-09 17:50:32 +0000
commitef7f537a80d2d8813b169f5efe28bf7c7916b0d6 (patch)
tree006ecaf4cfc6db04c023c2a2dc8916840171f020 /tests/check/libs/rtsp.c
parent9b4ea3f5dde03ae37895616c603c6f8cadcc9b28 (diff)
tests: rtsp: add some unit tests for new GstRTSPMessage API
Diffstat (limited to 'tests/check/libs/rtsp.c')
-rw-r--r--tests/check/libs/rtsp.c93
1 files changed, 90 insertions, 3 deletions
diff --git a/tests/check/libs/rtsp.c b/tests/check/libs/rtsp.c
index c817c3f3c..68046ad75 100644
--- a/tests/check/libs/rtsp.c
+++ b/tests/check/libs/rtsp.c
@@ -1,6 +1,6 @@
/* GStreamer unit tests for the RTSP support library
- *
* Copyright (C) 2010 Andy Wingo <wingo@oblong.com>
+ * Copyright (C) 2015 Tim-Philipp Müller <tim@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -24,8 +24,7 @@
#include <gst/check/gstcheck.h>
-#include <gst/rtsp/gstrtspurl.h>
-#include <gst/rtsp/gstrtsprange.h>
+#include <gst/rtsp/rtsp.h>
#include <string.h>
GST_START_TEST (test_rtsp_url_basic)
@@ -539,6 +538,93 @@ GST_START_TEST (test_rtsp_range_convert)
GST_END_TEST;
+GST_START_TEST (test_rtsp_message)
+{
+ GstRTSPMessage *msg;
+ GstRTSPResult res;
+ gchar *val = NULL;
+
+ res = gst_rtsp_message_new_request (&msg, GST_RTSP_PLAY,
+ "rtsp://foo.bar:8554/test");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+
+ res = gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CSEQ, "3");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ res = gst_rtsp_message_add_header (msg, GST_RTSP_HDR_SERVER, "GStreamer");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ res = gst_rtsp_message_add_header (msg, GST_RTSP_HDR_TRANSPORT,
+ "RTP/AVP/TCP;unicast;interleaved=0-1");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ res = gst_rtsp_message_add_header (msg, GST_RTSP_HDR_SESSION, "xnb_NpaKEc");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+
+ res = gst_rtsp_message_add_header_by_name (msg, "FOO99-Version", "bar.0");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ res = gst_rtsp_message_add_header_by_name (msg, "Custom", "value");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ res = gst_rtsp_message_add_header_by_name (msg, "FOO99-Version", "bar.1");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ res = gst_rtsp_message_add_header_by_name (msg, "FOO99-Version", "bar.2");
+ fail_unless_equals_int (res, GST_RTSP_OK);
+
+ /* make sure fields added via enum work as well */
+ res = gst_rtsp_message_get_header_by_name (msg, "CSeq", &val, 0);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ fail_unless_equals_string (val, "3");
+ res = gst_rtsp_message_get_header_by_name (msg, "CSeq", &val, 1);
+ fail_unless_equals_int (res, GST_RTSP_ENOTIMPL);
+
+ res = gst_rtsp_message_get_header (msg, GST_RTSP_HDR_CSEQ, &val, 0);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ fail_unless_equals_string (val, "3");
+ res = gst_rtsp_message_get_header (msg, GST_RTSP_HDR_CSEQ, &val, 1);
+ fail_unless_equals_int (res, GST_RTSP_ENOTIMPL);
+
+ res = gst_rtsp_message_get_header_by_name (msg, "DoesNotExist", &val, 0);
+ fail_unless_equals_int (res, GST_RTSP_ENOTIMPL);
+
+ res = gst_rtsp_message_get_header_by_name (msg, "Custom", &val, 1);
+ fail_unless_equals_int (res, GST_RTSP_ENOTIMPL);
+ res = gst_rtsp_message_get_header_by_name (msg, "Custom", &val, 0);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ fail_unless_equals_string (val, "value");
+
+ res = gst_rtsp_message_get_header_by_name (msg, "FOO99-Version", &val, 3);
+ fail_unless_equals_int (res, GST_RTSP_ENOTIMPL);
+ res = gst_rtsp_message_get_header_by_name (msg, "FOO99-Version", &val, 1);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ fail_unless_equals_string (val, "bar.1");
+ res = gst_rtsp_message_get_header_by_name (msg, "FOO99-Version", &val, 2);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ fail_unless_equals_string (val, "bar.2");
+ res = gst_rtsp_message_get_header_by_name (msg, "FOO99-Version", &val, 0);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ fail_unless_equals_string (val, "bar.0");
+
+ res = gst_rtsp_message_remove_header_by_name (msg, "FOO99-Version", 3);
+ fail_unless_equals_int (res, GST_RTSP_ENOTIMPL);
+ res = gst_rtsp_message_remove_header_by_name (msg, "FOO99-Version", 1);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+
+ res = gst_rtsp_message_get_header_by_name (msg, "FOO99-Version", &val, 2);
+ fail_unless_equals_int (res, GST_RTSP_ENOTIMPL);
+
+ /* 2 shifted to position 1 */
+ res = gst_rtsp_message_get_header_by_name (msg, "FOO99-Version", &val, 1);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ fail_unless_equals_string (val, "bar.2");
+ res = gst_rtsp_message_get_header_by_name (msg, "FOO99-Version", &val, 0);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+ fail_unless_equals_string (val, "bar.0");
+
+ /* gst_rtsp_message_dump (msg); */
+
+ res = gst_rtsp_message_free (msg);
+ fail_unless_equals_int (res, GST_RTSP_OK);
+}
+
+GST_END_TEST;
+
static Suite *
rtsp_suite (void)
{
@@ -554,6 +640,7 @@ rtsp_suite (void)
tcase_add_test (tc_chain, test_rtsp_range_smpte);
tcase_add_test (tc_chain, test_rtsp_range_clock);
tcase_add_test (tc_chain, test_rtsp_range_convert);
+ tcase_add_test (tc_chain, test_rtsp_message);
return s;
}