mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-13 12:51:16 +00:00
a6367c5971
Removed port allocation test from the media suite. The port allocation failure is now in the stream suite. rtspserver: Make sure that the media is suspended after the DESCRIBE request before reconfiguring the UDP sinks. rtspclientsink: In the RECORD case we have to set async property to false for the appsink element in the test in order to make sure that the media pipeline doesn't hang in start_preroll(). https://bugzilla.gnome.org/show_bug.cgi?id=757488
237 lines
7.4 KiB
C
237 lines
7.4 KiB
C
/* GStreamer
|
|
* Copyright (C) 2013 Axis Communications AB <dev-gstreamer at axis dot com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
#include <rtsp-stream.h>
|
|
#include <rtsp-address-pool.h>
|
|
|
|
GST_START_TEST (test_get_sockets)
|
|
{
|
|
GstPad *srcpad;
|
|
GstElement *pay;
|
|
GstRTSPStream *stream;
|
|
GstBin *bin;
|
|
GstElement *rtpbin;
|
|
GstRTSPAddressPool *pool;
|
|
GSocket *socket;
|
|
gboolean have_ipv4;
|
|
gboolean have_ipv6;
|
|
GstRTSPTransport *tr;
|
|
|
|
srcpad = gst_pad_new ("testsrcpad", GST_PAD_SRC);
|
|
fail_unless (srcpad != NULL);
|
|
gst_pad_set_active (srcpad, TRUE);
|
|
pay = gst_element_factory_make ("rtpgstpay", "testpayloader");
|
|
fail_unless (pay != NULL);
|
|
stream = gst_rtsp_stream_new (0, pay, srcpad);
|
|
fail_unless (stream != NULL);
|
|
gst_object_unref (pay);
|
|
gst_object_unref (srcpad);
|
|
rtpbin = gst_element_factory_make ("rtpbin", "testrtpbin");
|
|
fail_unless (rtpbin != NULL);
|
|
bin = GST_BIN (gst_bin_new ("testbin"));
|
|
fail_unless (bin != NULL);
|
|
fail_unless (gst_bin_add (bin, rtpbin));
|
|
|
|
/* configure address pool for IPv4 and IPv6 unicast addresses */
|
|
pool = gst_rtsp_address_pool_new ();
|
|
fail_unless (gst_rtsp_address_pool_add_range (pool, GST_RTSP_ADDRESS_POOL_ANY_IPV4,
|
|
GST_RTSP_ADDRESS_POOL_ANY_IPV4, 50000, 60000, 0));
|
|
fail_unless (gst_rtsp_address_pool_add_range (pool, GST_RTSP_ADDRESS_POOL_ANY_IPV6,
|
|
GST_RTSP_ADDRESS_POOL_ANY_IPV6, 50000, 60000, 0));
|
|
gst_rtsp_stream_set_address_pool (stream, pool);
|
|
|
|
fail_unless (gst_rtsp_stream_join_bin (stream, bin, rtpbin, GST_STATE_NULL));
|
|
|
|
gst_rtsp_transport_new (&tr);
|
|
tr->lower_transport = GST_RTSP_LOWER_TRANS_UDP;
|
|
fail_unless (gst_rtsp_stream_allocate_udp_sockets (stream, G_SOCKET_FAMILY_IPV4,
|
|
tr, FALSE));
|
|
|
|
socket = gst_rtsp_stream_get_rtp_socket (stream, G_SOCKET_FAMILY_IPV4);
|
|
have_ipv4 = (socket != NULL);
|
|
if (have_ipv4) {
|
|
fail_unless (g_socket_get_fd (socket) >= 0);
|
|
g_object_unref (socket);
|
|
}
|
|
|
|
socket = gst_rtsp_stream_get_rtcp_socket (stream, G_SOCKET_FAMILY_IPV4);
|
|
if (have_ipv4) {
|
|
fail_unless (socket != NULL);
|
|
fail_unless (g_socket_get_fd (socket) >= 0);
|
|
g_object_unref (socket);
|
|
} else {
|
|
fail_unless (socket == NULL);
|
|
}
|
|
|
|
socket = gst_rtsp_stream_get_rtp_socket (stream, G_SOCKET_FAMILY_IPV6);
|
|
have_ipv6 = (socket != NULL);
|
|
if (have_ipv6) {
|
|
fail_unless (g_socket_get_fd (socket) >= 0);
|
|
g_object_unref (socket);
|
|
}
|
|
|
|
socket = gst_rtsp_stream_get_rtcp_socket (stream, G_SOCKET_FAMILY_IPV6);
|
|
if (have_ipv6) {
|
|
fail_unless (socket != NULL);
|
|
fail_unless (g_socket_get_fd (socket) >= 0);
|
|
g_object_unref (socket);
|
|
} else {
|
|
fail_unless (socket == NULL);
|
|
}
|
|
|
|
/* check that at least one family is available */
|
|
fail_unless (have_ipv4 || have_ipv6);
|
|
|
|
gst_rtsp_transport_free (tr);
|
|
g_object_unref (pool);
|
|
|
|
fail_unless (gst_rtsp_stream_leave_bin (stream, bin, rtpbin));
|
|
|
|
gst_object_unref (bin);
|
|
gst_object_unref (stream);
|
|
}
|
|
|
|
GST_END_TEST;
|
|
|
|
GST_START_TEST (test_allocate_udp_ports_fail)
|
|
{
|
|
GstPad *srcpad;
|
|
GstElement *pay;
|
|
GstRTSPStream *stream;
|
|
GstBin *bin;
|
|
GstElement *rtpbin;
|
|
GstRTSPAddressPool *pool;
|
|
GstRTSPTransport *tr;
|
|
|
|
srcpad = gst_pad_new ("testsrcpad", GST_PAD_SRC);
|
|
fail_unless (srcpad != NULL);
|
|
gst_pad_set_active (srcpad, TRUE);
|
|
pay = gst_element_factory_make ("rtpgstpay", "testpayloader");
|
|
fail_unless (pay != NULL);
|
|
stream = gst_rtsp_stream_new (0, pay, srcpad);
|
|
fail_unless (stream != NULL);
|
|
gst_object_unref (pay);
|
|
gst_object_unref (srcpad);
|
|
rtpbin = gst_element_factory_make ("rtpbin", "testrtpbin");
|
|
fail_unless (rtpbin != NULL);
|
|
bin = GST_BIN (gst_bin_new ("testbin"));
|
|
fail_unless (bin != NULL);
|
|
fail_unless (gst_bin_add (bin, rtpbin));
|
|
|
|
pool = gst_rtsp_address_pool_new ();
|
|
fail_unless (gst_rtsp_address_pool_add_range (pool, "192.168.1.1",
|
|
"192.168.1.1", 6000, 6001, 0));
|
|
gst_rtsp_stream_set_address_pool (stream, pool);
|
|
|
|
fail_unless (gst_rtsp_stream_join_bin (stream, bin, rtpbin, GST_STATE_NULL));
|
|
|
|
gst_rtsp_transport_new (&tr);
|
|
tr->lower_transport = GST_RTSP_LOWER_TRANS_UDP;
|
|
fail_if (gst_rtsp_stream_allocate_udp_sockets (stream, G_SOCKET_FAMILY_IPV4,
|
|
tr, FALSE));
|
|
|
|
gst_rtsp_transport_free (tr);
|
|
g_object_unref (pool);
|
|
fail_unless (gst_rtsp_stream_leave_bin (stream, bin, rtpbin));
|
|
gst_object_unref (bin);
|
|
gst_object_unref (stream);
|
|
}
|
|
|
|
GST_END_TEST;
|
|
|
|
GST_START_TEST (test_get_multicast_address)
|
|
{
|
|
GstPad *srcpad;
|
|
GstElement *pay;
|
|
GstRTSPStream *stream;
|
|
GstRTSPAddressPool *pool;
|
|
GstRTSPAddress *addr1;
|
|
GstRTSPAddress *addr2;
|
|
|
|
srcpad = gst_pad_new ("testsrcpad", GST_PAD_SRC);
|
|
fail_unless (srcpad != NULL);
|
|
gst_pad_set_active (srcpad, TRUE);
|
|
pay = gst_element_factory_make ("rtpgstpay", "testpayloader");
|
|
fail_unless (pay != NULL);
|
|
stream = gst_rtsp_stream_new (0, pay, srcpad);
|
|
fail_unless (stream != NULL);
|
|
gst_object_unref (pay);
|
|
gst_object_unref (srcpad);
|
|
|
|
pool = gst_rtsp_address_pool_new ();
|
|
fail_unless (gst_rtsp_address_pool_add_range (pool,
|
|
"233.252.0.0", "233.252.0.0", 5000, 5001, 1));
|
|
fail_unless (gst_rtsp_address_pool_add_range (pool,
|
|
"FF11:DB8::1", "FF11:DB8::1", 5002, 5003, 1));
|
|
gst_rtsp_stream_set_address_pool (stream, pool);
|
|
|
|
addr1 = gst_rtsp_stream_get_multicast_address (stream, G_SOCKET_FAMILY_IPV4);
|
|
fail_unless (addr1 != NULL);
|
|
fail_unless_equals_string (addr1->address, "233.252.0.0");
|
|
fail_unless_equals_int (addr1->port, 5000);
|
|
fail_unless_equals_int (addr1->n_ports, 2);
|
|
|
|
addr2 = gst_rtsp_stream_get_multicast_address (stream, G_SOCKET_FAMILY_IPV4);
|
|
fail_unless (addr2 != NULL);
|
|
fail_unless_equals_string (addr2->address, "233.252.0.0");
|
|
fail_unless_equals_int (addr2->port, 5000);
|
|
fail_unless_equals_int (addr2->n_ports, 2);
|
|
|
|
gst_rtsp_address_free (addr1);
|
|
gst_rtsp_address_free (addr2);
|
|
|
|
addr1 = gst_rtsp_stream_get_multicast_address (stream, G_SOCKET_FAMILY_IPV6);
|
|
fail_unless (addr1 != NULL);
|
|
fail_unless (!g_ascii_strcasecmp (addr1->address, "FF11:DB8::1"));
|
|
fail_unless_equals_int (addr1->port, 5002);
|
|
fail_unless_equals_int (addr1->n_ports, 2);
|
|
|
|
addr2 = gst_rtsp_stream_get_multicast_address (stream, G_SOCKET_FAMILY_IPV6);
|
|
fail_unless (addr2 != NULL);
|
|
fail_unless (!g_ascii_strcasecmp (addr2->address, "FF11:DB8::1"));
|
|
fail_unless_equals_int (addr2->port, 5002);
|
|
fail_unless_equals_int (addr2->n_ports, 2);
|
|
|
|
gst_rtsp_address_free (addr1);
|
|
gst_rtsp_address_free (addr2);
|
|
|
|
g_object_unref (pool);
|
|
|
|
gst_object_unref (stream);
|
|
}
|
|
|
|
GST_END_TEST;
|
|
|
|
static Suite *
|
|
rtspstream_suite (void)
|
|
{
|
|
Suite *s = suite_create ("rtspstream");
|
|
TCase *tc = tcase_create ("general");
|
|
|
|
suite_add_tcase (s, tc);
|
|
tcase_add_test (tc, test_get_sockets);
|
|
tcase_add_test (tc, test_allocate_udp_ports_fail);
|
|
tcase_add_test (tc, test_get_multicast_address);
|
|
|
|
return s;
|
|
}
|
|
|
|
GST_CHECK_MAIN (rtspstream);
|