Package org.red5.server.net.rtmp
Class RTMPConnection
java.lang.Object
org.red5.server.AttributeStore
org.red5.server.BaseConnection
org.red5.server.net.rtmp.RTMPConnection
- All Implemented Interfaces:
IEventDispatcher
,IEventHandler
,IEventListener
,IAttributeStore
,ICastingAttributeStore
,IConnection
,ICoreObject
,IServiceCapableConnection
,IStreamCapableConnection
,AttributeStoreMXBean
,IReceivedMessageTaskQueueListener
- Direct Known Subclasses:
RTMPMinaConnection
public abstract class RTMPConnection
extends BaseConnection
implements IStreamCapableConnection, IServiceCapableConnection, IReceivedMessageTaskQueueListener
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate class
Task that keeps connection alive and disconnects if client is dead.private class
Task that waits for a valid handshake and disconnects the client if none is received.Nested classes/interfaces inherited from interface org.red5.server.api.IConnection
IConnection.Encoding
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
Data read intervalprivate ConcurrentMap<Integer,
Channel> Connection channelsprivate int
Concurrency level for channels collectionprivate int
Initial channel capacityprivate AtomicLong
Number of bytes the client reported to have received.private final AtomicBoolean
Closing flagprivate final AtomicInteger
Keep track of current queue sizeprotected ThreadPoolTaskScheduler
Thread pool for guarding deadlocks.protected Semaphore
protected RTMPDecodeState
private CopyOnWriteArraySet<DeferredResult>
Deferred results set.protected Semaphore
protected ThreadPoolTaskExecutor
Thread pool for message handling.private Integer
Specify the size of queue that will trigger audio packet dropping, disabled if it's 0protected IRTMPHandler
RTMP events handlerprivate ScheduledFuture<?>
Keep alive task.private AtomicInteger
Last ping round trip timeprivate AtomicLong
Timestamp when last ping command was sent.private AtomicLong
Timestamp when last ping result was received.protected int
Bandwidth limit type / enforcement.private static org.slf4j.Logger
static final double
protected long
Maximum time in milliseconds allowed to process received messageprivate int
Maximum time in milliseconds to wait for a valid handshake.protected int
Maximum time in ms after which a client is disconnected because of inactivity.protected long
Number of bytes to read next.private final AtomicLong
Packet sequence numberprivate ConcurrentMap<Integer,
IPendingServiceCall> Hash map that stores pending calls and ids as pairs.private int
Concurrency level for pending calls collectionprivate int
Initial pending calls capacityprivate ConcurrentMap<Number,
AtomicInteger> Map for pending video packets keyed by stream id.private int
Ping interval in ms to detect dead clients.Reserved stream ids.private int
Concurrency level for reserved streams collectionprivate int
Initial reserved streams capacitystatic final String
static final byte
Marker byte for encrypted RTMP data.static final byte
Marker byte for encrypted RTMP data using Blowfish.static final byte
Unknown type 0x0a, seen on youtubestatic final byte
Marker byte for encrypted RTMP data XTEA.static final Object
static final String
static final byte
Marker byte for standard or non-encrypted RTMP data.static final String
static final String
Cipher for RTMPE inputstatic final String
Cipher for RTMPE outputprotected final AtomicBoolean
Keep-alive worker flagprotected ThreadPoolTaskScheduler
Scheduling serviceprotected RTMP
Protocol stateprivate ConcurrentMap<Number,
Integer> Remembered stream buffer durations.private ConcurrentMap<Number,
IClientStream> Client streamsprivate int
Concurrency level for streams collectionprivate int
Initial streams capacityprivate final ConcurrentMap<Integer,
ReceivedMessageTaskQueue> Queues of tasks for every channelprivate final AtomicInteger
Timestamp generatorprivate AtomicInteger
Transaction identifier for remote commands.private AtomicInteger
Number of (NetStream) streams used.private ScheduledFuture<?>
Wait for handshake task.Fields inherited from class org.red5.server.BaseConnection
basicScopes, client, connectionListeners, droppedMessages, host, params, path, readMessages, remoteAddress, remoteAddresses, remotePort, scope, sessionId, type, writtenMessages
Fields inherited from class org.red5.server.AttributeStore
attributes
Fields inherited from interface org.red5.server.api.IConnection
PERSISTENT, POLLING, TRANSIENT
-
Constructor Summary
ConstructorDescriptionRTMPConnection
(String type) Creates anonymous RTMP connection without scope. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addClientStream
(IClientStream stream) void
close()
Closes connectionvoid
closeChannel
(int channelId) Closes channel.boolean
Connect to another scope on server with given parameterscreateOutputStream
(Number streamId) Creates output stream object from stream id.protected String
Generates new stream name.protected int
Returns the current received message queue size.private void
customizeStream
(Number streamId, AbstractClientStream stream) Specify name, connection, scope and etc for streamvoid
deleteStreamById
(Number streamId) Deletes the stream with the given id.void
dispatchEvent
(IEvent event) Dispatches eventgetChannel
(int channelId) Return channel by id.int
getChannelIdForStreamId
(Number streamId) Return channel id for given stream id.int
int
long
Get number of bytes the client reported to have received.Thread pool for guarding deadlocksReturn AMF protocol encoding used by this connection.int
getId()
org.apache.mina.core.session.IoSession
int
Difference between when the last ping was sent and when the last pong was received.int
Return round-trip time of last ping command.long
private String
getMessageType
(Packet packet) int
Getter for next available channel id.getPendingCall
(int invokeId) Get pending call service by id.int
int
long
getPendingVideoMessages
(Number streamId) Count of outgoing video messages not yet written.Returns the protocol type for this connection.long
Total number of bytes read from the connection.int
int
getState()
byte
getStreamByChannelId
(int channelId) Return stream by given channel id.getStreamById
(Number streamId) Get a stream by its id.getStreamIdForChannelId
(int channelId) Return stream id for given channel id.protected Collection<IClientStream>
Getter for client streams.int
int
int
getTimer()
Returns a usable timestamp for written packets.int
Generate next invoke id.protected int
Getter for used stream count.long
Total number of bytes written to the connection.void
handleMessageReceived
(Packet message) Handle the incoming message.void
Invoke method by name.void
Invoke method with parameters.void
invoke
(String method, Object[] params, IPendingServiceCallback callback) Invoke method with parameters.void
invoke
(String method, IPendingServiceCallback callback) Invoke method by name with callback.void
invoke
(IServiceCall call) Invokes service using remoting call object.void
invoke
(IServiceCall call, int channel) Invoke service using call and channel.boolean
isChannelUsed
(int channelId) Checks whether channel is used.boolean
Returns whether or not the connection is disconnected.boolean
isIdle()
Returns whether or not the connection has been idle for a maximum period.boolean
isValidStreamId
(Number streamId) Returns whether or not a given stream id is valid.void
logStream
(IClientStream stream) void
protected void
Increases number of dropped messages.void
Increases number of read messages by one.void
messageSent
(Packet message) Mark message as sent.messageTypeToName
(byte headerDataType) newBroadcastStream
(Number streamId) Create a broadcast stream.newPlaylistSubscriberStream
(Number streamId) Create a stream that can play a list.newSingleItemSubscriberStream
(Number streamId) Create a stream that can play only one item.void
Notify method.void
Notify method with parameters.void
notify
(IServiceCall call) Notify method.void
notify
(IServiceCall call, int channel) Notify method with channel id.protected abstract void
Inactive state event handler.void
void
void
open()
Opens the connection.void
ping()
Start measuring the round-trip time for a packet on the connection.void
Handler for ping event.void
pingReceived
(Ping pong) Marks that ping back was received.private void
processTasksQueue
(ReceivedMessageTaskQueue currentStreamTasks) void
receivedBytesRead
(int bytes) Read number of received bytes.void
registerDeferredResult
(DeferredResult result) Registers deferred result.void
registerPendingCall
(int invokeId, IPendingServiceCall call) Register pending call (remote function call that is yet to finish).private boolean
registerStream
(IClientStream stream) Store a stream in the connection.void
rememberStreamBufferDuration
(int streamId, int bufferDuration) void
removeClientStream
(Number streamId) Return a reserved stream id for use.reserveStreamId
(Number streamId) Return a reserved stream id for use with a preference for the one supplied.retrievePendingCall
(int invokeId) Retrieves and removes the pending call service by id.void
When the connection has been closed, notify any remaining pending service calls that they have failed because the connection is broken.void
setBandwidth
(int mbits) Sets the bandwidth using a mbit/s value.void
setChannelsConcurrencyLevel
(int channelsConcurrencyLevel) void
setChannelsInitalCapacity
(int channelsInitalCapacity) void
setDeadlockGuardScheduler
(ThreadPoolTaskScheduler deadlockGuardScheduler) Thread pool for guarding deadlocksvoid
setExecutor
(ThreadPoolTaskExecutor executor) void
setExecutorQueueSizeToDropAudioPackets
(Integer executorQueueSizeToDropAudioPackets) Specify the size of queue that will trigger audio packet dropping, disabled if it's 0void
setHandler
(IRTMPHandler handler) void
setId
(int clientId) Deprecated.void
setMaxHandlingTimeout
(long maxHandlingTimeout) void
setMaxHandshakeTimeout
(int maxHandshakeTimeout) Set maximum time to wait for valid handshake in milliseconds.void
setMaxInactivity
(int maxInactivity) Setter for maximum inactivity.void
setPendingCallsConcurrencyLevel
(int pendingCallsConcurrencyLevel) void
setPendingCallsInitalCapacity
(int pendingCallsInitalCapacity) void
setPingInterval
(int pingInterval) Setter for ping interval.void
setReservedStreamsConcurrencyLevel
(int reservedStreamsConcurrencyLevel) void
setReservedStreamsInitalCapacity
(int reservedStreamsInitalCapacity) void
setScheduler
(ThreadPoolTaskScheduler scheduler) Sets the scheduler.void
setStateCode
(byte code) void
setStreamsConcurrencyLevel
(int streamsConcurrencyLevel) void
setStreamsInitalCapacity
(int streamsInitalCapacity) void
Initialize connection.private void
Starts measurement.void
Start waiting for a valid handshake.void
Sends a status object to the connection.void
Sends a status object to the connection on a given channel.private void
Stops measurement.private void
Cancels wait for handshake task.toString()
void
Unregister deferred resultprivate void
unregisterStream
(IClientStream stream) Remove a stream from the connection.void
unreserveStreamId
(Number streamId) Unreserve this id for future use.protected void
Update number of bytes to read next value.abstract void
Write packet.abstract void
writeRaw
(org.apache.mina.core.buffer.IoBuffer out) Write raw byte buffer.protected void
writingMessage
(Packet message) Mark message as being written.Methods inherited from class org.red5.server.BaseConnection
addListener, connect, equals, getBasicScopes, getClient, getConnectParams, getDroppedMessages, getHost, getLock, getPath, getPendingMessages, getReadMessages, getRemoteAddress, getRemoteAddresses, getRemotePort, getScope, getSessionId, getStreamId, getType, getWrittenMessages, handleEvent, hashCode, initialize, isClosed, isConnected, isReaderIdle, isWriterIdle, notifyEvent, registerBasicScope, removeListener, setClient, setStreamId, unregisterBasicScope
Methods inherited from class org.red5.server.AttributeStore
filterNull, from, getAttribute, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes, size
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.red5.server.api.IAttributeStore
getAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes, size
Methods inherited from interface org.red5.server.api.ICastingAttributeStore
getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute
Methods inherited from interface org.red5.server.api.IConnection
addListener, connect, getBasicScopes, getClient, getConnectParams, getDroppedMessages, getHost, getPath, getPendingMessages, getReadMessages, getRemoteAddress, getRemoteAddresses, getRemotePort, getScope, getSessionId, getStreamId, getType, getWrittenMessages, initialize, isConnected, removeListener, setClient, setStreamId
Methods inherited from interface org.red5.server.api.event.IEventHandler
handleEvent
Methods inherited from interface org.red5.server.api.event.IEventListener
notifyEvent
-
Field Details
-
log
private static org.slf4j.Logger log -
RTMP_SESSION_ID
- See Also:
-
RTMP_HANDSHAKE
- See Also:
-
RTMP_CONN_MANAGER
- See Also:
-
RTMP_HANDLER
-
RTMP_NON_ENCRYPTED
public static final byte RTMP_NON_ENCRYPTEDMarker byte for standard or non-encrypted RTMP data.- See Also:
-
RTMP_ENCRYPTED
public static final byte RTMP_ENCRYPTEDMarker byte for encrypted RTMP data.- See Also:
-
RTMP_ENCRYPTED_XTEA
public static final byte RTMP_ENCRYPTED_XTEAMarker byte for encrypted RTMP data XTEA. http://en.wikipedia.org/wiki/XTEA- See Also:
-
RTMP_ENCRYPTED_BLOWFISH
public static final byte RTMP_ENCRYPTED_BLOWFISHMarker byte for encrypted RTMP data using Blowfish. http://en.wikipedia.org/wiki/Blowfish_(cipher)- See Also:
-
RTMP_ENCRYPTED_UNK
public static final byte RTMP_ENCRYPTED_UNKUnknown type 0x0a, seen on youtube- See Also:
-
RTMPE_CIPHER_IN
Cipher for RTMPE input- See Also:
-
RTMPE_CIPHER_OUT
Cipher for RTMPE output- See Also:
-
MAX_RESERVED_STREAMS
public static final double MAX_RESERVED_STREAMS- See Also:
-
channelsInitalCapacity
private int channelsInitalCapacityInitial channel capacity -
channelsConcurrencyLevel
private int channelsConcurrencyLevelConcurrency level for channels collection -
streamsInitalCapacity
private int streamsInitalCapacityInitial streams capacity -
streamsConcurrencyLevel
private int streamsConcurrencyLevelConcurrency level for streams collection -
pendingCallsInitalCapacity
private int pendingCallsInitalCapacityInitial pending calls capacity -
pendingCallsConcurrencyLevel
private int pendingCallsConcurrencyLevelConcurrency level for pending calls collection -
reservedStreamsInitalCapacity
private int reservedStreamsInitalCapacityInitial reserved streams capacity -
reservedStreamsConcurrencyLevel
private int reservedStreamsConcurrencyLevelConcurrency level for reserved streams collection -
channels
Connection channels- See Also:
-
tasksByStreams
Queues of tasks for every channel- See Also:
-
streams
Client streams- See Also:
-
reservedStreams
Reserved stream ids. Stream id's directly relate to individual NetStream instances. -
transactionId
Transaction identifier for remote commands. -
pendingCalls
Hash map that stores pending calls and ids as pairs. -
deferredResults
Deferred results set.- See Also:
-
lastPingRoundTripTime
Last ping round trip time -
lastPingSentOn
Timestamp when last ping command was sent. -
lastPongReceivedOn
Timestamp when last ping result was received. -
handler
RTMP events handler -
pingInterval
private volatile int pingIntervalPing interval in ms to detect dead clients. -
maxInactivity
protected volatile int maxInactivityMaximum time in ms after which a client is disconnected because of inactivity. -
bytesReadInterval
protected long bytesReadIntervalData read interval -
nextBytesRead
protected long nextBytesReadNumber of bytes to read next. -
clientBytesRead
Number of bytes the client reported to have received. -
pendingVideos
Map for pending video packets keyed by stream id. -
usedStreams
Number of (NetStream) streams used. -
streamBuffers
Remembered stream buffer durations. -
maxHandshakeTimeout
private int maxHandshakeTimeoutMaximum time in milliseconds to wait for a valid handshake. -
maxHandlingTimeout
protected long maxHandlingTimeoutMaximum time in milliseconds allowed to process received message -
limitType
protected int limitTypeBandwidth limit type / enforcement. (0=hard,1=soft,2=dynamic) -
state
Protocol state -
decoderLock
-
encoderLock
-
decoderState
-
scheduler
Scheduling service -
executor
Thread pool for message handling. -
deadlockGuardScheduler
Thread pool for guarding deadlocks. -
running
Keep-alive worker flag -
timer
Timestamp generator -
closing
Closing flag -
packetSequence
Packet sequence number -
executorQueueSizeToDropAudioPackets
Specify the size of queue that will trigger audio packet dropping, disabled if it's 0 -
currentQueueSize
Keep track of current queue size -
waitForHandshakeTask
Wait for handshake task. -
keepAliveTask
Keep alive task.
-
-
Constructor Details
-
RTMPConnection
Creates anonymous RTMP connection without scope.- Parameters:
type
- Connection type
-
-
Method Details
-
getId
public int getId() -
setId
Deprecated. -
setHandler
-
getHandler
-
getState
-
getStateCode
public byte getStateCode() -
setStateCode
public void setStateCode(byte code) -
getIoSession
public org.apache.mina.core.session.IoSession getIoSession() -
getDecoderLock
- Returns:
- the decoderLock
-
getEncoderLock
- Returns:
- the decoderLock
-
getDecoderState
- Returns:
- the decoderState
-
setBandwidth
public void setBandwidth(int mbits) Sets the bandwidth using a mbit/s value.- Specified by:
setBandwidth
in interfaceIConnection
- Parameters:
mbits
- target
-
getTimer
public int getTimer()Returns a usable timestamp for written packets.- Returns:
- timestamp
-
open
public void open()Opens the connection. -
connect
Description copied from class:BaseConnection
Connect to another scope on server with given parameters- Specified by:
connect
in interfaceIConnection
- Overrides:
connect
in classBaseConnection
- Parameters:
newScope
- New scopeparams
- Parameters to connect with- Returns:
- true on success, false otherwise
-
startWaitForHandshake
public void startWaitForHandshake()Start waiting for a valid handshake. -
stopWaitForHandshake
private void stopWaitForHandshake()Cancels wait for handshake task. -
startRoundTripMeasurement
private void startRoundTripMeasurement()Starts measurement. -
stopRoundTripMeasurement
private void stopRoundTripMeasurement()Stops measurement. -
setup
Initialize connection.- Parameters:
host
- Connection hostpath
- Connection pathparams
- Params passed from client
-
getEncoding
Return AMF protocol encoding used by this connection.- Specified by:
getEncoding
in interfaceIConnection
- Returns:
- AMF encoding used by connection
-
getNextAvailableChannelId
public int getNextAvailableChannelId()Getter for next available channel id.- Returns:
- Next available channel id
-
isChannelUsed
public boolean isChannelUsed(int channelId) Checks whether channel is used.- Parameters:
channelId
- Channel id- Returns:
- true if channel is in use, false otherwise
-
getChannel
Return channel by id.- Parameters:
channelId
- Channel id- Returns:
- Channel by id
-
closeChannel
public void closeChannel(int channelId) Closes channel.- Parameters:
channelId
- Channel id
-
getStreams
Getter for client streams.- Returns:
- Client streams as array
-
getStreamsMap
- Specified by:
getStreamsMap
in interfaceIStreamCapableConnection
-
reserveStreamId
Return a reserved stream id for use. According to FCS/FMS regulation, the base is 1.- Specified by:
reserveStreamId
in interfaceIStreamCapableConnection
- Returns:
- Reserved stream id
-
reserveStreamId
Return a reserved stream id for use with a preference for the one supplied.- Specified by:
reserveStreamId
in interfaceIStreamCapableConnection
- Parameters:
streamId
- supplied stream id- Returns:
- Reserved stream id
-
isValidStreamId
Returns whether or not a given stream id is valid.- Parameters:
streamId
- stream id- Returns:
- true if its valid, false if its invalid
-
isIdle
public boolean isIdle()Returns whether or not the connection has been idle for a maximum period.- Returns:
- true if max idle period has been exceeded, false otherwise
-
isDisconnected
public boolean isDisconnected()Returns whether or not the connection is disconnected.- Returns:
- true if connection state is RTMP.STATE_DISCONNECTED, false otherwise
-
newBroadcastStream
Create a broadcast stream.- Specified by:
newBroadcastStream
in interfaceIStreamCapableConnection
- Parameters:
streamId
- Stream id- Returns:
- New broadcast stream
-
newSingleItemSubscriberStream
Create a stream that can play only one item.- Specified by:
newSingleItemSubscriberStream
in interfaceIStreamCapableConnection
- Parameters:
streamId
- Stream id- Returns:
- New subscriber stream that can play only one item
-
newPlaylistSubscriberStream
Create a stream that can play a list.- Specified by:
newPlaylistSubscriberStream
in interfaceIStreamCapableConnection
- Parameters:
streamId
- Stream id- Returns:
- New stream that can play sequence of items
-
addClientStream
-
removeClientStream
-
getUsedStreamCount
protected int getUsedStreamCount()Getter for used stream count.- Returns:
- Value for property 'usedStreamCount'.
-
getStreamById
Get a stream by its id.- Specified by:
getStreamById
in interfaceIStreamCapableConnection
- Parameters:
streamId
- Stream id- Returns:
- Stream with given id
-
getStreamIdForChannelId
Return stream id for given channel id.- Parameters:
channelId
- Channel id- Returns:
- ID of stream that channel belongs to
-
getStreamByChannelId
Return stream by given channel id.- Parameters:
channelId
- Channel id- Returns:
- Stream that channel belongs to
-
getChannelIdForStreamId
Return channel id for given stream id.- Parameters:
streamId
- Stream id- Returns:
- ID of channel that belongs to the stream
-
createOutputStream
Creates output stream object from stream id. Output stream consists of audio, video, and data channels.- Parameters:
streamId
- Stream id- Returns:
- Output stream object
- See Also:
-
customizeStream
Specify name, connection, scope and etc for stream- Parameters:
streamId
- Stream idstream
- Stream
-
registerStream
Store a stream in the connection.- Parameters:
stream
-
-
unregisterStream
Remove a stream from the connection.- Parameters:
stream
-
-
close
public void close()Closes connection- Specified by:
close
in interfaceIConnection
- Overrides:
close
in classBaseConnection
-
logWarning
public void logWarning() -
logStream
-
dispatchEvent
Dispatches event- Specified by:
dispatchEvent
in interfaceIEventDispatcher
- Overrides:
dispatchEvent
in classBaseConnection
- Parameters:
event
- Event
-
sendPendingServiceCallsCloseError
public void sendPendingServiceCallsCloseError()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. -
unreserveStreamId
Unreserve this id for future use.- Specified by:
unreserveStreamId
in interfaceIStreamCapableConnection
- Parameters:
streamId
- ID of stream to unreserve
-
deleteStreamById
Deletes the stream with the given id.- Specified by:
deleteStreamById
in interfaceIStreamCapableConnection
- Parameters:
streamId
- ID of stream to delete
-
ping
Handler for ping event.- Parameters:
ping
- Ping event context
-
write
Write packet.- Parameters:
out
- Packet
-
writeRaw
public abstract void writeRaw(org.apache.mina.core.buffer.IoBuffer out) Write raw byte buffer.- Parameters:
out
- IoBuffer
-
updateBytesRead
protected void updateBytesRead()Update number of bytes to read next value. -
receivedBytesRead
public void receivedBytesRead(int bytes) Read number of received bytes.- Parameters:
bytes
- Number of bytes
-
getClientBytesRead
public long getClientBytesRead()Get number of bytes the client reported to have received.- Specified by:
getClientBytesRead
in interfaceIConnection
- Overrides:
getClientBytesRead
in classBaseConnection
- Returns:
- Number of bytes
- See Also:
-
invoke
Invokes service using remoting call object.- Specified by:
invoke
in interfaceIServiceCapableConnection
- Parameters:
call
- Service call object
-
getTransactionId
public int getTransactionId()Generate next invoke id.- Returns:
- Next invoke id for RPC
-
registerPendingCall
Register pending call (remote function call that is yet to finish).- Parameters:
invokeId
- Deferred operation idcall
- Call service
-
invoke
Invoke service using call and channel.- Specified by:
invoke
in interfaceIServiceCapableConnection
- Parameters:
call
- Service callchannel
- Channel used
-
invoke
Invoke method by name.- Specified by:
invoke
in interfaceIServiceCapableConnection
- Parameters:
method
- Called method name
-
invoke
Invoke method with parameters.- Specified by:
invoke
in interfaceIServiceCapableConnection
- Parameters:
method
- Method nameparams
- Invocation parameters passed to method
-
invoke
Invoke method by name with callback.- Specified by:
invoke
in interfaceIServiceCapableConnection
- Parameters:
method
- Called method namecallback
- Callback
-
invoke
Invoke method with parameters.- Specified by:
invoke
in interfaceIServiceCapableConnection
- Parameters:
method
- by nameparams
- method paramscallback
- callback
-
notify
Notify method.- Specified by:
notify
in interfaceIServiceCapableConnection
- Parameters:
call
- service call
-
notify
Notify method with channel id.- Specified by:
notify
in interfaceIServiceCapableConnection
- Parameters:
call
- service callchannel
- channel id
-
notify
Notify method.- Specified by:
notify
in interfaceIServiceCapableConnection
- Parameters:
method
- by name
-
notify
Notify method with parameters.- Specified by:
notify
in interfaceIServiceCapableConnection
- Parameters:
method
- by nameparams
- method params
-
status
Sends a status object to the connection.- Specified by:
status
in interfaceIServiceCapableConnection
- Parameters:
status
- Status
-
status
Sends a status object to the connection on a given channel.- Specified by:
status
in interfaceIServiceCapableConnection
- Parameters:
status
- Statuschannel
- channel id
-
getReadBytes
public long getReadBytes()Total number of bytes read from the connection.- Specified by:
getReadBytes
in interfaceIConnection
- Specified by:
getReadBytes
in classBaseConnection
- Returns:
- bytes read
-
getWrittenBytes
public long getWrittenBytes()Total number of bytes written to the connection.- Specified by:
getWrittenBytes
in interfaceIConnection
- Specified by:
getWrittenBytes
in classBaseConnection
- Returns:
- bytes written
-
getPendingCall
Get pending call service by id.- Parameters:
invokeId
- Pending call service id- Returns:
- Pending call service object
-
retrievePendingCall
Retrieves and removes the pending call service by id.- Parameters:
invokeId
- Pending call service id- Returns:
- Pending call service object
-
createStreamName
Generates new stream name.- Returns:
- New stream name
-
writingMessage
Mark message as being written.- Parameters:
message
- Message to mark
-
messageReceived
public void messageReceived()Increases number of read messages by one. Updates number of bytes read. -
getMessageType
-
messageTypeToName
-
handleMessageReceived
Handle the incoming message.- Parameters:
message
- message
-
onTaskAdded
- Specified by:
onTaskAdded
in interfaceIReceivedMessageTaskQueueListener
-
onTaskRemoved
- Specified by:
onTaskRemoved
in interfaceIReceivedMessageTaskQueueListener
-
processTasksQueue
-
messageSent
Mark message as sent.- Parameters:
message
- Message to mark
-
messageDropped
protected void messageDropped()Increases number of dropped messages. -
currentQueueSize
protected int currentQueueSize()Returns the current received message queue size.- Returns:
- current message queue size
-
getPendingVideoMessages
Count of outgoing video messages not yet written.- Specified by:
getPendingVideoMessages
in interfaceIStreamCapableConnection
- Overrides:
getPendingVideoMessages
in classBaseConnection
- Parameters:
streamId
- the id you want to know about- Returns:
- pending messages for this streamId
-
ping
public void ping()Start measuring the round-trip time for a packet on the connection.- Specified by:
ping
in interfaceIConnection
-
pingReceived
Marks that ping back was received.- Parameters:
pong
- Ping object
-
getLastPingSentAndLastPongReceivedInterval
public int getLastPingSentAndLastPongReceivedInterval()Difference between when the last ping was sent and when the last pong was received.- Returns:
- last interval of ping minus pong
-
getLastPingTime
public int getLastPingTime()Return round-trip time of last ping command.- Specified by:
getLastPingTime
in interfaceIConnection
- Returns:
- round-trip time in milliseconds
-
setPingInterval
public void setPingInterval(int pingInterval) Setter for ping interval.- Parameters:
pingInterval
- Interval in ms to ping clients. Set to 0 to disable ghost detection code.
-
setMaxInactivity
public void setMaxInactivity(int maxInactivity) Setter for maximum inactivity.- Parameters:
maxInactivity
- Maximum time in ms after which a client is disconnected in case of inactivity.
-
onInactive
protected abstract void onInactive()Inactive state event handler. -
setScheduler
Sets the scheduler.- Parameters:
scheduler
- scheduling service / thread executor
-
getScheduler
- Returns:
- the scheduler
-
getExecutor
-
setExecutor
-
getDeadlockGuardScheduler
Thread pool for guarding deadlocks- Returns:
- the deadlockGuardScheduler
-
setDeadlockGuardScheduler
Thread pool for guarding deadlocks- Parameters:
deadlockGuardScheduler
- the deadlockGuardScheduler to set
-
registerDeferredResult
Registers deferred result.- Parameters:
result
- Result to register
-
unregisterDeferredResult
Unregister deferred result- Parameters:
result
- Result to unregister
-
rememberStreamBufferDuration
public void rememberStreamBufferDuration(int streamId, int bufferDuration) -
setMaxHandshakeTimeout
public void setMaxHandshakeTimeout(int maxHandshakeTimeout) Set maximum time to wait for valid handshake in milliseconds.- Parameters:
maxHandshakeTimeout
- Maximum time in milliseconds
-
getMaxHandlingTimeout
public long getMaxHandlingTimeout() -
setMaxHandlingTimeout
public void setMaxHandlingTimeout(long maxHandlingTimeout) -
getChannelsInitalCapacity
public int getChannelsInitalCapacity() -
setChannelsInitalCapacity
public void setChannelsInitalCapacity(int channelsInitalCapacity) -
getChannelsConcurrencyLevel
public int getChannelsConcurrencyLevel() -
setChannelsConcurrencyLevel
public void setChannelsConcurrencyLevel(int channelsConcurrencyLevel) -
getStreamsInitalCapacity
public int getStreamsInitalCapacity() -
setStreamsInitalCapacity
public void setStreamsInitalCapacity(int streamsInitalCapacity) -
getStreamsConcurrencyLevel
public int getStreamsConcurrencyLevel() -
setStreamsConcurrencyLevel
public void setStreamsConcurrencyLevel(int streamsConcurrencyLevel) -
getPendingCallsInitalCapacity
public int getPendingCallsInitalCapacity() -
setPendingCallsInitalCapacity
public void setPendingCallsInitalCapacity(int pendingCallsInitalCapacity) -
getPendingCallsConcurrencyLevel
public int getPendingCallsConcurrencyLevel() -
setPendingCallsConcurrencyLevel
public void setPendingCallsConcurrencyLevel(int pendingCallsConcurrencyLevel) -
getReservedStreamsInitalCapacity
public int getReservedStreamsInitalCapacity() -
setReservedStreamsInitalCapacity
public void setReservedStreamsInitalCapacity(int reservedStreamsInitalCapacity) -
getReservedStreamsConcurrencyLevel
public int getReservedStreamsConcurrencyLevel() -
setReservedStreamsConcurrencyLevel
public void setReservedStreamsConcurrencyLevel(int reservedStreamsConcurrencyLevel) -
setExecutorQueueSizeToDropAudioPackets
Specify the size of queue that will trigger audio packet dropping, disabled if it's 0- Parameters:
executorQueueSizeToDropAudioPackets
- queue size
-
getProtocol
Description copied from interface:IConnection
Returns the protocol type for this connection. eg. rtmp, rtmpt, http- Specified by:
getProtocol
in interfaceIConnection
- Returns:
- protocol type
-
toString
-