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
30extern "C" {
31#endif
32
33#include <sys/time.h>
34
35#include "xmmsc/xmmsc_stdint.h"
36#include "xmmsc/xmmsc_sockets.h"
37
38double tv2ts (struct timeval *t);
39double net2ts (int32_t* s);
40void ts2net (int32_t* d, double t);
41void 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
60typedef 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
71typedef struct {
72 char *__unaligned_type; /* = 'V' */;
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
97typedef struct {
98 char *__unaligned_type; /* = 'T' */
102 int size;
104
107
108/**
109 * Possible data modes
110 */
111
112typedef 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
123typedef struct {
124 /* type of data */
126 /* wether to send both channels seperate, or mixed */
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
144typedef enum {
149
150typedef enum {
158
159/**
160 * data describing a unixshm transport
161 */
162
163typedef struct {
164 int semid;
165 int shmid;
167 int pos, size;
169
170/**
171 * data describing a udp transport
172 */
173
174typedef 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/** @} */
double net2ts(int32_t *s)
Definition timestamp.c:14
xmmsc_vis_state_t
char * packet_init_timing(xmmsc_vis_udp_timing_t *p)
Definition udp.c:22
#define XMMSC_VISUALIZATION_WINDOW_SIZE
void ts2net(int32_t *d, double t)
Definition timestamp.c:20
char * packet_init_data(xmmsc_vis_udp_data_t *p)
Definition udp.c:8
void tv2net(int32_t *d, struct timeval *t)
Definition timestamp.c:29
xmmsc_vis_transport_t
Possible vis transports.
double tv2ts(struct timeval *t)
Definition timestamp.c:8
xmmsc_vis_data_t
Possible data modes.
@ VIS_TRYING_UNIXSHM
@ VIS_TRYING_UDP
@ VIS_ERRORED
@ VIS_TO_TRY_UDP
@ VIS_WORKING
@ VIS_UNIXSHM
@ VIS_SPECTRUM
Properties of the delivered vis data.
UDP package descriptor to deliver a vis chunk.
xmmsc_vischunk_t * __unaligned_data
data describing a udp transport
UDP package descriptor to synchronize time.
data describing a unixshm transport
xmmsc_vischunk_t * buffer
Package format for vis data, encapsulated by unixshm or udp transport.
int xmms_socket_t