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
27G_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
42typedef struct _GstAppSink GstAppSink;
43typedef struct _GstAppSinkClass GstAppSinkClass;
44typedef 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 *
63 * A set of callbacks that can be installed on the appsink with
64 * gst_app_sink_set_callbacks().
65 */
66typedef struct {
67 void (*eos) (GstAppSink *appsink, gpointer user_data);
68 GstFlowReturn (*new_preroll) (GstAppSink *appsink, gpointer user_data);
69 GstFlowReturn (*new_sample) (GstAppSink *appsink, gpointer user_data);
70
71 /*< private >*/
72 gpointer _gst_reserved[GST_PADDING];
73} GstAppSinkCallbacks;
74
75struct _GstAppSink
76{
77 GstBaseSink basesink;
78
79 /*< private >*/
80 GstAppSinkPrivate *priv;
81
82 /*< private >*/
83 gpointer _gst_reserved[GST_PADDING];
84};
85
86struct _GstAppSinkClass
87{
88 GstBaseSinkClass basesink_class;
89
90 /* signals */
91 void (*eos) (GstAppSink *appsink);
92 GstFlowReturn (*new_preroll) (GstAppSink *appsink);
93 GstFlowReturn (*new_sample) (GstAppSink *appsink);
94
95 /* actions */
96 GstSample * (*pull_preroll) (GstAppSink *appsink);
97 GstSample * (*pull_sample) (GstAppSink *appsink);
98 GstSample * (*try_pull_preroll) (GstAppSink *appsink, GstClockTime timeout);
99 GstSample * (*try_pull_sample) (GstAppSink *appsink, GstClockTime timeout);
100
101 /*< private >*/
102 gpointer _gst_reserved[GST_PADDING - 2];
103};
104
105GST_APP_API
106GType gst_app_sink_get_type (void);
107
108GST_APP_API
109void gst_app_sink_set_caps (GstAppSink *appsink, const GstCaps *caps);
110
111GST_APP_API
112GstCaps * gst_app_sink_get_caps (GstAppSink *appsink);
113
114GST_APP_API
115gboolean gst_app_sink_is_eos (GstAppSink *appsink);
116
117GST_APP_API
118void gst_app_sink_set_emit_signals (GstAppSink *appsink, gboolean emit);
119
120GST_APP_API
121gboolean gst_app_sink_get_emit_signals (GstAppSink *appsink);
122
123GST_APP_API
124void gst_app_sink_set_max_buffers (GstAppSink *appsink, guint max);
125
126GST_APP_API
127guint gst_app_sink_get_max_buffers (GstAppSink *appsink);
128
129GST_APP_API
130void gst_app_sink_set_drop (GstAppSink *appsink, gboolean drop);
131
132GST_APP_API
133gboolean gst_app_sink_get_drop (GstAppSink *appsink);
134
135GST_APP_API
136void gst_app_sink_set_buffer_list_support (GstAppSink *appsink, gboolean enable_lists);
137
138GST_APP_API
139gboolean gst_app_sink_get_buffer_list_support (GstAppSink *appsink);
140
141GST_APP_API
142void gst_app_sink_set_wait_on_eos (GstAppSink *appsink, gboolean wait);
143
144GST_APP_API
145gboolean gst_app_sink_get_wait_on_eos (GstAppSink *appsink);
146
147GST_APP_API
148GstSample * gst_app_sink_pull_preroll (GstAppSink *appsink);
149
150GST_APP_API
151GstSample * gst_app_sink_pull_sample (GstAppSink *appsink);
152
153GST_APP_API
154GstSample * gst_app_sink_try_pull_preroll (GstAppSink *appsink, GstClockTime timeout);
155
156GST_APP_API
157GstSample * gst_app_sink_try_pull_sample (GstAppSink *appsink, GstClockTime timeout);
158
159GST_APP_API
160void gst_app_sink_set_callbacks (GstAppSink * appsink,
161 GstAppSinkCallbacks *callbacks,
162 gpointer user_data,
163 GDestroyNotify notify);
164
165#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
166G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAppSink, gst_object_unref)
167#endif
168
169G_END_DECLS
170
171#endif
172
173