static void test_rtxsender_packet_retention (gboolean test_with_time) { guint master_ssrc = 1234567; guint master_pt = 96; guint rtx_ssrc = 7654321; guint rtx_pt = 99; gint num_buffers = test_with_time ? 30 : 10; gint half_buffers = num_buffers / 2; guint timestamp_delta = 90000 / 30; guint timestamp = G_MAXUINT32 - half_buffers * timestamp_delta; GstHarness *h; GstStructure *pt_map = gst_structure_new ("application/x-rtp-pt-map", "96", G_TYPE_UINT, rtx_pt, NULL); GstStructure *ssrc_map = gst_structure_new ("application/x-rtp-ssrc-map", "1234567", G_TYPE_UINT, rtx_ssrc, NULL); h = gst_harness_new ("rtprtxsend"); /* In both cases we want the rtxsend queue to store 'half_buffers' amount of buffers at most. In max-size-packets mode, it's trivial. In max-size-time mode, we specify almost half a second, which is the equivalent of 15 frames in a 30fps video stream. */ g_object_set (h->element, "max-size-packets", test_with_time ? 0 : half_buffers, "max-size-time", test_with_time ? 499 : 0, "payload-type-map", pt_map, "ssrc-map", ssrc_map, NULL); gst_harness_set_src_caps_str (h, "application/x-rtp, " "media = (string)video, payload = (int)96, " "ssrc = (uint)1234567, clock-rate = (int)90000, " "encoding-name = (string)RAW"); /* Now push all buffers and request retransmission every time for all of them */ for (gint i = 0; i < num_buffers; ++i, timestamp += timestamp_delta) { /* Request to retransmit all the previous ones */ for (gint j = 0; j < i; ++j) { guint rtx_seqnum = 0x100 + j; gst_harness_push_upstream_event (h, create_rtx_event (master_ssrc, master_pt, rtx_seqnum)); /* Pull only the ones supposed to be retransmited */ if (j >= i - half_buffers) pull_and_verify (h, TRUE, rtx_ssrc, rtx_pt, rtx_seqnum); } /* Check there no extra buffers in the harness queue */ fail_unless_equals_int (gst_harness_buffers_in_queue (h), 0); /* We create RTP buffers with timestamps that will eventualy wrap around 0 to be sure, rtprtxsend can handle it properly */ push_pull_and_verify (h, create_rtp_buffer_with_timestamp (master_ssrc, master_pt, 0x100 + i, timestamp), FALSE, master_ssrc, master_pt, 0x100 + i); } gst_structure_free (pt_map); gst_structure_free (ssrc_map); gst_harness_teardown (h); }
static void session_harness_produce_rtcp (SessionHarness * h, gint num_rtcp_packets) { /* due to randomness in rescheduling of RTCP timeout, we need to keep cranking until we have the desired amount of packets */ while (gst_harness_buffers_in_queue (h->rtcp_h) < num_rtcp_packets) session_harness_crank_clock (h); }