2

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?

5
  • Edited to update details Mar 3, 2010 at 10:46
  • Just to add when I construct and send my own RTP packet I can recieve it! Just not from outside the application Mar 8, 2010 at 15:54
  • just a comment - port 5060 is usually used for SIP (remoteRtpRecvPort = "5060"). not sure what else...good luck!
    – brian_d
    May 7, 2010 at 15:34
  • Thanks Brian, I got this working a long time ago :) May 7, 2010 at 16:22
  • What did you change? Did you also send data via RTP from your android?
    – B770
    Aug 8, 2013 at 5:54

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.