2022-11-06 12:30:06 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-12-12 23:50:05 +00:00
|
|
|
File: AuCompressionInterceptor.hpp
|
2022-11-06 12:30:06 +00:00
|
|
|
Date: 2022-9-14
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/Protocol/Protocol.hpp>
|
|
|
|
|
|
|
|
namespace Aurora::Compression
|
|
|
|
{
|
|
|
|
struct CompressionInterceptor : ICompressionInterceptor, IO::IStreamReader
|
|
|
|
{
|
|
|
|
CompressionInterceptor();
|
|
|
|
|
|
|
|
void Init(const AuSPtr<ICompressionStream> &pStream,
|
|
|
|
const AuSPtr<BaseStream> &pBaseStream);
|
|
|
|
|
|
|
|
bool OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
|
|
|
|
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer) override;
|
|
|
|
|
|
|
|
inline virtual IO::EStreamError IsOpen() override;
|
|
|
|
|
|
|
|
inline virtual IO::EStreamError Read(const Memory::MemoryViewStreamWrite ¶meters) override;
|
|
|
|
|
|
|
|
inline virtual void Close() override;
|
|
|
|
|
2022-11-08 19:24:08 +00:00
|
|
|
void FlushNextFrame() override;
|
|
|
|
|
|
|
|
bool ConfigureAutoFlushPerFrame(bool bAutoFlush) override;
|
|
|
|
|
2022-11-07 22:46:35 +00:00
|
|
|
bool LimitHasHit() override;
|
|
|
|
void LimitReset() override;
|
|
|
|
void LimitSet(AuUInt uLength) override;
|
2022-12-16 00:41:01 +00:00
|
|
|
bool LimitPassthroughOnOverflow(bool bPassthrough) override;
|
2022-11-07 22:46:35 +00:00
|
|
|
AuUInt LimitGetIndex() override;
|
|
|
|
|
2022-11-06 12:30:06 +00:00
|
|
|
bool HasFailed() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool bErrorFlag_ {};
|
2022-11-08 19:24:08 +00:00
|
|
|
bool bSendFlush_ {};
|
|
|
|
bool bAutoFlush_ {};
|
2022-11-06 12:30:06 +00:00
|
|
|
AuSPtr<ICompressionStream> pStream_;
|
|
|
|
AuSPtr<BaseStream> pBaseStream_;
|
2022-11-07 13:34:28 +00:00
|
|
|
AuSPtr<Memory::ByteBuffer> pLastBuffer_;
|
2022-11-07 22:46:35 +00:00
|
|
|
AuUInt uCountMax_ { AuNumericLimits<AuUInt>::max() };
|
|
|
|
AuUInt uCount_ {};
|
2022-11-20 10:31:13 +00:00
|
|
|
bool bPassthrough_ {};
|
2022-11-06 12:30:06 +00:00
|
|
|
};
|
|
|
|
}
|