summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHavard Graff <havard.graff@gmail.com>2015-07-22 09:47:22 +0200
committerOlivier CrĂȘte <olivier.crete@collabora.com>2015-10-02 17:39:06 -0400
commitd5e26ab9099e5a46eda7e9b59f01c1efe463344d (patch)
tree38880a1eccda4bc20f3dd78f9d01c45dbdf59646 /tests
parent41a82b9706e8923a10803bdebe816dc4dfce9e18 (diff)
downloadgstreamer-plugins-good-d5e26ab9099e5a46eda7e9b59f01c1efe463344d.tar.gz
gstrtpmux: allow the ssrc-property to decide ssrc on outgoing buffers
By not doing this, the muxer is not effectively a rtpmuxer, rather a funnel, since it should be a single stream that exists the muxer. If not specified, take the first ssrc seen on a sinkpad, allowing upstream to decide ssrc in "passthrough" with only one sinkpad. Also, let downstream ssrc overrule internal configured one We hence has the following order for determining the ssrc used by rtpmux: 0. Suggestion from GstRTPCollision event 1. Downstream caps 2. ssrc-Property 3. (First) upstream caps containing ssrc 4. Randomly generated https://bugzilla.gnome.org/show_bug.cgi?id=752694
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/rtpmux.c211
1 files changed, 194 insertions, 17 deletions
diff --git a/tests/check/elements/rtpmux.c b/tests/check/elements/rtpmux.c
index 36b58e618..6f83c0810 100644
--- a/tests/check/elements/rtpmux.c
+++ b/tests/check/elements/rtpmux.c
@@ -61,6 +61,15 @@ query_func (GstPad * pad, GstObject * noparent, GstQuery * query)
return TRUE;
}
+static GstCaps *
+remove_ssrc_from_caps (GstCaps * caps)
+{
+ GstCaps *copy = gst_caps_copy (caps);
+ GstStructure *s = gst_caps_get_structure (copy, 0);
+ gst_structure_remove_field (s, "ssrc");
+ return copy;
+}
+
static gboolean
event_func (GstPad * pad, GstObject * noparent, GstEvent * event)
{
@@ -69,12 +78,20 @@ event_func (GstPad * pad, GstObject * noparent, GstEvent * event)
{
GstCaps *caps;
GstCaps **caps2 = g_object_get_data (G_OBJECT (pad), "caps");
+ GstCaps *caps_no_ssrc;
+ GstCaps *caps2_no_ssrc;
gst_event_parse_caps (event, &caps);
+ caps_no_ssrc = remove_ssrc_from_caps (caps);
+ caps2_no_ssrc = remove_ssrc_from_caps (*caps2);
+
fail_unless (caps2 != NULL && *caps2 != NULL);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_caps_is_fixed (*caps2));
- fail_unless (gst_caps_is_equal_fixed (caps, *caps2));
+
+ fail_unless (gst_caps_is_equal_fixed (caps_no_ssrc, caps2_no_ssrc));
+ gst_caps_unref (caps_no_ssrc);
+ gst_caps_unref (caps2_no_ssrc);
break;
}
default:
@@ -137,7 +154,6 @@ test_basic (const gchar * elem_name, const gchar * sink2, int count,
gst_caps_set_simple (src2caps, "clock-rate", G_TYPE_INT, 3, NULL);
caps = gst_pad_peer_query_caps (src1, NULL);
- fail_unless (gst_caps_is_equal (caps, sinkcaps));
gst_caps_unref (caps);
g_object_set (rtpmux, "seqnum-offset", 100, "timestamp-offset", 1000,
@@ -231,10 +247,10 @@ basic_check_cb (GstPad * pad, int i)
fail_unless (buffers && g_list_length (buffers) == 1);
gst_rtp_buffer_map (buffers->data, GST_MAP_READ, &rtpbuffer);
- fail_unless (gst_rtp_buffer_get_ssrc (&rtpbuffer) == 66);
- fail_unless (gst_rtp_buffer_get_timestamp (&rtpbuffer) ==
- 200 - 57 + 1000 + i);
- fail_unless (gst_rtp_buffer_get_seq (&rtpbuffer) == 100 + 1 + i);
+ fail_unless_equals_int (66, gst_rtp_buffer_get_ssrc (&rtpbuffer));
+ fail_unless_equals_int64 (200 - 57 + 1000 + i,
+ gst_rtp_buffer_get_timestamp (&rtpbuffer));
+ fail_unless_equals_int (100 + 1 + i, gst_rtp_buffer_get_seq (&rtpbuffer));
gst_rtp_buffer_unmap (&rtpbuffer);
}
@@ -265,10 +281,10 @@ lock_check_cb (GstPad * pad, int i)
fail_unless (buffers && g_list_length (buffers) == 1);
gst_rtp_buffer_map (buffers->data, GST_MAP_READ, &rtpbuffer);
- fail_unless (gst_rtp_buffer_get_ssrc (&rtpbuffer) == 66);
- fail_unless (gst_rtp_buffer_get_timestamp (&rtpbuffer) ==
- 200 - 57 + 1000 + i);
- fail_unless (gst_rtp_buffer_get_seq (&rtpbuffer) == 100 + 1 + i);
+ fail_unless_equals_int (66, gst_rtp_buffer_get_ssrc (&rtpbuffer));
+ fail_unless_equals_int64 (200 - 57 + 1000 + i,
+ gst_rtp_buffer_get_timestamp (&rtpbuffer));
+ fail_unless_equals_int (100 + 1 + i, gst_rtp_buffer_get_seq (&rtpbuffer));
gst_rtp_buffer_unmap (&rtpbuffer);
inbuf = gst_rtp_buffer_new_allocate (10, 0, 0);
@@ -325,16 +341,147 @@ generate_test_buffer (guint seq_num, guint ssrc)
return buf;
}
-GST_START_TEST (test_rtpmux_ssrc)
+static guint32
+_rtp_buffer_get_ssrc (GstBuffer * buf)
+{
+ GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
+ guint32 ret;
+ g_assert (gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp));
+ ret = gst_rtp_buffer_get_ssrc (&rtp);
+ gst_rtp_buffer_unmap (&rtp);
+ return ret;
+}
+
+GST_START_TEST (test_rtpmux_ssrc_property)
+{
+ GstHarness *h = gst_harness_new_with_padnames ("rtpmux", NULL, "src");
+ GstHarness *h0 = gst_harness_new_with_element (h->element, "sink_0", NULL);
+ GstHarness *h1 = gst_harness_new_with_element (h->element, "sink_1", NULL);
+ GstBuffer *buf0;
+ GstBuffer *buf1;
+
+ /* set ssrc to 111111 */
+ g_object_set (h->element, "ssrc", 111111, NULL);
+
+ /* both sinkpads have their own idea of what the ssrc should be */
+ gst_harness_set_src_caps_str (h0, "application/x-rtp, ssrc=(uint)222222");
+ gst_harness_set_src_caps_str (h1, "application/x-rtp, ssrc=(uint)333333");
+
+ /* push on both sinkpads with different ssrc */
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h0, generate_test_buffer (0, 222222)));
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h1, generate_test_buffer (0, 333333)));
+
+ buf0 = gst_harness_pull (h);
+ buf1 = gst_harness_pull (h);
+
+ /* we expect the ssrc to be what we specified in the property */
+ fail_unless_equals_int (111111, _rtp_buffer_get_ssrc (buf0));
+ fail_unless_equals_int (111111, _rtp_buffer_get_ssrc (buf1));
+
+ gst_buffer_unref (buf0);
+ gst_buffer_unref (buf1);
+
+ gst_harness_teardown (h0);
+ gst_harness_teardown (h1);
+ gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_rtpmux_ssrc_property_not_set)
+{
+ GstHarness *h = gst_harness_new_with_padnames ("rtpmux", NULL, "src");
+ GstHarness *h0 = gst_harness_new_with_element (h->element, "sink_0", NULL);
+ GstHarness *h1 = gst_harness_new_with_element (h->element, "sink_1", NULL);
+ GstBuffer *buf0;
+ GstBuffer *buf1;
+
+ gst_harness_set_src_caps_str (h0, "application/x-rtp, ssrc=(uint)222222");
+ gst_harness_set_src_caps_str (h1, "application/x-rtp, ssrc=(uint)333333");
+
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h0, generate_test_buffer (0, 222222)));
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h1, generate_test_buffer (0, 333333)));
+
+ buf0 = gst_harness_pull (h);
+ buf1 = gst_harness_pull (h);
+
+ /* we expect the ssrc to be the first ssrc that came in */
+ fail_unless_equals_int (222222, _rtp_buffer_get_ssrc (buf0));
+ fail_unless_equals_int (222222, _rtp_buffer_get_ssrc (buf1));
+
+ gst_buffer_unref (buf0);
+ gst_buffer_unref (buf1);
+
+ gst_harness_teardown (h0);
+ gst_harness_teardown (h1);
+ gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_rtpmux_ssrc_downstream_can_overrule)
{
- GstHarness * h = gst_harness_new_with_padnames ("rtpdtmfmux", NULL, "src");
- GstHarness * h0 = gst_harness_new_with_element (
- h->element, "sink_0", NULL);
- GstHarness * h1 = gst_harness_new_with_element (
- h->element, "sink_1", NULL);
+ GstHarness *h = gst_harness_new_with_padnames ("rtpmux", NULL, "src");
+ GstHarness *h0 = gst_harness_new_with_element (h->element, "sink_0", NULL);
+ GstHarness *h1 = gst_harness_new_with_element (h->element, "sink_1", NULL);
+ GstBuffer *buf0;
+ GstBuffer *buf1;
+
+ /* downstream is specifying 444444 as ssrc */
+ gst_harness_set_sink_caps_str (h, "application/x-rtp, ssrc=(uint)444444");
+ /* rtpmux ssrc is set to 111111 */
g_object_set (h->element, "ssrc", 111111, NULL);
+ /* while upstream ssrc is 222222 and 333333 */
+ gst_harness_set_src_caps_str (h0, "application/x-rtp, ssrc=(uint)222222");
+ gst_harness_set_src_caps_str (h1, "application/x-rtp, ssrc=(uint)333333");
+
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h0, generate_test_buffer (0, 222222)));
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h1, generate_test_buffer (0, 333333)));
+
+ buf0 = gst_harness_pull (h);
+ buf1 = gst_harness_pull (h);
+
+ /* we expect the ssrc to be downstream ssrc */
+ fail_unless_equals_int (444444, _rtp_buffer_get_ssrc (buf0));
+ fail_unless_equals_int (444444, _rtp_buffer_get_ssrc (buf1));
+
+ gst_buffer_unref (buf0);
+ gst_buffer_unref (buf1);
+
+ gst_harness_teardown (h0);
+ gst_harness_teardown (h1);
+ gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_rtpmux_ssrc_downstream_dynamic)
+{
+ GstHarness *h = gst_harness_new_parse ("rtpmux ! capsfilter");
+ GstElement *rtpmux = gst_harness_find_element (h, "rtpmux");
+ GstElement *capsfilter = gst_harness_find_element (h, "capsfilter");
+
+ GstHarness *h0 = gst_harness_new_with_element (rtpmux, "sink_0", NULL);
+ GstHarness *h1 = gst_harness_new_with_element (rtpmux, "sink_1", NULL);
+ GstCaps *caps;
+ GstBuffer *buf0;
+ GstBuffer *buf1;
+
+ gst_harness_play (h);
+
+ caps = gst_caps_from_string ("application/x-rtp, ssrc=(uint)444444");
+ g_object_set (capsfilter, "caps", caps, NULL);
+ gst_caps_unref (caps);
+
+ /* while upstream ssrc is 222222 and 333333 */
gst_harness_set_src_caps_str (h0, "application/x-rtp, ssrc=(uint)222222");
gst_harness_set_src_caps_str (h1, "application/x-rtp, ssrc=(uint)333333");
@@ -343,10 +490,37 @@ GST_START_TEST (test_rtpmux_ssrc)
fail_unless_equals_int (GST_FLOW_OK,
gst_harness_push (h1, generate_test_buffer (0, 333333)));
+ /* we expect the ssrc to be downstream ssrc (444444) */
+ buf0 = gst_harness_pull (h);
+ buf1 = gst_harness_pull (h);
+ fail_unless_equals_int (444444, _rtp_buffer_get_ssrc (buf0));
+ fail_unless_equals_int (444444, _rtp_buffer_get_ssrc (buf1));
+ gst_buffer_unref (buf0);
+ gst_buffer_unref (buf1);
+
+ caps = gst_caps_from_string ("application/x-rtp, ssrc=(uint)555555");
+ g_object_set (capsfilter, "caps", caps, NULL);
+ gst_caps_unref (caps);
+
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h0, generate_test_buffer (0, 222222)));
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h1, generate_test_buffer (0, 333333)));
+
+ /* we expect the ssrc to be the new downstream ssrc (555555) */
+ buf0 = gst_harness_pull (h);
+ buf1 = gst_harness_pull (h);
+ fail_unless_equals_int (555555, _rtp_buffer_get_ssrc (buf0));
+ fail_unless_equals_int (555555, _rtp_buffer_get_ssrc (buf1));
+ gst_buffer_unref (buf0);
+ gst_buffer_unref (buf1);
+
+ gst_object_unref (rtpmux);
gst_harness_teardown (h0);
gst_harness_teardown (h1);
gst_harness_teardown (h);
}
+
GST_END_TEST;
static Suite *
@@ -358,7 +532,10 @@ rtpmux_suite (void)
tc_chain = tcase_create ("rtpmux_basic");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_rtpmux_basic);
- tcase_add_test (tc_chain, test_rtpmux_ssrc);
+ tcase_add_test (tc_chain, test_rtpmux_ssrc_property);
+ tcase_add_test (tc_chain, test_rtpmux_ssrc_property_not_set);
+ tcase_add_test (tc_chain, test_rtpmux_ssrc_downstream_can_overrule);
+ tcase_add_test (tc_chain, test_rtpmux_ssrc_downstream_dynamic);
tc_chain = tcase_create ("rtpdtmfmux_basic");
tcase_add_test (tc_chain, test_rtpdtmfmux_basic);