mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-04 05:22:30 +00:00
rtpmux: property should overrule both upstream and downstream
https://bugzilla.gnome.org/show_bug.cgi?id=762213 https://bugzilla.gnome.org/show_bug.cgi?id=795162
This commit is contained in:
parent
fbc7976540
commit
7cd36d2914
2 changed files with 70 additions and 12 deletions
|
@ -265,7 +265,6 @@ gst_rtp_mux_init (GstRTPMux * rtp_mux)
|
|||
|
||||
rtp_mux->ssrc = DEFAULT_SSRC;
|
||||
rtp_mux->current_ssrc = DEFAULT_SSRC;
|
||||
rtp_mux->ssrc_random = TRUE;
|
||||
rtp_mux->ts_offset = DEFAULT_TIMESTAMP_OFFSET;
|
||||
rtp_mux->seqnum_offset = DEFAULT_SEQNUM_OFFSET;
|
||||
|
||||
|
@ -647,12 +646,13 @@ gst_rtp_mux_setcaps (GstPad * pad, GstRTPMux * rtp_mux, GstCaps * caps)
|
|||
|
||||
/* if we don't have a specified ssrc, first try to take one from the caps,
|
||||
and if that fails, generate one */
|
||||
if (!rtp_mux->have_ssrc) {
|
||||
if (rtp_mux->ssrc_random) {
|
||||
if (rtp_mux->ssrc == DEFAULT_SSRC) {
|
||||
if (rtp_mux->current_ssrc == DEFAULT_SSRC) {
|
||||
if (!gst_structure_get_uint (structure, "ssrc", &rtp_mux->current_ssrc))
|
||||
rtp_mux->current_ssrc = g_random_int ();
|
||||
rtp_mux->have_ssrc = TRUE;
|
||||
}
|
||||
} else {
|
||||
rtp_mux->current_ssrc = rtp_mux->ssrc;
|
||||
}
|
||||
|
||||
gst_caps_set_simple (caps,
|
||||
|
@ -738,6 +738,7 @@ gst_rtp_mux_getcaps (GstPad * pad, GstRTPMux * mux, GstCaps * filter)
|
|||
GstCaps *peercaps;
|
||||
GstCaps *othercaps;
|
||||
GstCaps *tcaps;
|
||||
const GstStructure *structure;
|
||||
|
||||
peercaps = gst_pad_peer_query_caps (mux->srcpad, NULL);
|
||||
|
||||
|
@ -759,6 +760,12 @@ gst_rtp_mux_getcaps (GstPad * pad, GstRTPMux * mux, GstCaps * filter)
|
|||
GST_LOG_OBJECT (pad, "Intersected srcpad-peercaps and template caps: %"
|
||||
GST_PTR_FORMAT, othercaps);
|
||||
|
||||
structure = gst_caps_get_structure (othercaps, 0);
|
||||
if (mux->ssrc == DEFAULT_SSRC) {
|
||||
if (gst_structure_get_uint (structure, "ssrc", &mux->current_ssrc))
|
||||
GST_DEBUG_OBJECT (pad, "Use downstream ssrc: %u", mux->current_ssrc);
|
||||
}
|
||||
|
||||
clear_caps (othercaps, TRUE);
|
||||
|
||||
g_value_init (&v, GST_TYPE_CAPS);
|
||||
|
|
|
@ -247,7 +247,7 @@ 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_equals_int (66, gst_rtp_buffer_get_ssrc (&rtpbuffer));
|
||||
fail_unless_equals_int (55, 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));
|
||||
|
@ -281,7 +281,7 @@ 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_equals_int (66, gst_rtp_buffer_get_ssrc (&rtpbuffer));
|
||||
fail_unless_equals_int (55, 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));
|
||||
|
@ -423,7 +423,7 @@ GST_START_TEST (test_rtpmux_ssrc_property_not_set)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_rtpmux_ssrc_downstream_can_overrule)
|
||||
GST_START_TEST (test_rtpmux_ssrc_downstream_overrules_upstream)
|
||||
{
|
||||
GstHarness *h = gst_harness_new_with_padnames ("rtpmux", NULL, "src");
|
||||
GstHarness *h0 = gst_harness_new_with_element (h->element, "sink_0", NULL);
|
||||
|
@ -434,9 +434,6 @@ GST_START_TEST (test_rtpmux_ssrc_downstream_can_overrule)
|
|||
/* 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");
|
||||
|
@ -463,6 +460,57 @@ GST_START_TEST (test_rtpmux_ssrc_downstream_can_overrule)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_rtpmux_ssrc_property_overrules_downstream)
|
||||
{
|
||||
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");
|
||||
|
||||
/* pushing now should fail */
|
||||
fail_unless_equals_int (GST_FLOW_NOT_NEGOTIATED,
|
||||
gst_harness_push (h0, generate_test_buffer (0, 222222)));
|
||||
fail_unless_equals_int (GST_FLOW_NOT_NEGOTIATED,
|
||||
gst_harness_push (h1, generate_test_buffer (0, 333333)));
|
||||
|
||||
/* open up the restriction on ssrc downstream */
|
||||
gst_harness_set_sink_caps_str (h, "application/x-rtp");
|
||||
|
||||
/* and push again */
|
||||
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 property ssrc */
|
||||
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_downstream_dynamic)
|
||||
{
|
||||
GstHarness *h = gst_harness_new_parse ("rtpmux ! capsfilter");
|
||||
|
@ -481,10 +529,10 @@ GST_START_TEST (test_rtpmux_ssrc_downstream_dynamic)
|
|||
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");
|
||||
|
||||
/* 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,
|
||||
|
@ -535,7 +583,10 @@ rtpmux_suite (void)
|
|||
tcase_add_test (tc_chain, test_rtpmux_basic);
|
||||
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_overrules_upstream);
|
||||
tcase_add_test (tc_chain, test_rtpmux_ssrc_property_overrules_downstream);
|
||||
|
||||
tcase_add_test (tc_chain, test_rtpmux_ssrc_downstream_dynamic);
|
||||
|
||||
tc_chain = tcase_create ("rtpdtmfmux_basic");
|
||||
|
|
Loading…
Reference in a new issue