Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

RTP help, guidance, resources?

  • 03-03-2010 10:41am
    #1
    Registered Users, Registered Users 2 Posts: 18,272 ✭✭✭✭


    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:

    I have now added this 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?


Comments

  • Registered Users, Registered Users 2 Posts: 18,272 ✭✭✭✭Atomic Pineapple


    I now currently have the following RTP setup:
    public void rtpTest() throws RtpException, IOException{
    		  
    		  RtpManager rtpManager = new RtpManager(myAddress);
    			Log.d("RTPMANAGER", "IPADDRESS here = " + rtpManager.getMyIpAddress());
    			RtpSession rtpSession = rtpManager.createRtpSession(8006);
    			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");
    			
    			//Socket socket = new Socket(getLocalIpAddressString(), 5162, getLocalIpAddress(), 8008);
    			//InputStream is = socket.getInputStream();
    			//byte[] b = new byte[1024];
    			//is.read(b);
    			 
    			//Log.d("IS", "  " + is.read()); 
    			
    			
    			
    			DatagramSocket ds = rtpSession.getRtpRecvSocket();
    			ds.connect(InetAddress.getByName(getLocalIpAddressString()), 8006);
    			Log.d("RTPMANAGER", "ds is bound? " + ds.isBound() + " is connected? " + ds.isConnected());
    			Log.d("RTPMANAGER", "ds is bound to port? " +ds.getPort());
    			Log.d("RTPMANAGER", "ds is bound to remote socket? " +ds.getRemoteSocketAddress());
    			
    			rtpSession.setRemoteIpAddress(getLocalIpAddressString());
    			Log.d("RTPMANAGER", "IPADDRESS recv port = " + getLocalIpAddressString());
    			rtpSession.setRemoteRtpRecvPort(8006);
    			
    			//rtpPacketReciever.run();
    			rtpSession.receiveRTPPackets();
    			RtpPacket rtpPacket = new RtpPacket();
    			rtpPacket.setV(2);
    //			rtpPacket.setP(16);
    			rtpPacket.setCC(4);
    			rtpPacket.setM(1);
    			rtpPacket.setPT(0);
    			rtpPacket.setPT(4);
    			rtpPacket.setPT(8);
    			rtpPacket.setSSRC(123342345);
    			byte[] bytes = new byte[16]; 
    			rtpPacket.setPayload(bytes, 16);
    			rtpSession.sendRtpPacket(rtpPacket);
    			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());
    			
    			Log.d("RTPMANAGER", "RTP PACKET RECEIVER is alive? = " + rtpPacketReciever.isAlive());
    			Log.d("RTPMANAGER", "IPADDRESS here 5");
    			//RtpPacketReceiver.dumpStack();
    		  
    	  }
    


    And I have implemented my class to be a RtpListener and implemented the following methods:
    @Override
    	public void handleRtpErrorEvent(RtpErrorEvent arg0) {
    		// TODO Auto-generated method stub
    		Log.d("RTP", "GOT RTP ERROR EVENT");
    	}
    
    	@Override
    	public void handleRtpPacketEvent(RtpPacketEvent rtpPacketEvent) {
    		// TODO Auto-generated method stub
    		Log.d("RTP", "GOT RTP PACKET EVENT");
    		Log.d("RTP", "PACKETEVENT = " + rtpPacketEvent.toString());
    		Log.d("RTP", "PACKETEVENT.getRTPPACKET = " + rtpPacketEvent.getRtpPacket());
    		Log.d("RTP", "PACKETEVENT.GETSOURCE = " + rtpPacketEvent.getSource());
    		
    	}
    
    	@Override
    	public void handleRtpStatusEvent(RtpStatusEvent arg0) {
    		// TODO Auto-generated method stub
    		Log.d("RTP", "GOT RTP STATUS EVENT");
    	}
    
    	@Override
    	public void handleRtpTimeoutEvent(RtpTimeoutEvent arg0) {
    		// TODO Auto-generated method stub
    		Log.d("RTP", "GOT RTP TIMEOUT EVENT");
    		
    	}
    

    So when I send my own rtppacket above it gets received in handleRtpPacketEvent(RtpPacketEvent rtpPacketEvent) but when I try to send Rtp from outside my application I dont get anything.

    I'm not quite sure what way to send the rtp packets, do I just send them to port 8006?


Advertisement