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;
/* 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,
GstCaps *peercaps;
GstCaps *othercaps;
GstCaps *tcaps;
+ const GstStructure *structure;
peercaps = gst_pad_peer_query_caps (mux->srcpad, NULL);
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);
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));
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));
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);
/* 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");
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");
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,
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");