English 中文(简体)
Rtp on Java beginners help?
原标题:

I have started playing around with RTP on Java in Android and was wondering if anyone could give me a bit of help or guidance.

Here is the code I have started on:

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");

}

I am not sure of the correct way to set up an RTP manager, RTP session and RTP packet reciever.

Do I need to open a Datagram Socket first and link it to the RTP session?

When I print out the RTPSession to string from my code above I get the following:

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

I m not sure how correct or incorrect that is??

Also the code only gets to rtpPacketReciever.run(); and stops there, the logging after this method never gets printed, so I assume that there is a problem with rtpPacketReciever.run();?

I m extremely new to RTP so any guidance or good resources anyone knows of would be really helpful.

Thanks in advance

EDIT:

Edit:

I have now added this code:

Code:

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

And logging the ds remote socket gives back the following:

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

Which to me looks wrong? Is it?

问题回答

Hi I think you should try Port 5004. you can refer to following link http://www.networksorcery.com/enp/protocol/rtp.htm





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签