GstPad *jb_sink_pad, *jb_src_pad;
GstSegment seg;
GstMiniObject *obj;
+ GstCaps *caps;
/* create the testclock */
data->clock = gst_test_clock_new ();
/* link in the test sink-pad */
data->test_sink_pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_pad_set_element_private (data->test_sink_pad, data);
- gst_pad_set_caps (data->test_sink_pad, generate_caps ());
+ caps = generate_caps ();
+ gst_pad_set_caps (data->test_sink_pad, caps);
gst_pad_set_chain_function (data->test_sink_pad, test_sink_pad_chain_cb);
gst_pad_set_event_function (data->test_sink_pad, test_sink_pad_event_cb);
jb_src_pad = gst_element_get_static_pad (data->jitter_buffer, "src");
gst_pad_push_event (data->test_src_pad,
gst_event_new_stream_start ("stream0"));
- gst_pad_set_caps (data->test_src_pad, generate_caps ());
+ gst_pad_set_caps (data->test_src_pad, caps);
gst_pad_push_event (data->test_src_pad, gst_event_new_segment (&seg));
+ gst_caps_unref (caps);
obj = g_async_queue_pop (data->sink_event_queue);
gst_mini_object_unref (obj);
g_assert_cmpint (timestamp, ==, expected_timestamp);
g_assert_cmpint (duration, ==, expected_duration);
g_assert (late == expected_late);
+
+ gst_event_unref (event);
}
static void
g_assert_cmpint (timestamp, ==, expected_timestamp);
g_assert_cmpint (delay, ==, expected_delay);
g_assert_cmpint (spacing, ==, expected_spacing);
+
+ gst_event_unref (event);
}
GST_START_TEST (test_only_one_lost_event_on_large_gaps)
/* increase the time to timestamp + latency and release the wait */
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock),
jb_latency_ms * GST_MSECOND);
- g_assert (gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock))
- == id);
+ test_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ g_assert (test_id == id);
+ gst_clock_id_unref (test_id);
+ gst_clock_id_unref (id);
/* check for the buffer coming out that was pushed in */
out_buf = g_async_queue_pop (data.buf_queue);
g_assert (out_buf != NULL);
g_assert_cmpint (GST_BUFFER_DTS (out_buf), ==, 0);
g_assert_cmpint (GST_BUFFER_PTS (out_buf), ==, 0);
+ gst_buffer_unref (out_buf);
/* move time ahead 10 seconds */
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 10 * GST_SECOND);
gst_test_clock_advance_time (GST_TEST_CLOCK (data.clock), GST_MSECOND * 20);
test_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == test_id);
+ gst_clock_id_unref (test_id);
+ gst_clock_id_unref (id);
/* we should now receive a packet-lost-event for buffers 1 through 489 */
out_event = g_async_queue_pop (data.sink_event_queue);
if (t > gst_clock_get_time (data.clock)) {
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), t);
}
- gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ test_id =
+ gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ gst_clock_id_unref (test_id);
+ gst_clock_id_unref (id);
}
}
gst_rtp_buffer_unmap (&rtp);
g_assert_cmpint (GST_BUFFER_DTS (out_buf), ==, (10 * GST_SECOND));
g_assert_cmpint (GST_BUFFER_PTS (out_buf), ==, (10 * GST_SECOND));
+ gst_buffer_unref (out_buf);
/* we get as many lost events as the the number of buffers the jitterbuffer
* is able to wait for (+ the one we already got) */
GST_START_TEST (test_two_lost_one_arrives_in_time)
{
TestData data;
- GstClockID id;
+ GstClockID id, test_id;
GstBuffer *in_buf, *out_buf;
GstEvent *out_event;
gint jb_latency_ms = 100;
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (data.clock), &id);
now = jb_latency_ms * GST_MSECOND;
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), now);
- g_assert (gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock))
- == id);
+ test_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ g_assert (test_id == id);
+ gst_clock_id_unref (test_id);
+ gst_clock_id_unref (id);
out_buf = g_async_queue_pop (data.buf_queue);
g_assert (out_buf != NULL);
in_buf = generate_test_buffer (buffer_time, TRUE, b, b * 160);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), now + buffer_time);
g_assert_cmpint (gst_pad_push (data.test_src_pad, in_buf), ==, GST_FLOW_OK);
+ gst_buffer_unref (out_buf);
/* check for the buffer coming out that was pushed in */
out_buf = g_async_queue_pop (data.buf_queue);
g_assert_cmpint (GST_BUFFER_DTS (out_buf), ==, buffer_time);
g_assert_cmpint (GST_BUFFER_PTS (out_buf), ==, buffer_time);
}
+ gst_buffer_unref (out_buf);
/* hop over 2 packets and make another one (gap of 2) */
b = 5;
/* let the time expire... */
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock),
gst_clock_id_get_time (id));
- g_assert (gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock))
- == id);
+ test_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ g_assert (test_id == id);
+ gst_clock_id_unref (test_id);
+ gst_clock_id_unref (id);
/* we should now receive a packet-lost-event for buffer 3 */
out_event = g_async_queue_pop (data.sink_event_queue);
gst_rtp_buffer_map (out_buf, GST_MAP_READ, &rtp);
g_assert_cmpint (gst_rtp_buffer_get_seq (&rtp), ==, 4);
gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unref (out_buf);
/* and see that buffer 5 now arrives in a normal fashion */
out_buf = g_async_queue_pop (data.buf_queue);
gst_rtp_buffer_map (out_buf, GST_MAP_READ, &rtp);
g_assert_cmpint (gst_rtp_buffer_get_seq (&rtp), ==, 5);
gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unref (out_buf);
/* should still have only seen 1 packet lost event */
g_assert_cmpint (data.lost_event_count, ==, 1);
GST_START_TEST (test_late_packets_still_makes_lost_events)
{
TestData data;
- GstClockID id;
+ GstClockID id, test_id;
GstBuffer *in_buf, *out_buf;
GstEvent *out_event;
gint jb_latency_ms = 10;
g_assert_cmpint (gst_pad_push (data.test_src_pad, in_buf), ==, GST_FLOW_OK);
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (data.clock), &id);
- g_assert (gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock))
- == id);
+ test_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ g_assert (test_id == id);
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (test_id);
out_buf = g_async_queue_pop (data.buf_queue);
g_assert (out_buf != NULL);
buffer_time = b * GST_MSECOND * 20;
in_buf = generate_test_buffer (buffer_time, TRUE, b, b * 160);
g_assert_cmpint (gst_pad_push (data.test_src_pad, in_buf), ==, GST_FLOW_OK);
+ gst_buffer_unref (out_buf);
/* check for the buffer coming out that was pushed in */
out_buf = g_async_queue_pop (data.buf_queue);
g_assert_cmpint (GST_BUFFER_DTS (out_buf), ==, buffer_time);
g_assert_cmpint (GST_BUFFER_PTS (out_buf), ==, buffer_time);
}
+ gst_buffer_unref (out_buf);
/* hop over 2 packets and make another one (gap of 2) */
b = 5;
gst_rtp_buffer_map (out_buf, GST_MAP_READ, &rtp);
g_assert_cmpint (gst_rtp_buffer_get_seq (&rtp), ==, 5);
gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unref (out_buf);
/* should still have only seen 1 packet lost event */
g_assert_cmpint (data.lost_event_count, ==, 1);
GST_START_TEST (test_all_packets_are_timestamped_zero)
{
TestData data;
- GstClockID id;
+ GstClockID id, test_id;
GstBuffer *in_buf, *out_buf;
GstEvent *out_event;
gint jb_latency_ms = 10;
g_assert_cmpint (gst_pad_push (data.test_src_pad, in_buf), ==, GST_FLOW_OK);
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (data.clock), &id);
- g_assert (gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock))
- == id);
+ test_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ g_assert (test_id == id);
+ gst_clock_id_unref (test_id);
+ gst_clock_id_unref (id);
out_buf = g_async_queue_pop (data.buf_queue);
g_assert (out_buf != NULL);
for (b = 1; b < 3; b++) {
in_buf = generate_test_buffer (0, TRUE, b, 0);
g_assert_cmpint (gst_pad_push (data.test_src_pad, in_buf), ==, GST_FLOW_OK);
+ gst_buffer_unref (out_buf);
/* check for the buffer coming out that was pushed in */
out_buf = g_async_queue_pop (data.buf_queue);
g_assert_cmpint (GST_BUFFER_DTS (out_buf), ==, 0);
g_assert_cmpint (GST_BUFFER_PTS (out_buf), ==, 0);
}
+ gst_buffer_unref (out_buf);
/* hop over 2 packets and make another one (gap of 2) */
b = 5;
gst_rtp_buffer_map (out_buf, GST_MAP_READ, &rtp);
g_assert_cmpint (gst_rtp_buffer_get_seq (&rtp), ==, 5);
gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unref (out_buf);
/* should still have only seen 2 packet lost events */
g_assert_cmpint (data.lost_event_count, ==, 2);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 20 * GST_MSECOND);
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (data.clock), &id);
+ gst_clock_id_unref (id);
/* put second buffer, the jitterbuffer should now know that the packet spacing
* is 20ms and should ask for retransmission of seqnum 2 in 20ms */
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (data.clock), &id);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 60 * GST_MSECOND);
- g_assert (gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock))
- == id);
+ tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ g_assert (tid == id);
+ gst_clock_id_unref (tid);
+ gst_clock_id_unref (id);
out_event = g_async_queue_pop (data.src_event_queue);
g_assert (out_event != NULL);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 100 * GST_MSECOND);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (tid);
+ gst_clock_id_unref (id);
out_event = g_async_queue_pop (data.src_event_queue);
g_assert (out_event != NULL);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 140 * GST_MSECOND);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (tid);
+ gst_clock_id_unref (id);
out_event = g_async_queue_pop (data.src_event_queue);
g_assert (out_event != NULL);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 200 * GST_MSECOND);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (tid);
+ gst_clock_id_unref (id);
out_buf = g_async_queue_pop (data.buf_queue);
g_assert (out_buf != NULL);
+ gst_buffer_unref (out_buf);
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (data.clock), &id);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 260 * GST_MSECOND);
- g_assert (gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock))
- == id);
+ tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ g_assert (tid == id);
+ gst_clock_id_unref (tid);
+ gst_clock_id_unref (id);
/* we should now receive a packet-lost-event for buffer 2 */
out_event = g_async_queue_pop (data.sink_event_queue);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 60 * GST_MSECOND);
do {
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (data.clock), &id);
- } while (id !=
- gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock)));
+ tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
+ } while (id != tid);
/* we should have 2 events now, one for 2 and another for 3 */
out_event = g_async_queue_pop (data.src_event_queue);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 100 * GST_MSECOND);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
/* we should have 2 events now, one for 2 and another for 3 */
out_event = g_async_queue_pop (data.src_event_queue);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 140 * GST_MSECOND);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
/* now we only get requests for 2 */
out_event = g_async_queue_pop (data.src_event_queue);
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 200 * GST_MSECOND);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
for (i = 0; i < 2; i++) {
GST_DEBUG ("popping %d", i);
gst_rtp_buffer_map (out_buf, GST_MAP_READ, &rtp);
g_assert_cmpint (gst_rtp_buffer_get_seq (&rtp), ==, i);
gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unref (out_buf);
}
/* this is when 2 is lost */
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 240 * GST_MSECOND);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
/* we should now receive a packet-lost-event for buffer 2 */
out_event = g_async_queue_pop (data.sink_event_queue);
gst_rtp_buffer_map (out_buf, GST_MAP_READ, &rtp);
g_assert_cmpint (gst_rtp_buffer_get_seq (&rtp), ==, i);
gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unref (out_buf);
}
/* should still have only seen 1 packet lost events */
g_assert_cmpint (data.lost_event_count, ==, 1);
rtx_stat = gst_structure_get_value (rtx_stats, "rtx-rtt");
g_assert_cmpuint (g_value_get_uint64 (rtx_stat), ==, 0);
+ gst_structure_free (rtx_stats);
destroy_testharness (&data);
}
gst_test_clock_wait_for_next_pending_id (GST_TEST_CLOCK (data.clock), &id);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
for (i = 6; i < 8; i++) {
GST_DEBUG ("popping %d", i);
while (g_async_queue_length (data.buf_queue) < 1) {
if (gst_test_clock_peek_next_pending_id (GST_TEST_CLOCK (data.clock), &id)) {
GstClockTime t = gst_clock_id_get_time (id);
- if (t >= 240 * GST_MSECOND)
+ if (t >= 240 * GST_MSECOND) {
+ gst_clock_id_unref (id);
break;
+ }
if (t > gst_clock_get_time (data.clock)) {
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), t);
}
- gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
}
}
gst_rtp_buffer_map (out_buf, GST_MAP_READ, &rtp);
g_assert_cmpint (gst_rtp_buffer_get_seq (&rtp), ==, i);
gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unref (out_buf);
}
/* churn through sync_times until the next buffer gets pushed out */
while (g_async_queue_length (data.buf_queue) < 1) {
if (gst_test_clock_peek_next_pending_id (GST_TEST_CLOCK (data.clock), &id)) {
GstClockTime t = gst_clock_id_get_time (id);
- if (t >= 240 * GST_MSECOND)
+ if (t >= 240 * GST_MSECOND) {
+ gst_clock_id_unref (id);
break;
+ }
if (t > gst_clock_get_time (data.clock)) {
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), t);
}
- gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
}
}
gst_rtp_buffer_map (out_buf, GST_MAP_READ, &rtp);
g_assert_cmpint (gst_rtp_buffer_get_seq (&rtp), ==, i);
gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unref (out_buf);
}
GST_DEBUG ("waiting for 240ms");
gst_test_clock_set_time (GST_TEST_CLOCK (data.clock), 240 * GST_MSECOND);
tid = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (data.clock));
g_assert (id == tid);
+ gst_clock_id_unref (id);
+ gst_clock_id_unref (tid);
GST_DEBUG ("popping lost event 10");
out_event = g_async_queue_pop (data.sink_event_queue);