2010-03-02 75 views
1

我已經開始在Android上使用RTP在Java上玩,並想知道是否有人可以給我一些幫助或指導。關於Java初學者的Rtp有什麼幫助?

這裏是我已經開始對代碼:

public void rtpTest() throws UnknownHostException, SocketException, RtpException{ 

RtpManager rtpManager = new RtpManager(myAddress); 
Log.d("RTPMANAGER", "IPADDRESS here = " + rtpManager.getMyIpAddress()); 

tpSession rtpSession = rtpManager.createRtpSession(6040); 
Log.d("RTPMANAGER", "IPADDRESS here 2"); 

rtpSession.addRtpListener(this); 
Log.d("RTPMANAGER", "IPADDRESS here 3"); 

RtpPacketReceiver rtpPacketReciever = new RtpPacketReceiver(rtpSession); 
Log.d("RTPMANAGER", "IPADDRESS here 4"); 


//DatagramSocket ds = new DatagramSocket(6042); 
//ds.bind(null); 

rtpSession.setRemoteIpAddress(getLocalIpAddress()); 
Log.d("RTPMANAGER", "IPADDRESS recv port = " + getLocalIpAddress()); 

rtpSession.setRemoteRtpRecvPort(5060); 

rtpSession.receiveRTPPackets(); 

Log.d("RTPMANAGER", "REMOTE - IPADDRESS = " + rtpSession.getRemoteIpAddress()); 

Log.d("RTPMANAGER", "Recieve port = " + rtpSession.getMyRtpRecvPort()); 
Log.d("RTPMANAGER", "Recieve socket = " + rtpSession.getRtpRecvSocket()); 

Log.d("RTPMANAGER", "RTP SESSION = " + rtpSession.toString()); 
Log.d("RTPMANAGER", "RTP PACKET RECEIVER = " + rtpPacketReciever.toString()); 

Log.d("RTPMANAGER", "RTP PACKET RECEIVER is alive? = " + rtpPacketReciever.isAlive()); 

rtpPacketReciever.run(); 
Log.d("RTPMANAGER", "RTP PACKET RECEIVER is alive? = " + rtpPacketReciever.isAlive()); 

Log.d("RTPMANAGER", "IPADDRESS here 5"); 

} 

我不知道的設立一個RTP經理,RTP會話和RTP包reciever的正確方法。

我是否需要先打開數據報套接字並將其鏈接到RTP會話?

當我從我的代碼打印出RTPSession串上面我得到如下:

RTP SESSION = <rtp-session 
senderIpAddress = "192.168.2.xxx" 
remoteRtpRecvPort = "5060" 
myAddress = "192.168.2.xxx" 
myRtpRecvPort = "6040" 
/> 

我不知道那是多麼正確或不正確的?

此外代碼只能獲取到rtpPacketReciever.run();並停在那裏,這種方法後的日誌記錄永遠不會被打印,所以我認爲rtpPacketReciever.run()有問題;?

我對RTP非常陌生,所以任何人都知道的任何指導或好資源都會非常有用。

在此先感謝

編輯:

編輯:

我現在已經添加以下代碼:

代碼:

DatagramSocket ds = rtpSession.getRtpRecvSocket(); 
ds.connect(InetAddress.getByName(getLocalIpAddress()), 3120); 
Log.d("RTPMANAGER", "ds is bound to remote socket? " +ds.getRemoteSocketAddress()); 

並記錄DS遙控插座給返回以下內容:

ds is bound to remote socket: 192.168.2.163/192.168.2.163:3120 

對我來說,看起來不對?是嗎?

+0

編輯更新細節 – 2010-03-03 10:46:04

+0

就當我構造和發送我自己的RTP包我會接受它添加!只是不是從應用程序外部 – 2010-03-08 15:54:45

+0

只是一個註釋 - 端口5060通常用於SIP(remoteRtpRecvPort =「5060」)。不知道還有什麼...祝你好運! – 2010-05-07 15:34:35

回答