arduino-audio-tools
Loading...
Searching...
No Matches
vban.h
Go to the documentation of this file.
1/*
2 * This file is part of vban.
3 * Copyright (c) 2015 by BenoƮt Quiniou <quiniouben@yahoo.fr>
4 *
5 * vban is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * vban is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with vban. If not, see <http://www.gnu.org/licenses/>.
17 */
21//
22// MODIFIED by R. Kinnett, https://github.com/rkinnett, 2020
23//
25#include <stdint.h>
26#include <string.h>
27
28#ifndef __VBAN_H__
29#define __VBAN_H__
30
31#include <inttypes.h>
32
33
34#define VBAN_HEADER_SIZE (4 + 1 + 1 + 1 + 1 + 16)
35#define VBAN_STREAM_NAME_SIZE 16
36#define VBAN_PROTOCOL_MAX_SIZE 1464
37#define VBAN_DATA_MAX_SIZE (VBAN_PROTOCOL_MAX_SIZE - VBAN_HEADER_SIZE)
38#define VBAN_CHANNELS_MAX_NB 256
39#define VBAN_SAMPLES_MAX_NB 256
40
41
42
43#define VBAN_PACKET_NUM_SAMPLES 256
44#define VBAN_PACKET_MAX_SAMPLES 256
45#define VBAN_PACKET_HEADER_BYTES 24
46#define VBAN_PACKET_COUNTER_BYTES 4
47#define VBAN_PACKET_MAX_LEN_BYTES (VBAN_PACKET_HEADER_BYTES + VBAN_PACKET_COUNTER_BYTES + VBAN_PACKET_MAX_SAMPLES*2)
48
49
50typedef struct
51{
52 char preamble[4]; /* contains 'V' 'B', 'A', 'N' */
53 uint8_t sample_rate; /* SR index (see SRList above) */
54 uint8_t num_samples; /* nb sample per frame (1 to 256) */
55 uint8_t num_channels; /* nb channel (1 to 256) */
56 uint8_t sample_format; /* mask = 0x07 (nb Byte integer from 1 to 4) */
57 char stream_name[VBAN_STREAM_NAME_SIZE]; /* stream name */
59
60
61typedef struct {
63 uint32_t* packet_counter;
64 uint8_t* data_frame;
65 uint8_t packet[VBAN_PROTOCOL_MAX_SIZE];
68} VBan;
69
70
71
72
73#define VBAN_SR_MASK 0x1F
74#define VBAN_SR_MAXNUMBER 21
75static long const VBanSRList[VBAN_SR_MAXNUMBER]=
76{
77 6000, 12000, 24000, 48000, 96000, 192000, 384000,
78 8000, 16000, 32000, 64000, 128000, 256000, 512000,
79 11025, 22050, 44100, 88200, 176400, 352800, 705600
80};
81
106
107
108#define VBAN_PROTOCOL_MASK 0xE0
119
120#define VBAN_BIT_RESOLUTION_MASK 0x07
133
135{
136 1, 2, 3, 4, 4, 8,
137};
138
139#define VBAN_RESERVED_MASK 0x08
140
141#define VBAN_CODEC_MASK 0xF0
161
162
163/********************************************************
164 * SERVICE SUB PROTOCOL *
165 ********************************************************/
166// VBAN SERVICE PROTOCOL definitions
167#define VBAN_PROTOCOL_SERVICE 0x60
168
169// Service Types (format_nbc)
170#define VBAN_SERVICE_IDENTIFICATION 0x00
171#define VBAN_SERVICE_CHATUTF8 0x01
172#define VBAN_SERVICE_RTPACKETREGISTER 0x20
173#define VBAN_SERVICE_RTPACKET 0x21
174
175// Service Functions (format_nbs)
176#define VBAN_SERVICE_FNCT_PING0 0x00
177#define VBAN_SERVICE_FNCT_REPLY 0x80
178
180 uint32_t bitType;
181 uint32_t bitfeature;
182 uint32_t bitfeatureEx;
183 uint32_t PreferedRate;
184 uint32_t MinRate;
185 uint32_t MaxRate;
186 uint32_t color_rgb;
187 uint8_t nVersion[4];
188 char GPS_Position[8]; // Keep empty (all zero)
192 char reservedEx[64];
194 uint16_t DistantPort;
200 char UserName_utf8[128];
202} __attribute__((packed));
203/********************************************************
204 * TEXT SUB PROTOCOL *
205 ********************************************************/
206
207#define VBAN_BPS_MASK 0xE0
208#define VBAN_BPS_MAXNUMBER 25
209static long const VBanBPSList[VBAN_BPS_MAXNUMBER] =
210{
211 0, 110, 150, 300, 600,
212 1200, 2400, 4800, 9600, 14400,
213 19200, 31250, 38400, 57600, 115200,
214 128000, 230400, 250000, 256000, 460800,
215 921600,1000000,1500000,2000000, 3000000
216};
217
218#define VBAN_DATATYPE_MASK 0x07
219#define VBAN_DATATYPE_MAXNUMBER 1
224
225#define VBAN_STREAMTYPE_MASK 0xF0
245
246#endif /*__VBAN_H__*/
Definition vban.h:179
uint16_t DistantReserved
Definition vban.h:195
char ManufacturerName_ascii[64]
Definition vban.h:197
char DeviceName_ascii[64]
Definition vban.h:196
char UserName_utf8[128]
Definition vban.h:200
char HostName_ascii[64]
Definition vban.h:199
char USER_Position[8]
Definition vban.h:189
char LangCode_ascii[8]
Definition vban.h:190
char reserved_ascii[8]
Definition vban.h:191
char ApplicationName_ascii[64]
Definition vban.h:198
char UserComment_utf8[128]
Definition vban.h:201
char DistantIP_ascii[32]
Definition vban.h:193
uint8_t nVersion[4]
Definition vban.h:187
uint32_t bitfeature
Definition vban.h:181
uint32_t bitfeatureEx
Definition vban.h:182
uint32_t MaxRate
Definition vban.h:185
char reservedEx[64]
Definition vban.h:192
uint32_t bitType
Definition vban.h:180
uint32_t PreferedRate
Definition vban.h:183
char GPS_Position[8]
Definition vban.h:188
uint32_t color_rgb
Definition vban.h:186
uint32_t MinRate
Definition vban.h:184
uint16_t DistantPort
Definition vban.h:194
Definition vban.h:51
uint8_t num_channels
Definition vban.h:55
uint8_t sample_format
Definition vban.h:56
uint8_t num_samples
Definition vban.h:54
uint8_t sample_rate
Definition vban.h:53
Definition vban.h:61
uint16_t packet_total_bytes
Definition vban.h:67
uint8_t * data_frame
Definition vban.h:64
uint32_t * packet_counter
Definition vban.h:63
uint16_t packet_data_bytes
Definition vban.h:66
VBanHeader * hdr
Definition vban.h:62
#define VBAN_BPS_MAXNUMBER
Definition vban.h:208
VBanSampleRates
Definition vban.h:83
@ SAMPLE_RATE_384000_HZ
Definition vban.h:90
@ SAMPLE_RATE_8000_HZ
Definition vban.h:91
@ SAMPLE_RATE_6000_HZ
Definition vban.h:84
@ SAMPLE_RATE_44100_HZ
Definition vban.h:100
@ SAMPLE_RATE_256000_HZ
Definition vban.h:96
@ SAMPLE_RATE_176400_HZ
Definition vban.h:102
@ SAMPLE_RATE_128000_HZ
Definition vban.h:95
@ SAMPLE_RATE_88200_HZ
Definition vban.h:101
@ SAMPLE_RATE_11025_HZ
Definition vban.h:98
@ SAMPLE_RATE_16000_HZ
Definition vban.h:92
@ SAMPLE_RATE_12000_HZ
Definition vban.h:85
@ SAMPLE_RATE_192000_HZ
Definition vban.h:89
@ SAMPLE_RATE_32000_HZ
Definition vban.h:93
@ SAMPLE_RATE_352800_HZ
Definition vban.h:103
@ SAMPLE_RATE_22050_HZ
Definition vban.h:99
@ SAMPLE_RATE_705600_HZ
Definition vban.h:104
@ SAMPLE_RATE_24000_HZ
Definition vban.h:86
@ SAMPLE_RATE_512000_HZ
Definition vban.h:97
@ SAMPLE_RATE_64000_HZ
Definition vban.h:94
@ SAMPLE_RATE_48000_HZ
Definition vban.h:87
@ SAMPLE_RATE_96000_HZ
Definition vban.h:88
VBanCodec
Definition vban.h:143
@ VBAN_CODEC_UNDEFINED_4
Definition vban.h:148
@ VBAN_CODEC_USER
Definition vban.h:159
@ VBAN_CODEC_UNDEFINED_8
Definition vban.h:152
@ VBAN_CODEC_UNDEFINED_11
Definition vban.h:155
@ VBAN_CODEC_UNDEFINED_12
Definition vban.h:156
@ VBAN_CODEC_UNDEFINED_14
Definition vban.h:158
@ VBAN_CODEC_UNDEFINED_9
Definition vban.h:153
@ VBAN_CODEC_UNDEFINED_3
Definition vban.h:147
@ VBAN_CODEC_UNDEFINED_6
Definition vban.h:150
@ VBAN_CODEC_UNDEFINED_13
Definition vban.h:157
@ VBAN_CODEC_PCM
Definition vban.h:144
@ VBAN_CODEC_VBCV
Definition vban.h:146
@ VBAN_CODEC_VBCA
Definition vban.h:145
@ VBAN_CODEC_UNDEFINED_7
Definition vban.h:151
@ VBAN_CODEC_UNDEFINED_10
Definition vban.h:154
@ VBAN_CODEC_UNDEFINED_5
Definition vban.h:149
#define VBAN_STREAM_NAME_SIZE
Definition vban.h:35
enum VBanDataTypeList __attribute__
#define VBAN_PROTOCOL_MAX_SIZE
Definition vban.h:36
static long const VBanBPSList[25]
Definition vban.h:209
VBanBitResolution
Definition vban.h:122
@ VBAN_BITFMT_32_FLOAT
Definition vban.h:127
@ VBAN_BITFMT_16_INT
Definition vban.h:124
@ VBAN_BITFMT_12_INT
Definition vban.h:129
@ VBAN_BITFMT_10_INT
Definition vban.h:130
@ VBAN_BITFMT_8_INT
Definition vban.h:123
@ VBAN_BITFMT_32_INT
Definition vban.h:126
@ VBAN_BIT_RESOLUTION_MAX
Definition vban.h:131
@ VBAN_BITFMT_24_INT
Definition vban.h:125
@ VBAN_BITFMT_64_FLOAT
Definition vban.h:128
VBanDataTypeList
Definition vban.h:221
@ VBAN_DATATYPE_8BITS
Definition vban.h:222
static int const VBanBitResolutionSize[VBAN_BIT_RESOLUTION_MAX]
Definition vban.h:134
static long const VBanSRList[21]
Definition vban.h:75
VBanProtocol
Definition vban.h:110
@ VBAN_PROTOCOL_SERIAL
Definition vban.h:112
@ VBAN_PROTOCOL_UNDEFINED_2
Definition vban.h:115
@ VBAN_PROTOCOL_UNDEFINED_1
Definition vban.h:114
@ VBAN_PROTOCOL_UNDEFINED_3
Definition vban.h:116
@ VBAN_PROTOCOL_UNDEFINED_4
Definition vban.h:117
@ VBAN_PROTOCOL_TXT
Definition vban.h:113
@ VBAN_PROTOCOL_AUDIO
Definition vban.h:111
#define VBAN_SR_MAXNUMBER
Definition vban.h:74
VBanStreamType
Definition vban.h:227
@ VBAN_TXT_UNDEFINED_6
Definition vban.h:234
@ VBAN_TXT_UTF8
Definition vban.h:229
@ VBAN_TXT_UNDEFINED_13
Definition vban.h:241
@ VBAN_TXT_USER
Definition vban.h:243
@ VBAN_TXT_UNDEFINED_11
Definition vban.h:239
@ VBAN_TXT_UNDEFINED_9
Definition vban.h:237
@ VBAN_TXT_UNDEFINED_14
Definition vban.h:242
@ VBAN_TXT_UNDEFINED_10
Definition vban.h:238
@ VBAN_TXT_UNDEFINED_4
Definition vban.h:232
@ VBAN_TXT_UNDEFINED_12
Definition vban.h:240
@ VBAN_TXT_UNDEFINED_5
Definition vban.h:233
@ VBAN_TXT_UNDEFINED_7
Definition vban.h:235
@ VBAN_TXT_UNDEFINED_3
Definition vban.h:231
@ VBAN_TXT_UNDEFINED_8
Definition vban.h:236
@ VBAN_TXT_ASCII
Definition vban.h:228
@ VBAN_TXT_WCHAR
Definition vban.h:230