|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.red5.server.AttributeStore
org.red5.server.BaseConnection
org.red5.server.net.rtmp.RTMPConnection
public abstract class RTMPConnection
RTMP connection. Stores information about client streams, data transfer channels, pending RPC calls, bandwidth configuration, used encoding (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.Encoding |
Field Summary | |
---|---|
protected int |
bytesReadInterval
Data read interval |
protected int |
clientId
|
protected int |
limitType
Bandwidth limit type / enforcement. |
protected int |
nextBytesRead
Number of bytes to read next. |
static String |
RTMP_CONNECTION_KEY
|
static byte |
RTMP_ENCRYPTED
Marker byte for encrypted RTMP data. |
static String |
RTMP_HANDSHAKE
|
static byte |
RTMP_NON_ENCRYPTED
Marker byte for standard or non-encrypted RTMP data. |
static String |
RTMPE_CIPHER_IN
Cipher for RTMPE input |
static String |
RTMPE_CIPHER_OUT
Cipher for RTMPE output |
protected ISchedulingService |
schedulingService
Scheduling service |
protected RTMP |
state
Protocol state |
Fields inherited from class org.red5.server.BaseConnection |
---|
basicScopes, client, closed, 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 | |
---|---|
RTMPConnection(String type)
Creates anonymous RTMP connection without scope. |
Method Summary | |
---|---|
void |
addClientStream(IClientStream stream)
|
void |
close()
Closes connection |
void |
closeChannel(int channelId)
Closes channel. |
boolean |
connect(IScope newScope,
Object[] params)
Connect to another scope on server with given parameters |
OutputStream |
createOutputStream(int streamId)
Creates output stream object from stream id. |
protected String |
createStreamName()
Generates new stream name. |
void |
deleteStreamById(int streamId)
Deletes the stream with the given id. |
boolean |
equals(Object obj)
|
Channel |
getChannel(int channelId)
Return channel by id. |
long |
getClientBytesRead()
Get number of bytes the client reported to have received. |
IConnection.Encoding |
getEncoding()
Return AMF protocol encoding used by this connection. |
int |
getId()
|
int |
getInvokeId()
Generate next invoke id. |
int |
getLastPingTime()
Return roundtrip time of last ping command. |
int |
getNextAvailableChannelId()
Getter for next available channel id. |
IPendingServiceCall |
getPendingCall(int invokeId)
Get pending call service by id. |
long |
getPendingVideoMessages(int streamId)
Total number of video messages that are pending to be sent to a stream. |
long |
getReadBytes()
Total number of bytes read from the connection. |
RTMP |
getState()
|
byte |
getStateCode()
|
IClientStream |
getStreamByChannelId(int channelId)
Return stream by given channel id. |
IClientStream |
getStreamById(int id)
Get a stream by its id. |
int |
getStreamIdForChannel(int channelId)
Return stream id for given channel id. |
protected Collection<IClientStream> |
getStreams()
Getter for client streams. |
int |
getTimer()
Returns a usable timestamp for written packets. |
protected int |
getUsedStreamCount()
Getter for used stream count. |
long |
getWrittenBytes()
Total number of bytes written to the connection. |
int |
hashCode()
|
void |
invoke(IServiceCall call)
Invokes service using remoting call object |
void |
invoke(IServiceCall call,
int channel)
Invoke service using call and channel |
void |
invoke(String method)
Invoke method by name |
void |
invoke(String method,
IPendingServiceCallback callback)
Invoke method by name with callback |
void |
invoke(String method,
Object[] params)
Invoke method with parameters |
void |
invoke(String method,
Object[] params,
IPendingServiceCallback callback)
|
boolean |
isChannelUsed(int channelId)
Checks whether channel is used. |
boolean |
isValidStreamId(int streamId)
Returns whether or not a given stream id is valid. |
protected void |
messageDropped()
Increases number of dropped messages. |
void |
messageReceived()
Increases number of read messages by one. |
void |
messageSent(Packet message)
Mark message as sent. |
IClientBroadcastStream |
newBroadcastStream(int streamId)
Create a broadcast stream. |
IPlaylistSubscriberStream |
newPlaylistSubscriberStream(int streamId)
Create a stream that can play a list. |
ISingleItemSubscriberStream |
newSingleItemSubscriberStream(int streamId)
Create a stream that can play only one item. |
void |
notify(IServiceCall call)
|
void |
notify(IServiceCall call,
int channel)
|
void |
notify(String method)
|
void |
notify(String method,
Object[] params)
|
protected abstract void |
onInactive()
Inactive state event handler. |
void |
ping()
Start measuring the roundtrip time for a packet on the connection. |
void |
ping(Ping ping)
Handler for ping event. |
void |
pingReceived(Ping pong)
Marks that ping back was received. |
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). |
void |
rememberStreamBufferDuration(int streamId,
int bufferDuration)
|
void |
removeClientStream(int streamId)
|
int |
reserveStreamId()
Return a reserved stream id for use. |
int |
reserveStreamId(int id)
|
IPendingServiceCall |
retrievePendingCall(int invokeId)
Retrieves and removes the pending call service by id. |
void |
sendPendingServiceCallsCloseError()
When the connection has been closed, notify any remaining pending service calls that they have failed because the connection is broken. |
void |
sendSharedObjectMessage(String name,
int currentVersion,
boolean persistent,
ConcurrentLinkedQueue<ISharedObjectEvent> events)
Send a shared object message. |
void |
setBandwidth(int mbits)
Sets the bandwidth using a mbit/s value. |
void |
setId(int clientId)
|
void |
setMaxHandshakeTimeout(int maxHandshakeTimeout)
Set maximum time to wait for valid handshake in milliseconds. |
void |
setMaxInactivity(int maxInactivity)
Setter for maximum inactivity. |
void |
setPingInterval(int pingInterval)
Setter for ping interval. |
void |
setSchedulingService(ISchedulingService schedulingService)
Sets the scheduling service. |
void |
setState(RTMP state)
|
void |
setStateCode(byte code)
|
void |
setup(String host,
String path,
String sessionId,
Map<String,Object> params)
Initialize connection. |
void |
startRoundTripMeasurement()
Starts measurement. |
protected void |
startWaitForHandshake(ISchedulingService service)
Start waiting for a valid handshake. |
void |
status(Status status)
Sends a status object to the connection |
void |
status(Status status,
int channel)
Sends a status object to the connection on a given channel |
String |
toString()
|
void |
unregisterDeferredResult(DeferredResult result)
Unregister deferred result |
void |
unreserveStreamId(int streamId)
Unreserve this id for future use. |
protected void |
updateBytesRead()
Update number of bytes to read next value. |
abstract void |
write(Packet out)
Write packet. |
abstract void |
writeRaw(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, dispatchEvent, getBasicScopes, getClient, getConnectParams, getDroppedMessages, getHost, getLock, getNextClientId, getPath, getPendingMessages, getReadMessages, getRemoteAddress, getRemoteAddresses, getRemotePort, getScope, getSessionId, getType, getWrittenMessages, handleEvent, initialize, isConnected, isReaderIdle, isWriterIdle, notifyEvent, registerBasicScope, removeListener, 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.IConnection |
---|
addListener, connect, getBasicScopes, getClient, getConnectParams, getDroppedMessages, getHost, getPath, getPendingMessages, getReadMessages, getRemoteAddress, getRemoteAddresses, getRemotePort, getScope, getSessionId, getType, getWrittenMessages, initialize, isConnected, removeListener |
Methods inherited from interface org.red5.server.api.event.IEventDispatcher |
---|
dispatchEvent |
Methods inherited from interface org.red5.server.api.event.IEventHandler |
---|
handleEvent |
Methods inherited from interface org.red5.server.api.event.IEventListener |
---|
notifyEvent |
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.IAttributeStore |
---|
getAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes, size |
Field Detail |
---|
public static final String RTMP_CONNECTION_KEY
public static final String RTMP_HANDSHAKE
public static final byte RTMP_NON_ENCRYPTED
public static final byte RTMP_ENCRYPTED
public static final String RTMPE_CIPHER_IN
public static final String RTMPE_CIPHER_OUT
protected int bytesReadInterval
protected int nextBytesRead
protected int limitType
protected volatile int clientId
protected volatile RTMP state
protected ISchedulingService schedulingService
Constructor Detail |
---|
@ConstructorProperties(value="type") public RTMPConnection(String type)
type
- Connection typeMethod Detail |
---|
public int getId()
public void setId(int clientId)
public RTMP getState()
public byte getStateCode()
public void setStateCode(byte code)
public void setState(RTMP state)
public void setBandwidth(int mbits)
setBandwidth
in interface IConnection
public int getTimer()
public boolean connect(IScope newScope, Object[] params)
BaseConnection
connect
in interface IConnection
connect
in class BaseConnection
newScope
- New scopeparams
- Parameters to connect with
public void setup(String host, String path, String sessionId, Map<String,Object> params)
host
- Connection hostpath
- Connection pathsessionId
- Connection session idparams
- Params passed from clientpublic IConnection.Encoding getEncoding()
getEncoding
in interface IConnection
public int getNextAvailableChannelId()
public boolean isChannelUsed(int channelId)
channelId
- Channel id
true
if channel is in use, false
otherwisepublic Channel getChannel(int channelId)
channelId
- Channel id
public void closeChannel(int channelId)
channelId
- Channel idprotected Collection<IClientStream> getStreams()
public int reserveStreamId()
reserveStreamId
in interface IStreamCapableConnection
public int reserveStreamId(int id)
reserveStreamId
in interface IStreamCapableConnection
public boolean isValidStreamId(int streamId)
streamId
-
public OutputStream createOutputStream(int streamId)
streamId
- Stream id
OutputStream
public IClientBroadcastStream newBroadcastStream(int streamId)
newBroadcastStream
in interface IStreamCapableConnection
streamId
- Stream id
public ISingleItemSubscriberStream newSingleItemSubscriberStream(int streamId)
newSingleItemSubscriberStream
in interface IStreamCapableConnection
streamId
- Stream id
public IPlaylistSubscriberStream newPlaylistSubscriberStream(int streamId)
newPlaylistSubscriberStream
in interface IStreamCapableConnection
streamId
- Stream id
public void addClientStream(IClientStream stream)
public void removeClientStream(int streamId)
protected int getUsedStreamCount()
public IClientStream getStreamById(int id)
getStreamById
in interface IStreamCapableConnection
id
- Stream id
public int getStreamIdForChannel(int channelId)
channelId
- Channel id
public IClientStream getStreamByChannelId(int channelId)
channelId
- Channel id
public void close()
close
in interface IConnection
close
in class BaseConnection
public void sendPendingServiceCallsCloseError()
public void unreserveStreamId(int streamId)
unreserveStreamId
in interface IStreamCapableConnection
streamId
- ID of stream to unreservepublic void deleteStreamById(int streamId)
deleteStreamById
in interface IStreamCapableConnection
streamId
- ID of stream to deletepublic void ping(Ping ping)
ping
- Ping event contextpublic abstract void write(Packet out)
out
- Packetpublic abstract void writeRaw(IoBuffer out)
out
- IoBufferprotected void updateBytesRead()
public void receivedBytesRead(int bytes)
bytes
- Number of bytespublic long getClientBytesRead()
getClientBytesRead
in interface IConnection
getClientBytesRead
in class BaseConnection
BytesRead
public void invoke(IServiceCall call)
invoke
in interface IServiceCapableConnection
call
- Service call objectpublic int getInvokeId()
public void registerPendingCall(int invokeId, IPendingServiceCall call)
invokeId
- Deferred operation idcall
- Call servicepublic void invoke(IServiceCall call, int channel)
invoke
in interface IServiceCapableConnection
call
- Service callchannel
- Channel usedpublic void invoke(String method)
invoke
in interface IServiceCapableConnection
method
- Called method namepublic void invoke(String method, Object[] params)
invoke
in interface IServiceCapableConnection
method
- Method nameparams
- Invocation parameters passed to methodpublic void invoke(String method, IPendingServiceCallback callback)
invoke
in interface IServiceCapableConnection
method
- Called method namecallback
- Callbackpublic void invoke(String method, Object[] params, IPendingServiceCallback callback)
invoke
in interface IServiceCapableConnection
public void notify(IServiceCall call)
notify
in interface IServiceCapableConnection
public void notify(IServiceCall call, int channel)
notify
in interface IServiceCapableConnection
public void notify(String method)
notify
in interface IServiceCapableConnection
public void notify(String method, Object[] params)
notify
in interface IServiceCapableConnection
public void status(Status status)
status
in interface IServiceCapableConnection
public void status(Status status, int channel)
status
in interface IServiceCapableConnection
public long getReadBytes()
getReadBytes
in interface IConnection
getReadBytes
in class BaseConnection
public long getWrittenBytes()
getWrittenBytes
in interface IConnection
getWrittenBytes
in class BaseConnection
public IPendingServiceCall getPendingCall(int invokeId)
invokeId
- Pending call service id
public IPendingServiceCall retrievePendingCall(int invokeId)
invokeId
- Pending call service id
protected String createStreamName()
protected void writingMessage(Packet message)
message
- Message to markpublic void messageReceived()
public void messageSent(Packet message)
message
- Message to markprotected void messageDropped()
public long getPendingVideoMessages(int streamId)
getPendingVideoMessages
in interface IStreamCapableConnection
getPendingVideoMessages
in class BaseConnection
streamId
- the id you want to know about
public void sendSharedObjectMessage(String name, int currentVersion, boolean persistent, ConcurrentLinkedQueue<ISharedObjectEvent> events)
name
- shared object namecurrentVersion
- the current versionpersistent
- events
- public void ping()
ping
in interface IConnection
public void pingReceived(Ping pong)
pong
- Ping objectpublic int getLastPingTime()
getLastPingTime
in interface IConnection
public void setPingInterval(int pingInterval)
pingInterval
- Interval in ms to ping clients. Set to 0
to
disable ghost detection code.public void setMaxInactivity(int maxInactivity)
maxInactivity
- Maximum time in ms after which a client is disconnected in
case of inactivity.public void startRoundTripMeasurement()
protected abstract void onInactive()
public void setSchedulingService(ISchedulingService schedulingService)
schedulingService
- scheduling servicepublic void registerDeferredResult(DeferredResult result)
result
- Result to registerpublic void unregisterDeferredResult(DeferredResult result)
result
- Result to unregisterpublic void rememberStreamBufferDuration(int streamId, int bufferDuration)
public void setMaxHandshakeTimeout(int maxHandshakeTimeout)
maxHandshakeTimeout
- Maximum time in millisecondsprotected void startWaitForHandshake(ISchedulingService service)
service
- The scheduling service to usepublic int hashCode()
hashCode
in class BaseConnection
public boolean equals(Object obj)
equals
in class BaseConnection
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |