Port gtk-doc comments to their equivalent markdown syntax
[platform/upstream/gstreamer.git] / libs / gst / base / gstbasetransform.h
index 16eed7a..ee1bd7b 100644 (file)
@@ -14,8 +14,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #ifndef __GST_BASE_TRANSFORM_H__
@@ -31,7 +31,6 @@ G_BEGIN_DECLS
 #define GST_BASE_TRANSFORM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_TRANSFORM,GstBaseTransformClass))
 #define GST_IS_BASE_TRANSFORM(obj)        (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_TRANSFORM))
 #define GST_IS_BASE_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_TRANSFORM))
-/* since 0.10.4 */
 #define GST_BASE_TRANSFORM_CAST(obj)   ((GstBaseTransform *)(obj))
 
 /**
@@ -52,8 +51,6 @@ G_BEGIN_DECLS
  * @obj: base transform instance
  *
  * Gives the pointer to the source #GstPad object of the element.
- *
- * Since: 0.10.4
  */
 #define GST_BASE_TRANSFORM_SRC_PAD(obj)                (GST_BASE_TRANSFORM_CAST (obj)->srcpad)
 
@@ -62,8 +59,6 @@ G_BEGIN_DECLS
  * @obj: base transform instance
  *
  * Gives the pointer to the sink #GstPad object of the element.
- *
- * Since: 0.10.4
  */
 #define GST_BASE_TRANSFORM_SINK_PAD(obj)       (GST_BASE_TRANSFORM_CAST (obj)->sinkpad)
 
@@ -72,31 +67,9 @@ G_BEGIN_DECLS
  *
  * A #GstFlowReturn that can be returned from transform and transform_ip to
  * indicate that no output buffer was generated.
- *
- * Since: 0.10.13
  */
 #define GST_BASE_TRANSFORM_FLOW_DROPPED   GST_FLOW_CUSTOM_SUCCESS
 
-/**
- * GST_BASE_TRANSFORM_LOCK:
- * @obj: base transform instance
- *
- * Obtain a lock to protect the transform function from concurrent access.
- *
- * Since: 0.10.13
- */
-#define GST_BASE_TRANSFORM_LOCK(obj)   g_mutex_lock (GST_BASE_TRANSFORM_CAST (obj)->transform_lock)
-
-/**
- * GST_BASE_TRANSFORM_UNLOCK:
- * @obj: base transform instance
- *
- * Release the lock that protects the transform function from concurrent access.
- *
- * Since: 0.10.13
- */
-#define GST_BASE_TRANSFORM_UNLOCK(obj) g_mutex_unlock (GST_BASE_TRANSFORM_CAST (obj)->transform_lock)
-
 typedef struct _GstBaseTransform GstBaseTransform;
 typedef struct _GstBaseTransformClass GstBaseTransformClass;
 typedef struct _GstBaseTransformPrivate GstBaseTransformPrivate;
@@ -114,58 +87,65 @@ struct _GstBaseTransform {
   GstPad       *sinkpad;
   GstPad       *srcpad;
 
-  /* Set by sub-class */
-  gboolean      passthrough;
-  gboolean      always_in_place;
-
-  GstCaps      *cache_caps1;
-  gsize                 cache_caps1_size;
-  GstCaps      *cache_caps2;
-  gsize                 cache_caps2_size;
-  gboolean      have_same_caps;
-
-  gboolean      negotiated;
-
-  gboolean       have_segment;
-
   /* MT-protected (with STREAM_LOCK) */
+  gboolean       have_segment;
   GstSegment     segment;
-
-  GMutex       *transform_lock;
+  /* Default submit_input_buffer places the buffer here,
+   * for consumption by the generate_output method: */
+  GstBuffer      *queued_buf;
 
   /*< private >*/
   GstBaseTransformPrivate *priv;
 
-  gpointer       _gst_reserved[GST_PADDING_LARGE];
+  gpointer       _gst_reserved[GST_PADDING_LARGE-1];
 };
 
 /**
  * GstBaseTransformClass:
  * @parent_class:   Element parent class
- * @passthrough_on_same_caps: If set to TRUE, passthrough mode will be
+ * @passthrough_on_same_caps: If set to %TRUE, passthrough mode will be
  *                            automatically enabled if the caps are the same.
+ *                            Set to %FALSE by default.
+ * @transform_ip_on_passthrough: If set to %TRUE, @transform_ip will be called in
+ *                           passthrough mode. The passed buffer might not be
+ *                           writable. When %FALSE, neither @transform nor
+ *                           @transform_ip will be called in passthrough mode.
+ *                           Set to %TRUE by default.
  * @transform_caps: Optional.  Given the pad in this direction and the given
  *                  caps, what caps are allowed on the other pad in this
  *                  element ?
  * @fixate_caps:    Optional. Given the pad in this direction and the given
- *                  caps, fixate the caps on the other pad.
- * @accept_caps:    Optional. Since 0.10.30
+ *                  caps, fixate the caps on the other pad. The function takes
+ *                  ownership of @othercaps and returns a fixated version of
+ *                  @othercaps. @othercaps is not guaranteed to be writable.
+ * @accept_caps:    Optional.
  *                  Subclasses can override this method to check if @caps can be
  *                  handled by the element. The default implementation might not be
  *                  the most optimal way to check this in all cases.
  * @set_caps:       allows the subclass to be notified of the actual caps set.
- * @query:          Optional Since 0.10.36
+ * @query:          Optional.
  *                  Handle a requested query. Subclasses that implement this
  *                  should must chain up to the parent if they didn't handle the
  *                  query
- * @propose_allocation: Propose buffer allocation parameters for upstream elements.
- *                      This function is only called when not operating in
- *                      passthrough mode. The default implementation is NULL.
  * @decide_allocation: Setup the allocation parameters for allocating output
  *                    buffers. The passed in query contains the result of the
  *                    downstream allocation query. This function is only called
  *                    when not operating in passthrough mode. The default
- *                    implementation is NULL.
+ *                    implementation will remove all memory dependent metadata.
+ *                    If there is a @filter_meta method implementation, it will
+ *                    be called for all metadata API in the downstream query,
+ *                    otherwise the metadata API is removed.
+ * @filter_meta: Return %TRUE if the metadata API should be proposed in the
+ *               upstream allocation query. The default implementation is %NULL
+ *               and will cause all metadata to be removed.
+ * @propose_allocation: Propose buffer allocation parameters for upstream elements.
+ *                      This function must be implemented if the element reads or
+ *                      writes the buffer content. The query that was passed to
+ *                      the decide_allocation is passed in this method (or %NULL
+ *                      when the element is in passthrough mode). The default
+ *                      implementation will pass the query downstream when in
+ *                      passthrough mode and will copy all the filtered metadata
+ *                      API in non-passthrough mode.
  * @transform_size: Optional. Given the size of a buffer in the given direction
  *                  with the given caps, calculate the size in bytes of a buffer
  *                  on the other pad with the given other caps.
@@ -198,7 +178,11 @@ struct _GstBaseTransform {
  *                 Copy the metadata from the input buffer to the output buffer.
  *                 The default implementation will copy the flags, timestamps and
  *                 offsets of the buffer.
- * @before_transform: Optional. Since 0.10.22
+ * @transform_meta: Optional. Transform the metadata on the input buffer to the
+ *                  output buffer. By default this method copies all meta without
+ *                  tags. subclasses can implement this method and return %TRUE if
+ *                  the metadata is to be copied.
+ * @before_transform: Optional.
  *                    This method is called right before the base class will
  *                    start processing. Dynamic properties or other delayed
  *                    configuration could be performed in this method.
@@ -208,6 +192,22 @@ struct _GstBaseTransform {
  *                  of the outgoing buffer.
  * @transform_ip:   Required if the element operates in-place.
  *                  Transform the incoming buffer in-place.
+ * @submit_input_buffer: Function which accepts a new input buffer and pre-processes it.
+ *                  The default implementation performs caps (re)negotiation, then
+ *                  QoS if needed, and places the input buffer into the @queued_buf
+ *                  member variable. If the buffer is dropped due to QoS, it returns
+ *                  GST_BASE_TRANSFORM_FLOW_DROPPED. If this input buffer is not
+ *                  contiguous with any previous input buffer, then @is_discont
+ *                  is set to #TRUE. (Since 1.6)
+ * @generate_output: Called after each new input buffer is submitted repeatedly
+ *                   until it either generates an error or fails to generate an output
+ *                   buffer. The default implementation takes the contents of the
+ *                   @queued_buf variable, generates an output buffer if needed
+ *                   by calling the class @prepare_output_buffer, and then
+ *                   calls either @transform or @transform_ip. Elements that don't
+ *                   do 1-to-1 transformations on input to output buffers can either
+ *                   return GST_BASE_TRANSFORM_FLOW_DROPPED or simply not generate
+ *                   an output buffer until they are ready to do so. (Since 1.6)
  *
  * Subclasses can override any of the available virtual methods or not, as
  * needed. At minimum either @transform or @transform_ip need to be overridden.
@@ -219,12 +219,13 @@ struct _GstBaseTransformClass {
 
   /*< public >*/
   gboolean       passthrough_on_same_caps;
+  gboolean       transform_ip_on_passthrough;
 
   /* virtual methods for subclasses */
   GstCaps*     (*transform_caps) (GstBaseTransform *trans,
                                    GstPadDirection direction,
                                    GstCaps *caps, GstCaps *filter);
-  void         (*fixate_caps)    (GstBaseTransform *trans,
+  GstCaps*     (*fixate_caps)    (GstBaseTransform *trans,
                                    GstPadDirection direction, GstCaps *caps,
                                    GstCaps *othercaps);
   gboolean      (*accept_caps)    (GstBaseTransform *trans, GstPadDirection direction,
@@ -234,10 +235,14 @@ struct _GstBaseTransformClass {
   gboolean      (*query)          (GstBaseTransform *trans, GstPadDirection direction,
                                    GstQuery *query);
 
-  /* propose allocation query parameters for input buffers */
-  gboolean      (*propose_allocation) (GstBaseTransform *trans, GstQuery *query);
   /* decide allocation query for output buffers */
-  gboolean      (*decide_allocation) (GstBaseTransform *trans, GstQuery *query);
+  gboolean      (*decide_allocation)  (GstBaseTransform *trans, GstQuery *query);
+  gboolean      (*filter_meta)        (GstBaseTransform *trans, GstQuery *query,
+                                       GType api, const GstStructure *params);
+
+  /* propose allocation query parameters for input buffers */
+  gboolean      (*propose_allocation) (GstBaseTransform *trans, GstQuery *decide_query,
+                                       GstQuery *query);
 
   /* transform size */
   gboolean      (*transform_size) (GstBaseTransform *trans,
@@ -259,8 +264,11 @@ struct _GstBaseTransformClass {
   GstFlowReturn (*prepare_output_buffer) (GstBaseTransform * trans,
                                           GstBuffer *input, GstBuffer **outbuf);
 
-  gboolean      (*copy_metadata)     (GstBaseTransform * trans, GstBuffer *input,
+  /* metadata */
+  gboolean      (*copy_metadata)     (GstBaseTransform *trans, GstBuffer *input,
                                       GstBuffer *outbuf);
+  gboolean      (*transform_meta)    (GstBaseTransform *trans, GstBuffer *outbuf,
+                                      GstMeta *meta, GstBuffer *inbuf);
 
   void          (*before_transform)  (GstBaseTransform *trans, GstBuffer *buffer);
 
@@ -269,8 +277,11 @@ struct _GstBaseTransformClass {
                                  GstBuffer *outbuf);
   GstFlowReturn (*transform_ip) (GstBaseTransform *trans, GstBuffer *buf);
 
+  GstFlowReturn (*submit_input_buffer) (GstBaseTransform *trans, gboolean is_discont, GstBuffer *input);
+  GstFlowReturn (*generate_output) (GstBaseTransform *trans, GstBuffer **outbuf);
+
   /*< private >*/
-  gpointer       _gst_reserved[GST_PADDING_LARGE];
+  gpointer       _gst_reserved[GST_PADDING_LARGE - 2];
 };
 
 GType           gst_base_transform_get_type         (void);
@@ -294,9 +305,22 @@ gboolean   gst_base_transform_is_qos_enabled   (GstBaseTransform *trans);
 void            gst_base_transform_set_gap_aware    (GstBaseTransform *trans,
                                                      gboolean gap_aware);
 
-void           gst_base_transform_suggest          (GstBaseTransform *trans,
-                                                    GstCaps *caps, gsize size);
-void           gst_base_transform_reconfigure      (GstBaseTransform *trans);
+void            gst_base_transform_set_prefer_passthrough (GstBaseTransform *trans,
+                                                           gboolean prefer_passthrough);
+
+GstBufferPool * gst_base_transform_get_buffer_pool  (GstBaseTransform *trans);
+void            gst_base_transform_get_allocator    (GstBaseTransform *trans,
+                                                     GstAllocator **allocator,
+                                                     GstAllocationParams *params);
+
+void           gst_base_transform_reconfigure_sink (GstBaseTransform *trans);
+void           gst_base_transform_reconfigure_src  (GstBaseTransform *trans);
+gboolean gst_base_transform_update_src_caps (GstBaseTransform *trans,
+                                             GstCaps *updated_caps);
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstBaseTransform, gst_object_unref)
+#endif
+
 G_END_DECLS
 
 #endif /* __GST_BASE_TRANSFORM_H__ */