XMMS2
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;
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;
75  int size;
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;
102  int size;
104 
107 
108 /**
109  * Possible data modes
110  */
111 
112 typedef enum {
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 */
126  /* wether to send both channels seperate, or mixed */
127  int stereo;
128  /* wether the stereo signal should go 00001111 (false) or 01010101 (true) */
130 
131  /* TODO: implement following.. */
132  double freq;
133  double timeframe;
134  /* pcm amount of data wanted */
136  /* pcm bitsize wanted */
137 /* TODO xmms_sample_format_t pcm_sampleformat;*/
139 
140 /**
141  * Possible vis transports
142  */
143 
144 typedef enum {
149 
150 typedef enum {
158 
159 /**
160  * data describing a unixshm transport
161  */
162 
163 typedef struct {
164  int semid;
165  int shmid;
167  int pos, size;
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;
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif
190 
191 /** @} */
xmmsc_vischunk_t * buffer
void ts2net(int32_t *d, double t)
Definition: timestamp.c:20
data describing a udp transport
double net2ts(int32_t *s)
Definition: timestamp.c:14
UDP package descriptor to synchronize time.
xmmsc_vischunk_t * __unaligned_data
UDP package descriptor to deliver a vis chunk.
xmmsc_vis_transport_t
Possible vis transports.
xmmsc_vis_data_t
Possible data modes.
char * packet_init_data(xmmsc_vis_udp_data_t *p)
Definition: udp.c:8
int xmms_socket_t
Definition: xmmsc_sockets.h:37
#define XMMSC_VISUALIZATION_WINDOW_SIZE
Properties of the delivered vis data.
data describing a unixshm transport
Package format for vis data, encapsulated by unixshm or udp transport.
xmmsc_vis_state_t
char * packet_init_timing(xmmsc_vis_udp_timing_t *p)
Definition: udp.c:22
void tv2net(int32_t *d, struct timeval *t)
Definition: timestamp.c:29
double tv2ts(struct timeval *t)
Definition: timestamp.c:8