1/* GStreamer
2 * Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
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_PROMISE_H__
21#define __GST_PROMISE_H__
22
23#include <gst/gst.h>
24
25G_BEGIN_DECLS
26
27GST_API
28GType gst_promise_get_type(void);
29#define GST_TYPE_PROMISE (gst_promise_get_type())
30#define GST_IS_PROMISE(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_PROMISE))
31#define GST_PROMISE(obj) ((GstPromise *) obj)
32
33typedef struct _GstPromise GstPromise;
34
35/**
36 * GstPromiseResult:
37 * @GST_PROMISE_RESULT_PENDING: Initial state. Waiting for transition to any
38 * other state.
39 * @GST_PROMISE_RESULT_INTERRUPTED: Interrupted by the consumer as it doesn't
40 * want the value anymore.
41 * @GST_PROMISE_RESULT_REPLIED: A producer marked a reply
42 * @GST_PROMISE_RESULT_EXPIRED: The promise expired (the carrying object
43 * lost all refs) and the promise will never be fulfilled.
44 *
45 * The result of a #GstPromise
46 *
47 * Since: 1.14
48 */
49typedef enum
50{
51 GST_PROMISE_RESULT_PENDING,
52 GST_PROMISE_RESULT_INTERRUPTED,
53 GST_PROMISE_RESULT_REPLIED,
54 GST_PROMISE_RESULT_EXPIRED,
55} GstPromiseResult;
56
57/**
58 * GstPromiseChangeFunc:
59 * @promise: a #GstPromise
60 * @user_data: (closure): user data
61 *
62 * Since: 1.14
63 */
64typedef void (*GstPromiseChangeFunc) (GstPromise * promise, gpointer user_data);
65
66/**
67 * GstPromise:
68 * @parent: parent #GstMiniObject
69 *
70 * Since: 1.14
71 */
72struct _GstPromise
73{
74 GstMiniObject parent;
75};
76
77GST_API
78GstPromise * gst_promise_new (void);
79GST_API
80GstPromise * gst_promise_new_with_change_func (GstPromiseChangeFunc func,
81 gpointer user_data,
82 GDestroyNotify notify);
83
84GST_API
85GstPromiseResult gst_promise_wait (GstPromise * promise);
86GST_API
87void gst_promise_reply (GstPromise * promise,
88 GstStructure * s);
89GST_API
90void gst_promise_interrupt (GstPromise * promise);
91GST_API
92void gst_promise_expire (GstPromise * promise);
93
94GST_API
95const GstStructure * gst_promise_get_reply (GstPromise * promise);
96
97#ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS
98static inline GstPromise *
99gst_promise_ref (GstPromise * promise)
100{
101 return (GstPromise *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (promise));
102}
103
104static inline void
105gst_promise_unref (GstPromise * promise)
106{
107 gst_mini_object_unref (GST_MINI_OBJECT_CAST (promise));
108}
109
110static inline void
111gst_clear_promise (GstPromise ** promise_ptr)
112{
113 gst_clear_mini_object ((GstMiniObject **) promise_ptr);
114}
115#else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
116GST_API
117GstPromise * gst_promise_ref (GstPromise * promise);
118
119GST_API
120void gst_promise_unref (GstPromise * promise);
121
122GST_API
123void gst_clear_promise (GstPromise ** promise_ptr);
124#endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
125
126G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPromise, gst_promise_unref)
127
128G_END_DECLS
129
130#endif /* __GST_PROMISE_H__ */
131

source code of include/gstreamer-1.0/gst/gstpromise.h