Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / gst / gstpad.h
index b22bfad..344df07 100644 (file)
@@ -114,7 +114,7 @@ typedef enum {
  * @GST_FLOW_OK:                Data passing was ok.
  * @GST_FLOW_NOT_LINKED:        Pad is not linked.
  * @GST_FLOW_WRONG_STATE:       Pad is in wrong state.
- * @GST_FLOW_UNEXPECTED:        Did not expect anything, like after EOS.
+ * @GST_FLOW_EOS:                Pad is EOS.
  * @GST_FLOW_NOT_NEGOTIATED:    Pad is not negotiated.
  * @GST_FLOW_ERROR:             Some (fatal) error occured. Element generating
  *                               this error should post an error message with more
@@ -154,7 +154,7 @@ typedef enum {
   GST_FLOW_NOT_LINKED     = -1,
   GST_FLOW_WRONG_STATE    = -2,
   /* error cases */
-  GST_FLOW_UNEXPECTED     = -3,
+  GST_FLOW_EOS            = -3,
   GST_FLOW_NOT_NEGOTIATED = -4,
   GST_FLOW_ERROR         = -5,
   GST_FLOW_NOT_SUPPORTED  = -6,
@@ -209,32 +209,23 @@ typedef enum {
  *
  * Since: 0.10.30
  */
-#define GST_PAD_LINK_CHECK_DEFAULT (GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS)
+#define GST_PAD_LINK_CHECK_DEFAULT ((GstPadLinkCheck) (GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS))
 
 /**
- * GstActivateMode:
- * @GST_ACTIVATE_NONE:          Pad will not handle dataflow
- * @GST_ACTIVATE_PUSH:          Pad handles dataflow in downstream push mode
- * @GST_ACTIVATE_PULL:          Pad handles dataflow in upstream pull mode
+ * GstPadActivateMode:
+ * @GST_PAD_ACTIVATE_NONE: Pad will not handle dataflow
+ * @GST_PAD_ACTIVATE_PUSH: Pad handles dataflow in downstream push mode
+ * @GST_PAD_ACTIVATE_PULL: Pad handles dataflow in upstream pull mode
  *
  * The status of a GstPad. After activating a pad, which usually happens when the
- * parent element goes from READY to PAUSED, the GstActivateMode defines if the
+ * parent element goes from READY to PAUSED, the GstPadActivateMode defines if the
  * pad operates in push or pull mode.
  */
 typedef enum {
-  GST_ACTIVATE_NONE,
-  GST_ACTIVATE_PUSH,
-  GST_ACTIVATE_PULL
-} GstActivateMode;
-
-/**
- * GST_PAD_MODE_ACTIVATE:
- * @mode: a #GstActivateMode
- *
- * Macro to test if the given #GstActivateMode value indicates that datapassing
- * is possible or not.
- */
-#define GST_PAD_MODE_ACTIVATE(mode) ((mode) != GST_ACTIVATE_NONE)
+  GST_PAD_ACTIVATE_NONE,
+  GST_PAD_ACTIVATE_PUSH,
+  GST_PAD_ACTIVATE_PULL
+} GstPadActivateMode;
 
 /* pad states */
 /**
@@ -454,7 +445,7 @@ typedef gboolean            (*GstPadAcceptCapsFunction)     (GstPad *pad, GstCaps *caps);
  * @pad: a #GstPad
  * @caps: the #GstCaps to fixate
  *
- * Given possibly unfixed caps @caps, let @pad use its default prefered
+ * Given possibly unfixed caps @caps, let @pad use its default preferred
  * format to make a fixed caps. @caps should be writable. By default this
  * function will pick the first value of any ranges or lists in the caps but
  * elements can override this function to perform other behaviour.
@@ -475,70 +466,111 @@ typedef void                     (*GstPadFixateCapsFunction)     (GstPad *pad, GstCaps *caps);
 typedef gboolean               (*GstPadForwardFunction)        (GstPad *pad, gpointer user_data);
 
 /**
- * GstProbeType:
- * @GST_PROBE_TYPE_INVALID: invalid probe type
- * @GST_PROBE_TYPE_IDLE: probe idle pads and block
- * @GST_PROBE_TYPE_BLOCK: probe and block pads
- * @GST_PROBE_TYPE_BUFFER: probe buffers
- * @GST_PROBE_TYPE_BUFFER_LIST: probe buffer lists
- * @GST_PROBE_TYPE_EVENT: probe events
- * @GST_PROBE_TYPE_PUSH: probe push
- * @GST_PROBE_TYPE_PULL: probe pull
+ * GstPadProbeType:
+ * @GST_PAD_PROBE_TYPE_INVALID: invalid probe type
+ * @GST_PAD_PROBE_TYPE_IDLE: probe idle pads and block
+ * @GST_PAD_PROBE_TYPE_BLOCK: probe and block pads
+ * @GST_PAD_PROBE_TYPE_BUFFER: probe buffers
+ * @GST_PAD_PROBE_TYPE_BUFFER_LIST: probe buffer lists
+ * @GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM: probe downstream events
+ * @GST_PAD_PROBE_TYPE_EVENT_UPSTREAM: probe upstream events
+ * @GST_PAD_PROBE_TYPE_PUSH: probe push
+ * @GST_PAD_PROBE_TYPE_PULL: probe pull
  *
  * The different probing types that can occur. When either one of
- * @GST_PROBE_TYPE_IDLE or @GST_PROBE_TYPE_BLOCK is used, the probe will be a
+ * @GST_PAD_PROBE_TYPE_IDLE or @GST_PAD_PROBE_TYPE_BLOCK is used, the probe will be a
  * blocking probe.
  */
 typedef enum
 {
-  GST_PROBE_TYPE_INVALID      = 0,
+  GST_PAD_PROBE_TYPE_INVALID          = 0,
   /* flags to control blocking */
-  GST_PROBE_TYPE_IDLE         = (1 << 0),
-  GST_PROBE_TYPE_BLOCK        = (1 << 1),
+  GST_PAD_PROBE_TYPE_IDLE             = (1 << 0),
+  GST_PAD_PROBE_TYPE_BLOCK            = (1 << 1),
   /* flags to select datatypes */
-  GST_PROBE_TYPE_BUFFER       = (1 << 2),
-  GST_PROBE_TYPE_BUFFER_LIST  = (1 << 3),
-  GST_PROBE_TYPE_EVENT        = (1 << 4),
+  GST_PAD_PROBE_TYPE_BUFFER           = (1 << 2),
+  GST_PAD_PROBE_TYPE_BUFFER_LIST      = (1 << 3),
+  GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM = (1 << 4),
+  GST_PAD_PROBE_TYPE_EVENT_UPSTREAM   = (1 << 5),
   /* flags to select scheduling mode */
-  GST_PROBE_TYPE_PUSH         = (1 << 5),
-  GST_PROBE_TYPE_PULL         = (1 << 6),
-} GstProbeType;
-
-#define GST_PROBE_TYPE_BLOCKING   (GST_PROBE_TYPE_IDLE | GST_PROBE_TYPE_BLOCK)
-#define GST_PROBE_TYPE_DATA       (GST_PROBE_TYPE_BUFFER | GST_PROBE_TYPE_EVENT | \
-                                   GST_PROBE_TYPE_BUFFER_LIST)
-#define GST_PROBE_TYPE_SCHEDULING (GST_PROBE_TYPE_PUSH | GST_PROBE_TYPE_PULL)
-
-/**
- * GstProbeReturn:
- * @GST_PROBE_OK: normal probe return value
- * @GST_PROBE_DROP: drop data in data probes
- * @GST_PROBE_REMOVE: remove probe
- * @GST_PROBE_PASS: pass the data item in the block probe and block on
+  GST_PAD_PROBE_TYPE_PUSH             = (1 << 6),
+  GST_PAD_PROBE_TYPE_PULL             = (1 << 7),
+} GstPadProbeType;
+
+#define GST_PAD_PROBE_TYPE_BLOCKING         (GST_PAD_PROBE_TYPE_IDLE | GST_PAD_PROBE_TYPE_BLOCK)
+#define GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM (GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM)
+#define GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM   (GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_UPSTREAM)
+#define GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM  (GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | \
+                                             GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM)
+#define GST_PAD_PROBE_TYPE_DATA_UPSTREAM    (GST_PAD_PROBE_TYPE_EVENT_UPSTREAM)
+#define GST_PAD_PROBE_TYPE_DATA_BOTH        (GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM | \
+                                             GST_PAD_PROBE_TYPE_DATA_UPSTREAM)
+#define GST_PAD_PROBE_TYPE_EVENT_BOTH       (GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | \
+                                             GST_PAD_PROBE_TYPE_EVENT_UPSTREAM)
+#define GST_PAD_PROBE_TYPE_SCHEDULING       (GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_PULL)
+
+/**
+ * GstPadProbeReturn:
+ * @GST_PAD_PROBE_OK: normal probe return value
+ * @GST_PAD_PROBE_DROP: drop data in data probes
+ * @GST_PAD_PROBE_REMOVE: remove probe
+ * @GST_PAD_PROBE_PASS: pass the data item in the block probe and block on
  *                         the next item
  *
  * Different return values for the #GstPadProbeCallback.
  */
 typedef enum
 {
-  GST_PROBE_DROP,
-  GST_PROBE_OK,
-  GST_PROBE_REMOVE,
-  GST_PROBE_PASS,
-} GstProbeReturn;
+  GST_PAD_PROBE_DROP,
+  GST_PAD_PROBE_OK,
+  GST_PAD_PROBE_REMOVE,
+  GST_PAD_PROBE_PASS,
+} GstPadProbeReturn;
+
+
+/**
+ * GstPadProbeInfo:
+ * @type: the current probe type
+ * @data: type specific data, check the @type field to know the datatype.
+ *    This field can be NULL.
+ * @offset: offset of pull probe, this field is valid when @type contains
+ *    #GST_PAD_PROBE_TYPE_PULL
+ * @size: size of pull probe, this field is valid when @type contains
+ *    #GST_PAD_PROBE_TYPE_PULL
+ *
+ * Info passed in the #GstPadProbeCallback.
+ */
+typedef struct
+{
+  GstPadProbeType type;
+  gpointer data;
+  guint64 offset;
+  guint size;
+} GstPadProbeInfo;
+
+#define GST_PAD_PROBE_INFO_TYPE(d)         ((d)->type)
+#define GST_PAD_PROBE_INFO_DATA(d)         ((d)->data)
+
+#define GST_PAD_PROBE_INFO_BUFFER(d)       GST_BUFFER_CAST(GST_PAD_PROBE_INFO_DATA(d))
+#define GST_PAD_PROBE_INFO_BUFFER_LIST(d)  GST_BUFFER_LIST_CAST(GST_PAD_PROBE_INFO_DATA(d))
+#define GST_PAD_PROBE_INFO_EVENT(d)        GST_EVENT_CAST(GST_PAD_PROBE_INFO_DATA(d))
+
+#define GST_PAD_PROBE_INFO_OFFSET(d)       ((d)->offset)
+#define GST_PAD_PROBE_INFO_SIZE(d)         ((d)->size)
 
 /**
  * GstPadProbeCallback
  * @pad: the #GstPad that is blocked
- * @type: the current probe type
- * @type_data: type specific data
+ * @info: #GstPadProbeInfo
  * @user_data: the gpointer to optional user data.
  *
  * Callback used by gst_pad_add_probe(). Gets called to notify about the current
  * blocking type.
+ *
+ * The callback is allowed to modify the data pointer in @info.
  */
-typedef GstProbeReturn      (*GstPadProbeCallback)              (GstPad *pad, GstProbeType type,
-                                                                 gpointer type_data, gpointer user_data);
+typedef GstPadProbeReturn   (*GstPadProbeCallback)   (GstPad *pad, GstPadProbeInfo *info,
+                                                      gpointer user_data);
 
 /**
  * GstPadStickyEventsForeachFunction:
@@ -550,7 +582,8 @@ typedef GstProbeReturn      (*GstPadProbeCallback)              (GstPad *pad, Gs
  *
  * Returns: GST_FLOW_OK if the iteration should continue
  */
-typedef GstFlowReturn           (*GstPadStickyEventsForeachFunction) (GstPad *pad, GstEvent *event, gpointer user_data);
+typedef GstFlowReturn       (*GstPadStickyEventsForeachFunction) (GstPad *pad, GstEvent *event,
+                                                                  gpointer user_data);
 
 /**
  * GstPadFlags:
@@ -592,19 +625,22 @@ typedef enum {
  *                   the data used in streaming.
  * @task: task for this pad if the pad is actively driving dataflow.
  * @block_cond: conditional to signal pad block
+ * @probes: installed probes
  * @getcapsfunc: function to get caps of the pad
  * @acceptcapsfunc: function to check if pad can accept caps
  * @fixatecapsfunc: function to fixate caps
+ * @mode: current activation mode of the pad
  * @activatefunc: pad activation function
  * @activatepushfunc: function to activate/deactivate pad in push mode
  * @activatepullfunc: function to activate/deactivate pad in pull mode
+ * @peer: the pad this pad is linked to
  * @linkfunc: function called when pad is linked
  * @unlinkfunc: function called when pad is unlinked
- * @peer: the pad this pad is linked to
  * @chainfunc: function to chain buffer to pad
+ * @chainlistfunc: function to chain a list of buffers to pad
  * @getrangefunc: function to get a range of data from a pad
  * @eventfunc: function to send an event to a pad
- * @mode: current activation mode of the pad
+ * @offset: the pad offset
  * @querytypefunc: get list of supported queries
  * @queryfunc: perform a query on the pad
  * @iterintlinkfunc: get the internal links iterator of this pad
@@ -636,7 +672,7 @@ struct _GstPad {
   GstPadAcceptCapsFunction      acceptcapsfunc;
   GstPadFixateCapsFunction      fixatecapsfunc;
 
-  GstActivateMode               mode;
+  GstPadActivateMode            mode;
   GstPadActivateFunction        activatefunc;
   GstPadActivateModeFunction    activatepushfunc;
   GstPadActivateModeFunction    activatepullfunc;
@@ -662,11 +698,11 @@ struct _GstPad {
   /* internal links */
   GstPadIterIntLinkFunction      iterintlinkfunc;
 
+  /*< private >*/
   /* counts number of probes attached. */
   gint                          num_probes;
   gint                          num_blocked;
 
-  /*< private >*/
   GstPadPrivate                 *priv;
 
   gpointer _gst_reserved[GST_PADDING];
@@ -718,6 +754,8 @@ struct _GstPadClass {
 
 #define GST_PAD_IS_LINKED(pad)         (GST_PAD_PEER(pad) != NULL)
 
+#define GST_PAD_IS_ACTIVE(pad)          (GST_PAD_ACTIVATE_MODE(pad) != GST_PAD_ACTIVATE_NONE)
+
 #define GST_PAD_IS_BLOCKED(pad)                (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED))
 #define GST_PAD_IS_BLOCKING(pad)       (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING))
 #define GST_PAD_IS_FLUSHING(pad)       (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
@@ -818,7 +856,7 @@ gboolean            gst_pad_activate_pull                   (GstPad *pad, gboolean active);
 gboolean               gst_pad_activate_push                   (GstPad *pad, gboolean active);
 
 gulong                  gst_pad_add_probe                       (GstPad *pad,
-                                                                GstProbeType mask,
+                                                                GstPadProbeType mask,
                                                                 GstPadProbeCallback callback,
                                                                  gpointer user_data,
                                                                  GDestroyNotify destroy_data);
@@ -827,6 +865,7 @@ void                    gst_pad_remove_probe                    (GstPad *pad, gu
 gboolean               gst_pad_is_blocked                      (GstPad *pad);
 gboolean               gst_pad_is_blocking                     (GstPad *pad);
 
+void                    gst_pad_mark_reconfigure                (GstPad *pad);
 gboolean               gst_pad_check_reconfigure               (GstPad *pad);
 
 void                   gst_pad_set_element_private             (GstPad *pad, gpointer priv);
@@ -878,7 +917,6 @@ gboolean            gst_pad_peer_accept_caps                (GstPad * pad, GstCaps *caps);
 
 /* capsnego for linked pads */
 GstCaps *              gst_pad_get_allowed_caps                (GstPad * pad);
-GstCaps *               gst_pad_get_negotiated_caps             (GstPad * pad);
 
 /* pad offsets */
 gint64                  gst_pad_get_offset                      (GstPad *pad);