#include "demo_compressed_video_media_type_deserializer.h"
#include "adtf2_compressed_video_types.h"
#include <base64_codec/base64.h>
using namespace video_codec;
namespace adtf_file
{
namespace adtf2
{
namespace compressed_video
{
static PluginInitializer initializer([]
{
getObjects().push_back(std::make_shared<DemoCompressedVideoMediaTypeDeserializer>());
});
std::string DemoCompressedVideoMediaTypeDeserializer::getId() const
{
return "adtf.type.video_compressed.adtf2_support.serialization.adtf.cid";
}
void DemoCompressedVideoMediaTypeDeserializer::deserialize(InputStream& stream,
PropertyStreamType& stream_type) const
{
uint32_t major_type{}, sub_type{}, flags{}, size{};
CodecInfo codec_info{};
stream >> major_type >> sub_type >> flags >> size;
size_t attached_bytes_size{size - sizeof(CodecInfo)};
codec_info.size = size;
stream >> codec_info.version
>> codec_info.bitmap_format.width
>> codec_info.bitmap_format.height
>> codec_info.bitmap_format.bits_per_pixel
>> codec_info.bitmap_format.pixel_format
>> codec_info.bitmap_format.bytes_per_line
>> codec_info.bitmap_format.size
>> codec_info.bitmap_format.palette_size;
std::vector<char> codec_name(ADTF_MAX_CODEC_NAME_LENGTH, '\0');
std::vector<uint8_t> attached_bytes(attached_bytes_size);
stream.read(codec_name.data(), ADTF_MAX_CODEC_NAME_LENGTH);
stream_type.setMetaType("adtf/video_compressed");
stream_type.setProperty("codec_size", "tUInt32", std::to_string(codec_info.size));
stream_type.setProperty("codec_version", "tUInt32", std::to_string(codec_info.version));
stream_type.setProperty("bitmap_pixel_width", "tInt32", std::to_string(codec_info.bitmap_format.width));
stream_type.setProperty("bitmap_pixel_height", "tInt32", std::to_string(codec_info.bitmap_format.height));
stream_type.setProperty("bitmap_bits_per_pixel", "tInt32", std::to_string(codec_info.bitmap_format.bits_per_pixel));
stream_type.setProperty("bitmap_pixel_format", "tInt32", std::to_string(codec_info.bitmap_format.pixel_format));
stream_type.setProperty("bitmap_bytes_per_line", "tInt32", std::to_string(codec_info.bitmap_format.bytes_per_line));
stream_type.setProperty("bitmap_byte_size", "tInt32", std::to_string(codec_info.bitmap_format.size));
stream_type.setProperty("bitmap_palette_size", "tInt32", std::to_string(codec_info.bitmap_format.palette_size));
stream_type.setProperty("codec_name", "cString", codec_name.data());
if (attached_bytes_size > 0)
{
stream.read(attached_bytes.data(), attached_bytes_size);
stream_type.setProperty("attached_base64_data", "cString", base64_codec::Base64::encode(attached_bytes));
}
}
}
}
}