Class RTP

java.lang.Object
javaforce.voip.RTP
All Implemented Interfaces:
STUN.Listener

public class RTP extends Object implements STUN.Listener
RTP (Real-Time Transport Protocol) Handles sending/receiving RTP packets.
  • Field Details

    • sock1

      protected DatagramSocket sock1
    • sock2

      protected DatagramSocket sock2
    • active

      public volatile boolean active
    • iface

      protected RTPInterface iface
    • rawMode

      protected boolean rawMode
    • channels

      public ArrayList<RTPChannel> channels
    • now

      public static long now
    • log

      public int log
    • useTURN

      protected static boolean useTURN
    • turnHost

      protected static String turnHost
    • turnIP

      protected static String turnIP
    • turnUser

      protected static String turnUser
    • turnPass

      protected static String turnPass
    • stun1

      protected STUN stun1
    • stun2

      protected STUN stun2
    • turnToken

      protected byte[] turnToken
    • turnAllocExpires

      protected long turnAllocExpires
    • userobj

      public Object userobj
    • debug

      public static boolean debug
    • CODEC_UNKNOWN

      public static final Codec CODEC_UNKNOWN
    • CODEC_G711u

      public static final Codec CODEC_G711u
    • CODEC_GSM

      public static final Codec CODEC_GSM
    • CODEC_G711a

      public static final Codec CODEC_G711a
    • CODEC_G722

      public static final Codec CODEC_G722
    • CODEC_G729a

      public static final Codec CODEC_G729a
    • CODEC_JPEG

      public static final Codec CODEC_JPEG
    • CODEC_H263

      public static final Codec CODEC_H263
    • CODEC_RFC2833

      public static final Codec CODEC_RFC2833
    • CODEC_VP8

      public static final Codec CODEC_VP8
    • CODEC_VP9

      public static final Codec CODEC_VP9
    • CODEC_H263_1998

      public static final Codec CODEC_H263_1998
    • CODEC_H263_2000

      public static final Codec CODEC_H263_2000
    • CODEC_H264

      public static final Codec CODEC_H264
    • CODEC_H265

      public static final Codec CODEC_H265
    • bindingChannel

      protected volatile RTPChannel bindingChannel
    • bindLock

      protected final Object bindLock
  • Constructor Details

    • RTP

      public RTP()
  • Method Details

    • setLog

      public void setLog(int id)
    • enableTURN

      public static void enableTURN(String host, String user, String pass)
    • disableTURN

      public static void disableTURN()
    • getnextlocalrtpport

      public static int getnextlocalrtpport()
    • getlocalrtpport

      public int getlocalrtpport()
    • stunPublicIP

      public void stunPublicIP(STUN stun, String ip, int port)
      Specified by:
      stunPublicIP in interface STUN.Listener
    • turnAlloc

      public void turnAlloc(STUN stun, String ip, int port, byte[] token, int lifetime)
      Specified by:
      turnAlloc in interface STUN.Listener
    • turnBind

      public void turnBind(STUN stun)
      Specified by:
      turnBind in interface STUN.Listener
    • turnRefresh

      public void turnRefresh(STUN stun, int lifetime)
      Specified by:
      turnRefresh in interface STUN.Listener
    • turnFailed

      public void turnFailed(STUN stun)
      Specified by:
      turnFailed in interface STUN.Listener
    • turnData

      public void turnData(STUN stun, byte[] data, int offset, int length, short turnChannel)
      Specified by:
      turnData in interface STUN.Listener
    • wait4reset

      protected void wait4reset()
    • wait4reply

      protected void wait4reply() throws Exception
      Throws:
      Exception
    • init

      public boolean init(RTPInterface iface, int port)
      For testing only
    • init

      public boolean init(RTPInterface iface)
    • setReceiveBufferSize

      public void setReceiveBufferSize(int bytes)
    • setMTU

      public void setMTU(int mtu)
      Sets maximum packet size. Must call before start(). (default = 1500)
    • getNextTURNChannel

      protected short getNextTURNChannel()
    • start

      public boolean start()
      Starts RTP session.
    • stop

      public void stop()
      Stops RTP session and frees resources.
    • uninit

      public void uninit()
      Frees resources.
    • createChannel

      public RTPChannel createChannel(SDP.Stream stream)
      Create a new RTP channel with a random ssrc id.
    • createChannel

      public RTPChannel createChannel(int ssrc, SDP.Stream stream)
      Create a new RTP channel with a specified ssrc id.
    • removeChannel

      public void removeChannel(RTPChannel channel)
      Remote RTPChannel
    • getDefaultChannel

      public RTPChannel getDefaultChannel()
      Returns default RTP channel.
    • findChannel

      public RTPChannel findChannel(short turnChannel)
    • findChannel

      public RTPChannel findChannel(String ip, int port)
    • setPortRange

      public static void setPortRange(int min, int max)
      Sets global RTP port range to use (should be set before calling init()).
    • keepalive

      public void keepalive()
      Keep Alive - call every 30 seconds to keep active.
    • setRawMode

      public void setRawMode(boolean state)
      Sets raw mode
      Packets are not decoded, they are passed directly thru RTPInterface.rtpPacket()
      This is used by PBX to relay RTP packets between call originator and terminator.
    • getRawMode

      public boolean getRawMode()
      Returns current raw mode
    • getTurnIP

      public static String getTurnIP()
    • genIceufrag

      public static String genIceufrag()
    • genIcepwd

      public static String genIcepwd()
    • setInterface

      public void setInterface(RTPInterface iface)
    • toString

      public String toString()
      Overrides:
      toString in class Object