📄 mediaproxyservice.java
字号:
}
catch (Exception e) {
Log.error(e);
}
}
/**
* Load config using JiveGlobals
*/
private void initMediaProxy() {
try {
long idleTime =
Long.valueOf(JiveGlobals.getProperty("mediaproxy.idleTimeout"));
mediaProxy.setIdleTime(idleTime);
}
catch (NumberFormatException e) {
// Do nothing let the default values to be used.
}
try {
long lifetime =
Long.valueOf(JiveGlobals.getProperty("mediaproxy.lifetime"));
mediaProxy.setLifetime(lifetime);
}
catch (NumberFormatException e) {
// Do nothing let the default values to be used.
}
try {
int minPort = Integer.valueOf(JiveGlobals.getProperty("mediaproxy.portMin"));
mediaProxy.setMinPort(minPort);
}
catch (NumberFormatException e) {
// Do nothing let the default values to be used.
}
try {
int maxPort = JiveGlobals.getIntProperty("mediaproxy.portMax", mediaProxy.getMaxPort());
mediaProxy.setMaxPort(maxPort);
}
catch (NumberFormatException e) {
// Do nothing let the default values to be used.
}
this.enabled = JiveGlobals.getBooleanProperty("mediaproxy.enabled");
}
/**
* 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.
*
* @return the file transfer server domain (service name + host name).
*/
public String getServiceDomain() {
return serviceName + "." + XMPPServer.getInstance().getServerInfo().getXMPPDomain();
}
public JID getAddress() {
return new JID(null, getServiceDomain(), null);
}
public Iterator<DiscoServerItem> getItems()
{
List<DiscoServerItem> items = new ArrayList<DiscoServerItem>();
if (!isEnabled())
{
return items.iterator();
}
final DiscoServerItem item = new DiscoServerItem(new JID(
getServiceDomain()), "Media Proxy Service", null, null, this, this);
items.add(item);
return items.iterator();
}
public Iterator<Element> getIdentities(String name, String node, JID senderJID) {
List<Element> identities = new ArrayList<Element>();
// Answer the identity of the proxy
Element identity = DocumentHelper.createElement("identity");
identity.addAttribute("category", "proxy");
identity.addAttribute("name", "Media Proxy Service");
identity.addAttribute("type", "rtpbridge");
identities.add(identity);
return identities.iterator();
}
public Iterator<String> getFeatures(String name, String node, JID senderJID) {
return Arrays.asList(NAMESPACE,
"http://jabber.org/protocol/disco#info").iterator();
}
public XDataFormImpl getExtendedInfo(String name, String node, JID senderJID) {
return null;
}
public boolean hasInfo(String name, String node, JID senderJID) {
return true;
}
/**
* Return the list of active Agents
*
* @return list of active agents
*/
public Collection<MediaProxySession> getAgents() {
return mediaProxy.getSessions();
}
/**
* Set the keep alive delay of the mediaproxy agents.
* When an agent stay more then this delay, the agent is destroyed.
*
* @param delay time in millis
*/
public void setKeepAliveDelay(long delay) {
mediaProxy.setIdleTime(delay);
}
/**
* Returns the maximum amount of time (in milleseconds) that a session can
* be idle before it's closed.
*
* @return the max idle time in millis.
*/
public long getIdleTime() {
return mediaProxy.getIdleTime();
}
/**
* Set Minimal port value to listen for incoming packets.
*
* @param minPort port value to listen for incoming packets
*/
public void setMinPort(int minPort) {
mediaProxy.setMinPort(minPort);
}
/**
* Set Maximum port value to listen for incoming packets.
*
* @param maxPort port value to listen for incoming packets
*/
public void setMaxPort(int maxPort) {
mediaProxy.setMaxPort(maxPort);
}
/**
* Get Minimal port value to listen from incoming packets.
*
* @return minPort
*/
public int getMinPort() {
return mediaProxy.getMinPort();
}
/**
* Get Maximum port value to listen from incoming packets.
*
* @return maxPort
*/
public int getMaxPort() {
return mediaProxy.getMaxPort();
}
/**
* Get if the service is enabled.
*
* @return enabled
*/
public boolean isEnabled() {
return enabled;
}
/**
* Set the service enable status.
*
* @param enabled boolean value setting enabled or disabled
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
if (isEnabled()) {
start();
} else {
stop();
}
}
/**
* Stops every running agents
*/
public void stopAgents() {
mediaProxy.stopProxy();
}
/**
* Get the Life Time of Sessions
*
* @return lifetime in seconds
*/
public long getLifetime() {
return mediaProxy.getLifetime();
}
/**
* Set the Life time of Sessions
*
* @param lifetime lifetime in seconds
*/
public void setLifetime(long lifetime) {
mediaProxy.setLifetime(lifetime);
}
/**
* Get the Port used to the UDP Echo Test
*
* @return port number
*/
public int getEchoPort() {
return echoPort;
}
/**
* Set the Port used to the UDP Echo Test
*
* @param echoPort port number
*/
public void setEchoPort(int echoPort) {
this.echoPort = echoPort;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -