資源簡介
linux 語音實時 RTP 語音編碼

代碼片段和文件信息
/*?comm.h?-?Communication?input/output?modules
?*
?*?This?program?is?free?software;?you?can?redistribute?it?and/or?modify?it
?*?under?the?terms?of?the?GNU?General?Public?License?as?published?by?the?Free
?*?Software?Foundation;?either?version?2?of?the?License?or?(at?your?option)
?*?any?later?version.
?*
?*?This?program?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?General?Public?License?for?more
?*?details?(available?in?COPYING).
?*/
#include?
#include?
extern?rtp_t?rtp;
extern?int?open_soundcard?(int?oflag);
void?*mod_cin?(void?*ptr)
{
??int?rtpfd;????????????????????/*?RTP?socket?file?descriptor?*/
??int?rtcpfd;???????????????????/*?RTCP?socket?file?descriptor?*/
??int?addr_len;?????????????????/*?Data?size?Bytes?received?*/
??struct?sockaddr_in?rtps;??????/*?RTP?socket?*/
??struct?sockaddr_in?rtcps;?????/*?RTCP?socket?*/
??struct?sockaddr_in?remote;????/*?Remote?address?information?*/
??vstr_t?recv_data;?????????????/*?Received?data?*/
??rtp_packet_t?*packet;?????????/*?Parsed?RTP?packet?*/
??fd_set?readset;
??int?fdmax;
??fprintf(stderr?“+?Communication?input?module?loaded.\n“);
??vstr_init?(&recv_data?RTP_MTU_SIZE);
??if?((rtpfd?=?socket(AF_INET?SOCK_DGRAM?0))?0)?{
????perror(“Error?opening?socket“);
????exit(1);
??}
??if?((rtcpfd?=?socket(AF_INET?SOCK_DGRAM?0))?0)?{
????perror(“Error?opening?socket“);
????exit(1);
??}
??rtps.sin_family?=?AF_INET; /*?Internet?protocol?*/
??rtps.sin_port?=?htons(RTP_PORT); /*?Port?*/
??rtps.sin_addr.s_addr?=?htonl(INADDR_ANY); /*?rtps?address?*/
??memset(&(rtps.sin_zero)?‘\0‘?8); /*?Zero?the?rest?*/
??if?(bind(rtpfd?(struct?sockaddr?*)?&rtps?sizeof(struct?sockaddr))?0)?{
????perror(“Error?binding?socket“);
????exit(1);
??}
??rtcps.sin_family?=?AF_INET; /*?Internet?protocol?*/
??rtcps.sin_port?=?htons(RTCP_PORT); /*?Port?*/
??rtcps.sin_addr.s_addr?=?htonl(INADDR_ANY); /*?rtcps?address?*/
??memset(&(rtcps.sin_zero)?‘\0‘?8); /*?Zero?the?rest?*/
??if?(bind(rtcpfd?(struct?sockaddr?*)?&rtcps?sizeof(struct?sockaddr))?0)?{
????perror(“Error?binding?socket“);
????exit(1);
??}
??fprintf(stderr?“+?RTP?Listening?at?%s:%d...\n“
????????inet_ntoa(rtps.sin_addr)?ntohs(rtps.sin_port));
??fprintf(stderr?“+?RTCP?Listening?at?%s:%d...\n“
????????inet_ntoa(rtcps.sin_addr)?ntohs(rtcps.sin_port));
??addr_len?=?sizeof(struct?sockaddr);
??while(1)
??{
????FD_ZERO?(&readset);
????FD_SET?(rtpfd?&readset);
????FD_SET?(rtcpfd?&readset);
????fdmax?=?(rtpfd?
????select?(fdmax?+?1?&readset?NULL?NULL?NULL);
????if?(FD_ISSET(rtpfd?&readset))?{
??????/*?Receive?data?from?network?*/
??????recv_data.size?=?recvfrom?(rtpfd?recv_data.data?RTP_MTU_SIZE?0?&remote?&addr_len);
??????vstr_adv_tail?(&recv_data?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-04-01?13:18??voice_comm\
?????文件?????????404??2001-07-05?18:07??voice_comm\AUTHORS
?????文件???????17992??2001-07-05?18:07??voice_comm\COPYING
?????文件??????????91??2001-07-05?18:07??voice_comm\ChangeLog
?????文件????????7831??2001-07-05?18:07??voice_comm\INSTALL
?????文件???????11007??2012-04-11?21:34??voice_comm\Makefile
?????文件??????????14??2001-07-05?18:07??voice_comm\Makefile.am
?????文件???????10852??2001-11-20?16:47??voice_comm\Makefile.in
?????文件??????????54??2001-07-05?18:07??voice_comm\NEWS
?????文件?????????325??2001-07-05?18:07??voice_comm\README
?????文件???????17956??2001-11-20?16:47??voice_comm\aclocal.m4
?????文件????????2473??2012-04-11?21:30??voice_comm\config.cache
?????文件???????31247??2001-07-05?18:07??voice_comm\config.guess
?????文件????????1115??2012-04-11?20:47??voice_comm\config.h
?????文件?????????966??2001-07-05?18:16??voice_comm\config.h.in
?????文件????????2893??2012-04-11?21:30??voice_comm\config.log
?????文件???????10338??2012-04-11?21:30??voice_comm\config.status
?????文件???????24171??2001-07-05?18:07??voice_comm\config.sub
?????文件???????73728??2001-11-20?16:47??voice_comm\configure
?????文件?????????676??2001-11-20?16:46??voice_comm\configure.in
?????文件????????5598??2001-07-05?18:07??voice_comm\install-sh
?????文件??????142160??2012-04-11?21:30??voice_comm\libtool
?????文件???????99553??2001-07-05?18:07??voice_comm\ltconfig
?????文件??????138294??2001-07-05?18:07??voice_comm\ltmain.sh
?????文件????????6283??2001-07-05?18:07??voice_comm\missing
?????文件?????????722??2001-07-05?18:07??voice_comm\mkinstalldirs
?????目錄???????????0??2014-04-01?13:18??voice_comm\src\
?????文件???????10816??2012-04-11?21:34??voice_comm\src\Makefile
?????文件?????????222??2001-07-05?19:32??voice_comm\src\Makefile.am
?????文件???????10672??2001-11-20?16:47??voice_comm\src\Makefile.in
?????文件????????6313??2001-10-20?23:42??voice_comm\src\comm.c
............此處省略53個文件信息
評論
共有 條評論