sdp: Add tests for rtcp-fb parsing

https://bugzilla.gnome.org/show_bug.cgi?id=769698
This commit is contained in:
Tomasz Zajac 2016-10-28 08:47:40 +02:00 committed by Sebastian Dröge
parent 4d4f3c3cc4
commit 028b16bb67

View file

@ -74,6 +74,72 @@ static const gchar caps_audio_string[] =
"application/x-unknown, media=(string)audio, payload=(int)14, "
"clock-rate=(int)90000";
static const gchar * sdp_rtcp_fb = "v=0\r\n"
"o=- 123456 2 IN IP4 127.0.0.1 \r\n"
"s=-\r\n"
"t=0 0\r\n"
"a=maxptime:60\r\n"
"a=sendrecv\r\n"
"m=video 1 UDP/TLS/RTP/SAVPF 100 101 102\r\n"
"c=IN IP4 1.1.1.1\r\n"
"a=rtpmap:100 VP8/90000\r\n"
"a=rtcp-fb:100 nack\r\n"
"a=rtcp-fb:100 nack pli\r\n"
"a=rtcp-fb:100 ccm fir\r\n"
"a=rtpmap:101 VP9/90000\r\n"
"a=rtcp-fb:101 nack pli\r\n"
"a=rtpmap:102 H264/90000\r\n"
"a=rtcp-fb:102 ccm fir\r\n"; /* incorrect spacing */
static const gchar caps_video_rtcp_fb_pt_100[] =
"application/x-unknown, media=(string)video, payload=(int)100, "
"clock-rate=(int)90000, encoding-name=(string)VP8, "
"rtcp-fb-ccm-fir=(boolean)true, rtcp-fb-nack=(boolean)true, "
"rtcp-fb-nack-pli=(boolean)true";
static const gchar caps_video_rtcp_fb_pt_101[] =
"application/x-unknown, media=(string)video, payload=(int)101, "
"clock-rate=(int)90000, encoding-name=(string)VP9, "
"rtcp-fb-nack-pli=(boolean)true";
static const gchar caps_video_rtcp_fb_pt_102[] =
"application/x-unknown, media=(string)video, payload=(int)102, "
"clock-rate=(int)90000, encoding-name=(string)H264, "
"rtcp-fb-ccm-fir=(boolean)true";
static const gchar *sdp_rtcp_fb_all = "v=0\r\n"
"o=- 123456 2 IN IP4 127.0.0.1 \r\n"
"s=-\r\n"
"t=0 0\r\n"
"a=maxptime:60\r\n"
"a=sendrecv\r\n"
"m=video 1 UDP/TLS/RTP/SAVPF 100 101 102\r\n"
"c=IN IP4 1.1.1.1\r\n"
"a=rtpmap:100 VP8/90000\r\n"
"a=rtcp-fb:* nack\r\n"
"a=rtcp-fb:* nack pli\r\n"
"a=rtcp-fb:100 ccm fir\r\n"
"a=rtpmap:101 VP9/90000\r\n"
"a=rtcp-fb:101 ccm fir\r\n" "a=rtpmap:102 H264/90000\r\n";
static const gchar caps_video_rtcp_fb_all_pt_100[] =
"application/x-unknown, media=(string)video, payload=(int)100, "
"clock-rate=(int)90000, encoding-name=(string)VP8, "
"rtcp-fb-ccm-fir=(boolean)true, rtcp-fb-nack=(boolean)true, "
"rtcp-fb-nack-pli=(boolean)true";
static const gchar caps_video_rtcp_fb_all_pt_101[] =
"application/x-unknown, media=(string)video, payload=(int)101, "
"clock-rate=(int)90000, encoding-name=(string)VP9, "
"rtcp-fb-ccm-fir=(boolean)true, rtcp-fb-nack=(boolean)true, "
"rtcp-fb-nack-pli=(boolean)true";
static const gchar caps_video_rtcp_fb_all_pt_102[] =
"application/x-unknown, media=(string)video, payload=(int)102, "
"clock-rate=(int)90000, encoding-name=(string)H264, "
"rtcp-fb-nack=(boolean)true, rtcp-fb-nack-pli=(boolean)true";
GST_START_TEST (boxed)
{
GValue value = G_VALUE_INIT;
@ -296,6 +362,164 @@ GST_START_TEST (media_from_caps)
gst_sdp_message_free (message);
}
GST_END_TEST
GST_START_TEST (caps_from_media_rtcp_fb)
{
GstSDPMessage *message;
glong length = -1;
const GstSDPMedia *media1;
GstCaps *caps1, *caps2, *caps3;
GstCaps *result1, *result2, *result3;
gst_sdp_message_new (&message);
gst_sdp_message_parse_buffer ((guint8 *) sdp_rtcp_fb, length, message);
media1 = gst_sdp_message_get_media (message, 0);
fail_unless (media1 != NULL);
caps1 = gst_sdp_media_get_caps_from_media (media1, 100);
result1 = gst_caps_from_string (caps_video_rtcp_fb_pt_100);
fail_unless (gst_caps_is_strictly_equal (caps1, result1));
gst_caps_unref (result1);
gst_caps_unref (caps1);
caps2 = gst_sdp_media_get_caps_from_media (media1, 101);
result2 = gst_caps_from_string (caps_video_rtcp_fb_pt_101);
fail_unless (gst_caps_is_strictly_equal (caps2, result2));
gst_caps_unref (result2);
gst_caps_unref (caps2);
caps3 = gst_sdp_media_get_caps_from_media (media1, 102);
result3 = gst_caps_from_string (caps_video_rtcp_fb_pt_102);
fail_unless (gst_caps_is_strictly_equal (caps3, result3));
gst_caps_unref (result3);
gst_caps_unref (caps3);
gst_sdp_message_free (message);
}
GST_END_TEST
GST_START_TEST (caps_from_media_rtcp_fb_all)
{
GstSDPMessage *message;
glong length = -1;
const GstSDPMedia *media1;
GstCaps *caps1, *caps2, *caps3;
GstCaps *result1, *result2, *result3;
gst_sdp_message_new (&message);
gst_sdp_message_parse_buffer ((guint8 *) sdp_rtcp_fb_all, length, message);
media1 = gst_sdp_message_get_media (message, 0);
fail_unless (media1 != NULL);
caps1 = gst_sdp_media_get_caps_from_media (media1, 100);
result1 = gst_caps_from_string (caps_video_rtcp_fb_all_pt_100);
fail_unless (gst_caps_is_strictly_equal (caps1, result1));
gst_caps_unref (result1);
gst_caps_unref (caps1);
caps2 = gst_sdp_media_get_caps_from_media (media1, 101);
result2 = gst_caps_from_string (caps_video_rtcp_fb_all_pt_101);
fail_unless (gst_caps_is_strictly_equal (caps2, result2));
gst_caps_unref (result2);
gst_caps_unref (caps2);
caps3 = gst_sdp_media_get_caps_from_media (media1, 102);
result3 = gst_caps_from_string (caps_video_rtcp_fb_all_pt_102);
fail_unless (gst_caps_is_strictly_equal (caps3, result3));
gst_caps_unref (result3);
gst_caps_unref (caps3);
gst_sdp_message_free (message);
}
GST_END_TEST
GST_START_TEST (media_from_caps_rtcp_fb_pt_100)
{
GstSDPResult ret = GST_SDP_OK;
GstSDPMessage *message;
glong length = -1;
GstSDPMedia *media_caps;
const GstSDPMedia *media_sdp;
GstCaps *caps;
const gchar *attr_val_caps1, *attr_val_caps2, *attr_val_caps3;
const gchar *attr_val_sdp1, *attr_val_sdp2, *attr_val_sdp3;
caps = gst_caps_from_string (caps_video_rtcp_fb_pt_100);
gst_sdp_media_new (&media_caps);
fail_unless (media_caps != NULL);
ret = gst_sdp_media_set_media_from_caps (caps, media_caps);
fail_unless (ret == GST_SDP_OK);
gst_caps_unref (caps);
gst_sdp_message_new (&message);
gst_sdp_message_parse_buffer ((guint8 *) sdp_rtcp_fb, length, message);
media_sdp = gst_sdp_message_get_media (message, 0);
fail_unless (media_sdp != NULL);
attr_val_caps1 = gst_sdp_media_get_attribute_val_n (media_caps, "rtcp-fb", 0);
attr_val_caps2 = gst_sdp_media_get_attribute_val_n (media_caps, "rtcp-fb", 1);
attr_val_caps3 = gst_sdp_media_get_attribute_val_n (media_caps, "rtcp-fb", 2);
attr_val_sdp1 = gst_sdp_media_get_attribute_val_n (media_sdp, "rtcp-fb", 0);
attr_val_sdp2 = gst_sdp_media_get_attribute_val_n (media_sdp, "rtcp-fb", 1);
attr_val_sdp3 = gst_sdp_media_get_attribute_val_n (media_sdp, "rtcp-fb", 2);
fail_if (g_strcmp0 (attr_val_caps1, attr_val_sdp1) != 0);
fail_if (g_strcmp0 (attr_val_caps2, attr_val_sdp2) != 0);
fail_if (g_strcmp0 (attr_val_caps3, attr_val_sdp3) != 0);
gst_sdp_media_free (media_caps);
gst_sdp_message_free (message);
}
GST_END_TEST
GST_START_TEST (media_from_caps_rtcp_fb_pt_101)
{
GstSDPResult ret = GST_SDP_OK;
GstSDPMessage *message;
glong length = -1;
GstSDPMedia *media_caps;
const GstSDPMedia *media_sdp;
GstCaps *caps;
const gchar *attr_val_caps1, *attr_val_sdp1;
caps = gst_caps_from_string (caps_video_rtcp_fb_pt_101);
gst_sdp_media_new (&media_caps);
fail_unless (media_caps != NULL);
ret = gst_sdp_media_set_media_from_caps (caps, media_caps);
fail_unless (ret == GST_SDP_OK);
gst_caps_unref (caps);
gst_sdp_message_new (&message);
gst_sdp_message_parse_buffer ((guint8 *) sdp_rtcp_fb, length, message);
media_sdp = gst_sdp_message_get_media (message, 0);
fail_unless (media_sdp != NULL);
attr_val_caps1 = gst_sdp_media_get_attribute_val (media_caps, "rtcp-fb");
attr_val_sdp1 = gst_sdp_media_get_attribute_val_n (media_sdp, "rtcp-fb", 3);
fail_if (g_strcmp0 (attr_val_caps1, attr_val_sdp1) != 0);
gst_sdp_media_free (media_caps);
gst_sdp_message_free (message);
}
GST_END_TEST
/*
* End of test cases
@ -312,6 +536,10 @@ sdp_suite (void)
tcase_add_test (tc_chain, modify);
tcase_add_test (tc_chain, caps_from_media);
tcase_add_test (tc_chain, media_from_caps);
tcase_add_test (tc_chain, caps_from_media_rtcp_fb);
tcase_add_test (tc_chain, caps_from_media_rtcp_fb_all);
tcase_add_test (tc_chain, media_from_caps_rtcp_fb_pt_100);
tcase_add_test (tc_chain, media_from_caps_rtcp_fb_pt_101);
return s;
}