public abstract class RTMPConnection extends BaseConnection implements IStreamCapableConnection, IServiceCapableConnection
IConnection.Encoding| Modifier and Type | Field and Description |
|---|---|
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 RTMP |
state
protocol state
|
basicScopes, client, closed, droppedMessages, host, params, path, readMessages, remoteAddress, remoteAddresses, remotePort, scope, sessionId, type, writtenMessagesattributesPERSISTENT, POLLING, TRANSIENT| Constructor and Description |
|---|
RTMPConnection(String type)
Creates anonymous RTMP connection without scope.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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 |
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.
|
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.
|
connect, dispatchEvent, getBasicScopes, getClient, getConnectParams, getDroppedMessages, getHost, getLock, getNextClientId, getPath, getPendingMessages, getReadMessages, getRemoteAddress, getRemoteAddresses, getRemotePort, getScope, getSessionId, getType, getWrittenMessages, handleEvent, initialize, isConnected, notifyEvent, registerBasicScope, unregisterBasicScopefilterNull, from, getAttribute, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributesclone, finalize, getClass, notify, notifyAll, wait, wait, waitconnect, getBasicScopes, getClient, getConnectParams, getDroppedMessages, getHost, getPath, getPendingMessages, getReadMessages, getRemoteAddress, getRemoteAddresses, getRemotePort, getScope, getSessionId, getType, getWrittenMessages, initialize, isConnecteddispatchEventhandleEventnotifyEventgetBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttributegetAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributespublic 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
@ConstructorProperties(value="type") public RTMPConnection(String type)
type - Connection typepublic 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 IConnectionpublic boolean connect(IScope newScope, Object[] params)
BaseConnectionconnect in interface IConnectionconnect in class BaseConnectionnewScope - New scopeparams - Parameters to connect withpublic 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 IConnectionpublic int getNextAvailableChannelId()
public boolean isChannelUsed(int channelId)
channelId - Channel idtrue if channel is in use, false
otherwisepublic Channel getChannel(int channelId)
channelId - Channel idpublic void closeChannel(int channelId)
channelId - Channel idprotected Collection<IClientStream> getStreams()
public int reserveStreamId()
reserveStreamId in interface IStreamCapableConnectionpublic int reserveStreamId(int id)
reserveStreamId in interface IStreamCapableConnectionpublic boolean isValidStreamId(int streamId)
streamId - public OutputStream createOutputStream(int streamId)
streamId - Stream idOutputStreampublic IClientBroadcastStream newBroadcastStream(int streamId)
newBroadcastStream in interface IStreamCapableConnectionstreamId - Stream idpublic ISingleItemSubscriberStream newSingleItemSubscriberStream(int streamId)
newSingleItemSubscriberStream in interface IStreamCapableConnectionstreamId - Stream idpublic IPlaylistSubscriberStream newPlaylistSubscriberStream(int streamId)
newPlaylistSubscriberStream in interface IStreamCapableConnectionstreamId - Stream idpublic void addClientStream(IClientStream stream)
public void removeClientStream(int streamId)
protected int getUsedStreamCount()
public IClientStream getStreamById(int id)
getStreamById in interface IStreamCapableConnectionid - Stream idpublic int getStreamIdForChannel(int channelId)
channelId - Channel idpublic IClientStream getStreamByChannelId(int channelId)
channelId - Channel idpublic void close()
close in interface IConnectionclose in class BaseConnectionpublic void sendPendingServiceCallsCloseError()
public void unreserveStreamId(int streamId)
unreserveStreamId in interface IStreamCapableConnectionstreamId - ID of stream to unreservepublic void deleteStreamById(int streamId)
deleteStreamById in interface IStreamCapableConnectionstreamId - 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 IConnectiongetClientBytesRead in class BaseConnectionBytesReadpublic void invoke(IServiceCall call)
invoke in interface IServiceCapableConnectioncall - 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 IServiceCapableConnectioncall - Service callchannel - Channel usedpublic void invoke(String method)
invoke in interface IServiceCapableConnectionmethod - Called method namepublic void invoke(String method, Object[] params)
invoke in interface IServiceCapableConnectionmethod - Method nameparams - Invocation parameters passed to methodpublic void invoke(String method, IPendingServiceCallback callback)
invoke in interface IServiceCapableConnectionmethod - Called method namecallback - Callbackpublic void invoke(String method, Object[] params, IPendingServiceCallback callback)
invoke in interface IServiceCapableConnectionpublic void notify(IServiceCall call)
notify in interface IServiceCapableConnectionpublic void notify(IServiceCall call, int channel)
notify in interface IServiceCapableConnectionpublic void notify(String method)
notify in interface IServiceCapableConnectionpublic void notify(String method, Object[] params)
notify in interface IServiceCapableConnectionpublic long getReadBytes()
getReadBytes in interface IConnectiongetReadBytes in class BaseConnectionpublic long getWrittenBytes()
getWrittenBytes in interface IConnectiongetWrittenBytes in class BaseConnectionpublic IPendingServiceCall getPendingCall(int invokeId)
invokeId - Pending call service idpublic IPendingServiceCall retrievePendingCall(int invokeId)
invokeId - Pending call service idprotected 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 IStreamCapableConnectiongetPendingVideoMessages in class BaseConnectionstreamId - the id you want to know aboutpublic void ping()
ping in interface IConnectionpublic void pingReceived(Ping pong)
pong - Ping objectpublic int getLastPingTime()
getLastPingTime in interface IConnectionpublic 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()
public void setSchedulingService(ISchedulingService schedulingService)
schedulingService - scheduling serviceprotected abstract void onInactive()
public 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 BaseConnectionpublic boolean equals(Object obj)
equals in class BaseConnectionCopyright © 2006-2012 The Red5 Project