C# Class HCS_Encoder.Utilities.EncoderController

This class provides a simplified way to start and stop an encode process, using a configuration file for the details.
Inheritance: IDisposable
ファイルを表示 Open project: i-e-b/HLS---Smooth-Encoder Class Usage Examples

Public Methods

Method Description
ClearBuffers ( ) : void

Clear all captured frames from all attached buffers. Buffers will refill if capture devices are running.

ContinueCapture ( ) : void

Resumes capture devices after a call to 'PauseCapture()'

ContinueOutput ( int MinimumChunkIndex ) : void

Resumes output sending (if 'EnableOutput' is false). Any chunks with an index below 'MiniumumChunkIndex' will be dropped.

Dispose ( ) : void
EncoderController ( Configuration Config ) : System

Create and initialise a new encoder job with the given config

ForceInsertFrame ( System VideoFrame, double SimulatedCaptureTime ) : void

Force a timed frame into the encoder's buffers. May cause unexpected operation. Use with caution!

ForceInsertFrame ( TimedSample AudioFrame ) : void

Force a timed frame into the encoder's buffers. May cause unexpected operation. Use with caution!

PauseCapture ( ) : void

Pauses all capture devices, but allows the encoder loop to continue (will sleep while buffers are empty)

RegisterPlugin ( IAudioProcessor PlugIn ) : void

Add a plug-in to the audio buffer's plug-in list

RegisterPlugin ( IVideoProcessor PlugIn ) : void

Add a plug-in to the video buffer's plug-in list

Start ( ) : void

Start the encoding process. This will start to over-write any existing encodes made with the configuration being used.

Stop ( ) : void

Stop the encoding process

Private Methods

Method Description
AdjustFrameSleep ( ) : void

Work out a resonable sleep duration (over which we'd expect a new frame in at least one buffer)

BuffersEmpty ( ) : bool

Returns true if any of the active capture buffers are below their encoding theshold.

CalculateScales ( int Width, int Height, List ScaleFactors ) : List

Given a set of linear scale factors, create a set of scaled (w*h) sizes.

Scaling the height and width directly will result in pixel count being reduced by the square of the scale factor, so instead we apply a rough factor to get a linear scaled pixel count.

CaptureSetup ( ) : void

Initialise capture devices and connect the appropriate buffers

ConnectPackageToBuffers ( EncoderPackage Package, PackageSpec Spec ) : void

Create encoder buffers for each package, and add to capture buffer lists.

EncoderCoreLoop ( object Package ) : void

This loop does the actual work of reading caches into the encoder and firing actions. This loop controls Multiple-bit-rate encoding

EncoderSetup ( ) : void

Initialise an encoder job based on previously setup capture devices. Need to have one job per 'ReductionFactor' in the config.

Halt ( ) : void

Stop the encode process, from within the core loop

InitAudioCapture ( ) : void
InitVideoCapture ( ) : void
InnerStartup ( ) : void

Start encoder threads & capture devices for each job.

ListRequiredPackages ( ) : List

Creates a list of encoder packages requires to fulfill the configured job.

NewEncoderThread ( EncoderPackage pkg ) : Thread

Create, start and return a new core encoder thread.

WaitAndCompensateCaptureTimes ( ) : void

Wait for first frames in buffer, and use those to compensate timecodes.

WaitForSyncFlag ( ) : void

Wait for the sync flag to be set by WaitAndCompensateCaptureTimes()

Method Details

ClearBuffers() public method

Clear all captured frames from all attached buffers. Buffers will refill if capture devices are running.
public ClearBuffers ( ) : void
return void

ContinueCapture() public method

Resumes capture devices after a call to 'PauseCapture()'
public ContinueCapture ( ) : void
return void

ContinueOutput() public method

Resumes output sending (if 'EnableOutput' is false). Any chunks with an index below 'MiniumumChunkIndex' will be dropped.
public ContinueOutput ( int MinimumChunkIndex ) : void
MinimumChunkIndex int
return void

Dispose() public method

public Dispose ( ) : void
return void

EncoderController() public method

Create and initialise a new encoder job with the given config
public EncoderController ( Configuration Config ) : System
Config EncoderConfiguration.Configuration
return System

ForceInsertFrame() public method

Force a timed frame into the encoder's buffers. May cause unexpected operation. Use with caution!
public ForceInsertFrame ( System VideoFrame, double SimulatedCaptureTime ) : void
VideoFrame System
SimulatedCaptureTime double
return void

ForceInsertFrame() public method

Force a timed frame into the encoder's buffers. May cause unexpected operation. Use with caution!
public ForceInsertFrame ( TimedSample AudioFrame ) : void
AudioFrame HCS_Encoder.Inputs.Buffers.TimedSample
return void

PauseCapture() public method

Pauses all capture devices, but allows the encoder loop to continue (will sleep while buffers are empty)
public PauseCapture ( ) : void
return void

RegisterPlugin() public method

Add a plug-in to the audio buffer's plug-in list
public RegisterPlugin ( IAudioProcessor PlugIn ) : void
PlugIn IAudioProcessor
return void

RegisterPlugin() public method

Add a plug-in to the video buffer's plug-in list
public RegisterPlugin ( IVideoProcessor PlugIn ) : void
PlugIn IVideoProcessor
return void

Start() public method

Start the encoding process. This will start to over-write any existing encodes made with the configuration being used.
public Start ( ) : void
return void

Stop() public method

Stop the encoding process
public Stop ( ) : void
return void