Class MediaProxySession

  • All Implemented Interfaces:
    Runnable, DatagramListener, ProxyCandidate
    Direct Known Subclasses:

    public abstract class MediaProxySession
    extends Thread
    implements ProxyCandidate, DatagramListener
    A media proxy session enables two clients to exchange UDP traffic. Each client connects to a UDP port and then the proxy is responsible for exchanging traffic. Each session uses a total of four ports: two for traffic exchange, and two control ports.
    Thiago Camargo
    • Field Detail

      • portA

        protected int portA
      • portB

        protected int portB
      • localPortA

        protected int localPortA
      • localPortB

        protected int localPortB
      • channelAtoB

        protected org.jivesoftware.openfire.mediaproxy.Channel channelAtoB
      • channelAtoBControl

        protected org.jivesoftware.openfire.mediaproxy.Channel channelAtoBControl
      • channelBtoA

        protected org.jivesoftware.openfire.mediaproxy.Channel channelBtoA
      • channelBtoAControl

        protected org.jivesoftware.openfire.mediaproxy.Channel channelBtoAControl
      • threadAtoB

        protected Thread threadAtoB
      • threadAtoBControl

        protected Thread threadAtoBControl
      • threadBtoA

        protected Thread threadBtoA
      • threadBtoAControl

        protected Thread threadBtoAControl
    • Constructor Detail

      • MediaProxySession

        public MediaProxySession​(String id,
                                 String creator,
                                 String localAddress,
                                 String hostA,
                                 int portA,
                                 String hostB,
                                 int portB,
                                 int minPort,
                                 int maxPort)
        Creates a new static UDP channel between Host A and Host B.
        id - of the Session (Could be a Jingle session ID)
        creator - the session creator name or description
        localAddress - the localhost IP that will listen for UDP packets
        hostA - the hostname or IP of the point A of the Channel
        portA - the port number point A of the Channel
        hostB - the hostname or IP of the point B of the Channel
        portB - the port number point B of the Channel
        minPort - the minimal port value to be used by the server
        maxPort - the maximun port value to be used by the server
    • Method Detail

      • getFreePort

        protected int getFreePort()
        Obtain a free port with a nested control port we can use.
        A free port number.
      • getSID

        public String getSID()
        Get the ID of the Session
        Specified by:
        getSID in interface ProxyCandidate
        the ID of the session
      • getPass

        public String getPass()
        Get the pass of this Session A pass can be used to authorize an Session modification
        Specified by:
        getPass in interface ProxyCandidate
      • getCreator

        public String getCreator()
        Get the agent creator. This field is open to MediaProxy users and just can be set in constructor.
        the session creator name or description
      • getTimestamp

        public long getTimestamp()
        Get last packet arrived timestamp
        TimeStamp in Millis
      • run

        public void run()
        Thread override method
        Specified by:
        run in interface Runnable
        run in class Thread
      • setPortA

        public void setPortA​(int portA)
        Set port A value
        Specified by:
        setPortA in interface ProxyCandidate
        portA - the port number for A
      • setPortB

        public void setPortB​(int portB)
        Set port B value
        Specified by:
        setPortB in interface ProxyCandidate
        portB - the port number for B
      • getPortA

        public int getPortA()
        Get the Port A IP
        Specified by:
        getPortA in interface ProxyCandidate
        the port for A
      • getPortB

        public int getPortB()
        Get the Port B IP
        Specified by:
        getPortB in interface ProxyCandidate
        the port for B
      • getLocalPortA

        public int getLocalPortA()
        Get the localport that listen for Host A Packets
        Specified by:
        getLocalPortA in interface ProxyCandidate
        the local port for A
      • getLocalPortB

        public int getLocalPortB()
        Get the localport that listen for Host B Packets
        Specified by:
        getLocalPortB in interface ProxyCandidate
        the local port for B
      • datagramReceived

        public boolean datagramReceived​(DatagramPacket datagramPacket)
        Implement DatagramListener to timestamp last packet arrived
        Specified by:
        datagramReceived in interface DatagramListener
        datagramPacket - the datagram packet
      • addAgentListener

        public void addAgentListener​(SessionListener sessionListener)
        Adds a listener for Session events
        sessionListener - the sessionj listener to add
      • removeAgentListener

        public void removeAgentListener​(SessionListener sessionListener)
        Removes an Session events listener
        sessionListener - the session listener to remove
      • clearAgentListeners

        public void clearAgentListeners()
        Removes every Session events listeners
      • dispatchAgentStopped

        public void dispatchAgentStopped()
        Dispatch Stop Event