org.red5.server.stream
Class PlaylistSubscriberStream

java.lang.Object
  extended by org.red5.server.stream.AbstractStream
      extended by org.red5.server.stream.AbstractClientStream
          extended by 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 subsciber


Nested Class Summary
 
Nested classes/interfaces inherited from class org.red5.server.stream.AbstractStream
AbstractStream.State
 
Field Summary
 
Fields inherited from class org.red5.server.stream.AbstractStream
metaData, state
 
Fields inherited from interface org.red5.server.api.stream.IClientStream
MODE_APPEND, MODE_LIVE, MODE_PUBLISH, MODE_READ, MODE_RECORD
 
Constructor Summary
PlaylistSubscriberStream()
          Constructs a new PlaylistSubscriberStream.
 
Method Summary
 void addItem(IPlayItem item)
          Add an item to the list.
 void addItem(IPlayItem item, int index)
          Add an item to specific index.
 void close()
          Close this stream.
 long getBytesSent()
          Return total number of bytes sent to the client from this stream.
 long getCreationTime()
          Returns timestamp at which the stream was created.
 IPlayItem getCurrentItem()
          Get currently playing item
 int getCurrentItemIndex()
          Get currently playing item index.
 int getCurrentTimestamp()
          Return the currently active timestamp inside the stream.
 double getEstimatedBufferFill()
          Return estimated fill ratio of the client buffer.
 ScheduledThreadPoolExecutor getExecutor()
          Return the executor to use.
 IPlayItem getItem(int index)
          Get the item according to the index.
 int getItemSize()
          Return number of items in list
 IPlaylistSubscriberStreamStatistics getStatistics()
          Return statistics about this stream.
 boolean hasMoreItems()
          Check if the playlist has more items after the currently playing one.
 boolean isPaused()
          Check if the stream is currently paused.
 boolean isRandom()
          Whether items are randomly played.
 boolean isRepeat()
          Whether repeat playing an item.
 boolean isRewind()
          Whether rewind the list.
 void nextItem()
          Go for next item decided by controller logic.
protected  void notifyItemPause(IPlayItem item, int position)
          Notifies subscribers on pause
protected  void notifyItemPlay(IPlayItem item, boolean isLive)
          Notifies subscribers on item playback
protected  void notifyItemResume(IPlayItem item, int position)
          Notifies subscribers on resume
protected  void notifyItemSeek(IPlayItem item, int position)
          Notify on item seek
protected  void notifyItemStop(IPlayItem item)
          Notifies subscribers on item stop
protected  void notifySubscriberClose()
          Notifies subscribers on stop
protected  void notifySubscriberStart()
          Notifies subscribers on start
protected  void onItemEnd()
          Notified by the play engine when the current item reaches the end.
 void pause(int position)
          Pause at a position for current playing item.
 void play()
          Start playing.
 void previousItem()
          Go for the previous played item.
 void receiveAudio(boolean receive)
          Should the stream send audio to the client?
 void receiveVideo(boolean receive)
          Should the stream send video to the client?
 void removeAllItems()
          Remove all items.
 void removeItem(int index)
          Remove an item from list.
 void resume(int position)
          Resume from a position for current playing item.
 void seek(int position)
          Seek into a position for current playing item.
 void setBufferCheckInterval(int bufferCheckInterval)
          Set interval to check for buffer underruns.
 void setExecutor(ScheduledThreadPoolExecutor executor)
          Set the executor to use.
 void setItem(int index)
          Set the current item for playing.
 void setPlaylistController(IPlaylistController controller)
          Set list controller.
 void setRandom(boolean random)
          Set whether items should be randomly played.
 void setRepeat(boolean repeat)
          Set whether repeat playing an item.
 void setRewind(boolean rewind)
          Set whether rewind the list.
 void setUnderrunTrigger(int underrunTrigger)
          Set maximum number of pending messages at which a NetStream.Play.InsufficientBW message will be generated for VOD streams
 void start()
          Start this stream.
 void stop()
          Stop playing.
 
Methods inherited from class org.red5.server.stream.AbstractClientStream
getClientBufferDuration, getConnection, getStreamId, setClientBufferDuration, setConnection, setStreamId
 
Methods inherited from class org.red5.server.stream.AbstractStream
getCodecInfo, getMetaData, getName, getScope, getStreamAwareHandler, setCodecInfo, setName, setScope
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.red5.server.api.stream.IClientStream
getClientBufferDuration, getConnection, getStreamId, setClientBufferDuration
 
Methods inherited from interface org.red5.server.api.stream.IStream
getCodecInfo, getName, getScope
 
Methods inherited from interface org.red5.server.api.statistics.IPlaylistSubscriberStreamStatistics
getClientBufferDuration
 

Constructor Detail

PlaylistSubscriberStream

public PlaylistSubscriberStream()
Constructs a new PlaylistSubscriberStream.

Method Detail

setExecutor

public void setExecutor(ScheduledThreadPoolExecutor executor)
Set the executor to use.

Parameters:
executor - the executor

getExecutor

public ScheduledThreadPoolExecutor getExecutor()
Return the executor to use.

Returns:
the executor

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 a NetStream.Play.InsufficientBW message will be generated for VOD streams

Parameters:
underrunTrigger - the maximum number of pending messages

start

public void start()
Start this stream.

Specified by:
start in interface IStream

play

public void play()
          throws IOException
Start playing.

Specified by:
play in interface ISubscriberStream
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:
pause in interface ISubscriberStream
Parameters:
position - Position for pause in millisecond.

resume

public void resume(int position)
Resume from a position for current playing item.

Specified by:
resume in interface ISubscriberStream
Parameters:
position - Position for resume in millisecond.

stop

public void stop()
Stop playing.

Specified by:
stop in interface IStream
Specified by:
stop in interface ISubscriberStream

seek

public void seek(int position)
          throws OperationNotSupportedException
Seek into a position for current playing item.

Specified by:
seek in interface ISubscriberStream
Parameters:
position - Position for seek in millisecond.
Throws:
OperationNotSupportedException - if the stream doesn't support seeking.

close

public void close()
Close this stream.

Specified by:
close in interface IStream

isPaused

public boolean isPaused()
Check if the stream is currently paused.

Specified by:
isPaused in interface ISubscriberStream
Returns:
stream is paused

addItem

public void addItem(IPlayItem item)
Add an item to the list.

Specified by:
addItem in interface IPlaylist
Parameters:
item - Playlist item

addItem

public void addItem(IPlayItem item,
                    int index)
Add an item to specific index.

Specified by:
addItem in interface IPlaylist
Parameters:
item - Playlist item
index - Index in list

removeItem

public void removeItem(int index)
Remove an item from list.

Specified by:
removeItem in interface IPlaylist
Parameters:
index - Index in list

removeAllItems

public void removeAllItems()
Remove all items.

Specified by:
removeAllItems in interface IPlaylist

previousItem

public void previousItem()
Go for the previous played item.

Specified by:
previousItem in interface IPlaylist

hasMoreItems

public boolean hasMoreItems()
Check if the playlist has more items after the currently playing one.

Specified by:
hasMoreItems in interface IPlaylist
Returns:
true if more items are available, false otherwise

nextItem

public void nextItem()
Go for next item decided by controller logic.

Specified by:
nextItem in interface IPlaylist

setItem

public void setItem(int index)
Set the current item for playing.

Specified by:
setItem in interface IPlaylist
Parameters:
index - Position in list

isRandom

public boolean isRandom()
Whether items are randomly played.

Specified by:
isRandom in interface IPlaylist
Returns:
true if shuffle is on for this list, false otherwise

setRandom

public void setRandom(boolean random)
Set whether items should be randomly played.

Specified by:
setRandom in interface IPlaylist
Parameters:
random - Shuffle flag

isRewind

public boolean isRewind()
Whether rewind the list.

Specified by:
isRewind in interface IPlaylist
Returns:
true if playlist is rewind on end, false otherwise

setRewind

public void setRewind(boolean rewind)
Set whether rewind the list.

Specified by:
setRewind in interface IPlaylist
Parameters:
rewind - New vallue for rewind flag

isRepeat

public boolean isRepeat()
Whether repeat playing an item.

Specified by:
isRepeat in interface IPlaylist
Returns:
true if repeat mode is on for this playlist, false otherwise

setRepeat

public void setRepeat(boolean repeat)
Set whether repeat playing an item.

Specified by:
setRepeat in interface IPlaylist
Parameters:
repeat - New value for item playback repeat flag

receiveVideo

public void receiveVideo(boolean receive)
Should the stream send video to the client?

Specified by:
receiveVideo in interface ISubscriberStream

receiveAudio

public void receiveAudio(boolean receive)
Should the stream send audio to the client?

Specified by:
receiveAudio in interface ISubscriberStream

setPlaylistController

public void setPlaylistController(IPlaylistController controller)
Set list controller.

Specified by:
setPlaylistController in interface IPlaylist
Parameters:
controller - Playlist controller

getItemSize

public int getItemSize()
Return number of items in list

Specified by:
getItemSize in interface IPlaylist
Returns:
Number of items in list

getCurrentItemIndex

public int getCurrentItemIndex()
Get currently playing item index.

Specified by:
getCurrentItemIndex in interface IPlaylist
Returns:
Currently playing item index.

getCurrentItem

public IPlayItem getCurrentItem()
Get currently playing item

Specified by:
getCurrentItem in interface IPlaylist
Returns:
Item

getItem

public IPlayItem getItem(int index)
Get the item according to the index.

Specified by:
getItem in interface IPlaylist
Parameters:
index - Item index
Returns:
Item at that index in list

onItemEnd

protected void onItemEnd()
Notified by the play engine when the current item reaches the end.


notifySubscriberStart

protected void notifySubscriberStart()
Notifies subscribers on start


notifySubscriberClose

protected void notifySubscriberClose()
Notifies subscribers on stop


notifyItemPlay

protected void notifyItemPlay(IPlayItem item,
                              boolean isLive)
Notifies subscribers on item playback

Parameters:
item - Item being played
isLive - Is it a live broadcasting?

notifyItemStop

protected void notifyItemStop(IPlayItem item)
Notifies subscribers on item stop

Parameters:
item - Item that just has been stopped

notifyItemPause

protected void notifyItemPause(IPlayItem item,
                               int position)
Notifies subscribers on pause

Parameters:
item - Item that just has been paused
position - Playback head position

notifyItemResume

protected void notifyItemResume(IPlayItem item,
                                int position)
Notifies subscribers on resume

Parameters:
item - Item that just has been resumed
position - Playback head position

notifyItemSeek

protected void notifyItemSeek(IPlayItem item,
                              int position)
Notify on item seek

Parameters:
item - Playlist item
position - Seek position

getStatistics

public IPlaylistSubscriberStreamStatistics getStatistics()
Return statistics about this stream.

Specified by:
getStatistics in interface IPlaylistSubscriberStream
Returns:
statistics

getCreationTime

public long getCreationTime()
Returns timestamp at which the stream was created.

Specified by:
getCreationTime in interface IStatisticsBase
Specified by:
getCreationTime in interface IStream
Overrides:
getCreationTime in class AbstractStream
Returns:
creation timestamp

getCurrentTimestamp

public int getCurrentTimestamp()
Return the currently active timestamp inside the stream.

Specified by:
getCurrentTimestamp in interface IStreamStatistics
Returns:
the timestamp in milliseconds

getBytesSent

public long getBytesSent()
Return total number of bytes sent to the client from this stream.

Specified by:
getBytesSent in interface IPlaylistSubscriberStreamStatistics
Returns:
number of bytes

getEstimatedBufferFill

public double getEstimatedBufferFill()
Return estimated fill ratio of the client buffer.

Specified by:
getEstimatedBufferFill in interface IPlaylistSubscriberStreamStatistics
Returns:
fill ratio in percent


Copyright © 2006-2010 The Red5 Project