FileDocCategorySizeDatePackage
RtspManager.javaAPI DocJMF 2.1.1e3809Mon May 12 12:20:56 BST 2003com.sun.media.rtsp

RtspManager

public class RtspManager extends Object

Fields Summary
private Vector
listeners
private int
connectionCounter
private Vector
connections
private String
address
private int
port
Constructors Summary
public RtspManager()

        listeners = new Vector();

        connections = new Vector();

        Server server = new Server(this);

        server.start();
    
public RtspManager(boolean server_socket)

        listeners = new Vector();

        connections = new Vector();

        if (server_socket) {
            Server server = new Server(this);

            server.start();
        }
    
Methods Summary
public voidaddConnection(java.net.Socket socket)

        connectionCounter++;

        Connection connection = new Connection(this, connectionCounter, socket);

        connections.addElement(connection);
    
public voidaddListener(com.sun.media.rtsp.RtspListener listener)

        listeners.addElement(listener);
    
public voidcloseConnection(int connectionId)

        Connection connection = getConnection(connectionId);

        if (connection != null) {
            connection.close();

            connections.removeElement(connection);
        } else {
            System.out.println("connection not found!");
        }
    
public intcreateConnection(java.lang.String address, int port)

        this.address = address;
        this.port = port;

        int connectionId = -1;

        try {
            Connection connection = new Connection(this, connectionCounter + 1,
                    address.getBytes(), port);

            connections.addElement(connection);

            connectionId = connection.connectionId;

            connectionCounter++;
        } catch (UnknownHostException e) {
            Log.error("[EXCEPTION]: Unknown host.");

            connectionId = -2;
        }
        catch (ConnectException e) {
            Log.error("[EXCEPTION]: Can't connect to server.");

            connectionId = -3;
        }

        return connectionId;
    
public voiddataIndication(int connectionId, Message message)

        for (int i = 0; i < listeners.size(); i++) {
            RtspListener listener = (RtspListener) listeners.elementAt(i);

            listener.rtspMessageIndication(connectionId, message);
        }
    
public com.sun.media.rtsp.ConnectiongetConnection(int connectionId)

        Connection connection = null;

        for (int i = 0; i < connections.size(); i++) {
            Connection tmpConnection = (Connection) connections.elementAt(i);

            if (tmpConnection.connectionId == connectionId) {
                connection = tmpConnection;

                break;
            }
        }

        return connection;
    
public voidremoveConnection(int connectionId)

        Connection connection = getConnection(connectionId);

        connections.removeElement(connection);

        for (int i = 0; i < listeners.size(); i++) {
            RtspListener listener = (RtspListener) listeners.elementAt(i);

            listener.rtspConnectionTerminated(connectionId);
        }
    
public voidremoveListener(com.sun.media.rtsp.RtspListener listener)

        listeners.removeElement(listener);
    
public booleansendMessage(int connectionId, java.lang.String message)

        Log.comment("outgoing msg:");
        Log.comment(message);

        Connection connection = getConnection(connectionId);

        boolean success;

        if (connection == null) {
            success = false;
        } else {
            success = connection.sendData(message.getBytes());
        }

        return success;