| 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_SINK_H_ |
| 21 | #define _GST_APP_SINK_H_ |
| 22 | |
| 23 | #include <gst/gst.h> |
| 24 | #include <gst/base/gstbasesink.h> |
| 25 | #include <gst/app/app-prelude.h> |
| 26 | |
| 27 | G_BEGIN_DECLS |
| 28 | |
| 29 | #define GST_TYPE_APP_SINK \ |
| 30 | (gst_app_sink_get_type()) |
| 31 | #define GST_APP_SINK(obj) \ |
| 32 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_APP_SINK,GstAppSink)) |
| 33 | #define GST_APP_SINK_CLASS(klass) \ |
| 34 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_APP_SINK,GstAppSinkClass)) |
| 35 | #define GST_IS_APP_SINK(obj) \ |
| 36 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_APP_SINK)) |
| 37 | #define GST_IS_APP_SINK_CLASS(klass) \ |
| 38 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_APP_SINK)) |
| 39 | #define GST_APP_SINK_CAST(obj) \ |
| 40 | ((GstAppSink*)(obj)) |
| 41 | |
| 42 | typedef struct _GstAppSink GstAppSink; |
| 43 | typedef struct _GstAppSinkClass GstAppSinkClass; |
| 44 | typedef struct _GstAppSinkPrivate GstAppSinkPrivate; |
| 45 | |
| 46 | /* FIXME 2.0: Make the instance/class struct private */ |
| 47 | |
| 48 | /** |
| 49 | * GstAppSinkCallbacks: (skip) |
| 50 | * @eos: Called when the end-of-stream has been reached. This callback |
| 51 | * is called from the streaming thread. |
| 52 | * @new_preroll: Called when a new preroll sample is available. |
| 53 | * This callback is called from the streaming thread. |
| 54 | * The new preroll sample can be retrieved with |
| 55 | * gst_app_sink_pull_preroll() either from this callback |
| 56 | * or from any other thread. |
| 57 | * @new_sample: Called when a new sample is available. |
| 58 | * This callback is called from the streaming thread. |
| 59 | * The new sample can be retrieved with |
| 60 | * gst_app_sink_pull_sample() either from this callback |
| 61 | * or from any other thread. |
| 62 | * @new_event: Called when a new event is available. |
| 63 | * This callback is called from the streaming thread. |
| 64 | * The new event can be retrieved with |
| 65 | * gst_app_sink_pull_event() either from this callback |
| 66 | * or from any other thread. |
| 67 | * The callback should return %TRUE if the event has been handled, |
| 68 | * %FALSE otherwise. |
| 69 | * Since: 1.20 |
| 70 | * @propose_allocation: Called when the propose_allocation query is available. |
| 71 | * This callback is called from the streaming thread. |
| 72 | * The allocation query can be retrieved with |
| 73 | * gst_app_sink_propose_allocation() either from this callback |
| 74 | * or from any other thread. |
| 75 | * Since: 1.24 |
| 76 | * |
| 77 | * A set of callbacks that can be installed on the appsink with |
| 78 | * gst_app_sink_set_callbacks(). |
| 79 | */ |
| 80 | typedef struct { |
| 81 | void (*eos) (GstAppSink *appsink, gpointer user_data); |
| 82 | GstFlowReturn (*new_preroll) (GstAppSink *appsink, gpointer user_data); |
| 83 | GstFlowReturn (*new_sample) (GstAppSink *appsink, gpointer user_data); |
| 84 | gboolean (*new_event) (GstAppSink *appsink, gpointer user_data); |
| 85 | gboolean (*propose_allocation) (GstAppSink *appsink, GstQuery *query, gpointer user_data); |
| 86 | |
| 87 | /*< private >*/ |
| 88 | gpointer _gst_reserved[GST_PADDING - 2]; |
| 89 | } GstAppSinkCallbacks; |
| 90 | |
| 91 | struct _GstAppSink |
| 92 | { |
| 93 | GstBaseSink basesink; |
| 94 | |
| 95 | /*< private >*/ |
| 96 | GstAppSinkPrivate *priv; |
| 97 | |
| 98 | /*< private >*/ |
| 99 | gpointer _gst_reserved[GST_PADDING]; |
| 100 | }; |
| 101 | |
| 102 | struct _GstAppSinkClass |
| 103 | { |
| 104 | GstBaseSinkClass basesink_class; |
| 105 | |
| 106 | /* signals */ |
| 107 | void (*eos) (GstAppSink *appsink); |
| 108 | GstFlowReturn (*new_preroll) (GstAppSink *appsink); |
| 109 | GstFlowReturn (*new_sample) (GstAppSink *appsink); |
| 110 | /* new_event is missing as we ran out padding */ |
| 111 | |
| 112 | /* actions */ |
| 113 | GstSample * (*pull_preroll) (GstAppSink *appsink); |
| 114 | GstSample * (*pull_sample) (GstAppSink *appsink); |
| 115 | GstSample * (*try_pull_preroll) (GstAppSink *appsink, GstClockTime timeout); |
| 116 | GstSample * (*try_pull_sample) (GstAppSink *appsink, GstClockTime timeout); |
| 117 | /** |
| 118 | * GstAppSinkClass::try_pull_object: |
| 119 | * |
| 120 | * See #GstAppSink::try-pull-object: signal. |
| 121 | * |
| 122 | * Since: 1.20 |
| 123 | */ |
| 124 | |
| 125 | GstMiniObject * (*try_pull_object) (GstAppSink *appsink, GstClockTime timeout); |
| 126 | /*< private >*/ |
| 127 | gpointer _gst_reserved[GST_PADDING - 3]; |
| 128 | }; |
| 129 | |
| 130 | GST_APP_API |
| 131 | GType gst_app_sink_get_type (void); |
| 132 | |
| 133 | GST_APP_API |
| 134 | void gst_app_sink_set_caps (GstAppSink *appsink, const GstCaps *caps); |
| 135 | |
| 136 | GST_APP_API |
| 137 | GstCaps * gst_app_sink_get_caps (GstAppSink *appsink); |
| 138 | |
| 139 | GST_APP_API |
| 140 | gboolean gst_app_sink_is_eos (GstAppSink *appsink); |
| 141 | |
| 142 | GST_APP_API |
| 143 | void gst_app_sink_set_emit_signals (GstAppSink *appsink, gboolean emit); |
| 144 | |
| 145 | GST_APP_API |
| 146 | gboolean gst_app_sink_get_emit_signals (GstAppSink *appsink); |
| 147 | |
| 148 | GST_APP_API |
| 149 | void gst_app_sink_set_max_buffers (GstAppSink *appsink, guint max); |
| 150 | |
| 151 | GST_APP_API |
| 152 | guint gst_app_sink_get_max_buffers (GstAppSink *appsink); |
| 153 | |
| 154 | GST_APP_API |
| 155 | void gst_app_sink_set_max_time (GstAppSink *appsink, GstClockTime max); |
| 156 | |
| 157 | GST_APP_API |
| 158 | GstClockTime gst_app_sink_get_max_time (GstAppSink *appsink); |
| 159 | |
| 160 | GST_APP_API |
| 161 | void gst_app_sink_set_max_bytes (GstAppSink *appsink, guint64 max); |
| 162 | |
| 163 | GST_APP_API |
| 164 | guint64 gst_app_sink_get_max_bytes (GstAppSink *appsink); |
| 165 | |
| 166 | GST_APP_API |
| 167 | void gst_app_sink_set_drop (GstAppSink *appsink, gboolean drop); |
| 168 | |
| 169 | GST_APP_API |
| 170 | gboolean gst_app_sink_get_drop (GstAppSink *appsink); |
| 171 | |
| 172 | GST_APP_API |
| 173 | void gst_app_sink_set_buffer_list_support (GstAppSink *appsink, gboolean enable_lists); |
| 174 | |
| 175 | GST_APP_API |
| 176 | gboolean gst_app_sink_get_buffer_list_support (GstAppSink *appsink); |
| 177 | |
| 178 | GST_APP_API |
| 179 | void gst_app_sink_set_wait_on_eos (GstAppSink *appsink, gboolean wait); |
| 180 | |
| 181 | GST_APP_API |
| 182 | gboolean gst_app_sink_get_wait_on_eos (GstAppSink *appsink); |
| 183 | |
| 184 | GST_APP_API |
| 185 | GstSample * gst_app_sink_pull_preroll (GstAppSink *appsink); |
| 186 | |
| 187 | GST_APP_API |
| 188 | GstSample * gst_app_sink_pull_sample (GstAppSink *appsink); |
| 189 | |
| 190 | GST_APP_API |
| 191 | GstMiniObject * gst_app_sink_pull_object (GstAppSink *appsink); |
| 192 | |
| 193 | GST_APP_API |
| 194 | GstSample * gst_app_sink_try_pull_preroll (GstAppSink *appsink, GstClockTime timeout); |
| 195 | |
| 196 | GST_APP_API |
| 197 | GstSample * gst_app_sink_try_pull_sample (GstAppSink *appsink, GstClockTime timeout); |
| 198 | |
| 199 | GST_APP_API |
| 200 | GstMiniObject * gst_app_sink_try_pull_object (GstAppSink *appsink, GstClockTime timeout); |
| 201 | |
| 202 | GST_APP_API |
| 203 | void gst_app_sink_set_callbacks (GstAppSink * appsink, |
| 204 | GstAppSinkCallbacks *callbacks, |
| 205 | gpointer user_data, |
| 206 | GDestroyNotify notify); |
| 207 | |
| 208 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAppSink, gst_object_unref) |
| 209 | |
| 210 | G_END_DECLS |
| 211 | |
| 212 | #endif |
| 213 | |