⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 musicout.c.patch

📁 linux环境下用纯c写的RTP协议的通用开发库
💻 PATCH
📖 第 1 页 / 共 2 页
字号:
5c5<  * $Id: musicout.c.patch,v 1.2 2000/06/29 23:02:54 evangemh Exp $--->  * $Id: musicout.c.patch,v 1.2 2000/06/29 23:02:54 evangemh Exp $7d6<  * $Log: musicout.c.patch,v $<  * Revision 1.2  2000/06/29 23:02:54  evangemh<  * .<  *92a92,118> #include <sys/types.h>> #include <sys/stat.h>> #include <fcntl.h>> > #ifdef SOLARIS> #include <sys/audioio.h>> #endif> #ifdef LINUX> #include <linux/soundcard.h>> #endif> > #include <rtp.h>> #include <netinet/in.h>> #include <event.h>> #include <syn.h>> #include <payload.h>> #include <frame.h>> > /* >  * Upcall functions needed by RTP library>  * to extract MPEG audio frames.>  */> extern void out_audio();> extern bool aligned(struct rtp *, int);> extern int dataoffset(struct rtp *, int);> extern mediatime_t frameduration(char *, int);> extern int framelength(char *, int);110,111d135< static void GetArguments();<   124a149,151> /* to implement rebuffering and resetting player on signal for testing */> extern long totbit, offset,buf_bit_idx,buf_byte_idx;> 127,132c154,155< main(argc, argv)< int argc;< char **argv;< {< /*typedef short PCM[2][3][SBLIMIT];*/< typedef short PCM[2][SSLIMIT][SBLIMIT];---> int plaympeg(struct synsession *pssn, ssrc_t ssrc, int audiodev) {>   typedef short PCM[2][SSLIMIT][SBLIMIT];134c157< typedef unsigned int SAM[2][3][SBLIMIT];--->   typedef unsigned int SAM[2][3][SBLIMIT];136c159< typedef double FRA[2][3][SBLIMIT];--->   typedef double FRA[2][3][SBLIMIT];138c161< typedef double VE[2][HAN_SIZE];--->   typedef double VE[2][HAN_SIZE];155d177<     Arguments_t       Arguments;158,159c180,181< III_scalefac_t III_scalefac;< III_side_info_t III_side_info;--->   III_scalefac_t III_scalefac;>   III_side_info_t III_side_info;161,163c183,184< #ifdef  MACINTOSH<     console_options.nrows = MAC_WINDOW_SIZE;<     argc = ccommand(&argv);---> #ifdef SOLARIS>   audio_info_t		audio_info;164a186,191>   struct timespec	now,packtime;>   mediatime_t		ts;>   struct framereadparam	freadparam;>   int			 rv, tmp;>   unsigned int span;>   layer *rtp_info;179,183c206,220<     Arguments.topSb = 0;<     GetArguments(argc, argv, &Arguments);<     if ((musicout = fopen(Arguments.decoded_file_name, "w+b")) == NULL) {<           printf ("Could not create \"%s\".\n", Arguments.decoded_file_name);<           exit(1);--->   /* get up the bitstream */>   bzero((char *) &freadparam, sizeof(struct framereadparam));>   bzero((char *) &bs, sizeof(bs));>   bs.buf = (char *) malloc(2048);>   bs.format = BINARY;>   bs.mode = READ_MODE;>   bs.eob = FALSE;>   bs.eobs = FALSE;> >   sample_frames = 0;> >   while (TRUE) {>     synctl(pssn, SYN_CTL_STREAM_GETBUFSPAN, (char *) &span, ssrc);>     if (span == 0) {>       synrebuffer(pssn, ssrc);185d221<     open_bit_stream_r(&bs, Arguments.encoded_file_name, BUFFER_SIZE);187,191c223,231<     if (Arguments.need_aiff)<        if (aiff_seek_to_sound_data(musicout) == -1) {<           printf("Could not seek to PCM sound data in \"%s\".\n",<                  Arguments.decoded_file_name);<           exit(1);--->     /*>      * Read a frame.>      */>     rv = synread(pssn, ssrc, &packtime, &ts, bs.buf, 2048, &freadparam);> > #ifdef LINUX>     clock_gettime(CLOCK_REALTIME, &now);>     if (timecmp(now, packtime) < 0) {>       ioctl(audiodev, SNDCTL_DSP_SYNC);192a233> #endif194c235,236<     sample_frames = 0;--->     if (rv < 0)>       break;196c238,242<     while (!end_bs(&bs)) {--->     bs.buf_size = rv;>     bs.buf_byte_idx = 0;>     bs.buf_bit_idx = 8;>     bs.eob = FALSE;>     bs.eobs = FALSE;200,203d245<        if(frameNum > 0)        /* don't want to print on 1st loop; no lay */<           if(frameBits%bitsPerSlot)<              fprintf(stderr,"Got %ld bits = %ld slots plus %ld\n",<                      frameBits, frameBits/bitsPerSlot, frameBits%bitsPerSlot);210,214d251<           /* finally write out the buffer */<           if (info.lay != 1) out_fifo(*pcm_sample, 3, &fr_ps, done,<                                       musicout, &sample_frames);<           else               out_fifo(*pcm_sample, 1, &fr_ps, done,<                                       musicout, &sample_frames);232d268<        if(frameNum == 0) WriteHdr(&fr_ps, stdout);  /* printout layer/mode */234,239c270,293< #ifdef ESPS< if (frameNum == 0 && Arguments.need_esps) {< 	esps_write_header(musicout,(long) sample_frames, (double)< 		s_freq[info.version][info.sampling_frequency] * 1000,< 		(int) stereo, Arguments.decoded_file_name );< } /* MI */--->     if(frameNum == 0) {> >       rtp_info = fr_ps.header;> 	 >       /*>        * Set the audiodevice's clock rate; >        * all other parameters should already be set.>        */> > #ifdef SOLARIS	   >       if (ioctl(audiodev, AUDIO_GETINFO, &audio_info) < 0) {> 	perror("ioctl1");> 	exit(1);>       }> 	   >       audio_info.play.sample_rate = (int) (s_freq[rtp_info->version][rtp_info->sampling_frequency] * 1000);>       audio_info.play.channels = fr_ps.stereo;>       audio_info.play.precision = 16;>       audio_info.play.encoding = AUDIO_ENCODING_LINEAR;> 	   >       if (ioctl(audiodev, AUDIO_SETINFO, &audio_info) < 0) {> 	perror("ioctl2");> 	exit(1);>       }240a295,333> #ifdef LINUX>       if (ioctl(audiodev, SNDCTL_DSP_RESET) < 0) {> 	perror("ioctl DSP_RESET");> 	exit(1);>       }> 	   >       tmp = APF_NETWORK;>       if (ioctl(audiodev, SNDCTL_DSP_PROFILE, &tmp) < 0) {	> 	perror("ioctl DSP_PROFILE");> 	exit(1);>       }> >       if (ioctl(audiodev, SNDCTL_DSP_SYNC) < 0) {	> 	perror("ioctl DSP_SAMPLESZ");> 	exit(1);>       }> 	   >       tmp = AFMT_S16_LE;	   >       if (ioctl(audiodev, SNDCTL_DSP_SETFMT, &tmp) < 0) {> 	perror("ioctl DSP_SETFMT");> 	exit(1);>       }> >       tmp = (int) (s_freq[rtp_info->version][rtp_info->sampling_frequency] * 1000);>       if(ioctl(audiodev, SNDCTL_DSP_SPEED, &tmp) < 0) {> 	printf("ioctl SNDCTL_DSP_SPEED");> 	exit(1);>       }> >       tmp = fr_ps.stereo;>       if (ioctl(audiodev, SNDCTL_DSP_CHANNELS, &tmp) < 0) {> 	printf("ioctl SNDCLT_DSP_CHANNELS");> 	exit(1);>       }> #endif>       printf("Audio device reconfigured.\n");>     }> >     frameNum++;242d334<        fprintf(stderr, "{%4lu}", frameNum++); fflush(stderr); 270,274d361<                 if(Arguments.topSb>0)        /* clear channels to 0 */<                    for(j=Arguments.topSb; j<fr_ps.sblimit; ++j)<                       for(k=0; k<stereo; ++k)<                          (*fraction)[k][0][j] = 0;< 279,280c366<                 out_fifo(*pcm_sample, 1, &fr_ps, done,<                          musicout, &sample_frames);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -