2 * Copyright (C) 2007 David Schleef <ds@schleef.org>
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.
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.
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.
20 #ifndef _GST_APP_SRC_H_
21 #define _GST_APP_SRC_H_
24 #include <gst/base/gstpushsrc.h>
25 #include <gst/app/app-prelude.h>
26 #include <gst/app/app-enumtypes.h>
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) \
43 typedef struct _GstAppSrc GstAppSrc;
44 typedef struct _GstAppSrcClass GstAppSrcClass;
45 typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
47 /* FIXME 2.0: Make the instance/class struct private */
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.
61 * A set of callbacks that can be installed on the appsrc with
62 * gst_app_src_set_callbacks().
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);
70 gpointer _gst_reserved[GST_PADDING];
75 * @GST_APP_STREAM_TYPE_STREAM: No seeking is supported in the stream, such as a
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.
86 GST_APP_STREAM_TYPE_STREAM,
87 GST_APP_STREAM_TYPE_SEEKABLE,
88 GST_APP_STREAM_TYPE_RANDOM_ACCESS
96 GstAppSrcPrivate *priv;
99 gpointer _gst_reserved[GST_PADDING];
102 struct _GstAppSrcClass
104 GstBaseSrcClass basesrc_class;
107 void (*need_data) (GstAppSrc *appsrc, guint length);
108 void (*enough_data) (GstAppSrc *appsrc);
109 gboolean (*seek_data) (GstAppSrc *appsrc, guint64 offset);
112 GstFlowReturn (*push_buffer) (GstAppSrc *appsrc, GstBuffer *buffer);
113 GstFlowReturn (*end_of_stream) (GstAppSrc *appsrc);
114 GstFlowReturn (*push_sample) (GstAppSrc *appsrc, GstSample *sample);
115 GstFlowReturn (*push_buffer_list) (GstAppSrc *appsrc, GstBufferList *buffer_list);
118 gpointer _gst_reserved[GST_PADDING-2];
122 GType gst_app_src_get_type (void);
125 void gst_app_src_set_caps (GstAppSrc *appsrc, const GstCaps *caps);
128 GstCaps* gst_app_src_get_caps (GstAppSrc *appsrc);
131 void gst_app_src_set_size (GstAppSrc *appsrc, gint64 size);
134 gint64 gst_app_src_get_size (GstAppSrc *appsrc);
137 void gst_app_src_set_duration (GstAppSrc *appsrc, GstClockTime duration);
140 GstClockTime gst_app_src_get_duration (GstAppSrc *appsrc);
143 void gst_app_src_set_stream_type (GstAppSrc *appsrc, GstAppStreamType type);
146 GstAppStreamType gst_app_src_get_stream_type (GstAppSrc *appsrc);
149 void gst_app_src_set_max_bytes (GstAppSrc *appsrc, guint64 max);
152 guint64 gst_app_src_get_max_bytes (GstAppSrc *appsrc);
155 guint64 gst_app_src_get_current_level_bytes (GstAppSrc *appsrc);
158 void gst_app_src_set_latency (GstAppSrc *appsrc, guint64 min, guint64 max);
161 void gst_app_src_get_latency (GstAppSrc *appsrc, guint64 *min, guint64 *max);
164 void gst_app_src_set_emit_signals (GstAppSrc *appsrc, gboolean emit);
167 gboolean gst_app_src_get_emit_signals (GstAppSrc *appsrc);
170 GstFlowReturn gst_app_src_push_buffer (GstAppSrc *appsrc, GstBuffer *buffer);
173 GstFlowReturn gst_app_src_push_buffer_list (GstAppSrc * appsrc, GstBufferList * buffer_list);
176 GstFlowReturn gst_app_src_end_of_stream (GstAppSrc *appsrc);
179 GstFlowReturn gst_app_src_push_sample (GstAppSrc *appsrc, GstSample *sample);
182 void gst_app_src_set_callbacks (GstAppSrc * appsrc,
183 GstAppSrcCallbacks *callbacks,
185 GDestroyNotify notify);
187 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
188 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAppSrc, gst_object_unref)