| 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 | /** | 
| 92 |  * GstAppLeakyType: | 
| 93 |  * @GST_APP_LEAKY_TYPE_NONE: Not Leaky | 
| 94 |  * @GST_APP_LEAKY_TYPE_UPSTREAM: Leaky on upstream (new buffers) | 
| 95 |  * @GST_APP_LEAKY_TYPE_DOWNSTREAM: Leaky on downstream (old buffers) | 
| 96 |  * | 
| 97 |  * Buffer dropping scheme to avoid the element's internal queue to block when | 
| 98 |  * full. | 
| 99 |  * | 
| 100 |  * Since: 1.20 | 
| 101 |  */ | 
| 102 | typedef enum { | 
| 103 |   GST_APP_LEAKY_TYPE_NONE, | 
| 104 |   GST_APP_LEAKY_TYPE_UPSTREAM, | 
| 105 |   GST_APP_LEAKY_TYPE_DOWNSTREAM | 
| 106 | } GstAppLeakyType; | 
| 107 |  | 
| 108 | struct _GstAppSrc | 
| 109 | { | 
| 110 |   GstBaseSrc basesrc; | 
| 111 |  | 
| 112 |   /*< private >*/ | 
| 113 |   GstAppSrcPrivate *priv; | 
| 114 |  | 
| 115 |   /*< private >*/ | 
| 116 |   gpointer     _gst_reserved[GST_PADDING]; | 
| 117 | }; | 
| 118 |  | 
| 119 | struct _GstAppSrcClass | 
| 120 | { | 
| 121 |   GstBaseSrcClass basesrc_class; | 
| 122 |  | 
| 123 |   /* signals */ | 
| 124 |   void          (*need_data)       (GstAppSrc *appsrc, guint length); | 
| 125 |   void          (*enough_data)     (GstAppSrc *appsrc); | 
| 126 |   gboolean      (*seek_data)       (GstAppSrc *appsrc, guint64 offset); | 
| 127 |  | 
| 128 |   /* actions */ | 
| 129 |   GstFlowReturn (*push_buffer)     (GstAppSrc *appsrc, GstBuffer *buffer); | 
| 130 |   GstFlowReturn (*end_of_stream)   (GstAppSrc *appsrc); | 
| 131 |   GstFlowReturn (*push_sample)     (GstAppSrc *appsrc, GstSample *sample); | 
| 132 |   GstFlowReturn (*push_buffer_list) (GstAppSrc *appsrc, GstBufferList *buffer_list); | 
| 133 |  | 
| 134 |   /*< private >*/ | 
| 135 |   gpointer     _gst_reserved[GST_PADDING-2]; | 
| 136 | }; | 
| 137 |  | 
| 138 | GST_APP_API | 
| 139 | GType            gst_app_src_get_type                (void); | 
| 140 |  | 
| 141 | GST_APP_API | 
| 142 | void             gst_app_src_set_caps                (GstAppSrc *appsrc, const GstCaps *caps); | 
| 143 |  | 
| 144 | GST_APP_API | 
| 145 | GstCaps*         gst_app_src_get_caps                (GstAppSrc *appsrc); | 
| 146 |  | 
| 147 | GST_APP_API | 
| 148 | void             gst_app_src_set_size                (GstAppSrc *appsrc, gint64 size); | 
| 149 |  | 
| 150 | GST_APP_API | 
| 151 | gint64           gst_app_src_get_size                (GstAppSrc *appsrc); | 
| 152 |  | 
| 153 | GST_APP_API | 
| 154 | void             gst_app_src_set_duration            (GstAppSrc *appsrc, GstClockTime duration); | 
| 155 |  | 
| 156 | GST_APP_API | 
| 157 | GstClockTime     gst_app_src_get_duration            (GstAppSrc *appsrc); | 
| 158 |  | 
| 159 | GST_APP_API | 
| 160 | void             gst_app_src_set_stream_type         (GstAppSrc *appsrc, GstAppStreamType type); | 
| 161 |  | 
| 162 | GST_APP_API | 
| 163 | GstAppStreamType gst_app_src_get_stream_type         (GstAppSrc *appsrc); | 
| 164 |  | 
| 165 | GST_APP_API | 
| 166 | void             gst_app_src_set_max_bytes           (GstAppSrc *appsrc, guint64 max); | 
| 167 |  | 
| 168 | GST_APP_API | 
| 169 | guint64          gst_app_src_get_max_bytes           (GstAppSrc *appsrc); | 
| 170 |  | 
| 171 | GST_APP_API | 
| 172 | guint64          gst_app_src_get_current_level_bytes (GstAppSrc *appsrc); | 
| 173 |  | 
| 174 | GST_APP_API | 
| 175 | void             gst_app_src_set_max_buffers           (GstAppSrc *appsrc, guint64 max); | 
| 176 |  | 
| 177 | GST_APP_API | 
| 178 | guint64          gst_app_src_get_max_buffers           (GstAppSrc *appsrc); | 
| 179 |  | 
| 180 | GST_APP_API | 
| 181 | guint64          gst_app_src_get_current_level_buffers (GstAppSrc *appsrc); | 
| 182 |  | 
| 183 | GST_APP_API | 
| 184 | void             gst_app_src_set_max_time            (GstAppSrc *appsrc, GstClockTime max); | 
| 185 |  | 
| 186 | GST_APP_API | 
| 187 | GstClockTime     gst_app_src_get_max_time            (GstAppSrc *appsrc); | 
| 188 |  | 
| 189 | GST_APP_API | 
| 190 | GstClockTime     gst_app_src_get_current_level_time  (GstAppSrc *appsrc); | 
| 191 |  | 
| 192 | GST_APP_API | 
| 193 | void             gst_app_src_set_leaky_type          (GstAppSrc *appsrc, GstAppLeakyType leaky); | 
| 194 |  | 
| 195 | GST_APP_API | 
| 196 | GstAppLeakyType  gst_app_src_get_leaky_type          (GstAppSrc *appsrc); | 
| 197 |  | 
| 198 | GST_APP_API | 
| 199 | void             gst_app_src_set_latency             (GstAppSrc *appsrc, guint64 min, guint64 max); | 
| 200 |  | 
| 201 | GST_APP_API | 
| 202 | void             gst_app_src_get_latency             (GstAppSrc *appsrc, guint64 *min, guint64 *max); | 
| 203 |  | 
| 204 | GST_APP_API | 
| 205 | void             gst_app_src_set_emit_signals        (GstAppSrc *appsrc, gboolean emit); | 
| 206 |  | 
| 207 | GST_APP_API | 
| 208 | gboolean         gst_app_src_get_emit_signals        (GstAppSrc *appsrc); | 
| 209 |  | 
| 210 | GST_APP_API | 
| 211 | GstFlowReturn    gst_app_src_push_buffer             (GstAppSrc *appsrc, GstBuffer *buffer); | 
| 212 |  | 
| 213 | GST_APP_API | 
| 214 | GstFlowReturn    gst_app_src_push_buffer_list        (GstAppSrc * appsrc, GstBufferList * buffer_list); | 
| 215 |  | 
| 216 | GST_APP_API | 
| 217 | GstFlowReturn    gst_app_src_end_of_stream           (GstAppSrc *appsrc); | 
| 218 |  | 
| 219 | GST_APP_API | 
| 220 | GstFlowReturn    gst_app_src_push_sample             (GstAppSrc *appsrc, GstSample *sample); | 
| 221 |  | 
| 222 | GST_APP_API | 
| 223 | void             gst_app_src_set_callbacks           (GstAppSrc * appsrc, | 
| 224 |                                                       GstAppSrcCallbacks *callbacks, | 
| 225 |                                                       gpointer user_data, | 
| 226 |                                                       GDestroyNotify notify); | 
| 227 |  | 
| 228 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAppSrc, gst_object_unref) | 
| 229 |  | 
| 230 | G_END_DECLS | 
| 231 |  | 
| 232 | #endif | 
| 233 |  |