发送WAV(PCMU)的声音文件到VLC播放器,能够听到音乐,但是噪音很大,有没有知道是什么原因的,谢谢,谢谢,谢谢... ...
发送端代码:
#include <stdio.h>
#include <signal.h>
#include <ortp/ortp.h>
#define SIZE 160
#define TIMESTAMP 160
int cond=1;
void stop(int signum)
{
cond=0;
}
int main(int argc,char** argv)
{
RtpSession* session;
int ts=0;
int fd;
int readcount=0;
int sendcount=0;
char buf[SIZE];
ortp_init();
ortp_scheduler_init();
ortp_init();
ortp_scheduler_init();
ortp_set_log_level_mask(ORTP_MESSAGE| \
ORTP_WARNING|ORTP_ERROR);
session=rtp_session_new(RTP_SESSION_SENDONLY);
rtp_session_set_scheduling_mode(session,1);
rtp_session_set_blocking_mode(session,1);
rtp_session_set_connected_mode(session,TRUE);
rtp_session_set_remote_addr(session,argv[2],atoi(argv[3]));
rtp_session_set_payload_type(session,0);
fd=open(argv[1],O_RDONLY);
if(fd==-1)
{
perror("open");
return -1;
}
signal(SIGINT,stop);
while(cond)
{
readcount=read(fd,buf,SIZE);
if(readcount>0)
{
sendcount=rtp_session_send_with_ts(session,buf,readcount,ts);
}
else if(readcount==0)
{
printf("reading complete\n");
break;
}
else if(readcount==-1)
{
perror("read");
return -1;
}
ts+=TIMESTAMP;
}
if(close(fd)==-1)
{
perror("close");
return -1;
}
rtp_session_destroy(session);
ortp_exit();
ortp_global_stats_display();
return 0;
}
VLC的SDP文件:
m=audio 8888 RTP/AVP 0
a=rtpmap:0 pcmu/8000
a=ptime:20
c=IN IP4 192.168.0.36