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 "msrtprecv.h"
|
|
22 #include "ms.h"
|
|
23 #include "mswrite.h"
|
|
24 #include "msosswrite.h"
|
|
25 #include "msMUlawdec.h"
|
|
26 #include "mstimer.h"
|
|
27 #include "msfdispatcher.h"
|
|
28
|
|
29 #include <signal.h>
|
|
30 #include <sys/types.h>
|
|
31 #include <unistd.h>
|
|
32 #include <stdio.h>
|
|
33
|
|
34 static int cond=1;
|
|
35
|
|
36 void stop_handler(int signum)
|
|
37 {
|
|
38 cond=0;
|
|
39 }
|
|
40
|
|
41 int main()
|
|
42 {
|
|
43 MSFilter *play,*dec,*rec,*filerec,*dis;
|
|
44 MSSync *timer;
|
|
45 RtpSession *rtps;
|
|
46
|
|
47 /*create the rtp session */
|
|
48 ortp_init();
|
|
49 ortp_set_debug_file("oRTP",NULL);
|
|
50 rtps=rtp_session_new(RTP_SESSION_RECVONLY);
|
|
51 rtp_session_set_local_addr(rtps,"0.0.0.0",8000);
|
|
52 rtp_session_set_scheduling_mode(rtps,0);
|
|
53 rtp_session_set_blocking_mode(rtps,0);
|
|
54
|
|
55 ms_init();
|
|
56 signal(SIGINT,stop_handler);
|
|
57
|
|
58 play=ms_rtp_recv_new();
|
|
59 rec=ms_oss_write_new();
|
|
60 ms_sound_write_set_device(MS_SOUND_WRITE(rec),0);
|
|
61 dec=ms_MULAWdecoder_new();
|
|
62 filerec=ms_write_new("/tmp/rtpstream");
|
|
63 dis=ms_fdispatcher_new();
|
|
64 timer=ms_timer_new();
|
|
65
|
|
66 ms_rtp_recv_set_session(MS_RTP_RECV(play),rtps);
|
|
67
|
|
68 ms_filter_add_link(play,dec);
|
|
69 ms_filter_add_link(dec,dis);
|
|
70 ms_filter_add_link(dis,rec);
|
|
71 ms_filter_add_link(dis,filerec);
|
|
72 ms_sync_attach(timer,play);
|
|
73 printf("gran=%i\n",MS_SYNC(timer)->samples_per_tick);
|
|
74
|
|
75 ms_start(timer);
|
|
76 ms_sound_write_start(MS_SOUND_WRITE(rec));
|
|
77 while(cond)
|
|
78 {
|
|
79 sleep(1);
|
|
80 }
|
|
81
|
|
82 printf("stoping sync...\n");
|
|
83 ms_stop(timer);
|
|
84 ms_sound_write_stop(MS_SOUND_WRITE(rec));
|
|
85 printf("unlinking filters...\n");
|
|
86 ms_filter_remove_links(play,dec);
|
|
87 ms_filter_remove_links(dec,rec);
|
|
88 printf("destroying filters...\n");
|
|
89 ms_filter_destroy(play);
|
|
90 ms_filter_destroy(dec);
|
|
91 ms_filter_destroy(rec);
|
|
92 ms_filter_destroy(dis);
|
|
93 ms_filter_destroy(filerec);
|
|
94
|
|
95 rtp_session_destroy(rtps);
|
|
96 ms_sync_destroy(timer);
|
|
97 ortp_global_stats_display();
|
|
98
|
|
99 return 0;
|
|
100 }
|