1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gst-gmyth/multiqueue/gstdataqueue.h Tue Aug 28 08:16:13 2007 +0100
1.3 @@ -0,0 +1,159 @@
1.4 +/* GStreamer
1.5 + * Copyright (C) 2006 Edward Hervey <edward@fluendo.com>
1.6 + *
1.7 + * gstdataqueue.h:
1.8 + *
1.9 + * This library is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU Library General Public
1.11 + * License as published by the Free Software Foundation; either
1.12 + * version 2 of the License, or (at your option) any later version.
1.13 + *
1.14 + * This library is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.17 + * Library General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU Library General Public
1.20 + * License along with this library; if not, write to the
1.21 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1.22 + * Boston, MA 02111-1307, USA.
1.23 + */
1.24 +
1.25 +
1.26 +#ifndef __GST_DATA_QUEUE_H__
1.27 +#define __GST_DATA_QUEUE_H__
1.28 +
1.29 +#include <gst/gst.h>
1.30 +
1.31 +G_BEGIN_DECLS
1.32 +#define GST_TYPE_DATA_QUEUE \
1.33 + (gst_data_queue_get_type())
1.34 +#define GST_DATA_QUEUE(obj) \
1.35 + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DATA_QUEUE,GstDataQueue))
1.36 +#define GST_DATA_QUEUE_CLASS(klass) \
1.37 + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DATA_QUEUE,GstDataQueueClass))
1.38 +#define GST_IS_DATA_QUEUE(obj) \
1.39 + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DATA_QUEUE))
1.40 +#define GST_IS_DATA_QUEUE_CLASS(klass) \
1.41 + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DATA_QUEUE))
1.42 +typedef struct _GstDataQueue GstDataQueue;
1.43 +typedef struct _GstDataQueueClass GstDataQueueClass;
1.44 +typedef struct _GstDataQueueSize GstDataQueueSize;
1.45 +typedef struct _GstDataQueueItem GstDataQueueItem;
1.46 +
1.47 +/**
1.48 + * GstDataQueueItem:
1.49 + * @object: the #GstMiniObject to queue.
1.50 + * @size: the size in bytes of the miniobject.
1.51 + * @duration: the duration in #GstClockTime of the miniobject. Can not be
1.52 + * #GST_CLOCK_TIME_NONE.
1.53 + * @visible: #TRUE if @object should be considered as a visible object.
1.54 + * @destroy: The #GDestroyNotify function to use to free the #GstDataQueueItem.
1.55 + * This function should also drop the reference to @object the owner of the
1.56 + * #GstDataQueueItem is assumed to hold.
1.57 + *
1.58 + * Structure used by #GstDataQueue. You can supply a different structure, as
1.59 + * long as the top of the structure is identical to this structure.
1.60 + */
1.61 +
1.62 +struct _GstDataQueueItem
1.63 +{
1.64 + GstMiniObject *object;
1.65 + guint size;
1.66 + guint64 duration;
1.67 + gboolean visible;
1.68 +
1.69 + /* user supplied destroy function */
1.70 + GDestroyNotify destroy;
1.71 +};
1.72 +
1.73 +/**
1.74 + * GstDataQueueSize:
1.75 + * @visible: number of buffers
1.76 + * @bytes: number of bytes
1.77 + * @time: amount of time
1.78 + *
1.79 + * Structure describing the size of a queue.
1.80 + */
1.81 +struct _GstDataQueueSize
1.82 +{
1.83 + guint visible;
1.84 + guint bytes;
1.85 + guint64 time;
1.86 +};
1.87 +
1.88 +/**
1.89 + * GstDataQueueCheckFullFunction:
1.90 + * @queue: a #GstDataQueue.
1.91 + * @visible: The number of visible items currently in the queue.
1.92 + * @bytes: The amount of bytes currently in the queue.
1.93 + * @time: The accumulated duration of the items currently in the queue.
1.94 + * @checkdata: The #gpointer registered when the #GstDataQueue was created.
1.95 + *
1.96 + * The prototype of the function used to inform the queue that it should be
1.97 + * considered as full.
1.98 + *
1.99 + * Returns: #TRUE if the queue should be considered full.
1.100 + */
1.101 +typedef gboolean (*GstDataQueueCheckFullFunction) (GstDataQueue * queue,
1.102 + guint visible, guint bytes, guint64 time, gpointer checkdata);
1.103 +
1.104 +/**
1.105 + * GstDataQueue:
1.106 + *
1.107 + * Opaque #GstDataQueue structure.
1.108 + */
1.109 +struct _GstDataQueue
1.110 +{
1.111 + GObject object;
1.112 +
1.113 + /*< private > */
1.114 + /* the queue of data we're keeping our grubby hands on */
1.115 + GQueue *queue;
1.116 +
1.117 + GstDataQueueSize cur_level; /* size of the queue */
1.118 + GstDataQueueCheckFullFunction checkfull; /* Callback to check if the queue is full */
1.119 + gpointer *checkdata;
1.120 +
1.121 + GMutex *qlock; /* lock for queue (vs object lock) */
1.122 + GCond *item_add; /* signals buffers now available for reading */
1.123 + GCond *item_del; /* signals space now available for writing */
1.124 + gboolean flushing; /* indicates whether conditions where signalled because
1.125 + * of external flushing */
1.126 +
1.127 + gpointer _gst_reserved[GST_PADDING];
1.128 +};
1.129 +
1.130 +struct _GstDataQueueClass
1.131 +{
1.132 + GObjectClass parent_class;
1.133 +
1.134 + /* signals */
1.135 + void (*empty) (GstDataQueue * queue);
1.136 + void (*full) (GstDataQueue * queue);
1.137 +
1.138 + gpointer _gst_reserved[GST_PADDING];
1.139 +};
1.140 +
1.141 +GType gst_data_queue_get_type (void);
1.142 +
1.143 +GstDataQueue * gst_data_queue_new (GstDataQueueCheckFullFunction checkfull,
1.144 + gpointer checkdata);
1.145 +
1.146 +gboolean gst_data_queue_push (GstDataQueue * queue, GstDataQueueItem * item);
1.147 +gboolean gst_data_queue_pop (GstDataQueue * queue, GstDataQueueItem ** item);
1.148 +
1.149 +void gst_data_queue_flush (GstDataQueue * queue);
1.150 +void gst_data_queue_set_flushing (GstDataQueue * queue, gboolean flushing);
1.151 +
1.152 +gboolean gst_data_queue_drop_head (GstDataQueue * queue, GType type);
1.153 +
1.154 +gboolean gst_data_queue_is_full (GstDataQueue * queue);
1.155 +gboolean gst_data_queue_is_empty (GstDataQueue * queue);
1.156 +
1.157 +void gst_data_queue_get_level (GstDataQueue * queue, GstDataQueueSize *level);
1.158 +void gst_data_queue_limits_changed (GstDataQueue * queue);
1.159 +
1.160 +G_END_DECLS
1.161 +
1.162 +#endif /* __GST_DATA_QUEUE_H__ */