summaryrefslogtreecommitdiff
path: root/gst-libs/gst/audio/gstaudioaggregator.h
blob: 9cd66d3288ee1f9af2bea32ce7da459939a78e1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/* GStreamer
 * Copyright (C) 2014 Collabora
 *   Author: Olivier Crete <olivier.crete@collabora.com>
 *
 * gstaudioaggregator.h:
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * 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., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __GST_AUDIO_AGGREGATOR_H__
#define __GST_AUDIO_AGGREGATOR_H__

#include <gst/gst.h>
#include <gst/base/gstaggregator.h>
#include <gst/audio/audio.h>

G_BEGIN_DECLS

/*******************************
 * GstAudioAggregator Structs  *
 *******************************/

typedef struct _GstAudioAggregator GstAudioAggregator;
typedef struct _GstAudioAggregatorPrivate GstAudioAggregatorPrivate;
typedef struct _GstAudioAggregatorClass GstAudioAggregatorClass;


/************************
 * GstAudioAggregatorPad API *
 ***********************/

#define GST_TYPE_AUDIO_AGGREGATOR_PAD            (gst_audio_aggregator_pad_get_type())
#define GST_AUDIO_AGGREGATOR_PAD(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPad))
#define GST_AUDIO_AGGREGATOR_PAD_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPadClass))
#define GST_AUDIO_AGGREGATOR_PAD_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPadClass))
#define GST_IS_AUDIO_AGGREGATOR_PAD(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD))
#define GST_IS_AUDIO_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_PAD))

/****************************
 * GstAudioAggregatorPad Structs *
 ***************************/

typedef struct _GstAudioAggregatorPad GstAudioAggregatorPad;
typedef struct _GstAudioAggregatorPadClass GstAudioAggregatorPadClass;
typedef struct _GstAudioAggregatorPadPrivate GstAudioAggregatorPadPrivate;

/**
 * GstAudioAggregatorPad:
 * @parent: The parent #GstAggregatorPad
 * @info: The audio info for this pad set from the incoming caps
 *
 * The default implementation of GstPad used with #GstAudioAggregator
 */
struct _GstAudioAggregatorPad
{
  GstAggregatorPad                  parent;

  GstAudioInfo                      info;

  /*< private >*/
  GstAudioAggregatorPadPrivate   *  priv;

  gpointer _gst_reserved[GST_PADDING];
};

/**
 * GstAudioAggregatorPadClass:
 *
 */
struct _GstAudioAggregatorPadClass
  {
  GstAggregatorPadClass   parent_class;

  /*< private >*/
  gpointer      _gst_reserved[GST_PADDING_LARGE];
};

GST_EXPORT
GType gst_audio_aggregator_pad_get_type           (void);

#define GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD            (gst_audio_aggregator_convert_pad_get_type())
#define GST_AUDIO_AGGREGATOR_CONVERT_PAD(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPad))
#define GST_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass))
#define GST_AUDIO_AGGREGATOR_CONVERT_PAD_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass))
#define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD))
#define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD))

/****************************
 * GstAudioAggregatorPad Structs *
 ***************************/

typedef struct _GstAudioAggregatorConvertPad GstAudioAggregatorConvertPad;
typedef struct _GstAudioAggregatorConvertPadClass GstAudioAggregatorConvertPadClass;
typedef struct _GstAudioAggregatorConvertPadPrivate GstAudioAggregatorConvertPadPrivate;

/**
 * GstAudioAggregatorConvertPad:
 * @parent: The parent #GstAudioAggregatorPad
 *
 * An implementation of GstPad that can be used with #GstAudioAggregator.
 *
 * See #GstAudioAggregator for more details.
 */
struct _GstAudioAggregatorConvertPad
{
  GstAudioAggregatorPad                  parent;

  /*< private >*/
  GstAudioAggregatorConvertPadPrivate   *  priv;

  gpointer _gst_reserved[GST_PADDING];
};

/**
 * GstAudioAggregatorConvertPadClass:
 *
 */
struct _GstAudioAggregatorConvertPadClass
{
  GstAudioAggregatorPadClass   parent_class;

  /*< private >*/
  gpointer      _gst_reserved[GST_PADDING];
};

GST_EXPORT
GType gst_audio_aggregator_convert_pad_get_type           (void);

/**************************
 * GstAudioAggregator API *
 **************************/

#define GST_TYPE_AUDIO_AGGREGATOR            (gst_audio_aggregator_get_type())
#define GST_AUDIO_AGGREGATOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregator))
#define GST_AUDIO_AGGREGATOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass))
#define GST_AUDIO_AGGREGATOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass))
#define GST_IS_AUDIO_AGGREGATOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR))
#define GST_IS_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR))

/**
 * GstAudioAggregator:
 * @parent: The parent #GstAggregator
 * @info: The information parsed from the current caps
 * @current_caps: The caps set by the subclass
 *
 * GstAudioAggregator object
 */
struct _GstAudioAggregator
{
  GstAggregator            parent;

  /* All member are read only for subclasses, must hold OBJECT lock  */
  GstAudioInfo    info;

  GstCaps *current_caps;

  /*< private >*/
  GstAudioAggregatorPrivate *priv;

  gpointer                 _gst_reserved[GST_PADDING];
};

/**
 * GstAudioAggregatorClass:
 * @create_output_buffer: Create a new output buffer contains num_frames frames.
 * @aggregate_one_buffer: Aggregates one input buffer to the output
 *  buffer.  The in_offset and out_offset are in "frames", which is
 *  the size of a sample times the number of channels. Returns TRUE if
 *  any non-silence was added to the buffer
 * @convert_buffer: Convert a buffer from one format to another. The pad
 *  is either a sinkpad, when converting an input buffer, or the source pad,
 *  when converting the output buffer after a downstream format change is
 *  requested.
 */
struct _GstAudioAggregatorClass {
  GstAggregatorClass   parent_class;

  GstBuffer * (* create_output_buffer) (GstAudioAggregator * aagg,
      guint num_frames);
  gboolean (* aggregate_one_buffer) (GstAudioAggregator * aagg,
      GstAudioAggregatorPad * pad, GstBuffer * inbuf, guint in_offset,
      GstBuffer * outbuf, guint out_offset, guint num_frames);
  GstBuffer * (* convert_buffer) (GstAudioAggregator *aagg,
                                  GstPad * pad,
                                  GstAudioInfo *in_info,
                                  GstAudioInfo *out_info,
                                  GstBuffer * buffer);

  /*< private >*/
  gpointer          _gst_reserved[GST_PADDING_LARGE];
};

/*************************
 * GstAggregator methods *
 ************************/

GST_EXPORT
GType gst_audio_aggregator_get_type(void);

GST_EXPORT
void  gst_audio_aggregator_set_sink_caps (GstAudioAggregator    * aagg,
                                          GstAudioAggregatorPad * pad,
                                          GstCaps               * caps);

G_END_DECLS

#endif /* __GST_AUDIO_AGGREGATOR_H__ */