2 The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) 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>
25 #include <sys/types.h>
29 /*defined in library, but not declared in public headers (this method is only useful for tests)*/
30 extern int __rtp_session_sendm_with_ts(RtpSession *session, mblk_t *packet, uint32_t packet_ts, uint32_t send_ts);
34 void stophandler(int signum)
39 static char *help="usage: rtpsend filename dest_ip4addr dest_port [ --with-clockslide <value> ] [ --with-ptime <milliseconds>]\n";
41 int main(int argc, char *argv[])
44 unsigned char buffer[160];
48 uint32_t packet_ts=0,send_ts=0;
49 uint32_t send_ts_inc=160;
57 if (strcmp(argv[i],"--with-clockslide")==0){
63 clockslide=atoi(argv[i]);
64 ortp_message("Using clockslide of %i milisecond every 50 packets.",clockslide);
65 }else if (strcmp(argv[i],"--with-ptime")==0){
66 ortp_message("Ptime related jitter will be added to outgoing stream.");
78 ortp_scheduler_init();
79 ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
80 session=rtp_session_new(RTP_SESSION_SENDONLY);
82 rtp_session_set_scheduling_mode(session,1);
83 rtp_session_set_blocking_mode(session,1);
84 rtp_session_set_connected_mode(session,TRUE);
85 rtp_session_set_remote_addr(session,argv[2],atoi(argv[3]));
86 rtp_session_set_payload_type(session,0);
90 printf("using SSRC=%i.\n",atoi(ssrc));
91 rtp_session_set_ssrc(session,atoi(ssrc));
95 infile=fopen(argv[1],"r");
97 infile=fopen(argv[1],"rb");
101 perror("Cannot open file");
105 signal(SIGINT,stophandler);
106 while( ((i=fread(buffer,1,160,infile))>0) && (runcond) )
108 mblk_t *m=rtp_session_create_packet(session,RTP_FIXED_HEADER_SIZE,buffer,i);
109 __rtp_session_sendm_with_ts(session,m,packet_ts,send_ts);
111 if ((send_ts+send_ts_inc)<=packet_ts){
112 send_ts+=send_ts_inc;
114 if (clockslide!=0 && send_ts%(160*50)==0){
115 ortp_message("Clock sliding of %i miliseconds now",clockslide);
116 rtp_session_make_time_distorsion(session,clockslide);
121 rtp_session_destroy(session);
123 ortp_global_stats_display();