~ubuntu-branches/ubuntu/quantal/gst-plugins-bad0.10/quantal-proposed

« back to all changes in this revision

Viewing changes to gst/audioparsers/gstbaseparse.h

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine
  • Date: 2011-07-19 14:32:43 UTC
  • mfrom: (18.4.21 sid)
  • Revision ID: james.westby@ubuntu.com-20110719143243-p7pnkh45akfp0ihk
Tags: 0.10.22-2ubuntu1
* Rebased on debian unstable, remaining changes:
  - debian/gstreamer-plugins-bad.install
    * don't include dtmf, liveadder, rtpmux, autoconvert and shm, we include 
      them in -good

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* GStreamer
2
 
 * Copyright (C) 2008 Nokia Corporation. All rights reserved.
3
 
 *
4
 
 * Contact: Stefan Kost <stefan.kost@nokia.com>
5
 
 *
6
 
 * This library is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU Library General Public
8
 
 * License as published by the Free Software Foundation; either
9
 
 * version 2 of the License, or (at your option) any later version.
10
 
 *
11
 
 * This library is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 
 * Library General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU Library General Public
17
 
 * License along with this library; if not, write to the
18
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
 
 * Boston, MA 02111-1307, USA.
20
 
 */
21
 
 
22
 
#ifndef __GST_BASE_PARSE_H__
23
 
#define __GST_BASE_PARSE_H__
24
 
 
25
 
#include <gst/gst.h>
26
 
#include <gst/base/gstadapter.h>
27
 
 
28
 
G_BEGIN_DECLS
29
 
 
30
 
#define GST_TYPE_BASE_PARSE                (gst_base_parse_get_type())
31
 
#define GST_BASE_PARSE(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_PARSE,GstBaseParse))
32
 
#define GST_BASE_PARSE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_PARSE,GstBaseParseClass))
33
 
#define GST_BASE_PARSE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_PARSE,GstBaseParseClass))
34
 
#define GST_IS_BASE_PARSE(obj)     (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_PARSE))
35
 
#define GST_IS_BASE_PARSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_PARSE))
36
 
#define GST_BASE_PARSE_CAST(obj)        ((GstBaseParse *)(obj))
37
 
 
38
 
/**
39
 
 * GST_BASE_PARSE_SINK_NAME:
40
 
 *
41
 
 * the name of the templates for the sink pad
42
 
 */
43
 
#define GST_BASE_PARSE_SINK_NAME        "sink"
44
 
/**
45
 
 * GST_BASE_PARSE_SRC_NAME:
46
 
 *
47
 
 * the name of the templates for the source pad
48
 
 */
49
 
#define GST_BASE_PARSE_SRC_NAME "src"
50
 
 
51
 
/**
52
 
 * GST_BASE_PARSE_SRC_PAD:
53
 
 * @obj: base parse instance
54
 
 *
55
 
 * Gives the pointer to the source #GstPad object of the element.
56
 
 *
57
 
 * Since: 0.10.x
58
 
 */
59
 
#define GST_BASE_PARSE_SRC_PAD(obj)             (GST_BASE_PARSE_CAST (obj)->srcpad)
60
 
 
61
 
/**
62
 
 * GST_BASE_PARSE_SINK_PAD:
63
 
 * @obj: base parse instance
64
 
 *
65
 
 * Gives the pointer to the sink #GstPad object of the element.
66
 
 *
67
 
 * Since: 0.10.x
68
 
 */
69
 
#define GST_BASE_PARSE_SINK_PAD(obj)    (GST_BASE_PARSE_CAST (obj)->sinkpad)
70
 
 
71
 
/**
72
 
 * GST_BASE_PARSE_SEGMENT:
73
 
 * @obj: base parse instance
74
 
 *
75
 
 * Gives the segment of the element.
76
 
 *
77
 
 * Since: 0.10.x
78
 
 */
79
 
#define GST_BASE_PARSE_SEGMENT(obj)     (GST_BASE_PARSE_CAST (obj)->segment)
80
 
 
81
 
/**
82
 
 * GST_BASE_PARSE_FLOW_DROPPED:
83
 
 *
84
 
 * A #GstFlowReturn that can be returned from parse_frame to
85
 
 * indicate that no output buffer was generated, or from pre_push_buffer to
86
 
 * to forego pushing buffer.
87
 
 *
88
 
 * Since: 0.10.x
89
 
 */
90
 
#define GST_BASE_PARSE_FLOW_DROPPED   GST_FLOW_CUSTOM_SUCCESS
91
 
 
92
 
/**
93
 
 * GST_BASE_PARSE_FLOW_CLIP:
94
 
 *
95
 
 * A #GstFlowReturn that can be returned from pre_push_buffer to
96
 
 * indicate that regular segment clipping should be performed.
97
 
 *
98
 
 * Since: 0.10.x
99
 
 */
100
 
#define GST_BASE_PARSE_FLOW_CLIP      GST_FLOW_CUSTOM_SUCCESS_1
101
 
 
102
 
/**
103
 
 * GST_BASE_PARSE_BUFFER_FLAG_NO_FRAME:
104
 
 *
105
 
 * A #GstBufferFlag that can be set to have this buffer not counted as frame,
106
 
 * e.g. if this frame is dependent on a previous one.  As it is not counted as
107
 
 * a frame, bitrate increases but frame to time conversions are maintained.
108
 
 *
109
 
 * Since: 0.10.x
110
 
 */
111
 
#define GST_BASE_PARSE_BUFFER_FLAG_NO_FRAME     GST_BUFFER_FLAG_LAST
112
 
 
113
 
/**
114
 
 * GST_BASE_PARSE_LOCK:
115
 
 * @obj: base parse instance
116
 
 *
117
 
 * Obtain a lock to protect the parse function from concurrent access.
118
 
 *
119
 
 * Since: 0.10.x
120
 
 */
121
 
#define GST_BASE_PARSE_LOCK(obj)   g_mutex_lock (GST_BASE_PARSE_CAST (obj)->parse_lock)
122
 
 
123
 
/**
124
 
 * GST_BASE_PARSE_UNLOCK:
125
 
 * @obj: base parse instance
126
 
 *
127
 
 * Release the lock that protects the parse function from concurrent access.
128
 
 *
129
 
 * Since: 0.10.x
130
 
 */
131
 
#define GST_BASE_PARSE_UNLOCK(obj) g_mutex_unlock (GST_BASE_PARSE_CAST (obj)->parse_lock)
132
 
 
133
 
 
134
 
/**
135
 
 * GstBaseParseSeekable:
136
 
 * @GST_BASE_PARSE_SEEK_NONE: No seeking possible.
137
 
 * GST_BASE_PARSE_SEEK_DEFAULT: Default seeking possible using estimated bitrate.
138
 
 * GST_BASE_PARSE_SEEK_TABLE: Additional metadata provides more accurate seeking.
139
 
 *
140
 
 * Indicates what level (of quality) of seeking is possible.
141
 
 */
142
 
typedef enum _GstBaseParseSeekable {
143
 
  GST_BASE_PARSE_SEEK_NONE,
144
 
  GST_BASE_PARSE_SEEK_DEFAULT,
145
 
  GST_BASE_PARSE_SEEK_TABLE
146
 
} GstBaseParseSeekable;
147
 
 
148
 
typedef struct _GstBaseParse GstBaseParse;
149
 
typedef struct _GstBaseParseClass GstBaseParseClass;
150
 
typedef struct _GstBaseParsePrivate GstBaseParsePrivate;
151
 
 
152
 
/**
153
 
 * GstBaseParse:
154
 
 * @element: the parent element.
155
 
 *
156
 
 * The opaque #GstBaseParse data structure.
157
 
 */
158
 
struct _GstBaseParse {
159
 
  GstElement     element;
160
 
  GstAdapter    *adapter;
161
 
 
162
 
  /*< protected >*/
163
 
  /* source and sink pads */
164
 
  GstPad         *sinkpad;
165
 
  GstPad         *srcpad;
166
 
 
167
 
  /* MT-protected (with STREAM_LOCK) */
168
 
  GstSegment      segment;
169
 
 
170
 
  /* Newsegment event to be sent after SEEK */
171
 
  GstEvent       *pending_segment;
172
 
 
173
 
  /* Segment event that closes the running segment prior to SEEK */
174
 
  GstEvent       *close_segment;
175
 
 
176
 
  GMutex         *parse_lock;
177
 
 
178
 
  /*< private >*/
179
 
  gpointer       _gst_reserved[GST_PADDING_LARGE];
180
 
  GstBaseParsePrivate *priv;
181
 
};
182
 
 
183
 
/**
184
 
 * GstBaseParseClass:
185
 
 * @start:          Optional.
186
 
 *                  Called when the element starts processing.
187
 
 *                  Allows opening external resources.
188
 
 * @stop:           Optional.
189
 
 *                  Called when the element stops processing.
190
 
 *                  Allows closing external resources.
191
 
 * @set_sink_caps:  allows the subclass to be notified of the actual caps set.
192
 
 * @check_valid_frame:  Check if the given piece of data contains a valid
193
 
 *                      frame.
194
 
 * @parse_frame:    Parse the already checked frame. Subclass need to
195
 
 *                  set the buffer timestamp, duration, caps and possibly
196
 
 *                  other necessary metadata. This is called with srcpad's
197
 
 *                  STREAM_LOCK held.
198
 
 * @convert:        Optional.
199
 
 *                  Convert between formats.
200
 
 * @find_frame:     Optional.
201
 
 *                  Finds a frame. Gets a position passed and should return
202
 
 *                  TRUE and the offset in bytes where this position is.
203
 
 *                  Will only be called in pull mode and the subclass can pull
204
 
 *                  whatever it wants from upstream. If not implemented,
205
 
 *                  the base class will implement it by calling
206
 
 *                  @check_valid_frame and @parse_frame to find the wanted
207
 
 *                  frame and build a seek table.
208
 
 * @event:          Optional.
209
 
 *                  Event handler on the sink pad. This function should return
210
 
 *                  TRUE if the event was handled and can be dropped.
211
 
 * @src_event:      Optional.
212
 
 *                  Event handler on the source pad. Should return TRUE
213
 
 *                  if the event was handled and can be dropped.
214
 
 *
215
 
 * @get_frame_overhead: Finds the metadata overhead for the given frame. This
216
 
 *                      is used to enable more accurate bitrate computations.
217
 
 *                      If NULL, the per-frame overhead is assumed to be 0. If
218
 
 *                      this returns -1, it is assumed that this frame should
219
 
 *                      be skipped in bitrate calculation.
220
 
 *
221
 
 * @pre_push_buffer: Optional.
222
 
 *                   Called just prior to pushing a frame (after any pending
223
 
 *                   events have been sent) to give subclass a chance to perform
224
 
 *                   additional actions at this time (e.g. tag sending) or to
225
 
 *                   decide whether this buffer should be dropped or no
226
 
 *                   (e.g. custom segment clipping).
227
 
 *
228
 
 * Subclasses can override any of the available virtual methods or not, as
229
 
 * needed. At minimum @check_valid_frame and @parse_frame needs to be
230
 
 * overridden.
231
 
 */
232
 
struct _GstBaseParseClass {
233
 
  GstElementClass parent_class;
234
 
 
235
 
  /*< public >*/
236
 
  /* virtual methods for subclasses */
237
 
 
238
 
  gboolean      (*start)              (GstBaseParse *parse);
239
 
 
240
 
  gboolean      (*stop)               (GstBaseParse *parse);
241
 
 
242
 
  gboolean      (*set_sink_caps)      (GstBaseParse *parse,
243
 
                                       GstCaps *caps);
244
 
 
245
 
  gboolean      (*check_valid_frame)  (GstBaseParse *parse,
246
 
                                       GstBuffer *buffer,
247
 
                                       guint *framesize,
248
 
                                       gint *skipsize);
249
 
 
250
 
  GstFlowReturn (*parse_frame)        (GstBaseParse *parse,
251
 
                                       GstBuffer *buffer);
252
 
 
253
 
  gboolean      (*convert)            (GstBaseParse * parse,
254
 
                                       GstFormat src_format,
255
 
                                       gint64 src_value,
256
 
                                       GstFormat dest_format,
257
 
                                       gint64 * dest_value);
258
 
 
259
 
  gboolean      (*find_frame)         (GstBaseParse *parse,
260
 
                                       GstFormat src_format,
261
 
                                       gint64 src_value,
262
 
                                       gint64 * dest_value);
263
 
 
264
 
  gboolean      (*event)              (GstBaseParse *parse,
265
 
                                       GstEvent *event);
266
 
 
267
 
  gboolean      (*src_event)          (GstBaseParse *parse,
268
 
                                       GstEvent *event);
269
 
 
270
 
  gint          (*get_frame_overhead) (GstBaseParse *parse,
271
 
                                       GstBuffer *buf);
272
 
 
273
 
  GstFlowReturn (*pre_push_buffer)    (GstBaseParse *parse,
274
 
                                       GstBuffer *buf);
275
 
 
276
 
  /*< private >*/
277
 
  gpointer       _gst_reserved[GST_PADDING_LARGE];  
278
 
};
279
 
 
280
 
GType           gst_base_parse_get_type         (void);
281
 
 
282
 
 
283
 
GstFlowReturn gst_base_parse_push_buffer (GstBaseParse *parse,
284
 
                                          GstBuffer *buffer);
285
 
 
286
 
void gst_base_parse_set_duration (GstBaseParse *parse,
287
 
                                  GstFormat fmt, gint64 duration, gint interval);
288
 
 
289
 
void gst_base_parse_set_seek (GstBaseParse * parse,
290
 
                              GstBaseParseSeekable seek, guint bitrate);
291
 
 
292
 
void gst_base_parse_set_min_frame_size (GstBaseParse *parse,
293
 
                                        guint min_size);
294
 
void gst_base_parse_set_passthrough (GstBaseParse * parse, gboolean passthrough);
295
 
 
296
 
void gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
297
 
                                     guint fps_den, guint lead_in, guint lead_out);
298
 
 
299
 
gboolean gst_base_parse_get_sync (GstBaseParse * parse);
300
 
 
301
 
gboolean gst_base_parse_get_drain (GstBaseParse * parse);
302
 
 
303
 
gboolean gst_base_parse_convert_default (GstBaseParse * parse,
304
 
                                         GstFormat src_format, gint64 src_value,
305
 
                                         GstFormat dest_format, gint64 * dest_value);
306
 
 
307
 
gboolean gst_base_parse_add_index_entry (GstBaseParse * parse, guint64 offset,
308
 
                                         GstClockTime ts, gboolean key, gboolean force);
309
 
 
310
 
G_END_DECLS
311
 
 
312
 
#endif /* __GST_BASE_PARSE_H__ */