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
/* this program shows how to send streams in paralel using the SessionSet api
21
and two threads only. */
23
#include <ortp/ortp.h>
29
#include <sys/types.h>
36
void stophandler(int signum)
41
static char *help="usage: mrtpsend filename ip port nstreams [--packet-size size] [--ts-inc value]\n";
43
#define STREAMS_COUNT 1000
47
int main(int argc, char *argv[])
49
RtpSession *session[STREAMS_COUNT];
50
unsigned char *buffer;
66
channels=atoi(argv[4]);
72
/* look at command line options */
75
if (strcmp(argv[i],"--packet-size")==0)
78
packet_size=atoi(argv[i+1]);
85
printf("Packet size can't be %s.\n",argv[i+1]);
91
else if (strcmp(argv[i],"--ts-inc")==0)
94
ts_inc=atoi(argv[i+1]);
101
printf("Timestanp increment can't be %s.\n",argv[i+1]);
108
printf("Timestamp increment will be %i\n",ts_inc);
109
printf("Packet size will be %i\n",packet_size);
110
buffer=ortp_malloc(packet_size);
112
ortp_scheduler_init();
113
printf("scheduler initialized\n");
116
for (i=0;i<channels;i++){
117
printf("channel %d\n", i);
118
session[i]=rtp_session_new(RTP_SESSION_SENDONLY);
119
rtp_session_set_scheduling_mode(session[i],1);
120
rtp_session_set_blocking_mode(session[i],0);
121
rtp_session_set_remote_addr(session[i],argv[2],port);
122
rtp_session_set_payload_type(session[i],0);
123
if (ssrc!=NULL) rtp_session_set_ssrc(session[i],atoi(ssrc));
128
infile=fopen(argv[1],"r");
130
infile=fopen(argv[1],"rb");
133
perror("Cannot open file");
136
printf("open file\n");
137
signal(SIGINT,stophandler);
139
set=session_set_new();
140
while( ((i=fread(buffer,1,packet_size,infile))>0) && (runcond) )
143
//ortp_message("Sending packet.");
144
for (k=0;k<channels;k++){
145
/* add the session to the set */
146
session_set_set(set,session[k]);
148
/* and then suspend the process by selecting() */
149
session_set_select(NULL,set,NULL);
150
for (k=0;k<channels;k++){
151
/* this is stupid to do this test, because all session work the same way,
152
as the same user_ts is used for all sessions, here. */
153
if (session_set_is_set(set,session[k])){
154
rtp_session_send_with_ts(session[k],buffer,i,user_ts);
155
//ortp_message("packet sended !");
161
printf("close file\n");
162
/*sleep a little to wait last packets to be sent */
168
for (i=0;i<channels;i++)
169
rtp_session_destroy(session[i]);
170
session_set_destroy(set);
173
ortp_global_stats_display();