sdpmessage: add_attribute accepts NULL value

The attribute can be defined without value regardless session-level
or media-level.
Although `gst_sdp_message_insert_attribute` can be used to set NULL,
it would be easier if `gst_sdp_message_add_attribute` accepts NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=789841
This commit is contained in:
Justin Kim 2017-11-01 11:23:17 +09:00 committed by Matthew Waters
parent a23d4d1c1f
commit 91179622eb
2 changed files with 32 additions and 5 deletions

View file

@ -1537,7 +1537,7 @@ gst_sdp_message_get_key (const GstSDPMessage * msg)
* gst_sdp_attribute_set:
* @attr: a #GstSDPAttribute
* @key: the key
* @value: the value
* @value: (nullable): the value
*
* Set the attribute with @key and @value.
*
@ -1698,7 +1698,7 @@ DEFINE_ARRAY_REMOVE (attribute, attributes, GstSDPAttribute, FREE_ATTRIBUTE);
* gst_sdp_message_add_attribute:
* @msg: a #GstSDPMessage
* @key: the key
* @value: the value
* @value: (nullable): the value
*
* Add the attribute with @key and @value to @msg.
*
@ -1712,7 +1712,6 @@ gst_sdp_message_add_attribute (GstSDPMessage * msg, const gchar * key,
g_return_val_if_fail (msg != NULL, GST_SDP_EINVAL);
g_return_val_if_fail (key != NULL, GST_SDP_EINVAL);
g_return_val_if_fail (value != NULL, GST_SDP_EINVAL);
gst_sdp_attribute_set (&attr, key, value);
g_array_append_val (msg->attributes, attr);
@ -2732,7 +2731,7 @@ gst_sdp_media_attributes_len (const GstSDPMedia * media)
* gst_sdp_media_add_attribute:
* @media: a #GstSDPMedia
* @key: a key
* @value: a value
* @value: (nullable): a value
*
* Add the attribute with @key and @value to @media.
*
@ -2746,7 +2745,6 @@ gst_sdp_media_add_attribute (GstSDPMedia * media, const gchar * key,
g_return_val_if_fail (media != NULL, GST_SDP_EINVAL);
g_return_val_if_fail (key != NULL, GST_SDP_EINVAL);
g_return_val_if_fail (value != NULL, GST_SDP_EINVAL);
gst_sdp_attribute_set (&attr, key, value);
g_array_append_val (media->attributes, attr);

View file

@ -277,6 +277,34 @@ GST_START_TEST (modify)
gst_sdp_message_free (message);
}
GST_END_TEST
GST_START_TEST (null)
{
GstSDPMessage *message;
const GstSDPMedia *media;
glong length = -1;
const gchar *val;
gst_sdp_message_new (&message);
gst_sdp_message_parse_buffer ((guint8 *) sdp, length, message);
fail_unless (gst_sdp_message_add_attribute (message,
"test_attr_session", NULL) == GST_SDP_OK);
val = gst_sdp_message_get_attribute_val (message, "test_attr_session");
fail_unless (val == NULL);
media = gst_sdp_message_get_media (message, 0);
fail_unless (gst_sdp_media_add_attribute ((GstSDPMedia *) media,
"test_attr_media", NULL) == GST_SDP_OK);
val = gst_sdp_media_get_attribute_val (media, "test_attr_media");
fail_unless (val == NULL);
gst_sdp_message_free (message);
}
GST_END_TEST
GST_START_TEST (caps_from_media)
{
@ -573,6 +601,7 @@ sdp_suite (void)
tcase_add_test (tc_chain, copy);
tcase_add_test (tc_chain, boxed);
tcase_add_test (tc_chain, modify);
tcase_add_test (tc_chain, null);
tcase_add_test (tc_chain, caps_from_media);
tcase_add_test (tc_chain, caps_from_media_really_const);
tcase_add_test (tc_chain, media_from_caps);