/* The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) 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 #include #include #ifndef _WIN32 #include #include #include #endif int cond=1; void stop_handler(int signum) { cond=0; } void ssrc_cb(RtpSession *session) { printf("hey, the ssrc has changed !\n"); } static char *help="usage: rtprecv filename loc_port [--format format] [--soundcard] [--noadapt] [--with-jitter ]\n"; #define MULAW 0 #define ALAW 1 #if defined(__hpux) && HAVE_SYS_AUDIO_H #include int sound_init(int format) { int fd; fd=open("/dev/audio",O_WRONLY); if (fd<0){ perror("Can't open /dev/audio"); return -1; } ioctl(fd,AUDIO_RESET,0); ioctl(fd,AUDIO_SET_SAMPLE_RATE,8000); ioctl(fd,AUDIO_SET_CHANNELS,1); if (format==MULAW) ioctl(fd,AUDIO_SET_DATA_FORMAT,AUDIO_FORMAT_ULAW); else ioctl(fd,AUDIO_SET_DATA_FORMAT,AUDIO_FORMAT_ALAW); return fd; } #else int sound_init(int format) { return -1; } #endif int main(int argc, char*argv[]) { RtpSession *session; unsigned char buffer[160]; int err; uint32_t ts=0; int stream_received=0; FILE *outfile; int local_port; int have_more; int i; int format=0; int soundcard=0; int sound_fd=0; int jittcomp=40; bool_t adapt=TRUE; /* init the lib */ if (argc<3){ printf("%s",help); return -1; } local_port=atoi(argv[2]); if (local_port<=0) { printf("%s",help); return -1; } for (i=3;i0) stream_received=1; /* this is to avoid to write to disk some silence before the first RTP packet is returned*/ if ((stream_received) && (err>0)) { size_t ret = fwrite(buffer,1,err,outfile); if (sound_fd>0){ ret = write(sound_fd,buffer,err); if (ret==-1){ fprintf(stderr,"write to sound card failed (%s)",strerror(errno)); } } } } ts+=160; //ortp_message("Receiving packet."); } rtp_session_destroy(session); ortp_exit(); ortp_global_stats_display(); return 0; }