VideoCodec/Modules/StreamFormat/StreamFormatter.cpp
#include "StreamFormatter.h"
namespace VideoCodec
{
StreamFormatter::StreamFormatter() : Module(STREAM_FORMATTER_MODULE_ID)
{
this->output = NULL;
}
StreamFormatter::~StreamFormatter()
{
this->output = NULL;
}
ConfigurationStatus StreamFormatter::Configure(ConfigurationElement* configuration)
{
return MODULE_CONFIGURATION_OK;
}
void StreamFormatter::SetOutputModule(StreamOutputModule* outputModule)
{
this->output = outputModule;
}
void StreamFormatter::OutputFormatHeader()
{
if (this->output == NULL)
{
Logger::LogMessage("Warning: An output module must be set for the stream formatter.");
return;
}
this->output->Write((CodecIdentifier)STREAM_FORMAT_CODEC_IDENTIFIER);
this->output->Write((StreamFormatIdentifier)STREAM_FORMAT_VERSION_IDENTIFIER);
}
void StreamFormatter::OutputStreamHeader(FrameCount totalFrameCount, BlockCount blockColumns, BlockCount blockRows, bool mv4, bool halfPixel)
{
if (this->output == NULL)
{
Logger::LogMessage("Warning: An output module must be set for the stream formatter.");
return;
}
this->output->Write(totalFrameCount);
this->output->Write(blockColumns);
this->output->Write(blockRows);
this->output->Write((unsigned char)(mv4 ? 1 : 0));
this->output->Write((unsigned char)(halfPixel ? 1 : 0));
}
void StreamFormatter::OutputFrameHeader(bool pFrame, DCTCoefficientQuantizationMethod quantizationMethod, UnsignedByte quantizationScale)
{
if (this->output == NULL)
{
Logger::LogMessage("Warning: An output module must be set for the stream formatter.");
return;
}
this->output->Write((unsigned char)(pFrame ? 1 : 0));
this->output->Write((unsigned char)(quantizationMethod));
this->output->Write((unsigned char)(quantizationScale));
}
void StreamFormatter::OutputFrame(UnsignedByte* frameData, FrameDataByteCount elements)
{
if (this->output == NULL)
{
Logger::LogMessage("Warning: An output module must be set for the stream formatter.");
return;
}
this->output->Write(frameData, elements);
}
}