📄 rtpsend.c
字号:
/* The oRTP LinPhone RTP library intends to provide basics for a RTP stack. Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include <ortp/ortp.h>#include <signal.h>#include <stdlib.h>#ifndef _WIN32 #include <sys/types.h>#include <sys/time.h>#include <stdio.h>#endifint runcond=1;void stophandler(int signum){ runcond=0;}static char *help="usage: rtpsend filename dest_ip4addr dest_port [ --with-clockslide value ] [ --with-jitter]\n";int main(int argc, char *argv[]){ RtpSession *session; char buffer[160]; int i; FILE *infile; char *ssrc; guint32 user_ts=0; gint clockslide=0; gint jitter=0; if (argc<4){ printf(help); return -1; } for(i=4;i<argc;i++){ if (strcmp(argv[i],"--with-clockslide")==0){ i++; if (i>=argc) { printf(help); return -1; } clockslide=atoi(argv[i]); g_message("Using clockslide of %i milisecond every 50 packets.",clockslide); }else if (strcmp(argv[i],"--with-jitter")==0){ g_message("Jitter will be added to outgoing stream."); jitter=1; } } ortp_init(); ortp_scheduler_init(); ortp_set_debug_file("oRTP",stdout); session=rtp_session_new(RTP_SESSION_SENDONLY); rtp_session_set_scheduling_mode(session,1); rtp_session_set_blocking_mode(session,1); rtp_session_set_remote_addr(session,argv[2],atoi(argv[3])); rtp_session_set_payload_type(session,0); ssrc=getenv("SSRC"); if (ssrc!=NULL) { printf("using SSRC=%i.\n",atoi(ssrc)); rtp_session_set_ssrc(session,atoi(ssrc)); } #ifndef _WIN32 infile=fopen(argv[1],"r"); #else infile=fopen(argv[1],"rb"); #endif if (infile==NULL) { perror("Cannot open file"); return -1; } signal(SIGINT,stophandler); while( ((i=fread(buffer,1,160,infile))>0) && (runcond) ) { rtp_session_send_with_ts(session,buffer,i,user_ts); user_ts+=160; if (clockslide!=0 && user_ts%(160*50)==0){ g_message("Clock sliding of %i miliseconds now",clockslide); rtp_session_make_time_distorsion(session,clockslide); } if (jitter && (user_ts%(160*6)==0)) usleep(50000); } fclose(infile); rtp_session_destroy(session); ortp_exit(); ortp_global_stats_display(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -