mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
tests/webrtc: validate number of sdp media using validate_sdp
This commit is contained in:
parent
7e1cdbfd4d
commit
eb79f95bf8
1 changed files with 50 additions and 49 deletions
|
@ -621,12 +621,32 @@ _pad_added_fakesink (struct test_webrtc *t, GstElement * element,
|
||||||
t->harnesses = g_list_prepend (t->harnesses, h);
|
t->harnesses = g_list_prepend (t->harnesses, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstWebRTCSessionDescription *
|
static void
|
||||||
_count_num_sdp_media (struct test_webrtc *t, GstElement * element,
|
_count_num_sdp_media (struct test_webrtc *t, GstElement * element,
|
||||||
|
GstWebRTCSessionDescription * desc, gpointer user_data)
|
||||||
|
{
|
||||||
|
guint expected = GPOINTER_TO_UINT (user_data);
|
||||||
|
|
||||||
|
fail_unless_equals_int (gst_sdp_message_medias_len (desc->sdp), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef void (*ValidateSDPFunc) (struct test_webrtc * t, GstElement * element,
|
||||||
|
GstWebRTCSessionDescription * desc, gpointer user_data);
|
||||||
|
|
||||||
|
struct validate_sdp;
|
||||||
|
struct validate_sdp
|
||||||
|
{
|
||||||
|
ValidateSDPFunc validate;
|
||||||
|
gpointer user_data;
|
||||||
|
struct validate_sdp *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
static GstWebRTCSessionDescription *
|
||||||
|
_check_validate_sdp (struct test_webrtc *t, GstElement * element,
|
||||||
GstPromise * promise, gpointer user_data)
|
GstPromise * promise, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
struct validate_sdp *validate = user_data;
|
||||||
GstWebRTCSessionDescription *offer = NULL;
|
GstWebRTCSessionDescription *offer = NULL;
|
||||||
guint expected = GPOINTER_TO_UINT (user_data);
|
|
||||||
const GstStructure *reply;
|
const GstStructure *reply;
|
||||||
const gchar *field;
|
const gchar *field;
|
||||||
|
|
||||||
|
@ -636,7 +656,10 @@ _count_num_sdp_media (struct test_webrtc *t, GstElement * element,
|
||||||
gst_structure_get (reply, field,
|
gst_structure_get (reply, field,
|
||||||
GST_TYPE_WEBRTC_SESSION_DESCRIPTION, &offer, NULL);
|
GST_TYPE_WEBRTC_SESSION_DESCRIPTION, &offer, NULL);
|
||||||
|
|
||||||
fail_unless_equals_int (gst_sdp_message_medias_len (offer->sdp), expected);
|
while (validate) {
|
||||||
|
validate->validate (t, element, offer, validate->user_data);
|
||||||
|
validate = validate->next;
|
||||||
|
}
|
||||||
|
|
||||||
return offer;
|
return offer;
|
||||||
}
|
}
|
||||||
|
@ -644,14 +667,18 @@ _count_num_sdp_media (struct test_webrtc *t, GstElement * element,
|
||||||
GST_START_TEST (test_sdp_no_media)
|
GST_START_TEST (test_sdp_no_media)
|
||||||
{
|
{
|
||||||
struct test_webrtc *t = test_webrtc_new ();
|
struct test_webrtc *t = test_webrtc_new ();
|
||||||
|
struct validate_sdp offer =
|
||||||
|
{ _count_num_sdp_media, GUINT_TO_POINTER (0), NULL };
|
||||||
|
struct validate_sdp answer =
|
||||||
|
{ _count_num_sdp_media, GUINT_TO_POINTER (0), NULL };
|
||||||
|
|
||||||
/* check that a no stream connection creates 0 media sections */
|
/* check that a no stream connection creates 0 media sections */
|
||||||
|
|
||||||
t->on_negotiation_needed = NULL;
|
t->on_negotiation_needed = NULL;
|
||||||
t->offer_data = GUINT_TO_POINTER (0);
|
t->offer_data = &offer;
|
||||||
t->on_offer_created = _count_num_sdp_media;
|
t->on_offer_created = _check_validate_sdp;
|
||||||
t->answer_data = GUINT_TO_POINTER (0);
|
t->answer_data = &answer;
|
||||||
t->on_answer_created = _count_num_sdp_media;
|
t->on_answer_created = _check_validate_sdp;
|
||||||
|
|
||||||
fail_if (gst_element_set_state (t->webrtc1,
|
fail_if (gst_element_set_state (t->webrtc1,
|
||||||
GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
|
GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
|
||||||
|
@ -706,15 +733,19 @@ create_audio_test (void)
|
||||||
GST_START_TEST (test_audio)
|
GST_START_TEST (test_audio)
|
||||||
{
|
{
|
||||||
struct test_webrtc *t = create_audio_test ();
|
struct test_webrtc *t = create_audio_test ();
|
||||||
|
struct validate_sdp offer =
|
||||||
|
{ _count_num_sdp_media, GUINT_TO_POINTER (1), NULL };
|
||||||
|
struct validate_sdp answer =
|
||||||
|
{ _count_num_sdp_media, GUINT_TO_POINTER (1), NULL };
|
||||||
|
|
||||||
/* check that a single stream connection creates the associated number
|
/* check that a single stream connection creates the associated number
|
||||||
* of media sections */
|
* of media sections */
|
||||||
|
|
||||||
t->on_negotiation_needed = NULL;
|
t->on_negotiation_needed = NULL;
|
||||||
t->offer_data = GUINT_TO_POINTER (1);
|
t->offer_data = &offer;
|
||||||
t->on_offer_created = _count_num_sdp_media;
|
t->on_offer_created = _check_validate_sdp;
|
||||||
t->answer_data = GUINT_TO_POINTER (1);
|
t->answer_data = &answer;
|
||||||
t->on_answer_created = _count_num_sdp_media;
|
t->on_answer_created = _check_validate_sdp;
|
||||||
t->on_ice_candidate = NULL;
|
t->on_ice_candidate = NULL;
|
||||||
|
|
||||||
fail_if (gst_element_set_state (t->webrtc1,
|
fail_if (gst_element_set_state (t->webrtc1,
|
||||||
|
@ -754,15 +785,19 @@ create_audio_video_test (void)
|
||||||
GST_START_TEST (test_audio_video)
|
GST_START_TEST (test_audio_video)
|
||||||
{
|
{
|
||||||
struct test_webrtc *t = create_audio_video_test ();
|
struct test_webrtc *t = create_audio_video_test ();
|
||||||
|
struct validate_sdp offer =
|
||||||
|
{ _count_num_sdp_media, GUINT_TO_POINTER (2), NULL };
|
||||||
|
struct validate_sdp answer =
|
||||||
|
{ _count_num_sdp_media, GUINT_TO_POINTER (2), NULL };
|
||||||
|
|
||||||
/* check that a dual stream connection creates the associated number
|
/* check that a dual stream connection creates the associated number
|
||||||
* of media sections */
|
* of media sections */
|
||||||
|
|
||||||
t->on_negotiation_needed = NULL;
|
t->on_negotiation_needed = NULL;
|
||||||
t->offer_data = GUINT_TO_POINTER (2);
|
t->offer_data = &offer;
|
||||||
t->on_offer_created = _count_num_sdp_media;
|
t->on_offer_created = _check_validate_sdp;
|
||||||
t->answer_data = GUINT_TO_POINTER (2);
|
t->answer_data = &answer;
|
||||||
t->on_answer_created = _count_num_sdp_media;
|
t->on_answer_created = _check_validate_sdp;
|
||||||
t->on_ice_candidate = NULL;
|
t->on_ice_candidate = NULL;
|
||||||
|
|
||||||
fail_if (gst_element_set_state (t->webrtc1,
|
fail_if (gst_element_set_state (t->webrtc1,
|
||||||
|
@ -779,40 +814,6 @@ GST_START_TEST (test_audio_video)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
typedef void (*ValidateSDPFunc) (struct test_webrtc * t, GstElement * element,
|
|
||||||
GstWebRTCSessionDescription * desc, gpointer user_data);
|
|
||||||
|
|
||||||
struct validate_sdp;
|
|
||||||
struct validate_sdp
|
|
||||||
{
|
|
||||||
ValidateSDPFunc validate;
|
|
||||||
gpointer user_data;
|
|
||||||
struct validate_sdp *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
static GstWebRTCSessionDescription *
|
|
||||||
_check_validate_sdp (struct test_webrtc *t, GstElement * element,
|
|
||||||
GstPromise * promise, gpointer user_data)
|
|
||||||
{
|
|
||||||
struct validate_sdp *validate = user_data;
|
|
||||||
GstWebRTCSessionDescription *offer = NULL;
|
|
||||||
const GstStructure *reply;
|
|
||||||
const gchar *field;
|
|
||||||
|
|
||||||
field = t->offerror == 1 && t->webrtc1 == element ? "offer" : "answer";
|
|
||||||
|
|
||||||
reply = gst_promise_get_reply (promise);
|
|
||||||
gst_structure_get (reply, field,
|
|
||||||
GST_TYPE_WEBRTC_SESSION_DESCRIPTION, &offer, NULL);
|
|
||||||
|
|
||||||
while (validate) {
|
|
||||||
validate->validate (t, element, offer, validate->user_data);
|
|
||||||
validate = validate->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
return offer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_sdp_media_direction (struct test_webrtc *t, GstElement * element,
|
on_sdp_media_direction (struct test_webrtc *t, GstElement * element,
|
||||||
GstWebRTCSessionDescription * desc, gpointer user_data)
|
GstWebRTCSessionDescription * desc, gpointer user_data)
|
||||||
|
|
Loading…
Reference in a new issue