- *
- * @param name the name of the attribute to get
- * @param defaultValue the value of the attribute to set if the attribute doesn't
- * exist
- * @return the attribute value
- */
- public Object getAttribute(String name, Object defaultValue);
-
- /**
- * Check the object has an attribute.
- *
- * @param name the name of the attribute to check
- * @return true if the attribute exists otherwise false
- */
- public boolean hasAttribute(String name);
-
- /**
- * Remove an attribute.
- *
- * @param name the name of the attribute to remove
- * @return true if the attribute was found and removed otherwise false
- */
- public boolean removeAttribute(String name);
-
- /**
- * Remove all attributes.
- */
- public void removeAttributes();
-
- /**
- * Size of the attribute store.
- *
- * @return count of attributes
- */
- public int size();
-
-}
diff --git a/src/main/java/org/red5/server/api/ICastingAttributeStore.java b/src/main/java/org/red5/server/api/ICastingAttributeStore.java
deleted file mode 100644
index d616d8ab8..000000000
--- a/src/main/java/org/red5/server/api/ICastingAttributeStore.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Attribute storage with automatic object casting support.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface ICastingAttributeStore extends IAttributeStore {
-
- /**
- * Get Boolean attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public Boolean getBoolAttribute(String name);
-
- /**
- * Get Byte attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public Byte getByteAttribute(String name);
-
- /**
- * Get Double attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public Double getDoubleAttribute(String name);
-
- /**
- * Get Integer attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public Integer getIntAttribute(String name);
-
- /**
- * Get List attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public List> getListAttribute(String name);
-
- /**
- * Get boolean attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public Long getLongAttribute(String name);
-
- /**
- * Get Long attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public Map, ?> getMapAttribute(String name);
-
- /**
- * Get Set attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public Set> getSetAttribute(String name);
-
- /**
- * Get Short attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public Short getShortAttribute(String name);
-
- /**
- * Get String attribute by name
- *
- * @param name Attribute name
- * @return Attribute
- */
- public String getStringAttribute(String name);
-
-}
diff --git a/src/main/java/org/red5/server/api/IClient.java b/src/main/java/org/red5/server/api/IClient.java
deleted file mode 100644
index 80c3fd37e..000000000
--- a/src/main/java/org/red5/server/api/IClient.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import org.red5.server.adapter.IApplication;
-import org.red5.server.api.scope.IScope;
-
-/**
- * The client object represents a single client. One client may have multiple
- * connections to different scopes on the same host. In some ways the client
- * object is like a HTTP session. You can create IClient objects with
- * {@link IClientRegistry#newClient(Object[])}
- *
- *
- * NOTE: I removed session, since client serves the same purpose as a client
- * with attributes
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- */
-public interface IClient extends IAttributeStore {
-
- /**
- * The key used to store the client object in a http session.
- */
- public static final String ID = "red5.client";
-
- /**
- * Sets the clients id
- * @param id client id
- */
- public void setId(String id);
-
- /**
- * Get the unique ID for this client. This will be generated by the server
- * if not passed upon connection from client-side Flex/Flash app. To assign a custom ID to the client use
- * params object of
- * {@link IApplication#appConnect(IConnection, Object[])} method, that
- * contains 2nd all the rest values you pass to
- * NetConnection.connect method.
- *
- * Example:
- *
- * At client side:
- * NetConnection.connect( "http://localhost/killerapp/", "user123" );
- *
- * then at server side:
- * public boolean appConnect( IConnection connection, Object[] params ){
- * try {
- * connection.getClient().setId( (String) params[0] );
- * } catch(Exception e){
- * log.error("{}", e);
- * }
- * }
- *
- *
- * @return client id
- */
- public String getId();
-
- /**
- * Get the creation time for this client object.
- *
- * @return Creation time in milliseconds
- */
- public long getCreationTime();
-
- /**
- * Get a set of scopes the client is connected to.
- *
- * @return Set of scopes
- */
- public Collection getScopes();
-
- /**
- * Get a set of connections.
- *
- * @return Set of connections
- */
- public Set getConnections();
-
- /**
- * Get a set of connections of a given scope.
- *
- * @param scope scope to get connections for
- * @return Set of connections to the passed scope
- */
- public Set getConnections(IScope scope);
-
- /**
- * Closes all the connections.
- */
- public void disconnect();
-
- /**
- * Set the permissions for this client in a given context.
- *
- * @param conn Connection specifying the context to set the permissions for.
- * @param permissions Permissions the client has in this context or null for no permissions.
- */
- public void setPermissions(IConnection conn, Collection permissions);
-
- /**
- * Return the permissions in a given context.
- *
- * @param conn Connection specifying the context to get the permissions for.
- * @return Permission names.
- */
- public Collection getPermissions(IConnection conn);
-
- /**
- * Check if the client has a permission in the given context.
- *
- * @param conn Connection specifying the context to check the permissions for.
- * @param permissionName Name of the permission to check.
- * @return true if the client has the permission, otherwise false
- */
- public boolean hasPermission(IConnection conn, String permissionName);
-
- /**
- * Performs a bandwidth checking routine.
- * Information may be found here: http://www.adobe.com/devnet/flashmediaserver/articles/dynamic_stream_switching_04.html
- */
- public void checkBandwidth();
-
- /**
- * Performs a bandwidth checking callback for the client.
- * Information may be found here: http://www.adobe.com/devnet/flashmediaserver/articles/dynamic_stream_switching_04.html
- */
- public Map checkBandwidthUp(Object[] params);
-
- /**
- * Returns whether or not a bandwidth check has been requested.
- * @return true if requested and false otherwise
- */
- public boolean isBandwidthChecked();
-
-}
diff --git a/src/main/java/org/red5/server/api/IClientRegistry.java b/src/main/java/org/red5/server/api/IClientRegistry.java
deleted file mode 100644
index 2ff45a8f0..000000000
--- a/src/main/java/org/red5/server/api/IClientRegistry.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-import org.red5.server.exception.ClientNotFoundException;
-import org.red5.server.exception.ClientRejectedException;
-
-/**
- * Provides a registry of client objects.
- * You can lookup a client by its client id / session id using lookupClient method.
- * This interface implementations also create new client objects from given params, usually
- * passed from client-side Flex/Flash application upon initial connection.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- */
-public interface IClientRegistry {
-
- /**
- * Check if a client with a given id exists.
- *
- * @param id the id of the client to check for
- * @return true if the client exists, false otherwise
- */
- public boolean hasClient(String id);
-
- /**
- * Create a new client client object from connection params.
- *
- * @param params the parameters the client passed during connection
- * @return the new client
- * @throws ClientNotFoundException no client could be created from the passed parameters
- * @throws ClientRejectedException the client is not allowed to connect
- */
- public IClient newClient(Object[] params) throws ClientNotFoundException, ClientRejectedException;
-
- /**
- * Return an existing client from a client id.
- *
- * @param id the id of the client to return
- * @return the client object
- * @throws ClientNotFoundException no client with the passed id exists
- */
- public IClient lookupClient(String id) throws ClientNotFoundException;
-
- /**
- * Adds a client to the registry.
- *
- * @param client
- */
- public void addClient(IClient client);
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/IConnection.java b/src/main/java/org/red5/server/api/IConnection.java
deleted file mode 100644
index 6f9784a08..000000000
--- a/src/main/java/org/red5/server/api/IConnection.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.red5.server.api.listeners.IConnectionListener;
-import org.red5.server.api.scope.IBasicScope;
-import org.red5.server.api.scope.IScope;
-
-/**
- * The connection object.
- *
- * Each connection has an associated client and scope. Connections may be
- * persistent, polling, or transient. The aim of this interface is to provide
- * basic connection methods shared between different types of connections
- *
- * Future subclasses: RTMPConnection, RemotingConnection, AJAXConnection,
- * HttpConnection, etc
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- */
-public interface IConnection extends ICoreObject, ICastingAttributeStore {
-
- /**
- * AMF version types, either AMF0 or AMF3.
- */
- public static enum Encoding {
- AMF0,
- AMF3
- };
-
- /**
- * Persistent connection type, eg RTMP.
- */
- public static final String PERSISTENT = "persistent";
-
- /**
- * Polling connection type, eg RTMPT.
- */
- public static final String POLLING = "polling";
-
- /**
- * Transient connection type, eg Remoting, HTTP, etc.
- */
- public static final String TRANSIENT = "transient";
-
- /**
- * Get the connection type.
- *
- * @return string containing one of connection types
- */
- public String getType(); // PERSISTENT | POLLING | TRANSIENT
-
- /**
- * Get the object encoding (AMF version) for this connection.
- *
- * @return the used encoding.
- */
- public Encoding getEncoding();
-
- /**
- * Initialize the connection.
- * @param client Client object associated with connection
- */
- public void initialize(IClient client);
-
- /**
- * Try to connect to the scope.
- * @return true on success, false otherwise
- * @param scope Scope object
- */
- public boolean connect(IScope scope);
-
- /**
- * Try to connect to the scope with a list of connection parameters.
- * @param params Connections parameters
- * @return true on success, false otherwise
- * @param scope Scope object
- */
- public boolean connect(IScope scope, Object[] params);
-
- /**
- * Is the client connected to the scope. Result depends on connection type,
- * true for persistent and polling connections, false for transient.
- *
- * @return true if the connection is persistent or polling,
- * otherwise false
- */
- public boolean isConnected();
-
- /**
- * Close this connection. This will disconnect the client from the
- * associated scope.
- */
- public void close();
-
- /**
- * Return the parameters that were given in the call to "connect".
- *
- * @return Connection parameters passed from client-side (Flex/Flash application)
- */
- public Map getConnectParams();
-
- /**
- * Sets the Client.
- *
- * @param client
- */
- public void setClient(IClient client);
-
- /**
- * Get the client object associated with this connection.
- *
- * @return Client object
- */
- public IClient getClient();
-
- /**
- * Get the hostname that the client is connected to. If they are connected
- * to an IP, the IP address will be returned as a String.
- *
- * @return String containing the hostname
- */
- public String getHost();
-
- /**
- * Get the IP address the client is connected from.
- *
- * @return The IP address of the client
- */
- public String getRemoteAddress();
-
- /**
- * Get the IP addresses the client is connected from. If a client is connected
- * through RTMPT and uses a proxy to connect, this will contain all hosts the
- * client used to connect to the server.
- *
- * @return The IP addresses of the client
- */
- public List getRemoteAddresses();
-
- /**
- * Get the port the client is connected from.
- *
- * @return The port of the client
- */
- public int getRemotePort();
-
- /**
- * Get the path for this connection.
- * This is not updated if you switch scope.
- *
- * @return path Connection path
- */
- public String getPath();
-
- /**
- * Get the session id, this may be null.
- *
- * @return Session id
- */
- public String getSessionId();
-
- /**
- * Total number of bytes read from the connection.
- *
- * @return Number of read bytes
- */
- public long getReadBytes();
-
- /**
- * Total number of bytes written to the connection.
- *
- * @return Number of written bytes
- */
- public long getWrittenBytes();
-
- /**
- * Total number of messages read from the connection.
- *
- * @return Number of read messages
- */
- public long getReadMessages();
-
- /**
- * Total number of messages written to the connection.
- *
- * @return Number of written messages
- */
- public long getWrittenMessages();
-
- /**
- * Total number of messages that have been dropped.
- *
- * @return Number of dropped messages
- */
- public long getDroppedMessages();
-
- /**
- * Total number of messages that are pending to be sent to the connection.
- *
- * @return Number of pending messages
- */
- public long getPendingMessages();
-
- /**
- * Return number of written bytes the client reports to have received.
- * This is the last value of the BytesRead message received from a client.
- *
- * @see org.red5.server.net.rtmp.event.BytesRead
- * @return number of written bytes received by the client
- */
- public long getClientBytesRead();
-
- /**
- * Start measuring the round-trip time for a packet on the connection.
- */
- public void ping();
-
- /**
- * Return round-trip time of last ping command.
- *
- * @return round-trip time in milliseconds
- */
- public int getLastPingTime();
-
- /**
- * Get the scope this is connected to.
- *
- * @return The connected scope
- */
- public IScope getScope();
-
- /**
- * Get the basic scopes this connection has subscribed. This list will
- * contain the shared objects and broadcast streams the connection
- * connected to.
- *
- * @return List of basic scopes
- */
- public Iterator getBasicScopes();
-
- /**
- * Sets the bandwidth using a mbit/s value.
- *
- * @param mbits
- */
- public void setBandwidth(int mbits);
-
- /**
- * Adds a listener to this object
- *
- * @param listener
- */
- public void addListener(IConnectionListener listener);
-
- /**
- * Removes the listener from this object
- *
- * @param listener
- */
- public void removeListener(IConnectionListener listener);
-
- /**
- * Returns the current stream id.
- *
- * @return stream id
- */
- public int getStreamId();
-
- /**
- * Sets the current stream id.
- *
- * @param id stream id
- */
- public void setStreamId(int id);
-
-}
diff --git a/src/main/java/org/red5/server/api/IContext.java b/src/main/java/org/red5/server/api/IContext.java
deleted file mode 100644
index a376098d4..000000000
--- a/src/main/java/org/red5/server/api/IContext.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-import org.red5.server.api.persistence.IPersistenceStore;
-import org.red5.server.api.scope.IGlobalScope;
-import org.red5.server.api.scope.IScope;
-import org.red5.server.api.scope.IScopeHandler;
-import org.red5.server.api.service.IServiceInvoker;
-import org.springframework.context.ApplicationContext;
-import org.springframework.core.io.support.ResourcePatternResolver;
-
-/**
- * The current context, this object basically wraps the Spring context
- * or in the case of the .Net version, any similar system.
- *
- */
-public interface IContext extends ResourcePatternResolver {
-
- public static final String ID = "red5.context";
-
- /**
- * Getter for application context
- *
- * @return Application context
- */
- ApplicationContext getApplicationContext();
-
- // public IScopeResolver getScopeResolver();
- /**
- * Get client registry. Client registry is a place where all clients are
- * registred.
- *
- * @return Client registry object
- */
- IClientRegistry getClientRegistry();
-
- /**
- * Returns service invoker object. Service invokers are objects that make
- * service calls to client side NetConnection objects.
- *
- * @return Service invoker object
- */
- IServiceInvoker getServiceInvoker();
-
- /**
- * Returns persistence store object, a storage for persistent objects like
- * persistent SharedObjects.
- *
- * @return Persistence store object
- */
- IPersistenceStore getPersistanceStore();
-
- /**
- * Returns scope handler (object that handle all actions related to the
- * scope) by path. See {@link IScopeHandler} for details.
- *
- * @param path
- * Path of scope handler
- * @return Scope handler
- */
- IScopeHandler lookupScopeHandler(String path);
-
- /**
- * Returns scope by path. You can think of IScope as of tree items, used to
- * separate context and resources between users. See {@link IScope} for more
- * details.
- *
- * @param path
- * Path of scope
- * @return IScope object
- */
- IScope resolveScope(String path);
-
- /**
- * Returns scope by path from given root. You can think of IScope as of tree
- * items, used to separate context and resources between users.
- * See {@link IScope} for more details.
- *
- * @param root
- * Root to start from
- * @param path
- * Path of scope
- * @return IScope object
- */
- IScope resolveScope(IScope root, String path);
-
- /**
- * Returns global scope reference
- *
- * @return global scope reference
- */
- IGlobalScope getGlobalScope();
-
- /**
- * Returns service by name.
- *
- * @param serviceName
- * Name of service
- * @return Service object
- */
- Object lookupService(String serviceName);
-
- /**
- * Returns bean by ID
- *
- * @param beanId
- * Bean ID
- * @return Given bean instance
- */
- Object getBean(String beanId);
-
- /**
- * Returns true if the context contains a certain bean,
- * false otherwise.
- * @param beanId The name of the bean to find.
- * @return True if the bean exists, false otherwise.
- */
- boolean hasBean(String beanId);
-
- /**
- * Returns core service by bean id
- *
- * @param beanId
- * Bean ID
- * @return Core service
- */
- Object getCoreService(String beanId);
-
- /**
- * Returns IMappingStrategy object
- *
- * @return IMappingStrategy object
- */
- public IMappingStrategy getMappingStrategy();
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/ICoreObject.java b/src/main/java/org/red5/server/api/ICoreObject.java
deleted file mode 100644
index 170656d1e..000000000
--- a/src/main/java/org/red5/server/api/ICoreObject.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-import org.red5.server.api.event.IEventDispatcher;
-import org.red5.server.api.event.IEventHandler;
-import org.red5.server.api.event.IEventListener;
-
-/**
- * Base marker interface for all core objects.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- *
- */
-public interface ICoreObject extends IEventDispatcher, IEventHandler, IEventListener {
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/IMappingStrategy.java b/src/main/java/org/red5/server/api/IMappingStrategy.java
deleted file mode 100644
index ab8d66484..000000000
--- a/src/main/java/org/red5/server/api/IMappingStrategy.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-/**
- * This interface encapsulates the mapping strategy used by the context.
- */
-public interface IMappingStrategy {
-
- /**
- * Map a name to the name of a service.
- *
- * @param name name to map
- * @return The name of the service with the passed name
- */
- public String mapServiceName(String name);
-
- /**
- * Map a context path to the name of a scope handler.
- *
- * @param contextPath context path to map
- * @return The name of a scope handler
- */
- public String mapScopeHandlerName(String contextPath);
-
- /**
- * Map a context path to a path prefix for resources.
- *
- * @param contextPath context path to map
- * @return The path prefix for resources with the given name
- */
- public String mapResourcePrefix(String contextPath);
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/IServer.java b/src/main/java/org/red5/server/api/IServer.java
deleted file mode 100644
index 4b8336906..000000000
--- a/src/main/java/org/red5/server/api/IServer.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.red5.server.api.listeners.IConnectionListener;
-import org.red5.server.api.listeners.IScopeListener;
-import org.red5.server.api.scope.IGlobalScope;
-
-/**
- * The interface that represents the Red5 server.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- *
- */
-public interface IServer {
- /**
- * Server ID
- */
- public static final String ID = "red5.server";
-
- /**
- * Get the global scope with given name.
- *
- * @param name Name of the global scope
- * @return the global scope
- */
- public IGlobalScope getGlobal(String name);
-
- /**
- * Register a global scope.
- *
- * @param scope The global scope to register
- */
- public void registerGlobal(IGlobalScope scope);
-
- /**
- * Lookup the global scope for a host.
- *
- * @param hostName The name of the host
- * @param contextPath The path in the host
- * @return The found global scope or null
- */
- public IGlobalScope lookupGlobal(String hostName, String contextPath);
-
- /**
- * Map a virtual hostname and a path to the name of a global scope.
- *
- * @param hostName The name of the host to map
- * @param contextPath The path to map
- * @param globalName The name of the global scope to map to
- * @return true if the name was mapped, otherwise
- * false
- */
- public boolean addMapping(String hostName, String contextPath, String globalName);
-
- /**
- * Unregister a previously mapped global scope.
- *
- * @param hostName The name of the host to unmap
- * @param contextPath The path for this host to unmap
- * @return true if the global scope was unmapped, otherwise
- * false
- */
- public boolean removeMapping(String hostName, String contextPath);
-
- /**
- * Query informations about the global scope mappings.
- *
- * @return Map containing informations about the mappings
- */
- public Map getMappingTable();
-
- /**
- * Get list of global scope names.
- *
- * @return Iterator for names of global scopes
- */
- public Iterator getGlobalNames();
-
- /**
- * Get list of global scopes.
- *
- * @return Iterator for global scopes objects
- */
- public Iterator getGlobalScopes();
-
- /**
- * Add listener to get notified about scope events.
- *
- * @param listener the listener to add
- */
- public void addListener(IScopeListener listener);
-
- /**
- * Add listener to get notified about connection events.
- *
- * @param listener the listener to add
- */
- public void addListener(IConnectionListener listener);
-
- /**
- * Remove listener that got notified about scope events.
- *
- * @param listener the listener to remove
- */
- public void removeListener(IScopeListener listener);
-
- /**
- * Remove listener that got notified about connection events.
- *
- * @param listener the listener to remove
- */
- public void removeListener(IConnectionListener listener);
-
-}
diff --git a/src/main/java/org/red5/server/api/Red5.java b/src/main/java/org/red5/server/api/Red5.java
deleted file mode 100644
index 09ebda671..000000000
--- a/src/main/java/org/red5/server/api/Red5.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2012 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api;
-
-import java.lang.ref.WeakReference;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.management.openmbean.CompositeData;
-
-import org.red5.logging.Red5LoggerFactory;
-import org.red5.server.api.scope.IScope;
-import org.slf4j.Logger;
-
-/**
- * Utility class for accessing Red5 API objects.
- *
- * This class uses a thread local, and will be setup by the service invoker.
- *
- * The code below shows various uses.
- *
- *
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- * @author Paul Gregoire (mondain@gmail.com)
- * @author Tiago Daniel Jacobs (os@tdj.cc)
- */
-public final class Red5 {
-
- private static Logger log = Red5LoggerFactory.getLogger(Red5.class);
-
- /**
- * Connection associated with the current thread. Each connection runs in a separate thread.
- */
- private static final ThreadLocal> connThreadLocal = new ThreadLocal>();
-
- /**
- * Connection local to the current thread
- */
- public IConnection conn;
-
- /**
- * Server version with revision
- */
- public static final String VERSION = "Red5 Server 1.0.4-SNAPSHOT";
-
- /**
- * Server version for fmsVer requests
- */
- public static final String FMS_VERSION = "RED5/1,0,4,0";
-
- /**
- * Server capabilities
- */
- public static final Integer CAPABILITIES = Integer.valueOf(33); // was 31
-
- /**
- * Data version for NetStatusEvents
- */
- @SuppressWarnings("serial")
- public static final Map DATA_VERSION = new HashMap(2) {
- {
- put("version", "4,0,0,1121");
- put("type", "red5");
- }
- };
-
- /**
- * Server start time
- */
- private static final long START_TIME = System.currentTimeMillis();
-
- /**
- * Detection of debug mode
- */
- private static boolean debug = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("jdwp") >= 0;
-
- /**
- * Create a new Red5 object using given connection.
- *
- * @param conn Connection object.
- */
- public Red5(IConnection conn) {
- this.conn = conn;
- }
-
- /**
- * Create a new Red5 object using the connection local to the current thread
- * A bit of magic that lets you access the red5 scope from anywhere
- */
- public Red5() {
- conn = Red5.getConnectionLocal();
- }
-
- /**
- * Setter for connection
- *
- * @param connection Thread local connection
- */
- public static void setConnectionLocal(IConnection connection) {
- log.debug("Set connection: {} with thread: {}", (connection != null ? connection.getSessionId() : null), Thread.currentThread().getName());
- if (connection != null) {
- connThreadLocal.set(new WeakReference(connection));
- IScope scope = connection.getScope();
- if (scope != null) {
- Thread.currentThread().setContextClassLoader(scope.getClassLoader());
- }
- } else {
- // use null to clear the value
- connThreadLocal.remove();
- }
- }
-
- /**
- * Get the connection associated with the current thread. This method allows
- * you to get connection object local to current thread. When you need to
- * get a connection associated with event handler and so forth, this method
- * provides you with it.
- *
- * @return Connection object
- */
- public static IConnection getConnectionLocal() {
- log.debug("Get connection on thread: {}", Thread.currentThread().getName());
- WeakReference ref = connThreadLocal.get();
- if (ref != null) {
- return ref.get();
- } else {
- return null;
- }
- }
-
- /**
- * Get the connection object.
- *
- * @return Connection object
- */
- public IConnection getConnection() {
- return conn;
- }
-
- /**
- * Get the scope
- *
- * @return Scope object
- */
- public IScope getScope() {
- return conn.getScope();
- }
-
- /**
- * Get the client
- *
- * @return Client object
- */
- public IClient getClient() {
- return conn.getClient();
- }
-
- /**
- * Get the spring application context
- *
- * @return Application context
- */
- public IContext getContext() {
- return conn.getScope().getContext();
- }
-
- /**
- * Returns the current version with revision number
- *
- * @return String version
- */
- public static String getVersion() {
- return VERSION;
- }
-
- /**
- * Returns the current version for fmsVer requests
- *
- * @return String fms version
- */
- public static String getFMSVersion() {
- return FMS_VERSION;
- }
-
- public static Integer getCapabilities() {
- return CAPABILITIES;
- }
-
- public static Object getDataVersion() {
- return DATA_VERSION;
- }
-
- /**
- * Returns true if java debugging was detected.
- *
- * @return true if debugging, false otherwise
- */
- public static boolean isDebug() {
- return debug;
- }
-
- /**
- * Returns server uptime in milliseconds.
- *
- * @return String version
- */
- public static long getUpTime() {
- return System.currentTimeMillis() - START_TIME;
- }
-
- /**
- * Allows for reconstruction via CompositeData.
- *
- * @param cd composite data
- * @return Red5 class instance
- */
- public static Red5 from(CompositeData cd) {
- Red5 instance = null;
- if (cd.containsKey("connection")) {
- Object cn = cd.get("connection");
- if (cn != null && cn instanceof IConnection) {
- instance = new Red5((IConnection) cn);
- } else {
- instance = new Red5();
- }
- } else {
- instance = new Red5();
- }
- return instance;
- }
-
-}
diff --git a/src/main/java/org/red5/server/api/event/IEvent.java b/src/main/java/org/red5/server/api/event/IEvent.java
deleted file mode 100644
index c8c377e66..000000000
--- a/src/main/java/org/red5/server/api/event/IEvent.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.event;
-
-/**
- * IEvent interfaces is the essential interface every Event should implement
- */
-public interface IEvent {
-
- /**
- * Returns even type
- *
- * @return Event type enumeration
- */
- public Type getType();
-
- /**
- * Returns event context object
- *
- * @return Event context object
- */
- public Object getObject();
-
- /**
- * Whether event has source (event listener(s))
- * @return true if so, false otherwise
- */
- public boolean hasSource();
-
- /**
- * Returns event listener
- * @return Event listener object
- */
- public IEventListener getSource();
-
- enum Type {
- SYSTEM, STATUS, SERVICE_CALL, SHARED_OBJECT, STREAM_ACTION, STREAM_CONTROL, STREAM_DATA, CLIENT, CLIENT_INVOKE, CLIENT_NOTIFY, SERVER
- }
-
-}
diff --git a/src/main/java/org/red5/server/api/event/IEventDispatcher.java b/src/main/java/org/red5/server/api/event/IEventDispatcher.java
deleted file mode 100644
index d49cac1e7..000000000
--- a/src/main/java/org/red5/server/api/event/IEventDispatcher.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.event;
-
-/**
- * IEventDispatcher interface implementations dispatch events
- */
-public interface IEventDispatcher {
-
- /**
- * Dispatches event
- * @param event Event object
- */
- public void dispatchEvent(IEvent event);
-
-}
diff --git a/src/main/java/org/red5/server/api/event/IEventHandler.java b/src/main/java/org/red5/server/api/event/IEventHandler.java
deleted file mode 100644
index 0220fce0f..000000000
--- a/src/main/java/org/red5/server/api/event/IEventHandler.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.event;
-
-public interface IEventHandler {
-
- /**
- * Handle an event.
- *
- * @param event to handle
- * @return true if event was handled, false if it should bubble
- */
- public boolean handleEvent(IEvent event);
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/event/IEventListener.java b/src/main/java/org/red5/server/api/event/IEventListener.java
deleted file mode 100644
index 32581622c..000000000
--- a/src/main/java/org/red5/server/api/event/IEventListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.event;
-
-public interface IEventListener {
-
- /**
- * Notify of event.
- * @param event the event object
- */
- public void notifyEvent(IEvent event);
-
-}
diff --git a/src/main/java/org/red5/server/api/event/IEventObservable.java b/src/main/java/org/red5/server/api/event/IEventObservable.java
deleted file mode 100644
index 9ff63c114..000000000
--- a/src/main/java/org/red5/server/api/event/IEventObservable.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.event;
-
-import java.util.Set;
-
-/**
- * IEventObservable hold functionality of the well-known Observer pattern, that is
- * it has a list of objects that listen to events.
- */
-public interface IEventObservable {
-
- /**
- * Add event listener to this observable
- *
- * @param listener Event listener
- * @return true if listener is added and false otherwise
- */
- public boolean addEventListener(IEventListener listener);
-
- /**
- * Remove event listener from this observable
- *
- * @param listener Event listener
- * @return true if listener is removed and false otherwise
- */
- public boolean removeEventListener(IEventListener listener);
-
- /**
- * Returns event listeners
- *
- * @return Event listeners iterator
- */
- public Set getEventListeners();
-
-}
diff --git a/src/main/java/org/red5/server/api/listeners/IConnectionListener.java b/src/main/java/org/red5/server/api/listeners/IConnectionListener.java
deleted file mode 100644
index de2f21808..000000000
--- a/src/main/java/org/red5/server/api/listeners/IConnectionListener.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.listeners;
-
-import org.red5.server.api.IConnection;
-
-/**
- * Interface for listeners to connection events.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (bauch@struktur.de)
- */
-public interface IConnectionListener {
-
- /**
- * A new connection was established.
- *
- * @param conn the new connection
- */
- public void notifyConnected(IConnection conn);
-
- /**
- * A connection was disconnected.
- *
- * @param conn the disconnected connection
- */
- public void notifyDisconnected(IConnection conn);
-
-}
diff --git a/src/main/java/org/red5/server/api/listeners/IScopeListener.java b/src/main/java/org/red5/server/api/listeners/IScopeListener.java
deleted file mode 100644
index cc90bb6a0..000000000
--- a/src/main/java/org/red5/server/api/listeners/IScopeListener.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.listeners;
-
-import org.red5.server.api.scope.IScope;
-
-/**
- * Interface for listeners to scope events.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (bauch@struktur.de)
- */
-public interface IScopeListener {
-
- /**
- * A scope has been created.
- *
- * @param scope the new scope
- */
- public void notifyScopeCreated(IScope scope);
-
- /**
- * A scope has been removed.
- *
- * @param scope the removed scope
- */
- public void notifyScopeRemoved(IScope scope);
-
-}
diff --git a/src/main/java/org/red5/server/api/persistence/IPersistable.java b/src/main/java/org/red5/server/api/persistence/IPersistable.java
deleted file mode 100644
index 14b3f2dbc..000000000
--- a/src/main/java/org/red5/server/api/persistence/IPersistable.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.persistence;
-
-import java.io.IOException;
-
-import org.red5.io.object.Input;
-import org.red5.io.object.Output;
-
-/**
- * Base interface for objects that can be made persistent.
- *
- * Every object that complies to this interface must provide either a
- * constructor that takes an input stream as only parameter or an empty
- * constructor so it can be loaded from the persistence store.
- *
- * However this is not required for objects that are created by the application
- * and initialized afterwards.
- *
- * @see org.red5.io.object.Input
- * @see IPersistenceStore#load(String)
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- * @author Joachim Bauch (jojo@struktur.de)
- */
-
-public interface IPersistable {
-
- /**
- * Prefix for attribute names that should not be made persistent.
- */
- public static final String TRANSIENT_PREFIX = "_transient";
-
- /**
- * Returns true if the object is persistent,
- * false otherwise.
- *
- * @return true if object is persistent, false otherwise
- */
- public boolean isPersistent();
-
- /**
- * Set the persistent flag of the object.
- *
- * @param persistent true if object is persistent, false otherwise
- */
- public void setPersistent(boolean persistent);
-
- /**
- * Returns the name of the persistent object.
- *
- * @return Object name
- */
- public String getName();
-
- /**
- * Set the name of the persistent object.
- *
- * @param name New object name
- */
- public void setName(String name);
-
- /**
- * Returns the type of the persistent object.
- *
- * @return Object type
- */
- public String getType();
-
- /**
- * Returns the path of the persistent object.
- *
- * @return Persisted object path
- */
- public String getPath();
-
- /**
- * Set the path of the persistent object.
- *
- * @param path New persisted object path
- */
- public void setPath(String path);
-
- /**
- * Returns the timestamp when the object was last modified.
- *
- * @return Last modification date in milliseconds
- */
- public long getLastModified();
-
- /**
- * Returns the persistence store this object is stored in
- *
- * @return This object's persistence store
- */
- public IPersistenceStore getStore();
-
- /**
- * Store a reference to the persistence store in the object.
- *
- * @param store
- * Store the object is saved in
- */
- void setStore(IPersistenceStore store);
-
- /**
- * Write the object to the passed output stream.
- *
- * @param output
- * Output stream to write to
- * @throws java.io.IOException Any I/O exception
- */
- void serialize(Output output) throws IOException;
-
- /**
- * Load the object from the passed input stream.
- *
- * @param input
- * Input stream to load from
- * @throws java.io.IOException Any I/O exception
- */
- void deserialize(Input input) throws IOException;
-
-}
diff --git a/src/main/java/org/red5/server/api/persistence/IPersistenceStore.java b/src/main/java/org/red5/server/api/persistence/IPersistenceStore.java
deleted file mode 100644
index eeae2a469..000000000
--- a/src/main/java/org/red5/server/api/persistence/IPersistenceStore.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.persistence;
-
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * Storage for persistent objects.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- * @author Joachim Bauch (jojo@struktur.de)
- */
-
-public interface IPersistenceStore {
-
- /**
- * Persist given object.
- *
- * @param obj Object to store
- * @return true on success, false otherwise
- */
- public boolean save(IPersistable obj);
-
- /**
- * Load a persistent object with the given name. The object must provide
- * either a constructor that takes an input stream as only parameter or an
- * empty constructor so it can be loaded from the persistence store.
- *
- * @param name the name of the object to load
- * @return The loaded object or null if no such object was
- * found
- */
- public IPersistable load(String name);
-
- /**
- * Load state of an already instantiated persistent object.
- *
- * @param obj the object to initializ
- * @return true if the object was initialized, false otherwise
- */
- public boolean load(IPersistable obj);
-
- /**
- * Delete the passed persistent object.
- *
- * @param obj the object to delete
- * @return true if object was persisted and thus can be removed, false otherwise
- */
- public boolean remove(IPersistable obj);
-
- /**
- * Delete the persistent object with the given name.
- *
- * @param name the name of the object to delete
- * @return true if object was persisted and thus can be removed, false otherwise
- */
- public boolean remove(String name);
-
- /**
- * Return iterator over the names of all already loaded objects in the
- * storage.
- *
- * @return Set of all object names
- */
- public Set getObjectNames();
-
- /**
- * Return iterator over the already loaded objects in the storage.
- *
- * @return Set of all objects
- */
- public Collection getObjects();
-
- /**
- * Notify store that it's being closed. This allows the store to write
- * any pending objects to disk.
- */
- public void notifyClose();
-
-}
diff --git a/src/main/java/org/red5/server/api/persistence/PersistenceUtils.java b/src/main/java/org/red5/server/api/persistence/PersistenceUtils.java
deleted file mode 100644
index 0747faf28..000000000
--- a/src/main/java/org/red5/server/api/persistence/PersistenceUtils.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.persistence;
-
-import java.lang.reflect.Constructor;
-
-import org.springframework.core.io.support.ResourcePatternResolver;
-
-/**
- * Helper class for persistence.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public class PersistenceUtils {
-
- /**
- * Returns persistence store object class constructor
- *
- * @param theClass Persistence store class
- * @param interfaces Interfaces that are being implemented by persistence store object class
- * @return Constructor
- * @throws Exception
- */
- private static Constructor> getPersistenceStoreConstructor(Class> theClass, Class>[] interfaces) throws Exception {
- Constructor> constructor = null;
- for (Class> interfaceClass : interfaces) {
- try {
- constructor = theClass.getConstructor(new Class[] { interfaceClass });
- } catch (NoSuchMethodException err) {
- // Ignore this error
- }
- if (constructor != null) {
- break;
- }
- constructor = getPersistenceStoreConstructor(theClass, interfaceClass.getInterfaces());
- if (constructor != null) {
- break;
- }
- }
- return constructor;
- }
-
- /**
- * Returns persistence store object. Persistence store is a special object
- * that stores persistence objects and provides methods to manipulate them
- * (save, load, remove, list).
- *
- * @param resolver Resolves connection pattern into Resource object
- * @param className Name of persistence class
- * @return IPersistence store object that provides methods for persistence object handling
- * @throws Exception if error
- */
- public static IPersistenceStore getPersistenceStore(ResourcePatternResolver resolver, String className) throws Exception {
- Class> persistenceClass = Class.forName(className);
- Constructor> constructor = getPersistenceStoreConstructor(persistenceClass, resolver.getClass().getInterfaces());
- if (constructor == null) {
- // Search in superclasses of the object.
- Class> superClass = resolver.getClass().getSuperclass();
- while (superClass != null) {
- constructor = getPersistenceStoreConstructor(persistenceClass, superClass.getInterfaces());
- if (constructor != null) {
- break;
- }
- superClass = superClass.getSuperclass();
- }
- }
- if (constructor == null) {
- throw new NoSuchMethodException();
- }
- return (IPersistenceStore) constructor.newInstance(new Object[] { resolver });
- }
-
-}
diff --git a/src/main/java/org/red5/server/api/remoting/IRemotingHeader.java b/src/main/java/org/red5/server/api/remoting/IRemotingHeader.java
deleted file mode 100644
index 5b8174c60..000000000
--- a/src/main/java/org/red5/server/api/remoting/IRemotingHeader.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.remoting;
-
-/**
- * A Remoting header.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IRemotingHeader {
-
- /** Name of header specifying string to add to gateway url. */
- public static final String APPEND_TO_GATEWAY_URL = "AppendToGatewayUrl";
-
- /** Name of header specifying new gateway url to use. */
- public static final String REPLACE_GATEWAY_URL = "ReplaceGatewayUrl";
-
- /** Name of header specifying new header to send. */
- public static final String PERSISTENT_HEADER = "RequestPersistentHeader";
-
- /** Name of header containing authentication data. */
- public static final String CREDENTIALS = "Credentials";
-
- /** Name of header to request debug informations from the server. */
- public static final String DEBUG_SERVER = "amf_server_debug";
-
- /**
- * Return name of header.
- *
- * @return name of header
- */
- public String getName();
-
- /**
- * Return value of header.
- *
- * @return value of header
- */
- public Object getValue();
-
- /**
- * Return boolean flag if receiver must process header before handling
- * other headers or messages.
- *
- * @return must understand
- */
- public boolean getMustUnderstand();
-
-}
diff --git a/src/main/java/org/red5/server/api/scheduling/IScheduledJob.java b/src/main/java/org/red5/server/api/scheduling/IScheduledJob.java
deleted file mode 100644
index 739d19bce..000000000
--- a/src/main/java/org/red5/server/api/scheduling/IScheduledJob.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.scheduling;
-
-/**
- * Interface that must be implemented by classes that can be scheduled for
- * periodic execution.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IScheduledJob {
-
- /**
- * Called each time the job is triggered by the scheduling service.
- *
- * @param service the service that called the job
- * @throws CloneNotSupportedException throws if Darth Vader attempts to use
- * this object for his own nefarious purposes.
- */
- public void execute(ISchedulingService service) throws CloneNotSupportedException;
-
-}
diff --git a/src/main/java/org/red5/server/api/scheduling/ISchedulingService.java b/src/main/java/org/red5/server/api/scheduling/ISchedulingService.java
deleted file mode 100644
index 417defcfb..000000000
--- a/src/main/java/org/red5/server/api/scheduling/ISchedulingService.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.scheduling;
-
-import java.util.Date;
-import java.util.List;
-
-import org.red5.server.api.scope.IScopeService;
-
-/**
- * Service that supports periodic execution of jobs, adding, removing and
- * getting their name as list.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- * @author Paul Gregoire (mondain@gmail.com)
- */
-public interface ISchedulingService extends IScopeService {
-
- public static String BEAN_NAME = "schedulingService";
-
- /**
- * Schedule a job for periodic execution.
- *
- * @param interval time in milliseconds between two notifications of the job
- * @param job the job to trigger periodically
- * @return the name of the scheduled job
- */
- public String addScheduledJob(int interval, IScheduledJob job);
-
- /**
- * Schedule a job for single execution in the future. Please note
- * that the jobs are not saved if Red5 is restarted in the meantime.
- *
- * @param timeDelta time delta in milliseconds from the current date
- * @param job the job to trigger
- * @return the name of the scheduled job
- */
- public String addScheduledOnceJob(long timeDelta, IScheduledJob job);
-
- /**
- * Schedule a job for single execution at a given date. Please note
- * that the jobs are not saved if Red5 is restarted in the meantime.
- *
- * @param date date when the job should be executed
- * @param job the job to trigger
- * @return the name of the scheduled job
- */
- public String addScheduledOnceJob(Date date, IScheduledJob job);
-
- /**
- * Schedule a job for periodic execution which will start after the specifed delay.
- *
- * @param interval time in milliseconds between two notifications of the job
- * @param job the job to trigger periodically
- * @param delay time in milliseconds to pass before first execution.
- * @return
- * the name of the scheduled job
- */
- public String addScheduledJobAfterDelay(int interval, IScheduledJob job, int delay);
-
- /**
- * Pauses the trigger which initiates job execution.
- *
- * @param name name of the job to stop
- */
- public void pauseScheduledJob(String name);
-
- /**
- * Resumes the trigger which initiates job execution.
- *
- * @param name name of the job to stop
- */
- public void resumeScheduledJob(String name);
-
- /**
- * Stop executing a previously scheduled job.
- *
- * @param name name of the job to stop
- */
- public void removeScheduledJob(String name);
-
- /**
- * Return names of scheduled jobs.
- *
- * @return list of job names
- */
- public List getScheduledJobNames();
-
-}
diff --git a/src/main/java/org/red5/server/api/scope/IBasicScope.java b/src/main/java/org/red5/server/api/scope/IBasicScope.java
deleted file mode 100644
index dc223c2d5..000000000
--- a/src/main/java/org/red5/server/api/scope/IBasicScope.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.scope;
-
-import org.red5.server.api.ICoreObject;
-import org.red5.server.api.event.IEventObservable;
-import org.red5.server.api.persistence.IPersistenceStore;
-
-/**
- * Base interface for all scope objects, including SharedObjects.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- */
-public interface IBasicScope extends ICoreObject, IEventObservable {
-
- /**
- * Does this scope have a parent? You can think of scopes as of tree items
- * where scope may have a parent and children (child).
- *
- * @return true if this scope has a parent, otherwise
- * false
- */
- public boolean hasParent();
-
- /**
- * Get this scopes parent.
- *
- * @return parent scope, or null if this scope doesn't have a
- * parent
- */
- public IScope getParent();
-
- /**
- * Get the scopes depth, how far down the scope tree is it. The lowest depth
- * is 0x00, the depth of Global scope. Application scope depth is 0x01. Room
- * depth is 0x02, 0x03 and so forth.
- *
- * @return the depth
- */
- public int getDepth();
-
- /**
- * Get the name of this scope. Eg. someroom.
- *
- * @return the name
- */
- public String getName();
-
- /**
- * Get the persistable store
- * @return the store
- */
- public IPersistenceStore getStore();
-
- /**
- * Get the full absolute path. Eg. host/myapp/someroom.
- *
- * @return Absolute scope path
- */
- public String getPath();
-
- /**
- * Get the type of the scope.
- *
- * @return Type of scope
- */
- public ScopeType getType();
-
- /**
- * Sets the amount of time to keep the scope available after the
- * last disconnect.
- *
- * @param keepDelay delay
- */
- public void setKeepDelay(int keepDelay);
-
- /**
- * Validates a scope based on its name and type
- *
- * @return true if both name and type are valid, false otherwise
- */
- public boolean isValid();
-
-}
diff --git a/src/main/java/org/red5/server/api/scope/IBroadcastScope.java b/src/main/java/org/red5/server/api/scope/IBroadcastScope.java
deleted file mode 100644
index 1f8d0e81a..000000000
--- a/src/main/java/org/red5/server/api/scope/IBroadcastScope.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.red5.server.api.scope;
-
-import org.red5.server.api.stream.IClientBroadcastStream;
-import org.red5.server.messaging.IPipe;
-
-/**
- * Broadcast scope is marker interface that represents object that works as basic scope and
- * has pipe connection event dispatching capabilities.
- */
-public interface IBroadcastScope extends IBasicScope, IPipe {
-
- public IClientBroadcastStream getClientBroadcastStream();
-
- public void setClientBroadcastStream(IClientBroadcastStream clientBroadcastStream);
-
-}
diff --git a/src/main/java/org/red5/server/api/scope/IGlobalScope.java b/src/main/java/org/red5/server/api/scope/IGlobalScope.java
deleted file mode 100644
index 7afcc6384..000000000
--- a/src/main/java/org/red5/server/api/scope/IGlobalScope.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.scope;
-
-import org.red5.server.api.IServer;
-
-/**
- * The global scope that acts as root for all applications in a host.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- *
- */
-public interface IGlobalScope extends IScope {
-
- /**
- * Register the global scope in the server and initialize it
- */
- public void register();
-
- /**
- * Return the server this global scope runs in.
- *
- * @return the server
- */
- public IServer getServer();
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/scope/IScope.java b/src/main/java/org/red5/server/api/scope/IScope.java
deleted file mode 100644
index c190df52c..000000000
--- a/src/main/java/org/red5/server/api/scope/IScope.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.scope;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import org.red5.server.api.IClient;
-import org.red5.server.api.IConnection;
-import org.red5.server.api.IContext;
-import org.red5.server.api.service.IServiceHandlerProvider;
-import org.red5.server.api.statistics.IScopeStatistics;
-import org.springframework.core.io.support.ResourcePatternResolver;
-
-/**
- * The scope object.
- *
- * A stateful object shared between a group of clients connected to the same
- * context path. Scopes are arranged in hierarchical way, so its possible for
- * a scope to have a parent and children scopes. If a client connects to a scope then they are
- * also connected to its parent scope. The scope object is used to access
- * resources, shared object, streams, etc. That is, scope are general option for grouping things
- * in application.
- *
- * The following are all names for scopes: application, room, place, lobby.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- */
-public interface IScope extends IBasicScope, ResourcePatternResolver, IServiceHandlerProvider {
-
- /**
- * Scope separator
- */
- public static final String SEPARATOR = ":";
-
- /**
- * Check to see if this scope has a child scope matching a given name.
- *
- * @param name the name of the child scope
- * @return true if a child scope exists, otherwise
- * false
- */
- public boolean hasChildScope(String name);
-
- /**
- * Checks whether scope has a child scope with given name and type
- *
- * @param type Child scope type
- * @param name Child scope name
- * @return true if a child scope exists, otherwise
- * false
- */
- public boolean hasChildScope(ScopeType type, String name);
-
- /**
- * Creates child scope with name given and returns success value. Returns
- * true on success, false if given scope
- * already exists among children.
- *
- * @param name New child scope name
- * @return true if child scope was successfully creates,
- * false otherwise
- */
- public boolean createChildScope(String name);
-
- /**
- * Adds scope as a child scope. Returns true on success,
- * false if given scope is already a child of current.
- *
- * @param scope Scope given
- * @return true if child scope was successfully added,
- * false otherwise
- */
- public boolean addChildScope(IBasicScope scope);
-
- /**
- * Removes scope from the children scope list.
- *
- * @param scope Scope given
- */
- public void removeChildScope(IBasicScope scope);
-
- /**
- * Removes all the child scopes
- */
- public void removeChildren();
-
- /**
- * Get a set of the child scope names.
- *
- * @return set containing child scope names
- */
- public Set getScopeNames();
-
- public Set getBasicScopeNames(ScopeType type);
-
- /**
- * Return the broadcast scope for a given name
- *
- * @param name
- * @return broadcast scope or null if not found
- */
- public IBroadcastScope getBroadcastScope(String name);
-
- /**
- * Get a child scope by type and name.
- *
- * @param type Child scope type
- * @param name Name of the child scope
- * @return the child scope, or null if no scope is found
- */
- public IBasicScope getBasicScope(ScopeType type, String name);
-
- /**
- * Return scope by name
- *
- * @param name Scope name
- * @return Scope with given name
- */
- public IScope getScope(String name);
-
- /**
- * Get a set of connected clients. You can get the connections by passing
- * the scope to the clients {@link IClient#getConnections()} method.
- *
- * @return Set containing all connected clients
- * @see org.red5.server.api.IClient#getConnections(IScope)
- */
- public Set getClients();
-
- /**
- * Get a connection iterator. You can call remove, and the connection will
- * be closed.
- *
- * @deprecated Use {@link IScope#getClientConnections()} instead
- * @return Iterator holding all connections
- */
- @Deprecated
- public Collection> getConnections();
-
- /**
- * Get all current connections. You can call remove, and the connection will
- * be closed.
- *
- * @return Set containing all connections
- */
- public Set getClientConnections();
-
- /**
- * Lookup connections.
- *
- * @deprecated Use {@link IScope#lookupConnection(IClient)} instead
- * @param client object
- * @return Set of connection objects (read-only)
- */
- @Deprecated
- public Set lookupConnections(IClient client);
-
- /**
- * Lookup connection for a given client.
- *
- * @param client object
- * @return connection object
- */
- public IConnection lookupConnection(IClient client);
-
- /**
- * Returns scope context
- *
- * @return Scope context
- */
- public IContext getContext();
-
- /**
- * Checks whether scope has handler or not.
- *
- * @return true if scope has a handler, false
- * otherwise
- */
- public boolean hasHandler();
-
- /**
- * Return handler of the scope
- *
- * @return Scope handler
- */
- public IScopeHandler getHandler();
-
- /**
- * Return context path.
- *
- * @return Context path
- */
- public String getContextPath();
-
- /**
- * Adds given connection to the scope
- *
- * @param conn Given connection
- * @return true on success, false if given
- * connection already belongs to this scope
- */
- public boolean connect(IConnection conn);
-
- /**
- * Add given connection to the scope, overloaded for parameters pass case.
- * @param conn Given connection
- * @param params Parameters passed
- * @return true on success, false if given
- * connection already belongs to this scope
- */
- public boolean connect(IConnection conn, Object[] params);
-
- /**
- * Removes given connection from list of scope connections. This disconnects
- * all clients of given connection from the scope.
- *
- * @param conn Connection given
- */
- public void disconnect(IConnection conn);
-
- /**
- * Return statistics informations about the scope.
- *
- * @return statistics
- */
- public IScopeStatistics getStatistics();
-
- /**
- * Set attribute by name
- *
- * @param name
- * @param value
- * @return true if added, false if not added
- */
- public boolean setAttribute(String name, Object value);
-
- /**
- * Get attribute by name
- *
- * @param name
- * @return value for the given name in the attributes or null if not found
- */
- public Object getAttribute(String name);
-
- /**
- * Whether or not an attribute exists, keyed by the given name
- *
- * @param name
- * @return true if it exists, false otherwise
- */
- public boolean hasAttribute(String name);
-
- /**
- * Remove attribute by name
- *
- * @param name
- * @return true if removed, false otherwise
- */
- public boolean removeAttribute(String name);
-
- /**
- * Return attribute names
- *
- * @return attribute names
- */
- public Set getAttributeNames();
-
- /**
- * Return scope attributes
- *
- * @return attributes
- */
- public Map getAttributes();
-
-}
diff --git a/src/main/java/org/red5/server/api/scope/IScopeAware.java b/src/main/java/org/red5/server/api/scope/IScopeAware.java
deleted file mode 100644
index 28ad0187d..000000000
--- a/src/main/java/org/red5/server/api/scope/IScopeAware.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.scope;
-
-/**
- * Maker interface for all objects that are aware of the scope they are located
- * in.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- */
-public interface IScopeAware {
-
- /**
- * Set the scope the object is located in.
- *
- * @param scope Scope for this object
- */
- public void setScope(IScope scope);
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/scope/IScopeHandler.java b/src/main/java/org/red5/server/api/scope/IScopeHandler.java
deleted file mode 100644
index 0126adfa2..000000000
--- a/src/main/java/org/red5/server/api/scope/IScopeHandler.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.scope;
-
-import org.red5.server.api.IClient;
-import org.red5.server.api.IConnection;
-import org.red5.server.api.event.IEventHandler;
-import org.red5.server.api.service.IServiceCall;
-
-/**
- * The scope handler controls actions performed against a scope object, and also
- * is notified of all events.
- *
- * Gives fine grained control over what actions can be performed with the can*
- * methods. Allows for detailed reporting on what is happening within the scope
- * with the on* methods. This is the core interface users implement to create
- * applications.
- *
- * The thread local connection is always available via the Red5 object within
- * these methods
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- */
-public interface IScopeHandler extends IEventHandler {
-
- /**
- * Called when a scope is created for the first time.
- *
- * @param scope
- * the new scope object
- * @return true to allow, false to deny
- */
- boolean start(IScope scope);
-
- /**
- * Called just before a scope is disposed.
- * @param scope Scope that id disposed
- */
- void stop(IScope scope);
-
- /**
- * Called just before every connection to a scope. You can pass additional
- * params from client using NetConnection.connect method (see
- * below).
- *
- * @param conn
- * Connection object
- * @param params
- * List of params passed from client via
- * NetConnection.connect method. All parameters
- * but the first one passed to NetConnection.connect
- * method are available as params array.
- *
- *
- * @return true to allow, false to deny
- * @param scope Scope object
- */
- boolean connect(IConnection conn, IScope scope, Object[] params);
-
- /**
- * Called just after the a connection is disconnected.
- *
- * @param conn
- * Connection object
- * @param scope
- * Scope object
- */
- void disconnect(IConnection conn, IScope scope);
-
- /**
- * Called just before a child scope is added.
- *
- * @param scope
- * Scope that will be added
- * @return true to allow, false to deny
- */
- boolean addChildScope(IBasicScope scope);
-
- /**
- * Called just after a child scope has been removed.
- *
- * @param scope
- * Scope that has been removed
- */
- void removeChildScope(IBasicScope scope);
-
- /**
- * Called just before a client enters the scope.
- *
- * @param client
- * Client object
- * @return true to allow, false to deny
- * connection
- * @param scope Scope that is joined by client
- */
- boolean join(IClient client, IScope scope);
-
- /**
- * Called just after the client leaves the scope.
- *
- * @param client
- * Client object
- * @param scope
- * Scope object
- */
- void leave(IClient client, IScope scope);
-
- /**
- * Called when a service is called.
- *
- * @param conn
- * The connection object
- * @param call
- * The call object.
- *
- * @return true to allow, false to deny
- */
- boolean serviceCall(IConnection conn, IServiceCall call);
-
-}
diff --git a/src/main/java/org/red5/server/api/scope/IScopeService.java b/src/main/java/org/red5/server/api/scope/IScopeService.java
deleted file mode 100644
index 59d1d2bb6..000000000
--- a/src/main/java/org/red5/server/api/scope/IScopeService.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.red5.server.api.scope;
-
-/**
- * Base marker interface for all scope services. Used by the ScopeUtils to lookup
- * services defined as beans in Spring application context. A scope service usually can perform various
- * tasks on a scope like managing shared objects, streams, etc.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (bauch@struktur.de)
- */
-public interface IScopeService {
-
- /**
- * Name of a bean defining that scope service. Override in
- * subinterfaces.
- * */
- public static String BEAN_NAME = null;
-
-}
diff --git a/src/main/java/org/red5/server/api/scope/ScopeType.java b/src/main/java/org/red5/server/api/scope/ScopeType.java
deleted file mode 100644
index 4d8aa85d6..000000000
--- a/src/main/java/org/red5/server/api/scope/ScopeType.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.red5.server.api.scope;
-
-/**
- * Represents all the supported scope types.
- *
- * @author Paul Gregoire (mondain@gmail.com)
- */
-public enum ScopeType {
-
- UNDEFINED, GLOBAL, APPLICATION, ROOM, BROADCAST, SHARED_OBJECT;
-
-}
diff --git a/src/main/java/org/red5/server/api/service/IPendingServiceCall.java b/src/main/java/org/red5/server/api/service/IPendingServiceCall.java
deleted file mode 100644
index b5aee9745..000000000
--- a/src/main/java/org/red5/server/api/service/IPendingServiceCall.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.service;
-
-import java.util.Set;
-
-/**
- * IPendingServiceCall is a call that have a list of callbacks.
- *
- *
- */
-public interface IPendingServiceCall extends IServiceCall {
-
- /**
- * Returns service call result
- *
- * @return Remote call result
- */
- public abstract Object getResult();
-
- /**
- * Setter for property 'result'.
- *
- * @param result Value to set for property 'result'.
- */
- public abstract void setResult(Object result);
-
- /**
- * Registers callback object usually represented as an anonymous class
- * instance that implements IPendingServiceCallback interface.
- *
- * @param callback Callback object
- */
- public void registerCallback(IPendingServiceCallback callback);
-
- /**
- * Unregisters callback object usually represented as an anonymous class
- * instance that implements IPendingServiceCallback interface.
- *
- * @param callback Callback object
- */
- public void unregisterCallback(IPendingServiceCallback callback);
-
- /**
- * Returns list of callback objects, usually callback object represented as
- * an anonymous class instance that implements IPendingServiceCallback
- * interface.
- *
- * @return Set of pending operations callbacks
- */
- public Set getCallbacks();
-}
diff --git a/src/main/java/org/red5/server/api/service/IPendingServiceCallback.java b/src/main/java/org/red5/server/api/service/IPendingServiceCallback.java
deleted file mode 100644
index 24ff2e5b9..000000000
--- a/src/main/java/org/red5/server/api/service/IPendingServiceCallback.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.service;
-
-/**
- * Callback that will be executed when the result of a pending service call
- * has been received.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- *
- */
-public interface IPendingServiceCallback {
-
- /**
- * Triggered when results are recieved
- *
- * @param call Call object this callback is applied to
- */
- public void resultReceived(IPendingServiceCall call);
-
-}
diff --git a/src/main/java/org/red5/server/api/service/IServiceCall.java b/src/main/java/org/red5/server/api/service/IServiceCall.java
deleted file mode 100644
index 6005e5835..000000000
--- a/src/main/java/org/red5/server/api/service/IServiceCall.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.service;
-
-/**
- * Container for a Service Call
- */
-public interface IServiceCall {
-
- /**
- * Whether call was successful or not
- *
- * @return true on success, false otherwise
- */
- public abstract boolean isSuccess();
-
- /**
- * Returns service method name
- *
- * @return Service method name as string
- */
- public abstract String getServiceMethodName();
-
- /**
- * Returns service name
- *
- * @return Service name
- */
- public abstract String getServiceName();
-
- /**
- * Returns array of service method arguments
- *
- * @return array of service method arguments
- */
- public abstract Object[] getArguments();
-
- /**
- * Get service call status
- *
- * @return service call status
- */
- public abstract byte getStatus();
-
- /**
- * Returns the time stamp at which this object was deserialized.
- *
- * @return the readTime
- */
- public long getReadTime();
-
- /**
- * Returns the time stamp at which this object was serialized.
- *
- * @return the writeTime
- */
- public long getWriteTime();
-
- /**
- * Get service call exception
- *
- * @return service call exception
- */
- public abstract Exception getException();
-
- /**
- * Sets status
- *
- * @param status Status as byte
- */
- public abstract void setStatus(byte status);
-
- /**
- * Sets exception
- *
- * @param exception Call exception
- */
- public abstract void setException(Exception exception);
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/service/IServiceCapableConnection.java b/src/main/java/org/red5/server/api/service/IServiceCapableConnection.java
deleted file mode 100644
index 4e4f90f65..000000000
--- a/src/main/java/org/red5/server/api/service/IServiceCapableConnection.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.service;
-
-import org.red5.server.api.IConnection;
-import org.red5.server.net.rtmp.status.Status;
-
-/**
- * Connection that has options to invoke and handle remote calls
- */
-// TODO: this should really extend IServiceInvoker
-public interface IServiceCapableConnection extends IConnection {
- /**
- * Invokes service using remoting call object
- * @param call Service call object
- */
- void invoke(IServiceCall call);
-
- /**
- * Invoke service using call and channel
- * @param call Service call
- * @param channel Channel used
- */
- void invoke(IServiceCall call, int channel);
-
- /**
- * Invoke method by name
- * @param method Called method name
- */
- void invoke(String method);
-
- /**
- * Invoke method by name with callback
- * @param method Called method name
- * @param callback Callback
- */
- void invoke(String method, IPendingServiceCallback callback);
-
- /**
- * Invoke method with parameters
- * @param method Method name
- * @param params Invocation parameters passed to method
- */
- void invoke(String method, Object[] params);
-
- /**
- *
- * @param method
- * @param params
- * @param callback
- */
- void invoke(String method, Object[] params, IPendingServiceCallback callback);
-
- /**
- *
- * @param call
- */
- void notify(IServiceCall call);
-
- /**
- *
- * @param call
- * @param channel
- */
- void notify(IServiceCall call, int channel);
-
- /**
- *
- * @param method
- */
- void notify(String method);
-
- /**
- *
- * @param method
- * @param params
- */
- void notify(String method, Object[] params);
-
- /**
- * Sends a status object to the connection
- * @param status
- */
- void status(Status status);
-
- /**
- * Sends a status object to the connection on a given channel
- * @param status
- * @param channel
- */
- void status(Status status, int channel);
-}
diff --git a/src/main/java/org/red5/server/api/service/IServiceHandlerProvider.java b/src/main/java/org/red5/server/api/service/IServiceHandlerProvider.java
deleted file mode 100644
index 20cf93b5b..000000000
--- a/src/main/java/org/red5/server/api/service/IServiceHandlerProvider.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.service;
-
-import java.util.Set;
-
-/**
- * Supports registration and lookup of service handlers.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- *
- */
-public interface IServiceHandlerProvider {
-
- /**
- * Register an object that provides methods which can be called from a
- * client.
- *
- *
- * Example:
- * If you registered a handler with the name "one.two" that
- * provides a method "callMe", you can call a method
- * "one.two.callMe" from the client.
- *
- * @param name the name of the handler
- * @param handler the handler object
- */
- public void registerServiceHandler(String name, Object handler);
-
- /**
- * Unregister service handler.
- *
- * @param name the name of the handler
- */
- public void unregisterServiceHandler(String name);
-
- /**
- * Return a previously registered service handler.
- *
- * @param name the name of the handler to return
- * @return the previously registered handler
- */
- public Object getServiceHandler(String name);
-
- /**
- * Get list of registered service handler names.
- *
- * @return the names of the registered handlers
- */
- public Set getServiceHandlerNames();
-
-}
diff --git a/src/main/java/org/red5/server/api/service/IServiceInvoker.java b/src/main/java/org/red5/server/api/service/IServiceInvoker.java
deleted file mode 100644
index d24f37145..000000000
--- a/src/main/java/org/red5/server/api/service/IServiceInvoker.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.service;
-
-import org.red5.server.api.scope.IScope;
-
-/**
- * Interface for objects that execute service calls (remote calls from client).
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- */
-public interface IServiceInvoker {
-
- /**
- * Execute the passed service call in the given scope. This looks up the
- * handler for the call in the scope and the context of the scope.
- *
- * @param call
- * the call to invoke
- * @param scope
- * the scope to search for a handler
- * @return true if the call was performed, otherwise false
- */
- boolean invoke(IServiceCall call, IScope scope);
-
- /**
- * Execute the passed service call in the given object.
- *
- * @param call
- * the call to invoke
- * @param service
- * the service to use
- * @return true if the call was performed, otherwise false
- */
- boolean invoke(IServiceCall call, Object service);
-
-}
diff --git a/src/main/java/org/red5/server/api/service/IStreamSecurityService.java b/src/main/java/org/red5/server/api/service/IStreamSecurityService.java
deleted file mode 100644
index d21b189b5..000000000
--- a/src/main/java/org/red5/server/api/service/IStreamSecurityService.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.service;
-
-import java.util.Set;
-
-import org.red5.server.api.scope.IScopeService;
-import org.red5.server.api.stream.IStreamPlaybackSecurity;
-import org.red5.server.api.stream.IStreamPublishSecurity;
-
-/**
- * Service that supports protecting access to streams.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IStreamSecurityService extends IScopeService {
-
- /**
- * Name of a bean defining that scope service.
- * */
- public static final String BEAN_NAME = "streamSecurityService";
-
- /**
- * Add handler that protects stream publishing.
- *
- * @param handler Handler to add.
- */
- public void registerStreamPublishSecurity(IStreamPublishSecurity handler);
-
- /**
- * Remove handler that protects stream publishing.
- *
- * @param handler Handler to remove.
- */
- public void unregisterStreamPublishSecurity(IStreamPublishSecurity handler);
-
- /**
- * Get handlers that protect stream publishing.
- *
- * @return list of handlers
- */
- public Set getStreamPublishSecurity();
-
- /**
- * Add handler that protects stream playback.
- *
- * @param handler Handler to add.
- */
- public void registerStreamPlaybackSecurity(IStreamPlaybackSecurity handler);
-
- /**
- * Remove handler that protects stream playback.
- *
- * @param handler Handler to remove.
- */
- public void unregisterStreamPlaybackSecurity(IStreamPlaybackSecurity handler);
-
- /**
- * Get handlers that protect stream plaback.
- *
- * @return list of handlers
- */
- public Set getStreamPlaybackSecurity();
-
-}
diff --git a/src/main/java/org/red5/server/api/service/IStreamableFileService.java b/src/main/java/org/red5/server/api/service/IStreamableFileService.java
deleted file mode 100644
index 45679567b..000000000
--- a/src/main/java/org/red5/server/api/service/IStreamableFileService.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.service;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.red5.io.IStreamableFile;
-
-/**
- * Provides access to files that can be streamed.
- */
-public interface IStreamableFileService {
-
- /**
- * Sets the prefix.
- *
- * @param prefix
- */
- public void setPrefix(String prefix);
-
- /**
- * Getter for prefix. Prefix is used in filename composition to fetch real file name.
- *
- * @return Prefix
- */
- public String getPrefix();
-
- /**
- * Sets the file extensions serviced. If there are more than one, they are separated
- * by commas.
- *
- * @param extension
- */
- public void setExtension(String extension);
-
- /**
- * Getter for extension of file
- *
- * @return File extension that is used
- */
- public String getExtension();
-
- /**
- * Prepair given string to conform filename requirements, for example, add
- * extension to the end if missing.
- * @param name String to format
- * @return Correct filename
- */
- public String prepareFilename(String name);
-
- /**
- * Check whether file can be used by file service, that is, it does exist and have valid extension
- * @param file File object
- * @return true if file exist and has valid extension,
- * false otherwise
- */
- public boolean canHandle(File file);
-
- /**
- * Return streamable file reference. For FLV files returned streamable file already has
- * generated metadata injected.
- *
- * @param file File resource
- * @return Streamable file resource
- * @throws IOException Thrown if there were problems accessing given file
- */
- public IStreamableFile getStreamableFile(File file) throws IOException;
-
-}
diff --git a/src/main/java/org/red5/server/api/so/IClientSharedObject.java b/src/main/java/org/red5/server/api/so/IClientSharedObject.java
deleted file mode 100644
index e526ad2bd..000000000
--- a/src/main/java/org/red5/server/api/so/IClientSharedObject.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.so;
-
-import org.red5.server.api.IConnection;
-
-/**
- * Clientside access to shared objects.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-
-public interface IClientSharedObject extends ISharedObjectBase {
-
- /**
- * Connect the shared object using the passed connection.
- *
- * @param conn connect to connect to
- */
- public void connect(IConnection conn);
-
- /**
- * Check if the shared object is connected to the server.
- *
- * @return is connected
- */
- public boolean isConnected();
-
- /**
- * Disconnect the shared object.
- */
- public void disconnect();
-
-}
diff --git a/src/main/java/org/red5/server/api/so/ISharedObject.java b/src/main/java/org/red5/server/api/so/ISharedObject.java
deleted file mode 100644
index a7bd30780..000000000
--- a/src/main/java/org/red5/server/api/so/ISharedObject.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.so;
-
-import org.red5.server.api.scope.IBasicScope;
-import org.red5.server.api.statistics.ISharedObjectStatistics;
-
-/**
- * Serverside access to shared objects.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-
-public interface ISharedObject extends IBasicScope, ISharedObjectBase, ISharedObjectSecurityService {
-
- /**
- * Prevent shared object from being released. Each call to acquire
- * must be paired with a call to release so the SO isn't held
- * forever.
- *
- * This method basically is a noop for persistent SOs as their data is stored
- * and they can be released without losing their contents.
- */
- public void acquire();
-
- /**
- * Check if shared object currently is acquired.
- *
- * @return true if the SO is acquired, otherwise false
- */
- public boolean isAcquired();
-
- /**
- * Release previously acquired shared object. If the SO is non-persistent,
- * no more clients are connected the SO isn't acquired any more, the data
- * is released.
- */
- public void release();
-
- /**
- * Return statistics about the shared object.
- *
- * @return statistics
- */
- public ISharedObjectStatistics getStatistics();
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/so/ISharedObjectBase.java b/src/main/java/org/red5/server/api/so/ISharedObjectBase.java
deleted file mode 100644
index 993c8af31..000000000
--- a/src/main/java/org/red5/server/api/so/ISharedObjectBase.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.so;
-
-import java.util.List;
-import java.util.Map;
-
-import org.red5.server.api.ICastingAttributeStore;
-import org.red5.server.api.event.IEventListener;
-
-/**
- * Base interface for shared objects. Changes to the shared objects are
- * propagated to all subscribed clients.
- *
- * If you want to modify multiple attributes and notify the clients about all
- * changes at once, you can use code like this:
- *
- *
- * All changes between "beginUpdate" and "endUpdate" will be sent to the clients
- * using one notification event.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-
-public interface ISharedObjectBase extends ISharedObjectHandlerProvider, ICastingAttributeStore {
-
- /**
- * Returns the version of the shared object. The version is incremented
- * automatically on each modification.
- *
- * @return the version of the shared object
- */
- public int getVersion();
-
- /**
- * Check if the object has been created as persistent shared object by the
- * client.
- *
- * @return true if the shared object is persistent, false otherwise
- */
- public boolean isPersistent();
-
- /**
- * Return a map containing all attributes of the shared object.
- * NOTE: The returned map will be read-only.
- *
- * @return a map containing all attributes of the shared object
- */
- public Map getData();
-
- /**
- * Send a message to a handler of the shared object.
- *
- * @param handler the name of the handler to call
- * @param arguments a list of objects that should be passed as arguments to the
- * handler
- */
- public void sendMessage(String handler, List> arguments);
-
- /**
- * Start performing multiple updates to the shared object from serverside
- * code.
- */
- public void beginUpdate();
-
- /**
- * Start performing multiple updates to the shared object from a connected
- * client.
- * @param source Update events listener
- */
- public void beginUpdate(IEventListener source);
-
- /**
- * The multiple updates are complete, notify clients about all changes at
- * once.
- */
- public void endUpdate();
-
- /**
- * Register object that will be notified about update events.
- *
- * @param listener the object to notify
- */
- public void addSharedObjectListener(ISharedObjectListener listener);
-
- /**
- * Unregister object to not longer receive update events.
- *
- * @param listener the object to unregister
- */
- public void removeSharedObjectListener(ISharedObjectListener listener);
-
- /**
- * Locks the shared object instance. Prevents any changes to this object by
- * clients until the SharedObject.unlock() method is called.
- */
- public void lock();
-
- /**
- * Unlocks a shared object instance that was locked with
- * SharedObject.lock().
- */
- public void unlock();
-
- /**
- * Returns the locked state of this SharedObject.
- *
- * @return true if in a locked state; false otherwise
- */
- public boolean isLocked();
-
- /**
- * Deletes all the attributes and sends a clear event to all listeners. The
- * persistent data object is also removed from a persistent shared object.
- *
- * @return true if successful; false otherwise
- */
- public boolean clear();
-
- /**
- * Detaches a reference from this shared object, this will destroy the
- * reference immediately. This is useful when you don't want to proxy a
- * shared object any longer.
- */
- public void close();
-
-}
diff --git a/src/main/java/org/red5/server/api/so/ISharedObjectHandlerProvider.java b/src/main/java/org/red5/server/api/so/ISharedObjectHandlerProvider.java
deleted file mode 100644
index 23b320b13..000000000
--- a/src/main/java/org/red5/server/api/so/ISharedObjectHandlerProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.so;
-
-import org.red5.server.api.service.IServiceHandlerProvider;
-
-/**
- * Supports registration and lookup of shared object handlers.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- *
- */
-public interface ISharedObjectHandlerProvider extends IServiceHandlerProvider {
-
- /**
- * Register an object that provides methods which handle calls without
- * a service name to a shared object.
- *
- * @param handler the handler object
- */
- public void registerServiceHandler(Object handler);
-
- /**
- * Unregister the shared object handler for calls without a service name.
- */
- public void unregisterServiceHandler(String name);
-
-}
diff --git a/src/main/java/org/red5/server/api/so/ISharedObjectListener.java b/src/main/java/org/red5/server/api/so/ISharedObjectListener.java
deleted file mode 100644
index c7cf33090..000000000
--- a/src/main/java/org/red5/server/api/so/ISharedObjectListener.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.so;
-
-import java.util.List;
-import java.util.Map;
-
-import org.red5.server.api.IAttributeStore;
-
-/**
- * Notifications about shared object updates.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface ISharedObjectListener {
-
- /**
- * Called when a client connects to a shared object.
- *
- * @param so
- * the shared object
- */
- void onSharedObjectConnect(ISharedObjectBase so);
-
- /**
- * Called when a client disconnects from a shared object.
- *
- * @param so
- * the shared object
- */
- void onSharedObjectDisconnect(ISharedObjectBase so);
-
- /**
- * Called when a shared object attribute is updated.
- *
- * @param so
- * the shared object
- * @param key
- * the name of the attribute
- * @param value
- * the value of the attribute
- */
- void onSharedObjectUpdate(ISharedObjectBase so, String key, Object value);
-
- /**
- * Called when multiple attributes of a shared object are updated.
- *
- * @param so
- * the shared object
- * @param values
- * the new attributes of the shared object
- */
- void onSharedObjectUpdate(ISharedObjectBase so, IAttributeStore values);
-
- /**
- * Called when multiple attributes of a shared object are updated.
- *
- * @param so
- * the shared object
- * @param values
- * the new attributes of the shared object
- */
- void onSharedObjectUpdate(ISharedObjectBase so, Map values);
-
- /**
- * Called when an attribute is deleted from the shared object.
- *
- * @param so
- * the shared object
- * @param key
- * the name of the attribute to delete
- */
- void onSharedObjectDelete(ISharedObjectBase so, String key);
-
- /**
- * Called when all attributes of a shared object are removed.
- *
- * @param so
- * the shared object
- */
- void onSharedObjectClear(ISharedObjectBase so);
-
- /**
- * Called when a shared object method call is sent.
- *
- * @param so
- * the shared object
- * @param method
- * the method name to call
- * @param params
- * the arguments
- */
- void onSharedObjectSend(ISharedObjectBase so, String method, List> params);
-
-}
diff --git a/src/main/java/org/red5/server/api/so/ISharedObjectSecurity.java b/src/main/java/org/red5/server/api/so/ISharedObjectSecurity.java
deleted file mode 100644
index 89024cc30..000000000
--- a/src/main/java/org/red5/server/api/so/ISharedObjectSecurity.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.so;
-
-import java.util.List;
-
-import org.red5.server.api.scope.IScope;
-
-/**
- * Interface for handlers that control access to shared objects.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface ISharedObjectSecurity {
-
- /**
- * Check if the a shared object may be created in the given scope.
- *
- * @param scope scope
- * @param name name
- * @param persistent is persistent
- * @return is creation allowed
- */
- public boolean isCreationAllowed(IScope scope, String name, boolean persistent);
-
- /**
- * Check if a connection to the given existing shared object is allowed.
- *
- * @param so shared ojbect
- * @return is connection alowed
- */
- public boolean isConnectionAllowed(ISharedObject so);
-
- /**
- * Check if a modification is allowed on the given shared object.
- *
- * @param so shared object
- * @param key key
- * @param value value
- * @return true if given key is modifiable; false otherwise
- */
- public boolean isWriteAllowed(ISharedObject so, String key, Object value);
-
- /**
- * Check if the deletion of a property is allowed on the given shared object.
- *
- * @param so shared object
- * @param key key
- * @return true if delete allowed; false otherwise
- */
- public boolean isDeleteAllowed(ISharedObject so, String key);
-
- /**
- * Check if sending a message to the shared object is allowed.
- *
- * @param so shared object
- * @param message message
- * @param arguments arguments
- * @return true if allowed
- */
- public boolean isSendAllowed(ISharedObject so, String message, List> arguments);
-
-}
diff --git a/src/main/java/org/red5/server/api/so/ISharedObjectSecurityService.java b/src/main/java/org/red5/server/api/so/ISharedObjectSecurityService.java
deleted file mode 100644
index 9493b5bbc..000000000
--- a/src/main/java/org/red5/server/api/so/ISharedObjectSecurityService.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.so;
-
-import java.util.Set;
-
-import org.red5.server.api.scope.IScopeService;
-
-/**
- * Service that supports protecting access to shared objects.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface ISharedObjectSecurityService extends IScopeService {
-
- /**
- * Name of a bean defining that scope service.
- * */
- public static final String BEAN_NAME = "sharedObjectSecurityService";
-
- /**
- * Add handler that protects shared objects.
- *
- * @param handler Handler to add.
- */
- public void registerSharedObjectSecurity(ISharedObjectSecurity handler);
-
- /**
- * Remove handler that protects shared objects.
- *
- * @param handler Handler to remove.
- */
- public void unregisterSharedObjectSecurity(ISharedObjectSecurity handler);
-
- /**
- * Get handlers that protect shared objects.
- *
- * @return list of handlers
- */
- public Set getSharedObjectSecurity();
-
-}
diff --git a/src/main/java/org/red5/server/api/so/ISharedObjectService.java b/src/main/java/org/red5/server/api/so/ISharedObjectService.java
deleted file mode 100644
index 775f1daf4..000000000
--- a/src/main/java/org/red5/server/api/so/ISharedObjectService.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.so;
-
-import java.util.Set;
-
-import org.red5.server.api.scope.IScope;
-import org.red5.server.api.scope.IScopeService;
-
-/**
- * Service that manages shared objects for given scope.
- *
- */
-public interface ISharedObjectService extends IScopeService {
-
- public static String BEAN_NAME = "sharedObjectService";
-
- /**
- * Get a set of the shared object names.
- *
- * @param scope the scope to return the shared object names from
- * @return set containing the shared object names
- */
- public Set getSharedObjectNames(IScope scope);
-
- /**
- * Create a new shared object.
- *
- * @param scope the scope to create the shared object in
- * @param name the name of the shared object
- * @param persistent will the shared object be persistent
- * @return true if the shared object was created or already exists, otherwise
- * false
- */
- public boolean createSharedObject(IScope scope, String name, boolean persistent);
-
- /**
- * Get a shared object by name.
- *
- * @param scope the scope to get the shared object from
- * @param name the name of the shared object
- * @return shared object, or null if not found
- */
- public ISharedObject getSharedObject(IScope scope, String name);
-
- /**
- * Get a shared object by name and create it if it doesn't exist.
- *
- * @param scope the scope to get the shared object from
- * @param name the name of the shared object
- * @param persistent should the shared object be created persistent
- * @return the shared object
- */
- public ISharedObject getSharedObject(IScope scope, String name, boolean persistent);
-
- /**
- * Check if a shared object exists.
- *
- * @param scope the scope to check for the shared object
- * @param name the name of the shared object
- * @return true if the shared object exists, otherwise
- * false
- */
- public boolean hasSharedObject(IScope scope, String name);
-
- /**
- *
- * Deletes persistent shared objects specified by name and clears all
- * properties from active shared objects (persistent and nonpersistent). The
- * name parameter specifies the name of a shared object, which can include a
- * slash (/) as a delimiter between directories in the path. The last
- * element in the path can contain wildcard patterns (for example, a
- * question mark [?] and an asterisk [*]) or a shared object name. The
- * clearSharedObjects() method traverses the shared object hierarchy along
- * the specified path and clears all the shared objects. Specifying a slash
- * (/) clears all the shared objects associated with an application
- * instance.
- *
- *
- * The following values are possible for the soPath parameter: /
- * clears all local and persistent shared objects associated with the
- * instance.
- * /foo/bar clears the shared object /foo/bar; if bar is a directory name,
- * no shared objects are deleted.
- * /foo/bar/* clears all shared objects stored under the instance directory
- * /foo/bar. The bar directory is also deleted if no persistent shared
- * objects are in use within this namespace.
- * /foo/bar/XX?? clears all shared objects that begin with XX, followed by
- * any two characters. If a directory name matches this specification, all
- * the shared objects within this directory are cleared.
- *
- *
- * If you call the clearSharedObjects() method and the specified path
- * matches a shared object that is currently active, all its properties are
- * deleted, and a "clear" event is sent to all subscribers of the shared
- * object. If it is a persistent shared object, the persistent store is also
- * cleared.
- *
- *
- *
- * @param scope the scope to check for the shared object
- * @param name the name of the shared object
- * @return true if the shared object at the specified path was deleted;
- * otherwise, false. If using wildcard characters to delete multiple
- * files, the method returns true only if all the shared objects
- * matching the wildcard pattern were successfully deleted;
- * otherwise, it will return false.
- */
- public boolean clearSharedObjects(IScope scope, String name);
-
-}
diff --git a/src/main/java/org/red5/server/api/statistics/IClientBroadcastStreamStatistics.java b/src/main/java/org/red5/server/api/statistics/IClientBroadcastStreamStatistics.java
deleted file mode 100644
index 473ef3b13..000000000
--- a/src/main/java/org/red5/server/api/statistics/IClientBroadcastStreamStatistics.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.statistics;
-
-/**
- * Statistical informations about a stream that is broadcasted by a client.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IClientBroadcastStreamStatistics extends IStreamStatistics {
-
- /**
- * Get the filename the stream is being saved as.
- *
- * @return The filename relative to the scope or null
- * if the stream is not being saved.
- */
- public String getSaveFilename();
-
- /**
- * Get stream publish name. Publish name is the value of the first parameter
- * had been passed to NetStream.publish on client side in
- * SWF.
- *
- * @return Stream publish name
- */
- public String getPublishedName();
-
- /**
- * Return total number of subscribers.
- *
- * @return number of subscribers
- */
- public int getTotalSubscribers();
-
- /**
- * Return maximum number of concurrent subscribers.
- *
- * @return number of subscribers
- */
- public int getMaxSubscribers();
-
- /**
- * Return current number of subscribers.
- *
- * @return number of subscribers
- */
- public int getActiveSubscribers();
-
- /**
- * Return total number of bytes received from client for this stream.
- *
- * @return number of bytes
- */
- public long getBytesReceived();
-
-}
diff --git a/src/main/java/org/red5/server/api/statistics/IPlaylistSubscriberStreamStatistics.java b/src/main/java/org/red5/server/api/statistics/IPlaylistSubscriberStreamStatistics.java
deleted file mode 100644
index df402bdd1..000000000
--- a/src/main/java/org/red5/server/api/statistics/IPlaylistSubscriberStreamStatistics.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.statistics;
-
-/**
- * Statistical informations about a stream that is subscribed by a client.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IPlaylistSubscriberStreamStatistics extends IStreamStatistics {
-
- /**
- * Return total number of bytes sent to the client from this stream.
- *
- * @return number of bytes
- */
- public long getBytesSent();
-
- /**
- * Return the buffer duration as requested by the client.
- *
- * @return the buffer duration in milliseconds
- */
- public int getClientBufferDuration();
-
- /**
- * Return estimated fill ratio of the client buffer.
- *
- * @return fill ratio in percent
- */
- public double getEstimatedBufferFill();
-
-}
diff --git a/src/main/java/org/red5/server/api/statistics/IScopeStatistics.java b/src/main/java/org/red5/server/api/statistics/IScopeStatistics.java
deleted file mode 100644
index ab99614c2..000000000
--- a/src/main/java/org/red5/server/api/statistics/IScopeStatistics.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.statistics;
-
-/**
- * Statistical informations about a scope.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IScopeStatistics extends IStatisticsBase {
-
- /**
- * Get the name of this scope. Eg. someroom.
- *
- * @return the name
- */
- public String getName();
-
- /**
- * Get the full absolute path. Eg. host/myapp/someroom.
- *
- * @return Absolute scope path
- */
- public String getPath();
-
- /**
- * Get the scopes depth, how far down the scope tree is it. The lowest depth
- * is 0x00, the depth of Global scope. Application scope depth is 0x01. Room
- * depth is 0x02, 0x03 and so forth.
- *
- * @return the depth
- */
- public int getDepth();
-
- /**
- * Return total number of connections to the scope.
- *
- * @return number of connections
- */
- public int getTotalConnections();
-
- /**
- * Return maximum number of concurrent connections to the scope.
- *
- * @return number of connections
- */
- public int getMaxConnections();
-
- /**
- * Return current number of connections to the scope.
- *
- * @return number of connections
- */
- public int getActiveConnections();
-
- /**
- * Return total number of clients connected to the scope.
- *
- * @return number of clients
- */
- public int getTotalClients();
-
- /**
- * Return maximum number of clients concurrently connected to the scope.
- *
- * @return number of clients
- */
- public int getMaxClients();
-
- /**
- * Return current number of clients connected to the scope.
- *
- * @return number of clients
- */
- public int getActiveClients();
-
- /**
- * Return total number of subscopes created.
- *
- * @return number of subscopes created
- */
- public int getTotalSubscopes();
-
- /**
- * Return maximum number of concurrently existing subscopes.
- *
- * @return number of subscopes
- */
- public int getMaxSubscopes();
-
- /**
- * Return number of currently existing subscopes.
- *
- * @return number of subscopes
- */
- public int getActiveSubscopes();
-
-}
diff --git a/src/main/java/org/red5/server/api/statistics/ISharedObjectStatistics.java b/src/main/java/org/red5/server/api/statistics/ISharedObjectStatistics.java
deleted file mode 100644
index 530b30e32..000000000
--- a/src/main/java/org/red5/server/api/statistics/ISharedObjectStatistics.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.statistics;
-
-/**
- * Statistics informations about a shared object.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface ISharedObjectStatistics extends IStatisticsBase {
-
- /**
- * Return the name of the shared object.
- *
- * @return the name of the shared object
- */
- public String getName();
-
- /**
- * Check if the shared object is persistent.
- *
- * @return True if the shared object is persistent, otherwise False
- */
- public boolean isPersistent();
-
- /**
- * Return the version number of the shared object.
- *
- * @return the version
- */
- public int getVersion();
-
- /**
- * Return total number of subscribed listeners.
- *
- * @return number of listeners
- */
- public int getTotalListeners();
-
- /**
- * Return maximum number of concurrent subscribed listenes.
- *
- * @return number of listeners
- */
- public int getMaxListeners();
-
- /**
- * Return current number of subscribed listeners.
- *
- * @return number of listeners
- */
- public int getActiveListeners();
-
- /**
- * Return number of attribute changes.
- *
- * @return number of changes
- */
- public int getTotalChanges();
-
- /**
- * Return number of attribute deletes.
- *
- * @return number of deletes
- */
- public int getTotalDeletes();
-
- /**
- * Return number of times a message was sent.
- *
- * @return number of sends
- */
- public int getTotalSends();
-
-}
diff --git a/src/main/java/org/red5/server/api/statistics/IStatisticsBase.java b/src/main/java/org/red5/server/api/statistics/IStatisticsBase.java
deleted file mode 100644
index edb096907..000000000
--- a/src/main/java/org/red5/server/api/statistics/IStatisticsBase.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.statistics;
-
-/**
- * Base class for all statistics informations.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IStatisticsBase {
-
- /**
- * Return the timestamp the object was created.
- *
- * @return the timestamp in milliseconds since midnight, January 1, 1970 UTC.
- */
- public long getCreationTime();
-
-}
diff --git a/src/main/java/org/red5/server/api/statistics/IStreamStatistics.java b/src/main/java/org/red5/server/api/statistics/IStreamStatistics.java
deleted file mode 100644
index 45c0bc7a2..000000000
--- a/src/main/java/org/red5/server/api/statistics/IStreamStatistics.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.statistics;
-
-/**
- * Base class for all stream statistics.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IStreamStatistics extends IStatisticsBase {
-
- /**
- * Return the currently active timestamp inside the stream.
- *
- * @return the timestamp in milliseconds
- */
- public int getCurrentTimestamp();
-
-}
diff --git a/src/main/java/org/red5/server/api/statistics/support/StatisticsCounter.java b/src/main/java/org/red5/server/api/statistics/support/StatisticsCounter.java
deleted file mode 100644
index 8bf352524..000000000
--- a/src/main/java/org/red5/server/api/statistics/support/StatisticsCounter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.statistics.support;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Counts numbers used by the statistics. Keeps track of current,
- * maximum and total numbers.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public class StatisticsCounter {
-
- /** Current number. */
- private AtomicInteger current = new AtomicInteger();
-
- /** Total number. */
- private AtomicInteger total = new AtomicInteger();
-
- /** Maximum number. */
- private AtomicInteger max = new AtomicInteger();
-
- /**
- * Increment statistics by one.
- */
- public void increment() {
- total.incrementAndGet();
- max.compareAndSet(current.intValue(), current.incrementAndGet());
- }
-
- /**
- * Decrement statistics by one.
- */
- public void decrement() {
- current.decrementAndGet();
- }
-
- /**
- * Get current number.
- *
- * @return current number
- */
- public int getCurrent() {
- return current.intValue();
- }
-
- /**
- * Get total number.
- *
- * @return total
- */
- public int getTotal() {
- return total.intValue();
- }
-
- /**
- * Get maximum number.
- *
- * @return max
- */
- public int getMax() {
- return max.intValue();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "StatisticsCounter [current=" + current + ", total=" + total + ", max=" + max + "]";
- }
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IBroadcastStream.java b/src/main/java/org/red5/server/api/stream/IBroadcastStream.java
deleted file mode 100644
index 6617d22ec..000000000
--- a/src/main/java/org/red5/server/api/stream/IBroadcastStream.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.red5.server.messaging.IProvider;
-import org.red5.server.net.rtmp.event.Notify;
-
-/**
- * A broadcast stream is a stream source to be subscribed to by clients. To
- * subscribe to a stream from your client Flash application use NetStream.play
- * method. Broadcast stream can be saved at the server-side.
- *
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IBroadcastStream extends IStream {
-
- /**
- * Save the broadcast stream as a file.
- *
- * @param filePath
- * The path of the file relative to the scope.
- * @param isAppend
- * Whether to append to the end of file.
- * @throws IOException
- * File could not be created/written to.
- * @throws ResourceExistException
- * Resource exist when trying to create.
- * @throws ResourceNotFoundException
- * Resource not exist when trying to append.
- */
- void saveAs(String filePath, boolean isAppend)
- throws IOException, ResourceNotFoundException, ResourceExistException;
-
- /**
- * Get the filename the stream is being saved as.
- *
- * @return The filename relative to the scope or null
- * if the stream is not being saved.
- */
- String getSaveFilename();
-
- /**
- * Get the provider corresponding to this stream. Provider objects are
- * object that
- *
- * @return the provider
- */
- IProvider getProvider();
-
- /**
- * Get stream publish name. Publish name is the value of the first parameter
- * had been passed to NetStream.publish on client side in
- * SWF.
- *
- * @return Stream publish name
- */
- String getPublishedName();
-
- /**
- *
- * @param name
- * Set stream publish name
- */
- void setPublishedName(String name);
-
- /**
- * Add a listener to be notified about received packets.
- *
- * @param listener the listener to add
- */
- public void addStreamListener(IStreamListener listener);
-
- /**
- * Remove a listener from being notified about received packets.
- *
- * @param listener the listener to remove
- */
- public void removeStreamListener(IStreamListener listener);
-
- /**
- * Return registered stream listeners.
- *
- * @return the registered listeners
- */
- public Collection getStreamListeners();
-
- /**
- * Returns the metadata for the associated stream, if it exists.
- *
- * @return stream meta data
- */
- public Notify getMetaData();
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/stream/IClientBroadcastStream.java b/src/main/java/org/red5/server/api/stream/IClientBroadcastStream.java
deleted file mode 100644
index cee9f8b33..000000000
--- a/src/main/java/org/red5/server/api/stream/IClientBroadcastStream.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import java.util.Map;
-import org.red5.server.api.statistics.IClientBroadcastStreamStatistics;
-
-/**
- * A broadcast stream that comes from client.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- * @author Paul Gregoire (mondain@gmail.com)
- */
-public interface IClientBroadcastStream extends IClientStream, IBroadcastStream {
-
- /**
- * Notify client that stream is ready for publishing.
- */
- public void startPublishing();
-
- /**
- * Return statistics about the stream.
- *
- * @return statistics
- */
- public IClientBroadcastStreamStatistics getStatistics();
-
- /**
- * Sets streaming parameters as supplied by the publishing application.
- *
- * @param params
- */
- public void setParameters(Map params);
-
- /**
- * Returns streaming parameters.
- *
- * @return parameters
- */
- public Map getParameters();
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IClientStream.java b/src/main/java/org/red5/server/api/stream/IClientStream.java
deleted file mode 100644
index 4e1cad7b7..000000000
--- a/src/main/java/org/red5/server/api/stream/IClientStream.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-/**
- * A stream that is bound to a client.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IClientStream extends IStream {
-
- public static final String MODE_READ = "read";
-
- public static final String MODE_RECORD = "record";
-
- public static final String MODE_APPEND = "append";
-
- public static final String MODE_LIVE = "live";
-
- public static final String MODE_PUBLISH = "publish";
-
- /**
- * Get stream id allocated in a connection.
- *
- * @return the stream id
- */
- int getStreamId();
-
- /**
- * Get connection containing the stream.
- *
- * @return the connection object or null if the connection is no longer active
- */
- IStreamCapableConnection getConnection();
-
- /**
- * Set the buffer duration for this stream as requested by the client.
- *
- * @param bufferTime duration in ms the client wants to buffer
- */
- void setClientBufferDuration(int bufferTime);
-
- /**
- * Get the buffer duration for this stream as requested by the client.
- *
- * @return bufferTime duration in ms the client wants to buffer
- */
- int getClientBufferDuration();
-
- /**
- * Set the published stream name that this client is consuming.
- *
- * @param streamName of stream being consumed
- */
- void setBroadcastStreamPublishName(String streamName);
-
- /**
- * Returns the published stream name that this client is consuming.
- *
- * @return stream name of stream being consumed
- */
- String getBroadcastStreamPublishName();
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IPlayItem.java b/src/main/java/org/red5/server/api/stream/IPlayItem.java
deleted file mode 100644
index 4a3831da4..000000000
--- a/src/main/java/org/red5/server/api/stream/IPlayItem.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.messaging.IMessageInput;
-
-/**
- * Playlist item. Each playlist item has name, start time, length in milliseconds and
- * message input source.
- */
-public interface IPlayItem {
-
- /**
- * Get name of item.
- * The VOD or Live stream provider is found according to this name.
- * @return the name
- */
- String getName();
-
- /**
- * Start time in milliseconds.
- *
- * @return start time
- */
- long getStart();
-
- /**
- * Play length in milliseconds.
- *
- * @return length in milliseconds
- */
- long getLength();
-
- /**
- * Get a message input for play.
- * This object overrides the default algorithm for finding the appropriate VOD or Live stream provider according to
- * the item name.
- *
- * @return message input
- */
- IMessageInput getMessageInput();
-}
diff --git a/src/main/java/org/red5/server/api/stream/IPlaylist.java b/src/main/java/org/red5/server/api/stream/IPlaylist.java
deleted file mode 100644
index bdb5caa84..000000000
--- a/src/main/java/org/red5/server/api/stream/IPlaylist.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-/**
- * Playlist
- */
-public interface IPlaylist {
- /**
- * Add an item to the list.
- *
- * @param item Playlist item
- */
- void addItem(IPlayItem item);
-
- /**
- * Add an item to specific index.
- *
- * @param item Playlist item
- * @param index Index in list
- */
- void addItem(IPlayItem item, int index);
-
- /**
- * Remove an item from list.
- *
- * @param index Index in list
- */
- void removeItem(int index);
-
- /**
- * Remove all items.
- */
- void removeAllItems();
-
- /**
- * Return number of items in list
- *
- * @return Number of items in list
- */
- int getItemSize();
-
- /**
- * Get currently playing item index.
- * @return Currently playing item index.
- */
- int getCurrentItemIndex();
-
- /**
- * Get currently playing item
- * @return Item
- */
- IPlayItem getCurrentItem();
-
- /**
- * Get the item according to the index.
- * @param index Item index
- * @return Item at that index in list
- */
- IPlayItem getItem(int index);
-
- /**
- * Check if the playlist has more items after the currently
- * playing one.
- *
- * @return true if more items are available, false otherwise
- */
- boolean hasMoreItems();
-
- /**
- * Go for the previous played item.
- */
- void previousItem();
-
- /**
- * Go for next item decided by controller logic.
- */
- void nextItem();
-
- /**
- * Set the current item for playing.
- *
- * @param index Position in list
- */
- void setItem(int index);
-
- /**
- * Whether items are randomly played.
- *
- * @return true if shuffle is on for this list, false otherwise
- */
- boolean isRandom();
-
- /**
- * Set whether items should be randomly played.
- *
- * @param random Shuffle flag
- */
- void setRandom(boolean random);
-
- /**
- * Whether rewind the list.
- *
- * @return true if playlist is rewind on end, false otherwise
- */
- boolean isRewind();
-
- /**
- * Set whether rewind the list.
- *
- * @param rewind New vallue for rewind flag
- */
- void setRewind(boolean rewind);
-
- /**
- * Whether repeat playing an item.
- *
- * @return true if repeat mode is on for this playlist, false otherwise
- */
- boolean isRepeat();
-
- /**
- * Set whether repeat playing an item.
- *
- * @param repeat New value for item playback repeat flag
- */
- void setRepeat(boolean repeat);
-
- /**
- * Set list controller.
- *
- * @param controller Playlist controller
- */
- void setPlaylistController(IPlaylistController controller);
-}
diff --git a/src/main/java/org/red5/server/api/stream/IPlaylistController.java b/src/main/java/org/red5/server/api/stream/IPlaylistController.java
deleted file mode 100644
index 0d3ce8b95..000000000
--- a/src/main/java/org/red5/server/api/stream/IPlaylistController.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-/**
- * A play list controller that controls the order of play items.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IPlaylistController {
- /**
- * Get next item to play.
- *
- * @param playlist
- * The related play list.
- * @param itemIndex
- * The current item index. -1 indicates to retrieve
- * the first item for play.
- * @return The next item index to play. -1 reaches the end.
- */
- int nextItem(IPlaylist playlist, int itemIndex);
-
- /**
- * Get previous item to play.
- *
- * @param playlist
- * The related play list.
- * @param itemIndex
- * The current item index. IPlaylist.itemSize
- * indicated to retrieve the last item for play.
- * @return The previous item index to play. -1 reaches the
- * beginning.
- */
- int previousItem(IPlaylist playlist, int itemIndex);
-}
diff --git a/src/main/java/org/red5/server/api/stream/IPlaylistSubscriberStream.java b/src/main/java/org/red5/server/api/stream/IPlaylistSubscriberStream.java
deleted file mode 100644
index 682899c65..000000000
--- a/src/main/java/org/red5/server/api/stream/IPlaylistSubscriberStream.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.api.statistics.IPlaylistSubscriberStreamStatistics;
-
-/**
- * IPlaylistSubscriberStream has methods of both ISubscriberStream and IPlaylist
- * but adds nothing new
- */
-public interface IPlaylistSubscriberStream extends ISubscriberStream, IPlaylist {
-
- /**
- * Return statistics about this stream.
- *
- * @return statistics
- */
- public IPlaylistSubscriberStreamStatistics getStatistics();
-
- /**
- * Handles a change occurring on the stream.
- *
- * @param state stream state that we are changing to or notifying of
- * @param changed changed items
- */
- public void onChange(StreamState state, Object... changed);
-
- /**
- * Replaces an item in the list with another item.
- *
- * @param oldItem
- * @param newItem
- * @return true if successful and false otherwise
- */
- public boolean replace(IPlayItem oldItem, IPlayItem newItem);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IRtmpSampleAccess.java b/src/main/java/org/red5/server/api/stream/IRtmpSampleAccess.java
deleted file mode 100644
index a8935b247..000000000
--- a/src/main/java/org/red5/server/api/stream/IRtmpSampleAccess.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.api.scope.IScope;
-
-public interface IRtmpSampleAccess {
-
- public static String BEAN_NAME = "rtmpSampleAccess";
-
- /**
- * Return true if sample access allowed on audio stream
- * @param scope
- * @return true if sample access allowed on audio stream
- */
- public boolean isAudioAllowed(IScope scope);
-
- /**
- * Return true if sample access allowed on video stream
- * @param scope
- * @return true if sample access allowed on video stream
- */
- public boolean isVideoAllowed(IScope scope);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/ISingleItemSubscriberStream.java b/src/main/java/org/red5/server/api/stream/ISingleItemSubscriberStream.java
deleted file mode 100644
index bfef4477a..000000000
--- a/src/main/java/org/red5/server/api/stream/ISingleItemSubscriberStream.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-/**
- * A subscriber stream that has only one item for play.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface ISingleItemSubscriberStream extends ISubscriberStream {
- /**
- * Setter for property 'playItem'.
- *
- * @param item Value to set for property 'playItem'.
- */
- void setPlayItem(IPlayItem item);
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStream.java b/src/main/java/org/red5/server/api/stream/IStream.java
deleted file mode 100644
index 5b862aeab..000000000
--- a/src/main/java/org/red5/server/api/stream/IStream.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.codec.IStreamCodecInfo;
-import org.red5.server.api.scope.IScope;
-
-/**
- * Base interface for stream objects.
- * A stream object is always associated with a scope.
- */
-public interface IStream {
-
- /**
- * Get the name of the stream. The name is unique across the server. This is
- * just an id of the stream and NOT the name that is used at client side to
- * subscribe to the stream. For that name, use
- * {@link IBroadcastStream#getPublishedName()}
- *
- * @return the name of the stream
- */
- public String getName();
-
- /**
- * Get Codec info for a stream.
- *
- * @return codec info
- */
- IStreamCodecInfo getCodecInfo();
-
- /**
- * Get the scope this stream is associated with.
- *
- * @return scope object
- */
- public IScope getScope();
-
- /**
- * Start this stream.
- */
- public void start();
-
- /**
- * Stop this stream.
- */
- public void stop();
-
- /**
- * Close this stream.
- */
- public void close();
-
- /**
- * Returns the timestamp at which the stream was created.
- *
- * @return creation timestamp
- */
- public long getCreationTime();
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamAwareScopeHandler.java b/src/main/java/org/red5/server/api/stream/IStreamAwareScopeHandler.java
deleted file mode 100644
index bbe24934f..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamAwareScopeHandler.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.api.scope.IScopeHandler;
-
-/**
- * A scope handler that is stream aware.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IStreamAwareScopeHandler extends IScopeHandler {
- /**
- * A broadcast stream starts being published. This will be called
- * when the first video packet has been received.
- *
- * @param stream stream
- */
- public void streamPublishStart(IBroadcastStream stream);
-
- /**
- * A broadcast stream starts being recorded. This will be called
- * when the first video packet has been received.
- *
- * @param stream stream
- */
- public void streamRecordStart(IBroadcastStream stream);
-
- /**
- * A broadcast stream stops being recorded. This will be called
- * when the record-stop notification is sent to the Flash client.
- *
- * @param stream stream
- */
- public void streamRecordStop(IBroadcastStream stream);
-
- /**
- * Notified when a broadcaster starts.
- *
- */
- public void streamBroadcastStart(IBroadcastStream stream);
-
- /**
- * Notified when a broadcaster closes.
- *
- * @param stream stream
- */
- public void streamBroadcastClose(IBroadcastStream stream);
-
- /**
- * Notified when a subscriber starts.
- *
- * @param stream stream
- */
- public void streamSubscriberStart(ISubscriberStream stream);
-
- /**
- * Notified when a subscriber closes.
- *
- * @param stream stream
- */
- public void streamSubscriberClose(ISubscriberStream stream);
-
- /**
- * Notified when a play item plays.
- *
- * @param stream stream
- * @param item item
- * @param isLive true if live
- */
- public void streamPlayItemPlay(ISubscriberStream stream, IPlayItem item, boolean isLive);
-
- /**
- * Notified when a play item stops.
- *
- * @param stream stream
- * @param item item
- */
- public void streamPlayItemStop(ISubscriberStream stream, IPlayItem item);
-
- /**
- * Notified when a play item pauses.
- *
- * @param stream stream
- * @param item item
- * @param position position
- */
- public void streamPlayItemPause(ISubscriberStream stream, IPlayItem item, int position);
-
- /**
- * Notified when a play item resumes.
- *
- * @param stream stream
- * @param item item
- * @param position position
- */
- public void streamPlayItemResume(ISubscriberStream stream, IPlayItem item, int position);
-
- /**
- * Notified when a play item seeks.
- *
- * @param stream stream
- * @param item item
- * @param position position
- */
- public void streamPlayItemSeek(ISubscriberStream stream, IPlayItem item, int position);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamCapableConnection.java b/src/main/java/org/red5/server/api/stream/IStreamCapableConnection.java
deleted file mode 100644
index a9a15cb69..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamCapableConnection.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.api.IConnection;
-
-/**
- * A connection that supports streaming.
- *
- * @author The Red5 Project
- * @author Luke Hubbard (luke@codegent.com)
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IStreamCapableConnection extends IConnection {
-
- /**
- * Return a reserved stream id for use.
- * According to FCS/FMS regulation, the base is 1.
- * @return Reserved stream id
- */
- int reserveStreamId();
-
- int reserveStreamId(int id);
-
- /**
- * Unreserve this id for future use.
- *
- * @param streamId ID of stream to unreserve
- */
- void unreserveStreamId(int streamId);
-
- /**
- * Deletes the stream with the given id.
- *
- * @param streamId ID of stream to delete
- */
- void deleteStreamById(int streamId);
-
- /**
- * Get a stream by its id.
- *
- * @param streamId Stream id
- * @return Stream with given id
- */
- IClientStream getStreamById(int streamId);
-
- /**
- * Create a stream that can play only one item.
- *
- * @param streamId Stream id
- * @return New subscriber stream that can play only one item
- */
- ISingleItemSubscriberStream newSingleItemSubscriberStream(int streamId);
-
- /**
- * Create a stream that can play a list.
- *
- * @param streamId Stream id
- * @return New stream that can play sequence of items
- */
- IPlaylistSubscriberStream newPlaylistSubscriberStream(int streamId);
-
- /**
- * Create a broadcast stream.
- *
- * @param streamId Stream id
- * @return New broadcast stream
- */
- IClientBroadcastStream newBroadcastStream(int streamId);
-
- /**
- * Total number of video messages that are pending to be sent to a stream.
- *
- * @param streamId Stream id
- * @return Number of pending video messages
- */
- long getPendingVideoMessages(int streamId);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamFilenameGenerator.java b/src/main/java/org/red5/server/api/stream/IStreamFilenameGenerator.java
deleted file mode 100644
index fc2179555..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamFilenameGenerator.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.api.scope.IScope;
-import org.red5.server.api.scope.IScopeService;
-
-/**
- * A class that can generate filenames for streams.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (bauch@struktur.de)
- */
-public interface IStreamFilenameGenerator extends IScopeService {
-
- /** Name of the bean to setup a custom filename generator in an application. */
- public static String BEAN_NAME = "streamFilenameGenerator";
-
- /** Possible filename generation types. */
- public static enum GenerationType {
- PLAYBACK, RECORD
- };
-
- /**
- * Generate a filename without an extension.
- *
- * @param scope Scope to use
- * @param name Stream name
- * @param type Generation strategy (either playback or record)
- * @return Full filename
- */
- public String generateFilename(IScope scope, String name, GenerationType type);
-
- /**
- * Generate a filename with an extension.
- *
- * @param scope Scope to use
- * @param name Stream filename
- * @param extension Extension
- * @param type Generation strategy (either playback or record)
- * @return Full filename with extension
- */
- public String generateFilename(IScope scope, String name, String extension, GenerationType type);
-
- /**
- * True if returned filename is an absolute path, else relative to application.
- *
- * If relative to application, you need to use
- * scope.getContext().getResources(fileName)[0].getFile() to resolve
- * this to a file.
- *
- * If absolute (ie returns true) simply use new File(generateFilename(scope, name))
- *
- * @return true if an absolute path; else false
- */
- public boolean resolvesToAbsolutePath();
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamListener.java b/src/main/java/org/red5/server/api/stream/IStreamListener.java
deleted file mode 100644
index 35415e6d8..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-/**
- * Listener that is notified about packets received from a stream.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IStreamListener {
-
- /**
- * A packet has been received from a stream.
- *
- * @param stream the stream the packet has been received for
- * @param packet the packet received
- */
- public void packetReceived(IBroadcastStream stream, IStreamPacket packet);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamPacket.java b/src/main/java/org/red5/server/api/stream/IStreamPacket.java
deleted file mode 100644
index 346ec2440..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamPacket.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.apache.mina.core.buffer.IoBuffer;
-
-/**
- * Packet containing stream data.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IStreamPacket {
-
- /**
- * Type of this packet. This is one of the TYPE_ constants.
- *
- * @return the type
- */
- public byte getDataType();
-
- /**
- * Timestamp of this packet.
- *
- * @return the timestamp in milliseconds
- */
- public int getTimestamp();
-
- /**
- * Packet contents.
- *
- * @return the contents
- */
- public IoBuffer getData();
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamPlaybackSecurity.java b/src/main/java/org/red5/server/api/stream/IStreamPlaybackSecurity.java
deleted file mode 100644
index 8b659d878..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamPlaybackSecurity.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.api.scope.IScope;
-
-/**
- * Interface for handlers that control access to stream playback.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IStreamPlaybackSecurity {
-
- /**
- * Check if playback of a stream with the given name is allowed.
- *
- * @param scope Scope the stream is about to be played back from.
- * @param name Name of the stream to play.
- * @param start Position to start playback from (in milliseconds).
- * @param length Duration to play (in milliseconds).
- * @param flushPlaylist Flush playlist?
- * @return True if playback is allowed, otherwise False
- */
- public boolean isPlaybackAllowed(IScope scope, String name, int start, int length, boolean flushPlaylist);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamPublishSecurity.java b/src/main/java/org/red5/server/api/stream/IStreamPublishSecurity.java
deleted file mode 100644
index 566db7096..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamPublishSecurity.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.api.scope.IScope;
-
-/**
- * Interface for handlers that control access to stream publishing.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IStreamPublishSecurity {
-
- /**
- * Check if publishing a stream with the given name is allowed.
- *
- * @param scope Scope the stream is about to be published in.
- * @param name Name of the stream to publish.
- * @param mode Publishing mode.
- * @return True if publishing is allowed, otherwise False
- */
- public boolean isPublishAllowed(IScope scope, String name, String mode);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamService.java b/src/main/java/org/red5/server/api/stream/IStreamService.java
deleted file mode 100644
index 2d5c075b3..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamService.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import org.red5.server.api.IConnection;
-import org.red5.server.api.scope.IScopeService;
-
-/**
- * This interface represents the stream methods that can be called throug RTMP.
- */
-public interface IStreamService extends IScopeService {
-
- public static String BEAN_NAME = "streamService";
-
- /**
- * Create a stream and return a corresponding id.
- *
- * @return ID of created stream
- */
- public int createStream();
-
- /**
- * Close the stream but not deallocate the resources.
- *
- * @param connection Connection
- * @param streamId Stream id
- */
- public void closeStream(IConnection connection, int streamId);
-
- /**
- * Close the stream if not been closed.
- * Deallocate the related resources.
- * @param streamId Stream id
- */
- public void deleteStream(int streamId);
-
- /**
- * Called by FMS.
- *
- * @param streamId Stream id
- */
- public void initStream(int streamId);
-
- /**
- * Called by FME.
- *
- * @param streamName stream name
- */
- public void releaseStream(String streamName);
-
- /**
- * Delete stream
- * @param conn Stream capable connection
- * @param streamId Stream id
- */
- public void deleteStream(IStreamCapableConnection conn, int streamId);
-
- /**
- * Play stream without initial stop
- * @param dontStop Stoppage flag
- */
- public void play(Boolean dontStop);
-
- /**
- * Play stream with name
- * @param name Stream name
- */
- public void play(String name);
-
- /**
- * Play stream with name from start position
- * @param name Stream name
- * @param start Start position
- */
- public void play(String name, int start);
-
- /**
- * Play stream with name from start position and for given amount if time
- * @param name Stream name
- * @param start Start position
- * @param length Playback length
- */
- public void play(String name, int start, int length);
-
- /**
- * Publishes stream from given position for given amount of time
- * @param name Stream published name
- * @param start Start position
- * @param length Playback length
- * @param flushPlaylist Flush playlist?
- */
- public void play(String name, int start, int length, boolean flushPlaylist);
-
- /**
- * Publishes stream with given name
- * @param name Stream published name
- */
- public void publish(String name);
-
- /**
- * Publishes stream with given name and mode
- * @param name Stream published name
- * @param mode Stream publishing mode
- */
- public void publish(String name, String mode);
-
- /**
- * Publish
- * @param dontStop Whether need to stop first
- */
- public void publish(Boolean dontStop);
-
- /**
- * Seek to position
- * @param position Seek position
- */
- public void seek(int position);
-
- /**
- * Pauses playback
- * @param pausePlayback Pause or resume flash
- * @param position Pause position
- */
- public void pause(Boolean pausePlayback, int position);
-
- /**
- * Undocumented Flash Plugin 10 call, assuming to be the alias to pause(boolean, int)
- *
- * @param pausePlayback Pause or resume flash
- * @param position Pause position
- */
- public void pauseRaw(Boolean pausePlayback, int position);
-
- /**
- * Can recieve video?
- * @param receive Boolean flag
- */
- public void receiveVideo(boolean receive);
-
- /**
- * Can recieve audio?
- * @param receive Boolean flag
- */
- public void receiveAudio(boolean receive);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/IStreamableFileFactory.java b/src/main/java/org/red5/server/api/stream/IStreamableFileFactory.java
deleted file mode 100644
index 002fc114f..000000000
--- a/src/main/java/org/red5/server/api/stream/IStreamableFileFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import java.io.File;
-import java.util.Set;
-
-import org.red5.server.api.scope.IScopeService;
-import org.red5.server.api.service.IStreamableFileService;
-
-/**
- * Scope service extension that provides method to get streamable file services set
- */
-public interface IStreamableFileFactory extends IScopeService {
-
- public static String BEAN_NAME = "streamableFileFactory";
-
- public abstract IStreamableFileService getService(File fp);
-
- /**
- * Getter for services
- *
- * @return Set of streamable file services
- */
- public abstract Set getServices();
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/api/stream/ISubscriberStream.java b/src/main/java/org/red5/server/api/stream/ISubscriberStream.java
deleted file mode 100644
index 764ca7275..000000000
--- a/src/main/java/org/red5/server/api/stream/ISubscriberStream.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-import java.io.IOException;
-
-import org.red5.server.api.scheduling.IScheduledJob;
-
-/**
- * ISubscriberStream is a stream from subscriber's point of view. That is, it
- * provides methods for common stream operations like play, pause or seek.
- */
-public interface ISubscriberStream extends IClientStream {
- /**
- * Start playing.
- *
- * @throws IOException if an IO error occurred while starting to play the stream
- */
- void play() throws IOException;
-
- /**
- * Pause at a position for current playing item.
- *
- * @param position
- * Position for pause in millisecond.
- */
- void pause(int position);
-
- /**
- * Resume from a position for current playing item.
- *
- * @param position
- * Position for resume in millisecond.
- */
- void resume(int position);
-
- /**
- * Stop playing.
- */
- void stop();
-
- /**
- * Seek into a position for current playing item.
- *
- * @param position
- * Position for seek in millisecond.
- * @throws OperationNotSupportedException if the stream doesn't support seeking.
- */
- void seek(int position) throws OperationNotSupportedException;
-
- /**
- * Check if the stream is currently paused.
- *
- * @return stream is paused
- */
- boolean isPaused();
-
- /**
- * Should the stream send video to the client?
- *
- * @param receive
- */
- void receiveVideo(boolean receive);
-
- /**
- * Should the stream send audio to the client?
- *
- * @param receive
- */
- void receiveAudio(boolean receive);
-
- /**
- * Return the streams state enum.
- *
- * @return current state
- */
- public StreamState getState();
-
- /**
- * Sets the streams state enum.
- *
- * @param state sets current state
- */
- public void setState(StreamState state);
-
- /**
- * Notification of state change and associated parameters.
- *
- * @param state new state
- * @param changed parameters associated with the change
- */
- public void onChange(final StreamState state, final Object... changed);
-
- /**
- * Schedule a job to be executed only once after a 10ms delay.
- *
- * @param job
- * @return jobName
- */
- public String scheduleOnceJob(IScheduledJob job);
-
- /**
- * Schedule a job to be executed regularly at the given interval.
- *
- * @param job
- * @param interval
- * @return jobName
- */
- public String scheduleWithFixedDelay(IScheduledJob job, int interval);
-
- /**
- * Cancels a scheduled job by name.
- *
- * @param pullAndPush
- */
- public void cancelJob(String pullAndPush);
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/OperationNotSupportedException.java b/src/main/java/org/red5/server/api/stream/OperationNotSupportedException.java
deleted file mode 100644
index 05fb789c0..000000000
--- a/src/main/java/org/red5/server/api/stream/OperationNotSupportedException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-/**
- * The requested operation is not supported by the stream.
- *
- */
-public class OperationNotSupportedException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = -6166602683688991431L;
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/ResourceExistException.java b/src/main/java/org/red5/server/api/stream/ResourceExistException.java
deleted file mode 100644
index b688fa6db..000000000
--- a/src/main/java/org/red5/server/api/stream/ResourceExistException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-public class ResourceExistException extends Exception {
- private static final long serialVersionUID = 443389396219999143L;
-
- /** Constructs a new ResourceExistException. */
- public ResourceExistException() {
- super();
- }
-
- public ResourceExistException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ResourceExistException(String message) {
- super(message);
- }
-
- public ResourceExistException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/ResourceNotFoundException.java b/src/main/java/org/red5/server/api/stream/ResourceNotFoundException.java
deleted file mode 100644
index 0a1cc5f60..000000000
--- a/src/main/java/org/red5/server/api/stream/ResourceNotFoundException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-/**
- * @author daccattato
- *
- */
-public class ResourceNotFoundException extends Exception {
- private static final long serialVersionUID = -1963629259187714996L;
-
- /** Constructs a new ResourceNotFoundException. */
- public ResourceNotFoundException() {
- super();
- }
-
- public ResourceNotFoundException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ResourceNotFoundException(String message) {
- super(message);
- }
-
- public ResourceNotFoundException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/StreamState.java b/src/main/java/org/red5/server/api/stream/StreamState.java
deleted file mode 100644
index a934df373..000000000
--- a/src/main/java/org/red5/server/api/stream/StreamState.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream;
-
-/**
- * Represents all the states that a stream may be in at a requested point in time.
- *
- * @author Paul Gregoire (mondain@gmail.com)
- */
-public enum StreamState {
-
- INIT, UNINIT, OPEN, CLOSED, STARTED, STOPPED, PLAYING, PAUSED, RESUMED, END, SEEK;
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/support/DynamicPlayItem.java b/src/main/java/org/red5/server/api/stream/support/DynamicPlayItem.java
deleted file mode 100644
index 1d943d0f6..000000000
--- a/src/main/java/org/red5/server/api/stream/support/DynamicPlayItem.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream.support;
-
-import org.red5.server.api.stream.IPlayItem;
-import org.red5.server.messaging.IMessageInput;
-
-/**
- * Dynamic playlist item implementation
- */
-public class DynamicPlayItem implements IPlayItem {
-
- /**
- * Playlist item name
- */
- protected final String name;
-
- /**
- * Start mark
- */
- protected final long start;
-
- /**
- * Length - amount to play
- */
- protected final long length;
-
- /**
- * Size - for VOD items this will be the file size
- */
- protected long size = -1;
-
- /**
- * Offset
- */
- protected double offset;
-
- /**
- * Message source
- */
- protected IMessageInput msgInput;
-
- private DynamicPlayItem(String name, long start, long length) {
- this.name = name;
- this.start = start;
- this.length = length;
- }
-
- private DynamicPlayItem(String name, long start, long length, double offset) {
- this.name = name;
- this.start = start;
- this.length = length;
- this.offset = offset;
- }
-
- /**
- * Returns play item length in milliseconds
- *
- * @return Play item length in milliseconds
- */
- public long getLength() {
- return length;
- }
-
- /**
- * Returns IMessageInput object. IMessageInput is an endpoint for a consumer
- * to connect.
- *
- * @return IMessageInput object
- */
- public IMessageInput getMessageInput() {
- return msgInput;
- }
-
- /**
- * Returns item name
- *
- * @return item name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns boolean value that specifies whether item can be played
- */
- public long getStart() {
- return start;
- }
-
- /**
- * Alias for getMessageInput
- *
- * @return Message input source
- */
- public IMessageInput getMsgInput() {
- return msgInput;
- }
-
- /**
- * Setter for message input
- *
- * @param msgInput Message input
- */
- public void setMsgInput(IMessageInput msgInput) {
- this.msgInput = msgInput;
- }
-
- /**
- * Returns size in bytes
- */
- public long getSize() {
- return size;
- }
-
- /**
- * Set the size in bytes
- *
- * @param size size in bytes
- */
- public void setSize(long size) {
- this.size = size;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + (int) (size ^ (size >>> 32));
- result = prime * result + (int) (start ^ (start >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- DynamicPlayItem other = (DynamicPlayItem) obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- if (size != other.size)
- return false;
- if (start != other.start)
- return false;
- return true;
- }
-
- /**
- * Builder for DynamicPlayItem
- *
- * @param name
- * @param start
- * @param length
- * @return play item instance
- */
- public static DynamicPlayItem build(String name, long start, long length) {
- DynamicPlayItem playItem = new DynamicPlayItem(name, start, length);
- return playItem;
- }
-
- /**
- * Builder for DynamicPlayItem
- *
- * @param name
- * @param start
- * @param length
- * @param offset
- * @return play item instance
- */
- public static DynamicPlayItem build(String name, long start, long length, double offset) {
- DynamicPlayItem playItem = new DynamicPlayItem(name, start, length, offset);
- return playItem;
- }
-
-}
diff --git a/src/main/java/org/red5/server/api/stream/support/SimplePlayItem.java b/src/main/java/org/red5/server/api/stream/support/SimplePlayItem.java
deleted file mode 100644
index f1760872f..000000000
--- a/src/main/java/org/red5/server/api/stream/support/SimplePlayItem.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.api.stream.support;
-
-import org.red5.server.api.stream.IPlayItem;
-import org.red5.server.messaging.IMessageInput;
-
-/**
- * Simple playlist item implementation
- */
-public class SimplePlayItem implements IPlayItem, Comparable {
-
- private long created = System.nanoTime();
-
- /**
- * Playlist item name
- */
- protected final String name;
-
- /**
- * Start mark
- */
- protected final long start;
-
- /**
- * Length - amount to play
- */
- protected final long length;
-
- /**
- * Message source
- */
- protected IMessageInput msgInput;
-
- private SimplePlayItem(String name) {
- this.name = name;
- this.start = -2L;
- this.length = -1L;
- }
-
- private SimplePlayItem(String name, long start, long length) {
- this.name = name;
- this.start = start;
- this.length = length;
- }
-
- /**
- * Returns play item length in milliseconds
- *
- * @return Play item length in milliseconds
- */
- public long getLength() {
- return length;
- }
-
- /**
- * Returns IMessageInput object. IMessageInput is an endpoint for a consumer
- * to connect.
- *
- * @return IMessageInput object
- */
- public IMessageInput getMessageInput() {
- return msgInput;
- }
-
- /**
- * Returns item name
- *
- * @return item name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns boolean value that specifies whether item can be played
- */
- public long getStart() {
- return start;
- }
-
- /**
- * Alias for getMessageInput
- *
- * @return Message input source
- */
- public IMessageInput getMsgInput() {
- return msgInput;
- }
-
- /**
- * Setter for message input
- *
- * @param msgInput Message input
- */
- public void setMsgInput(IMessageInput msgInput) {
- this.msgInput = msgInput;
- }
-
- /**
- * @return the created
- */
- public long getCreated() {
- return created;
- }
-
- /**
- * @param created the created to set
- */
- public void setCreated(long created) {
- this.created = created;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + (int) (start ^ (start >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- SimplePlayItem other = (SimplePlayItem) obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- if (start != other.start)
- return false;
- return true;
- }
-
- @Override
- public int compareTo(SimplePlayItem that) {
- if (created > that.getCreated()) {
- return -1;
- } else if (created < that.getCreated()) {
- return 1;
- }
- return 0;
- }
-
- /**
- * Builder for SimplePlayItem
- *
- * @param name
- * @return play item instance
- */
- public static SimplePlayItem build(String name) {
- SimplePlayItem playItem = new SimplePlayItem(name);
- return playItem;
- }
-
- /**
- * Builder for SimplePlayItem
- *
- * @param name
- * @param start
- * @param length
- * @return play item instance
- */
- public static SimplePlayItem build(String name, long start, long length) {
- SimplePlayItem playItem = new SimplePlayItem(name, start, length);
- return playItem;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "SimplePlayItem [created=" + created + ", name=" + name + ", start=" + start + ", length=" + length + "]";
- }
-
-}
diff --git a/src/main/java/org/red5/server/exception/ClientDetailsException.java b/src/main/java/org/red5/server/exception/ClientDetailsException.java
deleted file mode 100644
index 5c2dcf981..000000000
--- a/src/main/java/org/red5/server/exception/ClientDetailsException.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.exception;
-
-/**
- * Exception class than contains additional parameters to return to the client.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public class ClientDetailsException extends RuntimeException {
-
- private static final long serialVersionUID = -1908769505547253205L;
-
- /**
- * Parameters to return to the client.
- */
- private Object parameters;
-
- /**
- * Also return stacktrace to client?
- */
- private boolean stacktrace;
-
- /**
- * Create new exception object from message and parameters. By default, no
- * stacktrace is returned to the client.
- *
- * @param message message
- * @param params parameters for message
- */
- public ClientDetailsException(String message, Object params) {
- this(message, params, false);
- }
-
- /**
- * Create new exception object from message and parameters with optional stacktrace.
- *
- * @param message message
- * @param params parameters
- * @param includeStacktrace whether or not to include a stack trace
- */
- public ClientDetailsException(String message, Object params, boolean includeStacktrace) {
- super(message);
- this.parameters = params;
- this.stacktrace = includeStacktrace;
- }
-
- /**
- * Get parameters to return to the client.
- *
- * @return parameters
- */
- public Object getParameters() {
- return parameters;
- }
-
- /**
- * Should the stacktrace returned to the client?
- *
- * @return stacktrace
- */
- public boolean includeStacktrace() {
- return stacktrace;
- }
-
-}
diff --git a/src/main/java/org/red5/server/exception/ClientNotFoundException.java b/src/main/java/org/red5/server/exception/ClientNotFoundException.java
deleted file mode 100644
index 674ff9cfa..000000000
--- a/src/main/java/org/red5/server/exception/ClientNotFoundException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.exception;
-
-/**
- * Client not found
- */
-public class ClientNotFoundException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 3135070223941800751L;
-
- /**
- * Create exception from given string message
- * @param id id
- */
- public ClientNotFoundException(String id) {
- super("Client \"" + id + "\" not found.");
- }
-
-}
diff --git a/src/main/java/org/red5/server/exception/ClientRejectedException.java b/src/main/java/org/red5/server/exception/ClientRejectedException.java
deleted file mode 100644
index c8f39b168..000000000
--- a/src/main/java/org/red5/server/exception/ClientRejectedException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.exception;
-
-/**
- * The client is not allowed to connect. Reason that provided with this
- * exception is sent to client-side status event description.
- *
- */
-public class ClientRejectedException extends RuntimeException {
-
- private static final long serialVersionUID = 9204597649465357898L;
-
- @SuppressWarnings("all")
- private Object reason;
-
- /** Constructs a new ClientRejectedException. */
- public ClientRejectedException() {
- this("Client rejected");
- }
-
- /**
- * Create new exception with given rejection reason
- * @param reason Rejection reason
- */
- public ClientRejectedException(Object reason) {
- super("Client rejected");
- this.reason = reason;
- }
-
- /**
- * Getter for reason
- *
- * @return Rejection reason
- */
- public Object getReason() {
- return reason;
- }
-
-}
diff --git a/src/main/java/org/red5/server/exception/ScopeException.java b/src/main/java/org/red5/server/exception/ScopeException.java
deleted file mode 100644
index af86b2101..000000000
--- a/src/main/java/org/red5/server/exception/ScopeException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.exception;
-
-/**
- * Generic Scope exception.
- */
-public class ScopeException extends RuntimeException {
-
- private static final long serialVersionUID = -8512088658139011L;
-
- public ScopeException(String string) {
- super(string);
- }
-
-}
diff --git a/src/main/java/org/red5/server/exception/ScopeNotFoundException.java b/src/main/java/org/red5/server/exception/ScopeNotFoundException.java
deleted file mode 100644
index cc0e7cd55..000000000
--- a/src/main/java/org/red5/server/exception/ScopeNotFoundException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.exception;
-
-import org.red5.server.api.scope.IScope;
-
-/**
- * Scope not found, thrown when child scope wasn't found.
- */
-public class ScopeNotFoundException extends RuntimeException {
-
- private static final long serialVersionUID = -8512088658139018041L;
-
- /**
- * Create exception from given scope object and given child subscope
- * @param scope Scope
- * @param childName Subscope name
- */
- public ScopeNotFoundException(IScope scope, String childName) {
- super("Scope not found: " + childName + " in " + scope);
- }
-
-}
diff --git a/src/main/java/org/red5/server/exception/ScopeShuttingDownException.java b/src/main/java/org/red5/server/exception/ScopeShuttingDownException.java
deleted file mode 100644
index 29d7fca5e..000000000
--- a/src/main/java/org/red5/server/exception/ScopeShuttingDownException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.exception;
-
-import org.red5.server.api.scope.IScope;
-
-/**
- * Scope is currently shutting down.
- */
-public class ScopeShuttingDownException extends RuntimeException {
-
- private static final long serialVersionUID = 9129189610425512289L;
-
- /**
- * Create exception from given scope object
- * @param scope Scope
- */
- public ScopeShuttingDownException(IScope scope) {
- super("Scope shutting down: " + scope);
- }
-
-}
diff --git a/src/main/java/org/red5/server/jmx/mxbeans/AttributeStoreMXBean.java b/src/main/java/org/red5/server/jmx/mxbeans/AttributeStoreMXBean.java
deleted file mode 100644
index f0e4827c5..000000000
--- a/src/main/java/org/red5/server/jmx/mxbeans/AttributeStoreMXBean.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.jmx.mxbeans;
-
-import java.util.Set;
-
-import javax.management.MXBean;
-
-/**
- * Base interface for all API objects with attributes
- *
- * @author The Red5 Project
- * @author Paul Gregoire (mondain@gmail.com)
- */
-@MXBean
-public interface AttributeStoreMXBean {
-
- public Set getAttributeNames();
-
- public boolean hasAttribute(String name);
-
- public boolean removeAttribute(String name);
-
- public void removeAttributes();
-
-}
diff --git a/src/main/java/org/red5/server/jmx/mxbeans/ClientBroadcastStreamMXBean.java b/src/main/java/org/red5/server/jmx/mxbeans/ClientBroadcastStreamMXBean.java
deleted file mode 100644
index b132a8721..000000000
--- a/src/main/java/org/red5/server/jmx/mxbeans/ClientBroadcastStreamMXBean.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.jmx.mxbeans;
-
-import java.io.IOException;
-
-import javax.management.MXBean;
-
-import org.red5.server.api.stream.ResourceExistException;
-import org.red5.server.api.stream.ResourceNotFoundException;
-
-/**
- * Represents live stream broadcasted from client. As Flash Media Server, Red5 supports
- * recording mode for live streams, that is, broadcasted stream has broadcast mode. It can be either
- * "live" or "record" and latter causes server-side application to record broadcasted stream.
- *
- * Note that recorded streams are recorded as FLV files. The same is correct for audio, because
- * NellyMoser codec that Flash Player uses prohibits on-the-fly transcoding to audio formats like MP3
- * without paying of licensing fee or buying SDK.
- *
- * This type of stream uses two different pipes for live streaming and recording.
- */
-@MXBean
-public interface ClientBroadcastStreamMXBean {
-
- public void start();
-
- public void startPublishing();
-
- public void stop();
-
- public void close();
-
- public void saveAs(String name, boolean isAppend) throws IOException, ResourceNotFoundException, ResourceExistException;
-
- public String getSaveFilename();
-
- public String getPublishedName();
-
- public void setPublishedName(String name);
-
-}
diff --git a/src/main/java/org/red5/server/jmx/mxbeans/ClientRegistryMXBean.java b/src/main/java/org/red5/server/jmx/mxbeans/ClientRegistryMXBean.java
deleted file mode 100644
index 6e21ccafd..000000000
--- a/src/main/java/org/red5/server/jmx/mxbeans/ClientRegistryMXBean.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.jmx.mxbeans;
-
-import java.util.List;
-
-import javax.management.MXBean;
-
-import org.red5.server.Client;
-import org.red5.server.exception.ClientNotFoundException;
-
-/**
- * An MBean interface for the client registry.
- *
- * @author The Red5 Project
- * @author Paul Gregoire (mondain@gmail.com)
- */
-@MXBean
-public interface ClientRegistryMXBean {
-
- public String nextId();
-
- public String previousId();
-
- public boolean hasClient(String id);
-
- public List getClientList();
-
- public Client getClient(String id) throws ClientNotFoundException;
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/jmx/mxbeans/QuartzSchedulingServiceMXBean.java b/src/main/java/org/red5/server/jmx/mxbeans/QuartzSchedulingServiceMXBean.java
deleted file mode 100644
index e6f398fa0..000000000
--- a/src/main/java/org/red5/server/jmx/mxbeans/QuartzSchedulingServiceMXBean.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.jmx.mxbeans;
-
-import java.util.List;
-
-import javax.management.MXBean;
-
-/**
- * Scheduling service that uses Quartz as backend.
- *
- * @author The Red5 Project
- * @author Paul Gregoire (mondain@gmail.com)
- */
-@MXBean
-public interface QuartzSchedulingServiceMXBean {
-
- /**
- * Getter for job name.
- *
- * @return Job name
- */
- public String getJobName();
-
- public void removeScheduledJob(String name);
-
- public List getScheduledJobNames();
-
-}
diff --git a/src/main/java/org/red5/server/jmx/mxbeans/RTMPConnectionMXBean.java b/src/main/java/org/red5/server/jmx/mxbeans/RTMPConnectionMXBean.java
deleted file mode 100644
index 18cc2e79b..000000000
--- a/src/main/java/org/red5/server/jmx/mxbeans/RTMPConnectionMXBean.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.jmx.mxbeans;
-
-import java.util.List;
-
-import javax.management.MXBean;
-
-@MXBean
-public interface RTMPConnectionMXBean extends AttributeStoreMXBean {
-
- public String getType();
-
- public String getHost();
-
- public String getRemoteAddress();
-
- public List getRemoteAddresses();
-
- public int getRemotePort();
-
- public String getPath();
-
- public String getSessionId();
-
- public boolean isConnected();
-
- public void close();
-
- public long getReadBytes();
-
- public long getWrittenBytes();
-
- public long getReadMessages();
-
- public long getWrittenMessages();
-
- public long getDroppedMessages();
-
- public long getPendingMessages();
-
- public long getPendingVideoMessages(int streamId);
-
-}
diff --git a/src/main/java/org/red5/server/jmx/mxbeans/RTMPMinaConnectionMXBean.java b/src/main/java/org/red5/server/jmx/mxbeans/RTMPMinaConnectionMXBean.java
deleted file mode 100644
index 0b5d48862..000000000
--- a/src/main/java/org/red5/server/jmx/mxbeans/RTMPMinaConnectionMXBean.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.jmx.mxbeans;
-
-import javax.management.MXBean;
-
-@MXBean
-public interface RTMPMinaConnectionMXBean extends RTMPConnectionMXBean {
-
- public void invokeMethod(String method);
-
-}
diff --git a/src/main/java/org/red5/server/jmx/mxbeans/RTMPMinaTransportMXBean.java b/src/main/java/org/red5/server/jmx/mxbeans/RTMPMinaTransportMXBean.java
deleted file mode 100644
index 7a7df8251..000000000
--- a/src/main/java/org/red5/server/jmx/mxbeans/RTMPMinaTransportMXBean.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.jmx.mxbeans;
-
-import javax.management.MXBean;
-
-/**
- *
- */
-@MXBean
-public interface RTMPMinaTransportMXBean {
- public void setIoThreads(int ioThreads);
-
- public void setTcpNoDelay(boolean tcpNoDelay);
-
- public void setUseHeapBuffers(boolean useHeapBuffers);
-
- public String getAddress();
-
- public String getStatistics();
-
- public void start() throws Exception;
-
- public void stop();
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/jmx/mxbeans/ScopeMXBean.java b/src/main/java/org/red5/server/jmx/mxbeans/ScopeMXBean.java
deleted file mode 100644
index 9dec2fc03..000000000
--- a/src/main/java/org/red5/server/jmx/mxbeans/ScopeMXBean.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.jmx.mxbeans;
-
-import java.util.Set;
-
-import javax.management.MXBean;
-
-import org.red5.server.api.scope.ScopeType;
-
-/**
- * An MBean interface for the scope object.
- *
- * @author The Red5 Project
- * @author Paul Gregoire (mondain@gmail.com)
- */
-@MXBean
-public interface ScopeMXBean {
-
- /**
- * Check if scope is enabled
- * @return true if scope is enabled, false otherwise
- */
- public boolean getEnabled();
-
- /**
- * Enable or disable scope by setting enable flag
- * @param enabled Enable flag value
- */
- public void setEnabled(boolean enabled);
-
- /**
- * Check if scope is in running state
- * @return true if scope is in running state, false otherwise
- */
- public boolean getRunning();
-
- /**
- * Setter for autostart flag
- * @param autoStart Autostart flag value
- */
- public void setAutoStart(boolean autoStart);
-
- /**
- * Initialization actions, start if autostart is set to true
- */
- public void init();
-
- /**
- * Starts scope
- * @return true if scope has handler and it's start method returned true, false otherwise
- */
- public boolean start();
-
- /**
- * Stops scope
- */
- public void stop();
-
- /**
- * Destroys scope
- *
- * @throws Exception
- */
- public void destroy() throws Exception;
-
- /**
- * Set scope persistence class
- *
- * @param persistenceClass Scope's persistence class
- * @throws Exception Exception
- */
- public void setPersistenceClass(String persistenceClass) throws Exception;
-
- /**
- * Setter for child load path. Should be implemented in subclasses?
- * @param pattern Load path pattern
- */
- public void setChildLoadPath(String pattern);
-
- /**
- * Check whether scope has child scope with given name
- * @param name Child scope name
- * @return true if scope has child node with given name, false otherwise
- */
- public boolean hasChildScope(String name);
-
- /**
- * Check whether scope has child scope with given name and type
- * @param type Child scope type
- * @param name Child scope name
- * @return true if scope has child node with given name and type, false otherwise
- */
- public boolean hasChildScope(ScopeType type, String name);
-
- /**
- * Check if scope has a context
- * @return true if scope has context, false otherwise
- */
- public boolean hasContext();
-
- /**
- * Return scope context path
- * @return Scope context path
- */
- public String getContextPath();
-
- /**
- * Setter for scope name
- * @param name Scope name
- */
- public void setName(String name);
-
- /**
- * Return scope path calculated from parent path and parent scope name
- * @return Scope path
- */
- public String getPath();
-
- /**
- * Check if scope or it's parent has handler
- * @return true if scope or it's parent scope has a handler, false otherwise
- */
- public boolean hasHandler();
-
- /**
- * Check if scope has parent scope
- * @return true if scope has parent scope, false otherwise`
- */
- public boolean hasParent();
-
- /**
- * Set scope depth
- * @param depth Scope depth
- */
- public void setDepth(int depth);
-
- /**
- * return scope depth
- * @return Scope depth
- */
- public int getDepth();
-
- /**
- * Create child scope with given name
- * @param name Child scope name
- * @return true on success, false otherwise
- */
- public boolean createChildScope(String name);
-
- /**
- * Unregisters service handler by name
- * @param name Service handler name
- */
- public void unregisterServiceHandler(String name);
-
- /**
- * Return set of service handler names
- * @return Set of service handler names
- */
- public Set getServiceHandlerNames();
-
- /**
- * Return total number of connections to the scope.
- *
- * @return number of connections
- */
- public int getTotalConnections();
-
- /**
- * Return maximum number of concurrent connections to the scope.
- *
- * @return number of connections
- */
- public int getMaxConnections();
-
- /**
- * Return current number of connections to the scope.
- *
- * @return number of connections
- */
- public int getActiveConnections();
-
- /**
- * Return total number of clients connected to the scope.
- *
- * @return number of clients
- */
- public int getTotalClients();
-
- /**
- * Return maximum number of clients concurrently connected to the scope.
- *
- * @return number of clients
- */
- public int getMaxClients();
-
- /**
- * Return current number of clients connected to the scope.
- *
- * @return number of clients
- */
- public int getActiveClients();
-
- /**
- * Return total number of subscopes created.
- *
- * @return number of subscopes created
- */
- public int getTotalSubscopes();
-
- /**
- * Return maximum number of concurrently existing subscopes.
- *
- * @return number of subscopes
- */
- public int getMaxSubscopes();
-
- /**
- * Return number of currently existing subscopes.
- *
- * @return number of subscopes
- */
- public int getActiveSubscopes();
-
-}
diff --git a/src/main/java/org/red5/server/messaging/AbstractMessage.java b/src/main/java/org/red5/server/messaging/AbstractMessage.java
deleted file mode 100644
index 29d78e97c..000000000
--- a/src/main/java/org/red5/server/messaging/AbstractMessage.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-import java.util.Map;
-
-/**
- * Abstract base for all messages
- *
- * @see org.red5.server.messaging.IMessage
- */
-public class AbstractMessage implements IMessage {
-
- protected String messageID;
-
- protected String correlationID;
-
- protected String messageType;
-
- protected Map, ?> extraHeaders = null;
-
- /** {@inheritDoc} */
- public String getMessageID() {
- return messageID;
- }
-
- /** {@inheritDoc} */
- public void setMessageID(String id) {
- this.messageID = id;
- }
-
- /** {@inheritDoc} */
- public String getCorrelationID() {
- return correlationID;
- }
-
- /** {@inheritDoc} */
- public void setCorrelationID(String id) {
- this.correlationID = id;
- }
-
- /** {@inheritDoc} */
- public String getMessageType() {
- return messageType;
- }
-
- /** {@inheritDoc} */
- public void setMessageType(String type) {
- this.messageType = type;
- }
-
- /** {@inheritDoc} */
- public boolean getBooleanProperty(String name) {
- return false;
- }
-
- /** {@inheritDoc} */
- public void setBooleanProperty(String name, boolean value) {
- }
-
- /** {@inheritDoc} */
- public byte getByteProperty(String name) {
- return 0;
- }
-
- /** {@inheritDoc} */
- public void setByteProperty(String name, byte value) {
- }
-
- /** {@inheritDoc} */
- public double getDoubleProperty(String name) {
- return 0;
- }
-
- /** {@inheritDoc} */
- public void setDoubleProperty(String name, double value) {
- }
-
- /** {@inheritDoc} */
- public float getFloatProperty(String name) {
- return 0;
- }
-
- /** {@inheritDoc} */
- public void setFloatProperty(String name, float value) {
- }
-
- /** {@inheritDoc} */
- public int getIntProperty(String name) {
- return 0;
- }
-
- /** {@inheritDoc} */
- public void setIntProperty(String name, int value) {
- }
-
- /** {@inheritDoc} */
- public long getLongProperty(String name) {
- return 0;
- }
-
- /** {@inheritDoc} */
- public void setLongProperty(String name, long value) {
- }
-
- /** {@inheritDoc} */
- public short getShortProperty(String name) {
- return 0;
- }
-
- /** {@inheritDoc} */
- public void setShortProperty(String name, short value) {
- }
-
- /** {@inheritDoc} */
- public String getStringProperty(String name) {
- return null;
- }
-
- /** {@inheritDoc} */
- public void setStringProperty(String name, String value) {
- }
-
- /** {@inheritDoc} */
- public Object getObjectProperty(String name) {
- return null;
- }
-
- /** {@inheritDoc} */
- public void setObjectProperty(String name, Object value) {
- }
-
-}
diff --git a/src/main/java/org/red5/server/messaging/AbstractPipe.java b/src/main/java/org/red5/server/messaging/AbstractPipe.java
deleted file mode 100644
index c0a7a8ee9..000000000
--- a/src/main/java/org/red5/server/messaging/AbstractPipe.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
-
-/**
- * Abstract pipe that books providers/consumers and listeners.
- * Aim to ease the implementation of concrete pipes. For more
- * information on what pipe is, see IPipe interface documentation.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- *
- * @see org.red5.server.messaging.IPipe
- */
-public abstract class AbstractPipe implements IPipe {
-
- private static final Logger log = LoggerFactory.getLogger(AbstractPipe.class);
-
- /**
- * Pipe consumers list
- */
- protected volatile CopyOnWriteArrayList consumers = new CopyOnWriteArrayList();
-
- /**
- * Pipe providers list
- */
- protected volatile CopyOnWriteArrayList providers = new CopyOnWriteArrayList();
-
- /**
- * Event listeners
- */
- protected volatile CopyOnWriteArrayList listeners = new CopyOnWriteArrayList();
-
- /**
- * Executor service used to run pipe tasks.
- */
- private static ExecutorService taskExecutor;
-
- /**
- * Connect consumer to this pipe. Doesn't allow to connect one consumer twice.
- * Does register event listeners if instance of IPipeConnectionListener is given.
- *
- * @param consumer Consumer
- * @param paramMap Parameters passed with connection, used in concrete pipe implementations
- * @return true if consumer was added, false otherwise
- */
- public boolean subscribe(IConsumer consumer, Map paramMap) {
- // if consumer is listener object register it as listener
- if (consumer instanceof IPipeConnectionListener) {
- listeners.addIfAbsent((IPipeConnectionListener) consumer);
- }
- // pipe is possibly used by dozens of threads at once (like many subscribers for one server stream)
- return consumers.addIfAbsent(consumer);
- }
-
- /**
- * Connect provider to this pipe. Doesn't allow to connect one provider twice.
- * Does register event listeners if instance of IPipeConnectionListener is given.
- *
- * @param provider Provider
- * @param paramMap Parameters passed with connection, used in concrete pipe implementations
- * @return true if provider was added, false otherwise
- */
- public boolean subscribe(IProvider provider, Map paramMap) {
- // register event listener if given
- if (provider instanceof IPipeConnectionListener) {
- listeners.add((IPipeConnectionListener) provider);
- }
- return providers.addIfAbsent(provider);
- }
-
- /**
- * Disconnects provider from this pipe. Fires pipe connection event.
- * @param provider Provider that should be removed
- * @return true on success, false otherwise
- */
- public boolean unsubscribe(IProvider provider) {
- if (providers.remove(provider)) {
- fireProviderConnectionEvent(provider, PipeConnectionEvent.PROVIDER_DISCONNECT, null);
- listeners.remove(provider);
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Disconnects consumer from this pipe. Fires pipe connection event.
- * @param consumer Consumer that should be removed
- * @return true on success, false otherwise
- */
- public boolean unsubscribe(IConsumer consumer) {
- if (consumers.remove(consumer)) {
- fireConsumerConnectionEvent(consumer, PipeConnectionEvent.CONSUMER_DISCONNECT, null);
- listeners.remove(consumer);
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Registers pipe connect events listener
- * @param listener Listener
- */
- public void addPipeConnectionListener(IPipeConnectionListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Removes pipe connection listener
- * @param listener Listener
- */
- public void removePipeConnectionListener(IPipeConnectionListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Send out-of-band ("special") control message to all consumers
- *
- * @param provider Provider, may be used in concrete implementations
- * @param oobCtrlMsg Out-of-band control message
- */
- public void sendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg) {
- for (IConsumer consumer : consumers) {
- try {
- consumer.onOOBControlMessage(provider, this, oobCtrlMsg);
- } catch (Throwable t) {
- log.error("exception when passing OOBCM from provider to consumers", t);
- }
- }
- }
-
- /**
- * Send out-of-band ("special") control message to all providers
- *
- * @param consumer Consumer, may be used in concrete implementations
- * @param oobCtrlMsg Out-of-band control message
- */
- public void sendOOBControlMessage(IConsumer consumer, OOBControlMessage oobCtrlMsg) {
- for (IProvider provider : providers) {
- try {
- provider.onOOBControlMessage(consumer, this, oobCtrlMsg);
- } catch (Throwable t) {
- log.error("exception when passing OOBCM from consumer to providers", t);
- }
- }
- }
-
- /**
- * Getter for pipe connection events listeners
- *
- * @return Listeners
- */
- public List getListeners() {
- return Collections.unmodifiableList(listeners);
- }
-
- /**
- * Setter for pipe connection events listeners
- *
- * @param newListeners Listeners
- */
- public void setListeners(List newListeners) {
- listeners.clear();
- listeners.addAll(newListeners);
- }
-
- /**
- * Getter for providers
- *
- * @return Providers list
- */
- public List getProviders() {
- return Collections.unmodifiableList(providers);
- }
-
- /**
- * Getter for consumers
- *
- * @return consumers list
- */
- public List getConsumers() {
- return Collections.unmodifiableList(consumers);
- }
-
- /**
- * Broadcast consumer connection event
- *
- * @param consumer Consumer that has connected
- * @param type Event type
- * @param paramMap Parameters passed with connection
- */
- protected void fireConsumerConnectionEvent(IConsumer consumer, int type, Map paramMap) {
- // Create event object
- PipeConnectionEvent event = new PipeConnectionEvent(this);
- // Fill it up
- event.setConsumer(consumer);
- event.setType(type);
- event.setParamMap(paramMap);
- // Fire it
- firePipeConnectionEvent(event);
- }
-
- /**
- * Broadcast provider connection event
- * @param provider Provider that has connected
- * @param type Event type
- * @param paramMap Parameters passed with connection
- */
- protected void fireProviderConnectionEvent(IProvider provider, int type, Map paramMap) {
- PipeConnectionEvent event = new PipeConnectionEvent(this);
- event.setProvider(provider);
- event.setType(type);
- event.setParamMap(paramMap);
- firePipeConnectionEvent(event);
- }
-
- /**
- * Fire any pipe connection event and run all it's tasks
- * @param event Pipe connection event
- */
- protected void firePipeConnectionEvent(PipeConnectionEvent event) {
- for (IPipeConnectionListener element : listeners) {
- try {
- element.onPipeConnectionEvent(event);
- } catch (Throwable t) {
- log.error("Exception when handling pipe connection event", t);
- }
- }
- if (taskExecutor == null) {
- taskExecutor = Executors.newCachedThreadPool(new CustomizableThreadFactory("Pipe-"));
- }
- // Run all of event's tasks
- for (Runnable task : event.getTaskList()) {
- try {
- taskExecutor.execute(task);
- } catch (Throwable t) {
- log.warn("Exception executing pipe task {}", t);
- }
- }
- // Clear event's tasks list
- event.getTaskList().clear();
- }
-
- /**
- * Close the pipe
- */
- public void close() {
- //clean up collections
- if (consumers != null) {
- consumers.clear();
- consumers = null;
- }
- if (providers != null) {
- providers.clear();
- providers = null;
- }
- if (listeners != null) {
- listeners.clear();
- listeners = null;
- }
- }
-
-}
diff --git a/src/main/java/org/red5/server/messaging/IConsumer.java b/src/main/java/org/red5/server/messaging/IConsumer.java
deleted file mode 100644
index 1e8fef3c9..000000000
--- a/src/main/java/org/red5/server/messaging/IConsumer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-/**
- * Signature for the message consumer.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IConsumer extends IMessageComponent {
-
-}
diff --git a/src/main/java/org/red5/server/messaging/IFilter.java b/src/main/java/org/red5/server/messaging/IFilter.java
deleted file mode 100644
index c6a4591b2..000000000
--- a/src/main/java/org/red5/server/messaging/IFilter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-/**
- * Filter marker interface groups consumer and provider interfaces
- */
-public interface IFilter extends IConsumer, IProvider {
-
-}
diff --git a/src/main/java/org/red5/server/messaging/IMessage.java b/src/main/java/org/red5/server/messaging/IMessage.java
deleted file mode 100644
index 95622b8b6..000000000
--- a/src/main/java/org/red5/server/messaging/IMessage.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-/**
- * Common interface for all messages.
- *
Structure of messages is designed according to
- * JMS Message interface. Message is composed of header and body.
- * Header contains commonly used pre-defined headers
- * and extensible headers.
- *
- *
Each message has correlation ID that is never used so far and is subject to be removed in future.
- *
- *
Message has type and number of properties.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IMessage {
- /**
- * Return message id
- * @return Message id
- */
- String getMessageID();
-
- /**
- * Setter for new message id
- * @param id Message id
- */
- void setMessageID(String id);
-
- /**
- * Return correlation id
- * @return Correlation id
- */
- String getCorrelationID();
-
- /**
- * Setter for correlation id
- * @param id Correlation id
- */
- void setCorrelationID(String id);
-
- /**
- * Return message type
- * @return Message type
- */
- String getMessageType();
-
- /**
- * Setter for message type
- * @param type Message type
- */
- void setMessageType(String type);
-
- /**
- * Getter for boolean property
- * @param name Boolean property name
- * @return Boolean property
- */
- boolean getBooleanProperty(String name);
-
- /**
- * Add boolean property to message
- * @param name Boolean property name
- * @param value Boolean property value
- */
- void setBooleanProperty(String name, boolean value);
-
- /**
- * Add byte property to message
- * @param name Byte property name
- * @return Byte property value
- */
- byte getByteProperty(String name);
-
- /**
- * Add byte property to message
- * @param name Byte property name
- * @param value Byte property value
- */
- void setByteProperty(String name, byte value);
-
- /**
- * Return double property by name
- * @param name Double property name
- * @return Double property value
- */
- double getDoubleProperty(String name);
-
- /**
- * Add double property to message
- * @param name Double property name
- * @param value Double property value
- */
- void setDoubleProperty(String name, double value);
-
- /**
- * Return float property by name
- * @param name Float property name
- * @return Float property value
- */
- float getFloatProperty(String name);
-
- /**
- * Add float property to message
- * @param name Float property name
- * @param value Float property value
- */
- void setFloatProperty(String name, float value);
-
- /**
- * Return int property by name
- * @param name Int property name
- * @return Int property value
- */
- int getIntProperty(String name);
-
- /**
- * Add int property to message
- * @param name Int property name
- * @param value Int property value
- */
- void setIntProperty(String name, int value);
-
- /**
- * Return long property to message
- * @param name Long property name
- * @return Long property value
- */
- long getLongProperty(String name);
-
- /**
- * Add long property to message
- * @param name Long property name
- * @param value Long property value
- */
- void setLongProperty(String name, long value);
-
- /**
- * Return short property to message
- * @param name Short property name
- * @return Short property value
- */
- short getShortProperty(String name);
-
- /**
- * Add short property to message
- * @param name Short property name
- * @param value Short property value
- */
- void setShortProperty(String name, short value);
-
- /**
- * Return string property to message
- * @param name String property name
- * @return String property value
- */
- String getStringProperty(String name);
-
- /**
- * Add string property to message
- * @param name String property name
- * @param value String property value
- */
- void setStringProperty(String name, String value);
-
- /**
- * Return object property to message
- * @param name Object property name
- * @return Object property value
- */
- Object getObjectProperty(String name);
-
- /**
- * Add object property to message
- * @param name Object property name
- * @param value Object property value
- */
- void setObjectProperty(String name, Object value);
-}
diff --git a/src/main/java/org/red5/server/messaging/IMessageComponent.java b/src/main/java/org/red5/server/messaging/IMessageComponent.java
deleted file mode 100644
index 797c78334..000000000
--- a/src/main/java/org/red5/server/messaging/IMessageComponent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-/**
- * Message component handles out-of-band control messages
- */
-public interface IMessageComponent {
- /**
- *
- * @param source Message component source
- * @param pipe Connection pipe
- * @param oobCtrlMsg Out-of-band control message
- */
- void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg);
-}
diff --git a/src/main/java/org/red5/server/messaging/IMessageInput.java b/src/main/java/org/red5/server/messaging/IMessageInput.java
deleted file mode 100644
index 01477f8c1..000000000
--- a/src/main/java/org/red5/server/messaging/IMessageInput.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Input Endpoint for a consumer to connect.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IMessageInput {
- /**
- * Pull message from this input endpoint. Return
- * w/o waiting.
- * @return The pulled message or null if message is
- * not available.
- * @throws IOException on error
- */
- IMessage pullMessage() throws IOException;
-
- /**
- * Pull message from this input endpoint. Wait
- * wait milliseconds if message is not available.
- * @param wait milliseconds to wait when message is not
- * available.
- * @return The pulled message or null if message is
- * not available.
- */
- IMessage pullMessage(long wait);
-
- /**
- * Connect to a consumer.
- *
- * @param consumer Consumer
- * @param paramMap Parameters map
- * @return true when successfully subscribed,
- * false otherwise.
- */
- boolean subscribe(IConsumer consumer, Map paramMap);
-
- /**
- * Disconnect from a consumer.
- *
- * @param consumer Consumer to disconnect
- * @return true when successfully unsubscribed,
- * false otherwise.
- */
- boolean unsubscribe(IConsumer consumer);
-
- /**
- * Getter for consumers list.
- *
- * @return Consumers.
- */
- List getConsumers();
-
- /**
- * Send OOB Control Message to all providers on the other side of pipe.
- *
- * @param consumer
- * The consumer that sends the message
- * @param oobCtrlMsg
- * Out-of-band control message
- */
- void sendOOBControlMessage(IConsumer consumer, OOBControlMessage oobCtrlMsg);
-}
diff --git a/src/main/java/org/red5/server/messaging/IMessageOutput.java b/src/main/java/org/red5/server/messaging/IMessageOutput.java
deleted file mode 100644
index df3e38b91..000000000
--- a/src/main/java/org/red5/server/messaging/IMessageOutput.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Output Endpoint for a provider to connect.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IMessageOutput {
- /**
- * Push a message to this output endpoint. May block
- * the pusher when output can't handle the message at
- * the time.
- * @param message Message to be pushed.
- * @throws IOException If message could not be written.
- */
- void pushMessage(IMessage message) throws IOException;
-
- /**
- * Connect to a provider. Note that params passed has nothing to deal with
- * NetConnection.connect in client-side Flex/Flash RIA.
- *
- * @param provider Provider
- * @param paramMap Parameters passed with connection
- * @return true when successfully subscribed,
- * false otherwise.
- */
- boolean subscribe(IProvider provider, Map paramMap);
-
- /**
- * Disconnect from a provider.
- *
- * @param provider Provider
- * @return true when successfully unsubscribed,
- * false otherwise.
- */
- boolean unsubscribe(IProvider provider);
-
- /**
- * Getter for providers
- *
- * @return Providers
- */
- List getProviders();
-
- /**
- * Send OOB Control Message to all consumers on the other side of pipe.
- *
- * @param provider
- * The provider that sends the message
- * @param oobCtrlMsg
- * Out-of-band control message
- */
- void sendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg);
-}
diff --git a/src/main/java/org/red5/server/messaging/IPassive.java b/src/main/java/org/red5/server/messaging/IPassive.java
deleted file mode 100644
index dbf1ee6df..000000000
--- a/src/main/java/org/red5/server/messaging/IPassive.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-/**
- * Signature to mark a provider/consumer never actively providers/consumers
- * messages.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IPassive {
- public static final String KEY = IPassive.class.getName();
-}
diff --git a/src/main/java/org/red5/server/messaging/IPipe.java b/src/main/java/org/red5/server/messaging/IPipe.java
deleted file mode 100644
index 8293bc588..000000000
--- a/src/main/java/org/red5/server/messaging/IPipe.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-/**
- * A pipe is an object that connects message providers and
- * message consumers. Its main function is to transport messages
- * in kind of ways it provides.
- *
- * Pipes fire events as they go, these events are common way to work with pipes for
- * higher level parts of server.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IPipe extends IMessageInput, IMessageOutput {
- /**
- * Add connection event listener to pipe
- * @param listener Connection event listener
- */
- void addPipeConnectionListener(IPipeConnectionListener listener);
-
- /**
- * Add connection event listener to pipe
- * @param listener Connection event listener
- */
- void removePipeConnectionListener(IPipeConnectionListener listener);
-}
diff --git a/src/main/java/org/red5/server/messaging/IPipeConnectionListener.java b/src/main/java/org/red5/server/messaging/IPipeConnectionListener.java
deleted file mode 100644
index 75d53ba23..000000000
--- a/src/main/java/org/red5/server/messaging/IPipeConnectionListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-/**
- * A listener that wants to listen to events when
- * provider/consumer connects to or disconnects from
- * a specific pipe.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IPipeConnectionListener {
- /**
- * Pipe connection event handler
- * @param event Pipe connection event
- */
- void onPipeConnectionEvent(PipeConnectionEvent event);
-}
diff --git a/src/main/java/org/red5/server/messaging/IProvider.java b/src/main/java/org/red5/server/messaging/IProvider.java
deleted file mode 100644
index 4646b7e95..000000000
--- a/src/main/java/org/red5/server/messaging/IProvider.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-/**
- * Signature for message provider.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IProvider extends IMessageComponent {
-
-}
diff --git a/src/main/java/org/red5/server/messaging/IPushableConsumer.java b/src/main/java/org/red5/server/messaging/IPushableConsumer.java
deleted file mode 100644
index 15a2b63db..000000000
--- a/src/main/java/org/red5/server/messaging/IPushableConsumer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-import java.io.IOException;
-
-/**
- * A consumer that supports event-driven message handling and message pushing through pipes.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public interface IPushableConsumer extends IConsumer {
- public static final String KEY = IPushableConsumer.class.getName();
-
- /**
- * Pushes message through pipe
- *
- * @param pipe Pipe
- * @param message Message
- * @throws IOException if message could not be written
- */
- void pushMessage(IPipe pipe, IMessage message) throws IOException;
-}
diff --git a/src/main/java/org/red5/server/messaging/InMemoryPushPushPipe.java b/src/main/java/org/red5/server/messaging/InMemoryPushPushPipe.java
deleted file mode 100644
index 44fc7da73..000000000
--- a/src/main/java/org/red5/server/messaging/InMemoryPushPushPipe.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A simple in-memory version of push-push pipe. It is triggered by an active provider to push messages
- * through it to an event-driven consumer.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public class InMemoryPushPushPipe extends AbstractPipe {
-
- private static final Logger log = LoggerFactory.getLogger(InMemoryPushPushPipe.class);
-
- /** {@inheritDoc} */
- @Override
- public boolean subscribe(IConsumer consumer, Map paramMap) {
- if (consumer instanceof IPushableConsumer) {
- boolean success = super.subscribe(consumer, paramMap);
- if (success) {
- fireConsumerConnectionEvent(consumer, PipeConnectionEvent.CONSUMER_CONNECT_PUSH, paramMap);
- }
- return success;
- } else {
- throw new IllegalArgumentException("Non-pushable consumer not supported by PushPushPipe");
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean subscribe(IProvider provider, Map paramMap) {
- boolean success = super.subscribe(provider, paramMap);
- if (success) {
- fireProviderConnectionEvent(provider, PipeConnectionEvent.PROVIDER_CONNECT_PUSH, paramMap);
- }
- return success;
- }
-
- /** {@inheritDoc} */
- public IMessage pullMessage() {
- return null;
- }
-
- /** {@inheritDoc} */
- public IMessage pullMessage(long wait) {
- return null;
- }
-
- /**
- * Pushes a message out to all the PushableConsumers.
- *
- * @param message the message to be pushed to consumers.
- */
- public void pushMessage(IMessage message) throws IOException {
- for (IConsumer consumer : consumers) {
- try {
- IPushableConsumer pcon = (IPushableConsumer) consumer;
- pcon.pushMessage(this, message);
- } catch (Throwable t) {
- if (t instanceof IOException) {
- // Pass this along
- throw (IOException) t;
- }
- log.error("Exception when pushing message to consumer", t);
- }
- }
- }
-}
diff --git a/src/main/java/org/red5/server/messaging/OOBControlMessage.java b/src/main/java/org/red5/server/messaging/OOBControlMessage.java
deleted file mode 100644
index f6c2e3be0..000000000
--- a/src/main/java/org/red5/server/messaging/OOBControlMessage.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * Out-of-band control message used by inter-components communication
- * which are connected with pipes.
- * Out-of-band data is a separate data stream used for specific purposes (in TCP
- * it's referenced as "urgent data"), like lifecycle control.
- *
- * 'Target' is used to represent the receiver who may be
- * interested for receiving. It's a string of any form.
- * XXX shall we design a standard form for Target, like "class.instance"?
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public class OOBControlMessage implements Serializable {
- private static final long serialVersionUID = -6037348177653934300L;
- /**
- * Target
- */
- private String target;
- /**
- * Service name
- */
- private String serviceName;
- /**
- * Service params name
- */
- private Map serviceParamMap;
- /**
- * Result
- */
- private Object result;
-
- /**
- * Getter for property 'serviceName'.
- *
- * @return Value for property 'serviceName'.
- */
- public String getServiceName() {
- return serviceName;
- }
-
- /**
- * Setter for property 'serviceName'.
- *
- * @param serviceName Value to set for property 'serviceName'.
- */
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- /**
- * Getter for property 'serviceParamMap'.
- *
- * @return Value for property 'serviceParamMap'.
- */
- public Map getServiceParamMap() {
- return serviceParamMap;
- }
-
- /**
- * Setter for property 'serviceParamMap'.
- *
- * @param serviceParamMap Value to set for property 'serviceParamMap'.
- */
- public void setServiceParamMap(Map serviceParamMap) {
- this.serviceParamMap = serviceParamMap;
- }
-
- /**
- * Getter for property 'target'.
- *
- * @return Value for property 'target'.
- */
- public String getTarget() {
- return target;
- }
-
- /**
- * Setter for property 'target'.
- *
- * @param target Value to set for property 'target'.
- */
- public void setTarget(String target) {
- this.target = target;
- }
-
- /**
- * Getter for property 'result'.
- *
- * @return Value for property 'result'.
- */
- public Object getResult() {
- return result;
- }
-
- /**
- * Setter for property 'result'.
- *
- * @param result Value to set for property 'result'.
- */
- public void setResult(Object result) {
- this.result = result;
- }
-}
diff --git a/src/main/java/org/red5/server/messaging/PipeConnectionEvent.java b/src/main/java/org/red5/server/messaging/PipeConnectionEvent.java
deleted file mode 100644
index 3657198d1..000000000
--- a/src/main/java/org/red5/server/messaging/PipeConnectionEvent.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.messaging;
-
-import java.util.ArrayList;
-import java.util.EventObject;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Event object corresponds to the connect/disconnect events
- * among providers/consumers and pipes.
- *
- * @author The Red5 Project
- * @author Steven Gong (steven.gong@gmail.com)
- */
-public class PipeConnectionEvent extends EventObject {
-
- private static final long serialVersionUID = 9078843765378168072L;
-
- private List taskList = new ArrayList(3);
-
- /**
- * A provider connects as pull mode.
- */
- public static final int PROVIDER_CONNECT_PULL = 0;
-
- /**
- * A provider connects as push mode.
- */
- public static final int PROVIDER_CONNECT_PUSH = 1;
-
- /**
- * A provider disconnects.
- */
- public static final int PROVIDER_DISCONNECT = 2;
-
- /**
- * A consumer connects as pull mode.
- */
- public static final int CONSUMER_CONNECT_PULL = 3;
-
- /**
- * A consumer connects as push mode.
- */
- public static final int CONSUMER_CONNECT_PUSH = 4;
-
- /**
- * A consumer disconnects.
- */
- public static final int CONSUMER_DISCONNECT = 5;
-
- /**
- * Provider
- */
- private transient IProvider provider;
-
- /**
- * Consumer
- */
- private transient IConsumer consumer;
-
- /**
- * Event type
- */
- private int type;
-
- /**
- * Parameters map
- */
- private Map paramMap;
-
- /**
- * Construct an object with the specific pipe as the
- * source
- * @param source A pipe that triggers this event.
- */
- public PipeConnectionEvent(Object source) {
- super(source);
- }
-
- /**
- * Return pipe connection provider
- * @return Provider
- */
- public IProvider getProvider() {
- return provider;
- }
-
- /**
- * Setter for pipe connection provider
- * @param provider Provider
- */
- public void setProvider(IProvider provider) {
- this.provider = provider;
- }
-
- /**
- * Return pipe connection consumer
- * @return Consumer
- */
- public IConsumer getConsumer() {
- return consumer;
- }
-
- /**
- * Setter for pipe connection consumer
- * @param consumer Consumer
- */
- public void setConsumer(IConsumer consumer) {
- this.consumer = consumer;
- }
-
- /**
- * Return event type
- * @return Event type
- */
- public int getType() {
- return type;
- }
-
- /**
- * Setter for event type
- * @param type Event type
- */
- public void setType(int type) {
- this.type = type;
- }
-
- /**
- * Return event parameters as Map
- * @return Event parameters as Map
- */
- public Map getParamMap() {
- return paramMap;
- }
-
- /**
- * Setter for event parameters map
- * @param paramMap Event parameters as Map
- */
- public void setParamMap(Map paramMap) {
- this.paramMap = paramMap;
- }
-
- /**
- * Add task to list
- * @param task Task to add
- */
- public void addTask(Runnable task) {
- taskList.add(task);
- }
-
- /**
- * Return list of tasks
- * @return List of tasks
- */
- List getTaskList() {
- return taskList;
- }
-}
diff --git a/src/main/java/org/red5/server/net/ICommand.java b/src/main/java/org/red5/server/net/ICommand.java
deleted file mode 100644
index 55e0c1372..000000000
--- a/src/main/java/org/red5/server/net/ICommand.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.red5.server.net;
-
-import java.util.Map;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.server.api.service.IServiceCall;
-
-/**
- * Represents a "command" sent to or received from an end-point.
- *
- * @author Paul Gregoire (mondain@gmail.com)
- */
-public interface ICommand {
-
- int getTransactionId();
-
- IServiceCall getCall();
-
- Map getConnectionParams();
-
- IoBuffer getData();
-
-}
diff --git a/src/main/java/org/red5/server/net/IConnectionManager.java b/src/main/java/org/red5/server/net/IConnectionManager.java
deleted file mode 100644
index 83136cf60..000000000
--- a/src/main/java/org/red5/server/net/IConnectionManager.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net;
-
-import java.util.Collection;
-
-public interface IConnectionManager {
-
- /**
- * Returns a connection matching the given client id.
- *
- * @param clientId
- * @return connection
- */
- T getConnection(int clientId);
-
- /**
- * Adds a connection.
- *
- * @param conn
- */
- void setConnection(T conn);
-
- /**
- * Returns a connection matching the given session id.
- *
- * @param sessionId
- * @return connection
- */
- T getConnectionBySessionId(String sessionId);
-
- /**
- * Returns all the current connections. It doesn't remove anything.
- *
- * @return list of connections
- */
- Collection getAllConnections();
-
- /**
- * Creates a connection based on the given type class.
- *
- * @param connCls
- * @return connection
- */
- T createConnection(Class> connCls);
-
- /**
- * Creates a connection of the type specified with associated session id.
- *
- * @param connCls
- * @param sessionId
- */
- T createConnection(Class> connCls, String sessionId);
-
- /**
- * Removes a connection matching the client id specified. If found, the connection
- * will be returned.
- *
- * @param clientId
- * @return connection
- */
- T removeConnection(int clientId);
-
- /**
- * Removes a connection by the given sessionId.
- *
- * @param sessionId
- * @return connection that was removed
- */
- T removeConnection(String sessionId);
-
- /**
- * Removes all the connections from the set.
- * @return connections
- */
- Collection removeConnections();
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/net/IHandshake.java b/src/main/java/org/red5/server/net/IHandshake.java
deleted file mode 100644
index e7c5ce5e9..000000000
--- a/src/main/java/org/red5/server/net/IHandshake.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net;
-
-import org.apache.mina.core.buffer.IoBuffer;
-
-/**
- * Base interface for Handshake classes.
- *
- * @author Paul Gregoire (mondain@gmail.com)
- */
-public interface IHandshake {
-
- public IoBuffer doHandshake(IoBuffer input);
-
- public boolean validate(IoBuffer input);
-}
diff --git a/src/main/java/org/red5/server/net/protocol/HandshakeFailedException.java b/src/main/java/org/red5/server/net/protocol/HandshakeFailedException.java
deleted file mode 100644
index 5474906b0..000000000
--- a/src/main/java/org/red5/server/net/protocol/HandshakeFailedException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.protocol;
-
-public class HandshakeFailedException extends ProtocolException {
-
- /**
- *
- */
- private static final long serialVersionUID = 8255789603304183796L;
-
- /**
- * Create handshake failed exception with given message
- *
- * @param message message
- */
- public HandshakeFailedException(String message) {
- super(message);
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/protocol/ProtocolException.java b/src/main/java/org/red5/server/net/protocol/ProtocolException.java
deleted file mode 100644
index 8559a3650..000000000
--- a/src/main/java/org/red5/server/net/protocol/ProtocolException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.protocol;
-
-public class ProtocolException extends RuntimeException {
-
- /**
- * Base exception for all protocol exceptions.
- */
- private static final long serialVersionUID = -5380844081848027068L;
-
- /**
- * Create protocol exception with given message.
- *
- * @param message message
- */
- public ProtocolException(String message) {
- super(message);
- }
-
- /**
- * Create protocol exception with given message and cause.
- *
- * @param message message
- * @param cause cause
- */
- public ProtocolException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/protocol/RTMPDecodeState.java b/src/main/java/org/red5/server/net/protocol/RTMPDecodeState.java
deleted file mode 100644
index bf5b20e0a..000000000
--- a/src/main/java/org/red5/server/net/protocol/RTMPDecodeState.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.protocol;
-
-/**
- * Represents current decode state of the protocol.
- */
-public class RTMPDecodeState {
-
- /**
- * Session id to which this decoding state belongs.
- */
- public String sessionId;
-
- /**
- * Decoding finished successfully state constant.
- */
- public static byte DECODER_OK = 0x00;
-
- /**
- * Decoding continues state constant.
- */
- public static byte DECODER_CONTINUE = 0x01;
-
- /**
- * Decoder is buffering state constant.
- */
- public static byte DECODER_BUFFER = 0x02;
-
- /**
- * Classes like the RTMP state object will extend this marker interface.
- */
- private int decoderBufferAmount;
-
- /**
- * Current decoder state, decoder is stopped by default.
- */
- private byte decoderState = DECODER_OK;
-
- public RTMPDecodeState(String sessionId) {
- this.sessionId = sessionId;
- }
-
- /**
- * Returns current buffer amount.
- *
- * @return Buffer amount
- */
- public int getDecoderBufferAmount() {
- return decoderBufferAmount;
- }
-
- /**
- * Specifies buffer decoding amount
- *
- * @param amount Buffer decoding amount
- */
- public void bufferDecoding(int amount) {
- decoderState = DECODER_BUFFER;
- decoderBufferAmount = amount;
- }
-
- /**
- * Set decoding state as "needed to be continued".
- */
- public void continueDecoding() {
- decoderState = DECODER_CONTINUE;
- }
-
- /**
- * Checks whether remaining buffer size is greater or equal than buffer amount and so if it makes sense to start decoding.
- *
- * @param remaining Remaining buffer size
- * @return true if there is data to decode, false otherwise
- */
- public boolean canStartDecoding(int remaining) {
- return remaining >= decoderBufferAmount;
- }
-
- /**
- * Starts decoding. Sets state to "ready" and clears buffer amount.
- */
- public void startDecoding() {
- decoderState = DECODER_OK;
- decoderBufferAmount = 0;
- }
-
- /**
- * Checks whether decoding is complete.
- *
- * @return true if decoding has finished, false otherwise
- */
- public boolean hasDecodedObject() {
- return (decoderState == DECODER_OK);
- }
-
- /**
- * Checks whether decoding process can be continued.
- *
- * @return true if decoding can be continued, false otherwise
- */
- public boolean canContinueDecoding() {
- return (decoderState != DECODER_BUFFER);
- }
-
- /**
- * @return the sessionId
- */
- public String getSessionId() {
- return sessionId;
- }
-
- /**
- * @param sessionId the sessionId to set
- */
- public void setSessionId(String sessionId) {
- this.sessionId = sessionId;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "RTMPDecodeState [sessionId=" + sessionId + ", decoderState=" + decoderState + ", decoderBufferAmount=" + decoderBufferAmount + "]";
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/remoting/IRemotingCallback.java b/src/main/java/org/red5/server/net/remoting/IRemotingCallback.java
deleted file mode 100644
index 32a6be3f3..000000000
--- a/src/main/java/org/red5/server/net/remoting/IRemotingCallback.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.remoting;
-
-/**
- * Callback for asynchronous remoting calls.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public interface IRemotingCallback {
-
- /**
- * The result of a remoting call has been received.
- *
- * @param client Remoting client
- * @param method Remote method name
- * @param params Call parameters
- * @param result Call result
- */
- public void resultReceived(RemotingClient client, String method,
- Object[] params, Object result);
-
- /**
- * An error occured while performing the remoting call.
- *
- * @param client Remoting client
- * @param method Remoting method
- * @param params Call parameters
- * @param error Call result
- */
- public void errorReceived(RemotingClient client, String method,
- Object[] params, Throwable error);
-
-}
diff --git a/src/main/java/org/red5/server/net/remoting/RemotingClient.java b/src/main/java/org/red5/server/net/remoting/RemotingClient.java
deleted file mode 100644
index 7ada52682..000000000
--- a/src/main/java/org/red5/server/net/remoting/RemotingClient.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.remoting;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.util.EntityUtils;
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.io.amf.Input;
-import org.red5.io.amf.Output;
-import org.red5.io.client.IRemotingClient;
-import org.red5.io.object.Deserializer;
-import org.red5.io.object.RecordSet;
-import org.red5.io.object.Serializer;
-import org.red5.server.util.HttpConnectionUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Client interface for remoting calls.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- * @author Paul Gregoire (mondain@gmail.com)
- */
-public class RemotingClient implements IRemotingClient {
-
- protected static Logger log = LoggerFactory.getLogger(RemotingClient.class);
-
- /** Default timeout to use. */
- public static final int DEFAULT_TIMEOUT = 30000;
-
- /** Content MIME type for HTTP requests. */
- protected static final String CONTENT_TYPE = "application/x-amf";
-
- /** HTTP client for remoting calls. */
- protected HttpClient client;
-
- /** Url to connect to. */
- protected String url;
-
- /** Additional string to use while connecting. */
- protected String appendToUrl = "";
-
- /** Headers to send to the server. */
- protected Map headers = new ConcurrentHashMap();
-
- /** Thread pool to use for asynchronous requests. */
- protected static ExecutorService executor;
-
- /** Maximum pool threads */
- protected int poolSize = 1;
-
- /**
- * Dummy constructor used by the spring configuration.
- */
- public RemotingClient() {
- log.debug("RemotingClient created");
- }
-
- /**
- * Create new remoting client for the given url.
- *
- * @param url URL to connect to
- */
- public RemotingClient(String url) {
- this(url, DEFAULT_TIMEOUT);
- log.debug("RemotingClient created - url: {}", url);
- }
-
- /**
- * Create new remoting client for the given url and given timeout.
- *
- * @param url URL to connect to
- * @param timeout Timeout for one request in milliseconds
- */
- public RemotingClient(String url, int timeout) {
- client = HttpConnectionUtil.getClient(timeout);
- this.url = url;
- log.debug("RemotingClient created - url: {} timeout: {}", url, timeout);
- }
-
- public int getPoolSize() {
- return poolSize;
- }
-
- public void setPoolSize(int poolSize) {
- this.poolSize = poolSize;
- executor = Executors.newFixedThreadPool(poolSize);
- }
-
- /**
- * Encode the method call.
- *
- * @param method
- * Remote method being called
- * @param params
- * Method parameters
- * @return Byte buffer with data to perform remoting call
- */
- private IoBuffer encodeInvoke(String method, Object[] params) {
- log.debug("RemotingClient encodeInvoke - method: {} params: {}", method, params);
- IoBuffer result = IoBuffer.allocate(1024);
- result.setAutoExpand(true);
-
- // XXX: which is the correct version?
- result.putShort((short) 0);
- // Headers
- Collection hdr = headers.values();
- result.putShort((short) hdr.size());
- for (RemotingHeader header : hdr) {
- Output.putString(result, header.name);
- result.put(header.required ? (byte) 0x01 : (byte) 0x00);
- IoBuffer tmp = IoBuffer.allocate(1024);
- tmp.setAutoExpand(true);
- Output tmpOut = new Output(tmp);
- Serializer.serialize(tmpOut, header.data);
- tmp.flip();
- // Size of header data
- result.putInt(tmp.limit());
- // Header data
- result.put(tmp);
- tmp.free();
- tmp = null;
- }
- // One body
- result.putShort((short) 1);
-
- // Method name
- Output.putString(result, method);
-
- // Client callback for response
- Output.putString(result, "");
-
- // Serialize parameters
- IoBuffer tmp = IoBuffer.allocate(1024);
- tmp.setAutoExpand(true);
- Output tmpOut = new Output(tmp);
-
- //if the params are null send the NULL AMF type
- //this should fix APPSERVER-296
- if (params == null) {
- tmpOut.writeNull();
- } else {
- tmpOut.writeArray(params);
- }
- tmp.flip();
-
- // Store size and parameters
- result.putInt(tmp.limit());
- result.put(tmp);
- tmp.free();
- tmp = null;
-
- result.flip();
- return result;
- }
-
- /**
- * Process any headers sent in the response.
- *
- * @param in
- * Byte buffer with response data
- */
- @SuppressWarnings("static-access")
- protected void processHeaders(IoBuffer in) {
- log.debug("RemotingClient processHeaders - buffer limit: {}", (in != null ? in.limit() : 0));
- int version = in.getUnsignedShort(); // skip
- log.debug("Version: {}", version);
- // the version by now, AMF3 is not yet implemented
- int count = in.getUnsignedShort();
- log.debug("Count: {}", count);
- Input input = new Input(in);
- for (int i = 0; i < count; i++) {
- String name = input.getString(in);
- //String name = deserializer.deserialize(input, String.class);
- log.debug("Name: {}", name);
- boolean required = (in.get() == 0x01);
- log.debug("Required: {}", required);
- int len = in.getInt();
- log.debug("Length: {}", len);
- Object value = Deserializer.deserialize(input, Object.class);
- log.debug("Value: {}", value);
-
- // XXX: this is pretty much untested!!!
- if (RemotingHeader.APPEND_TO_GATEWAY_URL.equals(name)) {
- // Append string to gateway url
- appendToUrl = (String) value;
- } else if (RemotingHeader.REPLACE_GATEWAY_URL.equals(name)) {
- // Replace complete gateway url
- url = (String) value;
- // XXX: reset the ) {
- @SuppressWarnings("unchecked")
- Map valueMap = (Map) value;
- RemotingHeader header = new RemotingHeader((String) valueMap.get("name"), (Boolean) valueMap.get("mustUnderstand"), valueMap.get("data"));
- headers.put(header.name, header);
- } else {
- log.error("Expected Map but received {}", value);
- }
- } else {
- log.warn("Unsupported remoting header \"{}\" received with value \"{}\"", name, value);
- }
- }
- }
-
- /**
- * Decode response received from remoting server.
- *
- * @param data
- * Result data to decode
- * @return Object deserialized from byte buffer data
- */
- private Object decodeResult(IoBuffer data) {
- log.debug("decodeResult - data limit: {}", (data != null ? data.limit() : 0));
- processHeaders(data);
- int count = data.getUnsignedShort();
- if (count != 1) {
- throw new RuntimeException("Expected exactly one result but got " + count);
- }
- Input input = new Input(data);
- String target = input.getString(); // expect "/onResult"
- log.debug("Target: {}", target);
- String nullString = input.getString(); // expect "null"
- log.debug("Null string: {}", nullString);
- // Read return value
- return Deserializer.deserialize(input, Object.class);
- }
-
- /**
- * Send authentication data with each remoting request.
- *
- * @param userid User identifier
- * @param password Password
- */
- public void setCredentials(String userid, String password) {
- Map data = new HashMap();
- data.put("userid", userid);
- data.put("password", password);
- RemotingHeader header = new RemotingHeader(RemotingHeader.CREDENTIALS, true, data);
- headers.put(RemotingHeader.CREDENTIALS, header);
- }
-
- /**
- * Stop sending authentication data.
- */
- public void resetCredentials() {
- removeHeader(RemotingHeader.CREDENTIALS);
- }
-
- /**
- * Send an additional header to the server.
- *
- * @param name Header name
- * @param required Header required?
- * @param value Header body
- */
- public void addHeader(String name, boolean required, Object value) {
- RemotingHeader header = new RemotingHeader(name, required, value);
- headers.put(name, header);
- }
-
- /**
- * Stop sending a given header.
- *
- * @param name Header name
- */
- public void removeHeader(String name) {
- headers.remove(name);
- }
-
- /**
- * Invoke a method synchronously on the remoting server.
- *
- * @param method Method name
- * @param params Parameters passed to method
- * @return the result of the method call
- */
- public Object invokeMethod(String method, Object[] params) {
- log.debug("invokeMethod url: {}", (url + appendToUrl));
- IoBuffer resultBuffer = null;
- IoBuffer data = encodeInvoke(method, params);
- //setup POST
- HttpPost post = null;
- try {
- post = new HttpPost(url + appendToUrl);
- post.addHeader("Content-Type", CONTENT_TYPE);
- post.setEntity(new InputStreamEntity(data.asInputStream(), data.limit()));
- // execute the method
- HttpResponse response = client.execute(post);
- int code = response.getStatusLine().getStatusCode();
- log.debug("HTTP response code: {}", code);
- if (code / 100 != 2) {
- throw new RuntimeException("Didn't receive success from remoting server");
- } else {
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- //fix for Trac #676
- int contentLength = (int) entity.getContentLength();
- //default the content length to 16 if post doesn't contain a good value
- if (contentLength < 1) {
- contentLength = 16;
- }
- // get the response as bytes
- byte[] bytes = EntityUtils.toByteArray(entity);
- resultBuffer = IoBuffer.wrap(bytes);
- Object result = decodeResult(resultBuffer);
- if (result instanceof RecordSet) {
- // Make sure we can retrieve paged results
- ((RecordSet) result).setRemotingClient(this);
- }
- return result;
- }
- }
- } catch (Exception ex) {
- log.error("Error while invoking remoting method.", ex);
- post.abort();
- } finally {
- if (resultBuffer != null) {
- resultBuffer.free();
- resultBuffer = null;
- }
- data.free();
- data = null;
- }
- return null;
- }
-
- /**
- * Invoke a method asynchronously on the remoting server.
- *
- * @param method Method name
- * @param methodParams Parameters passed to method
- * @param callback Callback
- */
- public void invokeMethod(String method, Object[] methodParams, IRemotingCallback callback) {
- try {
- RemotingWorker worker = new RemotingWorker(this, method, methodParams, callback);
- executor.execute(worker);
- } catch (Exception err) {
- log.warn("Exception invoking method: {}", method, err);
- }
- }
-
- /**
- * Worker class that is used for asynchronous remoting calls.
- */
- public final static class RemotingWorker implements Runnable {
-
- private final RemotingClient client;
-
- private final String method;
-
- private final Object[] params;
-
- private final IRemotingCallback callback;
-
- /**
- * Execute task.
- *
- * @param client Remoting client
- * @param method Method name
- * @param params Parameters to pass to method on call
- * @param callback Callback
- */
- public RemotingWorker(RemotingClient client, String method, Object[] params, IRemotingCallback callback) {
- this.client = client;
- this.method = method;
- this.params = params;
- this.callback = callback;
- }
-
- public void run() {
- try {
- Object result = client.invokeMethod(method, params);
- callback.resultReceived(client, method, params, result);
- } catch (Exception err) {
- callback.errorReceived(client, method, params, err);
- }
- }
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/remoting/RemotingHeader.java b/src/main/java/org/red5/server/net/remoting/RemotingHeader.java
deleted file mode 100644
index 531e1671f..000000000
--- a/src/main/java/org/red5/server/net/remoting/RemotingHeader.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.remoting;
-
-import org.red5.server.api.remoting.IRemotingHeader;
-
-/**
- * Remoting header to be sent to a server.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public class RemotingHeader implements IRemotingHeader {
-
- /**
- * The name of the header.
- */
- protected String name;
-
- /**
- * Is this header required?
- */
- protected boolean required;
-
- /**
- * The actual data of the header.
- */
- protected Object data;
-
- /**
- * Create a new header to be sent through remoting.
- *
- * @param name Header name
- * @param required Header required?
- * @param data Header data
- */
- public RemotingHeader(String name, boolean required, Object data) {
- this.name = name;
- this.required = required;
- this.data = data;
- }
-
- /** {@inheritDoc} */
- public boolean getMustUnderstand() {
- return required;
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return name;
- }
-
- /** {@inheritDoc} */
- public Object getValue() {
- return data;
- }
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/BaseRTMPHandler.java b/src/main/java/org/red5/server/net/rtmp/BaseRTMPHandler.java
deleted file mode 100644
index bd49d9dc0..000000000
--- a/src/main/java/org/red5/server/net/rtmp/BaseRTMPHandler.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.red5.io.object.StreamAction;
-import org.red5.server.api.event.IEventDispatcher;
-import org.red5.server.api.service.IPendingServiceCall;
-import org.red5.server.api.service.IPendingServiceCallback;
-import org.red5.server.api.service.IServiceCall;
-import org.red5.server.api.stream.IClientStream;
-import org.red5.server.net.ICommand;
-import org.red5.server.net.rtmp.codec.RTMP;
-import org.red5.server.net.rtmp.event.BytesRead;
-import org.red5.server.net.rtmp.event.ChunkSize;
-import org.red5.server.net.rtmp.event.ClientBW;
-import org.red5.server.net.rtmp.event.IRTMPEvent;
-import org.red5.server.net.rtmp.event.Invoke;
-import org.red5.server.net.rtmp.event.Notify;
-import org.red5.server.net.rtmp.event.Ping;
-import org.red5.server.net.rtmp.event.ServerBW;
-import org.red5.server.net.rtmp.event.Unknown;
-import org.red5.server.net.rtmp.message.Constants;
-import org.red5.server.net.rtmp.message.Header;
-import org.red5.server.net.rtmp.message.Packet;
-import org.red5.server.net.rtmp.status.StatusCodes;
-import org.red5.server.so.SharedObjectMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Base class for all RTMP handlers.
- *
- * @author The Red5 Project
- */
-public abstract class BaseRTMPHandler implements IRTMPHandler, Constants, StatusCodes {
-
- private static Logger log = LoggerFactory.getLogger(BaseRTMPHandler.class);
-
- /** {@inheritDoc} */
- public void connectionOpened(RTMPConnection conn) {
- log.trace("connectionOpened - conn: {} state: {}", conn, conn.getState());
- conn.open();
- }
-
- /** {@inheritDoc} */
- public void messageReceived(RTMPConnection conn, Packet packet) throws Exception {
- log.trace("Connection: {}", conn.getSessionId());
- if (conn != null) {
- IRTMPEvent message = null;
- try {
- message = packet.getMessage();
- final Header header = packet.getHeader();
- final int streamId = header.getStreamId();
- final Channel channel = conn.getChannel(header.getChannelId());
- final IClientStream stream = conn.getStreamById(streamId);
- log.trace("Message received - stream id: {} channel: {} header: {}", streamId, channel.getId(), header);
- // set stream id on the connection
- conn.setStreamId(streamId);
- // increase number of received messages
- conn.messageReceived();
- // set the source of the message
- message.setSource(conn);
- // process based on data type
- final byte headerDataType = header.getDataType();
- log.trace("Header / message data type: {}", headerDataType);
- switch (headerDataType) {
- case TYPE_AGGREGATE:
- log.debug("Aggregate type data - header timer: {} size: {}", header.getTimer(), header.getSize());
- case TYPE_AUDIO_DATA:
- case TYPE_VIDEO_DATA:
- // mark the event as from a live source
- // log.trace("Marking message as originating from a Live source");
- message.setSourceType(Constants.SOURCE_TYPE_LIVE);
- // NOTE: If we respond to "publish" with "NetStream.Publish.BadName",
- // the client sends a few stream packets before stopping. We need to ignore them
- if (stream != null) {
- ((IEventDispatcher) stream).dispatchEvent(message);
- }
- break;
- case TYPE_FLEX_SHARED_OBJECT:
- case TYPE_SHARED_OBJECT:
- onSharedObject(conn, channel, header, (SharedObjectMessage) message);
- break;
- case TYPE_INVOKE:
- case TYPE_FLEX_MESSAGE:
- onCommand(conn, channel, header, (Invoke) message);
- IPendingServiceCall call = ((Invoke) message).getCall();
- if (message.getHeader().getStreamId() != 0 && call.getServiceName() == null && StreamAction.PUBLISH.equals(call.getServiceMethodName())) {
- if (stream != null) {
- // Only dispatch if stream really was created
- ((IEventDispatcher) stream).dispatchEvent(message);
- }
- }
- break;
- case TYPE_NOTIFY: // like an invoke, but does not return
- // anything and has a invoke / transaction
- // id of 0
- case TYPE_FLEX_STREAM_SEND:
- if (((Notify) message).getData() != null && stream != null) {
- // Stream metadata
- ((IEventDispatcher) stream).dispatchEvent(message);
- } else {
- onCommand(conn, channel, header, (Notify) message);
- }
- break;
- case TYPE_PING:
- onPing(conn, channel, header, (Ping) message);
- break;
- case TYPE_BYTES_READ:
- onStreamBytesRead(conn, channel, header, (BytesRead) message);
- break;
- case TYPE_CHUNK_SIZE:
- onChunkSize(conn, channel, header, (ChunkSize) message);
- break;
- case Constants.TYPE_CLIENT_BANDWIDTH: // onBWDone / peer bw
- log.debug("Client bandwidth: {}", message);
- onClientBandwidth(conn, channel, (ClientBW) message);
- break;
- case Constants.TYPE_SERVER_BANDWIDTH: // window ack size
- log.debug("Server bandwidth: {}", message);
- onServerBandwidth(conn, channel, (ServerBW) message);
- break;
- default:
- log.debug("Unknown type: {}", header.getDataType());
- }
- if (message instanceof Unknown) {
- log.info("Message type unknown: {}", message);
- }
- } catch (Throwable t) {
- log.error("Exception", t);
- }
- // XXX this may be causing 'missing' data if previous methods are
- // not making copies before buffering etc..
- if (message != null) {
- message.release();
- }
- }
- }
-
- /** {@inheritDoc} */
- public void messageSent(RTMPConnection conn, Packet packet) {
- log.trace("Message sent");
- // increase number of sent messages
- conn.messageSent(packet);
- }
-
- /** {@inheritDoc} */
- public void connectionClosed(RTMPConnection conn) {
- log.debug("connectionClosed: {}", conn.getSessionId());
- if (conn.getStateCode() != RTMP.STATE_DISCONNECTED) {
- // inform any callbacks for pending calls that the connection is
- // closed
- conn.sendPendingServiceCallsCloseError();
- // close the connection
- if (conn.getStateCode() != RTMP.STATE_DISCONNECTING) {
- conn.close();
- }
- // set as disconnected
- conn.setStateCode(RTMP.STATE_DISCONNECTED);
- // remove from the manager
- RTMPConnManager.getInstance().removeConnection(conn.getSessionId());
- }
- log.trace("connectionClosed: {}", conn);
- }
-
- /**
- * Return hostname for URL.
- *
- * @param url
- * URL
- * @return Hostname from that URL
- */
- protected String getHostname(String url) {
- log.debug("url: {}", url);
- String[] parts = url.split("/");
- if (parts.length == 2) {
- return "";
- } else {
- String host = parts[2];
- // strip out default port in case the client added the port
- // explicitly
- if (host.endsWith(":1935")) {
- // remove default port from connection string
- return host.substring(0, host.length() - 5);
- }
- return host;
- }
- }
-
- /**
- * Handler for pending call result. Dispatches results to all pending call
- * handlers.
- *
- * @param conn
- * Connection
- * @param invoke
- * Pending call result event context
- */
- protected void handlePendingCallResult(RTMPConnection conn, Invoke invoke) {
- final IServiceCall call = invoke.getCall();
- final IPendingServiceCall pendingCall = conn.retrievePendingCall(invoke.getTransactionId());
- if (pendingCall != null) {
- // The client sent a response to a previously made call.
- Object[] args = call.getArguments();
- if (args != null && args.length > 0) {
- // TODO: can a client return multiple results?
- pendingCall.setResult(args[0]);
- }
- Set callbacks = pendingCall.getCallbacks();
- if (!callbacks.isEmpty()) {
- HashSet tmp = new HashSet();
- tmp.addAll(callbacks);
- for (IPendingServiceCallback callback : tmp) {
- try {
- callback.resultReceived(pendingCall);
- } catch (Exception e) {
- log.error("Error while executing callback {}", callback, e);
- }
- }
- }
- }
- }
-
- /**
- * Chunk size change event handler. Abstract, to be implemented in
- * subclasses.
- *
- * @param conn
- * Connection
- * @param channel
- * Channel
- * @param source
- * Header
- * @param chunkSize
- * New chunk size
- */
- protected abstract void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize);
-
- /**
- * Command event handler, which current consists of an Invoke or Notify type
- * object.
- *
- * @param conn
- * Connection
- * @param channel
- * Channel
- * @param source
- * Header
- * @param command
- * event context
- */
- protected abstract void onCommand(RTMPConnection conn, Channel channel, Header source, ICommand command);
-
- /**
- * Ping event handler.
- *
- * @param conn
- * Connection
- * @param channel
- * Channel
- * @param source
- * Header
- * @param ping
- * Ping event context
- */
- protected abstract void onPing(RTMPConnection conn, Channel channel, Header source, Ping ping);
-
- /**
- * Server bandwidth / Window ACK size event handler.
- *
- * @param conn
- * Connection
- * @param channel
- * Channel
- * @param message
- * ServerBW
- */
- protected void onServerBandwidth(RTMPConnection conn, Channel channel, ServerBW message) {
-
- }
-
- /**
- * Client bandwidth / Peer bandwidth set event handler.
- *
- * @param conn
- * Connection
- * @param channel
- * Channel
- * @param message
- * ClientBW
- */
- protected void onClientBandwidth(RTMPConnection conn, Channel channel, ClientBW message) {
-
- }
-
- /**
- * Stream bytes read event handler.
- *
- * @param conn
- * Connection
- * @param channel
- * Channel
- * @param source
- * Header
- * @param streamBytesRead
- * Bytes read event context
- */
- protected void onStreamBytesRead(RTMPConnection conn, Channel channel, Header source, BytesRead streamBytesRead) {
- conn.receivedBytesRead(streamBytesRead.getBytesRead());
- }
-
- /**
- * Shared object event handler.
- *
- * @param conn
- * Connection
- * @param channel
- * Channel
- * @param source
- * Header
- * @param message
- * Shared object message
- */
- protected abstract void onSharedObject(RTMPConnection conn, Channel channel, Header source, SharedObjectMessage message);
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/Channel.java b/src/main/java/org/red5/server/net/rtmp/Channel.java
deleted file mode 100644
index bdb965f4f..000000000
--- a/src/main/java/org/red5/server/net/rtmp/Channel.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.server.api.scope.IScope;
-import org.red5.server.api.stream.IClientStream;
-import org.red5.server.api.stream.IRtmpSampleAccess;
-import org.red5.server.net.rtmp.event.IRTMPEvent;
-import org.red5.server.net.rtmp.event.Invoke;
-import org.red5.server.net.rtmp.event.Notify;
-import org.red5.server.net.rtmp.message.Header;
-import org.red5.server.net.rtmp.message.Packet;
-import org.red5.server.net.rtmp.status.Status;
-import org.red5.server.net.rtmp.status.StatusCodes;
-import org.red5.server.service.Call;
-import org.red5.server.service.PendingCall;
-import org.red5.server.stream.IStreamData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Identified connection that transfers packets.
- */
-public class Channel {
-
- protected static Logger log = LoggerFactory.getLogger(Channel.class);
-
- private final static String CALL_ON_STATUS = "onStatus";
-
- /**
- * RTMP connection used to transfer packets.
- */
- private final RTMPConnection connection;
-
- /**
- * Channel id
- */
- private final int id;
-
- /**
- * Creates channel from connection and channel id
- * @param conn Connection
- * @param channelId Channel id
- */
- public Channel(RTMPConnection conn, int channelId) {
- assert(conn != null);
- connection = conn;
- id = channelId;
- }
-
- /**
- * Closes channel with this id on RTMP connection.
- */
- public void close() {
- connection.closeChannel(id);
- }
-
- /**
- * Getter for id.
- *
- * @return Channel ID
- */
- public int getId() {
- return id;
- }
-
- /**
- * Getter for RTMP connection.
- *
- * @return RTMP connection
- */
- protected RTMPConnection getConnection() {
- return connection;
- }
-
- /**
- * Writes packet from event data to RTMP connection.
- *
- * @param event Event data
- */
- public void write(IRTMPEvent event) {
- if (!connection.isClosed()) {
- final IClientStream stream = connection.getStreamByChannelId(id);
- if (id > 3 && stream == null) {
- log.warn("Non-existant stream for channel id: {}, connection id: {} discarding: {}", id, connection.getSessionId());
- }
- // if the stream is non-existant, the event will go out with stream id == 0
- final int streamId = (stream == null) ? 0 : stream.getStreamId();
- write(event, streamId);
- } else {
- log.debug("Associated connection {} is closed, cannot write to channel: {}", connection.getSessionId(), id);
- }
- }
-
- /**
- * Writes packet from event data to RTMP connection and stream id.
- *
- * @param event Event data
- * @param streamId Stream id
- */
- private void write(IRTMPEvent event, int streamId) {
- log.trace("write channel: {} stream id: {}", id, streamId);
- final Header header = new Header();
- final Packet packet = new Packet(header, event);
- header.setChannelId(id);
- int ts = event.getTimestamp();
- if (ts != 0) {
- header.setTimer(event.getTimestamp());
- } else {
- // TODO may need to add generated timestamps at some point
-// int timestamp = connection.getTimer();
-// header.setTimerBase(timestamp);
-// event.setTimestamp(timestamp);
- }
- header.setStreamId(streamId);
- header.setDataType(event.getDataType());
- // should use RTMPConnection specific method..
- //log.trace("Connection type for write: {}", connection.getClass().getName());
- connection.write(packet);
- }
-
- /**
- * Discard an event routed to this channel.
- *
- * @param event
- */
- @SuppressWarnings("unused")
- private void discard(IRTMPEvent event) {
- if (event instanceof IStreamData>) {
- log.debug("Discarding: {}", ((IStreamData>) event).toString());
- IoBuffer data = ((IStreamData>) event).getData();
- if (data != null) {
- log.trace("Freeing discarded event data");
- data.free();
- data = null;
- }
- }
- event.setHeader(null);
- }
-
- /**
- * Sends status notification.
- *
- * @param status Status
- */
- public void sendStatus(Status status) {
- if (connection != null) {
- final boolean andReturn = !status.getCode().equals(StatusCodes.NS_DATA_START);
- final Invoke event = new Invoke();
- if (andReturn) {
- final PendingCall call = new PendingCall(null, CALL_ON_STATUS, new Object[] { status });
- if (status.getCode().equals(StatusCodes.NS_PLAY_START)) {
- IScope scope = connection.getScope();
- if (scope.getContext().getApplicationContext().containsBean(IRtmpSampleAccess.BEAN_NAME)) {
- IRtmpSampleAccess sampleAccess = (IRtmpSampleAccess) scope.getContext().getApplicationContext().getBean(IRtmpSampleAccess.BEAN_NAME);
- boolean videoAccess = sampleAccess.isVideoAllowed(scope);
- boolean audioAccess = sampleAccess.isAudioAllowed(scope);
- if (videoAccess || audioAccess) {
- final Call call2 = new Call(null, "|RtmpSampleAccess", null);
- Notify notify = new Notify();
- notify.setCall(call2);
- notify.setData(IoBuffer.wrap(new byte[] { 0x01, (byte) (audioAccess ? 0x01 : 0x00), 0x01, (byte) (videoAccess ? 0x01 : 0x00) }));
- write(notify, connection.getStreamIdForChannel(id));
- }
- }
- }
- event.setCall(call);
- } else {
- final Call call = new Call(null, CALL_ON_STATUS, new Object[] { status });
- event.setCall(call);
- }
- // send directly to the corresponding stream as for some status codes, no stream has been created and thus "getStreamByChannelId" will fail
- write(event, connection.getStreamIdForChannel(id));
- }
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "Channel [id=" + id + ", connection=" + connection + "]";
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/DeferredResult.java b/src/main/java/org/red5/server/net/rtmp/DeferredResult.java
deleted file mode 100644
index c21b77dae..000000000
--- a/src/main/java/org/red5/server/net/rtmp/DeferredResult.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.lang.ref.WeakReference;
-
-import org.red5.server.api.service.IPendingServiceCall;
-import org.red5.server.net.rtmp.event.Invoke;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Can be returned to delay returning the result of invoked methods.
- *
- * @author The Red5 Project
- * @author Joachim Bauch (jojo@struktur.de)
- */
-public class DeferredResult {
- /**
- * Logger
- */
- protected static Logger log = LoggerFactory.getLogger(DeferredResult.class);
-
- /**
- * Weak reference to used channel
- */
- private WeakReference channel;
-
- /**
- * Pending call object
- */
- private IPendingServiceCall call;
-
- /**
- * Transaction id
- */
- private int transactionId;
-
- /**
- * Results sent flag
- */
- private boolean resultSent = false;
-
- /**
- * Set the result of a method call and send to the caller.
- *
- * @param result deferred result of the method call
- */
- public void setResult(Object result) {
- if (resultSent) {
- throw new RuntimeException("You can only set the result once.");
- }
- this.resultSent = true;
- Channel channel = this.channel.get();
- if (channel == null) {
- log.warn("The client is no longer connected.");
- return;
- }
- call.setResult(result);
- Invoke reply = new Invoke();
- reply.setCall(call);
- reply.setTransactionId(transactionId);
- channel.write(reply);
- channel.getConnection().unregisterDeferredResult(this);
- }
-
- /**
- * Check if the result has been sent to the client.
- *
- * @return true if the result has been sent, otherwise false
- */
- public boolean wasSent() {
- return resultSent;
- }
-
- /**
- * Setter for transaction id.
- *
- * @param id Invocation object identifier
- */
- public void setTransactionId(int id) {
- this.transactionId = id;
- }
-
- /**
- * Setter for service call.
- *
- * @param call Service call
- */
- public void setServiceCall(IPendingServiceCall call) {
- this.call = call;
- }
-
- /**
- * Setter for channel.
- *
- * @param channel Channel
- */
- public void setChannel(Channel channel) {
- this.channel = new WeakReference(channel);
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/IRTMPHandler.java b/src/main/java/org/red5/server/net/rtmp/IRTMPHandler.java
deleted file mode 100644
index 016341547..000000000
--- a/src/main/java/org/red5/server/net/rtmp/IRTMPHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import org.red5.server.net.rtmp.message.Packet;
-
-/**
- * RTMP events handler
- */
-public interface IRTMPHandler {
-
- /**
- * Connection open event.
- *
- * @param conn Connection
- */
- public void connectionOpened(RTMPConnection conn);
-
- /**
- * Message received.
- *
- * @param conn Connection
- * @param packet Packet containing an RTMP message
- * @throws Exception
- */
- public void messageReceived(RTMPConnection conn, Packet packet) throws Exception;
-
- /**
- * Message sent.
- *
- * @param conn Connection
- * @param packet RTMP message
- */
- public void messageSent(RTMPConnection conn, Packet packet);
-
- /**
- * Connection closed.
- *
- * @param conn Connection
- */
- public void connectionClosed(RTMPConnection conn);
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/InboundHandshake.java b/src/main/java/org/red5/server/net/rtmp/InboundHandshake.java
deleted file mode 100644
index 64e94e09e..000000000
--- a/src/main/java/org/red5/server/net/rtmp/InboundHandshake.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.security.KeyPair;
-import java.util.Arrays;
-
-import javax.crypto.Cipher;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.commons.codec.binary.Hex;
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.server.api.Red5;
-import org.red5.server.net.rtmp.message.Constants;
-
-/**
- * Performs handshaking for server connections.
- *
- * @author Paul Gregoire
- */
-public class InboundHandshake extends RTMPHandshake {
-
- public InboundHandshake() {
- super();
- }
-
- /**
- * Generates response for versioned connections.
- *
- * @param input incoming RTMP bytes
- * @return outgoing handshake
- */
- public IoBuffer doHandshake(IoBuffer input) {
- log.trace("doHandshake: {}", input);
- if (log.isDebugEnabled()) {
- log.debug("Player encryption byte: {}", handshakeType);
- byte[] bIn = input.array();
- log.debug("Detecting flash player version {},{},{},{}", new Object[]{(bIn[4] & 0x0ff), (bIn[5] & 0x0ff), (bIn[6] & 0x0ff), (bIn[7] & 0x0ff)});
- //if the 5th byte is 0 then dont generate new-style handshake
- if (log.isTraceEnabled()) {
- log.trace("First few bytes (in): {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}", new Object[] {
- bIn[0], bIn[1], bIn[2], bIn[3], bIn[4],
- bIn[5], bIn[6], bIn[7], bIn[8], bIn[9],
- bIn[10], bIn[11], bIn[12], bIn[13], bIn[14],
- bIn[15] });
- //client version hex
- byte[] ver = new byte[4];
- System.arraycopy(bIn, 4, ver, 0, 4);
- log.trace("Version string: {}", Hex.encodeHexString(ver));
- //dump
- byte[] buf = new byte[KEY_LENGTH];
- System.arraycopy(bIn, 0, buf, 0, KEY_LENGTH);
- log.trace("Hex: {}", Hex.encodeHexString(buf));
- }
- }
- input.mark();
- byte versionByte = input.get(4);
- log.debug("Player version byte: {}", (versionByte & 0x0ff));
- input.reset();
- if (versionByte == 0) {
- return generateUnversionedHandshake(input);
- }
- //create output buffer
- IoBuffer output = IoBuffer.allocate(HANDSHAKE_SIZE_SERVER);
- input.mark();
- //make sure this is a client we can communicate with
- if (validate(input)) {
- log.debug("Valid RTMP client detected");
- } else {
- log.info("Invalid RTMP connection data detected, you may experience errors");
- }
- input.reset();
- log.debug("Using new style handshake");
- input.mark();
- //create all the dh stuff and add to handshake bytes
- prepareResponse(input);
- input.reset();
- if (handshakeType == RTMPConnection.RTMP_ENCRYPTED) {
- log.debug("Incoming public key [{}]: {}", incomingPublicKey.length, Hex.encodeHexString(incomingPublicKey));
- log.debug("Outgoing public key [{}]: {}", outgoingPublicKey.length, Hex.encodeHexString(outgoingPublicKey));
- byte[] sharedSecret = getSharedSecret(outgoingPublicKey, keyAgreement);
- // create output cipher
- byte[] digestOut = calculateHMAC_SHA256(outgoingPublicKey, sharedSecret);
- try {
- cipherOut = Cipher.getInstance("RC4");
- cipherOut.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(digestOut, 0, 16, "RC4"));
- } catch (Exception e) {
- log.warn("Encryption cipher creation failed", e);
- }
- // create input cipher
- byte[] digestIn = calculateHMAC_SHA256(incomingPublicKey, sharedSecret);
- try {
- cipherIn = Cipher.getInstance("RC4");
- cipherIn.init(Cipher.DECRYPT_MODE, new SecretKeySpec(digestIn, 0, 16, "RC4"));
- } catch (Exception e) {
- log.warn("Decryption cipher creation failed", e);
- }
- // update 'encoder / decoder state' for the RC4 keys
- // both parties *pretend* as if handshake part 2 (1536 bytes) was encrypted
- // effectively this hides / discards the first few bytes of encrypted session
- // which is known to increase the secure-ness of RC4
- // RC4 state is just a function of number of bytes processed so far
- // that's why we just run 1536 arbitrary bytes through the keys below
- byte[] dummyBytes = new byte[Constants.HANDSHAKE_SIZE];
- cipherIn.update(dummyBytes);
- cipherOut.update(dummyBytes);
- }
- input.mark();
- //create the server digest
- int serverDigestOffset = getDigestOffset(handshakeBytes);
- byte[] tempBuffer = new byte[Constants.HANDSHAKE_SIZE - DIGEST_LENGTH];
- System.arraycopy(handshakeBytes, 0, tempBuffer, 0, serverDigestOffset);
- System.arraycopy(handshakeBytes, serverDigestOffset + DIGEST_LENGTH, tempBuffer, serverDigestOffset, Constants.HANDSHAKE_SIZE - serverDigestOffset - DIGEST_LENGTH);
- //calculate the hash
- byte[] tempHash = calculateHMAC_SHA256(tempBuffer, GENUINE_FMS_KEY, 36);
- //add the digest
- System.arraycopy(tempHash, 0, handshakeBytes, serverDigestOffset, DIGEST_LENGTH);
- //compute the challenge digest
- byte[] inputBuffer = new byte[Constants.HANDSHAKE_SIZE - DIGEST_LENGTH];
- //log.debug("Before get: {}", input.position());
- input.get(inputBuffer);
- //log.debug("After get: {}", input.position());
- int keyChallengeIndex = getDigestOffset(inputBuffer);
- byte[] challengeKey = new byte[DIGEST_LENGTH];
- input.position(keyChallengeIndex);
- input.get(challengeKey, 0, DIGEST_LENGTH);
- input.reset();
- //compute key
- tempHash = calculateHMAC_SHA256(challengeKey, GENUINE_FMS_KEY, 68);
- //generate hash
- byte[] randBytes = new byte[Constants.HANDSHAKE_SIZE - DIGEST_LENGTH];
- random.nextBytes(randBytes);
- byte[] lastHash = calculateHMAC_SHA256(randBytes, tempHash, DIGEST_LENGTH);
- //set handshake with encryption type
- output.put(handshakeType);
- output.put(handshakeBytes);
- output.put(randBytes);
- output.put(lastHash);
- output.flip();
- if (log.isTraceEnabled()) {
- byte[] bOut = output.array();
- log.trace("First few bytes (out): {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}", new Object[] {
- bOut[0], bOut[1], bOut[2], bOut[3], bOut[4],
- bOut[5], bOut[6], bOut[7], bOut[8], bOut[9],
- bOut[10], bOut[11], bOut[12], bOut[13], bOut[14],
- bOut[15]});
- byte[] buf = new byte[KEY_LENGTH];
- System.arraycopy(bOut, 0, buf, 0, KEY_LENGTH);
- log.trace("Hex: {}", Hex.encodeHexString(buf));
- }
- return output;
- }
-
- /**
- * Generates response for non-versioned connections, such as those before FP9.
- *
- * @param input incoming RTMP bytes
- * @return outgoing handshake
- */
- private IoBuffer generateUnversionedHandshake(IoBuffer input) {
- log.debug("Using old style (un-versioned) handshake");
- //save resource by only doing this after the first request
- if (HANDSHAKE_PAD_BYTES == null) {
- HANDSHAKE_PAD_BYTES = new byte[Constants.HANDSHAKE_SIZE - 4];
- //fill pad bytes
- Arrays.fill(HANDSHAKE_PAD_BYTES, (byte) 0x00);
- }
- IoBuffer output = IoBuffer.allocate(HANDSHAKE_SIZE_SERVER);
- //non-encrypted
- output.put(RTMPConnection.RTMP_NON_ENCRYPTED);
- //set server uptime in seconds
- output.putInt((int) Red5.getUpTime() / 1000); //0x01
- output.put(RTMPHandshake.HANDSHAKE_PAD_BYTES);
- output.put(input);
- output.flip();
- return output;
- }
-
- /**
- * Creates the servers handshake bytes
- */
- @Override
- protected void createHandshakeBytes() {
- handshakeBytes = new byte[Constants.HANDSHAKE_SIZE];
- //timestamp
- handshakeBytes[0] = 0;
- handshakeBytes[1] = 0;
- handshakeBytes[2] = 0;
- handshakeBytes[3] = 0;
- //version (0x01020304)
- handshakeBytes[4] = 1;
- handshakeBytes[5] = 2;
- handshakeBytes[6] = 3;
- handshakeBytes[7] = 4;
- //fill the rest with random bytes
- byte[] rndBytes = new byte[Constants.HANDSHAKE_SIZE - 8];
- random.nextBytes(rndBytes);
- //copy random bytes into our handshake array
- System.arraycopy(rndBytes, 0, handshakeBytes, 8, (Constants.HANDSHAKE_SIZE - 8));
- }
-
- /**
- * Gets the DH offset in the handshake bytes array based on validation scheme
- * Generates DH keypair
- * Adds public key to handshake bytes
- * @param input
- */
- private void prepareResponse(IoBuffer input) {
- //put the clients input into a byte array
- byte[] inputBuffer = new byte[input.limit()];
- input.get(inputBuffer);
- //get the clients dh offset
- int clientDHOffset = getDHOffset(inputBuffer);
- log.trace("Incoming DH offset: {}", clientDHOffset);
- //get the clients public key
- outgoingPublicKey = new byte[KEY_LENGTH];
- System.arraycopy(inputBuffer, clientDHOffset, outgoingPublicKey, 0, KEY_LENGTH);
- //get the servers dh offset
- int serverDHOffset = getDHOffset(handshakeBytes);
- log.trace("Outgoing DH offset: {}", serverDHOffset);
- //create keypair
- KeyPair keys = generateKeyPair();
- //get public key
- incomingPublicKey = getPublicKey(keys);
- //add to handshake bytes
- System.arraycopy(incomingPublicKey, 0, handshakeBytes, serverDHOffset, KEY_LENGTH);
- }
-
- /**
- * Determines the validation scheme for given input.
- *
- * @param input
- * @return true if client used a supported validation scheme, false if unsupported
- */
- @Override
- public boolean validate(IoBuffer input) {
- byte[] pBuffer = new byte[input.remaining()];
- //put all the input bytes into our buffer
- input.get(pBuffer, 0, input.remaining());
- if (validateScheme(pBuffer, 0)) {
- validationScheme = 0;
- log.debug("Selected scheme: 0");
- return true;
- }
- if (validateScheme(pBuffer, 1)) {
- validationScheme = 1;
- log.debug("Selected scheme: 1");
- return true;
- }
- log.error("Unable to validate client");
- return false;
- }
-
- private boolean validateScheme(byte[] pBuffer, int scheme) {
- int digestOffset = -1;
- switch (scheme) {
- case 0:
- digestOffset = getDigestOffset0(pBuffer);
- break;
- case 1:
- digestOffset = getDigestOffset1(pBuffer);
- break;
- default:
- log.error("Unknown scheme: {}", scheme);
- }
- log.debug("Scheme: {} client digest offset: {}", scheme, digestOffset);
-
- byte[] tempBuffer = new byte[Constants.HANDSHAKE_SIZE - DIGEST_LENGTH];
- System.arraycopy(pBuffer, 0, tempBuffer, 0, digestOffset);
- System.arraycopy(pBuffer, digestOffset + DIGEST_LENGTH, tempBuffer, digestOffset, Constants.HANDSHAKE_SIZE - digestOffset - DIGEST_LENGTH);
-
- byte[] tempHash = calculateHMAC_SHA256(tempBuffer, GENUINE_FP_KEY, 30);
- log.debug("Temp: {}", Hex.encodeHexString(tempHash));
-
- boolean result = true;
- for (int i = 0; i < DIGEST_LENGTH; i++) {
- //log.trace("Digest: {} Temp: {}", (pBuffer[digestOffset + i] & 0x0ff), (tempHash[i] & 0x0ff));
- if (pBuffer[digestOffset + i] != tempHash[i]) {
- result = false;
- break;
- }
- }
-
- return result;
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/RTMPConnManager.java b/src/main/java/org/red5/server/net/rtmp/RTMPConnManager.java
deleted file mode 100644
index b5c9adc6f..000000000
--- a/src/main/java/org/red5/server/net/rtmp/RTMPConnManager.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.management.JMX;
-import javax.management.ObjectName;
-
-import org.apache.mina.core.session.IoSession;
-import org.red5.server.api.Red5;
-import org.red5.server.api.scope.IBasicScope;
-import org.red5.server.jmx.mxbeans.RTMPMinaTransportMXBean;
-import org.red5.server.net.IConnectionManager;
-import org.red5.server.net.rtmpt.RTMPTConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
-
-/**
- * Responsible for management and creation of RTMP based connections.
- *
- * @author The Red5 Project
- */
-public class RTMPConnManager implements IConnectionManager, ApplicationContextAware, DisposableBean {
-
- private static final Logger log = LoggerFactory.getLogger(RTMPConnManager.class);
-
- protected static ApplicationContext applicationContext;
-
- private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1, new CustomizableThreadFactory("ConnectionChecker-"));
-
- protected ConcurrentMap connMap = new ConcurrentHashMap();
-
- protected AtomicInteger conns = new AtomicInteger();
-
- protected static IConnectionManager instance;
-
- protected boolean debug;
-
- {
- // create a scheduled job to check for dead or hung connections
- executor.scheduleAtFixedRate(new Runnable() {
- public void run() {
- // count the connections that need closing
- int closedConnections = 0;
- // get all the current connections
- Collection allConns = getAllConnections();
- log.debug("Checking {} connections", allConns.size());
- for (RTMPConnection conn : allConns) {
- if (log.isTraceEnabled()) {
- log.trace("{} session: {} state: {} keep-alive running: {}", new Object[] { conn.getClass().getSimpleName(), conn.getSessionId(), conn.getState().states[conn.getStateCode()], conn.running });
- log.trace("Decoder lock - permits: {} queue length: {}", conn.decoderLock.availablePermits(), conn.decoderLock.getQueueLength());
- log.trace("Encoder lock - permits: {} queue length: {}", conn.encoderLock.availablePermits(), conn.encoderLock.getQueueLength());
- log.trace("Client streams: {} used: {}", conn.getStreams().size(), conn.getUsedStreamCount());
- log.trace("Attributes: {}", conn.getAttributes());
- Iterator scopes = conn.getBasicScopes();
- while (scopes.hasNext()) {
- IBasicScope scope = scopes.next();
- log.trace("Scope: {}", scope);
- }
- }
- long ioTime = 0L;
- IoSession session = null;
- if (conn instanceof RTMPMinaConnection) {
- session = ((RTMPMinaConnection) conn).getIoSession();
- ioTime = System.currentTimeMillis() - session.getLastIoTime();
- if (log.isTraceEnabled()) {
- log.trace("Session - write queue: {} last io time: {} ms", session.getWriteRequestQueue().size(), ioTime);
- log.trace("Managed session count: {}", session.getService().getManagedSessionCount());
- }
- } else if (conn instanceof RTMPTConnection) {
- ioTime = System.currentTimeMillis() - ((RTMPTConnection) conn).getLastDataReceived();
- }
- // if exceeds max inactivity kill and clean up
- if (ioTime >= conn.maxInactivity) {
- log.warn("Connection {} has exceeded the max inactivity threshold", conn.getSessionId());
- if (session != null) {
- if (log.isDebugEnabled()) {
- log.debug("Prepared to clear write queue, if session is connected: {}; closing? {}", session.isConnected(), session.isClosing());
- }
- if (session.isConnected()) {
- // clear the write queue
- session.getWriteRequestQueue().clear(session);
- }
- }
- // call onInactive on the connection, this should cleanly close everything out
- conn.onInactive();
- if (!conn.isClosed()) {
- log.debug("Connection {} is not closed", conn.getSessionId());
- }
- closedConnections++;
- }
- }
- // if there is more than one connection that needed to be closed, request a GC to clean up memory.
- if (closedConnections > 0) {
- System.gc();
- }
- }
- }, 7000, 30000, TimeUnit.MILLISECONDS);
- }
-
- public static IConnectionManager getInstance() {
- if (instance == null) {
- log.trace("Connection manager instance does not exist");
- if (applicationContext != null && applicationContext.containsBean("rtmpConnManager")) {
- log.trace("Connection manager bean exists");
- instance = (RTMPConnManager) applicationContext.getBean("rtmpConnManager");
- } else {
- log.trace("Connection manager bean doesnt exist, creating new instance");
- instance = new RTMPConnManager();
- }
- }
- return instance;
- }
-
- /** {@inheritDoc} */
- public RTMPConnection createConnection(Class> connCls) {
- RTMPConnection conn = null;
- if (RTMPConnection.class.isAssignableFrom(connCls)) {
- try {
- // create connection
- conn = createConnectionInstance(connCls);
- // add to local map
- connMap.put(conn.getSessionId(), conn);
- log.trace("Connections: {}", conns.incrementAndGet());
- // set the scheduler
- if (applicationContext.containsBean("rtmpScheduler") && conn.getScheduler() == null) {
- conn.setScheduler((ThreadPoolTaskScheduler) applicationContext.getBean("rtmpScheduler"));
- }
- log.trace("Connection created: {}", conn);
- // start the wait for handshake
- conn.startWaitForHandshake();
- } catch (Exception ex) {
- log.warn("Exception creating connection", ex);
- }
- }
- return conn;
- }
-
- /** {@inheritDoc} */
- public RTMPConnection createConnection(Class> connCls, String sessionId) {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- /**
- * Adds a connection.
- *
- * @param conn
- */
- public void setConnection(RTMPConnection conn) {
- log.trace("Adding connection: {}", conn);
- int id = conn.getId();
- if (id == -1) {
- log.debug("Connection has unsupported id, using session id hash");
- id = conn.getSessionId().hashCode();
- }
- log.debug("Connection id: {} session id hash: {}", conn.getId(), conn.getSessionId().hashCode());
- if (debug) {
- log.info("Connection count (map): {}", connMap.size());
- try {
- RTMPMinaTransportMXBean proxy = JMX.newMXBeanProxy(ManagementFactory.getPlatformMBeanServer(), new ObjectName("org.red5.server:type=RTMPMinaTransport"),
- RTMPMinaTransportMXBean.class, true);
- if (proxy != null) {
- log.info("{}", proxy.getStatistics());
- }
- } catch (Exception e) {
- log.warn("Error on jmx lookup", e);
- }
- }
- }
-
- /**
- * Returns a connection for a given client id.
- *
- * @param clientId
- * @return connection if found and null otherwise
- */
- public RTMPConnection getConnection(int clientId) {
- log.trace("Getting connection by client id: {}", clientId);
- for (RTMPConnection conn : connMap.values()) {
- if (conn.getId() == clientId) {
- return connMap.get(conn.getSessionId());
- }
- }
- return null;
- }
-
- /**
- * Returns a connection for a given session id.
- *
- * @param sessionId
- * @return connection if found and null otherwise
- */
- public RTMPConnection getConnectionBySessionId(String sessionId) {
- log.trace("Getting connection by session id: {}", sessionId);
- if (connMap.containsKey(sessionId)) {
- return connMap.get(sessionId);
- } else {
- log.warn("Connection not found for {}", sessionId);
- if (log.isTraceEnabled()) {
- log.trace("Connections ({}) {}", connMap.size(), connMap.values());
- }
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public RTMPConnection removeConnection(int clientId) {
- log.trace("Removing connection with id: {}", clientId);
- // remove from map
- for (RTMPConnection conn : connMap.values()) {
- if (conn.getId() == clientId) {
- // remove the conn
- return removeConnection(conn.getSessionId());
- }
- }
- log.warn("Connection was not removed by id: {}", clientId);
- return null;
- }
-
- /** {@inheritDoc} */
- public RTMPConnection removeConnection(String sessionId) {
- log.trace("Removing connection with session id: {}", sessionId);
- if (log.isTraceEnabled()) {
- log.trace("Connections ({}) at pre-remove: {}", connMap.size(), connMap.values());
- }
- // remove from map
- RTMPConnection conn = connMap.remove(sessionId);
- if (conn != null) {
- log.trace("Connections: {}", conns.decrementAndGet());
- Red5.setConnectionLocal(null);
- }
- return conn;
- }
-
- /** {@inheritDoc} */
- public Collection getAllConnections() {
- ArrayList list = new ArrayList(connMap.size());
- list.addAll(connMap.values());
- return list;
- }
-
- /** {@inheritDoc} */
- public Collection removeConnections() {
- ArrayList list = new ArrayList(connMap.size());
- list.addAll(connMap.values());
- connMap.clear();
- conns.set(0);
- return list;
- }
-
- /**
- * Creates a connection instance based on the supplied type.
- *
- * @param cls
- * @return connection
- * @throws Exception
- */
- public RTMPConnection createConnectionInstance(Class> cls) throws Exception {
- RTMPConnection conn = null;
- if (cls == RTMPMinaConnection.class) {
- conn = (RTMPMinaConnection) applicationContext.getBean(RTMPMinaConnection.class);
- } else if (cls == RTMPTConnection.class) {
- conn = (RTMPTConnection) applicationContext.getBean(RTMPTConnection.class);
- } else {
- conn = (RTMPConnection) cls.newInstance();
- }
- return conn;
- }
-
- /**
- * @param debug the debug to set
- */
- public void setDebug(boolean debug) {
- this.debug = debug;
- }
-
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- RTMPConnManager.applicationContext = applicationContext;
- }
-
- public void destroy() throws Exception {
- executor.shutdownNow();
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java b/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java
deleted file mode 100755
index 8723b6f7b..000000000
--- a/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java
+++ /dev/null
@@ -1,1618 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.beans.ConstructorProperties;
-import java.util.BitSet;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.server.BaseConnection;
-import org.red5.server.api.Red5;
-import org.red5.server.api.event.IEvent;
-import org.red5.server.api.scope.IScope;
-import org.red5.server.api.service.IPendingServiceCall;
-import org.red5.server.api.service.IPendingServiceCallback;
-import org.red5.server.api.service.IServiceCall;
-import org.red5.server.api.service.IServiceCapableConnection;
-import org.red5.server.api.stream.IClientBroadcastStream;
-import org.red5.server.api.stream.IClientStream;
-import org.red5.server.api.stream.IPlaylistSubscriberStream;
-import org.red5.server.api.stream.ISingleItemSubscriberStream;
-import org.red5.server.api.stream.IStreamCapableConnection;
-import org.red5.server.api.stream.IStreamService;
-import org.red5.server.exception.ClientRejectedException;
-import org.red5.server.net.protocol.RTMPDecodeState;
-import org.red5.server.net.rtmp.codec.RTMP;
-import org.red5.server.net.rtmp.event.BytesRead;
-import org.red5.server.net.rtmp.event.ClientBW;
-import org.red5.server.net.rtmp.event.ClientInvokeEvent;
-import org.red5.server.net.rtmp.event.ClientNotifyEvent;
-import org.red5.server.net.rtmp.event.Invoke;
-import org.red5.server.net.rtmp.event.Notify;
-import org.red5.server.net.rtmp.event.Ping;
-import org.red5.server.net.rtmp.event.ServerBW;
-import org.red5.server.net.rtmp.event.VideoData;
-import org.red5.server.net.rtmp.message.Constants;
-import org.red5.server.net.rtmp.message.Header;
-import org.red5.server.net.rtmp.message.Packet;
-import org.red5.server.net.rtmp.status.Status;
-import org.red5.server.service.Call;
-import org.red5.server.service.PendingCall;
-import org.red5.server.so.FlexSharedObjectMessage;
-import org.red5.server.so.ISharedObjectEvent;
-import org.red5.server.so.SharedObjectMessage;
-import org.red5.server.stream.ClientBroadcastStream;
-import org.red5.server.stream.OutputStream;
-import org.red5.server.stream.PlaylistSubscriberStream;
-import org.red5.server.stream.SingleItemSubscriberStream;
-import org.red5.server.stream.StreamService;
-import org.red5.server.util.ScopeUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.task.TaskRejectedException;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
-import org.springframework.util.concurrent.ListenableFuture;
-import org.springframework.util.concurrent.ListenableFutureCallback;
-import org.springframework.util.concurrent.ListenableFutureTask;
-
-/**
- * RTMP connection. Stores information about client streams, data transfer channels, pending RPC calls, bandwidth configuration,
- * AMF encoding type (AMF0/AMF3), connection state (is alive, last ping time and ping result) and session.
- */
-public abstract class RTMPConnection extends BaseConnection implements IStreamCapableConnection, IServiceCapableConnection {
-
- private static Logger log = LoggerFactory.getLogger(RTMPConnection.class);
-
- public static final String RTMP_SESSION_ID = "rtmp.sessionid";
-
- public static final String RTMP_HANDSHAKE = "rtmp.handshake";
-
- /**
- * Marker byte for standard or non-encrypted RTMP data.
- */
- public static final byte RTMP_NON_ENCRYPTED = (byte) 0x03;
-
- /**
- * Marker byte for encrypted RTMP data.
- */
- public static final byte RTMP_ENCRYPTED = (byte) 0x06;
-
- /**
- * Cipher for RTMPE input
- */
- public static final String RTMPE_CIPHER_IN = "rtmpe.cipher.in";
-
- /**
- * Cipher for RTMPE output
- */
- public static final String RTMPE_CIPHER_OUT = "rtmpe.cipher.out";
-
- /**
- * Connection channels
- *
- * @see org.red5.server.net.rtmp.Channel
- */
- private ConcurrentMap channels = new ConcurrentHashMap(3, 0.9f, 1);
-
- /**
- * Client streams
- *
- * @see org.red5.server.api.stream.IClientStream
- */
- private ConcurrentMap streams = new ConcurrentHashMap(1, 0.9f, 1);
-
- /**
- * Reserved stream ids. Stream id's directly relate to individual NetStream instances.
- */
- private volatile BitSet reservedStreams = new BitSet();
-
- /**
- * Transaction identifier for remote commands.
- */
- private AtomicInteger transactionId = new AtomicInteger(1);
-
- /**
- * Hash map that stores pending calls and ids as pairs.
- */
- private ConcurrentMap pendingCalls = new ConcurrentHashMap(3, 0.75f, 1);
-
- /**
- * Deferred results set.
- *
- * @see org.red5.server.net.rtmp.DeferredResult
- */
- private CopyOnWriteArraySet deferredResults = new CopyOnWriteArraySet();
-
- /**
- * Last ping round trip time
- */
- private AtomicInteger lastPingRoundTripTime = new AtomicInteger(-1);
-
- /**
- * Timestamp when last ping command was sent.
- */
- private AtomicLong lastPingSentOn = new AtomicLong(0);
-
- /**
- * Timestamp when last ping result was received.
- */
- private AtomicLong lastPongReceivedOn = new AtomicLong(0);
-
- /**
- * RTMP events handler
- */
- protected IRTMPHandler handler;
-
- /**
- * Ping interval in ms to detect dead clients.
- */
- private volatile int pingInterval = 5000;
-
- /**
- * Maximum time in ms after which a client is disconnected because of inactivity.
- */
- protected volatile int maxInactivity = 60000;
-
- /**
- * Data read interval
- */
- protected long bytesReadInterval = 1024 * 1024;
-
- /**
- * Number of bytes to read next.
- */
- protected long nextBytesRead = 1024 * 1024;
-
- /**
- * Number of bytes the client reported to have received.
- */
- private AtomicLong clientBytesRead = new AtomicLong(0L);
-
- /**
- * Map for pending video packets and stream IDs.
- */
- private ConcurrentMap pendingVideos = new ConcurrentHashMap(1, 0.9f, 1);
-
- /**
- * Number of (NetStream) streams used.
- */
- private AtomicInteger usedStreams = new AtomicInteger(0);
-
- /**
- * Remembered stream buffer durations.
- */
- private ConcurrentMap streamBuffers = new ConcurrentHashMap(1, 0.9f, 1);
-
- /**
- * Maximum time in milliseconds to wait for a valid handshake.
- */
- private int maxHandshakeTimeout = 5000;
-
- /**
- * Maximum time in milliseconds allowed to process received message
- */
- protected long maxHandlingTimeout = 500L;
-
- /**
- * Bandwidth limit type / enforcement. (0=hard,1=soft,2=dynamic)
- */
- protected int limitType = 0;
-
- /**
- * Protocol state
- */
- protected RTMP state = new RTMP();
-
- // protection for the decoder when using multiple threads per connection
- protected Semaphore decoderLock = new Semaphore(1, true);
-
- // protection for the encoder when using multiple threads per connection
- protected Semaphore encoderLock = new Semaphore(1, true);
-
- // keeps track of the decode state
- protected ThreadLocal decoderState = new ThreadLocal() {
-
- @Override
- protected RTMPDecodeState initialValue() {
- return new RTMPDecodeState(getSessionId());
- }
-
- };
-
- /**
- * Scheduling service
- */
- protected ThreadPoolTaskScheduler scheduler;
-
- /**
- * Thread pool for message handling.
- */
- protected ThreadPoolTaskExecutor executor;
-
- /**
- * Keep-alive worker flag
- */
- protected final AtomicBoolean running;
-
- /**
- * Timestamp generator
- */
- private final AtomicInteger timer = new AtomicInteger(0);
-
- /**
- * Closing flag
- */
- private final AtomicBoolean closing = new AtomicBoolean(false);
-
- /**
- * Packet sequence number
- * */
- private AtomicLong packetSequence = new AtomicLong();
-
- /**
- * Specify the size of queue that will trigger audio packet dropping, disabled if it's 0
- * */
- private Integer executorQueueSizeToDropAudioPackets = 0;
-
- /**
- * Keep track of current queue size
- * */
- private AtomicInteger currentQueueSize = new AtomicInteger();
-
-
- /**
- * Creates anonymous RTMP connection without scope.
- *
- * @param type Connection type
- */
- @ConstructorProperties({ "type" })
- public RTMPConnection(String type) {
- // We start with an anonymous connection without a scope.
- // These parameters will be set during the call of "connect" later.
- super(type);
- // set running flag
- running = new AtomicBoolean(false);
- }
-
- public int getId() {
- // handle the fact that a client id is a String
- return client != null ? client.getId().hashCode() : -1;
- }
-
- @Deprecated
- public void setId(int clientId) {
- log.warn("Setting of a client id is deprecated, use IClient to manipulate the id", new Exception("RTMPConnection.setId is deprecated"));
- }
-
- public void setHandler(IRTMPHandler handler) {
- this.handler = handler;
- }
-
- public RTMP getState() {
- return state;
- }
-
- public byte getStateCode() {
- return state.getState();
- }
-
- public void setStateCode(byte code) {
- if (log.isTraceEnabled())
- log.trace("setStateCode: {} - {}", code, state.states[code]);
- state.setState(code);
- }
-
- /**
- * @return the decoderLock
- */
- public Semaphore getDecoderLock() {
- return decoderLock;
- }
-
- /**
- * @return the decoderLock
- */
- public Semaphore getEncoderLock() {
- return encoderLock;
- }
-
- /**
- * @return the decoderState
- */
- public RTMPDecodeState getDecoderState() {
- return decoderState.get();
- }
-
- /** {@inheritDoc} */
- public void setBandwidth(int mbits) {
- // tell the flash player how fast we want data and how fast we shall send it
- getChannel(2).write(new ServerBW(mbits));
- // second param is the limit type (0=hard,1=soft,2=dynamic)
- getChannel(2).write(new ClientBW(mbits, (byte) limitType));
- }
-
- /**
- * Returns a usable timestamp for written packets.
- *
- * @return timestamp
- */
- public int getTimer() {
- return timer.incrementAndGet();
- }
-
- /**
- * Opens the connection.
- */
- public void open() {
- // add the session id to the prefix
- executor.setThreadNamePrefix(String.format("RTMPConnectionExecutor#%s-", sessionId));
- //executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
- //executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
- //executor.setAllowCoreThreadTimeOut(true);
- executor.setDaemon(true);
- executor.setWaitForTasksToCompleteOnShutdown(true);
- if (log.isTraceEnabled()) {
- // dump memory stats
- log.trace("Memory at open - free: {}K total: {}K", Runtime.getRuntime().freeMemory() / 1024, Runtime.getRuntime().totalMemory() / 1024);
- }
- }
-
- @Override
- public boolean connect(IScope newScope, Object[] params) {
- if (log.isDebugEnabled())
- log.debug("Connect scope: {}", newScope);
- try {
- boolean success = super.connect(newScope, params);
- if (success) {
- // once the handshake has completed, start needed jobs start the ping / pong keep-alive
- startRoundTripMeasurement();
- } else {
- if (log.isDebugEnabled())
- log.debug("Connect failed");
- }
- return success;
- } catch (ClientRejectedException e) {
- String reason = (String) e.getReason();
- log.info("Client rejected, reason: " + ((reason != null) ? reason : "None"));
- throw e;
- }
- }
-
- /**
- * Start waiting for a valid handshake.
- */
- public void startWaitForHandshake() {
- if (log.isDebugEnabled())
- log.debug("startWaitForHandshake - {}", sessionId);
- // start the handshake waiter
- scheduler.execute(new WaitForHandshakeTask());
- }
-
- /**
- * Starts measurement.
- */
- public void startRoundTripMeasurement() {
- if (scheduler != null) {
- if (pingInterval > 0) {
- if (log.isDebugEnabled())
- log.debug("startRoundTripMeasurement - {}", sessionId);
- try {
- scheduler.scheduleAtFixedRate(new KeepAliveTask(), pingInterval);
- if (log.isDebugEnabled())
- log.debug("Keep alive scheduled for: {}", sessionId);
- } catch (Exception e) {
- log.error("Error creating keep alive job", e);
- }
- }
- } else {
- log.warn("startRoundTripMeasurement cannot be executed due to missing scheduler. This can happen if a connection drops before handshake is complete");
- }
- }
-
- /**
- * Initialize connection.
- *
- * @param host Connection host
- * @param path Connection path
- * @param params Params passed from client
- */
- public void setup(String host, String path, Map params) {
- this.host = host;
- this.path = path;
- this.params = params;
- if (Integer.valueOf(3).equals(params.get("objectEncoding"))) {
- if (log.isDebugEnabled())
- log.debug("Setting object encoding to AMF3");
- state.setEncoding(Encoding.AMF3);
- }
- }
-
- /**
- * Return AMF protocol encoding used by this connection.
- *
- * @return AMF encoding used by connection
- */
- public Encoding getEncoding() {
- return state.getEncoding();
- }
-
- /**
- * Getter for next available channel id.
- *
- * @return Next available channel id
- */
- public int getNextAvailableChannelId() {
- int result = 4;
- while (isChannelUsed(result)) {
- result++;
- }
- return result;
- }
-
- /**
- * Checks whether channel is used.
- *
- * @param channelId Channel id
- * @return true if channel is in use, false
- * otherwise
- */
- public boolean isChannelUsed(int channelId) {
- return channels.get(channelId) != null;
- }
-
- /**
- * Return channel by id.
- *
- * @param channelId Channel id
- * @return Channel by id
- */
- public Channel getChannel(int channelId) {
- if (channels != null) {
- Channel channel = channels.putIfAbsent(channelId, new Channel(this, channelId));
- if (channel == null) {
- channel = channels.get(channelId);
- }
- return channel;
- } else {
- return new Channel(null, channelId);
- }
- }
-
- /**
- * Closes channel.
- *
- * @param channelId Channel id
- */
- public void closeChannel(int channelId) {
- Channel chan = channels.remove(channelId);
- if (log.isDebugEnabled())
- log.debug("Closing / removing channel: {}", chan);
- chan = null;
- }
-
- /**
- * Getter for client streams.
- *
- * @return Client streams as array
- */
- protected Collection getStreams() {
- return streams.values();
- }
-
- /** {@inheritDoc} */
- public int reserveStreamId() {
- int result = -1;
- for (int i = 0; true; i++) {
- if (!reservedStreams.get(i)) {
- reservedStreams.set(i);
- result = i;
- break;
- }
- }
- return result + 1;
- }
-
- /** {@inheritDoc} */
- public int reserveStreamId(int id) {
- int result = -1;
- if (!reservedStreams.get(id - 1)) {
- reservedStreams.set(id - 1);
- result = id - 1;
- } else {
- result = reserveStreamId();
- }
- return result;
- }
-
- /**
- * Returns whether or not a given stream id is valid.
- *
- * @param streamId
- * @return true if its valid, false if its invalid
- */
- public boolean isValidStreamId(int streamId) {
- int index = streamId - 1;
- if (index < 0 || !reservedStreams.get(index)) {
- // stream id has not been reserved before
- return false;
- }
- if (streams.get(streamId - 1) != null) {
- // another stream already exists with this id
- return false;
- }
- return true;
- }
-
- /**
- * Returns whether or not the connection has been idle for a maximum period.
- *
- * @return true if max idle period has been exceeded, false otherwise
- */
- public boolean isIdle() {
- long lastPingTime = lastPingSentOn.get();
- long lastPongTime = lastPongReceivedOn.get();
- boolean idle = (lastPongTime > 0 && (lastPingTime - lastPongTime > maxInactivity));
- if (log.isTraceEnabled())
- log.trace("Connection {} {} idle", getSessionId(), (idle ? "is" : "is not"));
- return idle;
- }
-
- /**
- * Returns whether or not the connection is disconnected.
- *
- * @return true if connection state is RTMP.STATE_DISCONNECTED, false otherwise
- */
- public boolean isDisconnected() {
- return state.getState() == RTMP.STATE_DISCONNECTED;
- }
-
- /**
- * Creates output stream object from stream id. Output stream consists of audio, data and video channels.
- *
- * @see org.red5.server.stream.OutputStream
- *
- * @param streamId Stream id
- * @return Output stream object
- */
- public OutputStream createOutputStream(int streamId) {
- int channelId = (4 + ((streamId - 1) * 5));
- if (log.isDebugEnabled())
- log.debug("Channel id range start: {}", channelId);
- final Channel data = getChannel(channelId++);
- final Channel video = getChannel(channelId++);
- final Channel audio = getChannel(channelId++);
- return new OutputStream(video, audio, data);
- }
-
- /** {@inheritDoc} */
- public IClientBroadcastStream newBroadcastStream(int streamId) {
- if (isValidStreamId(streamId)) {
- // get ClientBroadcastStream defined as a prototype in red5-common.xml
- ClientBroadcastStream cbs = (ClientBroadcastStream) scope.getContext().getBean("clientBroadcastStream");
- Integer buffer = streamBuffers.get(streamId - 1);
- if (buffer != null) {
- cbs.setClientBufferDuration(buffer);
- }
- cbs.setStreamId(streamId);
- cbs.setConnection(this);
- cbs.setName(createStreamName());
- cbs.setScope(this.getScope());
-
- registerStream(cbs);
- usedStreams.incrementAndGet();
- return cbs;
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public ISingleItemSubscriberStream newSingleItemSubscriberStream(int streamId) {
- if (isValidStreamId(streamId)) {
- // get SingleItemSubscriberStream defined as a prototype in red5-common.xml
- SingleItemSubscriberStream siss = (SingleItemSubscriberStream) scope.getContext().getBean("singleItemSubscriberStream");
- Integer buffer = streamBuffers.get(streamId - 1);
- if (buffer != null) {
- siss.setClientBufferDuration(buffer);
- }
- siss.setName(createStreamName());
- siss.setConnection(this);
- siss.setScope(this.getScope());
- siss.setStreamId(streamId);
- registerStream(siss);
- usedStreams.incrementAndGet();
- return siss;
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public IPlaylistSubscriberStream newPlaylistSubscriberStream(int streamId) {
- if (isValidStreamId(streamId)) {
- // get PlaylistSubscriberStream defined as a prototype in red5-common.xml
- PlaylistSubscriberStream pss = (PlaylistSubscriberStream) scope.getContext().getBean("playlistSubscriberStream");
- Integer buffer = streamBuffers.get(streamId - 1);
- if (buffer != null) {
- pss.setClientBufferDuration(buffer);
- }
- pss.setName(createStreamName());
- pss.setConnection(this);
- pss.setScope(this.getScope());
- pss.setStreamId(streamId);
- registerStream(pss);
- usedStreams.incrementAndGet();
- return pss;
- }
- return null;
- }
-
- public void addClientStream(IClientStream stream) {
- int streamIndex = stream.getStreamId() - 1;
- if (!reservedStreams.get(streamIndex)) {
- reservedStreams.set(streamIndex);
- streams.put(streamIndex, stream);
- usedStreams.incrementAndGet();
- }
- }
-
- public void removeClientStream(int streamId) {
- unreserveStreamId(streamId);
- }
-
- /**
- * Getter for used stream count.
- *
- * @return Value for property 'usedStreamCount'.
- */
- protected int getUsedStreamCount() {
- return usedStreams.get();
- }
-
- /** {@inheritDoc} */
- public IClientStream getStreamById(int id) {
- if (id <= 0) {
- return null;
- }
- return streams.get(id - 1);
- }
-
- /**
- * Return stream id for given channel id.
- *
- * @param channelId Channel id
- * @return ID of stream that channel belongs to
- */
- public int getStreamIdForChannel(int channelId) {
- if (channelId < 4) {
- return 0;
- }
- return ((channelId - 4) / 5) + 1;
- }
-
- /**
- * Return stream by given channel id.
- *
- * @param channelId Channel id
- * @return Stream that channel belongs to
- */
- public IClientStream getStreamByChannelId(int channelId) {
- if (channelId < 4) {
- return null;
- }
- return streams.get(getStreamIdForChannel(channelId) - 1);
- }
-
- /**
- * Store a stream in the connection.
- *
- * @param stream
- */
- private void registerStream(IClientStream stream) {
- streams.put(stream.getStreamId() - 1, stream);
- }
-
- /**
- * Remove a stream from the connection.
- *
- * @param stream
- */
- @SuppressWarnings("unused")
- private void unregisterStream(IClientStream stream) {
- streams.remove(stream.getStreamId());
- }
-
- /** {@inheritDoc} */
- @Override
- public void close() {
- if (closing.compareAndSet(false, true)) {
- if (log.isDebugEnabled())
- log.debug("close: {}", sessionId);
- // update our state
- if (state != null) {
- final byte s = getStateCode();
- switch (s) {
- case RTMP.STATE_DISCONNECTED:
- if (log.isDebugEnabled())
- log.debug("Already disconnected");
- return;
- default:
- if (log.isDebugEnabled())
- log.debug("State: {}", state.states[s]);
- state.setState(RTMP.STATE_DISCONNECTING);
- }
- }
- Red5.setConnectionLocal(this);
- IStreamService streamService = (IStreamService) ScopeUtils.getScopeService(scope, IStreamService.class, StreamService.class);
- if (streamService != null) {
- for (Map.Entry entry : streams.entrySet()) {
- IClientStream stream = entry.getValue();
- if (stream != null) {
- if (log.isDebugEnabled())
- log.debug("Closing stream: {}", stream.getStreamId());
- streamService.deleteStream(this, stream.getStreamId());
- usedStreams.decrementAndGet();
- }
- }
- } else {
- if (log.isDebugEnabled())
- log.debug("Stream service was not found for scope: {}", (scope != null ? scope.getName() : "null or non-existant"));
- }
- // close the base connection - disconnect scopes and unregister client
- super.close();
- // kill all the collections etc
- if (channels != null) {
- channels.clear();
- } else {
- if (log.isTraceEnabled())
- log.trace("Channels collection was null");
- }
- if (streams != null) {
- streams.clear();
- } else {
- if (log.isTraceEnabled())
- log.trace("Streams collection was null");
- }
- if (pendingCalls != null) {
- pendingCalls.clear();
- } else {
- if (log.isTraceEnabled())
- log.trace("PendingCalls collection was null");
- }
- if (deferredResults != null) {
- deferredResults.clear();
- } else {
- if (log.isTraceEnabled())
- log.trace("DeferredResults collection was null");
- }
- if (pendingVideos != null) {
- pendingVideos.clear();
- } else {
- if (log.isTraceEnabled())
- log.trace("PendingVideos collection was null");
- }
- if (streamBuffers != null) {
- streamBuffers.clear();
- } else {
- if (log.isTraceEnabled())
- log.trace("StreamBuffers collection was null");
- }
- if (scheduler != null) {
- if (log.isDebugEnabled())
- log.debug("Shutting down scheduler");
- try {
- ScheduledExecutorService exe = scheduler.getScheduledExecutor();
- List runables = exe.shutdownNow();
- if (log.isDebugEnabled())
- log.debug("Scheduler - shutdown: {} queued: {}", exe.isShutdown(), runables.size());
- if (scheduler != null) {
- scheduler.shutdown();
- scheduler = null;
- } else {
- return;
- }
- } catch (NullPointerException e) {
- // this can happen in a multithreaded env, where close has been called from more than one spot
- if (log.isDebugEnabled()) {
- log.warn("Exception during scheduler shutdown", e);
- }
- } catch (Exception e) {
- log.warn("Exception during scheduler shutdown", e);
- }
- }
- if (executor != null) {
- if (log.isDebugEnabled())
- log.debug("Shutting down executor");
- try {
- ThreadPoolExecutor exe = executor.getThreadPoolExecutor();
- List runables = exe.shutdownNow();
- if (log.isDebugEnabled())
- log.debug("Executor - shutdown: {} queued: {}", exe.isShutdown(), runables.size());
- if (executor != null) {
- executor.shutdown();
- executor = null;
- } else {
- return;
- }
- } catch (NullPointerException e) {
- // this can happen in a multithreaded env, where close has been called from more than one spot
- if (log.isDebugEnabled()) {
- log.warn("Exception during executor shutdown", e);
- }
- } catch (Exception e) {
- log.warn("Exception during executor shutdown", e);
- }
- }
- // drain permits
- decoderLock.drainPermits();
- encoderLock.drainPermits();
- if (log.isTraceEnabled()) {
- // dump memory stats
- if (log.isTraceEnabled())
- log.trace("Memory at close - free: {}K total: {}K", Runtime.getRuntime().freeMemory() / 1024, Runtime.getRuntime().totalMemory() / 1024);
- }
- } else {
- if (log.isDebugEnabled())
- log.debug("Already closing..");
- }
- }
-
- /**
- * Dispatches event
- * @param event Event
- */
- @Override
- public void dispatchEvent(IEvent event) {
- if (log.isDebugEnabled())
- log.debug("Event notify: {}", event);
- // determine if its an outgoing invoke or notify
- switch (event.getType()) {
- case CLIENT_INVOKE:
- ClientInvokeEvent cie = (ClientInvokeEvent) event;
- invoke(cie.getMethod(), cie.getParams(), cie.getCallback());
- break;
- case CLIENT_NOTIFY:
- ClientNotifyEvent cne = (ClientNotifyEvent) event;
- notify(cne.getMethod(), cne.getParams());
- break;
- default:
- log.warn("Unhandled event: {}", event);
- }
- }
-
- /**
- * When the connection has been closed, notify any remaining pending service calls that they have failed because
- * the connection is broken. Implementors of IPendingServiceCallback may only deduce from this notification that
- * it was not possible to read a result for this service call. It is possible that (1) the service call was never
- * written to the service, or (2) the service call was written to the service and although the remote method was
- * invoked, the connection failed before the result could be read, or (3) although the remote method was invoked
- * on the service, the service implementor detected the failure of the connection and performed only partial
- * processing. The caller only knows that it cannot be confirmed that the callee has invoked the service call
- * and returned a result.
- */
- public void sendPendingServiceCallsCloseError() {
- if (pendingCalls != null && !pendingCalls.isEmpty()) {
- if (log.isDebugEnabled())
- log.debug("Connection calls pending: {}", pendingCalls.size());
- for (IPendingServiceCall call : pendingCalls.values()) {
- call.setStatus(Call.STATUS_NOT_CONNECTED);
- for (IPendingServiceCallback callback : call.getCallbacks()) {
- callback.resultReceived(call);
- }
- }
- }
- }
-
- /** {@inheritDoc} */
- public void unreserveStreamId(int streamId) {
- deleteStreamById(streamId);
- if (streamId > 0) {
- reservedStreams.clear(streamId - 1);
- }
- }
-
- /** {@inheritDoc} */
- public void deleteStreamById(int streamId) {
- if (streamId > 0) {
- if (streams.get(streamId - 1) != null) {
- pendingVideos.remove(streamId);
- usedStreams.decrementAndGet();
- streams.remove(streamId - 1);
- streamBuffers.remove(streamId - 1);
- }
- }
- }
-
- /**
- * Handler for ping event.
- *
- * @param ping Ping event context
- */
- public void ping(Ping ping) {
- getChannel(2).write(ping);
- }
-
- /**
- * Write packet.
- *
- * @param out Packet
- */
- public abstract void write(Packet out);
-
- /**
- * Write raw byte buffer.
- *
- * @param out IoBuffer
- */
- public abstract void writeRaw(IoBuffer out);
-
- /**
- * Update number of bytes to read next value.
- */
- protected void updateBytesRead() {
- if (log.isTraceEnabled())
- log.trace("updateBytesRead");
- long bytesRead = getReadBytes();
- if (bytesRead >= nextBytesRead) {
- BytesRead sbr = new BytesRead((int) (bytesRead % Integer.MAX_VALUE));
- getChannel(2).write(sbr);
- nextBytesRead += bytesReadInterval;
- }
- }
-
- /**
- * Read number of received bytes.
- *
- * @param bytes Number of bytes
- */
- public void receivedBytesRead(int bytes) {
- if (log.isDebugEnabled())
- log.debug("Client received {} bytes, written {} bytes, {} messages pending", new Object[] { bytes, getWrittenBytes(), getPendingMessages() });
- clientBytesRead.addAndGet(bytes);
- }
-
- /**
- * Get number of bytes the client reported to have received.
- *
- * @return Number of bytes
- */
- public long getClientBytesRead() {
- return clientBytesRead.get();
- }
-
- /** {@inheritDoc} */
- public void invoke(IServiceCall call) {
- invoke(call, 3);
- }
-
- /**
- * Generate next invoke id.
- *
- * @return Next invoke id for RPC
- */
- public int getTransactionId() {
- return transactionId.incrementAndGet();
- }
-
- /**
- * Register pending call (remote function call that is yet to finish).
- *
- * @param invokeId Deferred operation id
- * @param call Call service
- */
- public void registerPendingCall(int invokeId, IPendingServiceCall call) {
- pendingCalls.put(invokeId, call);
- }
-
- /** {@inheritDoc} */
- public void invoke(IServiceCall call, int channel) {
- // We need to use Invoke for all calls to the client
- Invoke invoke = new Invoke();
- invoke.setCall(call);
- invoke.setTransactionId(getTransactionId());
- if (call instanceof IPendingServiceCall) {
- registerPendingCall(invoke.getTransactionId(), (IPendingServiceCall) call);
- }
- getChannel(channel).write(invoke);
- }
-
- /** {@inheritDoc} */
- public void invoke(String method) {
- invoke(method, null, null);
- }
-
- /** {@inheritDoc} */
- public void invoke(String method, Object[] params) {
- invoke(method, params, null);
- }
-
- /** {@inheritDoc} */
- public void invoke(String method, IPendingServiceCallback callback) {
- invoke(method, null, callback);
- }
-
- /** {@inheritDoc} */
- public void invoke(String method, Object[] params, IPendingServiceCallback callback) {
- IPendingServiceCall call = new PendingCall(method, params);
- if (callback != null) {
- call.registerCallback(callback);
- }
- invoke(call);
- }
-
- /** {@inheritDoc} */
- public void notify(IServiceCall call) {
- notify(call, 3);
- }
-
- /** {@inheritDoc} */
- public void notify(IServiceCall call, int channel) {
- Notify notify = new Notify();
- notify.setCall(call);
- getChannel(channel).write(notify);
- }
-
- /** {@inheritDoc} */
- public void notify(String method) {
- notify(method, null);
- }
-
- /** {@inheritDoc} */
- public void notify(String method, Object[] params) {
- IServiceCall call = new Call(method, params);
- notify(call);
- }
-
- /** {@inheritDoc} */
- public void status(Status status) {
- status(status, 3);
- }
-
- /** {@inheritDoc} */
- public void status(Status status, int channel) {
- if (status != null) {
- getChannel(channel).sendStatus(status);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public long getReadBytes() {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override
- public long getWrittenBytes() {
- return 0;
- }
-
- /**
- * Get pending call service by id.
- *
- * @param invokeId
- * Pending call service id
- * @return Pending call service object
- */
- public IPendingServiceCall getPendingCall(int invokeId) {
- return pendingCalls.get(invokeId);
- }
-
- /**
- * Retrieves and removes the pending call service by id.
- *
- * @param invokeId
- * Pending call service id
- * @return Pending call service object
- */
- public IPendingServiceCall retrievePendingCall(int invokeId) {
- return pendingCalls.remove(invokeId);
- }
-
- /**
- * Generates new stream name.
- *
- * @return New stream name
- */
- protected String createStreamName() {
- return UUID.randomUUID().toString();
- }
-
- /**
- * Mark message as being written.
- *
- * @param message
- * Message to mark
- */
- protected void writingMessage(Packet message) {
- if (message.getMessage() instanceof VideoData) {
- int streamId = message.getHeader().getStreamId();
- final AtomicInteger value = new AtomicInteger();
- AtomicInteger old = pendingVideos.putIfAbsent(streamId, value);
- if (old == null) {
- old = value;
- }
- old.incrementAndGet();
- }
- }
-
- /**
- * Increases number of read messages by one. Updates number of bytes read.
- */
- public void messageReceived() {
- if (log.isTraceEnabled())
- log.trace("messageReceived");
- readMessages.incrementAndGet();
- // trigger generation of BytesRead messages
- updateBytesRead();
- }
-
- private String getMessageType(Packet packet) {
- final Header header = packet.getHeader();
- final byte headerDataType = header.getDataType();
- return messageTypeToName(headerDataType);
- }
-
- public String messageTypeToName(byte headerDataType) {
- switch (headerDataType) {
- case Constants.TYPE_AGGREGATE:
- return "TYPE_AGGREGATE";
- case Constants.TYPE_AUDIO_DATA:
- return "TYPE_AUDIO_DATA";
- case Constants.TYPE_VIDEO_DATA:
- return "TYPE_VIDEO_DATA";
- case Constants.TYPE_FLEX_SHARED_OBJECT:
- return "TYPE_FLEX_SHARED_OBJECT";
- case Constants.TYPE_SHARED_OBJECT:
- return "TYPE_SHARED_OBJECT";
- case Constants.TYPE_INVOKE:
- return "TYPE_INVOKE";
- case Constants.TYPE_FLEX_MESSAGE:
- return "TYPE_FLEX_MESSAGE";
- case Constants.TYPE_NOTIFY:
- return "TYPE_NOTIFY";
- case Constants.TYPE_FLEX_STREAM_SEND:
- return "TYPE_FLEX_STREAM_SEND";
- case Constants.TYPE_PING:
- return "TYPE_PING";
- case Constants.TYPE_BYTES_READ:
- return "TYPE_BYTES_READ";
- case Constants.TYPE_CHUNK_SIZE:
- return "TYPE_CHUNK_SIZE";
- case Constants.TYPE_CLIENT_BANDWIDTH:
- return "TYPE_CLIENT_BANDWIDTH";
- case Constants.TYPE_SERVER_BANDWIDTH:
- return "TYPE_SERVER_BANDWIDTH";
- default:
- return "UNKNOWN [" + headerDataType + "]";
-
- }
- }
-
- /**
- * Handle the incoming message.
- *
- * @param message
- */
- @SuppressWarnings("unchecked")
- public void handleMessageReceived(Packet message) {
- if (log.isTraceEnabled())
- log.trace("handleMessageReceived - {}", sessionId);
- final byte dataType = message.getHeader().getDataType();
- // route these types outside the executor
- switch(dataType) {
- case Constants.TYPE_PING:
- case Constants.TYPE_ABORT:
- case Constants.TYPE_BYTES_READ:
- case Constants.TYPE_CHUNK_SIZE:
- case Constants.TYPE_CLIENT_BANDWIDTH:
- case Constants.TYPE_SERVER_BANDWIDTH:
- // pass message to the handler
- try {
- handler.messageReceived(this, message);
- } catch (Exception e) {
- log.error("Error processing received message {}", sessionId, e);
- }
- break;
- default:
- if (executor != null) {
- try {
- final long packetNumber = packetSequence.incrementAndGet();
-
- if (executorQueueSizeToDropAudioPackets > 0 && currentQueueSize.get() >= executorQueueSizeToDropAudioPackets) {
- if (message.getHeader().getDataType() == Constants.TYPE_AUDIO_DATA){
- /**
- * There's a backlog of messages in the queue. Flash might have
- * sent a burst of messages after a network congestion.
- * Throw away packets that we are able to discard.
- */
- log.info("Queue threshold reached. Discarding packet: session=[{}], msgType=[{}], packetNum=[{}]", getSessionId(), getMessageType(message), packetNumber);
- return ;
- }
- }
- ReceivedMessageTask task = new ReceivedMessageTask(sessionId, message, handler, this);
- task.setMaxHandlingTimeout(maxHandlingTimeout);
- packetSequence.incrementAndGet();
- final Packet sentMessage = message;
- final Long startTime = System.nanoTime();
- ListenableFuture future = (ListenableFuture) executor.submitListenable(new ListenableFutureTask(task));
- currentQueueSize.incrementAndGet();
- future.addCallback(new ListenableFutureCallback() {
- private int getProcessingTime() {
- return (int) ((System.nanoTime() - startTime)/1000);
- }
-
- public void onFailure(Throwable t) {
- currentQueueSize.decrementAndGet();
-
- if (log.isWarnEnabled())
- log.warn("onFailure - session: {}, msgtype: {}, processingTime: {}, packetNum: {}", sessionId, getMessageType(sentMessage), getProcessingTime(), packetNumber);
- }
-
- public void onSuccess(Boolean success) {
- currentQueueSize.decrementAndGet();
- if (log.isDebugEnabled())
- log.debug("onSuccess - session: {}, msgType: {}, processingTime: {}, packetNum: {}", sessionId, getMessageType(sentMessage), getProcessingTime(), packetNumber);
- }
- });
- } catch (TaskRejectedException tre) {
- Throwable[] suppressed = tre.getSuppressed();
- for (Throwable t : suppressed) {
- log.warn("Suppressed exception on {}", sessionId, t);
- }
- log.info("Rejected message: {} on {}", message, sessionId);
- } catch (Exception e) {
- log.info("Incoming message handling failed on session=[{}], messageType=[{}]", getSessionId(), message);
- if (log.isDebugEnabled()) {
- log.debug("Execution rejected on {} - {}", getSessionId(), state.states[getStateCode()]);
- log.debug("Lock permits - decode: {} encode: {}", decoderLock.availablePermits(), encoderLock.availablePermits());
- }
- }
- } else {
- log.warn("Executor is null on {} state: {}", getSessionId(), state.states[getStateCode()]);
- }
- }
- }
-
- /**
- * Mark message as sent.
- *
- * @param message
- * Message to mark
- */
- public void messageSent(Packet message) {
- if (message.getMessage() instanceof VideoData) {
- int streamId = message.getHeader().getStreamId();
- AtomicInteger pending = pendingVideos.get(streamId);
- if (log.isTraceEnabled()) {
- log.trace("Stream id: {} pending: {} total pending videos: {}", streamId, pending, pendingVideos.size());
- }
- if (pending != null) {
- pending.decrementAndGet();
- }
- }
- writtenMessages.incrementAndGet();
- }
-
- /**
- * Increases number of dropped messages.
- */
- protected void messageDropped() {
- droppedMessages.incrementAndGet();
- }
-
- /** {@inheritDoc} */
- @Override
- public long getPendingVideoMessages(int streamId) {
- if (log.isTraceEnabled()) {
- log.trace("Total pending videos: {}", pendingVideos.size());
- }
- AtomicInteger count = pendingVideos.get(streamId);
- long result = (count != null ? count.intValue() - getUsedStreamCount() : 0);
- return (result > 0 ? result : 0);
- }
-
- /**
- * Send a shared object message.
- *
- * @param name shared object name
- * @param currentVersion the current version
- * @param persistent
- * @param events
- */
- public void sendSharedObjectMessage(String name, int currentVersion, boolean persistent, ConcurrentLinkedQueue events) {
- // create a new sync message for every client to avoid concurrent access through multiple threads
- SharedObjectMessage syncMessage = state.getEncoding() == Encoding.AMF3 ? new FlexSharedObjectMessage(null, name, currentVersion, persistent) : new SharedObjectMessage(
- null, name, currentVersion, persistent);
- syncMessage.addEvents(events);
- try {
- // get the channel for so updates
- Channel channel = getChannel((byte) 3);
- if (log.isTraceEnabled())
- log.trace("Send to channel: {}", channel);
- channel.write(syncMessage);
- } catch (Exception e) {
- log.warn("Exception sending shared object", e);
- }
- }
-
- /** {@inheritDoc} */
- public void ping() {
- long newPingTime = System.currentTimeMillis();
- if (log.isDebugEnabled())
- log.debug("Send Ping: session=[{}], currentTime=[{}], lastPingTime=[{}]", new Object[] { getSessionId(), newPingTime, lastPingSentOn.get() });
- if (lastPingSentOn.get() == 0) {
- lastPongReceivedOn.set(newPingTime);
- }
- Ping pingRequest = new Ping();
- pingRequest.setEventType(Ping.PING_CLIENT);
- lastPingSentOn.set(newPingTime);
- int now = (int) (newPingTime & 0xffffffff);
- pingRequest.setValue2(now);
- ping(pingRequest);
- }
-
- /**
- * Marks that ping back was received.
- *
- * @param pong
- * Ping object
- */
- public void pingReceived(Ping pong) {
- long now = System.currentTimeMillis();
- long previousPingValue = (int) (lastPingSentOn.get() & 0xffffffff);
- if (log.isDebugEnabled())
- log.debug("Pong Rx: session=[{}] at {} with value {}, previous received at {}", new Object[] { getSessionId(), now, pong.getValue2(), previousPingValue });
- if (pong.getValue2() == previousPingValue) {
- lastPingRoundTripTime.set((int) (now & 0xffffffff) - pong.getValue2());
- if (log.isDebugEnabled())
- log.debug("Ping response session=[{}], RTT=[{} ms]", new Object[] { getSessionId(), lastPingRoundTripTime.get() });
- } else {
- int pingRtt = (int) (now & 0xffffffff) - pong.getValue2();
- log.info("Pong delayed: session=[{}], ping response took [{} ms] to arrive. Connection may be congested.", new Object[] { getSessionId(), pingRtt });
- }
- lastPongReceivedOn.set(now);
- }
-
- /** {@inheritDoc} */
- public int getLastPingTime() {
- return lastPingRoundTripTime.get();
- }
-
- /**
- * Setter for ping interval.
- *
- * @param pingInterval Interval in ms to ping clients. Set to 0 to
- * disable ghost detection code.
- */
- public void setPingInterval(int pingInterval) {
- this.pingInterval = pingInterval;
- }
-
- /**
- * Setter for maximum inactivity.
- *
- * @param maxInactivity Maximum time in ms after which a client is disconnected in
- * case of inactivity.
- */
- public void setMaxInactivity(int maxInactivity) {
- this.maxInactivity = maxInactivity;
- }
-
- /**
- * Inactive state event handler.
- */
- protected abstract void onInactive();
-
- /**
- * Sets the scheduler.
- *
- * @param scheduler scheduling service / thread executor
- */
- public void setScheduler(ThreadPoolTaskScheduler scheduler) {
- this.scheduler = scheduler;
- // set the prefix
- this.scheduler.setThreadNamePrefix(String.format("RTMPConnectionExecutor#%d", System.currentTimeMillis()));
- this.scheduler.setDaemon(true);
- this.scheduler.setWaitForTasksToCompleteOnShutdown(true);
- }
-
- /**
- * @return the scheduler
- */
- public ThreadPoolTaskScheduler getScheduler() {
- return scheduler;
- }
-
- public ThreadPoolTaskExecutor getExecutor() {
- return executor;
- }
-
- public void setExecutor(ThreadPoolTaskExecutor executor) {
- this.executor = executor;
- }
-
- /**
- * Registers deferred result.
- *
- * @param result Result to register
- */
- public void registerDeferredResult(DeferredResult result) {
- deferredResults.add(result);
- }
-
- /**
- * Unregister deferred result
- *
- * @param result
- * Result to unregister
- */
- public void unregisterDeferredResult(DeferredResult result) {
- deferredResults.remove(result);
- }
-
- public void rememberStreamBufferDuration(int streamId, int bufferDuration) {
- streamBuffers.put(streamId - 1, bufferDuration);
- }
-
- /**
- * Set maximum time to wait for valid handshake in milliseconds.
- *
- * @param maxHandshakeTimeout Maximum time in milliseconds
- */
- public void setMaxHandshakeTimeout(int maxHandshakeTimeout) {
- this.maxHandshakeTimeout = maxHandshakeTimeout;
- }
-
- public long getMaxHandlingTimeout() {
- return maxHandlingTimeout;
- }
-
- public void setMaxHandlingTimeout(long maxHandlingTimeout) {
- this.maxHandlingTimeout = maxHandlingTimeout;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- if (log.isDebugEnabled()) {
- String id = getClient() != null ? getClient().getId() : null;
- return String.format("%1$s %2$s:%3$s to %4$s client: %5$s session: %6$s state: %7$s", new Object[] { getClass().getSimpleName(), getRemoteAddress(), getRemotePort(), getHost(), id,
- getSessionId(), getState().states[getStateCode()] });
- } else {
- Object[] args = new Object[] { getClass().getSimpleName(), getRemoteAddress(), getReadBytes(), getWrittenBytes(), getSessionId(), getState().states[getStateCode()] };
- return String.format("%1$s from %2$s (in: %3$s out: %4$s) session: %5$s state: %6$s", args);
- }
- }
-
- /**
- * Specify the size of queue that will trigger audio packet dropping, disabled if it's 0
- * */
- public void setExecutorQueueSizeToDropAudioPackets(
- Integer executorQueueSizeToDropAudioPackets) {
- this.executorQueueSizeToDropAudioPackets = executorQueueSizeToDropAudioPackets;
- }
-
- /**
- * Task that keeps connection alive and disconnects if client is dead.
- */
- private class KeepAliveTask implements Runnable {
-
- private final AtomicLong lastBytesRead = new AtomicLong(0);
-
- private volatile long lastBytesReadTime = 0;
-
- public void run() {
- // we dont ping until in connected state
- if (state.getState() == RTMP.STATE_CONNECTED) {
- // ensure the job is not already running
- if (running.compareAndSet(false, true)) {
- if (log.isTraceEnabled())
- log.trace("Running keep-alive for {}", getSessionId());
- try {
- // first check connected
- if (isConnected()) {
- // get now
- long now = System.currentTimeMillis();
- // get the current bytes read count on the connection
- long currentReadBytes = getReadBytes();
- // get our last bytes read count
- long previousReadBytes = lastBytesRead.get();
- if (log.isTraceEnabled())
- log.trace("Time now: {} current read count: {} last read count: {}", new Object[] { now, currentReadBytes, previousReadBytes });
- if (currentReadBytes > previousReadBytes) {
- if (log.isTraceEnabled())
- log.trace("Client is still alive, no ping needed");
- // client has sent data since last check and thus is not dead. No need to ping
- if (lastBytesRead.compareAndSet(previousReadBytes, currentReadBytes)) {
- // update the timestamp to match our update
- lastBytesReadTime = now;
- }
- // check idle
- if (isIdle()) {
- onInactive();
- }
- } else {
- // client didn't send response to ping command and didn't sent data for too long, disconnect
- long lastPingTime = lastPingSentOn.get();
- long lastPongTime = lastPongReceivedOn.get();
- if (lastPongTime > 0 && (lastPingTime - lastPongTime > maxInactivity) && (now - lastBytesReadTime > maxInactivity)) {
- log.warn("Closing connection - inactivity timeout: session=[{}}, lastPongReceived=[{} ms ago], lastPingSent=[{} ms ago], lastDataRx=[{} ms ago]", new Object[] { getSessionId(),
- (lastPingTime - lastPongTime), (now - lastPingTime), (now - lastBytesReadTime)});
- // the following line deals with a very common support request
- log.warn("Client on session=[{}] has not responded to our ping for [{} ms] and we haven't received data for [{} ms]",
- new Object[] { getSessionId(), (lastPingTime - lastPongTime), (now - lastBytesReadTime)});
- onInactive();
- } else {
- // send ping command to client to trigger sending of data
- ping();
- }
- }
- } else {
- if (log.isDebugEnabled())
- log.debug("No longer connected, clean up connection. Connection state: {}", state.states[state.getState()]);
- onInactive();
- }
- } catch (Exception e) {
- log.warn("Exception in keepalive for {}", getSessionId(), e);
- } finally {
- // reset running flag
- running.compareAndSet(true, false);
- }
- }
- }
- }
- }
-
- /**
- * Task that waits for a valid handshake and disconnects the client if none is received.
- */
- private class WaitForHandshakeTask implements Runnable {
-
- public void run() {
- if (log.isTraceEnabled())
- log.trace("Running handshake-wait for {}", getSessionId());
- try {
- Thread.sleep(maxHandshakeTimeout);
- // check for connected state before disconnecting
- if (state.getState() != RTMP.STATE_CONNECTED) {
- // Client didn't send a valid handshake, disconnect
- log.warn("Closing {}, due to long handshake. State: {}", getSessionId(), state.states[getStateCode()]);
- onInactive();
- }
- } catch (InterruptedException e) {
- }
- }
-
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/RTMPHandler.java b/src/main/java/org/red5/server/net/rtmp/RTMPHandler.java
deleted file mode 100644
index 27749c1a3..000000000
--- a/src/main/java/org/red5/server/net/rtmp/RTMPHandler.java
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.red5.io.object.StreamAction;
-import org.red5.logging.Red5LoggerFactory;
-import org.red5.server.api.IConnection.Encoding;
-import org.red5.server.api.IContext;
-import org.red5.server.api.IServer;
-import org.red5.server.api.Red5;
-import org.red5.server.api.scope.IBroadcastScope;
-import org.red5.server.api.scope.IGlobalScope;
-import org.red5.server.api.scope.IScope;
-import org.red5.server.api.scope.IScopeHandler;
-import org.red5.server.api.service.IPendingServiceCall;
-import org.red5.server.api.service.IServiceCall;
-import org.red5.server.api.so.ISharedObject;
-import org.red5.server.api.so.ISharedObjectSecurity;
-import org.red5.server.api.so.ISharedObjectSecurityService;
-import org.red5.server.api.so.ISharedObjectService;
-import org.red5.server.api.stream.IClientBroadcastStream;
-import org.red5.server.api.stream.IClientStream;
-import org.red5.server.api.stream.IStreamService;
-import org.red5.server.exception.ClientRejectedException;
-import org.red5.server.exception.ScopeNotFoundException;
-import org.red5.server.exception.ScopeShuttingDownException;
-import org.red5.server.messaging.IConsumer;
-import org.red5.server.messaging.OOBControlMessage;
-import org.red5.server.net.ICommand;
-import org.red5.server.net.rtmp.codec.RTMP;
-import org.red5.server.net.rtmp.event.ChunkSize;
-import org.red5.server.net.rtmp.event.Invoke;
-import org.red5.server.net.rtmp.event.Ping;
-import org.red5.server.net.rtmp.event.SetBuffer;
-import org.red5.server.net.rtmp.event.StreamActionEvent;
-import org.red5.server.net.rtmp.message.Header;
-import org.red5.server.net.rtmp.status.Status;
-import org.red5.server.net.rtmp.status.StatusObject;
-import org.red5.server.net.rtmp.status.StatusObjectService;
-import org.red5.server.service.Call;
-import org.red5.server.so.ISharedObjectEvent;
-import org.red5.server.so.SharedObjectEvent;
-import org.red5.server.so.SharedObjectMessage;
-import org.red5.server.so.SharedObjectService;
-import org.red5.server.stream.StreamService;
-import org.red5.server.util.ScopeUtils;
-import org.slf4j.Logger;
-
-/**
- * RTMP events handler.
- */
-public class RTMPHandler extends BaseRTMPHandler {
-
- protected static Logger log = Red5LoggerFactory.getLogger(RTMPHandler.class);
-
- /**
- * Status object service.
- */
- protected StatusObjectService statusObjectService;
-
- /**
- * Red5 server instance.
- */
- protected IServer server;
-
- /**
- * Whether or not global scope connections are allowed.
- */
- private boolean globalScopeConnectionAllowed;
-
- /**
- * Whether or not to dispatch stream actions to the current scope.
- */
- private boolean dispatchStreamActions;
-
- /**
- * Setter for server object.
- *
- * @param server Red5 server instance
- */
- public void setServer(IServer server) {
- this.server = server;
- }
-
- /**
- * Setter for status object service.
- *
- * @param statusObjectService Status object service.
- */
- public void setStatusObjectService(StatusObjectService statusObjectService) {
- this.statusObjectService = statusObjectService;
- }
-
- public boolean isGlobalScopeConnectionAllowed() {
- return globalScopeConnectionAllowed;
- }
-
- public void setGlobalScopeConnectionAllowed(boolean globalScopeConnectionAllowed) {
- this.globalScopeConnectionAllowed = globalScopeConnectionAllowed;
- }
-
- /**
- * @return the dispatchStreamActions
- */
- public boolean isDispatchStreamActions() {
- return dispatchStreamActions;
- }
-
- /**
- * @param dispatchStreamActions the dispatchStreamActions to set
- */
- public void setDispatchStreamActions(boolean dispatchStreamActions) {
- this.dispatchStreamActions = dispatchStreamActions;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) {
- int requestedChunkSize = chunkSize.getSize();
- log.debug("Chunk size: {}", requestedChunkSize);
- // set chunk size on the connection
- RTMP state = conn.getState();
- // set only the read chunk size since it came from the client
- state.setReadChunkSize(requestedChunkSize);
- //state.setWriteChunkSize(requestedChunkSize);
- // set on each of the streams
- for (IClientStream stream : conn.getStreams()) {
- if (stream instanceof IClientBroadcastStream) {
- IClientBroadcastStream bs = (IClientBroadcastStream) stream;
- IBroadcastScope scope = bs.getScope().getBroadcastScope(bs.getPublishedName());
- if (scope == null) {
- continue;
- }
- OOBControlMessage setChunkSize = new OOBControlMessage();
- setChunkSize.setTarget("ClientBroadcastStream");
- setChunkSize.setServiceName("chunkSize");
- if (setChunkSize.getServiceParamMap() == null) {
- setChunkSize.setServiceParamMap(new HashMap());
- }
- setChunkSize.getServiceParamMap().put("chunkSize", requestedChunkSize);
- scope.sendOOBControlMessage((IConsumer) null, setChunkSize);
- log.debug("Sending chunksize {} to {}", chunkSize, bs.getProvider());
- }
- }
- }
-
- /**
- * Remoting call invocation handler.
- *
- * @param conn RTMP connection
- * @param call Service call
- */
- protected void invokeCall(RTMPConnection conn, IServiceCall call) {
- final IScope scope = conn.getScope();
- if (scope != null) {
- if (scope.hasHandler()) {
- final IScopeHandler handler = scope.getHandler();
- log.debug("Scope: {} handler: {}", scope, handler);
- if (!handler.serviceCall(conn, call)) {
- // XXX: What to do here? Return an error?
- log.warn("Scope: {} handler failed on service call", scope.getName(), new Exception("Service call failed"));
- return;
- }
- }
- final IContext context = scope.getContext();
- log.debug("Context: {}", context);
- context.getServiceInvoker().invoke(call, scope);
- } else {
- log.warn("Scope was null for invoke: {} connection state: {}", call.getServiceMethodName(), conn.getStateCode());
- }
- }
-
- /**
- * Remoting call invocation handler.
- *
- * @param conn
- * RTMP connection
- * @param call
- * Service call
- * @param service
- * Server-side service object
- * @return true if the call was performed, otherwise
- * false
- */
- private boolean invokeCall(RTMPConnection conn, IServiceCall call, Object service) {
- final IScope scope = conn.getScope();
- final IContext context = scope.getContext();
- if (log.isTraceEnabled()) {
- log.trace("Scope: {} context: {} service: {}", scope, context, service);
- }
- return context.getServiceInvoker().invoke(call, service);
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({ "unchecked" })
- @Override
- protected void onCommand(RTMPConnection conn, Channel channel, Header source, ICommand command) {
- log.debug("onCommand {}", command);
- // get the call
- final IServiceCall call = command.getCall();
- log.trace("call: {}", call);
- // get the method name
- final String action = call.getServiceMethodName();
- // If it's a callback for server remote call then pass it over to callbacks handler and return
- if ("_result".equals(action) || "_error".equals(action)) {
- handlePendingCallResult(conn, (Invoke) command);
- return;
- }
- boolean disconnectOnReturn = false;
- // "connected" here means that there is a scope associated with the connection (post-"connect")
- boolean connected = conn.isConnected();
- if (connected) {
- // If this is not a service call then handle connection...
- if (call.getServiceName() == null) {
- StreamAction streamAction = StreamAction.getEnum(action);
- if (log.isDebugEnabled()) {
- log.debug("Stream action: {}", streamAction.toString());
- }
- // TODO change this to an application scope parameter and / or change to the listener pattern
- if (dispatchStreamActions) {
- // pass the stream action event to the handler
- try {
- conn.getScope().getHandler().handleEvent(new StreamActionEvent(streamAction));
- } catch (Exception ex) {
- log.warn("Exception passing stream action: {} to the scope handler", streamAction, ex);
- }
- }
- //if the "stream" action is not predefined a custom type will be returned
- switch (streamAction) {
- case DISCONNECT:
- conn.close();
- break;
- case CREATE_STREAM:
- case INIT_STREAM:
- case CLOSE_STREAM:
- case RELEASE_STREAM:
- case DELETE_STREAM:
- case PUBLISH:
- case PLAY:
- case PLAY2:
- case SEEK:
- case PAUSE:
- case PAUSE_RAW:
- case RECEIVE_VIDEO:
- case RECEIVE_AUDIO:
- IStreamService streamService = (IStreamService) ScopeUtils.getScopeService(conn.getScope(), IStreamService.class, StreamService.class);
- Status status = null;
- try {
- log.debug("Invoking {} from {} with service: {}", new Object[] { call, conn, streamService });
- if (invokeCall(conn, call, streamService)) {
- log.debug("Stream service invoke {} success", action);
- } else {
- status = getStatus(NS_INVALID_ARGUMENT).asStatus();
- status.setDescription(String.format("Failed to %s (stream id: %d)", action, source.getStreamId()));
- }
- } catch (Throwable err) {
- log.error("Error while invoking {} on stream service. {}", action, err);
- status = getStatus(NS_FAILED).asStatus();
- status.setDescription(String.format("Error while invoking %s (stream id: %d)", action, source.getStreamId()));
- status.setDetails(err.getMessage());
- }
- if (status != null) {
- channel.sendStatus(status);
- } else {
- log.debug("Status for {} was null", action);
- }
- break;
- default:
- log.debug("Defaulting to invoke for: {}", action);
- invokeCall(conn, call);
- }
- } else {
- // handle service calls
- invokeCall(conn, call);
- }
- } else {
- if (StreamAction.CONNECT.equals(action)) {
- // Handle connection
- log.debug("connect");
- // Get parameters passed from client to
- // NetConnection#connection
- final Map params = command.getConnectionParams();
- // Get hostname
- String host = getHostname((String) params.get("tcUrl"));
- // app name as path, but without query string if there is one
- String path = (String) params.get("app");
- if (path.indexOf("?") != -1) {
- int idx = path.indexOf("?");
- params.put("queryString", path.substring(idx));
- path = path.substring(0, idx);
- }
- params.put("path", path);
- // connection setup
- conn.setup(host, path, params);
- try {
- // Lookup server scope when connected using host and application name
- IGlobalScope global = server.lookupGlobal(host, path);
- log.trace("Global lookup result: {}", global);
- if (global != null) {
- final IContext context = global.getContext();
- IScope scope = null;
- try {
- // TODO optimize this to use Scope instead of Context
- scope = context.resolveScope(global, path);
- // if global scope connection is not allowed, reject
- if (scope.getDepth() < 1 && !globalScopeConnectionAllowed) {
- call.setStatus(Call.STATUS_ACCESS_DENIED);
- if (call instanceof IPendingServiceCall) {
- IPendingServiceCall pc = (IPendingServiceCall) call;
- StatusObject status = getStatus(NC_CONNECT_REJECTED);
- status.setDescription("Global scope connection disallowed on this server.");
- pc.setResult(status);
- }
- disconnectOnReturn = true;
- }
- if (scope != null) {
- if (log.isTraceEnabled()) {
- log.trace("Connecting to: {}", scope);
- }
- if (log.isDebugEnabled()) {
- log.debug("Connecting to: {}", scope.getName());
- log.debug("Conn {}, scope {}, call {}", new Object[] { conn, scope, call });
- log.debug("Call args {}", call.getArguments());
- }
- boolean okayToConnect;
- try {
- if (call.getArguments() != null) {
- okayToConnect = conn.connect(scope, call.getArguments());
- } else {
- okayToConnect = conn.connect(scope);
- }
- if (okayToConnect) {
- log.debug("Connected - {}", conn.getClient());
- call.setStatus(Call.STATUS_SUCCESS_RESULT);
- if (call instanceof IPendingServiceCall) {
- IPendingServiceCall pc = (IPendingServiceCall) call;
- //send fmsver and capabilities
- StatusObject result = getStatus(NC_CONNECT_SUCCESS);
- result.setAdditional("fmsVer", Red5.getFMSVersion());
- result.setAdditional("capabilities", Red5.getCapabilities());
- result.setAdditional("mode", Integer.valueOf(1));
- result.setAdditional("data", Red5.getDataVersion());
- pc.setResult(result);
- }
- // Measure initial roundtrip time after connecting
- conn.ping(new Ping(Ping.STREAM_BEGIN, 0, -1));
- disconnectOnReturn = false;
- } else {
- log.debug("Connect failed");
- call.setStatus(Call.STATUS_ACCESS_DENIED);
- if (call instanceof IPendingServiceCall) {
- IPendingServiceCall pc = (IPendingServiceCall) call;
- pc.setResult(getStatus(NC_CONNECT_REJECTED));
- }
- disconnectOnReturn = true;
- }
- } catch (ClientRejectedException rejected) {
- log.debug("Connect rejected");
- call.setStatus(Call.STATUS_ACCESS_DENIED);
- if (call instanceof IPendingServiceCall) {
- IPendingServiceCall pc = (IPendingServiceCall) call;
- StatusObject status = getStatus(NC_CONNECT_REJECTED);
- Object reason = rejected.getReason();
- if (reason != null) {
- status.setApplication(reason);
- //should we set description?
- status.setDescription(reason.toString());
- }
- pc.setResult(status);
- }
- disconnectOnReturn = true;
- }
- }
- } catch (ScopeNotFoundException err) {
- log.warn("Scope not found", err);
- call.setStatus(Call.STATUS_SERVICE_NOT_FOUND);
- if (call instanceof IPendingServiceCall) {
- StatusObject status = getStatus(NC_CONNECT_REJECTED);
- status.setDescription(String.format("No scope '%s' on this server.", path));
- ((IPendingServiceCall) call).setResult(status);
- }
- log.info("Scope {} not found on {}", path, host);
- disconnectOnReturn = true;
- } catch (ScopeShuttingDownException err) {
- log.warn("Scope shutting down", err);
- call.setStatus(Call.STATUS_APP_SHUTTING_DOWN);
- if (call instanceof IPendingServiceCall) {
- StatusObject status = getStatus(NC_CONNECT_APPSHUTDOWN);
- status.setDescription(String.format("Application at '%s' is currently shutting down.", path));
- ((IPendingServiceCall) call).setResult(status);
- }
- log.info("Application at {} currently shutting down on {}", path, host);
- disconnectOnReturn = true;
- }
- } else {
- log.warn("Scope {} not found", path);
- call.setStatus(Call.STATUS_SERVICE_NOT_FOUND);
- if (call instanceof IPendingServiceCall) {
- StatusObject status = getStatus(NC_CONNECT_INVALID_APPLICATION);
- status.setDescription(String.format("No scope '%s' on this server.", path));
- ((IPendingServiceCall) call).setResult(status);
- }
- log.info("No application scope found for {} on host {}", path, host);
- disconnectOnReturn = true;
- }
- } catch (RuntimeException e) {
- call.setStatus(Call.STATUS_GENERAL_EXCEPTION);
- if (call instanceof IPendingServiceCall) {
- IPendingServiceCall pc = (IPendingServiceCall) call;
- pc.setResult(getStatus(NC_CONNECT_FAILED));
- }
- log.error("Error connecting {}", e);
- disconnectOnReturn = true;
- }
- // Evaluate request for AMF3 encoding
- if (Integer.valueOf(3).equals(params.get("objectEncoding"))) {
- if (call instanceof IPendingServiceCall) {
- Object pcResult = ((IPendingServiceCall) call).getResult();
- Map result;
- if (pcResult instanceof Map) {
- result = (Map) pcResult;
- result.put("objectEncoding", 3);
- } else if (pcResult instanceof StatusObject) {
- result = new HashMap();
- StatusObject status = (StatusObject) pcResult;
- result.put("code", status.getCode());
- result.put("description", status.getDescription());
- result.put("application", status.getApplication());
- result.put("level", status.getLevel());
- result.put("objectEncoding", 3);
- ((IPendingServiceCall) call).setResult(result);
- }
- }
- conn.getState().setEncoding(Encoding.AMF3);
- }
- } else {
- // not connected and attempting to send an invoke
- log.warn("Not connected, closing connection");
- conn.close();
- }
- }
- if (command instanceof Invoke) {
- if ((source.getStreamId() != 0) && (call.getStatus() == Call.STATUS_SUCCESS_VOID || call.getStatus() == Call.STATUS_SUCCESS_NULL)) {
- // This fixes a bug in the FP on Intel Macs.
- log.debug("Method does not have return value, do not reply");
- return;
- }
- boolean sendResult = true;
- if (call instanceof IPendingServiceCall) {
- IPendingServiceCall psc = (IPendingServiceCall) call;
- Object result = psc.getResult();
- if (result instanceof DeferredResult) {
- // Remember the deferred result to be sent later
- DeferredResult dr = (DeferredResult) result;
- dr.setServiceCall(psc);
- dr.setChannel(channel);
- dr.setTransactionId(command.getTransactionId());
- conn.registerDeferredResult(dr);
- sendResult = false;
- }
- }
- if (sendResult) {
- // The client expects a result for the method call.
- Invoke reply = new Invoke();
- reply.setCall(call);
- reply.setTransactionId(command.getTransactionId());
- channel.write(reply);
- if (disconnectOnReturn) {
- log.debug("Close connection due to connect handling exception: {}", conn.getSessionId());
- conn.close();
- }
- }
- }
- }
-
- public StatusObject getStatus(String code) {
- return statusObjectService.getStatusObject(code);
- }
-
- /** {@inheritDoc} */
- @Override
- protected void onPing(RTMPConnection conn, Channel channel, Header source, Ping ping) {
- switch (ping.getEventType()) {
- case Ping.CLIENT_BUFFER:
- SetBuffer setBuffer = (SetBuffer) ping;
- // get the stream id
- int streamId = setBuffer.getStreamId();
- // get requested buffer size in milliseconds
- int buffer = setBuffer.getBufferLength();
- log.debug("Client sent a buffer size: {} ms for stream id: {}", buffer, streamId);
- IClientStream stream = null;
- if (streamId != 0) {
- // The client wants to set the buffer time
- stream = conn.getStreamById(streamId);
- if (stream != null) {
- stream.setClientBufferDuration(buffer);
- log.trace("Stream type: {}", stream.getClass().getName());
- }
- }
- //catch-all to make sure buffer size is set
- if (stream == null) {
- // Remember buffer time until stream is created
- conn.rememberStreamBufferDuration(streamId, buffer);
- log.debug("Remembering client buffer on stream: {}", buffer);
- }
- break;
- case Ping.PONG_SERVER:
- // This is the response to an IConnection.ping request
- conn.pingReceived(ping);
- break;
- default:
- log.warn("Unhandled ping: {}", ping);
- }
- }
-
- /**
- * Create and send SO message stating that a SO could not be created.
- *
- * @param conn
- * @param message Shared object message that incurred the failure
- */
- private void sendSOCreationFailed(RTMPConnection conn, SharedObjectMessage message) {
- log.debug("sendSOCreationFailed - message: {} conn: {}", message, conn);
- // reset the object so we can re-use it
- message.reset();
- // add the error event
- message.addEvent(new SharedObjectEvent(ISharedObjectEvent.Type.CLIENT_STATUS, "error", SO_CREATION_FAILED));
- if (conn.isChannelUsed(3)) {
- // XXX Paul: I dont like this direct write stuff, need to move to event-based
- conn.getChannel(3).write(message);
- } else {
- log.warn("Channel is not in-use and cannot handle SO event: {}", message, new Exception("SO event handling failure"));
- // XXX Paul: I dont like this direct write stuff, need to move to event-based
- conn.getChannel(3).write(message);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- protected void onSharedObject(RTMPConnection conn, Channel channel, Header source, SharedObjectMessage message) {
- if (log.isDebugEnabled()) {
- log.debug("onSharedObject - conn: {} channel: {} so message: {}", new Object[] { conn.getSessionId(), channel.getId(), message });
- }
- final IScope scope = conn.getScope();
- if (scope != null) {
- // so name
- String name = message.getName();
- // whether or not the incoming so is persistent
- boolean persistent = message.isPersistent();
- // shared object service
- ISharedObjectService sharedObjectService = (ISharedObjectService) ScopeUtils.getScopeService(scope, ISharedObjectService.class, SharedObjectService.class, false);
- if (!sharedObjectService.hasSharedObject(scope, name)) {
- log.debug("Shared object service doesnt have requested object, creation will be attempted");
- ISharedObjectSecurityService security = (ISharedObjectSecurityService) ScopeUtils.getScopeService(scope, ISharedObjectSecurityService.class);
- if (security != null) {
- // Check handlers to see if creation is allowed
- for (ISharedObjectSecurity handler : security.getSharedObjectSecurity()) {
- if (!handler.isCreationAllowed(scope, name, persistent)) {
- log.debug("Shared object create failed, creation is not allowed");
- sendSOCreationFailed(conn, message);
- return;
- }
- }
- }
- if (!sharedObjectService.createSharedObject(scope, name, persistent)) {
- log.debug("Shared object create failed");
- sendSOCreationFailed(conn, message);
- return;
- }
- }
- ISharedObject so = sharedObjectService.getSharedObject(scope, name);
- if (so != null) {
- if (so.isPersistent() == persistent) {
- log.debug("Dispatch persistent shared object");
- so.dispatchEvent(message);
- } else {
- log.warn("Shared object persistence mismatch - current: {} incoming: {}", so.isPersistent(), persistent);
- // reset the object so we can re-use it
- message.reset();
- // add the error event
- message.addEvent(new SharedObjectEvent(ISharedObjectEvent.Type.CLIENT_STATUS, "error", SO_PERSISTENCE_MISMATCH));
- conn.getChannel(3).write(message);
- }
- } else {
- log.warn("Shared object lookup returned null for {} in {}", name, scope.getName());
- // reset the object so we can re-use it
- message.reset();
- // add the error event
- message.addEvent(new SharedObjectEvent(ISharedObjectEvent.Type.CLIENT_STATUS, "error", NC_CALL_FAILED));
- conn.getChannel(3).write(message);
- }
- } else {
- // The scope already has been deleted
- log.debug("Shared object scope was not found");
- sendSOCreationFailed(conn, message);
- }
- }
-
- protected void onBWDone() {
- log.debug("onBWDone");
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/RTMPHandshake.java b/src/main/java/org/red5/server/net/rtmp/RTMPHandshake.java
deleted file mode 100644
index 0fb4a3f46..000000000
--- a/src/main/java/org/red5/server/net/rtmp/RTMPHandshake.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.KeyFactory;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.Security;
-import java.security.spec.KeySpec;
-import java.util.Random;
-
-import javax.crypto.Cipher;
-import javax.crypto.KeyAgreement;
-import javax.crypto.Mac;
-import javax.crypto.interfaces.DHPublicKey;
-import javax.crypto.spec.DHParameterSpec;
-import javax.crypto.spec.DHPublicKeySpec;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.commons.codec.binary.Hex;
-import org.apache.mina.core.buffer.IoBuffer;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.red5.server.net.IHandshake;
-import org.red5.server.net.rtmp.message.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Generates and validates the RTMP handshake response for Flash Players.
- * Client versions equal to or greater than Flash 9,0,124,0 require a nonzero
- * value as the fifth byte of the handshake request.
- *
- * @author Jacinto Shy II (jacinto.m.shy@ieee.org)
- * @author Steven Zimmer (stevenlzimmer@gmail.com)
- * @author Gavriloaie Eugen-Andrei
- * @author Ari-Pekka Viitanen
- * @author Paul Gregoire
- * @author Tiago Jacobs
- */
-public abstract class RTMPHandshake implements IHandshake {
-
- protected static Logger log = LoggerFactory.getLogger(RTMPHandshake.class);
-
- //for old style handshake
- public static byte[] HANDSHAKE_PAD_BYTES;
-
- protected static final byte[] GENUINE_FMS_KEY = {
- (byte) 0x47, (byte) 0x65, (byte) 0x6e, (byte) 0x75, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x20,
- (byte) 0x41, (byte) 0x64, (byte) 0x6f, (byte) 0x62, (byte) 0x65, (byte) 0x20, (byte) 0x46, (byte) 0x6c,
- (byte) 0x61, (byte) 0x73, (byte) 0x68, (byte) 0x20, (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x69,
- (byte) 0x61, (byte) 0x20, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x76, (byte) 0x65, (byte) 0x72,
- (byte) 0x20, (byte) 0x30, (byte) 0x30, (byte) 0x31, // Genuine Adobe Flash Media Server 001
- (byte) 0xf0, (byte) 0xee, (byte) 0xc2, (byte) 0x4a, (byte) 0x80, (byte) 0x68, (byte) 0xbe, (byte) 0xe8,
- (byte) 0x2e, (byte) 0x00, (byte) 0xd0, (byte) 0xd1, (byte) 0x02, (byte) 0x9e, (byte) 0x7e, (byte) 0x57,
- (byte) 0x6e, (byte) 0xec, (byte) 0x5d, (byte) 0x2d, (byte) 0x29, (byte) 0x80, (byte) 0x6f, (byte) 0xab,
- (byte) 0x93, (byte) 0xb8, (byte) 0xe6, (byte) 0x36, (byte) 0xcf, (byte) 0xeb, (byte) 0x31, (byte) 0xae};
-
- protected static final byte[] GENUINE_FP_KEY = {
- (byte) 0x47, (byte) 0x65, (byte) 0x6E, (byte) 0x75, (byte) 0x69, (byte) 0x6E, (byte) 0x65, (byte) 0x20,
- (byte) 0x41, (byte) 0x64, (byte) 0x6F, (byte) 0x62, (byte) 0x65, (byte) 0x20, (byte) 0x46, (byte) 0x6C,
- (byte) 0x61, (byte) 0x73, (byte) 0x68, (byte) 0x20, (byte) 0x50, (byte) 0x6C, (byte) 0x61, (byte) 0x79,
- (byte) 0x65, (byte) 0x72, (byte) 0x20, (byte) 0x30, (byte) 0x30, (byte) 0x31, // Genuine Adobe Flash Player 001
- (byte) 0xF0, (byte) 0xEE, (byte) 0xC2, (byte) 0x4A, (byte) 0x80, (byte) 0x68, (byte) 0xBE, (byte) 0xE8,
- (byte) 0x2E, (byte) 0x00, (byte) 0xD0, (byte) 0xD1, (byte) 0x02, (byte) 0x9E, (byte) 0x7E, (byte) 0x57,
- (byte) 0x6E, (byte) 0xEC, (byte) 0x5D, (byte) 0x2D, (byte) 0x29, (byte) 0x80, (byte) 0x6F, (byte) 0xAB,
- (byte) 0x93, (byte) 0xB8, (byte) 0xE6, (byte) 0x36, (byte) 0xCF, (byte) 0xEB, (byte) 0x31, (byte) 0xAE};
-
- /** Modulus bytes from flazr */
- protected static final byte[] DH_MODULUS_BYTES = { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xc9, (byte) 0x0f, (byte) 0xda, (byte) 0xa2, (byte) 0x21,
- (byte) 0x68, (byte) 0xc2, (byte) 0x34, (byte) 0xc4, (byte) 0xc6, (byte) 0x62, (byte) 0x8b, (byte) 0x80,
- (byte) 0xdc, (byte) 0x1c, (byte) 0xd1, (byte) 0x29, (byte) 0x02, (byte) 0x4e, (byte) 0x08, (byte) 0x8a,
- (byte) 0x67, (byte) 0xcc, (byte) 0x74, (byte) 0x02, (byte) 0x0b, (byte) 0xbe, (byte) 0xa6, (byte) 0x3b,
- (byte) 0x13, (byte) 0x9b, (byte) 0x22, (byte) 0x51, (byte) 0x4a, (byte) 0x08, (byte) 0x79, (byte) 0x8e,
- (byte) 0x34, (byte) 0x04, (byte) 0xdd, (byte) 0xef, (byte) 0x95, (byte) 0x19, (byte) 0xb3, (byte) 0xcd,
- (byte) 0x3a, (byte) 0x43, (byte) 0x1b, (byte) 0x30, (byte) 0x2b, (byte) 0x0a, (byte) 0x6d, (byte) 0xf2,
- (byte) 0x5f, (byte) 0x14, (byte) 0x37, (byte) 0x4f, (byte) 0xe1, (byte) 0x35, (byte) 0x6d, (byte) 0x6d,
- (byte) 0x51, (byte) 0xc2, (byte) 0x45, (byte) 0xe4, (byte) 0x85, (byte) 0xb5, (byte) 0x76, (byte) 0x62,
- (byte) 0x5e, (byte) 0x7e, (byte) 0xc6, (byte) 0xf4, (byte) 0x4c, (byte) 0x42, (byte) 0xe9, (byte) 0xa6,
- (byte) 0x37, (byte) 0xed, (byte) 0x6b, (byte) 0x0b, (byte) 0xff, (byte) 0x5c, (byte) 0xb6, (byte) 0xf4,
- (byte) 0x06, (byte) 0xb7, (byte) 0xed, (byte) 0xee, (byte) 0x38, (byte) 0x6b, (byte) 0xfb, (byte) 0x5a,
- (byte) 0x89, (byte) 0x9f, (byte) 0xa5, (byte) 0xae, (byte) 0x9f, (byte) 0x24, (byte) 0x11, (byte) 0x7c,
- (byte) 0x4b, (byte) 0x1f, (byte) 0xe6, (byte) 0x49, (byte) 0x28, (byte) 0x66, (byte) 0x51, (byte) 0xec,
- (byte) 0xe6, (byte) 0x53, (byte) 0x81, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff };
-
- protected static final BigInteger DH_MODULUS = new BigInteger(1, DH_MODULUS_BYTES);
-
- protected static final BigInteger DH_BASE = BigInteger.valueOf(2);
-
- protected static final int HANDSHAKE_SIZE_SERVER = (Constants.HANDSHAKE_SIZE * 2) + 1;
-
- protected static final int DIGEST_LENGTH = 32;
-
- protected static final int KEY_LENGTH = 128;
-
- protected static final Random random = new Random();
-
- protected KeyAgreement keyAgreement;
-
- protected Cipher cipherOut;
-
- protected Cipher cipherIn;
-
- protected byte handshakeType;
-
- protected byte[] handshakeBytes;
-
- // validation scheme
- protected int validationScheme = 0;
-
- // servers public key
- protected byte[] incomingPublicKey;
-
- // clients public key
- protected byte[] outgoingPublicKey;
-
- // swf verification bytes
- protected byte[] swfVerificationBytes;
-
- private Mac hmacSHA256;
-
- static {
- //get security provider
- Security.addProvider(new BouncyCastleProvider());
- }
-
- public RTMPHandshake() {
- log.trace("Handshake ctor");
- try {
- hmacSHA256 = Mac.getInstance("HmacSHA256");
- } catch (SecurityException e) {
- log.error("Security exception when getting HMAC", e);
- } catch (NoSuchAlgorithmException e) {
- log.error("HMAC SHA256 does not exist");
- }
- //create our handshake bytes
- createHandshakeBytes();
- }
-
- /**
- * Calculates an HMAC SHA256 hash using a default key length.
- *
- * @param input
- * @param key
- * @return hmac hashed bytes
- */
- public byte[] calculateHMAC_SHA256(byte[] input, byte[] key) {
- byte[] output = null;
- try {
- hmacSHA256.init(new SecretKeySpec(key, "HmacSHA256"));
- output = hmacSHA256.doFinal(input);
- } catch (InvalidKeyException e) {
- log.error("Invalid key", e);
- }
- return output;
- }
-
- /**
- * Calculates an HMAC SHA256 hash using a set key length.
- *
- * @param input
- * @param key
- * @param length
- * @return hmac hashed bytes
- */
- public byte[] calculateHMAC_SHA256(byte[] input, byte[] key, int length) {
- byte[] output = null;
- try {
- hmacSHA256.init(new SecretKeySpec(key, 0, length, "HmacSHA256"));
- output = hmacSHA256.doFinal(input);
- } catch (InvalidKeyException e) {
- log.error("Invalid key", e);
- }
- return output;
- }
-
- /**
- * Creates a Diffie-Hellman key pair.
- *
- * @return dh keypair
- */
- protected KeyPair generateKeyPair() {
- KeyPair keyPair = null;
- DHParameterSpec keySpec = new DHParameterSpec(DH_MODULUS, DH_BASE);
- try {
- KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH");
- keyGen.initialize(keySpec);
- keyPair = keyGen.generateKeyPair();
- keyAgreement = KeyAgreement.getInstance("DH");
- keyAgreement.init(keyPair.getPrivate());
- } catch (Exception e) {
- log.error("Error generating keypair", e);
- }
- return keyPair;
- }
-
- /**
- * Returns the public key for a given key pair.
- *
- * @param keyPair
- * @return public key
- */
- protected static byte[] getPublicKey(KeyPair keyPair) {
- DHPublicKey incomingPublicKey = (DHPublicKey) keyPair.getPublic();
- BigInteger dhY = incomingPublicKey.getY();
- log.debug("Public key: {}", dhY);
- byte[] result = dhY.toByteArray();
- log.debug("Public key as bytes - length [{}]: {}", result.length, Hex.encodeHexString(result));
- byte[] temp = new byte[KEY_LENGTH];
- if (result.length < KEY_LENGTH) {
- System.arraycopy(result, 0, temp, KEY_LENGTH - result.length, result.length);
- result = temp;
- log.debug("Padded public key length to 128");
- } else if (result.length > KEY_LENGTH){
- System.arraycopy(result, result.length - KEY_LENGTH, temp, 0, KEY_LENGTH);
- result = temp;
- log.debug("Truncated public key length to 128");
- }
- return result;
- }
-
- /**
- * Determines the validation scheme for given input.
- *
- * @param otherPublicKeyBytes
- * @param agreement
- * @return shared secret bytes if client used a supported validation scheme
- */
- protected static byte[] getSharedSecret(byte[] otherPublicKeyBytes, KeyAgreement agreement) {
- BigInteger otherPublicKeyInt = new BigInteger(1, otherPublicKeyBytes);
- try {
- KeyFactory keyFactory = KeyFactory.getInstance("DH");
- KeySpec otherPublicKeySpec = new DHPublicKeySpec(otherPublicKeyInt, RTMPHandshake.DH_MODULUS, RTMPHandshake.DH_BASE);
- PublicKey otherPublicKey = keyFactory.generatePublic(otherPublicKeySpec);
- agreement.doPhase(otherPublicKey, true);
- } catch (Exception e) {
- log.error("Exception getting the shared secret", e);
- }
- byte[] sharedSecret = agreement.generateSecret();
- log.debug("Shared secret [{}]: {}", sharedSecret.length, Hex.encodeHexString(sharedSecret));
- return sharedSecret;
- }
-
- /**
- * Create the initial bytes for a request / response.
- */
- protected abstract void createHandshakeBytes();
-
- /**
- * Determines the validation scheme for given input.
- *
- * @param input
- * @return true if its a supported validation scheme, false if unsupported
- */
- public abstract boolean validate(IoBuffer input);
-
- /**
- * Returns the DH offset from an array of bytes.
- *
- * @param bytes
- * @return DH offset
- */
- protected int getDHOffset(byte[] bytes) {
- int dhOffset = -1;
- switch (validationScheme) {
- case 1:
- dhOffset = getDHOffset1(bytes);
- break;
- default:
- log.debug("Scheme 0 will be used for DH offset");
- case 0:
- dhOffset = getDHOffset0(bytes);
- }
- return dhOffset;
- }
-
- /**
- * Returns the DH byte offset.
- *
- * @return dh offset
- */
- protected int getDHOffset0(byte[] bytes) {
- int offset = (bytes[1532] & 0x0ff) + (bytes[1533] & 0x0ff) + (bytes[1534] & 0x0ff) + (bytes[1535] & 0x0ff);
- offset = offset % 632;
- offset = offset + 772;
- if (offset + KEY_LENGTH >= 1536) {
- log.error("Invalid DH offset");
- }
- return offset;
- }
-
- /**
- * Returns the DH byte offset.
- *
- * @return dh offset
- */
- protected int getDHOffset1(byte[] bytes) {
- int offset = (bytes[768] & 0x0ff) + (bytes[769] & 0x0ff) + (bytes[770] & 0x0ff) + (bytes[771] & 0x0ff);
- offset = offset % 632;
- offset = offset + 8;
- if (offset + KEY_LENGTH >= 1536) {
- log.error("Invalid DH offset");
- }
- return offset;
- }
-
- /**
- * Returns the digest offset using current validation scheme.
- *
- * @param pBuffer
- * @return digest offset
- */
- protected int getDigestOffset(byte[] pBuffer) {
- int serverDigestOffset = -1;
- switch (validationScheme) {
- case 1:
- serverDigestOffset = getDigestOffset1(pBuffer);
- break;
- default:
- log.debug("Scheme 0 will be used for DH offset");
- case 0:
- serverDigestOffset = getDigestOffset0(pBuffer);
- }
- return serverDigestOffset;
- }
-
- /**
- * Returns a digest byte offset.
- *
- * @param pBuffer source for digest data
- * @return digest offset
- */
- protected int getDigestOffset0(byte[] pBuffer) {
- if (log.isTraceEnabled()) {
- log.trace("Scheme 0 offset bytes {},{},{},{}", new Object[]{(pBuffer[8] & 0x0ff), (pBuffer[9] & 0x0ff), (pBuffer[10] & 0x0ff), (pBuffer[11] & 0x0ff)});
- }
- int offset = (pBuffer[8] & 0x0ff) + (pBuffer[9] & 0x0ff) + (pBuffer[10] & 0x0ff) + (pBuffer[11] & 0x0ff);
- offset = offset % 728;
- offset = offset + 12;
- if (offset + DIGEST_LENGTH >= 1536) {
- log.error("Invalid digest offset");
- }
- return offset;
- }
-
- /**
- * Returns a digest byte offset.
- *
- * @param pBuffer source for digest data
- * @return digest offset
- */
- protected int getDigestOffset1(byte[] pBuffer) {
- if (log.isTraceEnabled()) {
- log.trace("Scheme 1 offset bytes {},{},{},{}", new Object[]{(pBuffer[772] & 0x0ff), (pBuffer[773] & 0x0ff), (pBuffer[774] & 0x0ff), (pBuffer[775] & 0x0ff)});
- }
- int offset = (pBuffer[772] & 0x0ff) + (pBuffer[773] & 0x0ff) + (pBuffer[774] & 0x0ff) + (pBuffer[775] & 0x0ff);
- offset = offset % 728;
- offset = offset + 776;
- if (offset + DIGEST_LENGTH >= 1536) {
- log.error("Invalid digest offset");
- }
- return offset;
- }
-
- /**
- * Creates the servers handshake bytes
- */
- public byte[] getHandshakeBytes() {
- return handshakeBytes;
- }
-
- /**
- * Sets the handshake type. Currently only two types are supported, plain and encrypted.
- *
- * @param handshakeType
- */
- public void setHandshakeType(byte handshakeType) {
- log.trace("Setting handshake type: {}", handshakeType);
- this.handshakeType = handshakeType;
- }
-
- /**
- * Returns the handshake type.
- *
- * @return handshakeType
- */
- public byte getHandshakeType() {
- return handshakeType;
- }
-
- /**
- * Gets the DH offset in the handshake bytes array based on validation scheme
- * Generates DH keypair
- * Adds public key to handshake bytes
- */
- public Cipher getCipherOut() {
- return cipherOut;
- }
-
- /**
- * Returns the contained handshake bytes. These are just random bytes
- * if the player is using an non-versioned player.
- *
- * @return handshake bytes
- */
- public Cipher getCipherIn() {
- return cipherIn;
- }
-
- /**
- * Returns the SWF verification bytes.
- *
- * @return swf verification bytes
- */
- public byte[] getSwfVerificationBytes() {
- return swfVerificationBytes;
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/RTMPMinaConnection.java b/src/main/java/org/red5/server/net/rtmp/RTMPMinaConnection.java
deleted file mode 100644
index 0bd034901..000000000
--- a/src/main/java/org/red5/server/net/rtmp/RTMPMinaConnection.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.beans.ConstructorProperties;
-import java.lang.management.ManagementFactory;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.apache.mina.core.future.CloseFuture;
-import org.apache.mina.core.future.IoFutureListener;
-import org.apache.mina.core.session.IoSession;
-import org.red5.server.api.scope.IScope;
-import org.red5.server.jmx.mxbeans.RTMPMinaConnectionMXBean;
-import org.red5.server.net.rtmp.codec.RTMP;
-import org.red5.server.net.rtmp.event.ClientBW;
-import org.red5.server.net.rtmp.event.ServerBW;
-import org.red5.server.net.rtmp.message.Packet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jmx.export.annotation.ManagedResource;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-/**
- * Represents an RTMP connection using Mina.
- *
- * @see "http://mina.apache.org/report/trunk/apidocs/org/apache/mina/core/session/IoSession.html"
- *
- * @author Paul Gregoire
- */
-@ManagedResource
-public class RTMPMinaConnection extends RTMPConnection implements RTMPMinaConnectionMXBean {
-
- protected static Logger log = LoggerFactory.getLogger(RTMPMinaConnection.class);
-
- /**
- * MINA I/O session, connection between two end points
- */
- private IoSession ioSession;
-
- /**
- * MBean object name used for de/registration purposes.
- */
- private ObjectName oName;
-
- protected int defaultServerBandwidth = 10000000;
-
- protected int defaultClientBandwidth = 10000000;
-
- protected boolean bandwidthDetection = true;
-
- /** Constructs a new RTMPMinaConnection. */
- @ConstructorProperties(value = { "persistent" })
- public RTMPMinaConnection() {
- super(PERSISTENT);
- }
-
- @SuppressWarnings("cast")
- @Override
- public boolean connect(IScope newScope, Object[] params) {
- log.debug("Connect scope: {}", newScope);
- boolean success = super.connect(newScope, params);
- if (success) {
- // tell the flash player how fast we want data and how fast we shall
- // send it
- getChannel(2).write(new ServerBW(defaultServerBandwidth));
- // second param is the limit type (0=hard,1=soft,2=dynamic)
- getChannel(2).write(new ClientBW(defaultClientBandwidth, (byte) limitType));
- // if the client is null for some reason, skip the jmx registration
- if (client != null) {
- // perform bandwidth detection
- if (bandwidthDetection && !client.isBandwidthChecked()) {
- client.checkBandwidth();
- }
- } else {
- log.warn("Client was null");
- }
- registerJMX();
- } else {
- log.debug("Connect failed");
- }
- return success;
- }
-
- /** {@inheritDoc} */
- @Override
- public void close() {
- super.close();
- log.debug("IO Session closing: {}", (ioSession != null ? ioSession.isClosing() : null));
- if (ioSession != null && !ioSession.isClosing()) {
- // accept no further incoming data
- // ioSession.suspendRead();
- // close now, no flushing, no waiting
- final CloseFuture future = ioSession.close(true);
- log.debug("Connection close future: {}", future);
- IoFutureListener listener = new IoFutureListener() {
- public void operationComplete(CloseFuture future) {
- if (future.isClosed()) {
- log.debug("Connection is closed");
- log.trace("Session id - local: {} session: {}", getSessionId(), (String) ioSession.removeAttribute(RTMPConnection.RTMP_SESSION_ID));
- RTMPMinaConnection conn = (RTMPMinaConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);
- if (conn != null) {
- handler.connectionClosed(conn);
- }
- } else {
- log.debug("Connection is not yet closed");
- }
- future.removeListener(this);
- }
- };
- future.addListener(listener);
- }
- log.debug("Connection state: {}", getState());
- if (getStateCode() != RTMP.STATE_DISCONNECTED) {
- handler.connectionClosed(this);
- }
- // de-register with JMX
- unregisterJMX();
- }
-
- /**
- * Return MINA I/O session.
- *
- * @return MINA O/I session, connection between two end-points
- */
- public IoSession getIoSession() {
- return ioSession;
- }
-
- /**
- * @return the defaultServerBandwidth
- */
- public int getDefaultServerBandwidth() {
- return defaultServerBandwidth;
- }
-
- /**
- * @param defaultServerBandwidth
- * the defaultServerBandwidth to set
- */
- public void setDefaultServerBandwidth(int defaultServerBandwidth) {
- this.defaultServerBandwidth = defaultServerBandwidth;
- }
-
- /**
- * @return the defaultClientBandwidth
- */
- public int getDefaultClientBandwidth() {
- return defaultClientBandwidth;
- }
-
- /**
- * @param defaultClientBandwidth
- * the defaultClientBandwidth to set
- */
- public void setDefaultClientBandwidth(int defaultClientBandwidth) {
- this.defaultClientBandwidth = defaultClientBandwidth;
- }
-
- /**
- * @return the limitType
- */
- public int getLimitType() {
- return limitType;
- }
-
- /**
- * @param limitType
- * the limitType to set
- */
- public void setLimitType(int limitType) {
- this.limitType = limitType;
- }
-
- @Override
- public void setExecutor(ThreadPoolTaskExecutor executor) {
- this.executor = executor;
- }
-
- /**
- * @return the bandwidthDetection
- */
- public boolean isBandwidthDetection() {
- return bandwidthDetection;
- }
-
- /**
- * @param bandwidthDetection
- * the bandwidthDetection to set
- */
- public void setBandwidthDetection(boolean bandwidthDetection) {
- this.bandwidthDetection = bandwidthDetection;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isReaderIdle() {
- if (ioSession != null) {
- return ioSession.isReaderIdle();
- }
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isWriterIdle() {
- if (ioSession != null) {
- return ioSession.isWriterIdle();
- }
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- public long getPendingMessages() {
- if (ioSession != null) {
- return ioSession.getScheduledWriteMessages();
- }
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override
- public long getReadBytes() {
- if (ioSession != null) {
- return ioSession.getReadBytes();
- }
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override
- public long getWrittenBytes() {
- if (ioSession != null) {
- return ioSession.getWrittenBytes();
- }
- return 0;
- }
-
- public void invokeMethod(String method) {
- invoke(method);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isConnected() {
- log.debug("Connected: {}", (ioSession != null && ioSession.isConnected()));
- // XXX Paul: not sure isClosing is actually working as we expect here
- return super.isConnected() && (ioSession != null && ioSession.isConnected());
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isIdle() {
- if (ioSession != null) {
- log.debug("Connection idle - read: {} write: {}", ioSession.isReaderIdle(), ioSession.isWriterIdle());
- return super.isIdle() && ioSession.isBothIdle();
- }
- return super.isIdle();
- }
-
- /** {@inheritDoc} */
- @Override
- protected void onInactive() {
- close();
- }
-
- /**
- * Setter for MINA I/O session (connection).
- *
- * @param protocolSession
- * Protocol session
- */
- public void setIoSession(IoSession protocolSession) {
- SocketAddress remote = protocolSession.getRemoteAddress();
- if (remote instanceof InetSocketAddress) {
- remoteAddress = ((InetSocketAddress) remote).getAddress().getHostAddress();
- remotePort = ((InetSocketAddress) remote).getPort();
- } else {
- remoteAddress = remote.toString();
- remotePort = -1;
- }
- remoteAddresses = new ArrayList(1);
- remoteAddresses.add(remoteAddress);
- remoteAddresses = Collections.unmodifiableList(remoteAddresses);
- this.ioSession = protocolSession;
- log.trace("setIoSession conn: {}", this);
- }
-
- /** {@inheritDoc} */
- @Override
- public void write(Packet out) {
- if (ioSession != null) {
- final Semaphore lock = getLock();
- log.trace("Write lock wait count: {} closed: {}", lock.getQueueLength(), isClosed());
- while (!isClosed()) {
- boolean acquired = false;
- try {
- acquired = lock.tryAcquire(10, TimeUnit.MILLISECONDS);
- if (acquired) {
- log.trace("Writing message");
- writingMessage(out);
- ioSession.write(out);
- break;
- }
- } catch (InterruptedException e) {
- log.warn("Interrupted while waiting for write lock. State: {}", state.states[state.getState()], e);
- String exMsg = e.getMessage();
- // if the exception cause is null break out of here to
- // prevent looping until closed
- if (exMsg == null || exMsg.indexOf("null") >= 0) {
- log.debug("Exception writing to connection: {}", this);
- break;
- }
- } finally {
- if (acquired) {
- lock.release();
- }
- }
- }
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void writeRaw(IoBuffer out) {
- if (ioSession != null) {
- final Semaphore lock = getLock();
- while (!isClosed()) {
- boolean acquired = false;
- try {
- acquired = lock.tryAcquire(10, TimeUnit.MILLISECONDS);
- if (acquired) {
- log.trace("Writing raw message");
- ioSession.write(out);
- break;
- }
- } catch (InterruptedException e) {
- log.warn("Interrupted while waiting for write lock (writeRaw). State: {}", state.states[state.getState()], e);
- String exMsg = e.getMessage();
- // if the exception cause is null break out of here to
- // prevent looping until closed
- if (exMsg == null || exMsg.indexOf("null") >= 0) {
- log.debug("Exception writing to connection: {}", this);
- break;
- }
- } finally {
- if (acquired) {
- lock.release();
- }
- }
- }
- }
- }
-
- protected void registerJMX() {
- // register with jmx
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- try {
- String cName = this.getClass().getName();
- if (cName.indexOf('.') != -1) {
- cName = cName.substring(cName.lastIndexOf('.')).replaceFirst("[\\.]", "");
- }
- String hostStr = host;
- int port = 1935;
- if (host != null && host.indexOf(":") > -1) {
- String[] arr = host.split(":");
- hostStr = arr[0];
- port = Integer.parseInt(arr[1]);
- }
- // Create a new mbean for this instance
- oName = new ObjectName(String.format("org.red5.server:type=%s,connectionType=%s,host=%s,port=%d,clientId=%s", cName, type, hostStr, port, client.getId()));
- if (!mbs.isRegistered(oName)) {
- mbs.registerMBean(new StandardMBean(this, RTMPMinaConnectionMXBean.class, true), oName);
- } else {
- log.debug("Connection is already registered in JMX");
- }
- } catch (Exception e) {
- log.warn("Error on jmx registration", e);
- }
- }
-
- protected void unregisterJMX() {
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- if (oName != null && mbs.isRegistered(oName)) {
- try {
- mbs.unregisterMBean(oName);
- } catch (Exception e) {
- log.warn("Exception unregistering: {}", oName, e);
- }
- oName = null;
- }
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/RTMPMinaIoHandler.java b/src/main/java/org/red5/server/net/rtmp/RTMPMinaIoHandler.java
deleted file mode 100644
index adb8a462b..000000000
--- a/src/main/java/org/red5/server/net/rtmp/RTMPMinaIoHandler.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import java.io.IOException;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.apache.mina.core.future.CloseFuture;
-import org.apache.mina.core.future.IoFutureListener;
-import org.apache.mina.core.service.IoHandlerAdapter;
-import org.apache.mina.core.service.IoProcessor;
-import org.apache.mina.core.session.IoSession;
-import org.apache.mina.core.write.WriteRequestQueue;
-import org.apache.mina.filter.codec.ProtocolCodecFactory;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.red5.server.net.rtmp.codec.RTMP;
-import org.red5.server.net.rtmp.message.Packet;
-import org.red5.server.net.rtmpe.RTMPEIoFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Handles all RTMP protocol events fired by the MINA framework.
- */
-public class RTMPMinaIoHandler extends IoHandlerAdapter {
-
- private static Logger log = LoggerFactory.getLogger(RTMPMinaIoHandler.class);
-
- /**
- * RTMP events handler
- */
- protected IRTMPHandler handler;
-
- protected ProtocolCodecFactory codecFactory;
-
- /** {@inheritDoc} */
- @Override
- public void sessionCreated(IoSession session) throws Exception {
- log.debug("Session created");
- // add rtmpe filter
- session.getFilterChain().addFirst("rtmpeFilter", new RTMPEIoFilter());
- // add protocol filter next
- session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(codecFactory));
- // create a connection
- RTMPMinaConnection conn = createRTMPMinaConnection();
- // add session to the connection
- conn.setIoSession(session);
- // add the handler
- conn.setHandler(handler);
- // add the connections session id for look up using the connection manager
- session.setAttribute(RTMPConnection.RTMP_SESSION_ID, conn.getSessionId());
- // add the in-bound handshake
- session.setAttribute(RTMPConnection.RTMP_HANDSHAKE, new InboundHandshake());
- }
-
- /** {@inheritDoc} */
- @Override
- public void sessionOpened(IoSession session) throws Exception {
- String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- log.debug("Session opened: {} id: {}", session.getId(), sessionId);
- RTMPMinaConnection conn = (RTMPMinaConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);
- handler.connectionOpened(conn);
- }
-
- /** {@inheritDoc} */
- @Override
- public void sessionClosed(IoSession session) throws Exception {
- String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- log.debug("Session closed: {} id: {}", session.getId(), sessionId);
- if (log.isTraceEnabled()) {
- log.trace("Session attributes: {}", session.getAttributeKeys());
- }
- if (sessionId != null) {
- RTMPMinaConnection conn = (RTMPMinaConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);
- if (conn != null) {
- // fire-off closed event
- handler.connectionClosed(conn);
- // clear any session attributes we may have previously set
- // TODO: verify this cleanup code is necessary. The session is over and will be garbage collected surely?
- if (session.containsAttribute(RTMPConnection.RTMP_HANDSHAKE)) {
- session.removeAttribute(RTMPConnection.RTMP_HANDSHAKE);
- }
- if (session.containsAttribute(RTMPConnection.RTMPE_CIPHER_IN)) {
- session.removeAttribute(RTMPConnection.RTMPE_CIPHER_IN);
- session.removeAttribute(RTMPConnection.RTMPE_CIPHER_OUT);
- }
- } else {
- log.warn("Connection was not found for {}", sessionId);
- }
- } else {
- log.debug("Connections session id was null in session, may already be closed");
- }
- }
-
- /**
- * Handle raw buffer receiving event.
- *
- * @param in
- * Data buffer
- * @param session
- * I/O session, that is, connection between two endpoints
- */
- protected void rawBufferRecieved(IoBuffer in, IoSession session) {
- if (log.isTraceEnabled()) {
- log.trace("rawBufferRecieved: {}", in);
- }
- String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- log.trace("Session id: {}", sessionId);
- RTMPMinaConnection conn = (RTMPMinaConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);
- RTMPHandshake handshake = (RTMPHandshake) session.getAttribute(RTMPConnection.RTMP_HANDSHAKE);
- if (handshake != null) {
- if (conn.getStateCode() != RTMP.STATE_HANDSHAKE) {
- log.warn("Raw buffer after handshake, something odd going on");
- }
- log.debug("Handshake - server phase 1 - size: {}", in.remaining());
- IoBuffer out = handshake.doHandshake(in);
- if (out != null) {
- log.trace("Output: {}", out);
- session.write(out);
- //if we are connected and doing encryption, add the ciphers
- if (conn.getStateCode() == RTMP.STATE_CONNECTED) {
- // remove handshake from session now that we are connected
- // if we are using encryption then put the ciphers in the session
- if (handshake.getHandshakeType() == RTMPConnection.RTMP_ENCRYPTED) {
- log.debug("Adding ciphers to the session");
- session.setAttribute(RTMPConnection.RTMPE_CIPHER_IN, handshake.getCipherIn());
- session.setAttribute(RTMPConnection.RTMPE_CIPHER_OUT, handshake.getCipherOut());
- }
- }
- }
- } else {
- log.warn("Handshake was not found for this connection: {}", conn);
- log.debug("Session: {}", session.getId());
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void messageReceived(IoSession session, Object message) throws Exception {
- String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- log.trace("Message received on session: {} id: {}", session.getId(), sessionId);
- if (message instanceof IoBuffer) {
- rawBufferRecieved((IoBuffer) message, session);
- } else {
- log.trace("Session id: {}", sessionId);
- RTMPMinaConnection conn = (RTMPMinaConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);
- if (conn != null) {
- byte state = conn.getStateCode();
- // checking the state before allowing a task to be created will hopefully prevent rejected task exceptions
- if (state != RTMP.STATE_DISCONNECTING && state != RTMP.STATE_DISCONNECTED) {
- conn.handleMessageReceived((Packet) message);
- } else {
- log.info("Ignoring received message on {} due to state: {}", sessionId, conn.getState().states[state]);
- }
- } else {
- log.warn("Connection was not found for {}", sessionId);
- forceClose(session);
- }
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void messageSent(IoSession session, Object message) throws Exception {
- String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- log.trace("Message sent on session: {} id: {}", session.getId(), sessionId);
- RTMPMinaConnection conn = (RTMPMinaConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);
- if (conn != null) {
- byte state = conn.getStateCode();
- if (state != RTMP.STATE_DISCONNECTING && state != RTMP.STATE_DISCONNECTED) {
- if (message instanceof Packet) {
- handler.messageSent(conn, (Packet) message);
- } else {
- log.debug("Message was not of Packet type; its type: {}", message != null ? message.getClass().getName() : "null");
- }
- }
- } else {
- log.warn("Destination connection was null, it is already disposed. Session id: {}", sessionId);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
- String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- if (log.isDebugEnabled()) {
- log.debug("Exception caught on session: {} id: {}", session.getId(), sessionId, cause);
- cause.printStackTrace();
- }
- if (cause instanceof IOException) {
- // Mina states that the connection will be automatically closed when an IOException is caught
- log.debug("IOException caught on {}", sessionId);
- } else {
- log.debug("Non-IOException caught on {}", sessionId);
- forceClose(session);
- }
- }
-
- /**
- * Force the NioSession to be released and cleaned up.
- *
- * @param session
- */
- private void forceClose(final IoSession session) {
- log.warn("Force close - session: {}", session.getId());
- if (session.containsAttribute("FORCED_CLOSE")) {
- log.info("Close already forced on this session: {}", session.getId());
- } else {
- // set flag
- session.setAttribute("FORCED_CLOSE", Boolean.TRUE);
- // clean up
- final String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- log.debug("Forcing close on session: {} id: {}", session.getId(), sessionId);
- log.debug("Session closing: {}", session.isClosing());
- session.suspendRead();
- final WriteRequestQueue writeQueue = session.getWriteRequestQueue();
- if (writeQueue != null && !writeQueue.isEmpty(session)) {
- log.debug("Clearing write queue");
- try {
- writeQueue.clear(session);
- } catch (Exception ex) {
- // clear seems to cause a write to closed session ex in some cases
- log.warn("Exception clearing write queue for {}", sessionId, ex);
- }
- }
- // force close the session
- final CloseFuture future = session.close(true);
- IoFutureListener listener = new IoFutureListener() {
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void operationComplete(CloseFuture future) {
- // now connection should be closed
- log.debug("Close operation completed {}: {}", sessionId, future.isClosed());
- future.removeListener(this);
- for (Object key : session.getAttributeKeys()) {
- Object obj = session.getAttribute(key);
- log.debug("Attribute: {}", obj.getClass().getName());
- if (obj instanceof IoProcessor) {
- log.debug("Flushing session in processor");
- ((IoProcessor) obj).flush(session);
- log.debug("Removing session from processor");
- ((IoProcessor) obj).remove(session);
- } else if (obj instanceof IoBuffer) {
- log.debug("Clearing session buffer");
- ((IoBuffer) obj).clear();
- ((IoBuffer) obj).free();
- }
- }
- }
- };
- future.addListener(listener);
- }
- }
-
- /**
- * Setter for handler.
- *
- * @param handler RTMP events handler
- */
- public void setHandler(IRTMPHandler handler) {
- this.handler = handler;
- }
-
- /**
- * @param codecFactory the codecFactory to set
- */
- public void setCodecFactory(ProtocolCodecFactory codecFactory) {
- this.codecFactory = codecFactory;
- }
-
- protected RTMPMinaConnection createRTMPMinaConnection() {
- return (RTMPMinaConnection) RTMPConnManager.getInstance().createConnection(RTMPMinaConnection.class);
- }
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/RTMPType.java b/src/main/java/org/red5/server/net/rtmp/RTMPType.java
deleted file mode 100644
index bcde7e069..000000000
--- a/src/main/java/org/red5/server/net/rtmp/RTMPType.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-/**
- * Enum for RTMP types.
- *
- * @author Paul Gregoire (mondain@gmail.com)
- */
-public enum RTMPType {
-
- /**
- * The specification refers to the following types by different names:
- * 0x03 = Acknowledgement
- * 0x04 = User control message
- * 0x05 = Window Acknowledgement Size
- * 0x06 = Set Peer Bandwidth
- * 0x0f = AMF3 Data message
- * 0x10 = AMF3 Shared object message
- * 0x11 = AMF3 Command message
- * 0x12 = AMF0 Data message
- * 0x13 = AMF0 Shared object message
- * 0x14 = AMF0 Command message
- *
- * -------------------------------------------------------------------
- * RTMFP related (here for reference)
- *
- * 0x30 Initiator hello
- * 0x70 Responder hello
- * 0x38 Initiator initial keying
- * 0x78 Responder initial keying
- * 0x0f Forwarded initiator hello
- * 0x71 Forwarded hello response
- * 0x10 Normal user data
- * 0x11 Next user data
- * 0x0c Session failed on client side
- * 0x4c Session died
- * 0x01 Causes response with 0x41, reset keep alive
- * 0x41 Reset times keep alive
- * 0x5e Negative ack
- * 0x51 Some ack
- */
- TYPE_CHUNK_SIZE(0x01), TYPE_ABORT(0x02), TYPE_BYTES_READ(0x03), TYPE_PING(0x04), TYPE_SERVER_BANDWIDTH(0x05), TYPE_CLIENT_BANDWIDTH(0x06), TYPE_EDGE_ORIGIN(
- 0x07), TYPE_AUDIO_DATA(0x08), TYPE_VIDEO_DATA(0x09), TYPE_UNK1(0x0a), TYPE_UNK2(0x0b), TYPE_UNK3(0x0c), TYPE_UNK4(0x0d), TYPE_UNK5(0x0e), TYPE_FLEX_STREAM_SEND(0x0f), TYPE_FLEX_SHARED_OBJECT(
- 0x10), TYPE_FLEX_MESSAGE(0x11), TYPE_NOTIFY(0x12), TYPE_SHARED_OBJECT(0x13), TYPE_INVOKE(0x14), TYPE_UNK6(0x15), TYPE_AGGREGATE(0x16), TYPE_UNK7(0x17), TYPE_UNK8(0x18);
-
- private final byte type;
-
- RTMPType(byte type) {
- this.type = type;
- }
-
- RTMPType(int type) {
- this.type = (byte) type;
- }
-
- public byte getType() {
- return type;
- }
-
- public static String valueOf(byte dataType) {
- int idx = (int) dataType - 1;
- if (idx < RTMPType.values().length) {
- return RTMPType.values()[idx].name();
- } else {
- return "TYPE_UNKNOWN:" + dataType;
- }
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/RTMPUtils.java b/src/main/java/org/red5/server/net/rtmp/RTMPUtils.java
deleted file mode 100644
index 47481462a..000000000
--- a/src/main/java/org/red5/server/net/rtmp/RTMPUtils.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.server.net.rtmp.message.Constants;
-
-/**
- * RTMP utilities class.
- *
- * @author The Red5 Project
- * @author Luke Hubbard, Codegent Ltd (luke@codegent.com)
- * @author Art Clarke (aclarke@xuggle.com)
- */
-public class RTMPUtils implements Constants {
- /**
- * Writes reversed integer to buffer.
- *
- * @param out Buffer
- * @param value Integer to write
- */
- public static void writeReverseIntOld(IoBuffer out, int value) {
- byte[] bytes = new byte[4];
- IoBuffer rev = IoBuffer.allocate(4);
- rev.putInt(value);
- rev.flip();
- bytes[3] = rev.get();
- bytes[2] = rev.get();
- bytes[1] = rev.get();
- bytes[0] = rev.get();
- out.put(bytes);
- rev.free();
- rev = null;
- }
-
- /**
- * Writes reversed integer to buffer.
- *
- * @param out Buffer
- * @param value Integer to write
- */
- public static void writeReverseInt(IoBuffer out, int value) {
- out.put((byte) (0xFF & value));
- out.put((byte) (0xFF & (value >> 8)));
- out.put((byte) (0xFF & (value >> 16)));
- out.put((byte) (0xFF & (value >> 24)));
- }
-
- /**
- *
- * @param out output buffer
- * @param value value to write
- */
- public static void writeMediumInt(IoBuffer out, int value) {
- out.put((byte) (0xFF & (value >> 16)));
- out.put((byte) (0xFF & (value >> 8)));
- out.put((byte) (0xFF & (value >> 0)));
- }
-
- /**
- *
- * @param in input
- * @return unsigned int
- */
- public static int readUnsignedMediumInt(IoBuffer in) {
- final byte a = in.get();
- final byte b = in.get();
- final byte c = in.get();
- int val = 0;
- val += (a & 0xff) << 16;
- val += (b & 0xff) << 8;
- val += (c & 0xff);
- return val;
- }
-
- /**
- *
- * @param in input
- * @return unsigned medium (3 byte) int.
- */
- public static int readUnsignedMediumIntOld(IoBuffer in) {
- byte[] bytes = new byte[3];
- in.get(bytes);
- int val = 0;
- val += (bytes[0] & 0xFF) * 256 * 256;
- val += (bytes[1] & 0xFF) * 256;
- val += (bytes[2] & 0xFF);
- return val;
- }
-
- /**
- *
- * @param in input
- * @return signed 3-byte int
- */
- public static int readMediumIntOld(IoBuffer in) {
- IoBuffer buf = IoBuffer.allocate(4);
- buf.put((byte) 0x00);
- buf.put(in.get());
- buf.put(in.get());
- buf.put(in.get());
- buf.flip();
- int value = buf.getInt();
- buf.free();
- buf = null;
- return value;
- }
-
- /**
- *
- * @param in input
- * @return signed 3 byte int
- */
- public static int readMediumInt(IoBuffer in) {
- final byte a = in.get();
- final byte b = in.get();
- final byte c = in.get();
- // Fix unsigned values
- int val = 0;
- val += (a & 0xff) << 16;
- val += (b & 0xff) << 8;
- val += (c & 0xff);
- return val;
- }
-
- /**
- * Read integer in reversed order.
- *
- * @param in Input buffer
- * @return Integer
- */
- public static int readReverseInt(IoBuffer in) {
- final byte a = in.get();
- final byte b = in.get();
- final byte c = in.get();
- final byte d = in.get();
- int val = 0;
- val += (d & 0xff) << 24;
- val += (c & 0xff) << 16;
- val += (b & 0xff) << 8;
- val += (a & 0xff);
- return val;
- }
-
- /**
- * Encodes header size marker and channel id into header marker.
- * @param out output buffer
- *
- * @param headerSize Header size marker
- * @param channelId Channel used
- */
- public static void encodeHeaderByte(IoBuffer out, byte headerSize, int channelId) {
- if (channelId <= 63) {
- out.put((byte) ((headerSize << 6) + channelId));
- } else if (channelId <= 320) {
- out.put((byte) (headerSize << 6));
- out.put((byte) (channelId - 64));
- } else {
- out.put((byte) ((headerSize << 6) | 1));
- channelId -= 64;
- out.put((byte) (channelId & 0xff));
- out.put((byte) (channelId >> 8));
- }
- }
-
- /**
- * Decode channel id.
- *
- * @param header Header
- * @param byteCount byte count
- * @return Channel id
- */
- public static int decodeChannelId(int header, int byteCount) {
- if (byteCount == 1) {
- return (header & 0x3f);
- } else if (byteCount == 2) {
- return 64 + (header & 0xff);
- } else {
- return 64 + ((header >> 8) & 0xff) + ((header & 0xff) << 8);
- }
- }
-
- /**
- * Decode header size.
- *
- * @param header Header byte
- * @param byteCount byte count
- * @return Header size byte
- */
- public static byte decodeHeaderSize(int header, int byteCount) {
- if (byteCount == 1) {
- return (byte) (header >> 6);
- } else if (byteCount == 2) {
- return (byte) (header >> 14);
- } else {
- return (byte) (header >> 22);
- }
- }
-
- /**
- * Return header length from marker value.
- *
- * @param headerSize Header size marker value
- * @return Header length
- */
- public static int getHeaderLength(byte headerSize) {
- switch (headerSize) {
- case HEADER_NEW:
- return 12;
- case HEADER_SAME_SOURCE:
- return 8;
- case HEADER_TIMER_CHANGE:
- return 4;
- case HEADER_CONTINUE:
- return 1;
- default:
- return -1;
- }
- }
-
- /**
- * Compares two RTMP time stamps, accounting for time stamp wrapping.
- *
- * @param a First time stamp
- * @param b Second time stamp
- * @return -1 if a < b, 1 if a > b, or 0 if a == b
- */
- public static int compareTimestamps(final int a, final int b) {
- long diff = diffTimestamps(a, b);
- return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
- }
-
- /**
- * Calculates the delta between two time stamps, adjusting
- * for time stamp wrapping.
- *
- * @param a First time stamp
- * @param b Second time stamp
- * @return the distance between a and b, which will be negative if a is less than b.
- */
- public static long diffTimestamps(final int a, final int b) {
- // first convert each to unsigned integers
- final long unsignedA = a & 0xFFFFFFFFL;
- final long unsignedB = b & 0xFFFFFFFFL;
- // then find the delta
- final long delta = unsignedA-unsignedB;
- return delta;
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/ReceivedMessageTask.java b/src/main/java/org/red5/server/net/rtmp/ReceivedMessageTask.java
deleted file mode 100644
index ae5d5b20f..000000000
--- a/src/main/java/org/red5/server/net/rtmp/ReceivedMessageTask.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.red5.server.net.rtmp;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.red5.server.api.Red5;
-import org.red5.server.net.rtmp.message.Packet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class ReceivedMessageTask implements Callable {
-
- private final static Logger log = LoggerFactory.getLogger(ReceivedMessageTask.class);
-
- private RTMPConnection conn;
-
- private final IRTMPHandler handler;
-
- private final String sessionId;
-
- private Packet message;
-
- // flag representing handling status
- private AtomicBoolean done = new AtomicBoolean(false);
-
- // deadlock guard instance
- private DeadlockGuard guard;
-
- // maximum time allowed to process received message
- private long maxHandlingTime = 500L;
-
- public ReceivedMessageTask(String sessionId, Packet message, IRTMPHandler handler) {
- this(sessionId, message, handler, (RTMPConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId));
- }
-
- public ReceivedMessageTask(String sessionId, Packet message, IRTMPHandler handler, RTMPConnection conn) {
- this.sessionId = sessionId;
- this.message = message;
- this.handler = handler;
- this.conn = conn;
- }
-
- public Boolean call() throws Exception {
- // set connection to thread local
- Red5.setConnectionLocal(conn);
- try {
- // // don't run the deadlock guard if timeout is <= 0
- if (maxHandlingTime <= 0) {
- // don't run the deadlock guard if we're in debug mode
- if (!Red5.isDebug()) {
- // run a deadlock guard so hanging tasks will be interrupted
- guard = new DeadlockGuard();
- new Thread(guard, String.format("DeadlockGuard#%s", sessionId)).start();
- }
- }
- // pass message to the handler
- handler.messageReceived(conn, message);
- } catch (Exception e) {
- log.error("Error processing received message {} on {}", message, sessionId, e);
- } finally {
- //log.info("[{}] run end", sessionId);
- // clear thread local
- Red5.setConnectionLocal(null);
- // set done / completed flag
- done.set(true);
- if (guard != null) {
- // calls internal to the deadlock guard to join its thread from this executor task thread
- guard.join();
- }
- }
- return Boolean.valueOf(done.get());
- }
-
- /**
- * Sets maximum handling time for an incoming message.
- *
- * @param maxHandlingTimeout
- */
- public void setMaxHandlingTimeout(long maxHandlingTimeout) {
- this.maxHandlingTime = maxHandlingTimeout;
- }
-
- /**
- * Prevents deadlocked message handling.
- */
- private class DeadlockGuard implements Runnable {
-
- // executor task thread
- private Thread taskThread;
-
- // deadlock guard thread
- private Thread guardThread = null;
-
- AtomicBoolean sleeping = new AtomicBoolean(false);
-
- /**
- * Creates the deadlock guard to prevent a message task from taking too long to process.
- * @param thread
- */
- DeadlockGuard() {
- // executor thread ref
- this.taskThread = Thread.currentThread();
- }
-
- /**
- * Save the reference to the thread, and wait until the maxHandlingTimeout has elapsed.
- * If it elapsed, kill the other thread.
- * */
- public void run() {
- try {
- this.guardThread = Thread.currentThread();
- if (log.isDebugEnabled()) {
- log.debug("Threads - task: {} guard: {}", taskThread.getName(), guardThread.getName());
- }
- sleeping.compareAndSet(false, true);
- Thread.sleep(maxHandlingTime);
- } catch (InterruptedException e) {
- log.debug("Deadlock guard interrupted on {} during sleep", sessionId);
- } finally {
- sleeping.set(false);
- }
- // if the message task is not yet done interrupt
- if (!done.get()) {
- // if the task thread hasn't been interrupted check its live-ness
- if (!taskThread.isInterrupted()) {
- // if the task thread is alive, interrupt it
- if (taskThread.isAlive()) {
- log.warn("Interrupting unfinished active task on {}", sessionId);
- taskThread.interrupt();
- }
- } else {
- log.debug("Unfinished active task on {} already interrupted", sessionId);
- }
- }
- }
-
- /**
- * Joins the deadlock guard thread.
- * It's called when the task finish before the maxHandlingTimeout
- */
- public void join() {
- // interrupt deadlock guard if sleeping
- if (sleeping.get()) {
- guardThread.interrupt();
- }
- // Wait only a 1/4 of the max handling time
- // TDJ: Not really needed to wait guard die to release taskMessage processing
- //guardThread.join(maxHandlingTimeout / 4);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/red5/server/net/rtmp/codec/IEventDecoder.java b/src/main/java/org/red5/server/net/rtmp/codec/IEventDecoder.java
deleted file mode 100644
index d17affabd..000000000
--- a/src/main/java/org/red5/server/net/rtmp/codec/IEventDecoder.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp.codec;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.server.api.IConnection.Encoding;
-import org.red5.server.net.rtmp.event.Aggregate;
-import org.red5.server.net.rtmp.event.AudioData;
-import org.red5.server.net.rtmp.event.BytesRead;
-import org.red5.server.net.rtmp.event.ChunkSize;
-import org.red5.server.net.rtmp.event.FlexMessage;
-import org.red5.server.net.rtmp.event.Invoke;
-import org.red5.server.net.rtmp.event.Notify;
-import org.red5.server.net.rtmp.event.Ping;
-import org.red5.server.net.rtmp.event.Unknown;
-import org.red5.server.net.rtmp.event.VideoData;
-import org.red5.server.so.ISharedObjectMessage;
-
-/**
- * Event decoder decodes event objects from incoming byte buffer.
- */
-public interface IEventDecoder {
-
- /**
- * Decodes event of Unknown type.
- *
- * @param dataType Data type
- * @param in Byte buffer to decode
- * @return Unknown event
- */
- public abstract Unknown decodeUnknown(byte dataType, IoBuffer in);
-
- /**
- * Decodes chunk size event.
- *
- * @param in Byte buffer to decode
- * @return ChunkSize event
- */
- public abstract ChunkSize decodeChunkSize(IoBuffer in);
-
- /**
- * Decodes shared object message event.
- *
- * @param in Byte buffer to decode
- * @return ISharedObjectMessage event
- */
- public abstract ISharedObjectMessage decodeSharedObject(IoBuffer in);
-
- /**
- * Decodes shared object message event from AMF3 encoding.
- *
- * @param in Byte buffer to decode
- * @return ISharedObjectMessage event
- */
- public abstract ISharedObjectMessage decodeFlexSharedObject(IoBuffer in);
-
- /**
- * Decode a Notify.
- *
- * @param encoding
- * @param in
- * @return decoded notify result
- */
- public abstract Notify decodeNotify(Encoding encoding, IoBuffer in);
-
- /**
- * Decodes invocation event.
- *
- * @param encoding
- * @param in Byte buffer to decode
- * @return Invoke event
- */
- public abstract Invoke decodeInvoke(Encoding encoding, IoBuffer in);
-
- /**
- * Decodes ping event.
- *
- * @param in Byte buffer to decode
- * @return Ping event
- */
- public abstract Ping decodePing(IoBuffer in);
-
- /**
- * Decodes BytesRead event.
- *
- * @param in Byte buffer to decode
- * @return BytesRead event
- */
- public abstract BytesRead decodeBytesRead(IoBuffer in);
-
- /**
- * Decodes the aggregated data.
- *
- * @param in Byte buffer to decode
- * @return Aggregate event
- */
- public abstract Aggregate decodeAggregate(IoBuffer in);
-
- /**
- * Decodes audio data event.
- *
- * @param in Byte buffer to decode
- * @return AudioData event
- */
- public abstract AudioData decodeAudioData(IoBuffer in);
-
- /**
- * Decodes video data event.
- *
- * @param in Byte buffer to decode
- * @return VideoData event
- */
- public abstract VideoData decodeVideoData(IoBuffer in);
-
- /**
- * Decodes Flex message event.
- *
- * @param in Byte buffer to decode
- * @return FlexMessage event
- */
- public abstract FlexMessage decodeFlexMessage(IoBuffer in);
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/codec/IEventEncoder.java b/src/main/java/org/red5/server/net/rtmp/codec/IEventEncoder.java
deleted file mode 100644
index dcc8d654c..000000000
--- a/src/main/java/org/red5/server/net/rtmp/codec/IEventEncoder.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp.codec;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.server.net.rtmp.event.Aggregate;
-import org.red5.server.net.rtmp.event.AudioData;
-import org.red5.server.net.rtmp.event.BytesRead;
-import org.red5.server.net.rtmp.event.ChunkSize;
-import org.red5.server.net.rtmp.event.Invoke;
-import org.red5.server.net.rtmp.event.Notify;
-import org.red5.server.net.rtmp.event.Ping;
-import org.red5.server.net.rtmp.event.Unknown;
-import org.red5.server.net.rtmp.event.VideoData;
-import org.red5.server.so.ISharedObjectMessage;
-
-/**
- * Encodes events to byte buffer.
- */
-public interface IEventEncoder {
- /**
- * Encodes Notify event to byte buffer.
- *
- * @param notify Notify event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeNotify(Notify notify);
-
- /**
- * Encodes Invoke event to byte buffer.
- *
- * @param invoke Invoke event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeInvoke(Invoke invoke);
-
- /**
- * Encodes Ping event to byte buffer.
- *
- * @param ping Ping event
- * @return Byte buffer
- */
- public abstract IoBuffer encodePing(Ping ping);
-
- /**
- * Encodes BytesRead event to byte buffer.
- *
- * @param streamBytesRead BytesRead event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeBytesRead(BytesRead streamBytesRead);
-
- /**
- * Encodes Aggregate event to byte buffer.
- *
- * @param aggregate Aggregate event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeAggregate(Aggregate aggregate);
-
- /**
- * Encodes AudioData event to byte buffer.
- *
- * @param audioData AudioData event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeAudioData(AudioData audioData);
-
- /**
- * Encodes VideoData event to byte buffer.
- *
- * @param videoData VideoData event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeVideoData(VideoData videoData);
-
- /**
- * Encodes Unknown event to byte buffer.
- *
- * @param unknown Unknown event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeUnknown(Unknown unknown);
-
- /**
- * Encodes ChunkSize event to byte buffer.
- *
- * @param chunkSize ChunkSize event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeChunkSize(ChunkSize chunkSize);
-
- /**
- * Encodes SharedObjectMessage event to byte buffer.
- *
- * @param so ISharedObjectMessage event
- * @return Byte buffer
- */
- public abstract IoBuffer encodeSharedObject(ISharedObjectMessage so);
-
- /**
- * Encodes SharedObjectMessage event to byte buffer using AMF3 encoding.
- *
- * @param so ISharedObjectMessage event
- * @return Byte buffer
- */
- public IoBuffer encodeFlexSharedObject(ISharedObjectMessage so);
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/codec/RTMP.java b/src/main/java/org/red5/server/net/rtmp/codec/RTMP.java
deleted file mode 100644
index 266ec76ff..000000000
--- a/src/main/java/org/red5/server/net/rtmp/codec/RTMP.java
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp.codec;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.red5.server.api.IConnection.Encoding;
-import org.red5.server.net.rtmp.message.Header;
-import org.red5.server.net.rtmp.message.Packet;
-
-/**
- * RTMP is the RTMP protocol state representation.
- */
-public class RTMP {
-
- public String[] states = { "connect", "handshake", "connected", "error", "disconnecting", "disconnected" };
-
- /**
- * Connect state
- */
- public static final byte STATE_CONNECT = 0x00;
-
- /**
- * Handshake state. Server sends handshake request to client right after connection established.
- */
- public static final byte STATE_HANDSHAKE = 0x01;
-
- /**
- * Connected
- */
- public static final byte STATE_CONNECTED = 0x02;
-
- /**
- * Error
- */
- public static final byte STATE_ERROR = 0x03;
-
- /**
- * In the processing of disconnecting
- */
- public static final byte STATE_DISCONNECTING = 0x04;
-
- /**
- * Disconnected
- */
- public static final byte STATE_DISCONNECTED = 0x05;
-
- /**
- * Sent the connect message to origin.
- */
- public static final byte STATE_EDGE_CONNECT_ORIGIN_SENT = 0x11;
-
- /**
- * Forwarded client's connect call to origin.
- */
- public static final byte STATE_ORIGIN_CONNECT_FORWARDED = 0x12;
-
- /**
- * Edge is disconnecting, waiting Origin close connection.
- */
- public static final byte STATE_EDGE_DISCONNECTING = 0x13;
-
- /**
- * RTMP state.
- */
- private volatile byte state = STATE_CONNECT;
-
- /**
- * Encryption flag.
- */
- private boolean encrypted = false;
-
- /**
- * Map for channels, keyed by channel id.
- */
- private final ConcurrentMap channels = new ConcurrentHashMap(3, 0.9f, 1);
-
- /**
- * Read chunk size. Packets are read and written chunk-by-chunk.
- */
- private int readChunkSize = 128;
-
- /**
- * Write chunk size. Packets are read and written chunk-by-chunk.
- */
- private int writeChunkSize = 128;
-
- /**
- * Encoding type for objects.
- */
- private Encoding encoding = Encoding.AMF0;
-
- /**
- * Creates RTMP object; essentially for storing session information.
- */
- public RTMP() {
- }
-
- /**
- * Returns channel information for a given channel id.
- *
- * @param channelId
- * @return channel info
- */
- private ChannelInfo getChannelInfo(int channelId) {
- ChannelInfo info = channels.putIfAbsent(channelId, new ChannelInfo());
- if (info == null) {
- info = channels.get(channelId);
- }
- return info;
- }
-
- /**
- * @return the encrypted
- */
- public boolean isEncrypted() {
- return encrypted;
- }
-
- /**
- * @param encrypted the encrypted to set
- */
- public void setEncrypted(boolean encrypted) {
- this.encrypted = encrypted;
- }
-
- /**
- * Return current state.
- *
- * @return State
- */
- public byte getState() {
- return state;
- }
-
- /**
- * Releases a packet.
- *
- * @param packet Packet to release
- */
- private void freePacket(Packet packet) {
- if (packet != null && packet.getData() != null) {
- packet.clearData();
- }
- }
-
- /**
- * Releases the channels.
- */
- private void freeChannels() {
- for (ChannelInfo info : channels.values()) {
- freePacket(info.getReadPacket());
- freePacket(info.getWritePacket());
- }
- channels.clear();
- }
-
- /**
- * Setter for state.
- *
- * @param state New state
- */
- public void setState(byte state) {
- this.state = state;
- if (state == STATE_DISCONNECTED) {
- freeChannels();
- }
- }
-
- /**
- * Setter for last read header.
- *
- * @param channelId Channel id
- * @param header Header
- */
- public void setLastReadHeader(int channelId, Header header) {
- getChannelInfo(channelId).setReadHeader(header);
- }
-
- /**
- * Return last read header for channel.
- *
- * @param channelId Channel id
- * @return Last read header
- */
- public Header getLastReadHeader(int channelId) {
- return getChannelInfo(channelId).getReadHeader();
- }
-
- /**
- * Setter for last written header.
- *
- * @param channelId Channel id
- * @param header Header
- */
- public void setLastWriteHeader(int channelId, Header header) {
- getChannelInfo(channelId).setWriteHeader(header);
- }
-
- /**
- * Return last written header for channel.
- *
- * @param channelId Channel id
- * @return Last written header
- */
- public Header getLastWriteHeader(int channelId) {
- return getChannelInfo(channelId).getWriteHeader();
- }
-
- /**
- * Setter for last read packet.
- *
- * @param channelId Channel id
- * @param packet Packet
- */
- public void setLastReadPacket(int channelId, Packet packet) {
- final ChannelInfo info = getChannelInfo(channelId);
- // grab last packet
- Packet prevPacket = info.getReadPacket();
- // set new one
- info.setReadPacket(packet);
- // free the previous packet
- freePacket(prevPacket);
- }
-
- /**
- * Return last read packet for channel.
- *
- * @param channelId Channel id
- * @return Last read packet for that channel
- */
- public Packet getLastReadPacket(int channelId) {
- return getChannelInfo(channelId).getReadPacket();
- }
-
- /**
- * Setter for last written packet.
- *
- * @param channelId Channel id
- * @param packet Last written packet
- */
- public void setLastWritePacket(int channelId, Packet packet) {
- // Disabled to help GC because we currently don't use the write packets
- /*
- Packet prevPacket = writePackets.put(channelId, packet);
- if (prevPacket != null && prevPacket.getData() != null) {
- prevPacket.getData().release();
- prevPacket.setData(null);
- }
- */
- }
-
- /**
- * Return packet that has been written last.
- *
- * @param channelId Channel id
- * @return Packet that has been written last
- */
- public Packet getLastWritePacket(int channelId) {
- return getChannelInfo(channelId).getWritePacket();
- }
-
- /**
- * Getter for write chunk size. Data is being read chunk-by-chunk.
- *
- * @return Read chunk size
- */
- public int getReadChunkSize() {
- return readChunkSize;
- }
-
- /**
- * Setter for read chunk size. Data is being read chunk-by-chunk.
- *
- * @param readChunkSize Value to set for property 'readChunkSize'.
- */
- public void setReadChunkSize(int readChunkSize) {
- this.readChunkSize = readChunkSize;
- }
-
- /**
- * Getter for write chunk size. Data is being written chunk-by-chunk.
- *
- * @return Write chunk size
- */
- public int getWriteChunkSize() {
- return writeChunkSize;
- }
-
- /**
- * Setter for write chunk size.
- *
- * @param writeChunkSize Write chunk size
- */
- public void setWriteChunkSize(int writeChunkSize) {
- this.writeChunkSize = writeChunkSize;
- }
-
- /**
- * Getter for encoding version.
- *
- * @return Encoding version
- */
- public Encoding getEncoding() {
- return encoding;
- }
-
- /**
- * Setter for encoding version.
- *
- * @param encoding Encoding version
- */
- public void setEncoding(Encoding encoding) {
- this.encoding = encoding;
- }
-
- public void setLastFullTimestampWritten(int channelId, int timer) {
- getChannelInfo(channelId).setWriteTimestamp(timer);
- }
-
- public int getLastFullTimestampWritten(int channelId) {
- return getChannelInfo(channelId).getWriteTimestamp();
- }
-
- public void setLastReadPacketHeader(int channelId, Header header) {
- getChannelInfo(channelId).setReadPacketHeader(header);
- }
-
- public Header getLastReadPacketHeader(int channelId) {
- return getChannelInfo(channelId).getReadPacketHeader();
- }
-
- LiveTimestampMapping getLastTimestampMapping(int channelId) {
- return getChannelInfo(channelId).getLiveTimestamp();
- }
-
- void setLastTimestampMapping(int channelId, LiveTimestampMapping mapping) {
- getChannelInfo(channelId).setLiveTimestamp(mapping);
- }
-
- void clearLastTimestampMapping(int... channelIds) {
- for (int channelId : channelIds) {
- getChannelInfo(channelId).setLiveTimestamp(null);
- }
- }
-
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "RTMP [state=" + states[state] + ", encrypted=" + encrypted + ", readChunkSize=" + readChunkSize + ", writeChunkSize=" + writeChunkSize + ", encoding=" + encoding
- + "]";
- }
-
- /**
- * Class for mapping between clock time and stream time for live streams
- */
- final class LiveTimestampMapping {
-
- private final long clockStartTime;
-
- private final long streamStartTime;
-
- private boolean keyFrameNeeded;
-
- private long lastStreamTime;
-
- public LiveTimestampMapping(long clockStartTime, long streamStartTime) {
- this.clockStartTime = clockStartTime;
- this.streamStartTime = streamStartTime;
- this.keyFrameNeeded = true; // Always start with a key frame
- this.lastStreamTime = streamStartTime;
- }
-
- public long getStreamStartTime() {
- return streamStartTime;
- }
-
- public long getClockStartTime() {
- return clockStartTime;
- }
-
- public void setKeyFrameNeeded(boolean keyFrameNeeded) {
- this.keyFrameNeeded = keyFrameNeeded;
- }
-
- public boolean isKeyFrameNeeded() {
- return keyFrameNeeded;
- }
-
- public long getLastStreamTime() {
- return lastStreamTime;
- }
-
- public void setLastStreamTime(long lastStreamTime) {
- this.lastStreamTime = lastStreamTime;
- }
- }
-
- /**
- * Channel details
- */
- private final class ChannelInfo {
- // read header
- private Header readHeader;
-
- // write header
- private Header writeHeader;
-
- // packet header
- private Header readPacketHeader;
-
- // read packet
- private Packet readPacket;
-
- // written packet
- private Packet writePacket;
-
- // written timestamp
- private int writeTimestamp;
-
- // used for live streams
- private LiveTimestampMapping liveTimestamp;
-
- /**
- * @return the readHeader
- */
- public Header getReadHeader() {
- return readHeader;
- }
-
- /**
- * @param readHeader the readHeader to set
- */
- public void setReadHeader(Header readHeader) {
- this.readHeader = readHeader;
- }
-
- /**
- * @return the writeHeader
- */
- public Header getWriteHeader() {
- return writeHeader;
- }
-
- /**
- * @param writeHeader the writeHeader to set
- */
- public void setWriteHeader(Header writeHeader) {
- this.writeHeader = writeHeader;
- }
-
- /**
- * @return the readPacketHeader
- */
- public Header getReadPacketHeader() {
- return readPacketHeader;
- }
-
- /**
- * @param readPacketHeader the readPacketHeader to set
- */
- public void setReadPacketHeader(Header readPacketHeader) {
- this.readPacketHeader = readPacketHeader;
- }
-
- /**
- * @return the readPacket
- */
- public Packet getReadPacket() {
- return readPacket;
- }
-
- /**
- * @param readPacket the readPacket to set
- */
- public void setReadPacket(Packet readPacket) {
- this.readPacket = readPacket;
- }
-
- /**
- * @return the writePacket
- */
- public Packet getWritePacket() {
- return writePacket;
- }
-
- /**
- * @param writePacket the writePacket to set
- */
- @SuppressWarnings("unused")
- public void setWritePacket(Packet writePacket) {
- this.writePacket = writePacket;
- }
-
- /**
- * @return the writeTimestamp
- */
- public int getWriteTimestamp() {
- return writeTimestamp;
- }
-
- /**
- * @param writeTimestamp the writeTimestamp to set
- */
- public void setWriteTimestamp(int writeTimestamp) {
- this.writeTimestamp = writeTimestamp;
- }
-
- /**
- * @return the liveTimestamp
- */
- public LiveTimestampMapping getLiveTimestamp() {
- return liveTimestamp;
- }
-
- /**
- * @param liveTimestamp the liveTimestamp to set
- */
- public void setLiveTimestamp(LiveTimestampMapping liveTimestamp) {
- this.liveTimestamp = liveTimestamp;
- }
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/codec/RTMPCodecFactory.java b/src/main/java/org/red5/server/net/rtmp/codec/RTMPCodecFactory.java
deleted file mode 100644
index 5165c9ad5..000000000
--- a/src/main/java/org/red5/server/net/rtmp/codec/RTMPCodecFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp.codec;
-
-import org.apache.mina.core.session.IoSession;
-import org.apache.mina.filter.codec.ProtocolCodecFactory;
-import org.apache.mina.filter.codec.ProtocolDecoder;
-import org.apache.mina.filter.codec.ProtocolEncoder;
-
-/**
- * RTMP codec factory creates RTMP encoders/decoders.
- */
-public class RTMPCodecFactory implements ProtocolCodecFactory {
-
- /**
- * Mina protocol decoder for RTMP.
- */
- private RTMPMinaProtocolDecoder decoder;
-
- /**
- * Mina protocol encoder for RTMP.
- */
- private RTMPMinaProtocolEncoder encoder;
-
- /**
- * Initialization
- */
- public void init() {
- decoder = new RTMPMinaProtocolDecoder();
- encoder = new RTMPMinaProtocolEncoder();
- }
-
- /** {@inheritDoc} */
- public ProtocolDecoder getDecoder(IoSession session) {
- return decoder;
- }
-
- /** {@inheritDoc} */
- public ProtocolEncoder getEncoder(IoSession session) {
- return encoder;
- }
-
- /**
- * Returns the RTMP decoder.
- *
- * @return decoder
- */
- public RTMPProtocolDecoder getRTMPDecoder() {
- return decoder.getDecoder();
- }
-
- /**
- * Returns the RTMP encoder.
- *
- * @return encoder
- */
- public RTMPProtocolEncoder getRTMPEncoder() {
- return encoder.getEncoder();
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaProtocolDecoder.java b/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaProtocolDecoder.java
deleted file mode 100644
index e0da0e1cb..000000000
--- a/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaProtocolDecoder.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp.codec;
-
-import java.util.List;
-import java.util.concurrent.Semaphore;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.apache.mina.core.session.IoSession;
-import org.apache.mina.filter.codec.ProtocolCodecException;
-import org.apache.mina.filter.codec.ProtocolDecoderAdapter;
-import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-import org.red5.server.api.Red5;
-import org.red5.server.net.rtmp.RTMPConnManager;
-import org.red5.server.net.rtmp.RTMPConnection;
-import org.red5.server.net.rtmp.message.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * RTMP protocol decoder.
- */
-public class RTMPMinaProtocolDecoder extends ProtocolDecoderAdapter {
-
- protected static Logger log = LoggerFactory.getLogger(RTMPMinaProtocolDecoder.class);
-
- private RTMPProtocolDecoder decoder = new RTMPProtocolDecoder();
-
- /** {@inheritDoc} */
- public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws ProtocolCodecException {
- // create a buffer and store it on the session
- IoBuffer buf = (IoBuffer) session.getAttribute("buffer");
- if (buf == null) {
- buf = IoBuffer.allocate(Constants.HANDSHAKE_SIZE);
- buf.setAutoExpand(true);
- session.setAttribute("buffer", buf);
- }
- buf.put(in);
- buf.flip();
- // get the connection from the session
- String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- log.trace("Session id: {}", sessionId);
- // connection verification routine
- RTMPConnection conn = (RTMPConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);
- RTMPConnection connLocal = (RTMPConnection) Red5.getConnectionLocal();
- if (connLocal == null || !conn.getSessionId().equals(connLocal.getSessionId())) {
- if (log.isDebugEnabled() && connLocal != null) {
- log.debug("Connection local didn't match session");
- }
- }
- // set the connection to local if its referred to by this session
- Red5.setConnectionLocal(conn);
- // get the connections decoder lock
- final Semaphore lock = conn.getDecoderLock();
- try {
- // acquire the decoder lock
- log.trace("Decoder lock acquiring.. {}", conn.getSessionId());
- lock.acquire();
- log.trace("Decoder lock acquired {}", conn.getSessionId());
- // construct any objects from the decoded bugger
- List> objects = decoder.decodeBuffer(conn, buf);
- if (objects != null) {
- for (Object object : objects) {
- out.write(object);
- }
- }
- } catch (Exception e) {
- log.error("Error during decode", e);
- } finally {
- log.trace("Decoder lock releasing.. {}", conn.getSessionId());
- lock.release();
- // clear local
- Red5.setConnectionLocal(null);
- }
- }
-
- /**
- * Sets the RTMP protocol decoder.
- *
- * @param decoder
- */
- public void setDecoder(RTMPProtocolDecoder decoder) {
- this.decoder = decoder;
- }
-
- /**
- * Returns an RTMP decoder
- * @return RTMP decoder
- */
- public RTMPProtocolDecoder getDecoder() {
- return decoder;
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaProtocolEncoder.java b/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaProtocolEncoder.java
deleted file mode 100644
index ca94d8dd6..000000000
--- a/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaProtocolEncoder.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp.codec;
-
-import java.util.LinkedList;
-import java.util.concurrent.Semaphore;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.apache.mina.core.session.IoSession;
-import org.apache.mina.filter.codec.ProtocolCodecException;
-import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
-import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-import org.red5.server.api.Red5;
-import org.red5.server.net.rtmp.RTMPConnManager;
-import org.red5.server.net.rtmp.RTMPConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Mina protocol encoder for RTMP.
- */
-public class RTMPMinaProtocolEncoder extends ProtocolEncoderAdapter {
-
- protected static Logger log = LoggerFactory.getLogger(RTMPMinaProtocolEncoder.class);
-
- private RTMPProtocolEncoder encoder = new RTMPProtocolEncoder();
-
- private int targetChunkSize = 2048;
-
- /** {@inheritDoc} */
- public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws ProtocolCodecException {
- // get the connection from the session
- String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
- log.trace("Session id: {}", sessionId);
- RTMPConnection conn = (RTMPConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);
- if (conn != null) {
- // look for and compare the connection local; set it from the session
- if (!conn.equals((RTMPConnection) Red5.getConnectionLocal())) {
- log.debug("Connection local ({}) didn't match io session ({})", (Red5.getConnectionLocal() != null ? Red5.getConnectionLocal().getSessionId() : "null"), sessionId);
- Red5.setConnectionLocal(conn);
- }
- final Semaphore lock = conn.getEncoderLock();
- try {
- // acquire the decoder lock
- log.trace("Encoder lock acquiring.. {}", conn.getSessionId());
- lock.acquire();
- log.trace("Encoder lock acquired {}", conn.getSessionId());
- // get the buffer
- final IoBuffer buf = message instanceof IoBuffer ? (IoBuffer) message : encoder.encode(message);
- if (buf != null) {
- int requestedWriteChunkSize = conn.getState().getWriteChunkSize();
- log.trace("Requested chunk size: {} target chunk size: {}", requestedWriteChunkSize, targetChunkSize);
- if (buf.remaining() <= targetChunkSize * 2) {
- log.trace("Writing output data");
- out.write(buf);
- } else {
- /*
- LinkedList chunks = Chunker.chunk(buf, requestedWriteChunkSize, targetChunkSize);
- log.trace("Writing output data in {} chunks", chunks.size());
- for (IoBuffer chunk : chunks) {
- out.write(chunk);
- }
- chunks.clear();
- chunks = null;
- */
- int sentChunks = Chunker.chunkAndWrite(out, buf, requestedWriteChunkSize, targetChunkSize);
- log.trace("Wrote {} chunks", sentChunks);
- }
- } else {
- log.trace("Response buffer was null after encoding");
- }
- // WriteFuture future = out.flush();
- // if (future != null) {
- // future.addListener(new IoFutureListener() {
- // @Override
- // public void operationComplete(WriteFuture future) {
- // //log.debug("Buffer freed");
- // buf.free();
- // }
- // });
- // }
- } catch (Exception ex) {
- log.error("Exception during encode", ex);
- } finally {
- log.trace("Encoder lock releasing.. {}", conn.getSessionId());
- lock.release();
- }
- } else {
- log.debug("Connection is no longer available for encoding, may have been closed already");
- }
- }
-
- /**
- * Sets an RTMP protocol encoder
- * @param encoder the RTMP encoder
- */
- public void setEncoder(RTMPProtocolEncoder encoder) {
- this.encoder = encoder;
- }
-
- /**
- * Returns an RTMP encoder
- * @return RTMP encoder
- */
- public RTMPProtocolEncoder getEncoder() {
- return encoder;
- }
-
- /**
- * Setter for baseTolerance
- * */
- public void setBaseTolerance(long baseTolerance) {
- encoder.setBaseTolerance(baseTolerance);
- }
-
- /**
- * Setter for dropLiveFuture
- * */
- public void setDropLiveFuture(boolean dropLiveFuture) {
- encoder.setDropLiveFuture(dropLiveFuture);
- }
-
- /**
- * @return the targetChunkSize
- */
- public int getTargetChunkSize() {
- return targetChunkSize;
- }
-
- /**
- * @param targetChunkSize the targetChunkSize to set
- */
- public void setTargetChunkSize(int targetChunkSize) {
- this.targetChunkSize = targetChunkSize;
- }
-
- /**
- * Output data chunker.
- */
- private static final class Chunker {
-
- @SuppressWarnings("unused")
- public static LinkedList chunk(IoBuffer message, int chunkSize, int desiredSize) {
- LinkedList chunks = new LinkedList();
- int targetSize = desiredSize > chunkSize ? desiredSize : chunkSize;
- int limit = message.limit();
- do {
- int length = 0;
- int pos = message.position();
- while (length < targetSize && pos < limit) {
- byte basicHeader = message.get(pos);
- length += getDataSize(basicHeader) + chunkSize;
- pos += length;
- }
- int remaining = message.remaining();
- log.trace("Length: {} remaining: {} pos+len: {} limit: {}", new Object[] { length, remaining, (message.position() + length), limit });
- if (length > remaining) {
- length = remaining;
- }
- // add a chunk
- chunks.add(message.getSlice(length));
- } while (message.hasRemaining());
- return chunks;
- }
-
- public static int chunkAndWrite(ProtocolEncoderOutput out, IoBuffer message, int chunkSize, int desiredSize) {
- int sentChunks = 0;
- int targetSize = desiredSize > chunkSize ? desiredSize : chunkSize;
- int limit = message.limit();
- do {
- int length = 0;
- int pos = message.position();
- while (length < targetSize && pos < limit) {
- byte basicHeader = message.get(pos);
- length += getDataSize(basicHeader) + chunkSize;
- pos += length;
- }
- int remaining = message.remaining();
- log.trace("Length: {} remaining: {} pos+len: {} limit: {}", new Object[] { length, remaining, (message.position() + length), limit });
- if (length > remaining) {
- length = remaining;
- }
- // send it
- out.write(message.getSlice(length));
- sentChunks++;
- } while (message.hasRemaining());
- return sentChunks;
- }
-
- private static int getDataSize(byte basicHeader) {
- final int streamId = basicHeader & 0x0000003F;
- final int headerType = (basicHeader >> 6) & 0x00000003;
- int size = 0;
- switch (headerType) {
- case 0:
- size = 12;
- break;
- case 1:
- size = 8;
- break;
- case 2:
- size = 4;
- break;
- default:
- size = 1;
- break;
- }
- if (streamId == 0) {
- size += 1;
- } else if (streamId == 1) {
- size += 2;
- }
- return size;
- }
- }
-
-}
diff --git a/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java b/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java
deleted file mode 100644
index 54c1b2569..000000000
--- a/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java
+++ /dev/null
@@ -1,1173 +0,0 @@
-/*
- * RED5 Open Source Flash Server - http://code.google.com/p/red5/
- *
- * Copyright 2006-2014 by respective authors (see below). All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.red5.server.net.rtmp.codec;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.io.amf.AMF;
-import org.red5.io.amf.Output;
-import org.red5.io.amf3.AMF3;
-import org.red5.io.object.DataTypes;
-import org.red5.io.object.Deserializer;
-import org.red5.io.object.Input;
-import org.red5.io.object.StreamAction;
-import org.red5.io.utils.BufferUtils;
-import org.red5.server.api.IConnection.Encoding;
-import org.red5.server.api.Red5;
-import org.red5.server.net.protocol.HandshakeFailedException;
-import org.red5.server.net.protocol.ProtocolException;
-import org.red5.server.net.protocol.RTMPDecodeState;
-import org.red5.server.net.rtmp.RTMPConnection;
-import org.red5.server.net.rtmp.RTMPUtils;
-import org.red5.server.net.rtmp.event.Abort;
-import org.red5.server.net.rtmp.event.Aggregate;
-import org.red5.server.net.rtmp.event.AudioData;
-import org.red5.server.net.rtmp.event.BytesRead;
-import org.red5.server.net.rtmp.event.ChunkSize;
-import org.red5.server.net.rtmp.event.ClientBW;
-import org.red5.server.net.rtmp.event.FlexMessage;
-import org.red5.server.net.rtmp.event.FlexStreamSend;
-import org.red5.server.net.rtmp.event.IRTMPEvent;
-import org.red5.server.net.rtmp.event.Invoke;
-import org.red5.server.net.rtmp.event.Notify;
-import org.red5.server.net.rtmp.event.Ping;
-import org.red5.server.net.rtmp.event.SWFResponse;
-import org.red5.server.net.rtmp.event.ServerBW;
-import org.red5.server.net.rtmp.event.SetBuffer;
-import org.red5.server.net.rtmp.event.Unknown;
-import org.red5.server.net.rtmp.event.VideoData;
-import org.red5.server.net.rtmp.message.Constants;
-import org.red5.server.net.rtmp.message.Header;
-import org.red5.server.net.rtmp.message.Packet;
-import org.red5.server.net.rtmp.message.SharedObjectTypeMapping;
-import org.red5.server.service.Call;
-import org.red5.server.service.PendingCall;
-import org.red5.server.so.FlexSharedObjectMessage;
-import org.red5.server.so.ISharedObjectEvent;
-import org.red5.server.so.ISharedObjectMessage;
-import org.red5.server.so.SharedObjectMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * RTMP protocol decoder.
- */
-public class RTMPProtocolDecoder implements Constants, IEventDecoder {
-
- protected static Logger log = LoggerFactory.getLogger(RTMPProtocolDecoder.class);
-
- /** Constructs a new RTMPProtocolDecoder. */
- public RTMPProtocolDecoder() {
- }
-
- /**
- * Decode all available objects in buffer.
- *
- * @param conn RTMP connection
- * @param buffer IoBuffer of data to be decoded
- * @return a list of decoded objects, may be empty if nothing could be decoded
- */
- public List