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 ([email protected]), Vladimir Hmelyoff ([email protected])
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether or not automatically record incoming stream as mp4private booleanWhether or not automatically record incoming stream as mp4protected 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 booleanIs this stream still active?private IClusterNotifierprotected IMessageOutputOutput endpoint that providers useprotected longStores timestamp of first packetprotected longprotected Set<IStreamListener>Listeners to get notified about received packets.protected IPipePipe for live streamingprivate static final org.slf4j.Loggerprivate WeakReference<MuxAdaptor>Streaming parametersprotected StringStream published nameprivate WeakReference<IRecordingListener>Recording listenerprivate booleanWhether or not to register with JMX.protected booleanIs there need to send start notification?private StatisticsCounterStores statistics about subscribers.Fields inherited from class org.red5.server.stream.AbstractStream
creationTime, lock, stateFields 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 TypeMethodDescriptionvoidaddStreamListener(IStreamListener listener) Add a listener to be notified about received packets.private voidcheckSendNotifications(IEvent event) Check and send notification if necessaryvoidclose()Closes stream, unsubscribes provides, sends stoppage notifications and broadcast close notification.voiddispatchEvent(IEvent event) Dispatches eventintReturn current number of subscribers.longReturn total number of bytes received from client for this stream.intReturn the currently active timestamp inside the stream.getDatastore(ApplicationContext appCtx) intReturn maximum number of concurrent subscribers.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.booleanbooleanprivate voidNotifies handler on stream broadcast closeprivate voidNotifies handler on stream broadcast startprivate voidSend OOB control message with chunk sizeprivate 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.private voidSends publish start notificationsprivate voidSends publish stop notificationsprivate voidsendRecordFailedNotify(String reason) Sends record failed notificationsprivate voidSends record start notificationsprivate voidSends record stop notificationsprivate voidsendStartNotifications(IEventListener source) voidsetAutomaticHlsRecording(boolean automaticHlsRecording) voidsetAutomaticMp4Recording(boolean automaticMp4Recording) voidsetAutomaticRecording(boolean automaticRecording) voidsetMuxAdaptor(WeakReference<MuxAdaptor> muxAdaptor) voidsetParameters(Map<String, String> params) Sets streaming parameters as supplied by the publishing application.voidsetPublishedName(String name) Setter for stream published namevoidsetRegisterJMX(boolean registerJMX) private voidsetUpEndPoints(ApplicationContext appCtx, Broadcast broadcast, MuxAdaptor muxAdaptor) 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, setStreamIdMethods inherited from class org.red5.server.stream.AbstractStream
getAbsoluteStartTimeMs, getCodecInfo, getCreationTime, getMetaData, getName, getScope, getState, getStreamAwareHandler, 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
-
Field Details
-
log
private static final org.slf4j.Logger log -
automaticRecording
protected boolean automaticRecordingWhether or not to automatically record the associated stream. -
bytesReceived
protected long bytesReceivedTotal number of bytes received. -
checkVideoCodec
protected boolean checkVideoCodecIs there need to check video codec? -
checkAudioCodec
protected boolean checkAudioCodecIs there need to check audio codec? -
chunkSize
protected int chunkSizeData is sent by chunks, each of them has size -
closed
protected volatile boolean closedIs 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? -
subscriberStats
Stores statistics about subscribers. -
listeners
Listeners to get notified about received packets. -
recordingListener
Recording listener -
latestTimeStamp
protected long latestTimeStamp -
registerJMX
private boolean registerJMXWhether or not to register with JMX. -
automaticMp4Recording
private boolean automaticMp4RecordingWhether or not automatically record incoming stream as mp4 -
automaticHlsRecording
private boolean automaticHlsRecordingWhether or not automatically record incoming stream as mp4 -
muxAdaptor
-
clusterNotifier
-
-
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
private void notifyBroadcastClose()Notifies handler on stream broadcast close -
notifyRecordingStop
private void notifyRecordingStop()Notifies handler on stream recording stop -
notifyBroadcastStart
private void notifyBroadcastStart()Notifies handler on stream broadcast start -
notifyChunkSize
private 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
private void sendPublishStartNotify()Sends publish start notifications -
sendPublishStopNotify
private void sendPublishStopNotify()Sends publish stop notifications -
sendRecordFailedNotify
Sends record failed notifications -
sendRecordStartNotify
private void sendRecordStartNotify()Sends record start notifications -
sendRecordStopNotify
private 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
-
getDatastore
-
setUpEndPoints
-
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() -
setAutomaticMp4Recording
public void setAutomaticMp4Recording(boolean automaticMp4Recording) -
setAutomaticHlsRecording
public void setAutomaticHlsRecording(boolean automaticHlsRecording) -
setMuxAdaptor
-
getMuxAdaptor
-