docs: update more documentation
[platform/upstream/gstreamer.git] / gst / gstevent.c
index 8d624a1..a0b97f8 100644 (file)
  * elements will use gst_pad_send_event() or gst_pad_push_event().
  * The event should be unreffed with gst_event_unref() if it has not been sent.
  *
- * Events that have been received can be parsed with their respective 
+ * Events that have been received can be parsed with their respective
  * gst_event_parse_*() functions. It is valid to pass %NULL for unwanted details.
  *
  * Events are passed between elements in parallel to the data stream. Some events
  * are serialized with buffers, others are not. Some events only travel downstream,
- * others only upstream. Some events can travel both upstream and downstream. 
- * 
+ * others only upstream. Some events can travel both upstream and downstream.
+ *
  * The events are used to signal special conditions in the datastream such as
  * EOS (end of stream) or the start of a new stream-segment.
  * Events are also used to flush the pipeline of any pending data.
  *
- * Most of the event API is used inside plugins. Applications usually only 
- * construct and use seek events. 
+ * Most of the event API is used inside plugins. Applications usually only
+ * construct and use seek events.
  * To do that gst_event_new_seek() is used to create a seek event. It takes
  * the needed parameters to specify seeking time and mode.
  * <example>
@@ -72,7 +72,7 @@
  *   </programlisting>
  * </example>
  *
- * Last reviewed on 2006-09-6 (0.10.10)
+ * Last reviewed on 2012-03-28 (0.11.3)
  */
 
 
@@ -452,10 +452,6 @@ gst_event_set_seqnum (GstEvent * event, guint32 seqnum)
   GST_EVENT_SEQNUM (event) = seqnum;
 }
 
-/* FIXME 0.11: It would be nice to have flush events
- * that don't reset the running time in the sinks
- */
-
 /**
  * gst_event_new_flush_start:
  *
@@ -464,8 +460,8 @@ gst_event_set_seqnum (GstEvent * event, guint32 seqnum)
  *
  * It marks pads as being flushing and will make them return
  * #GST_FLOW_FLUSHING when used for data flow with gst_pad_push(),
- * gst_pad_chain(), gst_pad_alloc_buffer(), gst_pad_get_range() and
- * gst_pad_pull_range(). Any event (except a #GST_EVENT_FLUSH_STOP) received
+ * gst_pad_chain(), gst_pad_get_range() and gst_pad_pull_range().
+ * Any event (except a #GST_EVENT_FLUSH_STOP) received
  * on a flushing pad will return %FALSE immediately.
  *
  * Elements should unlock any blocking functions and exit their streaming
@@ -540,7 +536,7 @@ gst_event_parse_flush_stop (GstEvent * event, gboolean * reset_time)
  *
  * Create a new EOS event. The eos event can only travel downstream
  * synchronized with the buffer flow. Elements that receive the EOS
- * event on a pad can return #GST_FLOW_UNEXPECTED as a #GstFlowReturn
+ * event on a pad can return #GST_FLOW_EOS as a #GstFlowReturn
  * when data after the EOS event arrives.
  *
  * The EOS event will travel down to the sink elements in the pipeline
@@ -596,6 +592,7 @@ gst_event_new_gap (GstClockTime timestamp, GstClockTime duration)
 
 /**
  * gst_event_parse_gap:
+ * @event: a #GstEvent of type #GST_EVENT_GAP
  * @timestamp: (out) (allow-none): location where to store the
  *     start time (pts) of the gap, or %NULL
  * @duration: (out) (allow-none): location where to store the duration of
@@ -675,7 +672,7 @@ gst_event_parse_caps (GstEvent * event, GstCaps ** caps)
  * Create a new STREAM CONFIG event. The stream config event travels
  * downstream synchronized with the buffer flow and contains stream
  * configuration information for the stream, such as stream-headers
- * or codec-data. It is optional and should be sent after the CAPS
+ * or setup-data. It is optional and should be sent after the CAPS
  * event.
  *
  * Returns: (transfer full): the new STREAM CONFIG event.
@@ -718,18 +715,18 @@ gst_event_parse_stream_config (GstEvent * event, GstStreamConfigFlags * flags)
 }
 
 /**
- * gst_event_set_stream_config_codec_data:
+ * gst_event_set_stream_config_setup_data:
  * @event: a stream config event
- * @buf: a #GstBuffer with codec data
+ * @buf: a #GstBuffer with setup data
  *
- * Set codec data on the stream info event to signal out of bound setup data
- * to downstream elements. Unlike stream headers, codec data contains data
+ * Set setup data on the stream info event to signal out of bound setup data
+ * to downstream elements. Unlike stream headers, setup data contains data
  * that is required to interpret the data stream, but is not valid as-is
  * inside the data stream and thus can't just be prepended to or inserted
  * into the data stream.
  */
 void
-gst_event_set_stream_config_codec_data (GstEvent * event, GstBuffer * buf)
+gst_event_set_stream_config_setup_data (GstEvent * event, GstBuffer * buf)
 {
   GstStructure *s;
 
@@ -738,35 +735,41 @@ gst_event_set_stream_config_codec_data (GstEvent * event, GstBuffer * buf)
   g_return_if_fail (GST_IS_BUFFER (buf) && gst_buffer_get_size (buf) > 0);
 
   s = GST_EVENT_STRUCTURE (event);
-  gst_structure_id_set (s, GST_QUARK (CODEC_DATA), GST_TYPE_BUFFER, buf, NULL);
+  gst_structure_id_set (s, GST_QUARK (SETUP_DATA), GST_TYPE_BUFFER, buf, NULL);
 }
 
 /**
- * gst_event_set_stream_config_codec_data:
+ * gst_event_parse_stream_config_setup_data:
  * @event: a stream config event
- * @buf: (out) (transfer none): location where to store the #GstBuffer with codec data
+ * @buf: (out) (transfer none): location where to store the #GstBuffer with setup data
  *
- * Extracts the codec data buffer from the stream info event. Will store
- * %NULL in @buf if the event contains no codec data. The buffer returned
+ * Extracts the setup data buffer from the stream info event. Will store
+ * %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
- * acquire a referenceto 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
-gst_event_parse_stream_config_codec_data (GstEvent * event, GstBuffer ** buf)
+gboolean
+gst_event_parse_stream_config_setup_data (GstEvent * event, GstBuffer ** buf)
 {
   const GValue *val;
   GstStructure *s;
 
-  g_return_if_fail (GST_IS_EVENT (event));
-  g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_CONFIG);
-  g_return_if_fail (buf != NULL);
+  g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
+  g_return_val_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_CONFIG,
+      FALSE);
+  g_return_val_if_fail (buf != NULL, FALSE);
 
   s = GST_EVENT_STRUCTURE (event);
-  val = gst_structure_id_get_value (s, GST_QUARK (CODEC_DATA));
+  val = gst_structure_id_get_value (s, GST_QUARK (SETUP_DATA));
   if (val != NULL)
     *buf = g_value_get_boxed (val);
   else
     *buf = NULL;
+
+  return (*buf != NULL);
 }
 
 /**
@@ -851,8 +854,11 @@ gst_event_get_n_stream_config_headers (GstEvent * event)
  * 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
  * 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,
     GstBuffer ** buf)
 {
@@ -860,9 +866,10 @@ gst_event_parse_nth_stream_config_header (GstEvent * event, guint index,
   GstStructure *s;
   GstBuffer *ret = NULL;
 
-  g_return_if_fail (GST_IS_EVENT (event));
-  g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_CONFIG);
-  g_return_if_fail (buf != NULL);
+  g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
+  g_return_val_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_CONFIG,
+      FALSE);
+  g_return_val_if_fail (buf != NULL, FALSE);
 
   s = GST_EVENT_STRUCTURE (event);
   val = gst_structure_id_get_value (s, GST_QUARK (STREAM_HEADERS));
@@ -874,6 +881,7 @@ gst_event_parse_nth_stream_config_header (GstEvent * event, guint index,
   }
 
   *buf = ret;
+  return (ret != NULL);
 }
 
 /**