mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
test: rtpbin_buffer_list: add test to verify that receiving stats are correct
Add a test to verify that stats about received packets are correct when using buffer lists in the rtpsession receive path. Split get_session_source_stats() in two to be able to get stats from a GstRtpSession object directly.
This commit is contained in:
parent
80daea90f0
commit
ec56e2fb78
1 changed files with 38 additions and 5 deletions
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include <gst/rtp/gstrtpbuffer.h>
|
#include <gst/rtp/gstrtpbuffer.h>
|
||||||
|
|
||||||
|
/* UDP/IP is assumed for bandwidth calculation */
|
||||||
|
#define UDP_IP_HEADER_OVERHEAD 28
|
||||||
|
|
||||||
/* This test makes sure that RTP packets sent as buffer lists are sent through
|
/* This test makes sure that RTP packets sent as buffer lists are sent through
|
||||||
* the rtpbin as they are supposed to, and not corrupted in any way.
|
* the rtpbin as they are supposed to, and not corrupted in any way.
|
||||||
|
@ -206,6 +208,7 @@ check_packet (GstBufferList * list, guint list_index, guint packet_index)
|
||||||
* chain_list handler has been set.
|
* chain_list handler has been set.
|
||||||
*/
|
*/
|
||||||
static gboolean chain_list_func_called;
|
static gboolean chain_list_func_called;
|
||||||
|
static guint chain_list_bytes_received;
|
||||||
|
|
||||||
/* Create two packets with different payloads. */
|
/* Create two packets with different payloads. */
|
||||||
static GstBufferList *
|
static GstBufferList *
|
||||||
|
@ -258,6 +261,10 @@ sink_chain_list (GstPad * pad, GstObject * parent, GstBufferList * list)
|
||||||
fail_unless (GST_IS_BUFFER_LIST (list));
|
fail_unless (GST_IS_BUFFER_LIST (list));
|
||||||
fail_unless (gst_buffer_list_length (list) == 2);
|
fail_unless (gst_buffer_list_length (list) == 2);
|
||||||
|
|
||||||
|
/* received bytes include lower level protocol overhead */
|
||||||
|
chain_list_bytes_received = gst_buffer_list_calculate_size (list) +
|
||||||
|
2 * UDP_IP_HEADER_OVERHEAD;
|
||||||
|
|
||||||
fail_unless (gst_buffer_list_get (list, 0));
|
fail_unless (gst_buffer_list_get (list, 0));
|
||||||
check_packet (list, 0, 0);
|
check_packet (list, 0, 0);
|
||||||
|
|
||||||
|
@ -271,17 +278,13 @@ sink_chain_list (GstPad * pad, GstObject * parent, GstBufferList * list)
|
||||||
|
|
||||||
/* Get the stats of the **first** source of the given type (get_sender) */
|
/* Get the stats of the **first** source of the given type (get_sender) */
|
||||||
static void
|
static void
|
||||||
get_session_source_stats (GstElement * rtpbin, guint session,
|
get_source_stats (GstElement * rtpsession,
|
||||||
gboolean get_sender, GstStructure ** source_stats)
|
gboolean get_sender, GstStructure ** source_stats)
|
||||||
{
|
{
|
||||||
GstElement *rtpsession;
|
|
||||||
GstStructure *stats;
|
GstStructure *stats;
|
||||||
GValueArray *stats_arr;
|
GValueArray *stats_arr;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
g_signal_emit_by_name (rtpbin, "get-session", session, &rtpsession);
|
|
||||||
fail_if (rtpsession == NULL);
|
|
||||||
|
|
||||||
g_object_get (rtpsession, "stats", &stats, NULL);
|
g_object_get (rtpsession, "stats", &stats, NULL);
|
||||||
stats_arr =
|
stats_arr =
|
||||||
g_value_get_boxed (gst_structure_get_value (stats, "source-stats"));
|
g_value_get_boxed (gst_structure_get_value (stats, "source-stats"));
|
||||||
|
@ -306,6 +309,20 @@ get_session_source_stats (GstElement * rtpbin, guint session,
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_structure_free (stats);
|
gst_structure_free (stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the source stats given a session and a source type (get_sender) */
|
||||||
|
static void
|
||||||
|
get_session_source_stats (GstElement * rtpbin, guint session,
|
||||||
|
gboolean get_sender, GstStructure ** source_stats)
|
||||||
|
{
|
||||||
|
GstElement *rtpsession;
|
||||||
|
|
||||||
|
g_signal_emit_by_name (rtpbin, "get-session", session, &rtpsession);
|
||||||
|
fail_if (rtpsession == NULL);
|
||||||
|
|
||||||
|
get_source_stats (rtpsession, get_sender, source_stats);
|
||||||
|
|
||||||
gst_object_unref (rtpsession);
|
gst_object_unref (rtpsession);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,6 +395,9 @@ GST_START_TEST (test_bufferlist_recv)
|
||||||
GstPad *sinkpad;
|
GstPad *sinkpad;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstBufferList *list;
|
GstBufferList *list;
|
||||||
|
GstStructure *stats;
|
||||||
|
guint64 bytes_received;
|
||||||
|
guint64 packets_received;
|
||||||
|
|
||||||
list = create_buffer_list ();
|
list = create_buffer_list ();
|
||||||
fail_unless (list != NULL);
|
fail_unless (list != NULL);
|
||||||
|
@ -408,6 +428,19 @@ GST_START_TEST (test_bufferlist_recv)
|
||||||
fail_unless (gst_pad_push_list (srcpad, list) == GST_FLOW_OK);
|
fail_unless (gst_pad_push_list (srcpad, list) == GST_FLOW_OK);
|
||||||
fail_if (chain_list_func_called == FALSE);
|
fail_if (chain_list_func_called == FALSE);
|
||||||
|
|
||||||
|
/* make sure that stats about the number of received packets are OK too */
|
||||||
|
/* The source becomes a sender after probation succeeds, pass TRUE here. */
|
||||||
|
get_source_stats (rtpbin, TRUE, &stats);
|
||||||
|
fail_if (stats == NULL);
|
||||||
|
|
||||||
|
gst_structure_get (stats,
|
||||||
|
"bytes-received", G_TYPE_UINT64, &bytes_received,
|
||||||
|
"packets-received", G_TYPE_UINT64, &packets_received, NULL);
|
||||||
|
fail_unless (packets_received == 2);
|
||||||
|
fail_unless (bytes_received == chain_list_bytes_received);
|
||||||
|
gst_structure_free (stats);
|
||||||
|
|
||||||
|
|
||||||
gst_pad_set_active (sinkpad, FALSE);
|
gst_pad_set_active (sinkpad, FALSE);
|
||||||
gst_pad_set_active (srcpad, FALSE);
|
gst_pad_set_active (srcpad, FALSE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue