gstreamer_core/libs/gst/base/gstdataqueue.h
changeset 0 0e761a78d257
child 8 4a7fac7dd34a
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     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., 59 Temple Place - Suite 330,
       
    19  * Boston, MA 02111-1307, USA.
       
    20  */
       
    21 
       
    22 
       
    23 #ifndef __GST_DATA_QUEUE_H__
       
    24 #define __GST_DATA_QUEUE_H__
       
    25 
       
    26 #include <gst/gst.h>
       
    27 
       
    28 G_BEGIN_DECLS
       
    29 #define GST_TYPE_DATA_QUEUE \
       
    30   (gst_data_queue_get_type())
       
    31 #define GST_DATA_QUEUE(obj) \
       
    32   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DATA_QUEUE,GstDataQueue))
       
    33 #define GST_DATA_QUEUE_CLASS(klass) \
       
    34   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DATA_QUEUE,GstDataQueueClass))
       
    35 #define GST_IS_DATA_QUEUE(obj) \
       
    36   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DATA_QUEUE))
       
    37 #define GST_IS_DATA_QUEUE_CLASS(klass) \
       
    38   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DATA_QUEUE))
       
    39 typedef struct _GstDataQueue GstDataQueue;
       
    40 typedef struct _GstDataQueueClass GstDataQueueClass;
       
    41 typedef struct _GstDataQueueSize GstDataQueueSize;
       
    42 typedef struct _GstDataQueueItem GstDataQueueItem;
       
    43 
       
    44 /**
       
    45  * GstDataQueueItem:
       
    46  * @object: the #GstMiniObject to queue.
       
    47  * @size: the size in bytes of the miniobject.
       
    48  * @duration: the duration in #GstClockTime of the miniobject. Can not be
       
    49  * #GST_CLOCK_TIME_NONE.
       
    50  * @visible: #TRUE if @object should be considered as a visible object.
       
    51  * @destroy: The #GDestroyNotify function to use to free the #GstDataQueueItem.
       
    52  * This function should also drop the reference to @object the owner of the
       
    53  * #GstDataQueueItem is assumed to hold.
       
    54  *
       
    55  * Structure used by #GstDataQueue. You can supply a different structure, as
       
    56  * long as the top of the structure is identical to this structure.
       
    57  */
       
    58 
       
    59 struct _GstDataQueueItem
       
    60 {
       
    61   GstMiniObject *object;
       
    62   guint size;
       
    63   guint64 duration;
       
    64   gboolean visible;
       
    65 
       
    66   /* user supplied destroy function */
       
    67   GDestroyNotify destroy;
       
    68 };
       
    69 
       
    70 /**
       
    71  * GstDataQueueSize:
       
    72  * @visible: number of buffers
       
    73  * @bytes: number of bytes
       
    74  * @time: amount of time
       
    75  *
       
    76  * Structure describing the size of a queue.
       
    77  */
       
    78 struct _GstDataQueueSize
       
    79 {
       
    80   guint visible;
       
    81   guint bytes;
       
    82   guint64 time;
       
    83 };
       
    84 
       
    85 /**
       
    86  * GstDataQueueCheckFullFunction:
       
    87  * @queue: a #GstDataQueue.
       
    88  * @visible: The number of visible items currently in the queue.
       
    89  * @bytes: The amount of bytes currently in the queue.
       
    90  * @time: The accumulated duration of the items currently in the queue.
       
    91  * @checkdata: The #gpointer registered when the #GstDataQueue was created.
       
    92  * 
       
    93  * The prototype of the function used to inform the queue that it should be
       
    94  * considered as full.
       
    95  *
       
    96  * Returns: #TRUE if the queue should be considered full.
       
    97  */
       
    98 typedef gboolean (*GstDataQueueCheckFullFunction) (GstDataQueue * queue,
       
    99     guint visible, guint bytes, guint64 time, gpointer checkdata);
       
   100 
       
   101 /**
       
   102  * GstDataQueue:
       
   103  *
       
   104  * Opaque #GstDataQueue structure.
       
   105  */
       
   106 struct _GstDataQueue
       
   107 {
       
   108   GObject object;
       
   109 
       
   110   /*< private > */
       
   111   /* the queue of data we're keeping our grubby hands on */
       
   112   GQueue *queue;
       
   113 
       
   114   GstDataQueueSize cur_level;   /* size of the queue */
       
   115   GstDataQueueCheckFullFunction checkfull;      /* Callback to check if the queue is full */
       
   116   gpointer *checkdata;
       
   117 
       
   118   GMutex *qlock;                /* lock for queue (vs object lock) */
       
   119   GCond *item_add;              /* signals buffers now available for reading */
       
   120   GCond *item_del;              /* signals space now available for writing */
       
   121   gboolean flushing;            /* indicates whether conditions where signalled because
       
   122                                  * of external flushing */
       
   123 
       
   124   gpointer _gst_reserved[GST_PADDING];
       
   125 };
       
   126 
       
   127 struct _GstDataQueueClass
       
   128 {
       
   129   GObjectClass parent_class;
       
   130 
       
   131   /* signals */
       
   132   void (*empty) (GstDataQueue * queue);
       
   133   void (*full) (GstDataQueue * queue);
       
   134 
       
   135   gpointer _gst_reserved[GST_PADDING];
       
   136 };
       
   137 #ifdef __SYMBIAN32__
       
   138 IMPORT_C
       
   139 #endif
       
   140 
       
   141 
       
   142 GType gst_data_queue_get_type (void);
       
   143 #ifdef __SYMBIAN32__
       
   144 IMPORT_C
       
   145 #endif
       
   146 
       
   147 
       
   148 GstDataQueue * gst_data_queue_new            (GstDataQueueCheckFullFunction checkfull,
       
   149                                               gpointer checkdata);
       
   150 #ifdef __SYMBIAN32__
       
   151 IMPORT_C
       
   152 #endif
       
   153 
       
   154 
       
   155 gboolean       gst_data_queue_push           (GstDataQueue * queue, GstDataQueueItem * item);
       
   156 #ifdef __SYMBIAN32__
       
   157 IMPORT_C
       
   158 #endif
       
   159 
       
   160 gboolean       gst_data_queue_pop            (GstDataQueue * queue, GstDataQueueItem ** item);
       
   161 #ifdef __SYMBIAN32__
       
   162 IMPORT_C
       
   163 #endif
       
   164 
       
   165 
       
   166 void           gst_data_queue_flush          (GstDataQueue * queue);
       
   167 #ifdef __SYMBIAN32__
       
   168 IMPORT_C
       
   169 #endif
       
   170 
       
   171 void           gst_data_queue_set_flushing   (GstDataQueue * queue, gboolean flushing);
       
   172 #ifdef __SYMBIAN32__
       
   173 IMPORT_C
       
   174 #endif
       
   175 
       
   176 
       
   177 gboolean       gst_data_queue_drop_head      (GstDataQueue * queue, GType type);
       
   178 #ifdef __SYMBIAN32__
       
   179 IMPORT_C
       
   180 #endif
       
   181 
       
   182 
       
   183 gboolean       gst_data_queue_is_full        (GstDataQueue * queue);
       
   184 #ifdef __SYMBIAN32__
       
   185 IMPORT_C
       
   186 #endif
       
   187 
       
   188 gboolean       gst_data_queue_is_empty       (GstDataQueue * queue);
       
   189 #ifdef __SYMBIAN32__
       
   190 IMPORT_C
       
   191 #endif
       
   192 
       
   193 
       
   194 void           gst_data_queue_get_level      (GstDataQueue * queue, GstDataQueueSize *level);
       
   195 #ifdef __SYMBIAN32__
       
   196 IMPORT_C
       
   197 #endif
       
   198 
       
   199 void           gst_data_queue_limits_changed (GstDataQueue * queue);
       
   200 
       
   201 G_END_DECLS
       
   202 
       
   203 #endif /* __GST_DATA_QUEUE_H__ */