~ubuntu-branches/ubuntu/precise/gst-plugins-bad0.10/precise-proposed

« back to all changes in this revision

Viewing changes to gst/rtpmanager/async_jitter_queue.h

Tags: upstream-0.10.5.3
Import upstream version 0.10.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Async Jitter Queue based on g_async_queue
2
 
 *
3
 
 * Farsight Voice+Video library
4
 
 *  Copyright 2007 Collabora Ltd, 
5
 
 *  Copyright 2007 Nokia Corporation
6
 
 *   @author: Philippe Khalaf <philippe.khalaf@collabora.co.uk>.
7
 
 */
8
 
 
9
 
/* GLIB - Library of useful routines for C programming
10
 
 * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
11
 
 *
12
 
 * This library is free software; you can redistribute it and/or
13
 
 * modify it under the terms of the GNU Lesser General Public
14
 
 * License as published by the Free Software Foundation; either
15
 
 * version 2 of the License, or (at your option) any later version.
16
 
 *
17
 
 * This library is distributed in the hope that it will be useful,
18
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
 
 * Lesser General Public License for more details.
21
 
 *
22
 
 * You should have received a copy of the GNU Lesser General Public
23
 
 * License along with this library; if not, write to the
24
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25
 
 * Boston, MA 02111-1307, USA.
26
 
 */
27
 
 
28
 
/*
29
 
 * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
30
 
 * file for a list of people on the GLib Team.  See the ChangeLog
31
 
 * files for a list of changes.  These files are distributed with
32
 
 * GLib at ftp://ftp.gtk.org/pub/gtk/. 
33
 
 */
34
 
 
35
 
#ifndef __ASYNCJITTERQUEUE_H__
36
 
#define __ASYNCJITTERQUEUE_H__
37
 
 
38
 
#include <glib.h>
39
 
#include <glib/gthread.h>
40
 
 
41
 
G_BEGIN_DECLS
42
 
 
43
 
typedef struct _AsyncJitterQueue     AsyncJitterQueue;
44
 
 
45
 
/* Asyncronous Queues, can be used to communicate between threads
46
 
 */
47
 
 
48
 
/* Get a new AsyncJitterQueue with the ref_count 1 */
49
 
AsyncJitterQueue*  async_jitter_queue_new                (void);
50
 
 
51
 
/* Lock and unlock a AsyncJitterQueue. All functions lock the queue for
52
 
 * themselves, but in certain cirumstances you want to hold the lock longer,
53
 
 * thus you lock the queue, call the *_unlocked functions and unlock it again.
54
 
 */
55
 
void          async_jitter_queue_lock               (AsyncJitterQueue *queue);
56
 
void          async_jitter_queue_unlock             (AsyncJitterQueue *queue);
57
 
 
58
 
/* Ref and unref the AsyncJitterQueue. */
59
 
AsyncJitterQueue*  async_jitter_queue_ref           (AsyncJitterQueue *queue);
60
 
void          async_jitter_queue_unref              (AsyncJitterQueue *queue);
61
 
#ifndef G_DISABLE_DEPRECATED
62
 
/* You don't have to hold the lock for calling *_ref and *_unref anymore. */
63
 
void          async_jitter_queue_ref_unlocked       (AsyncJitterQueue *queue);
64
 
void          async_jitter_queue_unref_and_unlock   (AsyncJitterQueue *queue);
65
 
#endif /* !G_DISABLE_DEPRECATED */
66
 
 
67
 
void          async_jitter_queue_set_low_threshold  (AsyncJitterQueue *queue,
68
 
                                                gfloat threshold);
69
 
void          async_jitter_queue_set_high_threshold (AsyncJitterQueue *queue,
70
 
                                                gfloat threshold);
71
 
 
72
 
void          async_jitter_queue_set_max_queue_length (AsyncJitterQueue *queue,
73
 
                                                guint32 max_length);
74
 
 
75
 
/* Push data into the async queue. Must not be NULL. */
76
 
void          async_jitter_queue_push               (AsyncJitterQueue *queue,
77
 
                                                gpointer     data);
78
 
void          async_jitter_queue_push_unlocked      (AsyncJitterQueue *queue,
79
 
                                                gpointer     data);
80
 
gboolean      async_jitter_queue_push_sorted        (AsyncJitterQueue *queue,
81
 
                                                gpointer          data,
82
 
                                                GCompareDataFunc  func,
83
 
                                                gpointer          user_data);
84
 
 
85
 
void          async_jitter_queue_insert_after_unlocked(AsyncJitterQueue *queue,
86
 
                                                GList *sibling,
87
 
                                                gpointer data);
88
 
 
89
 
gboolean      async_jitter_queue_push_sorted_unlocked(AsyncJitterQueue *queue,
90
 
                                                gpointer          data,
91
 
                                                GCompareDataFunc  func,
92
 
                                                gpointer          user_data);
93
 
 
94
 
/* Pop data from the async queue. When no data is there, the thread is blocked
95
 
 * until data arrives. */
96
 
gpointer      async_jitter_queue_pop                (AsyncJitterQueue *queue);
97
 
gpointer      async_jitter_queue_pop_unlocked       (AsyncJitterQueue *queue);
98
 
 
99
 
/* Try to pop data. NULL is returned in case of empty queue. */
100
 
gpointer      async_jitter_queue_try_pop            (AsyncJitterQueue *queue);
101
 
gpointer      async_jitter_queue_try_pop_unlocked   (AsyncJitterQueue *queue);
102
 
 
103
 
/* Wait for data until at maximum until end_time is reached. NULL is returned
104
 
 * in case of empty queue. */
105
 
gpointer      async_jitter_queue_timed_pop          (AsyncJitterQueue *queue,
106
 
                                                GTimeVal    *end_time);
107
 
gpointer      async_jitter_queue_timed_pop_unlocked (AsyncJitterQueue *queue,
108
 
                                                GTimeVal    *end_time);
109
 
 
110
 
/* Return the length of the queue. Negative values mean that threads
111
 
 * are waiting, positve values mean that there are entries in the
112
 
 * queue. Actually this function returns the length of the queue minus
113
 
 * the number of waiting threads, async_jitter_queue_length == 0 could also
114
 
 * mean 'n' entries in the queue and 'n' thread waiting. Such can
115
 
 * happen due to locking of the queue or due to scheduling. */
116
 
gint          async_jitter_queue_length             (AsyncJitterQueue *queue);
117
 
gint          async_jitter_queue_length_unlocked    (AsyncJitterQueue *queue);
118
 
 
119
 
void          async_jitter_queue_set_flushing_unlocked   (AsyncJitterQueue* queue, 
120
 
                                                          GFunc free_func, gpointer user_data);
121
 
void          async_jitter_queue_unset_flushing_unlocked (AsyncJitterQueue* queue);
122
 
void          async_jitter_queue_set_blocking_unlocked   (AsyncJitterQueue* queue,
123
 
                                                          gboolean blocking);
124
 
guint32
125
 
async_jitter_queue_length_ts_units_unlocked (AsyncJitterQueue *queue);
126
 
 
127
 
G_END_DECLS
128
 
 
129
 
#endif /* __ASYNCJITTERQUEUE_H__ */
130