## org.red5.server.net.rtmp
Class BaseRTMPClientHandler

    java.lang.Object
      org.red5.server.net.rtmp.BaseRTMPHandler
          org.red5.server.net.rtmp.BaseRTMPClientHandler

All Implemented Interfaces:
  IRTMPHandler, Constants, StatusCodes, ApplicationContextAware

Direct Known Subclasses:
  RTMPClient, RTMPTClient

    public abstract class BaseRTMPClientHandler

extends BaseRTMPHandler

Base class for clients (RTMP and RTMPT)

Field Summary

Fields inherited from interface org.red5.server.net.rtmp.message.Constants

`HANDSHAKE_SIZE, HEADER_CONTINUE, HEADER_NEW, HEADER_SAME_SOURCE, HEADER_TIMER_CHANGE, MEDIUM_INT_MAX, SO_CLIENT_CLEAR_DATA, SO_CLIENT_DELETE_DATA, SO_CLIENT_INITIAL_DATA, SO_CLIENT_SEND_MESSAGE, SO_CLIENT_STATUS, SO_CLIENT_UPDATE_ATTRIBUTE, SO_CLIENT_UPDATE_DATA, SO_CONNECT, SO_DELETE_ATTRIBUTE, SO_DISCONNECT, SO_SEND_MESSAGE, SO_SET_ATTRIBUTE, SOURCE_TYPE_LIVE, SOURCE_TYPE_VOD, TYPE_ABORT, TYPE_AGGREGATE, TYPE_AUDIO_DATA, TYPE_BYTES_READ, TYPE_CHUNK_SIZE, TYPE_CLIENT_BANDWIDTH, TYPE_FLEX_MESSAGE, TYPE_FLEX_SHARED_OBJECT, TYPE_FLEX_STREAM_SEND, TYPE_INVOKE, TYPE_NOTIFY, TYPE_PING, TYPE_SERVER_BANDWIDTH, TYPE_SHARED_OBJECT, TYPE_STREAM_METADATA, TYPE_VIDEO_DATA`

Fields inherited from interface org.red5.server.net.rtmp.status.StatusCodes

`APP_GC, APP_RESOURCE_LOWMEMORY, APP_SCRIPT_ERROR, APP_SCRIPT_WARNING, APP_SHUTDOWN, NC_CALL_BADVERSION, NC_CALL_FAILED, NC_CONNECT_APPSHUTDOWN, NC_CONNECT_CLOSED, NC_CONNECT_FAILED, NC_CONNECT_INVALID_APPLICATION, NC_CONNECT_REJECTED, NC_CONNECT_SUCCESS, NS_CLEAR_FAILED, NS_CLEAR_SUCCESS, NS_DATA_START, NS_FAILED, NS_INVALID_ARGUMENT, NS_PAUSE_NOTIFY, NS_PLAY_COMPLETE, NS_PLAY_FAILED, NS_PLAY_FILE_STRUCTURE_INVALID, NS_PLAY_INSUFFICIENT_BW, NS_PLAY_NO_SUPPORTED_TRACK_FOUND, NS_PLAY_PUBLISHNOTIFY, NS_PLAY_RESET, NS_PLAY_START, NS_PLAY_STOP, NS_PLAY_STREAMNOTFOUND, NS_PLAY_SWITCH, NS_PLAY_UNPUBLISHNOTIFY, NS_PUBLISH_BADNAME, NS_PUBLISH_START, NS_RECORD_FAILED, NS_RECORD_NOACCESS, NS_RECORD_START, NS_RECORD_STOP, NS_SEEK_FAILED, NS_SEEK_NOTIFY, NS_UNPAUSE_NOTIFY, NS_UNPUBLISHED_SUCCESS, SO_CREATION_FAILED, SO_NO_READ_ACCESS, SO_NO_WRITE_ACCESS, SO_PERSISTENCE_MISMATCH`

Constructor Summary
`protected` `BaseRTMPClientHandler()`

Method Summary
`void` `connect(String server, int port, Map<String,Object> connectionParams)` Connect RTMP client to server via given port and with given connection parameters
`void` `connect(String server, int port, Map<String,Object> connectionParams, IPendingServiceCallback connectCallback)` Connect RTMP client to server's application via given port
`void` `connect(String server, int port, Map<String,Object> connectionParams, IPendingServiceCallback connectCallback, Object[] connectCallArguments)` Connect RTMP client to server's application via given port
`void` `connect(String server, int port, String application)` Connect RTMP client to server's application via given port
`void` `connect(String server, int port, String application, IPendingServiceCallback connectCallback)` Connect RTMP client to server's application via given port with given connection callback
`void` `connectionClosed(RTMPConnection conn, RTMP state)` Connection closed
`void` `connectionOpened(RTMPConnection conn, RTMP state)` Connection open event
`void` `createStream(IPendingServiceCallback callback)`
`void` `disconnect()` Disconnect the first connection in the connection map
`protected int` `getChannelForStreamId(int streamId)` Returns a channel based on the given stream id.
`RTMPCodecFactory` `getCodecFactory()` Getter for codec factory
`RTMPClientConnManager` `getConnManager()`
`IClientSharedObject` `getSharedObject(String name, boolean persistent)` Connect to client shared object.
`void` `handleException(Throwable throwable)`
`void` `invoke(String method, IPendingServiceCallback callback)` Invoke a method on the server.
`void` `invoke(String method, Object[] params, IPendingServiceCallback callback)` Invoke a method on the server and pass parameters.
`Map<String,Object>` `makeDefaultConnectionParams(String server, int port, String application)`
`protected void` `onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize)` Chunk size change event handler.
`protected void` `onInvoke(RTMPConnection conn, Channel channel, Header source, Notify invoke, RTMP rtmp)` Invocation event handler.
`protected void` `onPing(RTMPConnection conn, Channel channel, Header source, Ping ping)` Ping event handler.
`protected void` `onSharedObject(RTMPConnection conn, Channel channel, Header source, SharedObjectMessage object)` Shared object event handler.
`void` `play(int streamId, String name, int start, int length)`
`void` `publish(int streamId, String name, String mode, INetStreamEventHandler handler)`
`void` `publishStreamData(int streamId, IMessage message)`
`void` `setCodecFactory(RTMPCodecFactory factory)` Setter for codec factory
`void` `setConnectionClosedHandler(Runnable connectionClosedHandler)`
`void` `setExceptionHandler(ClientExceptionHandler exceptionHandler)`
`void` `setServiceProvider(Object serviceProvider)` Register object that provides methods that can be called by the server.
`void` `setStreamEventDispatcher(IEventDispatcher streamEventDispatcher)` Setter for stream event dispatcher (useful for saving playing stream to file)
`protected abstract void` `startConnector(String server, int port)` Start network connection to server
`void` `unpublish(int streamId)`

Methods inherited from class org.red5.server.net.rtmp.BaseRTMPHandler
`getHostname, getStreamId, handlePendingCallResult, messageReceived, messageSent, onStreamBytesRead, setApplicationContext`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BaseRTMPClientHandler

    protected BaseRTMPClientHandler()

Method Detail

### getConnManager

    public RTMPClientConnManager getConnManager()

### setConnectionClosedHandler

    public void setConnectionClosedHandler(Runnable connectionClosedHandler)

### setExceptionHandler

    public void setExceptionHandler(ClientExceptionHandler exceptionHandler)

### startConnector

    protected abstract void startConnector(String server,
                                           int port)

  Start network connection to server

  Parameters:
    `server` - Server
    `port` - Connection port

### connect

    public void connect(String server,
                        int port,
                        String application)

  Connect RTMP client to server's application via given port

  Parameters:
    `server` - Server
    `port` - Connection port
    `application` - Application at that server

### connect

    public void connect(String server,
                        int port,
                        String application,
                        IPendingServiceCallback connectCallback)

  Connect RTMP client to server's application via given port with given connection callback

  Parameters:
    `server` - Server
    `port` - Connection port
    `application` - Application at that server
    `connectCallback` - Connection callback

### makeDefaultConnectionParams

    public Map<String,Object> makeDefaultConnectionParams(String server,
                                                          int port,
                                                          String application)

  Parameters:
    `server` - Server
    `port` - Connection port
    `application` - Application at that server
  Returns:
    default connection parameters

### connect

    public void connect(String server,
                        int port,
                        Map<String,Object> connectionParams)

  Connect RTMP client to server via given port and with given connection parameters

  Parameters:
    `server` - Server
    `port` - Connection port
    `connectionParams` - Connection parameters

### connect

    public void connect(String server,
                        int port,
                        Map<String,Object> connectionParams,
                        IPendingServiceCallback connectCallback)

  Connect RTMP client to server's application via given port

  Parameters:
    `server` - Server
    `port` - Connection port
    `connectionParams` - Connection parameters
    `connectCallback` - Connection callback

### connect

    public void connect(String server,
                        int port,
                        Map<String,Object> connectionParams,
                        IPendingServiceCallback connectCallback,
                        Object[] connectCallArguments)

  Connect RTMP client to server's application via given port

  Parameters:
    `server` - Server
    `port` - Connection port
    `connectionParams` - Connection parameters
    `connectCallback` - Connection callback
    `connectCallArguments` - Arguments for 'connect' call

### setServiceProvider

    public void setServiceProvider(Object serviceProvider)

  Register object that provides methods that can be called by the server.

  Parameters:
    `serviceProvider` - Service provider

### getSharedObject

    public IClientSharedObject getSharedObject(String name,
                                               boolean persistent)

  Connect to client shared object.

  Parameters:
    `name` - Client shared object name
    `persistent` - SO persistence flag
  Returns:
    Client shared object instance

### onChunkSize

    protected void onChunkSize(RTMPConnection conn,
                               Channel channel,
                               Header source,
                               ChunkSize chunkSize)

  Chunk size change event handler. Abstract, to be implemented in subclasses.

  Specified by:
    `onChunkSize` in class `BaseRTMPHandler`
  Parameters:
    `conn` - Connection
    `channel` - Channel
    `source` - Header
    `chunkSize` - New chunk size

### onPing

    protected void onPing(RTMPConnection conn,
                          Channel channel,
                          Header source,
                          Ping ping)

  Ping event handler.

  Specified by:
    `onPing` in class `BaseRTMPHandler`
  Parameters:
    `conn` - Connection
    `channel` - Channel
    `source` - Header
    `ping` - Ping event context

### onSharedObject

    protected void onSharedObject(RTMPConnection conn,
                                  Channel channel,
                                  Header source,
                                  SharedObjectMessage object)

  Shared object event handler.

  Specified by:
    `onSharedObject` in class `BaseRTMPHandler`
  Parameters:
    `conn` - Connection
    `channel` - Channel
    `source` - Header
    `object` - Shared object event context

### invoke

    public void invoke(String method,
                       IPendingServiceCallback callback)

  Invoke a method on the server.

  Parameters:
    `method` - Method name
    `callback` - Callback handler

### invoke

    public void invoke(String method,
                       Object[] params,
                       IPendingServiceCallback callback)

  Invoke a method on the server and pass parameters.

  Parameters:
    `method` - Method
    `params` - Method call parameters
    `callback` - Callback object

### disconnect

    public void disconnect()

  Disconnect the first connection in the connection map

### createStream

    public void createStream(IPendingServiceCallback callback)

### publish

    public void publish(int streamId,
                        String name,
                        String mode,
                        INetStreamEventHandler handler)

### unpublish

    public void unpublish(int streamId)

### publishStreamData

    public void publishStreamData(int streamId,
                                  IMessage message)

### play

    public void play(int streamId,
                     String name,
                     int start,
                     int length)

### connectionOpened

    public void connectionOpened(RTMPConnection conn,
                                 RTMP state)

  Connection open event

  Specified by:
    `connectionOpened` in interface `IRTMPHandler`
  Overrides:
    `connectionOpened` in class `BaseRTMPHandler`
  Parameters:
    `conn` - Connection
    `state` - RTMP state

### connectionClosed

    public void connectionClosed(RTMPConnection conn,
                                 RTMP state)

  Description copied from class: `BaseRTMPHandler`
  Connection closed

  Specified by:
    `connectionClosed` in interface `IRTMPHandler`
  Overrides:
    `connectionClosed` in class `BaseRTMPHandler`
  Parameters:
    `conn` - Connection
    `state` - RTMP state

### onInvoke

    protected void onInvoke(RTMPConnection conn,
                            Channel channel,
                            Header source,
                            Notify invoke,
                            RTMP rtmp)

  Invocation event handler.

  Specified by:
    `onInvoke` in class `BaseRTMPHandler`
  Parameters:
    `conn` - Connection
    `channel` - Channel
    `source` - Header
    `invoke` - Invocation event context
    `rtmp` - RTMP connection state

### setCodecFactory

    public void setCodecFactory(RTMPCodecFactory factory)

  Setter for codec factory

  Parameters:
    `factory` - Codec factory to use

### getCodecFactory

    public RTMPCodecFactory getCodecFactory()

  Getter for codec factory

  Returns:
    Codec factory

### handleException

    public void handleException(Throwable throwable)

### getChannelForStreamId

    protected int getChannelForStreamId(int streamId)

  Returns a channel based on the given stream id.

  Parameters:
    `streamId` -
  Returns:
    the channel for this stream id

### setStreamEventDispatcher

    public void setStreamEventDispatcher(IEventDispatcher streamEventDispatcher)

  Setter for stream event dispatcher (useful for saving playing stream to file)

  Parameters:
    `streamEventDispatcher` - event dispatcher

Copyright © 2006-2010 The Red5 Project