gstdataqueue.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* GStreamer
  2. * Copyright (C) 2006 Edward Hervey <edward@fluendo.com>
  3. *
  4. * gstdataqueue.h:
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  19. * Boston, MA 02110-1301, USA.
  20. */
  21. #ifndef __GST_DATA_QUEUE_H__
  22. #define __GST_DATA_QUEUE_H__
  23. #include <gst/gst.h>
  24. G_BEGIN_DECLS
  25. #define GST_TYPE_DATA_QUEUE \
  26. (gst_data_queue_get_type())
  27. #define GST_DATA_QUEUE(obj) \
  28. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DATA_QUEUE,GstDataQueue))
  29. #define GST_DATA_QUEUE_CLASS(klass) \
  30. (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DATA_QUEUE,GstDataQueueClass))
  31. #define GST_IS_DATA_QUEUE(obj) \
  32. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DATA_QUEUE))
  33. #define GST_IS_DATA_QUEUE_CLASS(klass) \
  34. (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DATA_QUEUE))
  35. typedef struct _GstDataQueue GstDataQueue;
  36. typedef struct _GstDataQueueClass GstDataQueueClass;
  37. typedef struct _GstDataQueueSize GstDataQueueSize;
  38. typedef struct _GstDataQueueItem GstDataQueueItem;
  39. typedef struct _GstDataQueuePrivate GstDataQueuePrivate;
  40. /**
  41. * GstDataQueueItem: (skip)
  42. * @object: the #GstMiniObject to queue.
  43. * @size: the size in bytes of the miniobject.
  44. * @duration: the duration in #GstClockTime of the miniobject. Can not be
  45. * %GST_CLOCK_TIME_NONE.
  46. * @visible: %TRUE if @object should be considered as a visible object.
  47. * @destroy: The #GDestroyNotify function to use to free the #GstDataQueueItem.
  48. * This function should also drop the reference to @object the owner of the
  49. * #GstDataQueueItem is assumed to hold.
  50. *
  51. * Structure used by #GstDataQueue. You can supply a different structure, as
  52. * long as the top of the structure is identical to this structure.
  53. */
  54. struct _GstDataQueueItem
  55. {
  56. GstMiniObject *object;
  57. guint size;
  58. guint64 duration;
  59. gboolean visible;
  60. /* user supplied destroy function */
  61. GDestroyNotify destroy;
  62. /* < private > */
  63. gpointer _gst_reserved[GST_PADDING];
  64. };
  65. /**
  66. * GstDataQueueSize: (skip)
  67. * @visible: number of buffers
  68. * @bytes: number of bytes
  69. * @time: amount of time
  70. *
  71. * Structure describing the size of a queue.
  72. */
  73. struct _GstDataQueueSize
  74. {
  75. guint visible;
  76. guint bytes;
  77. guint64 time;
  78. };
  79. /**
  80. * GstDataQueueCheckFullFunction: (skip)
  81. * @queue: a #GstDataQueue.
  82. * @visible: The number of visible items currently in the queue.
  83. * @bytes: The amount of bytes currently in the queue.
  84. * @time: The accumulated duration of the items currently in the queue.
  85. * @checkdata: The #gpointer registered when the #GstDataQueue was created.
  86. *
  87. * The prototype of the function used to inform the queue that it should be
  88. * considered as full.
  89. *
  90. * Returns: %TRUE if the queue should be considered full.
  91. */
  92. typedef gboolean (*GstDataQueueCheckFullFunction) (GstDataQueue * queue,
  93. guint visible, guint bytes, guint64 time, gpointer checkdata);
  94. typedef void (*GstDataQueueFullCallback) (GstDataQueue * queue, gpointer checkdata);
  95. typedef void (*GstDataQueueEmptyCallback) (GstDataQueue * queue, gpointer checkdata);
  96. /**
  97. * GstDataQueue:
  98. * @object: the parent structure
  99. *
  100. * Opaque #GstDataQueue structure.
  101. */
  102. struct _GstDataQueue
  103. {
  104. GObject object;
  105. /*< private >*/
  106. GstDataQueuePrivate *priv;
  107. gpointer _gst_reserved[GST_PADDING];
  108. };
  109. /**
  110. * GstDataQueueClass:
  111. */
  112. struct _GstDataQueueClass
  113. {
  114. GObjectClass parent_class;
  115. /* signals */
  116. void (*empty) (GstDataQueue * queue);
  117. void (*full) (GstDataQueue * queue);
  118. gpointer _gst_reserved[GST_PADDING];
  119. };
  120. GType gst_data_queue_get_type (void);
  121. GstDataQueue * gst_data_queue_new (GstDataQueueCheckFullFunction checkfull,
  122. GstDataQueueFullCallback fullcallback,
  123. GstDataQueueEmptyCallback emptycallback,
  124. gpointer checkdata) G_GNUC_MALLOC;
  125. gboolean gst_data_queue_push (GstDataQueue * queue, GstDataQueueItem * item);
  126. gboolean gst_data_queue_push_force (GstDataQueue * queue, GstDataQueueItem * item);
  127. gboolean gst_data_queue_pop (GstDataQueue * queue, GstDataQueueItem ** item);
  128. gboolean gst_data_queue_peek (GstDataQueue * queue, GstDataQueueItem ** item);
  129. void gst_data_queue_flush (GstDataQueue * queue);
  130. void gst_data_queue_set_flushing (GstDataQueue * queue, gboolean flushing);
  131. gboolean gst_data_queue_drop_head (GstDataQueue * queue, GType type);
  132. gboolean gst_data_queue_is_full (GstDataQueue * queue);
  133. gboolean gst_data_queue_is_empty (GstDataQueue * queue);
  134. void gst_data_queue_get_level (GstDataQueue * queue, GstDataQueueSize *level);
  135. void gst_data_queue_limits_changed (GstDataQueue * queue);
  136. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  137. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDataQueue, gst_object_unref)
  138. #endif
  139. G_END_DECLS
  140. #endif /* __GST_DATA_QUEUE_H__ */