※ 引述《WindCloud (還有三天,看我七十二變!)》之銘言:
: RTPOpenPort()裡頭,預設是開啟 9000 這個 port,所以對方一定要連到自己電腦
: 的 9000 這個 port,換句話說,對方的 target port 一定得是 9000。
: 問題來了,作業裡又要求我們不能把 target port 寫死在程式碼裡,
: 難不成只是開一個文字編輯區,然後只能輸入 9000 這個值嗎?
: 因為輸入別的值,就連不到對方的 port 啦......
: 麻煩助教解答一下吧。 @_@
我 trace 了 cclRTP.h and cclRTP.c, 如果真的要改的話可能要去修改
rtp subproject 內的 rtp.c & rtcp.c 中的
RTP *rtp_open(u_int16 port, u_int32 ssrc)
RTCP *rtcp_open(u_int16 port, const char *cname)
裡面是如果 port = 0, 程式會從 RTP_PORT_BASE=9000 開始開 port
然後 rtp = 9000 rtcp = 9001 , for example ...
所以你可以修改 cclRTP.h and cclRTP.c, 增加
RETCODE cclRTPOpen(int channel, int rtpPacketSiz, u_int16 port);
供你上層的程式使用...
RETCODE cclRTPOpen(int channel, int rtpPacketSiz, u_int16 port)
{
if( channel<0 || channel>=MAX_RTP_CHANS )
return -1;
if( rtp[channel] ) {
RTP_PACKET_SIZ[channel] = rtpPacketSiz;
return 1;
}
rtp[channel] = rtp_open(port,0);
if( !rtp[channel] )
return -1;
rtcp[channel] = rtcp_open(port+1,0);
if( !rtcp[channel] )
return -1;
return 0;
}
參考看看吧!!
--
※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw)
◆ From: 218.160.22.87