Class MediaProxyService
- java.lang.Object
-
- org.jivesoftware.openfire.container.BasicModule
-
- org.jivesoftware.openfire.mediaproxy.MediaProxyService
-
- All Implemented Interfaces:
ChannelHandler<org.xmpp.packet.Packet>
,Module
,DiscoInfoProvider
,DiscoItemsProvider
,ServerItemsProvider
,RoutableChannelHandler
public class MediaProxyService extends BasicModule implements ServerItemsProvider, RoutableChannelHandler, DiscoInfoProvider, DiscoItemsProvider
A proxy service for UDP traffic such as RTP. It provides Jingle transport candidates to be used for media transmission. The media proxy is especially useful for users behind NAT devices or firewalls that prevent peer to peer communication..- Author:
- Thiago Camargo
-
-
Constructor Summary
Constructors Constructor Description MediaProxyService()
Constructs a new MediaProxyService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.xmpp.packet.JID
getAddress()
Returns the XMPP address.Collection<MediaProxySession>
getAgents()
Return the list of active Agentsint
getEchoPort()
Get the Port used to the UDP Echo Testorg.xmpp.forms.DataForm
getExtendedInfo(String name, String node, org.xmpp.packet.JID senderJID)
Returns an XDataForm with the extended information about the entity or null if none.Set<org.xmpp.forms.DataForm>
getExtendedInfos(String name, String node, org.xmpp.packet.JID senderJID)
Returns a collection of XDataForm with the extended information about the entity or an empty collection if none.Iterator<String>
getFeatures(String name, String node, org.xmpp.packet.JID senderJID)
Returns an Iterator (of String) with the supported features.Iterator<org.dom4j.Element>
getIdentities(String name, String node, org.xmpp.packet.JID senderJID)
Returns an Iterator (of Element) with the target entity's identities.long
getIdleTime()
Returns the maximum amount of time (in milleseconds) that a session can be idle before it's closed.Iterator<DiscoServerItem>
getItems()
Returns an Iterator (of DiscoServerItem) with the items associated with the server or null if none.Iterator<DiscoItem>
getItems(String name, String node, org.xmpp.packet.JID senderJID)
Returns an Iterator (of DiscoItem) with the target entity's items or null if none.long
getLifetime()
Get the Life Time of Sessionsint
getMaxPort()
Get Maximum port value to listen from incoming packets.int
getMinPort()
Get Minimal port value to listen from incoming packets.String
getName()
Obtain the name of the module.String
getServiceDomain()
Returns the fully-qualifed domain name of this chat service.boolean
hasInfo(String name, String node, org.xmpp.packet.JID senderJID)
Returns true if we can provide information related to the requested name and node.void
initialize(XMPPServer server)
Initializes the basic module.boolean
isEnabled()
Get if the service is enabled.void
process(org.xmpp.packet.Packet packet)
Process an XMPP packet.void
setEchoPort(int echoPort)
Set the Port used to the UDP Echo Testvoid
setEnabled(boolean enabled)
Set the service enable status.void
setKeepAliveDelay(long delay)
Set the keep alive delay of the mediaproxy agents.void
setLifetime(long lifetime)
Set the Life time of Sessionsvoid
setMaxPort(int maxPort)
Set Maximum port value to listen for incoming packets.void
setMinPort(int minPort)
Set Minimal port value to listen for incoming packets.void
start()
Starts the basic module.void
stop()
Stops the basic module.void
stopAgents()
Stops every running agents-
Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy
-
-
-
-
Field Detail
-
NAMESPACE
public static final String NAMESPACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(XMPPServer server)
Description copied from class:BasicModule
Initializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
- Specified by:
initialize
in interfaceModule
- Overrides:
initialize
in classBasicModule
- Parameters:
server
- the server hosting this module.
-
start
public void start()
Description copied from class:BasicModule
Starts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
- Specified by:
start
in interfaceModule
- Overrides:
start
in classBasicModule
-
stop
public void stop()
Description copied from class:BasicModule
Stops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
- Specified by:
stop
in interfaceModule
- Overrides:
stop
in classBasicModule
-
getName
public String getName()
Description copied from class:BasicModule
Obtain the name of the module.
- Specified by:
getName
in interfaceModule
- Overrides:
getName
in classBasicModule
- Returns:
- The name of the module
-
getItems
public Iterator<DiscoItem> getItems(String name, String node, org.xmpp.packet.JID senderJID)
Description copied from interface:DiscoItemsProvider
Returns an Iterator (of DiscoItem) with the target entity's items or null if none. Each DiscoItem must include a JID attribute and may include the name and node attributes of the entity. In case that the sender of the disco request is not authorized to discover items an UnauthorizedException will be thrown.- Specified by:
getItems
in interfaceDiscoItemsProvider
- Parameters:
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco items request.- Returns:
- an Iterator (of DiscoItem) with the target entity's items or null if none.
-
process
public void process(org.xmpp.packet.Packet packet) throws UnauthorizedException, PacketException
Description copied from interface:ChannelHandler
Process an XMPP packet.- Specified by:
process
in interfaceChannelHandler<org.xmpp.packet.Packet>
- Parameters:
packet
- a packet to process.- Throws:
UnauthorizedException
- if not allowed to process the packet.PacketException
- thrown if the packet is malformed (results in the sender's session being shutdown).
-
getServiceDomain
public String getServiceDomain()
Returns the fully-qualifed domain name of this chat service. The domain is composed by the service name and the name of the XMPP server where the service is running.- Returns:
- the file transfer server domain (service name + host name).
-
getAddress
public org.xmpp.packet.JID getAddress()
Description copied from interface:RoutableChannelHandler
Returns the XMPP address. The address is used by services like the core server packet router to determine if a packet should be sent to the handler. Handlers that are working on behalf of the server should use the generic server hostname address (e.g. server.com).- Specified by:
getAddress
in interfaceRoutableChannelHandler
- Returns:
- the XMPP address.
-
getItems
public Iterator<DiscoServerItem> getItems()
Description copied from interface:ServerItemsProvider
Returns an Iterator (of DiscoServerItem) with the items associated with the server or null if none.- Specified by:
getItems
in interfaceServerItemsProvider
- Returns:
- an Iterator (of DiscoServerItem) with the items associated with the server or null if none.
-
getIdentities
public Iterator<org.dom4j.Element> getIdentities(String name, String node, org.xmpp.packet.JID senderJID)
Description copied from interface:DiscoInfoProvider
Returns an Iterator (of Element) with the target entity's identities. Each Element must include the categoty, type and name attributes of the entity.- Specified by:
getIdentities
in interfaceDiscoInfoProvider
- Parameters:
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.- Returns:
- an Iterator (of Element) with the target entity's identities.
-
getFeatures
public Iterator<String> getFeatures(String name, String node, org.xmpp.packet.JID senderJID)
Description copied from interface:DiscoInfoProvider
Returns an Iterator (of String) with the supported features. The features to include are the features offered and supported protocols by the target entity identified by the requested name and node.- Specified by:
getFeatures
in interfaceDiscoInfoProvider
- Parameters:
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.- Returns:
- an Iterator (of String) with the supported features.
-
getExtendedInfo
public org.xmpp.forms.DataForm getExtendedInfo(String name, String node, org.xmpp.packet.JID senderJID)
Description copied from interface:DiscoInfoProvider
Returns an XDataForm with the extended information about the entity or null if none. Each bit of information about the entity must be included as a value of a field of the form.- Specified by:
getExtendedInfo
in interfaceDiscoInfoProvider
- Parameters:
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.- Returns:
- an XDataForm with the extended information about the entity or null if none.
-
getExtendedInfos
public Set<org.xmpp.forms.DataForm> getExtendedInfos(String name, String node, org.xmpp.packet.JID senderJID)
Description copied from interface:DiscoInfoProvider
Returns a collection of XDataForm with the extended information about the entity or an empty collection if none. Each bit of information about the entity must be included as a value of a field of the form.- Specified by:
getExtendedInfos
in interfaceDiscoInfoProvider
- Parameters:
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.- Returns:
- A collection of XDataForms with the extended information about the entity or an empty collection if none.
-
hasInfo
public boolean hasInfo(String name, String node, org.xmpp.packet.JID senderJID)
Description copied from interface:DiscoInfoProvider
Returns true if we can provide information related to the requested name and node. For example, if the requested name refers to a non-existant MUC room then the answer will be false. In case that the sender of the disco request is not authorized to discover this information an UnauthorizedException will be thrown.- Specified by:
hasInfo
in interfaceDiscoInfoProvider
- Parameters:
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.- Returns:
- true if we can provide information related to the requested name and node.
-
getAgents
public Collection<MediaProxySession> getAgents()
Return the list of active Agents- Returns:
- list of active agents
-
setKeepAliveDelay
public void setKeepAliveDelay(long delay)
Set the keep alive delay of the mediaproxy agents. When an agent stay more then this delay, the agent is destroyed.- Parameters:
delay
- time in millis
-
getIdleTime
public long getIdleTime()
Returns the maximum amount of time (in milleseconds) that a session can be idle before it's closed.- Returns:
- the max idle time in millis.
-
setMinPort
public void setMinPort(int minPort)
Set Minimal port value to listen for incoming packets.- Parameters:
minPort
- port value to listen for incoming packets
-
setMaxPort
public void setMaxPort(int maxPort)
Set Maximum port value to listen for incoming packets.- Parameters:
maxPort
- port value to listen for incoming packets
-
getMinPort
public int getMinPort()
Get Minimal port value to listen from incoming packets.- Returns:
- minPort
-
getMaxPort
public int getMaxPort()
Get Maximum port value to listen from incoming packets.- Returns:
- maxPort
-
isEnabled
public boolean isEnabled()
Get if the service is enabled.- Returns:
- enabled
-
setEnabled
public void setEnabled(boolean enabled)
Set the service enable status.- Parameters:
enabled
- boolean value setting enabled or disabled
-
stopAgents
public void stopAgents()
Stops every running agents
-
getLifetime
public long getLifetime()
Get the Life Time of Sessions- Returns:
- lifetime in seconds
-
setLifetime
public void setLifetime(long lifetime)
Set the Life time of Sessions- Parameters:
lifetime
- lifetime in seconds
-
getEchoPort
public int getEchoPort()
Get the Port used to the UDP Echo Test- Returns:
- port number
-
setEchoPort
public void setEchoPort(int echoPort)
Set the Port used to the UDP Echo Test- Parameters:
echoPort
- port number
-
-