2 The oRTP LinPhone RTP library intends to provide basics for a RTP stack.
3 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <ortp/ortp.h>
21 #include <ortp/telephonyevents.h>
25 #include <sys/types.h>
35 static int dtmf_tab[16]={'0','1','2','3','4','5','6','7','8','9','*','#','A','B','C','D'};
37 void stophandler(int signum)
42 static char *help="usage: test_tevrecv filename loc_port\n";
46 void recv_tev_cb(RtpSession *session,int type,long user_data)
48 printf("Receiving telephony event:%i\n",type);
49 if (type<16) printf("This is dtmf %c\n",dtmf_tab[type]);
53 int main(int argc, char *argv[])
56 unsigned char buffer[160];
68 ortp_scheduler_init();
70 /* set the telephony event payload type to 96 in the av profile.*/
71 rtp_profile_set_payload(&av_profile,96,&payload_type_telephone_event);
73 session=rtp_session_new(RTP_SESSION_RECVONLY);
75 rtp_session_set_scheduling_mode(session,1);
76 rtp_session_set_blocking_mode(session,1);
77 rtp_session_set_local_addr(session,"0.0.0.0",atoi(argv[2]));
78 rtp_session_set_payload_type(session,0);
80 /* register for telephony events */
81 rtp_session_signal_connect(session,"telephone-event",(RtpCallback)recv_tev_cb,0);
83 outfile=fopen(argv[1],"wb");
85 perror("Cannot open file");
88 signal(SIGINT,stophandler);
93 err=rtp_session_recv_with_ts(session,buffer,160,ts,&have_more);
95 size_t ret = fwrite(buffer,1,err,outfile);
100 //ortp_message("Receiving packet.");
103 rtp_session_destroy(session);
105 ortp_global_stats_display();
106 printf("Total dtmf events received: %i\n",dtmf_count);