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-media-factory.h>
24 GST_START_TEST (test_launch)
26 GstRTSPMediaFactory *factory;
29 GstRTSPStream *stream;
30 GstRTSPTimeRange *range;
33 factory = gst_rtsp_media_factory_new ();
34 fail_if (gst_rtsp_media_factory_is_shared (factory));
35 gst_rtsp_url_parse ("rtsp://localhost:8554/test", &url);
37 gst_rtsp_media_factory_set_launch (factory,
38 "( videotestsrc ! rtpvrawpay pt=96 name=pay0 )");
40 media = gst_rtsp_media_factory_construct (factory, url);
41 fail_unless (GST_IS_RTSP_MEDIA (media));
43 fail_unless (gst_rtsp_media_n_streams (media) == 1);
45 stream = gst_rtsp_media_get_stream (media, 0);
46 fail_unless (stream != NULL);
48 /* fails, need to be prepared */
49 str = gst_rtsp_media_get_range_string (media, FALSE);
50 fail_unless (str == NULL);
52 fail_unless (gst_rtsp_range_parse ("npt=5.0-", &range) == GST_RTSP_OK);
53 /* fails, need to be prepared */
54 fail_if (gst_rtsp_media_seek (media, range));
56 fail_unless (gst_rtsp_media_prepare (media));
58 str = gst_rtsp_media_get_range_string (media, FALSE);
59 fail_unless (g_str_equal (str, "npt=0-"));
62 str = gst_rtsp_media_get_range_string (media, TRUE);
63 fail_unless (g_str_equal (str, "npt=0-"));
66 fail_unless (gst_rtsp_media_seek (media, range));
68 str = gst_rtsp_media_get_range_string (media, FALSE);
69 fail_unless (g_str_equal (str, "npt=5-"));
72 str = gst_rtsp_media_get_range_string (media, TRUE);
73 fail_unless (g_str_equal (str, "npt=5-"));
76 fail_unless (gst_rtsp_media_unprepare (media));
78 /* should fail again */
79 str = gst_rtsp_media_get_range_string (media, FALSE);
80 fail_unless (str == NULL);
81 fail_if (gst_rtsp_media_seek (media, range));
83 gst_rtsp_range_free (range);
84 g_object_unref (media);
86 gst_rtsp_url_free (url);
87 g_object_unref (factory);
92 GST_START_TEST (test_media)
95 GstElement *bin, *e1, *e2;
97 bin = gst_bin_new ("bin");
98 fail_if (bin == NULL);
100 e1 = gst_element_factory_make ("videotestsrc", NULL);
101 fail_if (e1 == NULL);
103 e2 = gst_element_factory_make ("rtpvrawpay", "pay0");
104 fail_if (e2 == NULL);
105 g_object_set (e2, "pt", 96, NULL);
107 gst_bin_add_many (GST_BIN_CAST (bin), e1, e2, NULL);
108 gst_element_link_many (e1, e2, NULL);
110 media = gst_rtsp_media_new (bin);
111 fail_unless (GST_IS_RTSP_MEDIA (media));
112 g_object_unref (media);
118 rtspmedia_suite (void)
120 Suite *s = suite_create ("rtspmedia");
121 TCase *tc = tcase_create ("general");
123 suite_add_tcase (s, tc);
124 tcase_set_timeout (tc, 20);
125 tcase_add_test (tc, test_launch);
126 tcase_add_test (tc, test_media);
131 GST_CHECK_MAIN (rtspmedia);