tags:

views:

356

answers:

1

Hi all,

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?

A: 

I'm interested in hiring you to do a small but profitable project for me. Are you available? Where can I contact you?

StreamMaster