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 copy 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 #include "ms.h"
|
|
22
|
|
23 #include "msosswrite.h"
|
|
24 #include "msossread.h"
|
|
25 #include "mscopy.h"
|
|
26 #include "msnosync.h"
|
|
27 #include "mstimer.h"
|
|
28 #include "msMUlawdec.h"
|
|
29 #include "msMUlawenc.h"
|
|
30
|
|
31 #include <signal.h>
|
|
32 #include <sys/types.h>
|
|
33 #include <unistd.h>
|
|
34 #include <stdio.h>
|
|
35
|
|
36 static int cond=1;
|
|
37
|
|
38 void stop_handler(int signum)
|
|
39 {
|
|
40 cond=0;
|
|
41 }
|
|
42
|
|
43 int main()
|
|
44 {
|
|
45 MSFilter *play,*enc,*dec,*rec;
|
|
46 MSSync *timer;
|
|
47
|
|
48 ms_init();
|
|
49 signal(SIGINT,stop_handler);
|
|
50
|
|
51 play=ms_oss_read_new();
|
|
52 rec=ms_oss_write_new();
|
|
53 ms_sound_read_set_device(MS_SOUND_READ(play),0);
|
|
54 ms_sound_write_set_device(MS_SOUND_WRITE(rec),0);
|
|
55
|
|
56 enc=ms_MULAWencoder_new();
|
|
57 dec=ms_MULAWdecoder_new();
|
|
58 timer=ms_timer_new();
|
|
59
|
|
60 ms_filter_add_link(play,enc);
|
|
61 ms_filter_add_link(enc,dec);
|
|
62 ms_filter_add_link(dec,rec);
|
|
63 ms_sync_attach(timer,play);
|
|
64
|
|
65 ms_start(timer);
|
|
66 ms_sound_read_start(MS_SOUND_READ(play));
|
|
67 ms_sound_write_start(MS_SOUND_WRITE(rec));
|
|
68 while(cond)
|
|
69 {
|
|
70 sleep(1);
|
|
71 }
|
|
72 ms_sound_read_stop(MS_SOUND_READ(play));
|
|
73 ms_sound_write_stop(MS_SOUND_WRITE(rec));
|
|
74 printf("stoping sync...\n");
|
|
75 ms_stop(timer);
|
|
76 printf("unlinking filters...\n");
|
|
77 ms_filter_remove_links(play,enc);
|
|
78 ms_filter_remove_links(enc,dec);
|
|
79 ms_filter_remove_links(dec,rec);
|
|
80 printf("destroying filters...\n");
|
|
81 ms_filter_destroy(play);
|
|
82 ms_filter_destroy(enc);
|
|
83 ms_filter_destroy(dec);
|
|
84 ms_filter_destroy(rec);
|
|
85 ms_sync_destroy(timer);
|
|
86 return 0;
|
|
87 }
|