代码之家  ›  专栏  ›  技术社区  ›  Donal Rafferty

Rtp对Java初学者有帮助吗?

  •  1
  • Donal Rafferty  · 技术社区  · 14 年前

    我已经开始在Android上玩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 SESSION = <rtp-session
    senderIpAddress = "192.168.2.xxx"
    remoteRtpRecvPort = "5060"
    myAddress = "192.168.2.xxx"
    myRtpRecvPort = "6040"
    />
    

    我不知道这有多正确或不正确??

    代码也只能到达rtppacketraceiver.run();并且到此为止,此方法之后的日志记录永远不会被打印出来,因此我认为rtppacketraceiver.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
    

    在我看来哪个错了?它是?

    1 回复  |  直到 14 年前
        1
  •  2
  •   Angan    12 年前

    嗨,我想你应该试试5004端口。您可以参考以下链接 http://www.networksorcery.com/enp/protocol/rtp.htm