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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef _GST_APP_SRC_H_
21 #define _GST_APP_SRC_H_
24 #include <gst/base/gstpushsrc.h>
28 #define GST_TYPE_APP_SRC \
29 (gst_app_src_get_type())
30 #define GST_APP_SRC(obj) \
31 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_APP_SRC,GstAppSrc))
32 #define GST_APP_SRC_CLASS(klass) \
33 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_APP_SRC,GstAppSrcClass))
34 #define GST_IS_APP_SRC(obj) \
35 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_APP_SRC))
36 #define GST_IS_APP_SRC_CLASS(klass) \
37 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_APP_SRC))
39 #define GST_APP_SRC_CAST(obj) \
42 typedef struct _GstAppSrc GstAppSrc;
43 typedef struct _GstAppSrcClass GstAppSrcClass;
44 typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
48 * @need_data: Called when the appsrc needs more data. A buffer or EOS should be
49 * pushed to appsrc from this thread or another thread. @length is just a hint
50 * and when it is set to -1, any number of bytes can be pushed into @appsrc.
51 * @enough_data: Called when appsrc has enough data. It is recommended that the
52 * application stops calling push-buffer until the need_data callback is
53 * emitted again to avoid excessive buffer queueing.
54 * @seek_data: Called when a seek should be performed to the offset.
55 * The next push-buffer should produce buffers from the new @offset.
56 * This callback is only called for seekable stream types.
58 * A set of callbacks that can be installed on the appsrc with
59 * gst_app_src_set_callbacks().
64 void (*need_data) (GstAppSrc *src, guint length, gpointer user_data);
65 void (*enough_data) (GstAppSrc *src, gpointer user_data);
66 gboolean (*seek_data) (GstAppSrc *src, guint64 offset, gpointer user_data);
69 gpointer _gst_reserved[GST_PADDING];
74 * @GST_APP_STREAM_TYPE_STREAM: No seeking is supported in the stream, such as a
76 * @GST_APP_STREAM_TYPE_SEEKABLE: The stream is seekable but seeking might not
77 * be very fast, such as data from a webserver.
78 * @GST_APP_STREAM_TYPE_RANDOM_ACCESS: The stream is seekable and seeking is fast,
79 * such as in a local file.
85 GST_APP_STREAM_TYPE_STREAM,
86 GST_APP_STREAM_TYPE_SEEKABLE,
87 GST_APP_STREAM_TYPE_RANDOM_ACCESS
95 GstAppSrcPrivate *priv;
98 gpointer _gst_reserved[GST_PADDING];
101 struct _GstAppSrcClass
103 GstBaseSrcClass basesrc_class;
106 void (*need_data) (GstAppSrc *src, guint length);
107 void (*enough_data) (GstAppSrc *src);
108 gboolean (*seek_data) (GstAppSrc *src, guint64 offset);
111 GstFlowReturn (*push_buffer) (GstAppSrc *src, GstBuffer *buffer);
112 GstFlowReturn (*end_of_stream) (GstAppSrc *src);
115 gpointer _gst_reserved[GST_PADDING];
118 GType gst_app_src_get_type(void);
120 /* GType getter for GstAppStreamType, since 0.10.32 */
121 #define GST_TYPE_APP_STREAM_TYPE (gst_app_stream_type_get_type ())
122 GType gst_app_stream_type_get_type (void);
124 void gst_app_src_set_caps (GstAppSrc *appsrc, const GstCaps *caps);
125 GstCaps* gst_app_src_get_caps (GstAppSrc *appsrc);
127 void gst_app_src_set_size (GstAppSrc *appsrc, gint64 size);
128 gint64 gst_app_src_get_size (GstAppSrc *appsrc);
130 void gst_app_src_set_stream_type (GstAppSrc *appsrc, GstAppStreamType type);
131 GstAppStreamType gst_app_src_get_stream_type (GstAppSrc *appsrc);
133 void gst_app_src_set_max_bytes (GstAppSrc *appsrc, guint64 max);
134 guint64 gst_app_src_get_max_bytes (GstAppSrc *appsrc);
136 void gst_app_src_set_latency (GstAppSrc *appsrc, guint64 min, guint64 max);
137 void gst_app_src_get_latency (GstAppSrc *appsrc, guint64 *min, guint64 *max);
139 void gst_app_src_set_emit_signals (GstAppSrc *appsrc, gboolean emit);
140 gboolean gst_app_src_get_emit_signals (GstAppSrc *appsrc);
142 GstFlowReturn gst_app_src_push_buffer (GstAppSrc *appsrc, GstBuffer *buffer);
143 GstFlowReturn gst_app_src_end_of_stream (GstAppSrc *appsrc);
145 void gst_app_src_set_callbacks (GstAppSrc * appsrc,
146 GstAppSrcCallbacks *callbacks,
148 GDestroyNotify notify);