1/* GStreamer
2 * Copyright (C) 2007 David Schleef <ds@schleef.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef _GST_APP_SRC_H_
21#define _GST_APP_SRC_H_
22
23#include <gst/gst.h>
24#include <gst/base/gstpushsrc.h>
25#include <gst/app/app-prelude.h>
26#include <gst/app/app-enumtypes.h>
27
28G_BEGIN_DECLS
29
30#define GST_TYPE_APP_SRC \
31 (gst_app_src_get_type())
32#define GST_APP_SRC(obj) \
33 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_APP_SRC,GstAppSrc))
34#define GST_APP_SRC_CLASS(klass) \
35 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_APP_SRC,GstAppSrcClass))
36#define GST_IS_APP_SRC(obj) \
37 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_APP_SRC))
38#define GST_IS_APP_SRC_CLASS(klass) \
39 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_APP_SRC))
40#define GST_APP_SRC_CAST(obj) \
41 ((GstAppSrc*)(obj))
42
43typedef struct _GstAppSrc GstAppSrc;
44typedef struct _GstAppSrcClass GstAppSrcClass;
45typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
46
47/* FIXME 2.0: Make the instance/class struct private */
48
49/**
50 * GstAppSrcCallbacks: (skip)
51 * @need_data: Called when the appsrc needs more data. A buffer or EOS should be
52 * pushed to appsrc from this thread or another thread. @length is just a hint
53 * and when it is set to -1, any number of bytes can be pushed into @appsrc.
54 * @enough_data: Called when appsrc has enough data. It is recommended that the
55 * application stops calling push-buffer until the need_data callback is
56 * emitted again to avoid excessive buffer queueing.
57 * @seek_data: Called when a seek should be performed to the offset.
58 * The next push-buffer should produce buffers from the new @offset.
59 * This callback is only called for seekable stream types.
60 *
61 * A set of callbacks that can be installed on the appsrc with
62 * gst_app_src_set_callbacks().
63 */
64typedef struct {
65 void (*need_data) (GstAppSrc *src, guint length, gpointer user_data);
66 void (*enough_data) (GstAppSrc *src, gpointer user_data);
67 gboolean (*seek_data) (GstAppSrc *src, guint64 offset, gpointer user_data);
68
69 /*< private >*/
70 gpointer _gst_reserved[GST_PADDING];
71} GstAppSrcCallbacks;
72
73/**
74 * GstAppStreamType:
75 * @GST_APP_STREAM_TYPE_STREAM: No seeking is supported in the stream, such as a
76 * live stream.
77 * @GST_APP_STREAM_TYPE_SEEKABLE: The stream is seekable but seeking might not
78 * be very fast, such as data from a webserver.
79 * @GST_APP_STREAM_TYPE_RANDOM_ACCESS: The stream is seekable and seeking is fast,
80 * such as in a local file.
81 *
82 * The stream type.
83 */
84typedef enum
85{
86 GST_APP_STREAM_TYPE_STREAM,
87 GST_APP_STREAM_TYPE_SEEKABLE,
88 GST_APP_STREAM_TYPE_RANDOM_ACCESS
89} GstAppStreamType;
90
91/**
92 * GstAppLeakyType:
93 * @GST_APP_LEAKY_TYPE_NONE: Not Leaky
94 * @GST_APP_LEAKY_TYPE_UPSTREAM: Leaky on upstream (new buffers)
95 * @GST_APP_LEAKY_TYPE_DOWNSTREAM: Leaky on downstream (old buffers)
96 *
97 * Buffer dropping scheme to avoid the element's internal queue to block when
98 * full.
99 *
100 * Since: 1.20
101 */
102typedef enum {
103 GST_APP_LEAKY_TYPE_NONE,
104 GST_APP_LEAKY_TYPE_UPSTREAM,
105 GST_APP_LEAKY_TYPE_DOWNSTREAM
106} GstAppLeakyType;
107
108struct _GstAppSrc
109{
110 GstBaseSrc basesrc;
111
112 /*< private >*/
113 GstAppSrcPrivate *priv;
114
115 /*< private >*/
116 gpointer _gst_reserved[GST_PADDING];
117};
118
119struct _GstAppSrcClass
120{
121 GstBaseSrcClass basesrc_class;
122
123 /* signals */
124 void (*need_data) (GstAppSrc *appsrc, guint length);
125 void (*enough_data) (GstAppSrc *appsrc);
126 gboolean (*seek_data) (GstAppSrc *appsrc, guint64 offset);
127
128 /* actions */
129 GstFlowReturn (*push_buffer) (GstAppSrc *appsrc, GstBuffer *buffer);
130 GstFlowReturn (*end_of_stream) (GstAppSrc *appsrc);
131 GstFlowReturn (*push_sample) (GstAppSrc *appsrc, GstSample *sample);
132 GstFlowReturn (*push_buffer_list) (GstAppSrc *appsrc, GstBufferList *buffer_list);
133
134 /*< private >*/
135 gpointer _gst_reserved[GST_PADDING-2];
136};
137
138GST_APP_API
139GType gst_app_src_get_type (void);
140
141GST_APP_API
142void gst_app_src_set_caps (GstAppSrc *appsrc, const GstCaps *caps);
143
144GST_APP_API
145GstCaps* gst_app_src_get_caps (GstAppSrc *appsrc);
146
147GST_APP_API
148void gst_app_src_set_size (GstAppSrc *appsrc, gint64 size);
149
150GST_APP_API
151gint64 gst_app_src_get_size (GstAppSrc *appsrc);
152
153GST_APP_API
154void gst_app_src_set_duration (GstAppSrc *appsrc, GstClockTime duration);
155
156GST_APP_API
157GstClockTime gst_app_src_get_duration (GstAppSrc *appsrc);
158
159GST_APP_API
160void gst_app_src_set_stream_type (GstAppSrc *appsrc, GstAppStreamType type);
161
162GST_APP_API
163GstAppStreamType gst_app_src_get_stream_type (GstAppSrc *appsrc);
164
165GST_APP_API
166void gst_app_src_set_max_bytes (GstAppSrc *appsrc, guint64 max);
167
168GST_APP_API
169guint64 gst_app_src_get_max_bytes (GstAppSrc *appsrc);
170
171GST_APP_API
172guint64 gst_app_src_get_current_level_bytes (GstAppSrc *appsrc);
173
174GST_APP_API
175void gst_app_src_set_max_buffers (GstAppSrc *appsrc, guint64 max);
176
177GST_APP_API
178guint64 gst_app_src_get_max_buffers (GstAppSrc *appsrc);
179
180GST_APP_API
181guint64 gst_app_src_get_current_level_buffers (GstAppSrc *appsrc);
182
183GST_APP_API
184void gst_app_src_set_max_time (GstAppSrc *appsrc, GstClockTime max);
185
186GST_APP_API
187GstClockTime gst_app_src_get_max_time (GstAppSrc *appsrc);
188
189GST_APP_API
190GstClockTime gst_app_src_get_current_level_time (GstAppSrc *appsrc);
191
192GST_APP_API
193void gst_app_src_set_leaky_type (GstAppSrc *appsrc, GstAppLeakyType leaky);
194
195GST_APP_API
196GstAppLeakyType gst_app_src_get_leaky_type (GstAppSrc *appsrc);
197
198GST_APP_API
199void gst_app_src_set_latency (GstAppSrc *appsrc, guint64 min, guint64 max);
200
201GST_APP_API
202void gst_app_src_get_latency (GstAppSrc *appsrc, guint64 *min, guint64 *max);
203
204GST_APP_API
205void gst_app_src_set_emit_signals (GstAppSrc *appsrc, gboolean emit);
206
207GST_APP_API
208gboolean gst_app_src_get_emit_signals (GstAppSrc *appsrc);
209
210GST_APP_API
211GstFlowReturn gst_app_src_push_buffer (GstAppSrc *appsrc, GstBuffer *buffer);
212
213GST_APP_API
214GstFlowReturn gst_app_src_push_buffer_list (GstAppSrc * appsrc, GstBufferList * buffer_list);
215
216GST_APP_API
217GstFlowReturn gst_app_src_end_of_stream (GstAppSrc *appsrc);
218
219GST_APP_API
220GstFlowReturn gst_app_src_push_sample (GstAppSrc *appsrc, GstSample *sample);
221
222GST_APP_API
223void gst_app_src_set_callbacks (GstAppSrc * appsrc,
224 GstAppSrcCallbacks *callbacks,
225 gpointer user_data,
226 GDestroyNotify notify);
227
228G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAppSrc, gst_object_unref)
229
230G_END_DECLS
231
232#endif
233

source code of include/gstreamer-1.0/gst/app/gstappsrc.h