Package org.red5.server.stream
Class PlaylistSubscriberStream
java.lang.Object
org.red5.server.stream.AbstractStream
org.red5.server.stream.AbstractClientStream
org.red5.server.stream.PlaylistSubscriberStream
- All Implemented Interfaces:
IPlaylistSubscriberStreamStatistics,IStatisticsBase,IStreamStatistics,IClientStream,IPlaylist,IPlaylistSubscriberStream,IStream,ISubscriberStream
public class PlaylistSubscriberStream
extends AbstractClientStream
implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics
Stream of playlist subscriber
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassHandles notifications in a separate thread. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intInterval in ms to check for buffer underruns in VOD streams.protected longNumber of bytes sent.protected longTimestamp this stream was created.protected PlayEnginePlays items backprotected CopyOnWriteArraySet<String> Scheduled job namesprotected booleanRandom mode stateprotected booleanRepeat mode stateprotected booleanRewind mode stateprotected ISchedulingServiceService used to provide notifications, keep client buffer filled, clean up, etc...protected intNumber of pending messages at which aFields inherited from class org.red5.server.stream.AbstractStream
codecInfo, metaData, startTime, state, stateListenersFields inherited from interface org.red5.server.api.stream.IClientStream
MODE_APPEND, MODE_LIVE, MODE_PUBLISH, MODE_READ, MODE_RECORD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an item to the list.voidAdd an item to specific index.voidCancels a scheduled job by name.voidclose()Close this stream.longReturn total number of bytes sent to the client from this stream.longReturns timestamp at which the stream was created.Get currently playing itemintGet currently playing item index.intReturn the currently active timestamp inside the stream.doubleReturn estimated fill ratio of the client buffer.getItem(int index) Get the item according to the index.intReturn number of items in listReturn statistics about this stream.booleanCheck if the playlist has more items after the currently playing one.booleanisPaused()Check if the stream is currently paused.booleanisRandom()Whether items are randomly played.booleanisRepeat()Whether repeat playing an item.booleanisRewind()Whether rewind the list.voidnextItem()Go for next item decided by controller logic.voidonChange(StreamState state, Object... changed) Handles a change occurring on the stream.voidpause(int position) Pause at a position for current playing item.voidplay()Start playing.voidGo for the previous played item.voidreceiveAudio(boolean receive) Should the stream send audio to the client?voidreceiveVideo(boolean receive) Should the stream send video to the client?voidRemove all items.voidremoveItem(int index) Remove an item from list.booleanReplaces an item in the list with another item.voidresume(int position) Resume from a position for current playing item.Schedule a job to be executed only once after a 10ms delay.scheduleWithFixedDelay(IScheduledJob job, int interval) Schedule a job to be executed regularly at the given interval.voidseek(int position) Seek into a position for current playing item.voidsetBufferCheckInterval(int bufferCheckInterval) Set interval to check for buffer underruns.voidsetItem(int index) Set the current item for playing.voidsetMaxPendingVideoFrames(int maxPendingVideoFrames) voidsetMaxSequentialPendingVideoFrames(int maxSequentialPendingVideoFrames) voidsetPlaylistController(IPlaylistController controller) Set list controller.voidsetRandom(boolean random) Set whether items should be randomly played.voidsetRepeat(boolean repeat) Set whether repeat playing an item.voidsetRewind(boolean rewind) Set whether rewind the list.voidsetUnderrunTrigger(int underrunTrigger) Set maximum number of pending messages at which avoidstart()Start this stream.voidstop()Stop playing.Methods 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, 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.IClientStream
getBroadcastStreamPublishName, getClientBufferDuration, getConnection, getStreamId, setBroadcastStreamPublishName, setClientBufferDurationMethods inherited from interface org.red5.server.api.statistics.IPlaylistSubscriberStreamStatistics
getClientBufferDurationMethods inherited from interface org.red5.server.api.stream.IStream
getCodecInfo, getName, getScope, getStartTimeMethods inherited from interface org.red5.server.api.stream.ISubscriberStream
getState, setState
-
Field Details
-
engine
Plays items back -
rewind
protected boolean rewindRewind mode state -
random
protected boolean randomRandom mode state -
repeat
protected boolean repeatRepeat mode state -
schedulingService
Service used to provide notifications, keep client buffer filled, clean up, etc... -
jobs
Scheduled job names -
bufferCheckInterval
protected int bufferCheckIntervalInterval in ms to check for buffer underruns in VOD streams. -
underrunTrigger
protected int underrunTriggerNumber of pending messages at which aNetStream.Play.InsufficientBW
message is generated for VOD streams. -
creationTime
protected long creationTimeTimestamp this stream was created. -
bytesSent
protected long bytesSentNumber of bytes sent.
-
-
Constructor Details
-
PlaylistSubscriberStream
public PlaylistSubscriberStream()Constructs a new PlaylistSubscriberStream.
-
-
Method Details
-
setBufferCheckInterval
public void setBufferCheckInterval(int bufferCheckInterval) Set interval to check for buffer underruns. Set to 0 to disable.- Parameters:
bufferCheckInterval- interval in ms
-
setUnderrunTrigger
public void setUnderrunTrigger(int underrunTrigger) Set maximum number of pending messages at which aNetStream.Play.InsufficientBW
message will be generated for VOD streams- Parameters:
underrunTrigger- the maximum number of pending messages
-
start
public void start()Start this stream. -
play
Start playing.- Specified by:
playin interfaceISubscriberStream- Throws:
IOException- if an IO error occurred while starting to play the stream
-
pause
public void pause(int position) Pause at a position for current playing item.- Specified by:
pausein interfaceISubscriberStream- Parameters:
position- Position for pause in millisecond.
-
resume
public void resume(int position) Resume from a position for current playing item.- Specified by:
resumein interfaceISubscriberStream- Parameters:
position- Position for resume in millisecond.
-
stop
public void stop()Stop playing.- Specified by:
stopin interfaceIStream- Specified by:
stopin interfaceISubscriberStream
-
seek
Seek into a position for current playing item.- Specified by:
seekin interfaceISubscriberStream- Parameters:
position- Position for seek in millisecond.- Throws:
OperationNotSupportedException- if the stream doesn't support seeking.
-
close
public void close()Close this stream. -
isPaused
public boolean isPaused()Check if the stream is currently paused.- Specified by:
isPausedin interfaceISubscriberStream- Returns:
- stream is paused
-
addItem
Add an item to the list. -
addItem
Add an item to specific index. -
removeItem
public void removeItem(int index) Remove an item from list.- Specified by:
removeItemin interfaceIPlaylist- Parameters:
index- Index in list
-
removeAllItems
public void removeAllItems()Remove all items.- Specified by:
removeAllItemsin interfaceIPlaylist
-
previousItem
public void previousItem()Go for the previous played item.- Specified by:
previousItemin interfaceIPlaylist
-
hasMoreItems
public boolean hasMoreItems()Check if the playlist has more items after the currently playing one.- Specified by:
hasMoreItemsin interfaceIPlaylist- Returns:
true
if more items are available,false
otherwise
-
nextItem
public void nextItem()Go for next item decided by controller logic. -
setItem
public void setItem(int index) Set the current item for playing. -
isRandom
public boolean isRandom()Whether items are randomly played. -
setRandom
public void setRandom(boolean random) Set whether items should be randomly played. -
isRewind
public boolean isRewind()Whether rewind the list. -
setRewind
public void setRewind(boolean rewind) Set whether rewind the list. -
isRepeat
public boolean isRepeat()Whether repeat playing an item. -
setRepeat
public void setRepeat(boolean repeat) Set whether repeat playing an item. -
receiveVideo
public void receiveVideo(boolean receive) Should the stream send video to the client?- Specified by:
receiveVideoin interfaceISubscriberStream- Parameters:
receive- toggle
-
receiveAudio
public void receiveAudio(boolean receive) Should the stream send audio to the client?- Specified by:
receiveAudioin interfaceISubscriberStream- Parameters:
receive- toggle
-
setPlaylistController
Set list controller.- Specified by:
setPlaylistControllerin interfaceIPlaylist- Parameters:
controller- Playlist controller
-
getItemSize
public int getItemSize()Return number of items in list- Specified by:
getItemSizein interfaceIPlaylist- Returns:
- Number of items in list
-
getCurrentItemIndex
public int getCurrentItemIndex()Get currently playing item index.- Specified by:
getCurrentItemIndexin interfaceIPlaylist- Returns:
- Currently playing item index.
-
getCurrentItem
Get currently playing item- Specified by:
getCurrentItemin interfaceIPlaylist- Returns:
- Item
-
getItem
Get the item according to the index. -
replace
Replaces an item in the list with another item.- Specified by:
replacein interfaceIPlaylistSubscriberStream- Parameters:
oldItem- old play itemnewItem- new play item- Returns:
- true if successful and false otherwise
-
onChange
Handles a change occurring on the stream.- Specified by:
onChangein interfaceIPlaylistSubscriberStream- Specified by:
onChangein interfaceISubscriberStream- Parameters:
state- stream state that we are changing to or notifying ofchanged- changed items
-
getStatistics
Return statistics about this stream.- Specified by:
getStatisticsin interfaceIPlaylistSubscriberStream- Returns:
- statistics
-
getCreationTime
public long getCreationTime()Returns timestamp at which the stream was created.- Specified by:
getCreationTimein interfaceIStatisticsBase- Specified by:
getCreationTimein interfaceIStream- Overrides:
getCreationTimein classAbstractStream- Returns:
- creation timestamp
-
getCurrentTimestamp
public int getCurrentTimestamp()Return the currently active timestamp inside the stream.- Specified by:
getCurrentTimestampin interfaceIStreamStatistics- Returns:
- the timestamp in milliseconds
-
getBytesSent
public long getBytesSent()Return total number of bytes sent to the client from this stream.- Specified by:
getBytesSentin interfaceIPlaylistSubscriberStreamStatistics- Returns:
- number of bytes
-
getEstimatedBufferFill
public double getEstimatedBufferFill()Return estimated fill ratio of the client buffer.- Specified by:
getEstimatedBufferFillin interfaceIPlaylistSubscriberStreamStatistics- Returns:
- fill ratio in percent
-
setMaxPendingVideoFrames
public void setMaxPendingVideoFrames(int maxPendingVideoFrames) - Parameters:
maxPendingVideoFrames- the maxPendingVideoFrames to set
-
setMaxSequentialPendingVideoFrames
public void setMaxSequentialPendingVideoFrames(int maxSequentialPendingVideoFrames) - Parameters:
maxSequentialPendingVideoFrames- the maxSequentialPendingVideoFrames to set
-
scheduleOnceJob
Schedule a job to be executed only once after a 10ms delay.- Specified by:
scheduleOnceJobin interfaceISubscriberStream- Parameters:
job- scheduled job- Returns:
- jobName
-
scheduleWithFixedDelay
Schedule a job to be executed regularly at the given interval.- Specified by:
scheduleWithFixedDelayin interfaceISubscriberStream- Parameters:
job- scheduled jobinterval- interval- Returns:
- jobName
-
cancelJob
Cancels a scheduled job by name.- Specified by:
cancelJobin interfaceISubscriberStream- Parameters:
jobName- job name
-