cccbae30c2cfda41209f838f246ca305590ee51d
[platform/upstream/gstreamer.git] / libs / gst / check / gsttestclock.h
1 /* GstTestClock - A deterministic clock for GStreamer unit tests
2  *
3  * Copyright (C) 2008 Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
4  * Copyright (C) 2012 Sebastian Rasmussen <sebastian.rasmussen@axis.com>
5  * Copyright (C) 2012 Havard Graff <havard@pexip.com>
6  * Copyright (C) 2013 Haakon Sporsheim <haakon@pexip.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #ifndef __GST_TEST_CLOCK_H__
25 #define __GST_TEST_CLOCK_H__
26
27 #include <gst/gst.h>
28
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_TEST_CLOCK (gst_test_clock_get_type ())
32 #define GST_TEST_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
33     GST_TYPE_TEST_CLOCK, GstTestClock))
34 #define GST_IS_TEST_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
35     GST_TYPE_TEST_CLOCK))
36 #define GST_TEST_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
37     GST_TYPE_TEST_CLOCK, GstTestClockClass))
38 #define GST_IS_TEST_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (\
39     (klass), GST_TYPE_TEST_CLOCK))
40 #define GST_TEST_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (\
41     (obj), GST_TYPE_TEST_CLOCK, GstTestClockClass))
42 #define GST_TEST_CLOCK_CAST(obj) ((GstTestClock*)(obj))
43
44 typedef struct _GstTestClock GstTestClock;
45 typedef struct _GstTestClockClass GstTestClockClass;
46 typedef struct _GstTestClockPrivate GstTestClockPrivate;
47
48 /**
49  * GstTestClock:
50  *
51  * A #GstTestClock structure which is based on a #GstClock along with some
52  * private data.
53  *
54  * Since: 1.2
55  */
56 struct _GstTestClock
57 {
58   GstClock parent;
59
60   /*< private >*/
61   GstTestClockPrivate *priv;
62 };
63
64 /**
65  * GstTestClockClass:
66  * @parent_class: the parent class structure
67  *
68  * The class of a #GstTestClock, which has no virtual methods to override.
69  *
70  * Since: 1.2
71  */
72 struct _GstTestClockClass
73 {
74   GstClockClass parent_class;
75 };
76
77 GType         gst_test_clock_get_type (void);
78
79 GstClock *    gst_test_clock_new (void);
80
81 GstClock *    gst_test_clock_new_with_start_time (GstClockTime start_time);
82
83 void          gst_test_clock_set_time (GstTestClock * test_clock,
84                                       GstClockTime   new_time);
85
86 void          gst_test_clock_advance_time (GstTestClock *   test_clock,
87                                           GstClockTimeDiff delta);
88
89 guint         gst_test_clock_peek_id_count (GstTestClock * test_clock);
90
91 gboolean      gst_test_clock_has_id (GstTestClock * test_clock, GstClockID id);
92
93 gboolean      gst_test_clock_peek_next_pending_id (GstTestClock * test_clock,
94                                                    GstClockID   * pending_id);
95
96 void          gst_test_clock_wait_for_next_pending_id (GstTestClock * test_clock,
97                                                        GstClockID   * pending_id);
98
99 #ifndef GST_DISABLE_DEPRECATED
100 void          gst_test_clock_wait_for_pending_id_count (GstTestClock * test_clock,
101                                                         guint          count);
102 #endif
103
104 GstClockID    gst_test_clock_process_next_clock_id (GstTestClock * test_clock);
105
106 GstClockTime  gst_test_clock_get_next_entry_time   (GstTestClock * test_clock);
107
108 void          gst_test_clock_wait_for_multiple_pending_ids (GstTestClock * test_clock,
109                                                             guint          count,
110                                                             GList       ** pending_list);
111
112 guint         gst_test_clock_process_id_list (GstTestClock * test_clock,
113                                               const GList  * pending_list);
114
115 GstClockTime  gst_test_clock_id_list_get_latest_time (const GList * pending_list);
116
117 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
118 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstTestClock, gst_object_unref)
119 #endif
120
121 G_END_DECLS
122
123 #endif /* __GST_TEST_CLOCK_H__ */