Package org.red5.server.stream
Class ClientBroadcastStream
java.lang.Object
org.red5.server.stream.AbstractStream
org.red5.server.stream.AbstractClientStream
org.red5.server.stream.ClientBroadcastStream
- All Implemented Interfaces:
IEventDispatcher,IClientBroadcastStreamStatistics,IStatisticsBase,IStreamStatistics,IBroadcastStream,IClientBroadcastStream,IClientStream,IStream,ClientBroadcastStreamMXBean,IConsumer,IFilter,IMessageComponent,IPipeConnectionListener,IProvider,IPushableConsumer
@ManagedResource(objectName="org.red5.server:type=ClientBroadcastStream",
description="ClientBroadcastStream")
public class ClientBroadcastStream
extends AbstractClientStream
implements IClientBroadcastStream, IFilter, IPushableConsumer, IPipeConnectionListener, IEventDispatcher, IClientBroadcastStreamStatistics, ClientBroadcastStreamMXBean
Represents live stream broadcasted from client. As Flash Media Server, Red5 supports recording mode for live streams, that is,
broadcasted stream has broadcast mode. It can be either "live" or "record" and latter causes server-side application to record
broadcasted stream.
Note that recorded streams are recorded as FLV files.
This type of stream uses two different pipes for live streaming and recording.
- Author:
- The Red5 Project, Steven Gong, Paul Gregoire (mondain@gmail.com), Vladimir Hmelyoff (vlhm@splitmedialabs.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CopyOnWriteArraySet<String> Subscribe aliases for this instance.protected booleanWhether or not to automatically record the associated stream.protected longTotal number of bytes received.protected booleanIs there need to check audio codec?protected booleanIs there need to check video codec?protected intData is sent by chunks, each of them has sizeprotected AtomicBooleanIs this stream still active?protected IMessageOutputOutput endpoint that providers useprotected longStores timestamp of first packetprotected longprotected Set<IStreamListener> Listeners to get notified about received packets.protected IPipePipe for live streamingprotected static CopyOnWriteArraySet<String> Stream name aliases for the entire server instance.protected StringPublish alias for the stream name.Streaming parametersprotected StringStream published nameprotected WeakReference<IRecordingListener> Recording listenerprotected booleanWhether or not to register with JMX.protected booleanIs there need to send start notification?Fields inherited from class org.red5.server.stream.AbstractStream
codecInfo, creationTime, metaData, startTime, state, stateListenersFields inherited from interface org.red5.server.api.stream.IClientStream
MODE_APPEND, MODE_LIVE, MODE_PUBLISH, MODE_READ, MODE_RECORDFields inherited from interface org.red5.server.messaging.IPushableConsumer
KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a stream name subscribe-side alias.voidaddStreamListener(IStreamListener listener) Add a listener to be notified about received packets.booleanaliasRegistered(String alias) Returns whether or not an alias is in-use / registered already; this includes both publish and subscribe aliases within a server instance.protected voidcheckSendNotifications(IEvent event) Check and send notification if necessaryvoidclose()Closes stream, unsubscribes provides, sends stoppage notifications and broadcast close notification.booleancontainsAlias(String alias) Returns whether or not a given subscribe-side alias exists.voiddispatchEvent(IEvent event) Dispatches eventintReturn current number of subscribers.getAlias()Returns an subscribe-side alias.Returns all the subscribe-side aliases.longReturn total number of bytes received from client for this stream.intReturn the currently active timestamp inside the stream.intReturn maximum number of concurrent subscribers.Returns the publish-side alias, if configured.Returns streaming parameters.Getter for providerGetter for published nameprotected FilegetRecordFile(IScope scope, String name) Get the file we'd be recording to based on scope and given name.Get the filename the stream is being saved as.Return statistics about the stream.Return registered stream listeners.intReturn total number of subscribers.booleanhasAlias()Returns whether or not an subscribe-side alias for this stream exists.booleanbooleanprotected voidNotifies handler on stream broadcast closeprotected voidNotifies handler on stream broadcast startprotected voidSend OOB control message with chunk sizeprotected voidNotifies handler on stream recording stopvoidonOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) Out-of-band control message handlervoidPipe connection event handlervoidpushMessage(IPipe pipe, IMessage message) Currently not implementedprotected voidpushMessage(StatusMessage msg) Pushes a message out to a consumer.protected voidvoidremoveStreamListener(IStreamListener listener) Remove a listener from being notified about received packets.voidSave broadcasted stream.protected voidSends publish start notificationsprotected voidSends publish stop notificationsprotected voidsendRecordFailedNotify(String reason) Sends record failed notificationsprotected voidSends record start notificationsprotected voidSends record stop notificationsprotected voidsendStartNotifications(IEventListener source) voidsetAutomaticRecording(boolean automaticRecording) voidsetNameAlias(String nameAlias) Sets the publish-side alias for the streams name.voidsetParameters(Map<String, String> params) Sets streaming parameters as supplied by the publishing application.voidsetPublishedName(String name) Setter for stream published namevoidsetRegisterJMX(boolean registerJMX) voidstart()Starts stream, creates pipes, connectsvoidNotify client that stream is ready for publishing.voidstop()Stop this stream.voidStops any currently active recording.protected voidMethods inherited from class org.red5.server.stream.AbstractClientStream
getBroadcastStreamPublishName, getClientBufferDuration, getConnection, getStreamId, setBroadcastStreamPublishName, setClientBufferDuration, setConnection, setStreamId, setStreamIdMethods inherited from class org.red5.server.stream.AbstractStream
addStateChangeListener, fireStateChange, getCodecInfo, getCreationTime, getMetaData, getName, getScope, getStartTime, getState, getStreamAwareHandler, removeStateChangeListener, setCodecInfo, setMetaData, setName, setScope, setStateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.red5.server.api.stream.IBroadcastStream
getMetaDataMethods inherited from interface org.red5.server.api.stream.IClientStream
getBroadcastStreamPublishName, getClientBufferDuration, getConnection, getStreamId, setBroadcastStreamPublishName, setClientBufferDurationMethods inherited from interface org.red5.server.api.statistics.IStatisticsBase
getCreationTimeMethods inherited from interface org.red5.server.api.stream.IStream
getCodecInfo, getCreationTime, getName, getScope, getStartTime
-
Field Details
-
automaticRecording
protected boolean automaticRecordingWhether or not to automatically record the associated stream. -
bytesReceived
protected volatile long bytesReceivedTotal number of bytes received. -
checkVideoCodec
protected volatile boolean checkVideoCodecIs there need to check video codec? -
checkAudioCodec
protected volatile boolean checkAudioCodecIs there need to check audio codec? -
chunkSize
protected int chunkSizeData is sent by chunks, each of them has size -
closed
Is this stream still active? -
connMsgOut
Output endpoint that providers use -
firstPacketTime
protected long firstPacketTimeStores timestamp of first packet -
livePipe
Pipe for live streaming -
publishedName
Stream published name -
parameters
Streaming parameters -
sendStartNotification
protected boolean sendStartNotificationIs there need to send start notification? -
listeners
Listeners to get notified about received packets. -
recordingListener
Recording listener -
latestTimeStamp
protected volatile long latestTimeStamp -
registerJMX
protected boolean registerJMXWhether or not to register with JMX. -
localAliases
Stream name aliases for the entire server instance. -
nameAlias
Publish alias for the stream name. -
aliases
Subscribe aliases for this instance.
-
-
Constructor Details
-
ClientBroadcastStream
public ClientBroadcastStream()
-
-
Method Details
-
checkSendNotifications
Check and send notification if necessary- Parameters:
event- Event
-
close
public void close()Closes stream, unsubscribes provides, sends stoppage notifications and broadcast close notification.- Specified by:
closein interfaceClientBroadcastStreamMXBean- Specified by:
closein interfaceIStream
-
dispatchEvent
Dispatches event- Specified by:
dispatchEventin interfaceIEventDispatcher- Parameters:
event- Event to dispatch
-
getActiveSubscribers
public int getActiveSubscribers()Return current number of subscribers.- Specified by:
getActiveSubscribersin interfaceIClientBroadcastStreamStatistics- Returns:
- number of subscribers
-
getBytesReceived
public long getBytesReceived()Return total number of bytes received from client for this stream.- Specified by:
getBytesReceivedin interfaceIClientBroadcastStreamStatistics- Returns:
- number of bytes
-
getCurrentTimestamp
public int getCurrentTimestamp()Return the currently active timestamp inside the stream.- Specified by:
getCurrentTimestampin interfaceIStreamStatistics- Returns:
- the timestamp in milliseconds
-
getMaxSubscribers
public int getMaxSubscribers()Return maximum number of concurrent subscribers.- Specified by:
getMaxSubscribersin interfaceIClientBroadcastStreamStatistics- Returns:
- number of subscribers
-
getProvider
Getter for provider- Specified by:
getProviderin interfaceIBroadcastStream- Returns:
- Provider
-
setPublishedName
Setter for stream published name- Specified by:
setPublishedNamein interfaceClientBroadcastStreamMXBean- Specified by:
setPublishedNamein interfaceIBroadcastStream- Parameters:
name- Name that used for publishing. Set at client side when begin to broadcast with NetStream#publish.
-
getPublishedName
Getter for published name- Specified by:
getPublishedNamein interfaceClientBroadcastStreamMXBean- Specified by:
getPublishedNamein interfaceIBroadcastStream- Specified by:
getPublishedNamein interfaceIClientBroadcastStreamStatistics- Returns:
- Stream published name
-
setParameters
Sets streaming parameters as supplied by the publishing application.- Specified by:
setParametersin interfaceIClientBroadcastStream- Parameters:
params- parameter map
-
getParameters
Returns streaming parameters.- Specified by:
getParametersin interfaceIClientBroadcastStream- Returns:
- parameters
-
getSaveFilename
Get the filename the stream is being saved as.- Specified by:
getSaveFilenamein interfaceClientBroadcastStreamMXBean- Specified by:
getSaveFilenamein interfaceIBroadcastStream- Specified by:
getSaveFilenamein interfaceIClientBroadcastStreamStatistics- Returns:
- The filename relative to the scope or
null
if the stream is not being saved.
-
getStatistics
Return statistics about the stream.- Specified by:
getStatisticsin interfaceIClientBroadcastStream- Returns:
- statistics
-
getTotalSubscribers
public int getTotalSubscribers()Return total number of subscribers.- Specified by:
getTotalSubscribersin interfaceIClientBroadcastStreamStatistics- Returns:
- number of subscribers
-
isAutomaticRecording
public boolean isAutomaticRecording()- Returns:
- the automaticRecording
-
setAutomaticRecording
public void setAutomaticRecording(boolean automaticRecording) - Parameters:
automaticRecording- the automaticRecording to set
-
setRegisterJMX
public void setRegisterJMX(boolean registerJMX) - Parameters:
registerJMX- the registerJMX to set
-
notifyBroadcastClose
protected void notifyBroadcastClose()Notifies handler on stream broadcast close -
notifyRecordingStop
protected void notifyRecordingStop()Notifies handler on stream recording stop -
notifyBroadcastStart
protected void notifyBroadcastStart()Notifies handler on stream broadcast start -
notifyChunkSize
protected void notifyChunkSize()Send OOB control message with chunk size -
onOOBControlMessage
Out-of-band control message handler- Specified by:
onOOBControlMessagein interfaceIMessageComponent- Parameters:
source- OOB message sourcepipe- Pipe that used to send OOB messageoobCtrlMsg- Out-of-band control message
-
onPipeConnectionEvent
Pipe connection event handler- Specified by:
onPipeConnectionEventin interfaceIPipeConnectionListener- Parameters:
event- Pipe connection event
-
pushMessage
Currently not implemented- Specified by:
pushMessagein interfaceIPushableConsumer- Parameters:
pipe- Pipemessage- Message
-
saveAs
Save broadcasted stream.- Specified by:
saveAsin interfaceClientBroadcastStreamMXBean- Specified by:
saveAsin interfaceIBroadcastStream- Parameters:
name- Stream nameisAppend- Append mode- Throws:
IOException- File could not be created/written to
-
sendPublishStartNotify
protected void sendPublishStartNotify()Sends publish start notifications -
sendPublishStopNotify
protected void sendPublishStopNotify()Sends publish stop notifications -
sendRecordFailedNotify
Sends record failed notifications -
sendRecordStartNotify
protected void sendRecordStartNotify()Sends record start notifications -
sendRecordStopNotify
protected void sendRecordStopNotify()Sends record stop notifications -
pushMessage
Pushes a message out to a consumer.- Parameters:
msg- StatusMessage
-
sendStartNotifications
-
start
public void start()Starts stream, creates pipes, connects- Specified by:
startin interfaceClientBroadcastStreamMXBean- Specified by:
startin interfaceIStream
-
startPublishing
public void startPublishing()Notify client that stream is ready for publishing.- Specified by:
startPublishingin interfaceClientBroadcastStreamMXBean- Specified by:
startPublishingin interfaceIClientBroadcastStream
-
stop
public void stop()Stop this stream.- Specified by:
stopin interfaceClientBroadcastStreamMXBean- Specified by:
stopin interfaceIStream
-
stopRecording
public void stopRecording()Stops any currently active recording. -
isRecording
public boolean isRecording() -
addStreamListener
Add a listener to be notified about received packets.- Specified by:
addStreamListenerin interfaceIBroadcastStream- Parameters:
listener- the listener to add
-
getStreamListeners
Return registered stream listeners.- Specified by:
getStreamListenersin interfaceIBroadcastStream- Returns:
- the registered listeners
-
removeStreamListener
Remove a listener from being notified about received packets.- Specified by:
removeStreamListenerin interfaceIBroadcastStream- Parameters:
listener- the listener to remove
-
getRecordFile
Get the file we'd be recording to based on scope and given name.- Parameters:
scope- scopename- record name- Returns:
- file
-
registerJMX
protected void registerJMX() -
unregisterJMX
protected void unregisterJMX() -
addAlias
Description copied from interface:IClientBroadcastStreamAdds a stream name subscribe-side alias.- Specified by:
addAliasin interfaceIClientBroadcastStream- Parameters:
alias-- Returns:
- true if added to the aliases, false otherwise
-
hasAlias
public boolean hasAlias()Description copied from interface:IClientBroadcastStreamReturns whether or not an subscribe-side alias for this stream exists.- Specified by:
hasAliasin interfaceIClientBroadcastStream- Returns:
- true if an alias has been added and false otherwise
-
getAlias
Description copied from interface:IClientBroadcastStreamReturns an subscribe-side alias.- Specified by:
getAliasin interfaceIClientBroadcastStream- Returns:
- alias if at least one exists or null when there are none
-
containsAlias
Description copied from interface:IClientBroadcastStreamReturns whether or not a given subscribe-side alias exists.- Specified by:
containsAliasin interfaceIClientBroadcastStream- Parameters:
alias-- Returns:
- true if found and false otherwise
-
getAliases
Description copied from interface:IClientBroadcastStreamReturns all the subscribe-side aliases.- Specified by:
getAliasesin interfaceIClientBroadcastStream- Returns:
- all aliases for this instance or an empty set
-
setNameAlias
Description copied from interface:IClientBroadcastStreamSets the publish-side alias for the streams name. Subsequent calls will replace an existing alias if already set.- Specified by:
setNameAliasin interfaceIClientBroadcastStream- Parameters:
nameAlias- alias to set for the streams name or null to clear it
-
getNameAlias
Description copied from interface:IClientBroadcastStreamReturns the publish-side alias, if configured.- Specified by:
getNameAliasin interfaceIClientBroadcastStream- Returns:
- alias for the streams name or null if not set
-
aliasRegistered
Description copied from interface:IClientBroadcastStreamReturns whether or not an alias is in-use / registered already; this includes both publish and subscribe aliases within a server instance.- Specified by:
aliasRegisteredin interfaceIClientBroadcastStream- Parameters:
alias- the name to check against publish and subscribe aliases- Returns:
- true if registered and false otherwise
-