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 "msfdispatcher.h"
|
|
23
|
|
24 static MSFdispatcherClass *ms_fdispatcher_class=NULL;
|
|
25
|
|
26 MSFilter * ms_fdispatcher_new(void)
|
|
27 {
|
|
28 MSFdispatcher *obj;
|
|
29 obj=g_malloc(sizeof(MSFdispatcher));
|
|
30 if (ms_fdispatcher_class==NULL){
|
|
31 ms_fdispatcher_class=g_malloc(sizeof(MSFdispatcherClass));
|
|
32 ms_fdispatcher_class_init(ms_fdispatcher_class);
|
|
33 }
|
|
34 MS_FILTER(obj)->klass=MS_FILTER_CLASS(ms_fdispatcher_class);
|
|
35 ms_fdispatcher_init(obj);
|
|
36 return MS_FILTER(obj);
|
|
37 }
|
|
38
|
|
39
|
|
40 void ms_fdispatcher_init(MSFdispatcher *obj)
|
|
41 {
|
|
42 ms_filter_init(MS_FILTER(obj));
|
|
43 MS_FILTER(obj)->infifos=obj->f_inputs;
|
|
44 MS_FILTER(obj)->outfifos=obj->f_outputs;
|
|
45 MS_FILTER(obj)->r_mingran=MS_FDISPATCHER_DEF_GRAN;
|
|
46 memset(obj->f_inputs,0,sizeof(MSFifo*)*MS_FDISPATCHER_MAX_INPUTS);
|
|
47 memset(obj->f_outputs,0,sizeof(MSFifo*)*MS_FDISPATCHER_MAX_OUTPUTS);
|
|
48 }
|
|
49
|
|
50
|
|
51
|
|
52 void ms_fdispatcher_class_init(MSFdispatcherClass *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,"fdispatcher");
|
|
57 parent_class->max_finputs=MS_FDISPATCHER_MAX_INPUTS;
|
|
58 parent_class->max_foutputs=MS_FDISPATCHER_MAX_OUTPUTS;
|
|
59 parent_class->r_maxgran=MS_FDISPATCHER_DEF_GRAN;
|
|
60 parent_class->w_maxgran=MS_FDISPATCHER_DEF_GRAN;
|
|
61 parent_class->destroy=(MSFilterDestroyFunc)ms_fdispatcher_destroy;
|
|
62 parent_class->process=(MSFilterProcessFunc)ms_fdispatcher_process;
|
|
63 }
|
|
64
|
|
65
|
|
66 void ms_fdispatcher_destroy( MSFdispatcher *obj)
|
|
67 {
|
|
68 g_free(obj);
|
|
69 }
|
|
70
|
|
71 void ms_fdispatcher_process(MSFdispatcher *obj)
|
|
72 {
|
|
73 gint i;
|
|
74 MSFifo *inf=obj->f_inputs[0];
|
|
75
|
|
76
|
|
77 if (inf!=NULL){
|
|
78 void *s,*d;
|
|
79 /* dispatch fifos */
|
|
80 while ( ms_fifo_get_read_ptr(inf,MS_FDISPATCHER_DEF_GRAN,&s) >0 ){
|
|
81 for (i=0;i<MS_FDISPATCHER_MAX_OUTPUTS;i++){
|
|
82 MSFifo *outf=obj->f_outputs[i];
|
|
83
|
|
84 if (outf!=NULL)
|
|
85 {
|
|
86 ms_fifo_get_write_ptr(outf,MS_FDISPATCHER_DEF_GRAN,&d);
|
|
87 if (d!=NULL) memcpy(d,s,MS_FDISPATCHER_DEF_GRAN);
|
|
88 }
|
|
89 }
|
|
90 }
|
|
91 }
|
|
92 }
|
|
93
|
|
94
|