#pragma once

#include <inttypes.h>

#define MTU_SIZE 1500
#define VBAN_MAX_PACKET MTU_SIZE  - sizeof(VBAN_HEADER) -28

//typedef unsigned int uint32_t ;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;

#define VBAN_MARKER 0x4e414256
					

#pragma pack(1)
typedef struct VBAN_HEADER
{
	uint32_t vban; // contains 'V' 'B', 'A', 'N'
	uint8_t format_SR; // SR index (see SRList above)
	uint8_t format_nbs; // nb sample per frame (1 to 256)
	uint8_t format_nbc; // nb channel (1 to 256)
	uint8_t format_bit; // mask = 0x07 (see DATATYPE table below)
	char streamname[16]; // stream name
	uint32_t noFrame; // growing frame number
} VBAN_HEADER;
#pragma pack()

#define VBAN_CODEC_PCM 0x00
#define VBAN_CODEC_VBCA 0x10 //VB-AUDIO AOIP CODEC
#define VBAN_CODEC_VBCV 0x20 //VB-AUDIO VOIP CODEC
#define VBAN_CODEC_UNDEFINED_1 0x30
#define VBAN_CODEC_UNDEFINED_2 0x40
#define VBAN_CODEC_UNDEFINED_3 0x50
#define VBAN_CODEC_UNDEFINED_4 0x60
#define VBAN_CODEC_UNDEFINED_5 0x70
#define VBAN_CODEC_UNDEFINED_6 0x80
#define VBAN_CODEC_UNDEFINED_7 0x90
#define VBAN_CODEC_UNDEFINED_8 0xA0
#define VBAN_CODEC_UNDEFINED_9 0xB0
#define VBAN_CODEC_UNDEFINED_10 0xC0
#define VBAN_CODEC_UNDEFINED_11 0xD0
#define VBAN_CODEC_UNDEFINED_12 0xE0
#define VBAN_CODEC_USER 0xF0

typedef enum VBAN_CODEC
{
	CODEC_PCM		=	0x00,
	CODEC_VBCA		=	0x10,
	CODEC_VBCV		=	0x20,
	CODEC_UNDEF1	=	0x30,
	CODEC_UNDEF2	=	0x40,
	CODEC_UNDEF3	=	0x50,
	CODEC_UNDEF4	=	0x60,
	CODEC_UNDEF5	=	0x70,
	CODEC_UNDEF6	=	0x80,
	CODEC_UNDEF7	=	0x90,
	CODEC_UNDEF8	=	0xA0,
	CODEC_UNDEF9	=	0xB0,
	CODEC_UNDEF10	=	0xC0,
	CODEC_UNDEF11	=	0xD0,
	CODEC_UNDEF12	=	0xE0,
	CODEC_USER		=	0xF0

}VBAN_CODEC;

#define VBAN_DATATYPE_BYTE8 0x00
#define VBAN_DATATYPE_INT16 0x01
#define VBAN_DATATYPE_INT24 0x02
#define VBAN_DATATYPE_INT32 0x03
#define VBAN_DATATYPE_FLOAT32 0x04
#define VBAN_DATATYPE_FLOAT64 0x05
#define VBAN_DATATYPE_12BITS 0x06
#define VBAN_DATATYPE_10BITS 0x07

typedef enum VBAN_DATATYPE
{
	DATATYPE_BYTE8 = 0x00,
	DATATYPE_INT16 = 0x01,
	DATATYPE_INT24 = 0x02,
	DATATYPE_INT32 = 0x03,
	DATATYPE_FLOAT32= 0x04,
	DATATYPE_FLOAT64= 0x05,
	DATATYPE_12BITS =0x06,
	DATATYPE_10BITS =0x07
}VBAN_DATATYPE;

#define VBAN_PROTOCOL_AUDIO 0x00
#define VBAN_PROTOCOL_SERIAL 0x20
#define VBAN_PROTOCOL_TXT 0x40
#define VBAN_PROTOCOL_SERVICE 0x60
#define VBAN_PROTOCOL_UNDEFINED_1 0x80
#define VBAN_PROTOCOL_UNDEFINED_2 0xA0
#define VBAN_PROTOCOL_UNDEFINED_3 0xC0
#define VBAN_PROTOCOL_USER 0xE0

typedef enum VBAN_PROTOCOL 
{
	PROTOCOL_AUDIO = 0x00,
	PROTOCOL_SERIAL = 0x20,
	PROTOCOL_TXT = 0x40,
	PROTOCOL_SERVICE = 0x60,
	PROTOCOL_UNDEFINED_1 = 0x80,
	PROTOCOL_UNDEFINED_2 = 0xA0,
	PROTOCOL_UNDEFINED_3 = 0xC0,
	PROTOCOL_USER = 0xE0
}VBAN_PROTOCOL;


#define VBAN_SR_MAXNUMBER 21
static long VBAN_SRList[VBAN_SR_MAXNUMBER] =
{ 6000, 12000, 24000, 48000, 96000, 192000, 384000,
8000, 16000, 32000, 64000, 128000, 256000, 512000,
11025, 22050, 44100, 88200, 176400, 352800, 705600 };

typedef enum VBAN_SAMPLERATE 
{
	SR_6000, 
	SR_12000, 
	SR_24000, 
	SR_48000, 
	SR_96000, 
	SR_192000, 
	SR_384000,
	SR_8000, 
	SR_16000, 
	SR_32000, 
	SR_64000, 
	SR_128000, 
	SR_256000, 
	SR_512000,
	SR_11025, 
	SR_22050, 
	SR_44100, 
	SR_88200, 
	SR_176400, 
	SR_352800, 
	SR_705600
}VBAN_SAMPLERATE;