/*
 * DataRecorderFormat.h
 *
 */

#ifndef DATARECORDERFORMAT_H_
#define DATARECORDERFORMAT_H_

#include <stdint.h>

struct DataRecorderFormat
{
	enum
	{
		K_ESSENTIAL_MARKER0=0x5A5A5A5A,
		K_ESSENTIAL_MARKER1=0x5A5A5A5A,

                K_MARKER_END=0xA5A5A5A5,

                K_MARKER_DATA=0x41544144,

		K_ESSENTIAL_VERSION=0x0001	//0.1
	};

	struct name_t
	{
		char name[16];
	};

	struct BlockEssentialHeader	//4 works
	{
		uint32_t marker[2];
		uint32_t version;
		uint32_t spare;
        uint32_t block_header_size;
		uint32_t block_size;
	};

	struct BlockHeader
	{
		uint32_t skip_offset;
		uint32_t counter;
        uint32_t timetag_us;

		uint32_t b_counter;
		uint32_t s_counter;
		uint32_t b_timetag;
		uint32_t s_timetag;

		uint32_t buffer_status;
		uint32_t buffer_level;

		//uint32_t spare__[2];

		uint32_t chunk_info_size;
		uint32_t extra_info_size;
	};

	struct Chunk
	{
		uint32_t chunk_marker[2];
		uint32_t meta_size;
		name_t name;
		uint32_t size;
		uint32_t id;
        uint32_t type; //type_t
		uint32_t spare[1];
		uint32_t data_marker[2];
		uint32_t data[1];
	};

	struct BlockData
	{
		name_t blockName;
		uint32_t decoder_info;
		uint32_t chunks;
		Chunk chunk;
	};

	struct Block
	{
        BlockEssentialHeader headerEssential; //supposing to hold enought info to skip to next block
		BlockHeader header;
		BlockData data;
	};


	class RecorderChunk
	{
	public:
		uint32_t marker;
		uint32_t size;
		uint32_t data[1];
	};
};



#endif /* DATARECORDERFORMAT_H_ */
