XMMS2
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
include
xmmsc
xmmsc_visualization.h
Go to the documentation of this file.
1
/* XMMS2 - X Music Multiplexer System
2
* Copyright (C) 2003-2011 XMMS2 Team
3
*
4
* PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*/
16
17
/** @defgroup Visualization Common
18
* @brief Common structs for the visualization client and server
19
* @{
20
*/
21
22
#ifndef __XMMS_VIS_COMMON_H__
23
#define __XMMS_VIS_COMMON_H__
24
25
/* 512 is what libvisual wants for pcm data.
26
we won't deliver more than 512 samples at once. */
27
#define XMMSC_VISUALIZATION_WINDOW_SIZE 512
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
#include <sys/time.h>
34
35
#include "
xmmsc/xmmsc_stdint.h
"
36
#include "
xmmsc/xmmsc_sockets.h
"
37
38
double
tv2ts
(
struct
timeval *t);
39
double
net2ts
(int32_t* s);
40
void
ts2net
(int32_t* d,
double
t);
41
void
tv2net
(int32_t* d,
struct
timeval *t);
42
43
/* Note that features should only be added to the packet data, _not_
44
removed. The packet's format should stay downwardly compatible.
45
The client only tests if the server's version is equal or greater
46
than the client's version! */
47
#define XMMS_VISPACKET_VERSION 1
48
49
/* How many packages are in the shm queue?
50
* one package the server can operate on
51
* one packate the client can operate on
52
* to avoid needing to be in sync, one spare packet
53
* XXX packets to compensate the latency (TODO: find a good value) */
54
#define XMMS_VISPACKET_SHMCOUNT 500
55
56
/**
57
* Package format for vis data, encapsulated by unixshm or udp transport
58
*/
59
60
typedef
struct
{
61
int32_t timestamp[2];
62
uint16_t
format
;
63
uint16_t
size
;
64
int16_t data[2 *
XMMSC_VISUALIZATION_WINDOW_SIZE
];
65
}
xmmsc_vischunk_t
;
66
67
/**
68
* UDP package _descriptor_ to deliver a vis chunk
69
*/
70
71
typedef
struct
{
72
char
*
__unaligned_type
;
/* = 'V' */
;
73
uint16_t *__unaligned_grace;
74
xmmsc_vischunk_t
*
__unaligned_data
;
75
int
size
;
76
}
xmmsc_vis_udp_data_t
;
77
78
#define XMMSC_VIS_UNALIGNED_WRITE(dst, src, typ) do { \
79
typ *__d = (dst); \
80
typ __s = (src); \
81
memcpy (__d, &__s, sizeof (typ)); \
82
} while (0)
83
84
#define XMMSC_VIS_UNALIGNED_READ(dst, src, typ) do { \
85
typ *__s = (src); \
86
memcpy (&(dst), __s, sizeof (typ)); \
87
} while (0)
88
89
90
91
#define XMMS_VISPACKET_UDP_OFFSET (1 + sizeof (uint16_t))
92
93
/**
94
* UDP package _descriptor_ to synchronize time
95
*/
96
97
typedef
struct
{
98
char
*
__unaligned_type
;
/* = 'T' */
99
int32_t *
__unaligned_id
;
100
int32_t *
__unaligned_clientstamp
;
101
int32_t *
__unaligned_serverstamp
;
102
int
size
;
103
}
xmmsc_vis_udp_timing_t
;
104
105
char
*
packet_init_data
(
xmmsc_vis_udp_data_t
*p);
106
char
*
packet_init_timing
(
xmmsc_vis_udp_timing_t
*p);
107
108
/**
109
* Possible data modes
110
*/
111
112
typedef
enum
{
113
VIS_PCM
,
114
VIS_SPECTRUM
,
115
VIS_PEAK
116
}
xmmsc_vis_data_t
;
117
118
/**
119
* Properties of the delivered vis data. The client doesn't use this struct
120
* to date, but perhaps could in future
121
*/
122
123
typedef
struct
{
124
/* type of data */
125
xmmsc_vis_data_t
type
;
126
/* wether to send both channels seperate, or mixed */
127
int
stereo
;
128
/* wether the stereo signal should go 00001111 (false) or 01010101 (true) */
129
int
pcm_hardwire
;
130
131
/* TODO: implement following.. */
132
double
freq
;
133
double
timeframe
;
134
/* pcm amount of data wanted */
135
int
pcm_samplecount
;
136
/* pcm bitsize wanted */
137
/* TODO xmms_sample_format_t pcm_sampleformat;*/
138
}
xmmsc_vis_properties_t
;
139
140
/**
141
* Possible vis transports
142
*/
143
144
typedef
enum
{
145
VIS_UNIXSHM
,
146
VIS_UDP
,
147
VIS_NONE
148
}
xmmsc_vis_transport_t
;
149
150
typedef
enum
{
151
VIS_NEW
,
152
VIS_TRYING_UNIXSHM
,
153
VIS_TO_TRY_UDP
,
154
VIS_TRYING_UDP
,
155
VIS_ERRORED
,
156
VIS_WORKING
,
157
}
xmmsc_vis_state_t
;
158
159
/**
160
* data describing a unixshm transport
161
*/
162
163
typedef
struct
{
164
int
semid
;
165
int
shmid
;
166
xmmsc_vischunk_t
*
buffer
;
167
int
pos,
size
;
168
}
xmmsc_vis_unixshm_t
;
169
170
/**
171
* data describing a udp transport
172
*/
173
174
typedef
struct
{
175
// client address, used by server
176
struct
sockaddr_storage addr;
177
// file descriptors, used by the client
178
xmms_socket_t
socket[2];
179
// watch adjustment, used by the client
180
double
timediff
;
181
// grace value (lifetime of the client without pong)
182
int
grace
;
183
}
xmmsc_vis_udp_t
;
184
185
#ifdef __cplusplus
186
}
187
#endif
188
189
#endif
190
191
/** @} */
Generated by
1.8.1