Package org.red5.server.stream.consumer
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)
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.red5.server.net.rtmp.message.Constants
Constants.DataType -
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_DATAFields inherited from interface org.red5.server.messaging.IPushableConsumer
KEY -
Constructor Summary
ConstructorsConstructorDescriptionDefault ctorSlicedFileConsumer(IScope scope, File file) Creates file consumerSlicedFileConsumer(IScope scope, String fileName, String mode) Creates file consumer -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()final voiddoWrites()Write all the queued items to the writer.final voiddoWrites(QueuedMediaData[] slice) Write a slice of the queued items to the writer.getFile()Returns the file.intReturns the size of the delayed writing queue.intbooleanDeprecated.voidonOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) Out-of-band control message handlervoidPipe connection event handlervoidpushMessage(IPipe pipe, IMessage message) Push message through pipevoidsetAudioDecoderConfiguration(IRTMPEvent decoderConfig) Sets a audio decoder configuration; some codecs require this, such as AAC.voidsetDelayWrite(boolean delayWrite) Deprecated.voidSets the file we're writing to.voidSets the recording mode.voidsetQueueThreshold(int queueThreshold) Sets the threshold for the queue.voidsetSchedulerThreadSize(int schedulerThreadSize) voidSets the scope for this consumer.voidsetupOutputPath(String name) Sets up the output file path for writing.voidsetVideoDecoderConfiguration(IRTMPEvent decoderConfig) Sets a video decoder configuration; some codecs require this, such as AVC.voidsetWaitForVideoKeyframe(boolean waitForVideoKeyframe) Whether or not to wait for the first keyframe before processing video frames.voiduninit()Reset or uninitialize
-
Constructor Details
-
SlicedFileConsumer
public SlicedFileConsumer()Default ctor -
SlicedFileConsumer
Creates file consumer- Parameters:
scope- Scope of consumerfile- File
-
SlicedFileConsumer
Creates file consumer- Parameters:
scope- Scope of consumerfileName- The file name without the extensionmode- The recording mode
-
-
Method Details
-
pushMessage
Push message through pipe- Specified by:
pushMessagein interfaceIPushableConsumer- Parameters:
pipe- Pipemessage- Message to push- Throws:
IOException- if message could not be written
-
onOOBControlMessage
Out-of-band control message handler- Specified by:
onOOBControlMessagein interfaceIMessageComponent- Parameters:
source- Source of messagepipe- Pipe that is used to transmit OOB messageoobCtrlMsg- OOB control message
-
onPipeConnectionEvent
Pipe connection event handler- Specified by:
onPipeConnectionEventin interfaceIPipeConnectionListener- 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
Write a slice of the queued items to the writer.- Parameters:
slice- set of queued data
-
setupOutputPath
Sets up the output file path for writing.- Parameters:
name- output filename to use
-
setVideoDecoderConfiguration
Sets a video decoder configuration; some codecs require this, such as AVC.- Specified by:
setVideoDecoderConfigurationin interfaceIFileConsumer- Parameters:
decoderConfig- video codec configuration
-
setAudioDecoderConfiguration
Sets a audio decoder configuration; some codecs require this, such as AAC.- Specified by:
setAudioDecoderConfigurationin interfaceIFileConsumer- Parameters:
decoderConfig- audio codec configuration
-
setScope
Sets the scope for this consumer.- Parameters:
scope- scope
-
setFile
Sets the file we're writing to.- Parameters:
file- 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.Whether or not the queue should be utilized.- Returns:
- true if using the queue, false if sending directly to the writer
-
setDelayWrite
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
Sets the recording mode.- Parameters:
mode- either "record" or "append" depending on the type of action to perform
-
destroy
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-