Package org.red5.client.net.rtmp
Class BaseRTMPClientHandler
java.lang.Object
org.red5.server.net.rtmp.BaseRTMPHandler
org.red5.client.net.rtmp.BaseRTMPClientHandler
- All Implemented Interfaces:
IRTMPClient,IRTMPHandler,Constants,StatusCodes
- Direct Known Subclasses:
RTMPClient,RTMPTClient
Base class for clients (RTMP and RTMPT)
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.red5.server.net.rtmp.message.Constants
Constants.DataType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether or not the bandwidth done has been invokedprotected RTMPConnectionAssociated RTMP connectionConnection parametersprotected ScheduledExecutorServiceFor handling threading / scheduling in the clients.protected StringConnection scheme / protocolprotected booleanWhether or not the client is subscribedFields inherited from class org.red5.server.net.rtmp.BaseRTMPHandler
isDebug, isTrace, logFields 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_EDGE_ORIGIN, 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_DATAFields 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_RECONNECT_REQUEST, NC_CONNECT_REJECTED, NC_CONNECT_SUCCESS, NS_BUFFER_EMPTY, 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_TRANSITION, NS_PLAY_TRANSITION_COMPLETE, 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_TRANSITION_FORCED, NS_TRANSITION_SUCCESS, NS_UNPAUSE_NOTIFY, NS_UNPUBLISHED_SUCCESS, SO_CREATION_FAILED, SO_NO_READ_ACCESS, SO_NO_WRITE_ACCESS, SO_PERSISTENCE_MISMATCH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConnect RTMP client to server's application via given portvoidconnect(String server, int port, String application, IPendingServiceCallback connectCallback) Connect RTMP client to server's application via given port with given connection callbackvoidConnect RTMP client to server via given port and with given connection parametersvoidconnect(String server, int port, Map<String, Object> connectionParams, IPendingServiceCallback connectCallback) Connect RTMP client to server's application via given portvoidconnect(String server, int port, Map<String, Object> connectionParams, IPendingServiceCallback connectCallback, Object[] connectCallArguments) Connect RTMP client to server's application via given portvoidvoidvoidcreateStream(IPendingServiceCallback callback) voiddeleteStream(IPendingServiceCallback callback) voidDisconnect the first connection in the connection mapprotected intgetChannelForStreamId(Number streamId) Returns a channel based on the given stream id.Returns the connection associated with this client.getSharedObject(String name, boolean persistent) Connect to client shared object.voidhandleException(Throwable throwable) Handle any exceptions that occur.voidinvoke(String method, Object[] params, IPendingServiceCallback callback) Invoke a method on the server and pass parameters.voidinvoke(String method, IPendingServiceCallback callback) Invoke a method on the server.booleanReturns true if bandwidth done has been invokedbooleanReturns true if this client is subscribedbooleanReturns true if swf verification is enabledmakeDefaultConnectionParams(String server, int port, String application) Creates the default connection parameters collection.voidCalled when negotiating bandwidth.voidCalled when negotiating bandwidth.voidonBWDone()Called when bandwidth has been configured.voidCalled when bandwidth has been configured.protected voidonChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) protected voidonClientBandwidth(RTMPConnection conn, Channel channel, ClientBW message) protected voidonCommand(RTMPConnection conn, Channel channel, Header source, ICommand command) protected voidonPing(RTMPConnection conn, Channel channel, Header source, Ping ping) protected voidonServerBandwidth(RTMPConnection conn, Channel channel, ServerBW message) protected voidonSharedObject(RTMPConnection conn, Channel channel, Header source, SharedObjectMessage object) voidSends a ping.voidvoidDynamic streaming play method.voidpublish(Number streamId, String name, String mode, INetStreamEventHandler handler) voidpublishStreamData(Number streamId, IMessage message) voidreleaseStream(IPendingServiceCallback callback, Object[] params) voidsetConnection(RTMPConnection conn) Sets a reference to the connection associated with this client handler.voidsetConnectionClosedHandler(Runnable connectionClosedHandler) Sets a handler for connection close.voidsetExceptionHandler(ClientExceptionHandler exceptionHandler) Sets a handler for exceptions.voidsetProtocol(String protocol) Sets the protocol.voidsetServiceProvider(Object serviceProvider) Register object that provides methods that can be called by the server.voidsetStreamEventDispatcher(IEventDispatcher streamEventDispatcher) Setter for stream event dispatcher (useful for saving playing stream to file)voidsetStreamEventHandler(INetStreamEventHandler streamEventHandler) Setter for the stream event handler.voidsetSwfVerification(boolean enabled) Enables or disables SWF verification.protected abstract voidstartConnector(String server, int port) Start network connection to servervoidsubscribe(IPendingServiceCallback callback, Object[] params) voidMethods inherited from class org.red5.server.net.rtmp.BaseRTMPHandler
getHostname, handlePendingCallResult, messageReceived, messageSent, onStreamBytesRead
-
Field Details
-
protocol
Connection scheme / protocol -
connectionParams
Connection parameters -
conn
Associated RTMP connection -
bandwidthCheckDone
protected boolean bandwidthCheckDoneWhether or not the bandwidth done has been invoked -
subscribed
protected boolean subscribedWhether or not the client is subscribed -
executor
For handling threading / scheduling in the clients.
-
-
Constructor Details
-
BaseRTMPClientHandler
protected BaseRTMPClientHandler()
-
-
Method Details
-
startConnector
Start network connection to server- Parameters:
server- Serverport- Connection port
-
connect
Connect RTMP client to server's application via given port- Specified by:
connectin interfaceIRTMPClient- Parameters:
server- Serverport- Connection portapplication- 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- Specified by:
connectin interfaceIRTMPClient- Parameters:
server- Serverport- Connection portapplication- Application at that serverconnectCallback- Connection callback
-
makeDefaultConnectionParams
Creates the default connection parameters collection. Many implementations of this handler will create a tcUrl if not found, it is created with the current server url.- Specified by:
makeDefaultConnectionParamsin interfaceIRTMPClient- Parameters:
server- the server locationport- the port for the protocolapplication- the application name at the given server- Returns:
- connection parameters map
-
connect
Connect RTMP client to server via given port and with given connection parameters- Specified by:
connectin interfaceIRTMPClient- Parameters:
server- Serverport- Connection portconnectionParams- 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- Specified by:
connectin interfaceIRTMPClient- Parameters:
server- Serverport- Connection portconnectionParams- Connection parametersconnectCallback- 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- Specified by:
connectin interfaceIRTMPClient- Parameters:
server- Serverport- Connection portconnectionParams- Connection parametersconnectCallback- Connection callbackconnectCallArguments- Arguments for 'connect' call
-
setServiceProvider
Register object that provides methods that can be called by the server.- Specified by:
setServiceProviderin interfaceIRTMPClient- Parameters:
serviceProvider- Service provider
-
setConnectionClosedHandler
Sets a handler for connection close.- Specified by:
setConnectionClosedHandlerin interfaceIRTMPClient- Parameters:
connectionClosedHandler- close handler
-
setExceptionHandler
Sets a handler for exceptions.- Specified by:
setExceptionHandlerin interfaceIRTMPClient- Parameters:
exceptionHandler- exception handler
-
onChunkSize
protected void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) - Specified by:
onChunkSizein classBaseRTMPHandler
-
onPing
- Specified by:
onPingin classBaseRTMPHandler
-
onServerBandwidth
- Overrides:
onServerBandwidthin classBaseRTMPHandler
-
onClientBandwidth
- Overrides:
onClientBandwidthin classBaseRTMPHandler
-
onBWCheck
public void onBWCheck()Called when negotiating bandwidth. -
onBWCheck
Called when negotiating bandwidth.- Parameters:
params- bw parameters
-
onBWDone
Called when bandwidth has been configured.- Parameters:
params- bw parameters
-
onBWDone
public void onBWDone()Called when bandwidth has been configured. -
invoke
Invoke a method on the server.- Specified by:
invokein interfaceIRTMPClient- Parameters:
method- Method namecallback- Callback handler
-
invoke
Invoke a method on the server and pass parameters.- Specified by:
invokein interfaceIRTMPClient- Parameters:
method- Methodparams- Method call parameterscallback- Callback object
-
disconnect
public void disconnect()Disconnect the first connection in the connection map- Specified by:
disconnectin interfaceIRTMPClient
-
createStream
- Specified by:
createStreamin interfaceIRTMPClient
-
releaseStream
-
deleteStream
-
subscribe
-
publish
- Specified by:
publishin interfaceIRTMPClient
-
unpublish
- Specified by:
unpublishin interfaceIRTMPClient
-
publishStreamData
- Specified by:
publishStreamDatain interfaceIRTMPClient
-
play
- Specified by:
playin interfaceIRTMPClient
-
play2
Dynamic streaming play method. The following properties are supported on the play options:streamName: String. The name of the stream to play or the new stream to switch to. oldStreamName: String. The name of the initial stream that needs to be switched out. This is not needed and ignored when play2 is used for just playing the stream and not switching to a new stream. start: Number. The start time of the new stream to play, just as supported by the existing play API. and it has the same defaults. This is ignored when the method is called for switching (in other words, the transition is either NetStreamPlayTransition.SWITCH or NetStreamPlayTransitions.SWAP) len: Number. The duration of the playback, just as supported by the existing play API and has the same defaults. transition: String. The transition mode for the playback command. It could be one of the following: NetStreamPlayTransitions.RESET NetStreamPlayTransitions.APPEND NetStreamPlayTransitions.SWITCH NetStreamPlayTransitions.SWAPNetStreamPlayTransitions:APPEND : String = "append" - Adds the stream to a playlist and begins playback with the first stream. APPEND_AND_WAIT : String = "appendAndWait" - Builds a playlist without starting to play it from the first stream. RESET : String = "reset" - Clears any previous play calls and plays the specified stream immediately. RESUME : String = "resume" - Requests data from the new connection starting from the point at which the previous connection ended. STOP : String = "stop" - Stops playing the streams in a playlist. SWAP : String = "swap" - Replaces a content stream with a different content stream and maintains the rest of the playlist. SWITCH : String = "switch" - Switches from playing one stream to another stream, typically with streams of the same content.- Specified by:
play2in interfaceIRTMPClient- See Also:
-
ping
Sends a ping.- Parameters:
pingType- the type of pingstreamId- streams idparam- ping parameter
-
connectionOpened
- Specified by:
connectionOpenedin interfaceIRTMPHandler- Overrides:
connectionOpenedin classBaseRTMPHandler
-
connectionClosed
- Specified by:
connectionClosedin interfaceIRTMPHandler- Overrides:
connectionClosedin classBaseRTMPHandler
-
onCommand
- Specified by:
onCommandin classBaseRTMPHandler
-
handleException
Handle any exceptions that occur.- Parameters:
throwable- Exception thrown
-
getChannelForStreamId
Returns a channel based on the given stream id.- Parameters:
streamId- stream id- Returns:
- the channel for this stream id
-
setProtocol
Sets the protocol.- Parameters:
protocol- the data protocol to use.- Throws:
Exception- thrown
-
setConnection
Sets a reference to the connection associated with this client handler.- Parameters:
conn- connection
-
getConnection
Returns the connection associated with this client.- Specified by:
getConnectionin interfaceIRTMPClient- Returns:
- conn connection
-
setSwfVerification
public void setSwfVerification(boolean enabled) Enables or disables SWF verification.- Parameters:
enabled- state of SWF verification
-
isSwfVerification
public boolean isSwfVerification()Returns true if swf verification is enabled- Returns:
- the swfVerification
-
isBandwidthCheckDone
public boolean isBandwidthCheckDone()Returns true if bandwidth done has been invoked- Returns:
- the bandwidthCheckDone
-
isSubscribed
public boolean isSubscribed()Returns true if this client is subscribed- Returns:
- subscribed state
-
getConnectionParams
- Returns:
- the connectionParams
-
setStreamEventDispatcher
Setter for stream event dispatcher (useful for saving playing stream to file)- Specified by:
setStreamEventDispatcherin interfaceIRTMPClient- Parameters:
streamEventDispatcher- event dispatcher
-
setStreamEventHandler
Setter for the stream event handler.- Parameters:
streamEventHandler- event handler
-