-
Notifications
You must be signed in to change notification settings - Fork 18
/
ni2out.h
183 lines (146 loc) · 3.54 KB
/
ni2out.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* eti_ni2http.h
*
* Created on: 17.09.2013
* Author: tipok
*/
#ifndef ETI_NI2HTTP_H_
#define ETI_NI2HTTP_H_
#include <stdio.h>
#include <inttypes.h>
#include <endian.h>
#include <netinet/in.h>
// Use by gethostname()
#ifndef HOST_NAME_MAX
#ifdef _POSIX_HOST_NAME_MAX
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
#else
#define HOST_NAME_MAX (256)
#endif
#endif
#ifndef DOMAIN_NAME_MAX
#define DOMAIN_NAME_MAX (1024)
#endif
#define MAX_CHANNEL_COUNT 128
// Standard string buffer size
#define STR_BUF_SIZE 1025
#define MAX_CU_COUNT 864
/* Structure containing single channel */
typedef struct ni2http_channel_s {
int num; // channel number
int sid; // Packet Identifier of audio stream
// Metadata about the channel
char name[STR_BUF_SIZE]; // channel name
char genre[STR_BUF_SIZE]; // genre
char description[STR_BUF_SIZE]; // description
char url[STR_BUF_SIZE]; // Informational URL
char file_name[STR_BUF_SIZE]; // Informational URL
FILE *file;
int shout_state;
char is_public; // announce existance?
uint8_t *buf; // MPEG Audio Buffer
uint32_t buf_size; // Usable size of MPEG Audio Buffer
uint32_t buf_used; // Amount of buffer used
int bitrate;
int payload_size; // Size of the payload
int is_dabplus;
uint8_t *dabplus_data;
void *dabplus_rs;
int dabplus_frame;
int extract_dabplus;
int extract_pad;
uint8_t pad_data[STR_BUF_SIZE];
int pad_fillness;
int pad_bytes_left;
int title_switcher;
int pad_last_fl;
void *zmq_sock; /* zmq socket */
} ni2http_channel_t;
#define ZMQ_ENCODER_FDK 1
#define ZMQ_ENCODER_TOOLAME 2
struct zmq_frame_header
{
uint16_t version; // we support version=1 now
uint16_t encoder; // see ZMQ_ENCODER_XYZ
/* length of the 'data' field */
uint32_t datasize;
/* Audio level, peak, linear PCM */
int16_t audiolevel_left;
int16_t audiolevel_right;
/* Data follows this header */
} __attribute__ ((packed));
/* Structure server settings */
typedef struct ni2http_server_s {
char host[STR_BUF_SIZE];
int port;
char user[STR_BUF_SIZE];
char password[STR_BUF_SIZE];
int protocol;
} ni2http_server_t;
typedef struct {
union {
#if __BYTE_ORDER == __LITTLE_ENDIAN
/* reverse order for little-endian */
struct {
uint32_t fl:11;
uint32_t mid:2;
uint32_t fp:3;
uint32_t nst:7;
uint32_t ficf:1;
uint32_t fct:8;
};
#elif __BYTE_ORDER == __BIG_ENDIAN
/* reverse order for little-endian */
struct {
uint32_t fct:8;
uint32_t ficf:1;
uint32_t nst:7;
uint32_t fp:3;
uint32_t mid:2;
uint32_t fl:11;
};
#else
#error "Unknown system endian"
#endif
uint32_t val;
};
} fc_t;
typedef struct {
union {
#if __BYTE_ORDER == __LITTLE_ENDIAN
/* reverse order for little-endian */
struct {
uint32_t stl:10;
uint32_t tpl:6;
uint32_t sad:10;
uint32_t scid:6;
};
#elif __BYTE_ORDER == __BIG_ENDIAN
/* reverse order for little-endian */
struct {
uint32_t scid:6;
uint32_t sad:10;
uint32_t tpl:6;
uint32_t stl:10;
};
#else
#error "Unknown system endian"
#endif
uint32_t val;
};
} sstc_t;
/* In eti_ni2http.c */
extern int channel_count;
extern ni2http_channel_t *channel_map[MAX_CU_COUNT];
extern ni2http_channel_t *channels[MAX_CHANNEL_COUNT];
extern ni2http_server_t ni2http_server;
extern void *zmq_context;
/* In parse_config.c */
int parse_config( char *filepath );
/* In wfcrc.c */
int crccheck(unsigned char* buf, int len);
int crc16check(unsigned char* buf, int len);
/* In wffirecrc.c */
int firecrccheck(unsigned char* buf);
#define DABPLUS
#endif /* ETI_NI2HTTP_H_ */