Class SlicedFileConsumer

java.lang.Object
org.red5.server.stream.consumer.SlicedFileConsumer
All Implemented Interfaces:
IFileConsumer, IConsumer, IMessageComponent, IPipeConnectionListener, IPushableConsumer, Constants, org.springframework.beans.factory.DisposableBean

public class SlicedFileConsumer extends Object implements Constants, IPushableConsumer, IPipeConnectionListener, org.springframework.beans.factory.DisposableBean, IFileConsumer
Consumer that pushes messages to file. Used when recording live streams.
Author:
The Red5 Project, Paul Gregoire (mondain@gmail.com), Vladimir Hmelyoff (vlhm@splitmedialabs.com), Octavian Naicu (naicuoctavian@gmail.com)
  • Constructor Details

    • SlicedFileConsumer

      public SlicedFileConsumer()
      Default ctor
    • SlicedFileConsumer

      public SlicedFileConsumer(IScope scope, File file)
      Creates file consumer
      Parameters:
      scope - Scope of consumer
      file - File
    • SlicedFileConsumer

      public SlicedFileConsumer(IScope scope, String fileName, String mode)
      Creates file consumer
      Parameters:
      scope - Scope of consumer
      fileName - The file name without the extension
      mode - The recording mode
  • Method Details

    • pushMessage

      public void pushMessage(IPipe pipe, IMessage message) throws IOException
      Push message through pipe
      Specified by:
      pushMessage in interface IPushableConsumer
      Parameters:
      pipe - Pipe
      message - Message to push
      Throws:
      IOException - if message could not be written
    • onOOBControlMessage

      public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
      Out-of-band control message handler
      Specified by:
      onOOBControlMessage in interface IMessageComponent
      Parameters:
      source - Source of message
      pipe - Pipe that is used to transmit OOB message
      oobCtrlMsg - OOB control message
    • onPipeConnectionEvent

      public void onPipeConnectionEvent(PipeConnectionEvent event)
      Pipe connection event handler
      Specified by:
      onPipeConnectionEvent in interface IPipeConnectionListener
      Parameters:
      event - Pipe connection event
    • uninit

      public void uninit()
      Reset or uninitialize
    • doWrites

      public final void doWrites()
      Write all the queued items to the writer.
    • doWrites

      public final void doWrites(QueuedMediaData[] slice)
      Write a slice of the queued items to the writer.
      Parameters:
      slice - set of queued data
    • setupOutputPath

      public void setupOutputPath(String name)
      Sets up the output file path for writing.
      Parameters:
      name - output filename to use
    • setVideoDecoderConfiguration

      public void setVideoDecoderConfiguration(IRTMPEvent decoderConfig)
      Sets a video decoder configuration; some codecs require this, such as AVC.
      Specified by:
      setVideoDecoderConfiguration in interface IFileConsumer
      Parameters:
      decoderConfig - video codec configuration
    • setAudioDecoderConfiguration

      public void setAudioDecoderConfiguration(IRTMPEvent decoderConfig)
      Sets a audio decoder configuration; some codecs require this, such as AAC.
      Specified by:
      setAudioDecoderConfiguration in interface IFileConsumer
      Parameters:
      decoderConfig - audio codec configuration
    • setScope

      public void setScope(IScope scope)
      Sets the scope for this consumer.
      Parameters:
      scope - scope
    • setFile

      public void setFile(File file)
      Sets the file we're writing to.
      Parameters:
      file - file
    • getFile

      public File getFile()
      Returns the file.
      Returns:
      file
    • setQueueThreshold

      public void setQueueThreshold(int queueThreshold)
      Sets the threshold for the queue. When the threshold is met a worker is spawned to empty the sorted queue to the writer.
      Parameters:
      queueThreshold - number of items to queue before spawning worker
    • getQueueThreshold

      public int getQueueThreshold()
      Returns the size of the delayed writing queue.
      Returns:
      queue length
    • isDelayWrite

      @Deprecated public boolean isDelayWrite()
      Deprecated.
      Whether or not the queue should be utilized.
      Returns:
      true if using the queue, false if sending directly to the writer
    • setDelayWrite

      @Deprecated public void setDelayWrite(boolean delayWrite)
      Deprecated.
      Sets whether or not to use the queue.
      Parameters:
      delayWrite - true to use the queue, false if not
    • setWaitForVideoKeyframe

      public void setWaitForVideoKeyframe(boolean waitForVideoKeyframe)
      Whether or not to wait for the first keyframe before processing video frames.
      Parameters:
      waitForVideoKeyframe - wait for a key frame or not
    • getSchedulerThreadSize

      public int getSchedulerThreadSize()
      Returns:
      the schedulerThreadSize
    • setSchedulerThreadSize

      public void setSchedulerThreadSize(int schedulerThreadSize)
      Parameters:
      schedulerThreadSize - the schedulerThreadSize to set
    • setMode

      public void setMode(String mode)
      Sets the recording mode.
      Parameters:
      mode - either "record" or "append" depending on the type of action to perform
    • destroy

      public void destroy() throws Exception
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
      Throws:
      Exception