Home Units Hierarchy Routines All identifiers

Class unaAbstractEncoder

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type unaAbstractEncoder = class(unaObject)

Description

Base abstract class for stream encoder/decoder.

Hierarchy

Overview

Fields

Protected f_errorCode: UNA_ENCODER_ERR;
Protected f_configOK: bool;
Protected f_opened: bool;
Protected f_inBuf: pointer;
Protected f_inBufSize: unsigned;
Protected f_outBuf: pointer;
Protected f_outBufSize: unsigned;
Protected f_outBufUsed: DWORD;
Protected f_inputChunkSize: int;
Protected f_minOutputBufSize: DWORD;
Protected f_encodedDataSize: unsigned;

Methods

Public constructor create(priority: integer = THREAD_PRIORITY_NORMAL);
Public function close(): UNA_ENCODER_ERR;
Public function encodeChunk(data: pointer; size: unsigned; lastOne: bool = false): unsigned;
Public function encodeChunkInPlace(data: pointer; var size: unsigned; outBuf: pointer; outBufSize: unsigned): unsigned;
Public function open(): UNA_ENCODER_ERR;
Public function read(buf: pointer; size: unsigned = 0): unsigned;
Public function setConfig(config: pointer): UNA_ENCODER_ERR;
Protected function doClose(): UNA_ENCODER_ERR; virtual; abstract;
Protected function doDAEvent(data: pointer; size: unsigned): bool; virtual;
Protected function doEncode(data: pointer; nBytes: unsigned; out bytesUsed: unsigned): UNA_ENCODER_ERR; virtual; abstract;
Protected function doOpen(): UNA_ENCODER_ERR; virtual; abstract;
Protected function doSetConfig(config: pointer): UNA_ENCODER_ERR; virtual; abstract;
Protected function enter(timeout: tTimeout): bool;
Protected function leave(): bool;
Public procedure AfterConstruction(); override;
Public procedure BeforeDestruction(); override;
Public procedure lazyWrite(buf: pointer; size: unsigned);

Properties

Public property availableInputDataSize: unsigned index 1 read get_availableDataSize;
Public property availableLazyDataSize: unsigned index 2 read get_availableDataSize;
Public property availableOutputDataSize: unsigned index 0 read get_availableDataSize;
Public property encodedDataSize: unsigned read f_encodedDataSize;
Public property errorCode: UNA_ENCODER_ERR read f_errorCode;
Public property inputChunkSize: int read f_inputChunkSize;
Public property onDataAvailable: tUnaEncoderDataAvailableEvent read f_onDA write f_onDA;
Public property priority: integer read get_priority write set_priority;

Description

Fields

Protected f_errorCode: UNA_ENCODER_ERR;
 
Protected f_configOK: bool;
 
Protected f_opened: bool;
 
Protected f_inBuf: pointer;
 
Protected f_inBufSize: unsigned;
 
Protected f_outBuf: pointer;
 
Protected f_outBufSize: unsigned;
 
Protected f_outBufUsed: DWORD;
 
Protected f_inputChunkSize: int;
 
Protected f_minOutputBufSize: DWORD;

must be set by doSetup();

Protected f_encodedDataSize: unsigned;
 

Methods

Public constructor create(priority: integer = THREAD_PRIORITY_NORMAL);

Creates an encoder with specified priority.

@priority has meaning with lazyWrite() method only.

Public function close(): UNA_ENCODER_ERR;

Deactivates the encoder.

Public function encodeChunk(data: pointer; size: unsigned; lastOne: bool = false): unsigned;

Returns number of bytes produced by encoder. Encoded data is first sent to onDataAvailable() event (if handler is assigned). If this event has no handler assigned, or handler returns writeToStream = true, data is also written into ouput stream.

Check errorCode property if 0 was returned.

Do not mix lazyWrite() and encodeChunk() calls.

Public function encodeChunkInPlace(data: pointer; var size: unsigned; outBuf: pointer; outBufSize: unsigned): unsigned;

Encodes a chunk of data. Encoded data is copied into outBuf. Returns actual number of bytes produced by this function or zero if some error has occured. Writes encoded data into outBuf. Number of bytes written into outBuf will not exceed outBufSize (which could be less than required). This function does not call onDataAvailable() and does not write any data into output stream. Size parameter also used to return number of bytes used in input buffer.

Check errorCode property if 0 was returned.

Do not mix lazyWrite() and encodeChunkInPlace() calls.

Public function open(): UNA_ENCODER_ERR;

Activates the encoder.

Public function read(buf: pointer; size: unsigned = 0): unsigned;

Reads data from the encoder output buffer.

Returns

number of bytes read from output buffer.

Public function setConfig(config: pointer): UNA_ENCODER_ERR;

Configures encoder with specific stream parameters.

Protected function doClose(): UNA_ENCODER_ERR; virtual; abstract;

Override this method to provide implementation of closing the encoder.

Returns

status code of encoder after was closed.

Protected function doDAEvent(data: pointer; size: unsigned): bool; virtual;
 
Protected function doEncode(data: pointer; nBytes: unsigned; out bytesUsed: unsigned): UNA_ENCODER_ERR; virtual; abstract;

Override this method to provide implementation of encoding the portion of data.

Returns

status code of encoding.

Protected function doOpen(): UNA_ENCODER_ERR; virtual; abstract;

Override this method to provide implementation of opening the encoder.

Returns

status code of encoder after it was opened.

Protected function doSetConfig(config: pointer): UNA_ENCODER_ERR; virtual; abstract;

Override this method to provide implementation of encoder configuration.

Returns

status code of encoder after config information provided with config parameter was applied.

Protected function enter(timeout: tTimeout): bool;
 
Protected function leave(): bool;
 
Public procedure AfterConstruction(); override;
 
Public procedure BeforeDestruction(); override;
 
Public procedure lazyWrite(buf: pointer; size: unsigned);

Returns immediately after copying the data from buffer. Uses internal thread to feed the encoder.

Do not mix lazyWrite() and encodeChunk() calls.

Properties

Public property availableInputDataSize: unsigned index 1 read get_availableDataSize;

Returns number of bytes awaiting to be processed in the input stream.

Public property availableLazyDataSize: unsigned index 2 read get_availableDataSize;

Returns number of bytes awaiting to be processed in the input stream of lazy thread.

Public property availableOutputDataSize: unsigned index 0 read get_availableDataSize;

Returns number of bytes available to read from output stream.

Public property encodedDataSize: unsigned read f_encodedDataSize;

Number of bytes encoded so far.

Public property errorCode: UNA_ENCODER_ERR read f_errorCode;

Encoder status code.

Public property inputChunkSize: int read f_inputChunkSize;

Size of input chunk in bytes.

Public property onDataAvailable: tUnaEncoderDataAvailableEvent read f_onDA write f_onDA;

Can be fired from internal thread, so do not use VCL calls in the handler. If you assign a handler for this event, and will not change the copyToStream parameter, data will not be copied into output stream.

Public property priority: integer read get_priority write set_priority;

Priority of encoder thread. Has meaning only when you are using lazyWrite().

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09