if (!gst_structure_get_uint (s, "ssrc", &ssrc))
ssrc = -1;
- GST_DEBUG_OBJECT (rtp_mux, "collided ssrc: %" G_GUINT32_FORMAT, ssrc);
+ GST_DEBUG_OBJECT (rtp_mux, "collided ssrc: %x", ssrc);
/* choose another ssrc for our stream */
GST_OBJECT_LOCK (rtp_mux);
rtp_mux->current_ssrc = g_random_int ();
new_ssrc = rtp_mux->current_ssrc;
+ GST_INFO_OBJECT (rtp_mux, "New ssrc after collision %x (was: %x)",
+ new_ssrc, ssrc);
GST_OBJECT_UNLOCK (rtp_mux);
caps = gst_pad_get_current_caps (rtp_mux->srcpad);
gst_rtp_buffer_set_ssrc (rtpbuffer, rtp_mux->current_ssrc);
gst_rtp_mux_readjust_rtp_timestamp_locked (rtp_mux, padpriv, rtpbuffer);
GST_LOG_OBJECT (rtp_mux,
- "Pushing packet size %" G_GSIZE_FORMAT ", seq=%d, ts=%u",
+ "Pushing packet size %" G_GSIZE_FORMAT ", seq=%d, ts=%u, ssrc=%x",
rtpbuffer->map[0].size, rtp_mux->seqnum,
- gst_rtp_buffer_get_timestamp (rtpbuffer));
+ gst_rtp_buffer_get_timestamp (rtpbuffer), rtp_mux->current_ssrc);
if (padpriv) {
if (padpriv->segment.format == GST_FORMAT_TIME) {
structure = gst_caps_get_structure (othercaps, 0);
GST_OBJECT_LOCK (rtp_mux);
if (gst_structure_get_uint (structure, "ssrc", &rtp_mux->current_ssrc)) {
- GST_DEBUG_OBJECT (pad, "Use downstream ssrc: %x",
- rtp_mux->current_ssrc);
+ GST_INFO_OBJECT (pad, "Use downstream ssrc: %x", rtp_mux->current_ssrc);
rtp_mux->have_ssrc = TRUE;
}
GST_OBJECT_UNLOCK (rtp_mux);
and if that fails, generate one */
if (rtp_mux->ssrc == DEFAULT_SSRC) {
if (rtp_mux->current_ssrc == DEFAULT_SSRC) {
- if (!gst_structure_get_uint (structure, "ssrc", &rtp_mux->current_ssrc))
+ if (!gst_structure_get_uint (structure, "ssrc", &rtp_mux->current_ssrc)) {
rtp_mux->current_ssrc = g_random_int ();
+ GST_INFO_OBJECT (rtp_mux, "Set random ssrc %x", rtp_mux->current_ssrc);
+ }
}
} else {
rtp_mux->current_ssrc = rtp_mux->ssrc;
+ GST_INFO_OBJECT (rtp_mux, "Set ssrc %x", rtp_mux->current_ssrc);
}
gst_caps_set_simple (caps,
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);
+ GST_DEBUG_OBJECT (pad, "Use downstream ssrc: %x", mux->current_ssrc);
}
clear_caps (othercaps, TRUE);
rtp_mux->ssrc = g_value_get_uint (value);
rtp_mux->current_ssrc = rtp_mux->ssrc;
rtp_mux->have_ssrc = TRUE;
- rtp_mux->ssrc_random = FALSE;
+ GST_DEBUG_OBJECT (rtp_mux, "ssrc prop set to %x", rtp_mux->ssrc);
GST_OBJECT_UNLOCK (rtp_mux);
break;
default:
rtp_mux->last_stop = GST_CLOCK_TIME_NONE;
- if (rtp_mux->ssrc_random) {
- rtp_mux->have_ssrc = FALSE;
- } else {
+ if (rtp_mux->have_ssrc)
rtp_mux->current_ssrc = rtp_mux->ssrc;
- rtp_mux->have_ssrc = TRUE;
- }
GST_DEBUG_OBJECT (rtp_mux, "set timestamp-offset to %u", rtp_mux->ts_base);
}
GST_END_TEST;
+GST_START_TEST (test_rtpmux_ssrc_property_survive_statechange)
+{
+ 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_element_set_state (h->element, GST_STATE_NULL);
+ /* rtpmux ssrc is set to 111111 */
+ g_object_set (h->element, "ssrc", 111111, NULL);
+ gst_element_set_state (h->element, GST_STATE_PLAYING);
+
+ /* 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");
+
+ /* downstream is specifying 444444 as ssrc */
+ gst_harness_set_sink_caps_str (h, "application/x-rtp, ssrc=(uint)444444");
+ gst_harness_set_sink_caps_str (h, "application/x-rtp");
+
+ /* push*/
+ 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");
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_property_survive_statechange);
tcase_add_test (tc_chain, test_rtpmux_ssrc_downstream_dynamic);