041cb68215c8edd64eca2616907919539cf83562
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / 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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, 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
26 G_BEGIN_DECLS
27
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))
38 /* Since 0.10.23 */
39 #define GST_APP_SRC_CAST(obj) \
40   ((GstAppSrc*)(obj))
41
42 typedef struct _GstAppSrc GstAppSrc;
43 typedef struct _GstAppSrcClass GstAppSrcClass;
44 typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
45
46 /**
47  * GstAppSrcCallbacks:
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  *    emited 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.
57  *
58  * A set of callbacks that can be installed on the appsrc with
59  * gst_app_src_set_callbacks().
60  *
61  * Since: 0.10.23
62  */
63 typedef struct {
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);
67
68   /*< private >*/
69   gpointer     _gst_reserved[GST_PADDING];
70 } GstAppSrcCallbacks;
71
72 /**
73  * GstAppStreamType:
74  * @GST_APP_STREAM_TYPE_STREAM: No seeking is supported in the stream, such as a
75  * live stream.
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.
80  *
81  * The stream type.
82  */
83 typedef enum
84 {
85   GST_APP_STREAM_TYPE_STREAM,
86   GST_APP_STREAM_TYPE_SEEKABLE,
87   GST_APP_STREAM_TYPE_RANDOM_ACCESS
88 } GstAppStreamType;
89
90 struct _GstAppSrc
91 {
92   GstBaseSrc basesrc;
93
94   /*< private >*/
95   GstAppSrcPrivate *priv;
96
97   /*< private >*/
98   gpointer     _gst_reserved[GST_PADDING];
99 };
100
101 struct _GstAppSrcClass
102 {
103   GstBaseSrcClass basesrc_class;
104
105   /* signals */
106   void          (*need_data)       (GstAppSrc *src, guint length);
107   void          (*enough_data)     (GstAppSrc *src);
108   gboolean      (*seek_data)       (GstAppSrc *src, guint64 offset);
109
110   /* actions */
111   GstFlowReturn (*push_buffer)     (GstAppSrc *src, GstBuffer *buffer);
112   GstFlowReturn (*end_of_stream)   (GstAppSrc *src);
113
114   /*< private >*/
115   gpointer     _gst_reserved[GST_PADDING];
116 };
117
118 GType gst_app_src_get_type(void);
119
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);
123
124 void             gst_app_src_set_caps         (GstAppSrc *appsrc, const GstCaps *caps);
125 GstCaps*         gst_app_src_get_caps         (GstAppSrc *appsrc);
126
127 void             gst_app_src_set_size         (GstAppSrc *appsrc, gint64 size);
128 gint64           gst_app_src_get_size         (GstAppSrc *appsrc);
129
130 void             gst_app_src_set_stream_type  (GstAppSrc *appsrc, GstAppStreamType type);
131 GstAppStreamType gst_app_src_get_stream_type  (GstAppSrc *appsrc);
132
133 void             gst_app_src_set_max_bytes    (GstAppSrc *appsrc, guint64 max);
134 guint64          gst_app_src_get_max_bytes    (GstAppSrc *appsrc);
135
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);
138
139 void             gst_app_src_set_emit_signals (GstAppSrc *appsrc, gboolean emit);
140 gboolean         gst_app_src_get_emit_signals (GstAppSrc *appsrc);
141
142 GstFlowReturn    gst_app_src_push_buffer      (GstAppSrc *appsrc, GstBuffer *buffer);
143 GstFlowReturn    gst_app_src_end_of_stream    (GstAppSrc *appsrc);
144
145 void             gst_app_src_set_callbacks    (GstAppSrc * appsrc,
146                                                GstAppSrcCallbacks *callbacks,
147                                                gpointer user_data,
148                                                GDestroyNotify notify);
149
150 G_END_DECLS
151
152 #endif
153