~ubuntu-branches/ubuntu/quantal/linphone/quantal

« back to all changes in this revision

Viewing changes to oRTP/src/tests/tevrtpsend.c

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2006-11-15 10:34:50 UTC
  • mfrom: (1.2.1 upstream) (2.1.8 feisty)
  • Revision ID: james.westby@ubuntu.com-20061115103450-qgafwcks2lkhctlj
* New upstream release.
* Enable video support.
* Fix mismatched #endif in mscommon.h, closes: #398307.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  The oRTP LinPhone RTP library intends to provide basics for a RTP stack.
 
3
  Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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
 
18
*/
 
19
 
 
20
#include <ortp/ortp.h>
 
21
#include <ortp/telephonyevents.h>
 
22
#include <signal.h>
 
23
#include <stdlib.h>
 
24
#include <sys/types.h>
 
25
#ifndef _WIN32
 
26
#include <sys/time.h>
 
27
#else
 
28
#include <time.h>
 
29
#endif
 
30
#include <stdio.h>
 
31
 
 
32
int runcond=1;
 
33
 
 
34
void stophandler(int signum)
 
35
{
 
36
        runcond=0;
 
37
}
 
38
 
 
39
static char *help="usage: test_tevsend  filename dest_ip4addr dest_port\n";
 
40
 
 
41
int main(int argc, char *argv[])
 
42
{
 
43
        RtpSession *session;
 
44
        unsigned char buffer[160];
 
45
        int i;
 
46
        FILE *infile;
 
47
        char *ssrc;
 
48
        uint32_t user_ts=0;
 
49
        int tel=0;
 
50
        
 
51
        if (argc<4){
 
52
                printf(help);
 
53
                return -1;
 
54
        }
 
55
        
 
56
        ortp_init();
 
57
        ortp_scheduler_init();
 
58
        
 
59
        /* set the telephony event payload type to 96 in the av profile.*/
 
60
        rtp_profile_set_payload(&av_profile,96,&payload_type_telephone_event);
 
61
        
 
62
        session=rtp_session_new(RTP_SESSION_SENDONLY);
 
63
        
 
64
        rtp_session_set_scheduling_mode(session,1);
 
65
        rtp_session_set_blocking_mode(session,1);
 
66
        rtp_session_set_remote_addr(session,argv[2],atoi(argv[3]));
 
67
        rtp_session_set_send_payload_type(session,0);
 
68
        
 
69
        ssrc=getenv("SSRC");
 
70
        if (ssrc!=NULL) {
 
71
                printf("using SSRC=%i.\n",atoi(ssrc));
 
72
                rtp_session_set_ssrc(session,atoi(ssrc));
 
73
        }
 
74
                
 
75
        infile=fopen(argv[1],"rb");
 
76
        if (infile==NULL) {
 
77
                perror("Cannot open file");
 
78
                return -1;
 
79
        }
 
80
        signal(SIGINT,stophandler);
 
81
        while( ((i=fread(buffer,1,160,infile))>0) && (runcond) )
 
82
        {
 
83
                //ortp_message("Sending packet.");
 
84
                rtp_session_send_with_ts(session,buffer,i,user_ts);
 
85
                user_ts+=160;
 
86
                tel++;
 
87
                if (tel==50){
 
88
                        tel=0;
 
89
                        ortp_message("Sending telephony event packet.");
 
90
                        rtp_session_send_dtmf(session,'*',user_ts);
 
91
                        user_ts+=160+160+160; /* the duration of the dtmf */
 
92
                }
 
93
        }
 
94
        fclose(infile);
 
95
        rtp_session_destroy(session);
 
96
        ortp_exit();
 
97
        ortp_global_stats_display();
 
98
        return 0;
 
99
}