9 using System.Runtime.InteropServices;
25 internal ZStream _ztream =
new ZStream();
40 private GCHandle _hInput;
41 private GCHandle _hOutput;
43 private uint _checksum = 0;
54 _hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned);
55 _hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned);
77 if (_ztream.total_out > 0)
79 if (DataAvailable != null)
92 Add(data,0,data.Length);
109 public abstract void Finish();
118 #region Destructor & IDisposable stuff 140 protected abstract void CleanUp();
143 private void CleanUp(
bool isDisposing)
148 if (_hInput.IsAllocated)
150 if (_hOutput.IsAllocated)
160 #region Helper methods 170 Array.Copy(data, startIndex, _inBuffer,0, count);
171 _ztream.next_in = _hInput.AddrOfPinnedObject();
172 _ztream.total_in = 0;
173 _ztream.avail_in = (
uint)count;
182 _ztream.total_out = 0;
184 _ztream.next_out = _hOutput.AddrOfPinnedObject();
Declares methods and events for implementing compressors/decompressors
void setChecksum(uint newSum)
Updates the running checksum property
Implements the common functionality needed for all Codecs
abstract void CleanUp()
Performs any codec specific cleanup
CodecBase()
Initializes a new instance of the CodeBase class.
abstract void Finish()
Finishes up any pending data that needs to be processed and handled.
void Add(byte[] data)
Adds more data to the codec to be processed.
void copyInput(byte[] data, int startIndex, int count)
Copies a number of bytes to the internal codec buffer - ready for proccesing
void Dispose()
Releases any unmanaged resources and calls the CleanUp() method of the derived class ...
GLsizei GLsizei GLenum GLenum const GLvoid * data
void OnDataAvailable()
Fires the DataAvailable event
void resetOutput()
Resets the internal output buffers to a known state - ready for processing
uint Checksum
Gets the checksum of the data that has been added so far
bool _isDisposed
True if the object instance has been disposed, false otherwise
GLuint GLuint GLsizei count
delegate void DataAvailableHandler(byte[] data, int startIndex, int count)
Represents the method that will be called from a codec when new data are available.
const int kBufferSize
The size of the internal buffers
DataAvailableHandler DataAvailable
Occurs when more processed data are available.