annotate src/mediastreamer/mssync.h @ 12099:3960def0f75b

[gaim-migrate @ 14396] A small part of sf patch 1350631, from Sadrul Habib Chowdhury Gray out the "insert image" menu item based on a dumb flag that we shouldn't have that determines whether a particular conversation supports images or not. See my comments on the patch for more info. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 15 Nov 2005 01:23:04 +0000
parents e67993da8a22
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12024
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 The mediastreamer library aims at providing modular media processing and I/O
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 for linphone, but also for any telephony application.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 This library is free software; you can redistribute it and/or
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 modify it under the terms of the GNU Lesser General Public
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 License as published by the Free Software Foundation; either
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 version 2.1 of the License, or (at your option) any later version.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 This library is distributed in the hope that it will be useful,
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 Lesser General Public License for more details.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 You should have received a copy of the GNU Lesser General Public
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 License along with this library; if not, write to the Free Software
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 */
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 #ifndef MS_SYNC_H
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #define MS_SYNC_H
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "msfilter.h"
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 struct _MSSync
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 {
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 struct _MSSyncClass *klass;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 GMutex *lock;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 MSFilter **attached_filters; /* pointer to a table of pointer of filters*/
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 GList *execution_list; /* the list of filters to be executed. This is filled with compilation */
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 gint filters; /*number of filters attached to the sync */
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 gint run; /* flag to indicate whether the sync must be run or not */
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 GThread * thread; /* the thread ressource if this sync is run by a thread*/
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 GCond *thread_cond;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 GCond *stop_cond;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 guint32 flags;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 gint interval; /* in miliseconds*/
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #define MS_SYNC_NEED_UPDATE (0x0001) /* a modification has occured in the processing chains
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 attached to this sync; so the execution list has to be updated */
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 guint samples_per_tick; /* number of bytes produced by sources of the processing chains*/
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 guint32 ticks;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 guint32 time; /* a time since the start of the sync expressed in milisec*/
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 };
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 typedef struct _MSSync MSSync;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 typedef void (*MSSyncDestroyFunc)(MSSync*);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 typedef void (*MSSyncSyncFunc)(MSSync*);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 typedef int (*MSSyncAttachFunc)(MSSync*,MSFilter*);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 typedef int (*MSSyncDetachFunc)(MSSync*,MSFilter*);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 typedef struct _MSSyncClass
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 {
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 gint max_filters; /* the maximum number of filters that can be attached to this sync*/
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 MSSyncSyncFunc synchronize;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 MSSyncDestroyFunc destroy;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 MSSyncAttachFunc attach;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 MSSyncDetachFunc detach;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 } MSSyncClass;
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 /* private */
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 void ms_sync_init(MSSync *sync);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 void ms_sync_class_init(MSSyncClass *klass);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 int ms_sync_attach_generic(MSSync *sync,MSFilter *f);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 int ms_sync_detach_generic(MSSync *sync,MSFilter *f);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 /* public*/
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 #define MS_SYNC(sync) ((MSSync*)(sync))
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 #define MS_SYNC_CLASS(klass) ((MSSyncClass*)(klass))
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 #define ms_sync_synchronize(_sync) \
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 do \
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 { \
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 MSSync *__sync=_sync; \
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 __sync->ticks++; \
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 ((__sync)->klass->synchronize((__sync))); \
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 }while(0)
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 void ms_sync_setup(MSSync *sync);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 void ms_sync_unsetup(MSSync *sync);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 #define ms_sync_update(sync) (sync)->flags|=MS_SYNC_NEED_UPDATE
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 #define ms_sync_get_samples_per_tick(sync) ((sync)->samples_per_tick)
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 void ms_sync_set_samples_per_tick(MSSync *sync,gint size);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 #define ms_sync_get_tick_count(sync) ((sync)->ticks)
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 #define ms_sync_suspend(sync) g_cond_wait((sync)->thread_cond,(sync)->lock)
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 #define ms_sync_lock(sync) g_mutex_lock((sync)->lock)
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 #define ms_sync_unlock(sync) g_mutex_unlock((sync)->lock)
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 #define ms_sync_trylock(sync) g_mutex_trylock((sync)->lock)
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 /**
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 * function_name:ms_sync_attach
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 * @sync: A #MSSync object.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 * @f: A #MSFilter object.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 *
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 * Attach a chain of filters to a synchronisation source. Filter @f must be the first filter of the processing chain.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 *
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 * Returns: 0 if successfull, a negative value reprensenting the errno.h error.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 */
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 int ms_sync_attach(MSSync *sync,MSFilter *f);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 /**
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 * ms_sync_detach:
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 * @sync: A #MSSync object.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 * @f: A #MSFilter object.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 *
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 * Dettach a chain of filters to a synchronisation source. Filter @f must be the first filter of the processing chain.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 * The processing chain will no more be executed.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 *
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 * Returns: 0 if successfull, a negative value reprensenting the errno.h error.
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 */
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 int ms_sync_detach(MSSync *sync,MSFilter *f);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 int ms_sync_uninit(MSSync *sync);
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 #define ms_sync_start(sync) ms_start((sync))
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 #define ms_sync_stop(sync) ms_stop((sync))
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 /*destroy*/
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 #define ms_sync_destroy(sync) (sync)->klass->destroy((sync))
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
e67993da8a22 [gaim-migrate @ 14317]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 #endif