sdp: Add new constructor, sdp_message_from_text

Helper function for bindings, in python for example
users can now replace:

res, msg = GstSdp.SDPMessage.new()
GstSdp.sdp_message_parse_buffer(bytes(text.encode()), msg)

with:

res, msg = GstSdp.SDPMessage.new_from_text(text)

https://bugzilla.gnome.org/show_bug.cgi?id=796563
This commit is contained in:
Mathieu Duponchelle 2018-06-11 18:32:28 +02:00
parent 4683182381
commit a4a27fdca8
3 changed files with 28 additions and 0 deletions

View file

@ -1983,6 +1983,7 @@ GstSDPMedia
GstSDPMessage
gst_sdp_message_new
gst_sdp_message_new_from_text
gst_sdp_message_copy
gst_sdp_message_init
gst_sdp_message_uninit

View file

@ -236,6 +236,30 @@ gst_sdp_message_new (GstSDPMessage ** msg)
return gst_sdp_message_init (newmsg);
}
/**
* gst_sdp_message_new_from_text:
* @msg: (out) (transfer full): pointer to new #GstSDPMessage
* @text: A dynamically allocated string representing the SDP description
*
* Parse @text and create a new SDPMessage from these.
*
* Returns: a #GstSDPResult.
* Since: 1.16
*/
GstSDPResult
gst_sdp_message_new_from_text (const gchar * text, GstSDPMessage ** msg)
{
GstSDPResult res;
if ((res = gst_sdp_message_new (msg)) != GST_SDP_OK)
return res;
res =
gst_sdp_message_parse_buffer ((const guint8 *) text, strlen (text), *msg);
return res;
}
/**
* gst_sdp_message_init:
* @msg: a #GstSDPMessage

View file

@ -340,6 +340,9 @@ GstSDPResult gst_sdp_message_parse_buffer (const guint8 *data,
GST_SDP_API
gchar* gst_sdp_message_as_text (const GstSDPMessage *msg);
GST_SDP_API
GstSDPResult gst_sdp_message_new_from_text (const gchar *text, GstSDPMessage ** msg);
/* convert from/to uri */
GST_SDP_API