event: make _parse_nth_stream_config_header() and _parse_setup_data() return a boolean

As they can fail (only one of stream headers or setup data
is usually present).
This commit is contained in:
Tim-Philipp Müller 2012-02-12 21:04:18 +00:00
parent 4d937fafbb
commit 7329843fe6
2 changed files with 21 additions and 10 deletions

View file

@ -750,16 +750,20 @@ gst_event_set_stream_config_setup_data (GstEvent * event, GstBuffer * buf)
* %NULL in @buf if the event contains no setup data. The buffer returned * %NULL in @buf if the event contains no setup data. The buffer returned
* will remain valid as long as @event remains valid. The caller should * will remain valid as long as @event remains valid. The caller should
* acquire a reference to to @buf if needed. * acquire a reference to to @buf if needed.
*
* Returns: TRUE if @event contained setup data and @buf has been set,
* otherwise FALSE.
*/ */
void gboolean
gst_event_parse_stream_config_setup_data (GstEvent * event, GstBuffer ** buf) gst_event_parse_stream_config_setup_data (GstEvent * event, GstBuffer ** buf)
{ {
const GValue *val; const GValue *val;
GstStructure *s; GstStructure *s;
g_return_if_fail (GST_IS_EVENT (event)); g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_CONFIG); g_return_val_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_CONFIG,
g_return_if_fail (buf != NULL); FALSE);
g_return_val_if_fail (buf != NULL, FALSE);
s = GST_EVENT_STRUCTURE (event); s = GST_EVENT_STRUCTURE (event);
val = gst_structure_id_get_value (s, GST_QUARK (SETUP_DATA)); val = gst_structure_id_get_value (s, GST_QUARK (SETUP_DATA));
@ -767,6 +771,8 @@ gst_event_parse_stream_config_setup_data (GstEvent * event, GstBuffer ** buf)
*buf = g_value_get_boxed (val); *buf = g_value_get_boxed (val);
else else
*buf = NULL; *buf = NULL;
return (*buf != NULL);
} }
/** /**
@ -851,8 +857,11 @@ gst_event_get_n_stream_config_headers (GstEvent * event)
* Retrieves the n-th stream header buffer attached to the stream config * Retrieves the n-th stream header buffer attached to the stream config
* event and stores it in @buf. Will store %NULL in @buf if there is no such * event and stores it in @buf. Will store %NULL in @buf if there is no such
* stream header. * stream header.
*
* Returns: TRUE if @event contained a stream header at @index and @buf has
* been set, otherwise FALSE.
*/ */
void gboolean
gst_event_parse_nth_stream_config_header (GstEvent * event, guint index, gst_event_parse_nth_stream_config_header (GstEvent * event, guint index,
GstBuffer ** buf) GstBuffer ** buf)
{ {
@ -860,9 +869,10 @@ gst_event_parse_nth_stream_config_header (GstEvent * event, guint index,
GstStructure *s; GstStructure *s;
GstBuffer *ret = NULL; GstBuffer *ret = NULL;
g_return_if_fail (GST_IS_EVENT (event)); g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_CONFIG); g_return_val_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_CONFIG,
g_return_if_fail (buf != NULL); FALSE);
g_return_val_if_fail (buf != NULL, FALSE);
s = GST_EVENT_STRUCTURE (event); s = GST_EVENT_STRUCTURE (event);
val = gst_structure_id_get_value (s, GST_QUARK (STREAM_HEADERS)); val = gst_structure_id_get_value (s, GST_QUARK (STREAM_HEADERS));
@ -874,6 +884,7 @@ gst_event_parse_nth_stream_config_header (GstEvent * event, guint index,
} }
*buf = ret; *buf = ret;
return (ret != NULL);
} }
/** /**

View file

@ -503,14 +503,14 @@ void gst_event_parse_stream_config (GstEvent * event, Gs
void gst_event_set_stream_config_setup_data (GstEvent * event, GstBuffer * buf); void gst_event_set_stream_config_setup_data (GstEvent * event, GstBuffer * buf);
void gst_event_parse_stream_config_setup_data (GstEvent * event, GstBuffer ** buf); gboolean gst_event_parse_stream_config_setup_data (GstEvent * event, GstBuffer ** buf);
void gst_event_add_stream_config_header (GstEvent * event, GstBuffer * buf); void gst_event_add_stream_config_header (GstEvent * event, GstBuffer * buf);
guint gst_event_get_n_stream_config_headers (GstEvent * event); guint gst_event_get_n_stream_config_headers (GstEvent * event);
void gst_event_parse_nth_stream_config_header (GstEvent * event, guint index, GstBuffer ** buf); gboolean gst_event_parse_nth_stream_config_header (GstEvent * event, guint index, GstBuffer ** buf);
/* segment event */ /* segment event */
GstEvent* gst_event_new_segment (const GstSegment *segment) G_GNUC_MALLOC; GstEvent* gst_event_new_segment (const GstSegment *segment) G_GNUC_MALLOC;