gstclock.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /* GStreamer
  2. * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
  3. * 2000 Wim Taymans <wtay@chello.be>
  4. * 2005 Wim Taymans <wim@fluendo.com>
  5. *
  6. * gstclock.h: Header for clock subsystem
  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., 51 Franklin St, Fifth Floor,
  21. * Boston, MA 02110-1301, USA.
  22. */
  23. #ifndef __GST_CLOCK_H__
  24. #define __GST_CLOCK_H__
  25. #include <gst/gstconfig.h>
  26. #include <glib.h>
  27. G_BEGIN_DECLS
  28. /* --- standard type macros --- */
  29. #define GST_TYPE_CLOCK (gst_clock_get_type ())
  30. #define GST_CLOCK(clock) (G_TYPE_CHECK_INSTANCE_CAST ((clock), GST_TYPE_CLOCK, GstClock))
  31. #define GST_IS_CLOCK(clock) (G_TYPE_CHECK_INSTANCE_TYPE ((clock), GST_TYPE_CLOCK))
  32. #define GST_CLOCK_CLASS(cclass) (G_TYPE_CHECK_CLASS_CAST ((cclass), GST_TYPE_CLOCK, GstClockClass))
  33. #define GST_IS_CLOCK_CLASS(cclass) (G_TYPE_CHECK_CLASS_TYPE ((cclass), GST_TYPE_CLOCK))
  34. #define GST_CLOCK_GET_CLASS(clock) (G_TYPE_INSTANCE_GET_CLASS ((clock), GST_TYPE_CLOCK, GstClockClass))
  35. #define GST_CLOCK_CAST(clock) ((GstClock*)(clock))
  36. /**
  37. * GstClockTime:
  38. *
  39. * A datatype to hold a time, measured in nanoseconds.
  40. */
  41. typedef guint64 GstClockTime;
  42. /**
  43. * GST_TYPE_CLOCK_TIME:
  44. *
  45. * The #GType of a #GstClockTime.
  46. */
  47. #define GST_TYPE_CLOCK_TIME G_TYPE_UINT64
  48. /**
  49. * GstClockTimeDiff:
  50. *
  51. * A datatype to hold a time difference, measured in nanoseconds.
  52. */
  53. typedef gint64 GstClockTimeDiff;
  54. /**
  55. * GstClockID:
  56. *
  57. * A datatype to hold the handle to an outstanding sync or async clock callback.
  58. */
  59. typedef gpointer GstClockID;
  60. /**
  61. * GST_CLOCK_TIME_NONE: (value 18446744073709551615) (type GstClockTime)
  62. *
  63. * Constant to define an undefined clock time.
  64. */
  65. #define GST_CLOCK_TIME_NONE ((GstClockTime) -1)
  66. /**
  67. * GST_CLOCK_TIME_IS_VALID:
  68. * @time: clock time to validate
  69. *
  70. * Tests if a given #GstClockTime represents a valid defined time.
  71. */
  72. #define GST_CLOCK_TIME_IS_VALID(time) (((GstClockTime)(time)) != GST_CLOCK_TIME_NONE)
  73. /**
  74. * GST_CLOCK_STIME_NONE: (value -9223372036854775808) (type GstClockTimeDiff)
  75. *
  76. * Constant to define an undefined clock time.
  77. */
  78. #define GST_CLOCK_STIME_NONE G_MININT64
  79. /**
  80. * GST_CLOCK_STIME_IS_VALID:
  81. * @time: signed clock time to validate
  82. *
  83. * Tests if a given #GstClockTimeDiff of #gint64 represents a valid defined time.
  84. *
  85. * Since: 1.6
  86. */
  87. #define GST_CLOCK_STIME_IS_VALID(time) (((GstClockTimeDiff)(time)) != GST_CLOCK_STIME_NONE)
  88. /* FIXME: still need to explicitly force types on the defines below */
  89. /**
  90. * GST_SECOND: (value 1000000000) (type GstClockTime)
  91. *
  92. * Constant that defines one GStreamer second.
  93. */
  94. #define GST_SECOND (G_USEC_PER_SEC * G_GINT64_CONSTANT (1000))
  95. /**
  96. * GST_MSECOND: (value 1000000) (type GstClockTime)
  97. *
  98. * Constant that defines one GStreamer millisecond.
  99. */
  100. #define GST_MSECOND (GST_SECOND / G_GINT64_CONSTANT (1000))
  101. /**
  102. * GST_USECOND: (value 1000) (type GstClockTime)
  103. *
  104. * Constant that defines one GStreamer microsecond.
  105. */
  106. #define GST_USECOND (GST_SECOND / G_GINT64_CONSTANT (1000000))
  107. /**
  108. * GST_NSECOND: (value 1) (type GstClockTime)
  109. *
  110. * Constant that defines one GStreamer nanosecond
  111. */
  112. #define GST_NSECOND (GST_SECOND / G_GINT64_CONSTANT (1000000000))
  113. /**
  114. * GST_TIME_AS_SECONDS:
  115. * @time: the time
  116. *
  117. * Convert a #GstClockTime to seconds.
  118. */
  119. #define GST_TIME_AS_SECONDS(time) ((time) / GST_SECOND)
  120. /**
  121. * GST_TIME_AS_MSECONDS:
  122. * @time: the time
  123. *
  124. * Convert a #GstClockTime to milliseconds (1/1000 of a second).
  125. */
  126. #define GST_TIME_AS_MSECONDS(time) ((time) / G_GINT64_CONSTANT (1000000))
  127. /**
  128. * GST_TIME_AS_USECONDS:
  129. * @time: the time
  130. *
  131. * Convert a #GstClockTime to microseconds (1/1000000 of a second).
  132. */
  133. #define GST_TIME_AS_USECONDS(time) ((time) / G_GINT64_CONSTANT (1000))
  134. /**
  135. * GST_TIME_AS_NSECONDS:
  136. * @time: the time
  137. *
  138. * Convert a #GstClockTime to nanoseconds (1/1000000000 of a second).
  139. */
  140. #define GST_TIME_AS_NSECONDS(time) (time)
  141. /**
  142. * GST_CLOCK_DIFF:
  143. * @s: the first time
  144. * @e: the second time
  145. *
  146. * Calculate a difference between two clock times as a #GstClockTimeDiff.
  147. * The difference is calculated as @e - @s.
  148. */
  149. #define GST_CLOCK_DIFF(s, e) (GstClockTimeDiff)((e) - (s))
  150. /**
  151. * GST_TIMEVAL_TO_TIME:
  152. * @tv: the timeval to convert
  153. *
  154. * Convert a #GTimeVal to a #GstClockTime.
  155. */
  156. #define GST_TIMEVAL_TO_TIME(tv) (GstClockTime)((tv).tv_sec * GST_SECOND + (tv).tv_usec * GST_USECOND)
  157. /**
  158. * GST_TIME_TO_TIMEVAL:
  159. * @t: The #GstClockTime to convert
  160. * @tv: The target timeval
  161. *
  162. * Convert a #GstClockTime to a #GTimeVal
  163. *
  164. * <note>on 32-bit systems, a timeval has a range of only 2^32 - 1 seconds,
  165. * which is about 68 years. Expect trouble if you want to schedule stuff
  166. * in your pipeline for 2038.</note>
  167. */
  168. #define GST_TIME_TO_TIMEVAL(t,tv) \
  169. G_STMT_START { \
  170. g_assert ("Value of time " #t " is out of timeval's range" && \
  171. ((t) / GST_SECOND) < G_MAXLONG); \
  172. (tv).tv_sec = (glong) (((GstClockTime) (t)) / GST_SECOND); \
  173. (tv).tv_usec = (glong) ((((GstClockTime) (t)) - \
  174. ((GstClockTime) (tv).tv_sec) * GST_SECOND) \
  175. / GST_USECOND); \
  176. } G_STMT_END
  177. /**
  178. * GST_TIMESPEC_TO_TIME:
  179. * @ts: the timespec to convert
  180. *
  181. * Convert a struct timespec (see man pselect) to a #GstClockTime.
  182. */
  183. #define GST_TIMESPEC_TO_TIME(ts) (GstClockTime)((ts).tv_sec * GST_SECOND + (ts).tv_nsec * GST_NSECOND)
  184. /**
  185. * GST_TIME_TO_TIMESPEC:
  186. * @t: The #GstClockTime to convert
  187. * @ts: The target timespec
  188. *
  189. * Convert a #GstClockTime to a struct timespec (see man pselect)
  190. */
  191. #define GST_TIME_TO_TIMESPEC(t,ts) \
  192. G_STMT_START { \
  193. g_assert ("Value of time " #t " is out of timespec's range" && \
  194. ((t) / GST_SECOND) < G_MAXLONG); \
  195. (ts).tv_sec = (glong) ((t) / GST_SECOND); \
  196. (ts).tv_nsec = (glong) (((t) - (ts).tv_sec * GST_SECOND) / GST_NSECOND); \
  197. } G_STMT_END
  198. /* timestamp debugging macros */
  199. /**
  200. * GST_TIME_FORMAT:
  201. *
  202. * A string that can be used in printf-like format strings to display a
  203. * #GstClockTime value in h:m:s format. Use GST_TIME_ARGS() to construct
  204. * the matching arguments.
  205. *
  206. * Example:
  207. * |[<!-- language="C" -->
  208. * printf("%" GST_TIME_FORMAT "\n", GST_TIME_ARGS(ts));
  209. * ]|
  210. */
  211. #define GST_TIME_FORMAT "u:%02u:%02u.%09u"
  212. /**
  213. * GST_TIME_ARGS:
  214. * @t: a #GstClockTime
  215. *
  216. * Format @t for the #GST_TIME_FORMAT format string. Note: @t will be
  217. * evaluated more than once.
  218. */
  219. #define GST_TIME_ARGS(t) \
  220. GST_CLOCK_TIME_IS_VALID (t) ? \
  221. (guint) (((GstClockTime)(t)) / (GST_SECOND * 60 * 60)) : 99, \
  222. GST_CLOCK_TIME_IS_VALID (t) ? \
  223. (guint) ((((GstClockTime)(t)) / (GST_SECOND * 60)) % 60) : 99, \
  224. GST_CLOCK_TIME_IS_VALID (t) ? \
  225. (guint) ((((GstClockTime)(t)) / GST_SECOND) % 60) : 99, \
  226. GST_CLOCK_TIME_IS_VALID (t) ? \
  227. (guint) (((GstClockTime)(t)) % GST_SECOND) : 999999999
  228. /**
  229. * GST_STIME_FORMAT:
  230. *
  231. * A string that can be used in printf-like format strings to display a signed
  232. * #GstClockTimeDiff or #gint64 value in h:m:s format. Use GST_TIME_ARGS() to
  233. * construct the matching arguments.
  234. *
  235. * Example:
  236. * |[
  237. * printf("%" GST_STIME_FORMAT "\n", GST_STIME_ARGS(ts));
  238. * ]|
  239. *
  240. * Since: 1.6
  241. */
  242. #define GST_STIME_FORMAT "c%" GST_TIME_FORMAT
  243. /**
  244. * GST_STIME_ARGS:
  245. * @t: a #GstClockTimeDiff or #gint64
  246. *
  247. * Format @t for the #GST_STIME_FORMAT format string. Note: @t will be
  248. * evaluated more than once.
  249. *
  250. * Since: 1.6
  251. */
  252. #define GST_STIME_ARGS(t) \
  253. ((t) == GST_CLOCK_STIME_NONE || (t) >= 0) ? '+' : '-', \
  254. GST_CLOCK_STIME_IS_VALID (t) ? \
  255. (guint) (((GstClockTime)(ABS(t))) / (GST_SECOND * 60 * 60)) : 99, \
  256. GST_CLOCK_STIME_IS_VALID (t) ? \
  257. (guint) ((((GstClockTime)(ABS(t))) / (GST_SECOND * 60)) % 60) : 99, \
  258. GST_CLOCK_STIME_IS_VALID (t) ? \
  259. (guint) ((((GstClockTime)(ABS(t))) / GST_SECOND) % 60) : 99, \
  260. GST_CLOCK_STIME_IS_VALID (t) ? \
  261. (guint) (((GstClockTime)(ABS(t))) % GST_SECOND) : 999999999
  262. typedef struct _GstClockEntry GstClockEntry;
  263. typedef struct _GstClock GstClock;
  264. typedef struct _GstClockClass GstClockClass;
  265. typedef struct _GstClockPrivate GstClockPrivate;
  266. /* --- prototype for async callbacks --- */
  267. /**
  268. * GstClockCallback:
  269. * @clock: The clock that triggered the callback
  270. * @time: The time it was triggered
  271. * @id: The #GstClockID that expired
  272. * @user_data: user data passed in the gst_clock_id_wait_async() function
  273. *
  274. * The function prototype of the callback.
  275. *
  276. * Returns: %TRUE or %FALSE (currently unused)
  277. */
  278. typedef gboolean (*GstClockCallback) (GstClock *clock, GstClockTime time,
  279. GstClockID id, gpointer user_data);
  280. /**
  281. * GstClockReturn:
  282. * @GST_CLOCK_OK: The operation succeeded.
  283. * @GST_CLOCK_EARLY: The operation was scheduled too late.
  284. * @GST_CLOCK_UNSCHEDULED: The clockID was unscheduled
  285. * @GST_CLOCK_BUSY: The ClockID is busy
  286. * @GST_CLOCK_BADTIME: A bad time was provided to a function.
  287. * @GST_CLOCK_ERROR: An error occurred
  288. * @GST_CLOCK_UNSUPPORTED: Operation is not supported
  289. * @GST_CLOCK_DONE: The ClockID is done waiting
  290. *
  291. * The return value of a clock operation.
  292. */
  293. typedef enum
  294. {
  295. GST_CLOCK_OK = 0,
  296. GST_CLOCK_EARLY = 1,
  297. GST_CLOCK_UNSCHEDULED = 2,
  298. GST_CLOCK_BUSY = 3,
  299. GST_CLOCK_BADTIME = 4,
  300. GST_CLOCK_ERROR = 5,
  301. GST_CLOCK_UNSUPPORTED = 6,
  302. GST_CLOCK_DONE = 7
  303. } GstClockReturn;
  304. /**
  305. * GstClockEntryType:
  306. * @GST_CLOCK_ENTRY_SINGLE: a single shot timeout
  307. * @GST_CLOCK_ENTRY_PERIODIC: a periodic timeout request
  308. *
  309. * The type of the clock entry
  310. */
  311. typedef enum {
  312. GST_CLOCK_ENTRY_SINGLE,
  313. GST_CLOCK_ENTRY_PERIODIC
  314. } GstClockEntryType;
  315. /**
  316. * GST_CLOCK_ENTRY:
  317. * @entry: the entry to cast
  318. *
  319. * Cast to a clock entry
  320. */
  321. #define GST_CLOCK_ENTRY(entry) ((GstClockEntry *)(entry))
  322. /**
  323. * GST_CLOCK_ENTRY_CLOCK:
  324. * @entry: the entry to query
  325. *
  326. * Get the owner clock of the entry
  327. */
  328. #define GST_CLOCK_ENTRY_CLOCK(entry) ((entry)->clock)
  329. /**
  330. * GST_CLOCK_ENTRY_TYPE:
  331. * @entry: the entry to query
  332. *
  333. * Get the type of the clock entry
  334. */
  335. #define GST_CLOCK_ENTRY_TYPE(entry) ((entry)->type)
  336. /**
  337. * GST_CLOCK_ENTRY_TIME:
  338. * @entry: the entry to query
  339. *
  340. * Get the requested time of this entry
  341. */
  342. #define GST_CLOCK_ENTRY_TIME(entry) ((entry)->time)
  343. /**
  344. * GST_CLOCK_ENTRY_INTERVAL:
  345. * @entry: the entry to query
  346. *
  347. * Get the interval of this periodic entry
  348. */
  349. #define GST_CLOCK_ENTRY_INTERVAL(entry) ((entry)->interval)
  350. /**
  351. * GST_CLOCK_ENTRY_STATUS:
  352. * @entry: the entry to query
  353. *
  354. * The status of the entry
  355. */
  356. #define GST_CLOCK_ENTRY_STATUS(entry) ((entry)->status)
  357. /**
  358. * GstClockEntry:
  359. * @refcount: reference counter (read-only)
  360. *
  361. * All pending timeouts or periodic notifies are converted into
  362. * an entry.
  363. * Note that GstClockEntry should be treated as an opaque structure. It must
  364. * not be extended or allocated using a custom allocator.
  365. */
  366. struct _GstClockEntry {
  367. gint refcount;
  368. /*< protected >*/
  369. GstClock *clock;
  370. GstClockEntryType type;
  371. GstClockTime time;
  372. GstClockTime interval;
  373. GstClockReturn status;
  374. GstClockCallback func;
  375. gpointer user_data;
  376. GDestroyNotify destroy_data;
  377. gboolean unscheduled;
  378. gboolean woken_up;
  379. /*< private >*/
  380. gpointer _gst_reserved[GST_PADDING];
  381. };
  382. #include <gst/gstobject.h>
  383. /**
  384. * GstClockFlags:
  385. * @GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC: clock can do a single sync timeout request
  386. * @GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC: clock can do a single async timeout request
  387. * @GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC: clock can do sync periodic timeout requests
  388. * @GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC: clock can do async periodic timeout callbacks
  389. * @GST_CLOCK_FLAG_CAN_SET_RESOLUTION: clock's resolution can be changed
  390. * @GST_CLOCK_FLAG_CAN_SET_MASTER: clock can be slaved to a master clock
  391. * @GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC: clock needs to be synced before it can be used
  392. * (Since 1.6)
  393. * @GST_CLOCK_FLAG_LAST: subclasses can add additional flags starting from this flag
  394. *
  395. * The capabilities of this clock
  396. */
  397. typedef enum {
  398. GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC = (GST_OBJECT_FLAG_LAST << 0),
  399. GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC = (GST_OBJECT_FLAG_LAST << 1),
  400. GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC = (GST_OBJECT_FLAG_LAST << 2),
  401. GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC = (GST_OBJECT_FLAG_LAST << 3),
  402. GST_CLOCK_FLAG_CAN_SET_RESOLUTION = (GST_OBJECT_FLAG_LAST << 4),
  403. GST_CLOCK_FLAG_CAN_SET_MASTER = (GST_OBJECT_FLAG_LAST << 5),
  404. GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC = (GST_OBJECT_FLAG_LAST << 6),
  405. /* padding */
  406. GST_CLOCK_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 8)
  407. } GstClockFlags;
  408. /**
  409. * GST_CLOCK_FLAGS:
  410. * @clock: the clock to query
  411. *
  412. * Gets the #GstClockFlags clock flags.
  413. */
  414. #define GST_CLOCK_FLAGS(clock) GST_OBJECT_FLAGS(clock)
  415. /**
  416. * GstClock:
  417. *
  418. * #GstClock base structure. The values of this structure are
  419. * protected for subclasses, use the methods to use the #GstClock.
  420. */
  421. struct _GstClock {
  422. GstObject object;
  423. /*< private >*/
  424. GstClockPrivate *priv;
  425. gpointer _gst_reserved[GST_PADDING];
  426. };
  427. /**
  428. * GstClockClass:
  429. * @parent_class: the parent class structure
  430. * @change_resolution: change the resolution of the clock. Not all values might
  431. * be acceptable. The new resolution should be returned.
  432. * @get_resolution: get the resolution of the clock.
  433. * @get_internal_time: get the internal unadjusted time of the clock.
  434. * implement @wait_jitter instead.
  435. * @wait: perform a blocking wait on the given #GstClockEntry and return
  436. * the jitter.
  437. * @wait_async: perform an asynchronous wait for the given #GstClockEntry.
  438. * @unschedule: unblock a blocking or async wait operation.
  439. *
  440. * GStreamer clock class. Override the vmethods to implement the clock
  441. * functionality.
  442. */
  443. struct _GstClockClass {
  444. GstObjectClass parent_class;
  445. /*< public >*/
  446. /* vtable */
  447. GstClockTime (*change_resolution) (GstClock *clock,
  448. GstClockTime old_resolution,
  449. GstClockTime new_resolution);
  450. GstClockTime (*get_resolution) (GstClock *clock);
  451. GstClockTime (*get_internal_time) (GstClock *clock);
  452. /* waiting on an ID */
  453. GstClockReturn (*wait) (GstClock *clock, GstClockEntry *entry,
  454. GstClockTimeDiff *jitter);
  455. GstClockReturn (*wait_async) (GstClock *clock, GstClockEntry *entry);
  456. void (*unschedule) (GstClock *clock, GstClockEntry *entry);
  457. /*< private >*/
  458. gpointer _gst_reserved[GST_PADDING];
  459. };
  460. GType gst_clock_get_type (void);
  461. GstClockTime gst_clock_set_resolution (GstClock *clock,
  462. GstClockTime resolution);
  463. GstClockTime gst_clock_get_resolution (GstClock *clock);
  464. GstClockTime gst_clock_get_time (GstClock *clock);
  465. void gst_clock_set_calibration (GstClock *clock, GstClockTime internal,
  466. GstClockTime external,
  467. GstClockTime rate_num,
  468. GstClockTime rate_denom);
  469. void gst_clock_get_calibration (GstClock *clock, GstClockTime *internal,
  470. GstClockTime *external,
  471. GstClockTime *rate_num,
  472. GstClockTime *rate_denom);
  473. /* master/slave clocks */
  474. gboolean gst_clock_set_master (GstClock *clock, GstClock *master);
  475. GstClock* gst_clock_get_master (GstClock *clock);
  476. void gst_clock_set_timeout (GstClock *clock,
  477. GstClockTime timeout);
  478. GstClockTime gst_clock_get_timeout (GstClock *clock);
  479. gboolean gst_clock_add_observation (GstClock *clock, GstClockTime slave,
  480. GstClockTime master, gdouble *r_squared);
  481. gboolean gst_clock_add_observation_unapplied (GstClock *clock, GstClockTime slave,
  482. GstClockTime master, gdouble *r_squared,
  483. GstClockTime *internal,
  484. GstClockTime *external,
  485. GstClockTime *rate_num,
  486. GstClockTime *rate_denom);
  487. /* getting and adjusting internal/external time */
  488. GstClockTime gst_clock_get_internal_time (GstClock *clock);
  489. GstClockTime gst_clock_adjust_unlocked (GstClock *clock, GstClockTime internal);
  490. GstClockTime gst_clock_adjust_with_calibration (GstClock *clock,
  491. GstClockTime internal_target,
  492. GstClockTime cinternal,
  493. GstClockTime cexternal,
  494. GstClockTime cnum,
  495. GstClockTime cdenom);
  496. GstClockTime gst_clock_unadjust_with_calibration (GstClock *clock,
  497. GstClockTime external_target,
  498. GstClockTime cinternal,
  499. GstClockTime cexternal,
  500. GstClockTime cnum,
  501. GstClockTime cdenom);
  502. GstClockTime gst_clock_unadjust_unlocked (GstClock * clock, GstClockTime external);
  503. /* waiting for, signalling and checking for synchronization */
  504. gboolean gst_clock_wait_for_sync (GstClock * clock, GstClockTime timeout);
  505. gboolean gst_clock_is_synced (GstClock * clock);
  506. /* to be used by subclasses only */
  507. void gst_clock_set_synced (GstClock * clock, gboolean synced);
  508. /* creating IDs that can be used to get notifications */
  509. GstClockID gst_clock_new_single_shot_id (GstClock *clock,
  510. GstClockTime time);
  511. GstClockID gst_clock_new_periodic_id (GstClock *clock,
  512. GstClockTime start_time,
  513. GstClockTime interval);
  514. /* reference counting */
  515. GstClockID gst_clock_id_ref (GstClockID id);
  516. void gst_clock_id_unref (GstClockID id);
  517. /* operations on IDs */
  518. gint gst_clock_id_compare_func (gconstpointer id1, gconstpointer id2);
  519. GstClockTime gst_clock_id_get_time (GstClockID id);
  520. GstClockReturn gst_clock_id_wait (GstClockID id,
  521. GstClockTimeDiff *jitter);
  522. GstClockReturn gst_clock_id_wait_async (GstClockID id,
  523. GstClockCallback func,
  524. gpointer user_data,
  525. GDestroyNotify destroy_data);
  526. void gst_clock_id_unschedule (GstClockID id);
  527. gboolean gst_clock_single_shot_id_reinit (GstClock * clock,
  528. GstClockID id,
  529. GstClockTime time);
  530. gboolean gst_clock_periodic_id_reinit (GstClock * clock,
  531. GstClockID id,
  532. GstClockTime start_time,
  533. GstClockTime interval);
  534. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  535. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstClock, gst_object_unref)
  536. #endif
  537. G_END_DECLS
  538. #endif /* __GST_CLOCK_H__ */