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. */
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];
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=g_malloc(packet_size);
112
ortp_scheduler_init();
113
printf("scheduler initialized\n");
114
ortp_set_debug_file("oRTP",stdout);
117
for (i=0;i<channels;i++){
118
printf("channel %d\n", i);
119
session[i]=rtp_session_new(RTP_SESSION_SENDONLY);
120
rtp_session_set_scheduling_mode(session[i],1);
121
rtp_session_set_blocking_mode(session[i],0);
122
rtp_session_set_remote_addr(session[i],argv[2],port);
123
rtp_session_set_payload_type(session[i],0);
124
if (ssrc!=NULL) rtp_session_set_ssrc(session[i],atoi(ssrc));
129
infile=fopen(argv[1],"r");
131
infile=fopen(argv[1],"rb");
134
perror("Cannot open file");
137
printf("open file\n");
138
signal(SIGINT,stophandler);
140
set=session_set_new();
141
printf("session set\n");
142
while( ((i=fread(buffer,1,packet_size,infile))>0) && (runcond) )
145
//g_message("Sending packet.");
146
for (k=0;k<channels;k++){
147
/* add the session to the set */
148
session_set_set(set,session[k]);
149
printf("session set set %d\n", k);
151
/* and then suspend the process by selecting() */
152
session_set_select(NULL,set,NULL);
153
printf("session set select\n");
154
for (k=0;k<channels;k++){
156
/* this is stupid to do this test, because all session work the same way,
157
as the same user_ts is used for all sessions, here. */
158
if (session_set_is_set(set,session[k])){
159
printf("session set is set %d\n", k);
160
rtp_session_send_with_ts(session[k],buffer,i,user_ts);
161
//g_message("packet sended !");
167
printf("close file\n");
168
/*sleep a little to wait last packets to be sent */
174
for (i=0;i<channels;i++)
175
rtp_session_destroy(session[i]);
176
session_set_destroy(set);
179
ortp_global_stats_display();