2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2005 Wim Taymans <wim@fluendo.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef __GST_BASE_TRANSFORM_H__
22 #define __GST_BASE_TRANSFORM_H__
28 #define GST_TYPE_BASE_TRANSFORM (gst_base_transform_get_type())
29 #define GST_BASE_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_TRANSFORM,GstBaseTransform))
30 #define GST_BASE_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_TRANSFORM,GstBaseTransformClass))
31 #define GST_BASE_TRANSFORM_GET_CLASS(obj) \
32 (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_BASE_TRANSFORM,GstBaseTransformClass))
33 #define GST_IS_BASE_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_TRANSFORM))
34 #define GST_IS_BASE_TRANSFORM_CLASS(obj)(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_TRANSFORM))
37 * GST_BASE_TRANSFORM_SINK_NAME:
39 * the name of the templates for the sink pad
41 #define GST_BASE_TRANSFORM_SINK_NAME "sink"
43 * GST_BASE_TRANSFORM_SRC_NAME:
45 * the name of the templates for the source pad
47 #define GST_BASE_TRANSFORM_SRC_NAME "src"
49 typedef struct _GstBaseTransform GstBaseTransform;
50 typedef struct _GstBaseTransformClass GstBaseTransformClass;
55 * The opaque #GstBaseTransform data structure.
57 struct _GstBaseTransform {
61 /* source and sink pads */
65 /* Set by sub-class */
67 gboolean always_in_place;
70 guint cache_caps1_size;
72 guint cache_caps2_size;
73 gboolean have_same_caps;
75 gboolean delay_configure;
76 gboolean pending_configure;
79 gboolean have_newsegment;
81 /* MT-protected (with STREAM_LOCK) */
84 GMutex *transform_lock;
87 gpointer _gst_reserved[GST_PADDING];
91 * GstBaseTransformClass::transform_caps:
92 * @direction: the pad direction
95 * This method should answer the question "given this pad, and given these
96 * caps, what caps would you allow on the other pad inside your element ?"
98 struct _GstBaseTransformClass {
99 GstElementClass parent_class;
102 /* virtual methods for subclasses */
104 /* given the (non-)fixed simple caps on the pad in the given direction,
105 * what can I do on the other pad ? */
106 GstCaps* (*transform_caps) (GstBaseTransform *trans,
107 GstPadDirection direction,
110 /* given caps on one pad, how would you fixate caps on the other pad ? */
111 void (*fixate_caps) (GstBaseTransform *trans,
112 GstPadDirection direction, GstCaps *caps,
115 /* given the size of a buffer in the given direction with the given caps,
116 * calculate the byte size of an buffer on the other side with the given
117 * other caps; the default
118 * implementation uses get_size and keeps the number of units the same */
119 gboolean (*transform_size) (GstBaseTransform *trans,
120 GstPadDirection direction,
121 GstCaps *caps, guint size,
122 GstCaps *othercaps, guint *othersize);
124 /* get the byte size of one unit for a given caps.
125 * Always needs to be implemented if the transform is not in-place. */
126 gboolean (*get_unit_size) (GstBaseTransform *trans, GstCaps *caps,
129 /* notify the subclass of new caps */
130 gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *incaps,
133 /* start and stop processing, ideal for opening/closing the resource */
134 gboolean (*start) (GstBaseTransform *trans);
135 gboolean (*stop) (GstBaseTransform *trans);
137 gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
139 /* transform one incoming buffer to one outgoing buffer.
140 * Always needs to be implemented unless always operating in-place.
141 * transform function is allowed to change size/timestamp/duration of
142 * the outgoing buffer. */
143 GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf,
146 /* transform a buffer inplace */
147 GstFlowReturn (*transform_ip) (GstBaseTransform *trans, GstBuffer *buf);
149 /* FIXME: When adjusting the padding, more these to nicer places in the class */
150 /* Set by child classes to automatically do passthrough mode */
151 gboolean passthrough_on_same_caps;
153 /* Subclasses can override this to do their own allocation of output buffers.
154 * Elements that only do analysis can return a subbuffer or even just
155 * increment the reference to the input buffer (if in passthrough mode)
157 GstFlowReturn (*prepare_output_buffer) (GstBaseTransform * trans,
158 GstBuffer *input, gint size, GstCaps *caps, GstBuffer **buf);
161 gpointer _gst_reserved[GST_PADDING - 2];
164 GType gst_base_transform_get_type (void);
166 void gst_base_transform_set_passthrough (GstBaseTransform *trans,
167 gboolean passthrough);
168 gboolean gst_base_transform_is_passthrough (GstBaseTransform *trans);
170 void gst_base_transform_set_in_place (GstBaseTransform *trans,
172 gboolean gst_base_transform_is_in_place (GstBaseTransform *trans);
177 #endif /* __GST_BASE_TRANSFORM_H__ */