12024
|
1 /*
|
|
2 The mediastreamer library aims at providing modular media processing and I/O
|
|
3 for linphone, but also for any telephony application.
|
|
4 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
|
|
5
|
|
6 This library is free software; you can redistribute it and/or
|
|
7 modify it under the terms of the GNU Lesser General Public
|
|
8 License as published by the Free Software Foundation; either
|
|
9 version 2.1 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 Lesser General Public License for more details.
|
|
15
|
|
16 You should have received a dispatcher of the GNU Lesser General Public
|
|
17 License along with this library; if not, write to the Free Software
|
|
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 */
|
|
20
|
|
21
|
|
22 #include "msqdispatcher.h"
|
|
23
|
|
24 static MSQdispatcherClass *ms_qdispatcher_class=NULL;
|
|
25
|
|
26 MSFilter * ms_qdispatcher_new(void)
|
|
27 {
|
|
28 MSQdispatcher *obj;
|
|
29 obj=g_malloc(sizeof(MSQdispatcher));
|
|
30 if (ms_qdispatcher_class==NULL){
|
|
31 ms_qdispatcher_class=g_malloc0(sizeof(MSQdispatcherClass));
|
|
32 ms_qdispatcher_class_init(ms_qdispatcher_class);
|
|
33 }
|
|
34 MS_FILTER(obj)->klass=MS_FILTER_CLASS(ms_qdispatcher_class);
|
|
35 ms_qdispatcher_init(obj);
|
|
36 return MS_FILTER(obj);
|
|
37 }
|
|
38
|
|
39
|
|
40 void ms_qdispatcher_init(MSQdispatcher *obj)
|
|
41 {
|
|
42 ms_filter_init(MS_FILTER(obj));
|
|
43
|
|
44 MS_FILTER(obj)->inqueues=obj->q_inputs;
|
|
45 MS_FILTER(obj)->outqueues=obj->q_outputs;
|
|
46 memset(obj->q_inputs,0,sizeof(MSQueue*)*MS_QDISPATCHER_MAX_INPUTS);
|
|
47 memset(obj->q_outputs,0,sizeof(MSQueue*)*MS_QDISPATCHER_MAX_OUTPUTS);
|
|
48 }
|
|
49
|
|
50
|
|
51
|
|
52 void ms_qdispatcher_class_init(MSQdispatcherClass *klass)
|
|
53 {
|
|
54 MSFilterClass *parent_class=MS_FILTER_CLASS(klass);
|
|
55 ms_filter_class_init(parent_class);
|
|
56 ms_filter_class_set_name(parent_class,"qdispatcher");
|
|
57 parent_class->max_qinputs=MS_QDISPATCHER_MAX_INPUTS;
|
|
58 parent_class->max_qoutputs=MS_QDISPATCHER_MAX_OUTPUTS;
|
|
59
|
|
60 parent_class->destroy=(MSFilterDestroyFunc)ms_qdispatcher_destroy;
|
|
61 parent_class->process=(MSFilterProcessFunc)ms_qdispatcher_process;
|
|
62 }
|
|
63
|
|
64
|
|
65 void ms_qdispatcher_destroy( MSQdispatcher *obj)
|
|
66 {
|
|
67 g_free(obj);
|
|
68 }
|
|
69
|
|
70 void ms_qdispatcher_process(MSQdispatcher *obj)
|
|
71 {
|
|
72 gint i;
|
|
73 MSQueue *inq=obj->q_inputs[0];
|
|
74
|
|
75 if (inq!=NULL){
|
|
76 MSQueue *outq;
|
|
77 MSMessage *m1,*m2;
|
|
78 while ( (m1=ms_queue_get(inq))!=NULL){
|
|
79 /* dispatch incoming messages to output queues */
|
|
80 for (i=0;i<MS_QDISPATCHER_MAX_OUTPUTS;i++){
|
|
81 outq=obj->q_outputs[i];
|
|
82 if (outq!=NULL){
|
|
83 m2=ms_message_dup(m1);
|
|
84 ms_queue_put(outq,m2);
|
|
85 }
|
|
86 }
|
|
87 ms_message_destroy(m1);
|
|
88 }
|
|
89 }
|
|
90
|
|
91 }
|