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
91struct _GstAppSrc
92{
93 GstBaseSrc basesrc;
94
95 /*< private >*/
96 GstAppSrcPrivate *priv;
97
98 /*< private >*/
99 gpointer _gst_reserved[GST_PADDING];
100};
101
102struct _GstAppSrcClass
103{
104 GstBaseSrcClass basesrc_class;
105
106 /* signals */
107 void (*need_data) (GstAppSrc *appsrc, guint length);
108 void (*enough_data) (GstAppSrc *appsrc);
109 gboolean (*seek_data) (GstAppSrc *appsrc, guint64 offset);
110
111 /* actions */
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);
116
117 /*< private >*/
118 gpointer _gst_reserved[GST_PADDING-2];
119};
120
121GST_APP_API
122GType gst_app_src_get_type (void);
123
124GST_APP_API
125void gst_app_src_set_caps (GstAppSrc *appsrc, const GstCaps *caps);
126
127GST_APP_API
128GstCaps* gst_app_src_get_caps (GstAppSrc *appsrc);
129
130GST_APP_API
131void gst_app_src_set_size (GstAppSrc *appsrc, gint64 size);
132
133GST_APP_API
134gint64 gst_app_src_get_size (GstAppSrc *appsrc);
135
136GST_APP_API
137void gst_app_src_set_duration (GstAppSrc *appsrc, GstClockTime duration);
138
139GST_APP_API
140GstClockTime gst_app_src_get_duration (GstAppSrc *appsrc);
141
142GST_APP_API
143void gst_app_src_set_stream_type (GstAppSrc *appsrc, GstAppStreamType type);
144
145GST_APP_API
146GstAppStreamType gst_app_src_get_stream_type (GstAppSrc *appsrc);
147
148GST_APP_API
149void gst_app_src_set_max_bytes (GstAppSrc *appsrc, guint64 max);
150
151GST_APP_API
152guint64 gst_app_src_get_max_bytes (GstAppSrc *appsrc);
153
154GST_APP_API
155guint64 gst_app_src_get_current_level_bytes (GstAppSrc *appsrc);
156
157GST_APP_API
158void gst_app_src_set_latency (GstAppSrc *appsrc, guint64 min, guint64 max);
159
160GST_APP_API
161void gst_app_src_get_latency (GstAppSrc *appsrc, guint64 *min, guint64 *max);
162
163GST_APP_API
164void gst_app_src_set_emit_signals (GstAppSrc *appsrc, gboolean emit);
165
166GST_APP_API
167gboolean gst_app_src_get_emit_signals (GstAppSrc *appsrc);
168
169GST_APP_API
170GstFlowReturn gst_app_src_push_buffer (GstAppSrc *appsrc, GstBuffer *buffer);
171
172GST_APP_API
173GstFlowReturn gst_app_src_push_buffer_list (GstAppSrc * appsrc, GstBufferList * buffer_list);
174
175GST_APP_API
176GstFlowReturn gst_app_src_end_of_stream (GstAppSrc *appsrc);
177
178GST_APP_API
179GstFlowReturn gst_app_src_push_sample (GstAppSrc *appsrc, GstSample *sample);
180
181GST_APP_API
182void gst_app_src_set_callbacks (GstAppSrc * appsrc,
183 GstAppSrcCallbacks *callbacks,
184 gpointer user_data,
185 GDestroyNotify notify);
186
187#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
188G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAppSrc, gst_object_unref)
189#endif
190
191G_END_DECLS
192
193#endif
194