2 * Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
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.
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.
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.
20 #ifndef __GST_PROMISE_H__
21 #define __GST_PROMISE_H__
28 GType gst_promise_get_type(void);
29 #define GST_TYPE_PROMISE (gst_promise_get_type())
30 #define GST_PROMISE(obj) ((GstPromise *) obj)
32 typedef struct _GstPromise GstPromise;
36 * @GST_PROMISE_RESULT_PENDING: Initial state. Waiting for transition to any
38 * @GST_PROMISE_RESULT_INTERRUPTED: Interrupted by the consumer as it doesn't
39 * want the value anymore.
40 * @GST_PROMISE_RESULT_REPLIED: A producer marked a reply
41 * @GST_PROMISE_RESULT_EXPIRED: The promise expired (the carrying object
42 * lost all refs) and the promise will never be fulfilled.
44 * The result of a #GstPromise
48 GST_PROMISE_RESULT_PENDING,
49 GST_PROMISE_RESULT_INTERRUPTED,
50 GST_PROMISE_RESULT_REPLIED,
51 GST_PROMISE_RESULT_EXPIRED,
55 * GstPromiseChangeFunc:
56 * @promise: a #GstPromise
57 * @user_data: (closure): user data
59 typedef void (*GstPromiseChangeFunc) (GstPromise * promise, gpointer user_data);
63 * @parent: parent #GstMiniObject
71 GstPromise * gst_promise_new (void);
73 GstPromise * gst_promise_new_with_change_func (GstPromiseChangeFunc func,
75 GDestroyNotify notify);
78 GstPromiseResult gst_promise_wait (GstPromise * promise);
80 void gst_promise_reply (GstPromise * promise,
83 void gst_promise_interrupt (GstPromise * promise);
85 void gst_promise_expire (GstPromise * promise);
88 const GstStructure * gst_promise_get_reply (GstPromise * promise);
92 * @promise: a #GstPromise.
94 * Increases the refcount of the given @promise by one.
96 * Returns: (transfer full): @promise
98 static inline GstPromise *
99 gst_promise_ref (GstPromise * promise)
101 return (GstPromise *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (promise));
106 * @promise: (transfer full): a #GstPromise.
108 * Decreases the refcount of the promise. If the refcount reaches 0, the
109 * promise will be freed.
112 gst_promise_unref (GstPromise * promise)
114 gst_mini_object_unref (GST_MINI_OBJECT_CAST (promise));
119 #endif /* __GST_PROMISE_H__ */