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
- Direct Known Subclasses:
RTMPMinaConnection
public abstract class RTMPConnection
extends BaseConnection
implements IStreamCapableConnection, IServiceCapableConnection
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
Nested classes/interfaces inherited from interface org.red5.server.api.IConnection
IConnection.Duty, IConnection.Encoding, IConnection.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longData read intervalprotected ConcurrentMap<Integer, Channel> Connection channelsprotected AtomicLongNumber of bytes the client reported to have received.protected final AtomicBooleanClosing flagprotected Semaphoreprotected RTMPDecodeStateprotected CopyOnWriteArraySet<DeferredResult> Deferred results set.protected Semaphoreprotected org.springframework.scheduling.concurrent.ThreadPoolTaskExecutorThread pool for message handling.protected IRTMPHandlerRTMP events handlerprotected ScheduledFuture<?> Keep alive task.protected AtomicIntegerLast ping round trip timeprotected AtomicLongTimestamp when last ping command was sent.protected AtomicLongTimestamp when last ping result was received.protected intBandwidth limit type / enforcement.static final doubleprotected longMaximum time in milliseconds allowed to process received messageprotected intMaximum time in ms after which a client is disconnected because of inactivity.protected longNumber of bytes to read next.protected final AtomicLongPacket sequence numberprotected ConcurrentMap<Integer, IPendingServiceCall> Hash map that stores pending calls and ids as pairs.protected ConcurrentMap<Number, AtomicInteger> Map for pending video packets keyed by stream id.protected intPing interval in ms to detect dead clients.protected ExecutorServiceExecutor for received RTMP messages.protected Future<?> Future which takes packets from the queue and passes them to the handler.protected LinkedTransferQueue<Packet> Queue for received RTMP packets.protected intReceived packet queue sizeReserved stream ids.static final Stringstatic final Stringstatic final byteMarker byte for encrypted RTMP data.static final byteMarker byte for encrypted RTMP data using Blowfish.static final byteUnknown type 0x0a, seen on youtubestatic final byteMarker byte for encrypted RTMP data XTEA.static final Objectstatic final Stringstatic final byteMarker byte for standard or non-encrypted RTMP data.static final Stringstatic final StringCipher for RTMPE inputstatic final StringCipher for RTMPE outputprotected final AtomicBooleanKeep-alive worker flagprotected org.springframework.scheduling.concurrent.ThreadPoolTaskSchedulerScheduling serviceprotected RTMPProtocol stateprotected ConcurrentMap<Number, IClientStream> Client streamsprotected final AtomicIntegerTimestamp generatorprotected AtomicIntegerTransaction identifier for remote commands.protected ScheduledFuture<?> Wait for handshake task.Fields inherited from class org.red5.server.BaseConnection
basicScopes, client, connectionListeners, droppedMessages, duty, host, params, path, readMessages, remoteAddress, remoteAddresses, remotePort, scope, sessionId, type, writtenMessagesFields inherited from class org.red5.server.AttributeStore
attributes, isDebug, isTrace, log -
Constructor Summary
ConstructorsConstructorDescriptionRTMPConnection(String type) Creates anonymous RTMP connection without scope. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClientStream(IClientStream stream) voidclose()Closes connectionvoidcloseChannel(int channelId) Closes channel.booleanConnect to another scope on server with given parameterscreateOutputStream(Number streamId) Creates output stream object from stream id.protected StringGenerates new stream name.protected intReturns the current received message queue size.voiddeleteStreamById(Number streamId) Deletes the stream with the given id.voiddispatchEvent(IEvent event) Dispatches eventgetChannel(int channelId) Return channel by id.intgetChannelIdForStreamId(Number streamId) Return channel id for given stream id.intintlongGet number of bytes the client reported to have received.org.springframework.scheduling.concurrent.ThreadPoolTaskSchedulerDeprecated, for removal: This API element is subject to removal in a future version.Return AMF protocol encoding used by this connection.org.springframework.scheduling.concurrent.ThreadPoolTaskExecutororg.apache.mina.core.session.IoSessionintDifference between when the last ping was sent and when the last pong was received.intReturn round-trip time of last ping command.longlongintGetter for next available channel id.getPendingCall(int invokeId) Get pending call service by id.intintlonggetPendingVideoMessages(Number streamId) Count of outgoing video messages not yet written.Returns the protocol type for this connection.longTotal number of bytes read from the connection.intintorg.springframework.scheduling.concurrent.ThreadPoolTaskSchedulergetState()bytegetStreamByChannelId(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.intintintgetTimer()Returns a usable timestamp for written packets.intGenerate next invoke id.protected intGetter for used stream count.longTotal number of bytes written to the connection.voidhandleMessageReceived(Packet packet) Handle the incoming message.voidInvoke method by name.voidInvoke method with parameters.voidinvoke(String method, Object[] params, IPendingServiceCallback callback) Invoke method with parameters.voidinvoke(String method, IPendingServiceCallback callback) Invoke method by name with callback.voidinvoke(IServiceCall call) Invokes service using remoting call object.voidinvoke(IServiceCall call, int channel) Invoke service using call and channel.booleanisChannelUsed(int channelId) Checks whether channel is used.booleanCheck whether connection is alivebooleanReturns whether or not the connection is disconnected.booleanbooleanisIdle()Returns whether or not the connection has been idle for a maximum period.booleanisValidStreamId(Number streamId) Returns whether or not a given stream id is valid.protected voidIncreases number of dropped messages.voidIncreases number of read messages by one.voidmessageSent(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.voidNotify method.voidNotify method with parameters.voidnotify(IServiceCall call) Notify method.voidnotify(IServiceCall call, int channel) Notify method with channel id.protected abstract voidInactive state event handler.voidopen()Opens the connection.voidping()Start measuring the round-trip time for a packet on the connection.voidHandler for ping event.voidpingReceived(Ping pong) Marks that ping back was received.voidreceivedBytesRead(int bytes) Read number of received bytes.voidregisterDeferredResult(DeferredResult result) Registers deferred result.voidregisterPendingCall(int invokeId, IPendingServiceCall call) Register pending call (remote function call that is yet to finish).voidrememberStreamBufferDuration(int streamId, int bufferDuration) voidremoveClientStream(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.voidWhen the connection has been closed, notify any remaining pending service calls that they have failed because the connection is broken.voidsendSharedObjectMessage(String name, int currentVersion, boolean persistent, Set<ISharedObjectEvent> events) Send a shared object message.voidsetBandwidth(int mbits) Sets the bandwidth using a mbit/s value.voidsetChannelsConcurrencyLevel(int channelsConcurrencyLevel) voidsetChannelsInitalCapacity(int channelsInitalCapacity) voidsetDeadlockGuardScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler deadlockGuardScheduler) Deprecated, for removal: This API element is subject to removal in a future version.voidsetEncrypted(boolean encrypted) voidsetExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor executor) voidsetExecutorQueueSizeToDropAudioPackets(Integer executorQueueSizeToDropAudioPackets) Deprecated, for removal: This API element is subject to removal in a future version.voidsetHandler(IRTMPHandler handler) voidsetMaxHandlingTimeout(long maxHandlingTimeout) voidsetMaxHandshakeTimeout(int maxHandshakeTimeout) Set maximum time to wait for valid handshake in milliseconds.voidsetMaxInactivity(int maxInactivity) Setter for maximum inactivity.voidsetMaxPollTimeout(long maxPollTimeout) voidsetPendingCallsConcurrencyLevel(int pendingCallsConcurrencyLevel) voidsetPendingCallsInitalCapacity(int pendingCallsInitalCapacity) voidsetPingInterval(int pingInterval) Setter for ping interval.voidsetReservedStreamsConcurrencyLevel(int reservedStreamsConcurrencyLevel) voidsetReservedStreamsInitalCapacity(int reservedStreamsInitalCapacity) voidsetScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler scheduler) Sets the scheduler.voidsetStateCode(byte stateCode) Sets the state by code and fires property chanage notifications.voidsetStreamsConcurrencyLevel(int streamsConcurrencyLevel) voidsetStreamsInitalCapacity(int streamsInitalCapacity) voidInitialize connection.voidStart waiting for a valid handshake.voidSends a status object to the connection.voidSends a status object to the connection on a given channel.toString()voidUnregister deferred resultvoidunreserveStreamId(Number streamId) Unreserve this id for future use.protected voidUpdate number of bytes to read next value.abstract voidWrite packet.abstract voidwriteRaw(org.apache.mina.core.buffer.IoBuffer out) Write raw byte buffer.protected voidwritingMessage(Packet message) Mark message as being written.Methods inherited from class org.red5.server.BaseConnection
addListener, connect, disconnect, equals, getBasicScopes, getClient, getConnectParams, getDroppedMessages, getDuty, getHost, getId, getLock, getPath, getPendingMessages, getReadMessages, getRemoteAddress, getRemoteAddresses, getRemotePort, getScope, getSessionId, getStreamId, getType, getWrittenMessages, handleEvent, hashCode, initialize, isClosed, isReaderIdle, isWriterIdle, notifyEvent, notifyPropertyChanged, registerBasicScope, registerBasicScope, removeListener, setClient, setDuty, setId, setStreamId, uninitialize, unregisterBasicScopeMethods inherited from class org.red5.server.AttributeStore
filterNull, from, getAttribute, getAttribute, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute, hasAttribute, removeAttribute, removeAttribute, removeAttributes, setAttribute, setAttribute, setAttributes, setAttributes, sizeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.red5.server.api.IAttributeStore
getAttribute, getAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, hasAttribute, removeAttribute, removeAttribute, removeAttributes, setAttribute, setAttribute, setAttributes, setAttributes, sizeMethods inherited from interface org.red5.server.api.ICastingAttributeStore
getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttributeMethods inherited from interface org.red5.server.api.IConnection
addListener, connect, getBasicScopes, getClient, getConnectParams, getDroppedMessages, getDuty, getHost, getPath, getPendingMessages, getReadMessages, getRemoteAddress, getRemoteAddresses, getRemotePort, getScope, getSessionId, getStreamId, getType, getWrittenMessages, initialize, removeListener, setClient, setStreamId, uninitializeMethods inherited from interface org.red5.server.api.event.IEventHandler
handleEventMethods inherited from interface org.red5.server.api.event.IEventListener
notifyEvent
-
Field Details
-
RTMP_SESSION_ID
- See Also:
-
RTMP_HANDSHAKE
- See Also:
-
RTMP_BUFFER
- 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:
-
channels
Connection channels- See Also:
-
streams
Client streams- See Also:
-
reservedStreams
Reserved stream ids. Stream id's directly relate to individual NetStream instances. -
receivedQueueSize
protected volatile int receivedQueueSizeReceived packet queue size -
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
protected 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. -
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
protected transient org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler schedulerScheduling service -
executor
protected transient org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor executorThread pool for message handling. -
running
Keep-alive worker flag -
timer
Timestamp generator -
closing
Closing flag -
packetSequence
Packet sequence number -
waitForHandshakeTask
Wait for handshake task. -
keepAliveTask
Keep alive task. -
receivedPacketExecutor
Executor for received RTMP messages. -
receivedPacketFuture
Future which takes packets from the queue and passes them to the handler. -
receivedPacketQueue
Queue for received RTMP packets. This is a transfer queue from which packets are passed to a handler.
-
-
Constructor Details
-
RTMPConnection
Creates anonymous RTMP connection without scope.- Parameters:
type- Connection type
-
-
Method Details
-
setHandler
-
getHandler
-
getState
-
getStateCode
public byte getStateCode() -
setStateCode
public void setStateCode(byte stateCode) Sets the state by code and fires property chanage notifications.- Parameters:
stateCode-
-
getIoSession
public org.apache.mina.core.session.IoSession getIoSession() -
setEncrypted
public void setEncrypted(boolean encrypted) -
isEncrypted
public boolean isEncrypted() -
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:
setBandwidthin 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:BaseConnectionConnect to another scope on server with given parameters- Specified by:
connectin interfaceIConnection- Overrides:
connectin 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. -
setup
Initialize connection.- Parameters:
host- Connection hostpath- Connection pathparams- Params passed from client
-
getEncoding
Return AMF protocol encoding used by this connection.- Specified by:
getEncodingin 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:
getStreamsMapin interfaceIStreamCapableConnection
-
reserveStreamId
Return a reserved stream id for use. According to FCS/FMS regulation, the base is 1.- Specified by:
reserveStreamIdin interfaceIStreamCapableConnection- Returns:
- Reserved stream id
-
reserveStreamId
Return a reserved stream id for use with a preference for the one supplied.- Specified by:
reserveStreamIdin 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.- Overrides:
isIdlein classBaseConnection- Returns:
- true if max idle period has been exceeded, false otherwise
-
isConnected
public boolean isConnected()Check whether connection is alive- Specified by:
isConnectedin interfaceIConnection- Overrides:
isConnectedin classBaseConnection- Returns:
- true if connection is scope bound and state is not DISCONNECTED, false otherwise
-
isDisconnected
public boolean isDisconnected()Returns whether or not the connection is disconnected.- Overrides:
isDisconnectedin classBaseConnection- Returns:
- true if connection is not scope bound and state is DISCONNECTED, false otherwise
-
newBroadcastStream
Create a broadcast stream.- Specified by:
newBroadcastStreamin interfaceIStreamCapableConnection- Parameters:
streamId- Stream id- Returns:
- New broadcast stream
-
newSingleItemSubscriberStream
Create a stream that can play only one item.- Specified by:
newSingleItemSubscriberStreamin 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:
newPlaylistSubscriberStreamin 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:
getStreamByIdin 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:
-
close
public void close()Closes connection- Specified by:
closein interfaceIConnection- Overrides:
closein classBaseConnection
-
dispatchEvent
Dispatches event- Specified by:
dispatchEventin interfaceIEventDispatcher- Overrides:
dispatchEventin 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:
unreserveStreamIdin interfaceIStreamCapableConnection- Parameters:
streamId- ID of stream to unreserve
-
deleteStreamById
Deletes the stream with the given id.- Specified by:
deleteStreamByIdin 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:
getClientBytesReadin interfaceIConnection- Overrides:
getClientBytesReadin classBaseConnection- Returns:
- Number of bytes
- See Also:
-
invoke
Invokes service using remoting call object.- Specified by:
invokein 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:
invokein interfaceIServiceCapableConnection- Parameters:
call- Service callchannel- Channel used
-
invoke
Invoke method by name.- Specified by:
invokein interfaceIServiceCapableConnection- Parameters:
method- Called method name
-
invoke
Invoke method with parameters.- Specified by:
invokein interfaceIServiceCapableConnection- Parameters:
method- Method nameparams- Invocation parameters passed to method
-
invoke
Invoke method by name with callback.- Specified by:
invokein interfaceIServiceCapableConnection- Parameters:
method- Called method namecallback- Callback
-
invoke
Invoke method with parameters.- Specified by:
invokein interfaceIServiceCapableConnection- Parameters:
method- by nameparams- method paramscallback- callback
-
notify
Notify method.- Specified by:
notifyin interfaceIServiceCapableConnection- Parameters:
call- service call
-
notify
Notify method with channel id.- Specified by:
notifyin interfaceIServiceCapableConnection- Parameters:
call- service callchannel- channel id
-
notify
Notify method.- Specified by:
notifyin interfaceIServiceCapableConnection- Parameters:
method- by name
-
notify
Notify method with parameters.- Specified by:
notifyin interfaceIServiceCapableConnection- Parameters:
method- by nameparams- method params
-
status
Sends a status object to the connection.- Specified by:
statusin interfaceIServiceCapableConnection- Parameters:
status- Status
-
status
Sends a status object to the connection on a given channel.- Specified by:
statusin interfaceIServiceCapableConnection- Parameters:
status- Statuschannel- channel id
-
getReadBytes
public long getReadBytes()Total number of bytes read from the connection.- Specified by:
getReadBytesin interfaceIConnection- Specified by:
getReadBytesin classBaseConnection- Returns:
- bytes read
-
getWrittenBytes
public long getWrittenBytes()Total number of bytes written to the connection.- Specified by:
getWrittenBytesin interfaceIConnection- Specified by:
getWrittenBytesin 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. -
messageTypeToName
-
handleMessageReceived
Handle the incoming message.- Parameters:
packet- incoming message packet
-
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:
getPendingVideoMessagesin interfaceIStreamCapableConnection- Overrides:
getPendingVideoMessagesin 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:
pingin 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:
getLastPingTimein 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
public void setScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler scheduler) Sets the scheduler.- Parameters:
scheduler- scheduling service / thread executor
-
getScheduler
public org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler getScheduler()- Returns:
- the scheduler
-
getExecutor
public org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor getExecutor() -
setExecutor
public void setExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor executor) -
getDeadlockGuardScheduler
@Deprecated(since="1.3.29", forRemoval=true) public org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler getDeadlockGuardScheduler()Deprecated, for removal: This API element is subject to removal in a future version.Thread pool for guarding deadlocks- Returns:
- the deadlockGuardScheduler
-
setDeadlockGuardScheduler
@Deprecated(since="1.3.29", forRemoval=true) public void setDeadlockGuardScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler deadlockGuardScheduler) Deprecated, for removal: This API element is subject to removal in a future version.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) -
getMaxPollTimeout
public long getMaxPollTimeout() -
setMaxPollTimeout
public void setMaxPollTimeout(long maxPollTimeout) -
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
@Deprecated(since="1.3.29", forRemoval=true) public void setExecutorQueueSizeToDropAudioPackets(Integer executorQueueSizeToDropAudioPackets) Deprecated, for removal: This API element is subject to removal in a future version.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:IConnectionReturns the protocol type for this connection. eg. rtmp, rtmpt, http- Specified by:
getProtocolin interfaceIConnection- Returns:
- protocol type
-
toString
-