org.red5.server.stream.consumer
Class FileConsumer

java.lang.Object
  extended by org.red5.server.stream.consumer.FileConsumer
All Implemented Interfaces:
IConsumer, IMessageComponent, IPipeConnectionListener, IPushableConsumer, Constants

public class FileConsumer
extends Object
implements Constants, IPushableConsumer, IPipeConnectionListener

Consumer that pushes messages to file. Used when recording live streams.

Author:
The Red5 Project ([email protected]), Paul Gregoire ([email protected]), Vladimir Hmelyoff ([email protected])

Field Summary
 
Fields inherited from interface org.red5.server.net.rtmp.message.Constants
HANDSHAKE_SIZE, HEADER_CONTINUE, HEADER_NEW, HEADER_SAME_SOURCE, HEADER_TIMER_CHANGE, MEDIUM_INT_MAX, SO_CLIENT_CLEAR_DATA, SO_CLIENT_DELETE_DATA, SO_CLIENT_INITIAL_DATA, SO_CLIENT_SEND_MESSAGE, SO_CLIENT_STATUS, SO_CLIENT_UPDATE_ATTRIBUTE, SO_CLIENT_UPDATE_DATA, SO_CONNECT, SO_DELETE_ATTRIBUTE, SO_DISCONNECT, SO_SEND_MESSAGE, SO_SET_ATTRIBUTE, SOURCE_TYPE_LIVE, SOURCE_TYPE_VOD, TYPE_ABORT, TYPE_AGGREGATE, TYPE_AUDIO_DATA, TYPE_BYTES_READ, TYPE_CHUNK_SIZE, TYPE_CLIENT_BANDWIDTH, TYPE_EDGE_ORIGIN, TYPE_FLEX_MESSAGE, TYPE_FLEX_SHARED_OBJECT, TYPE_FLEX_STREAM_SEND, TYPE_INVOKE, TYPE_NOTIFY, TYPE_PING, TYPE_SERVER_BANDWIDTH, TYPE_SHARED_OBJECT, TYPE_STREAM_METADATA, TYPE_VIDEO_DATA
 
Fields inherited from interface org.red5.server.messaging.IPushableConsumer
KEY
 
Constructor Summary
FileConsumer()
          Default ctor
FileConsumer(IScope scope, File file)
          Creates file consumer
 
Method Summary
 void doWrites()
          Write all the queued items to the writer.
 void doWrites(org.red5.server.stream.consumer.FileConsumer.QueuedData[] slice)
          Write a slice of the queued items to the writer.
 int getQueueThreshold()
          Returns the size of the delayed writing queue.
 int getSchedulerThreadSize()
           
 boolean isDelayWrite()
          Whether or not the queue should be utilized.
 void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
          Out-of-band control message handler
 void onPipeConnectionEvent(PipeConnectionEvent event)
          Pipe connection event handler
 void pushMessage(IPipe pipe, IMessage message)
          Push message through pipe
 void setAudioDecoderConfiguration(IRTMPEvent decoderConfig)
          Sets a audio decoder configuration; some codecs require this, such as AAC.
 void setDelayWrite(boolean delayWrite)
          Sets whether or not to use the queue.
 void setFile(File file)
          Sets the file we're writing to.
 void setMode(String mode)
          Sets the recording mode.
 void setQueueThreshold(int queueThreshold)
          Sets the threshold for the queue.
 void setSchedulerThreadSize(int schedulerThreadSize)
           
 void setScope(IScope scope)
          Sets the scope for this consumer.
 void setVideoDecoderConfiguration(IRTMPEvent decoderConfig)
          Sets a video decoder configuration; some codecs require this, such as AVC.
 void uninit()
          Reset or uninitialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileConsumer

public FileConsumer()
Default ctor


FileConsumer

public FileConsumer(IScope scope,
                    File file)
Creates file consumer

Parameters:
scope - Scope of consumer
file - File
Method Detail

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(org.red5.server.stream.consumer.FileConsumer.QueuedData[] slice)
Write a slice of the queued items to the writer.


setVideoDecoderConfiguration

public void setVideoDecoderConfiguration(IRTMPEvent decoderConfig)
Sets a video decoder configuration; some codecs require this, such as AVC.

Parameters:
decoderConfig - video codec configuration

setAudioDecoderConfiguration

public void setAudioDecoderConfiguration(IRTMPEvent decoderConfig)
Sets a audio decoder configuration; some codecs require this, such as AAC.

Parameters:
decoderConfig - audio codec configuration

setScope

public void setScope(IScope scope)
Sets the scope for this consumer.

Parameters:
scope -

setFile

public void setFile(File file)
Sets the file we're writing to.

Parameters:
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

public boolean isDelayWrite()
Whether or not the queue should be utilized.

Returns:
true if using the queue, false if sending directly to the writer

setDelayWrite

public void setDelayWrite(boolean delayWrite)
Sets whether or not to use the queue.

Parameters:
delayWrite - true to use the queue, false if 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


Copyright © 2006-2012 The Red5 Project