app: GST_EXPORT -> GST_APP_API
[platform/upstream/gstreamer.git] / gst-libs / gst / app / gstappsrc.h
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
28 G_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
43 typedef struct _GstAppSrc GstAppSrc;
44 typedef struct _GstAppSrcClass GstAppSrcClass;
45 typedef 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  */
64 typedef 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  */
84 typedef 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 struct _GstAppSrc
92 {
93   GstBaseSrc basesrc;
94
95   /*< private >*/
96   GstAppSrcPrivate *priv;
97
98   /*< private >*/
99   gpointer     _gst_reserved[GST_PADDING];
100 };
101
102 struct _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
121 GST_APP_API
122 GType            gst_app_src_get_type                (void);
123
124 GST_APP_API
125 void             gst_app_src_set_caps                (GstAppSrc *appsrc, const GstCaps *caps);
126
127 GST_APP_API
128 GstCaps*         gst_app_src_get_caps                (GstAppSrc *appsrc);
129
130 GST_APP_API
131 void             gst_app_src_set_size                (GstAppSrc *appsrc, gint64 size);
132
133 GST_APP_API
134 gint64           gst_app_src_get_size                (GstAppSrc *appsrc);
135
136 GST_APP_API
137 void             gst_app_src_set_duration            (GstAppSrc *appsrc, GstClockTime duration);
138
139 GST_APP_API
140 GstClockTime     gst_app_src_get_duration            (GstAppSrc *appsrc);
141
142 GST_APP_API
143 void             gst_app_src_set_stream_type         (GstAppSrc *appsrc, GstAppStreamType type);
144
145 GST_APP_API
146 GstAppStreamType gst_app_src_get_stream_type         (GstAppSrc *appsrc);
147
148 GST_APP_API
149 void             gst_app_src_set_max_bytes           (GstAppSrc *appsrc, guint64 max);
150
151 GST_APP_API
152 guint64          gst_app_src_get_max_bytes           (GstAppSrc *appsrc);
153
154 GST_APP_API
155 guint64          gst_app_src_get_current_level_bytes (GstAppSrc *appsrc);
156
157 GST_APP_API
158 void             gst_app_src_set_latency             (GstAppSrc *appsrc, guint64 min, guint64 max);
159
160 GST_APP_API
161 void             gst_app_src_get_latency             (GstAppSrc *appsrc, guint64 *min, guint64 *max);
162
163 GST_APP_API
164 void             gst_app_src_set_emit_signals        (GstAppSrc *appsrc, gboolean emit);
165
166 GST_APP_API
167 gboolean         gst_app_src_get_emit_signals        (GstAppSrc *appsrc);
168
169 GST_APP_API
170 GstFlowReturn    gst_app_src_push_buffer             (GstAppSrc *appsrc, GstBuffer *buffer);
171
172 GST_APP_API
173 GstFlowReturn    gst_app_src_push_buffer_list        (GstAppSrc * appsrc, GstBufferList * buffer_list);
174
175 GST_APP_API
176 GstFlowReturn    gst_app_src_end_of_stream           (GstAppSrc *appsrc);
177
178 GST_APP_API
179 GstFlowReturn    gst_app_src_push_sample             (GstAppSrc *appsrc, GstSample *sample);
180
181 GST_APP_API
182 void             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
188 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAppSrc, gst_object_unref)
189 #endif
190
191 G_END_DECLS
192
193 #endif