gst-gmyth/multiqueue/gstdataqueue.h
author melunko
Wed Aug 01 14:50:29 2007 +0100 (2007-08-01)
branchtrunk
changeset 790 7a914b3fafc1
permissions -rw-r--r--
[svn r796] Moved maemo-ui to maemo-ui-old
renatofilho@787
     1
/* GStreamer
renatofilho@787
     2
 * Copyright (C) 2006 Edward Hervey <edward@fluendo.com>
renatofilho@787
     3
 *
renatofilho@787
     4
 * gstdataqueue.h:
renatofilho@787
     5
 *
renatofilho@787
     6
 * This library is free software; you can redistribute it and/or
renatofilho@787
     7
 * modify it under the terms of the GNU Library General Public
renatofilho@787
     8
 * License as published by the Free Software Foundation; either
renatofilho@787
     9
 * version 2 of the License, or (at your option) any later version.
renatofilho@787
    10
 *
renatofilho@787
    11
 * This library is distributed in the hope that it will be useful,
renatofilho@787
    12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
renatofilho@787
    13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
renatofilho@787
    14
 * Library General Public License for more details.
renatofilho@787
    15
 *
renatofilho@787
    16
 * You should have received a copy of the GNU Library General Public
renatofilho@787
    17
 * License along with this library; if not, write to the
renatofilho@787
    18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
renatofilho@787
    19
 * Boston, MA 02111-1307, USA.
renatofilho@787
    20
 */
renatofilho@787
    21
renatofilho@787
    22
renatofilho@787
    23
#ifndef __GST_DATA_QUEUE_H__
renatofilho@787
    24
#define __GST_DATA_QUEUE_H__
renatofilho@787
    25
renatofilho@787
    26
#include <gst/gst.h>
renatofilho@787
    27
renatofilho@787
    28
G_BEGIN_DECLS
renatofilho@787
    29
#define GST_TYPE_DATA_QUEUE \
renatofilho@787
    30
  (gst_data_queue_get_type())
renatofilho@787
    31
#define GST_DATA_QUEUE(obj) \
renatofilho@787
    32
  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DATA_QUEUE,GstDataQueue))
renatofilho@787
    33
#define GST_DATA_QUEUE_CLASS(klass) \
renatofilho@787
    34
  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DATA_QUEUE,GstDataQueueClass))
renatofilho@787
    35
#define GST_IS_DATA_QUEUE(obj) \
renatofilho@787
    36
  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DATA_QUEUE))
renatofilho@787
    37
#define GST_IS_DATA_QUEUE_CLASS(klass) \
renatofilho@787
    38
  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DATA_QUEUE))
renatofilho@787
    39
typedef struct _GstDataQueue GstDataQueue;
renatofilho@787
    40
typedef struct _GstDataQueueClass GstDataQueueClass;
renatofilho@787
    41
typedef struct _GstDataQueueSize GstDataQueueSize;
renatofilho@787
    42
typedef struct _GstDataQueueItem GstDataQueueItem;
renatofilho@787
    43
renatofilho@787
    44
/**
renatofilho@787
    45
 * GstDataQueueItem:
renatofilho@787
    46
 * @object: the #GstMiniObject to queue.
renatofilho@787
    47
 * @size: the size in bytes of the miniobject.
renatofilho@787
    48
 * @duration: the duration in #GstClockTime of the miniobject. Can not be
renatofilho@787
    49
 * #GST_CLOCK_TIME_NONE.
renatofilho@787
    50
 * @visible: #TRUE if @object should be considered as a visible object.
renatofilho@787
    51
 * @destroy: The #GDestroyNotify function to use to free the #GstDataQueueItem.
renatofilho@787
    52
 * This function should also drop the reference to @object the owner of the
renatofilho@787
    53
 * #GstDataQueueItem is assumed to hold.
renatofilho@787
    54
 *
renatofilho@787
    55
 * Structure used by #GstDataQueue. You can supply a different structure, as
renatofilho@787
    56
 * long as the top of the structure is identical to this structure.
renatofilho@787
    57
 */
renatofilho@787
    58
renatofilho@787
    59
struct _GstDataQueueItem
renatofilho@787
    60
{
renatofilho@787
    61
  GstMiniObject *object;
renatofilho@787
    62
  guint size;
renatofilho@787
    63
  guint64 duration;
renatofilho@787
    64
  gboolean visible;
renatofilho@787
    65
renatofilho@787
    66
  /* user supplied destroy function */
renatofilho@787
    67
  GDestroyNotify destroy;
renatofilho@787
    68
};
renatofilho@787
    69
renatofilho@787
    70
/**
renatofilho@787
    71
 * GstDataQueueSize:
renatofilho@787
    72
 * @visible: number of buffers
renatofilho@787
    73
 * @bytes: number of bytes
renatofilho@787
    74
 * @time: amount of time
renatofilho@787
    75
 *
renatofilho@787
    76
 * Structure describing the size of a queue.
renatofilho@787
    77
 */
renatofilho@787
    78
struct _GstDataQueueSize
renatofilho@787
    79
{
renatofilho@787
    80
  guint visible;
renatofilho@787
    81
  guint bytes;
renatofilho@787
    82
  guint64 time;
renatofilho@787
    83
};
renatofilho@787
    84
renatofilho@787
    85
/**
renatofilho@787
    86
 * GstDataQueueCheckFullFunction:
renatofilho@787
    87
 * @queue: a #GstDataQueue.
renatofilho@787
    88
 * @visible: The number of visible items currently in the queue.
renatofilho@787
    89
 * @bytes: The amount of bytes currently in the queue.
renatofilho@787
    90
 * @time: The accumulated duration of the items currently in the queue.
renatofilho@787
    91
 * @checkdata: The #gpointer registered when the #GstDataQueue was created.
renatofilho@787
    92
 * 
renatofilho@787
    93
 * The prototype of the function used to inform the queue that it should be
renatofilho@787
    94
 * considered as full.
renatofilho@787
    95
 *
renatofilho@787
    96
 * Returns: #TRUE if the queue should be considered full.
renatofilho@787
    97
 */
renatofilho@787
    98
typedef gboolean (*GstDataQueueCheckFullFunction) (GstDataQueue * queue,
renatofilho@787
    99
    guint visible, guint bytes, guint64 time, gpointer checkdata);
renatofilho@787
   100
renatofilho@787
   101
/**
renatofilho@787
   102
 * GstDataQueue:
renatofilho@787
   103
 *
renatofilho@787
   104
 * Opaque #GstDataQueue structure.
renatofilho@787
   105
 */
renatofilho@787
   106
struct _GstDataQueue
renatofilho@787
   107
{
renatofilho@787
   108
  GObject object;
renatofilho@787
   109
renatofilho@787
   110
  /*< private > */
renatofilho@787
   111
  /* the queue of data we're keeping our grubby hands on */
renatofilho@787
   112
  GQueue *queue;
renatofilho@787
   113
renatofilho@787
   114
  GstDataQueueSize cur_level;   /* size of the queue */
renatofilho@787
   115
  GstDataQueueCheckFullFunction checkfull;      /* Callback to check if the queue is full */
renatofilho@787
   116
  gpointer *checkdata;
renatofilho@787
   117
renatofilho@787
   118
  GMutex *qlock;                /* lock for queue (vs object lock) */
renatofilho@787
   119
  GCond *item_add;              /* signals buffers now available for reading */
renatofilho@787
   120
  GCond *item_del;              /* signals space now available for writing */
renatofilho@787
   121
  gboolean flushing;            /* indicates whether conditions where signalled because
renatofilho@787
   122
                                 * of external flushing */
renatofilho@787
   123
renatofilho@787
   124
  gpointer _gst_reserved[GST_PADDING];
renatofilho@787
   125
};
renatofilho@787
   126
renatofilho@787
   127
struct _GstDataQueueClass
renatofilho@787
   128
{
renatofilho@787
   129
  GObjectClass parent_class;
renatofilho@787
   130
renatofilho@787
   131
  /* signals */
renatofilho@787
   132
  void (*empty) (GstDataQueue * queue);
renatofilho@787
   133
  void (*full) (GstDataQueue * queue);
renatofilho@787
   134
renatofilho@787
   135
  gpointer _gst_reserved[GST_PADDING];
renatofilho@787
   136
};
renatofilho@787
   137
renatofilho@787
   138
GType gst_data_queue_get_type (void);
renatofilho@787
   139
renatofilho@787
   140
GstDataQueue * gst_data_queue_new            (GstDataQueueCheckFullFunction checkfull,
renatofilho@787
   141
                                              gpointer checkdata);
renatofilho@787
   142
renatofilho@787
   143
gboolean       gst_data_queue_push           (GstDataQueue * queue, GstDataQueueItem * item);
renatofilho@787
   144
gboolean       gst_data_queue_pop            (GstDataQueue * queue, GstDataQueueItem ** item);
renatofilho@787
   145
renatofilho@787
   146
void           gst_data_queue_flush          (GstDataQueue * queue);
renatofilho@787
   147
void           gst_data_queue_set_flushing   (GstDataQueue * queue, gboolean flushing);
renatofilho@787
   148
renatofilho@787
   149
gboolean       gst_data_queue_drop_head      (GstDataQueue * queue, GType type);
renatofilho@787
   150
renatofilho@787
   151
gboolean       gst_data_queue_is_full        (GstDataQueue * queue);
renatofilho@787
   152
gboolean       gst_data_queue_is_empty       (GstDataQueue * queue);
renatofilho@787
   153
renatofilho@787
   154
void           gst_data_queue_get_level      (GstDataQueue * queue, GstDataQueueSize *level);
renatofilho@787
   155
void           gst_data_queue_limits_changed (GstDataQueue * queue);
renatofilho@787
   156
renatofilho@787
   157
G_END_DECLS
renatofilho@787
   158
renatofilho@787
   159
#endif /* __GST_DATA_QUEUE_H__ */