Commit 2c9e6f17 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Work on media proxy.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6597 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9df13949
<?xml version="1.0" encoding="UTF-8"?>
<install4j version="4.0" transformSequenceNumber="1">
<install4j version="4.0.4" transformSequenceNumber="1">
<directoryPresets config="${compiler:RELEASE_FULL_PATH}/resources/security/truststore" />
<application name="${compiler:APP_NAME}" distributionSourceDir="" applicationId="${compiler:APPLICATION_ID}" mediaDir="../../target/release" mediaFilePattern="${compiler:FILE_PREFIX}_${compiler:VERSION_MAJOR}_${compiler:VERSION_MINOR}_${compiler:VERSION_REVISION}" compression="9" lzmaCompression="true" pack200Compression="false" keepModificationTimes="true" shortName="${compiler:APP_SHORT_NAME}" publisher="${compiler:PUBLISHER}" publisherWeb="${compiler:PUBLISHER_URL}" version="${compiler:VERSION_MAJOR}.${compiler:VERSION_MINOR}.${compiler:VERSION_REVISION}" allPathsRelative="true" backupOnSave="false" autoSave="true" convertDotsToUnderscores="true" macSignature="????" javaMinVersion="1.5" javaMaxVersion="" allowBetaVM="true">
<languages skipLanguageSelection="false">
......@@ -308,8 +308,40 @@
</serializedBean>
<condition />
<validation />
<actions />
<formComponents />
<actions>
<action name="" id="1292" beanClass="com.install4j.runtime.beans.actions.finish.ExecuteLauncherAction" rollbackBarrier="false" multiExec="false" failureStrategy="1" errorMessage="">
<serializedBean>
<java class="java.beans.XMLDecoder">
<object class="com.install4j.runtime.beans.actions.finish.ExecuteLauncherAction">
<void property="launcherId">
<string>12</string>
</void>
</object>
</java>
</serializedBean>
<condition>context.getBooleanVariable("executeLauncherAction") &amp;&amp; (!context.isUnattended())</condition>
</action>
</actions>
<formComponents>
<formComponent name="Execute launcher" id="1293" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent" insetTop="" insetLeft="" insetBottom="" insetRight="" resetInitOnPrevious="false">
<serializedBean>
<java class="java.beans.XMLDecoder">
<object class="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
<void property="checkboxText">
<string>${i18n:RunEntryExec("${compiler:sys.fullName}")}</string>
</void>
<void property="initiallySelected">
<boolean>true</boolean>
</void>
<void property="variableName">
<string>executeLauncherAction</string>
</void>
</object>
</java>
</serializedBean>
<initScript />
</formComponent>
</formComponents>
</screen>
</installerScreens>
<uninstallerScreens>
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.mediaproxy;
import java.net.DatagramPacket;
/**
* Interface to listener datagramReceived events
* Listener for datagram packets received.
*/
public interface DatagramListener {
/**
* Called when a datagram is received.
* If method return false the packet MUST NOT be resent from the received Channel.
* @param datagramPacket The received datagram
* Called when a datagram is received. If the method returns false, the
* packet MUST NOT be resent from the received Channel.
*
* @param datagramPacket the datagram packet received.
* @return ?
*/
public boolean datagramReceived(DatagramPacket datagramPacket);
}
\ No newline at end of file
/**
* $Revision$
* $Date$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.mediaproxy;
import org.jivesoftware.util.Log;
import java.util.List;
import java.util.ArrayList;
import java.net.InetAddress;
......@@ -15,14 +27,14 @@ import java.net.InetAddress;
*/
public class MediaProxy implements SessionListener {
final private List<Session> sessions = new ArrayList<Session>();
final private List<MediaProxySession> sessions = new ArrayList<MediaProxySession>();
private String localhost;
private int minPort = 10000;
private int maxPort = 20000;
private long keepAliveDelay = 90000;
private long idleTime = 90000;
/**
* Contruct a MediaProxy instance that will listen from every Network Interface.
......@@ -57,17 +69,17 @@ public class MediaProxy implements SessionListener {
* @return Time in millis
*/
public long getKeepAliveDelay() {
return keepAliveDelay;
return idleTime;
}
/**
* Set time in millis that an Session can stay without receive any packet.
* After this time it is auto closed.
* Returns the maximum amount of time (in milleseconds) that a session can
* be idle before it's closed.
*
* @return Time in millis
* @param idleTime the max idle time in millis.
*/
public void setKeepAliveDelay(long keepAliveDelay) {
this.keepAliveDelay = keepAliveDelay;
public void setIdleTime(long idleTime) {
this.idleTime = idleTime;
}
/**
......@@ -75,7 +87,7 @@ public class MediaProxy implements SessionListener {
*
* @return List of the Agents
*/
public List<Session> getAgents() {
public List<MediaProxySession> getAgents() {
return sessions;
}
......@@ -120,8 +132,8 @@ public class MediaProxy implements SessionListener {
*
* @param sid the session ID
*/
public Session getAgent(String sid) {
for (Session session : sessions) {
public MediaProxySession getAgent(String sid) {
for (MediaProxySession session : sessions) {
if (session.getSID().equals(sid)) {
System.out.println("SID: " + sid + " agentSID: " + session.getSID());
return session;
......@@ -134,10 +146,11 @@ public class MediaProxy implements SessionListener {
* Implements Session Listener stopAgent event.
* Remove the stopped session from the sessions list.
*
* @param session
* @param session the session to
*/
public void agentStopped(Session session) {
System.out.println("Session: " + session.getSID() + " removed: " + sessions.remove(session));
public void sessionClosed(MediaProxySession session) {
sessions.remove(session);
Log.debug("Session: " + session.getSID() + " removed.");
}
/**
......@@ -153,11 +166,11 @@ public class MediaProxy implements SessionListener {
*/
public ProxyCandidate addAgent(String id, String creator, String hostA, int portA, String hostB,
int portB) {
final Session session =
new Session(id, creator, localhost, hostA, portA, hostB, portB, minPort, maxPort);
final MediaProxySession session =
new MediaProxySession(id, creator, localhost, hostA, portA, hostB, portB, minPort, maxPort);
if (session != null) {
sessions.add(session);
session.addKeepAlive(keepAliveDelay);
session.addKeepAlive(idleTime);
session.addAgentListener(this);
}
return session;
......@@ -186,7 +199,7 @@ public class MediaProxy implements SessionListener {
minPort, maxPort);
if (agent != null) {
sessions.add(agent);
agent.addKeepAlive(keepAliveDelay);
agent.addKeepAlive(idleTime);
agent.addAgentListener(this);
}
return agent;
......@@ -213,7 +226,7 @@ public class MediaProxy implements SessionListener {
* Stop every running sessions.
*/
public void stopProxy() {
for (Session session : getAgents()) {
for (MediaProxySession session : getAgents()) {
try {
session.clearAgentListeners();
session.stopAgent();
......@@ -224,23 +237,4 @@ public class MediaProxy implements SessionListener {
}
sessions.clear();
}
public static void main(String args[]) {
MediaProxy media = new MediaProxy();
ProxyCandidate ag = media.addSmartAgent("abc", "tester", "200.233.136.54", 20001,
"200.233.136.54", 20008);
ag.start();
try {
Thread.sleep(5000);
System.out.println(InetAddress.getByName("0.0.0.0"));
}
catch (Exception e) {
}
ag.stopAgent();
System.out.println("Closed");
}
}
\ No newline at end of file
/**
* $Revision$
* $Date$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.mediaproxy;
import org.dom4j.Attribute;
......@@ -24,9 +34,9 @@ import java.util.Iterator;
import java.util.List;
/**
* RTP Bridge Media Proxy service plugin.
* Provides especial relayed Jingle transport candidates to be used for media transmission and receiving of UDP packets.
* Especialy used for behind NAT users to ensure connectivity between parties.
* 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
*/
......@@ -54,34 +64,23 @@ public class MediaProxyService extends BasicModule implements ServerItemsProvide
*/
private void loadRTPProxyConfig() {
try {
long keepAliveDelay =
Long.valueOf(JiveGlobals.getProperty("plugin.rtpbridge.keepalivedelay"));
mediaProxy.setKeepAliveDelay(keepAliveDelay);
long idleTime =
Long.valueOf(JiveGlobals.getProperty("mediaproxy.idleTimeout"));
mediaProxy.setIdleTime(idleTime);
}
catch (NumberFormatException e) {
// Do nothing let the default values to be used.
}
try {
int minPort = Integer.valueOf(JiveGlobals.getProperty("plugin.rtpbridge.minport"));
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 = Integer.valueOf(JiveGlobals.getProperty("plugin.rtpbridge.maxport"));
int maxPort = JiveGlobals.getIntProperty("mediaproxy.portMax", mediaProxy.getMaxPort());
mediaProxy.setMaxPort(maxPort);
}
catch (NumberFormatException e) {
// Do nothing let the default values to be used.
}
try {
boolean enabled = Boolean.valueOf(JiveGlobals.getProperty("plugin.rtpbridge.enabled"));
this.enabled = enabled;
}
catch (NumberFormatException e) {
this.enabled = false;
}
this.enabled = JiveGlobals.getBooleanProperty("mediaproxy.enabled");
}
public void destroy() {
......@@ -211,7 +210,7 @@ public class MediaProxyService extends BasicModule implements ServerItemsProvide
if (c != null) {
Session session = mediaProxy.getAgent(
MediaProxySession session = mediaProxy.getAgent(
childElementCopy.attribute("sid").getValue() + "-" + iq.getFrom());
Log.debug(
......@@ -357,7 +356,7 @@ public class MediaProxyService extends BasicModule implements ServerItemsProvide
*
* @return
*/
public List<Session> getAgents() {
public List<MediaProxySession> getAgents() {
return mediaProxy.getAgents();
}
......@@ -368,16 +367,16 @@ public class MediaProxyService extends BasicModule implements ServerItemsProvide
* @param delay time in millis
*/
public void setKeepAliveDelay(long delay) {
mediaProxy.setKeepAliveDelay(delay);
mediaProxy.setIdleTime(delay);
}
/**
* Get the keep alive delay of the mediaproxy agents.
* When an agent stay more then this delay, the agent is destroyed.
* Returns the maximum amount of time (in milleseconds) that a session can
* be idle before it's closed.
*
* @return delay time in millis
* @return the max idle time in millis.
*/
public long getKeepAliveDelay() {
public long getIdleTime() {
return mediaProxy.getKeepAliveDelay();
}
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.mediaproxy;
import java.net.InetAddress;
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.mediaproxy;
/**
* Listen for Session events
* Listener for media proxy session events.
*
* @author Thiago Camargo
*/
public interface SessionListener {
public void agentStopped(Session session);
/**
* A media proxy session was closed as a result of normal termination or because
* the max idle time elapsed.
*
* @param session the session that closed.
*/
public void sessionClosed(MediaProxySession session);
}
\ No newline at end of file
/**
* $Revision$
* $Date$
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.mediaproxy;
import java.net.*;
......@@ -16,7 +26,7 @@ import java.io.IOException;
* It has 4 Channels. 2 for data and 2 for control.
*/
public class SmartSession extends Session {
public class SmartSession extends MediaProxySession {
/**
* Creates a new Smart Session to provide connectivity between Host A and Host B.
......
......@@ -132,14 +132,9 @@
<!-- Server Settings -->
<sidebar id="sidebar-media-services" name="Media Services">
<!-- Media Proxy Settings -->
<item id="media-proxy-service" name="Media Proxy Settings"
url="media-proxy-properties.jsp"
description="Media Proxy Settings"/>
<!-- Media Proxy Session Summary -->
<item id="media-proxy-session-summary" name="Media Proxy Sessions"
url="media-proxy-session-summary.jsp"
description="Media Proxy Session Summary"/>
<item id="media-proxy-service" name="Media Proxy"
url="media-proxy.jsp"
description="Media proxy settings"/>
</sidebar>
......
......@@ -20,7 +20,7 @@ This page summarize every active Session in the RTP Media Proxy
%>
<%@ page import="org.jivesoftware.wildfire.mediaproxy.MediaProxyService" %>
<%@ page import="org.jivesoftware.wildfire.XMPPServer" %>
<%@ page import="org.jivesoftware.wildfire.mediaproxy.Session" %>
<%@ page import="org.jivesoftware.wildfire.mediaproxy.MediaProxySession" %>
<%@ page import="org.jivesoftware.wildfire.mediaproxy.SmartSession" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
......@@ -73,7 +73,7 @@ This page summarize every active Session in the RTP Media Proxy
<tbody>
<% // Print the list of agents
List<Session> agents = mediaProxyService.getAgents();
List<MediaProxySession> agents = mediaProxyService.getAgents();
if (agents.isEmpty()) {
%>
<tr>
......@@ -85,7 +85,7 @@ This page summarize every active Session in the RTP Media Proxy
<%
}
int i = 0;
for (Session proxySession : agents) {
for (MediaProxySession proxySession : agents) {
i++;
%>
<tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>">
......
<%--
- $Revision: $
- $Date: $
-
- Copyright (C) 2006 Jive Software. All rights reserved.
-
- This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution.
--%>
<%@ page import="org.jivesoftware.util.JiveGlobals" %>
<%@ page import="org.jivesoftware.util.ParamUtils" %>
<%@ page import="org.jivesoftware.wildfire.XMPPServer" %>
<%@ page import="org.jivesoftware.wildfire.mediaproxy.MediaProxyService" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%
MediaProxyService mediaProxyService = XMPPServer.getInstance().getMediaProxyService();
......@@ -15,18 +29,18 @@
boolean enabled = false;
if (save) {
keepAliveDelay = ParamUtils.getLongParameter(request, "keepalivedelay", keepAliveDelay);
keepAliveDelay = ParamUtils.getLongParameter(request, "keepalive", keepAliveDelay);
if (keepAliveDelay > 50) {
mediaProxyService.setKeepAliveDelay(keepAliveDelay);
JiveGlobals
.setProperty("plugin.rtpbridge.keepalivedelay", String.valueOf(keepAliveDelay));
.setProperty("mediaproxy.keepalive", String.valueOf(keepAliveDelay));
}
minPort = ParamUtils.getIntParameter(request, "minport", minPort);
maxPort = ParamUtils.getIntParameter(request, "maxport", maxPort);
enabled = ParamUtils.getBooleanParameter(request, "enabled", enabled);
JiveGlobals.setProperty("plugin.rtpbridge.enabled", String.valueOf(enabled));
JiveGlobals.setProperty("mediaproxy.enabled", String.valueOf(enabled));
mediaProxyService.setEnabled(enabled);
......@@ -34,8 +48,8 @@
if (maxPort - minPort > 1000) {
mediaProxyService.setMinPort(minPort);
mediaProxyService.setMaxPort(maxPort);
JiveGlobals.setProperty("plugin.rtpbridge.minport", String.valueOf(minPort));
JiveGlobals.setProperty("plugin.rtpbridge.maxport", String.valueOf(maxPort));
JiveGlobals.setProperty("mediaproxy.portMin", String.valueOf(minPort));
JiveGlobals.setProperty("mediaproxy.portMax", String.valueOf(maxPort));
}
}
......@@ -45,13 +59,15 @@
%>
<html>
<head>
<title>Media Proxy Settings</title>
<title>Media Proxy</title>
<meta name="pageID" content="media-proxy-service"/>
</head>
<body>
<p>
Use the form below to manage Media Proxy settings.<br>
The media proxy enables clients to make rich media (including VoIP) connections to one another
when peer to peer connections fail, such as when one or both clients are behind a
strict firewall.<br>
</p>
<% if (success) { %>
......@@ -71,7 +87,53 @@
<% } %>
<form action="media-proxy-properties.jsp" method="post">
<form action="media-proxy.jsp" method="post">
<div class="jive-contentBoxHeader">
Media Proxy Settings
</div>
<div class="jive-contentBox">
<table cellpadding="3" cellspacing="0" border="0">
<tbody>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="proxyEnabled" value="true" id="rb02"
<%= (enabled ? "checked" : "") %> >
</td>
<td width="99%">
<label for="rb02">
<b>Enabled</b>
- This server will act as a media proxy.
</label>
<br>
Session Idle Timeout:&nbsp<input type="text" size="5" maxlength="8" name="idleTimeout"
value="<%=mediaProxyService.getIdleTime()/1000%>"
align="left">
<input type="text" size="5" maxlength="10" name="port"
value="<%= 38 %>" >
</td>
</tr>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="proxyEnabled" value="false" id="rb01"
<%= (!enabled ? "checked" : "") %> >
</td>
<td width="99%">
<label for="rb01">
<b>Disabled</b>
- This server will not act as a media proxy.
</label>
</td>
</tr>
</tbody>
</table>
</div>
<input type="submit" name="update" value="<fmt:message key="global.save_settings" />">
</form>
<form action="media-proxy.jsp" method="post">
<fieldset>
<legend>Media Proxy Settings</legend>
<div>
......@@ -83,15 +145,15 @@
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td align="left">Keep Alive Delay:&nbsp<input type="text" size="20"
<td align="left">Idle Timeout:&nbsp<input type="text" size="20"
maxlength="100"
name="keepalivedelay"
value="<%=mediaProxyService.getKeepAliveDelay()%>"
value="<%=mediaProxyService.getIdleTime()%>"
align="left">
</td>
</tr>
<tr>
<td align="left">Minimal Port Value:&nbsp<input type="text" size="20"
<td align="left">Port Range: Min&nbsp<input type="text" size="20"
maxlength="100"
name="minport"
value="<%=mediaProxyService.getMinPort()%>"
......@@ -99,7 +161,7 @@
</td>
</tr>
<tr>
<td align="left">Maximum Port Value:&nbsp<input type="text" size="20"
<td align="left">Max:&nbsp<input type="text" size="20"
maxlength="100"
name="maxport"
value="<%=mediaProxyService.getMaxPort()%>"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment