Class SingleItemSubscriberStream

All Implemented Interfaces:
IClientStream, ISingleItemSubscriberStream, IStream, ISubscriberStream

public class SingleItemSubscriberStream extends AbstractClientStream implements ISingleItemSubscriberStream
Stream of a single play item for a subscriber
Author:
Paul Gregoire (mondain@gmail.com)
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • schedulingService

      protected ISchedulingService schedulingService
      Service used to provide notifications, keep client buffer filled, clean up, etc...
    • jobs

      protected Set<String> jobs
      Scheduled job names
    • bufferCheckInterval

      protected int bufferCheckInterval
      Interval in ms to check for buffer underruns in VOD streams.
    • underrunTrigger

      protected int underrunTrigger
      Number of pending messages at which a
       NetStream.Play.InsufficientBW
       
      message is generated for VOD streams.
    • creationTime

      protected long creationTime
      Timestamp this stream was created.
    • item

      private volatile IPlayItem item
    • engine

      protected PlayEngine engine
      Plays items back
  • Constructor Details

    • SingleItemSubscriberStream

      public SingleItemSubscriberStream()
  • Method Details

    • setPlayItem

      public void setPlayItem(IPlayItem item)
      Description copied from interface: ISingleItemSubscriberStream
      Setter for property 'playItem'.
      Specified by:
      setPlayItem in interface ISingleItemSubscriberStream
      Parameters:
      item - Value to set for property 'playItem'.
    • play

      public void play() throws IOException
      Description copied from interface: ISubscriberStream
      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.
    • isPaused

      public boolean isPaused()
      Description copied from interface: ISubscriberStream
      Check if the stream is currently paused.
      Specified by:
      isPaused in interface ISubscriberStream
      Returns:
      stream is paused
    • receiveVideo

      public void receiveVideo(boolean receive)
      Should the stream send video to the client?
      Specified by:
      receiveVideo in interface ISubscriberStream
      Parameters:
      receive - toggle
    • receiveAudio

      public void receiveAudio(boolean receive)
      Should the stream send audio to the client?
      Specified by:
      receiveAudio in interface ISubscriberStream
      Parameters:
      receive - toggle
    • createEngine

      PlayEngine createEngine(ISchedulingService schedulingService, IConsumerService consumerService, IProviderService providerService)
      Creates a play engine based on current services (scheduling service, consumer service, and provider service). This method is useful during unit testing.
    • 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()
      Description copied from interface: IStream
      Start this stream.
      Specified by:
      start in interface IStream
    • close

      public void close()
      Description copied from interface: IStream
      Close this stream.
      Specified by:
      close in interface IStream
    • onChange

      public void onChange(StreamState state, Object... changed)
      Notification of state change and associated parameters.
      Specified by:
      onChange in interface ISubscriberStream
      Parameters:
      state - new state
      changed - parameters associated with the change
    • seekToCurrentPlayback

      private void seekToCurrentPlayback()
      Seek to current position to restart playback with audio and/or video.
    • scheduleOnceJob

      public String scheduleOnceJob(IScheduledJob job)
      Schedule a job to be executed only once after a 10ms delay.
      Specified by:
      scheduleOnceJob in interface ISubscriberStream
      Parameters:
      job - scheduled job
      Returns:
      jobName
    • scheduleWithFixedDelay

      public String scheduleWithFixedDelay(IScheduledJob job, int interval)
      Schedule a job to be executed regularly at the given interval.
      Specified by:
      scheduleWithFixedDelay in interface ISubscriberStream
      Parameters:
      job - scheduled job
      interval - interval
      Returns:
      jobName
    • cancelJob

      public void cancelJob(String jobName)
      Cancels a scheduled job by name.
      Specified by:
      cancelJob in interface ISubscriberStream
      Parameters:
      jobName - job name