| 1 |
/* $Id: rplay.h,v 1.3 1999/03/10 07:57:27 boyns Exp $ */ |
| 2 |
|
| 3 |
/* |
| 4 |
* Copyright (C) 1993-99 Mark R. Boyns <[email protected]> |
| 5 |
* |
| 6 |
* This file is part of rplay. |
| 7 |
* |
| 8 |
* rplay is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation; either version 2 of the License, or |
| 11 |
* (at your option) any later version. |
| 12 |
* |
| 13 |
* rplay is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with rplay; see the file COPYING. If not, write to the |
| 20 |
* Free Software Foundation, Inc., |
| 21 |
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
| 22 |
*/ |
| 23 |
|
| 24 |
|
| 25 |
#ifndef _rplay_h |
| 26 |
#define _rplay_h |
| 27 |
|
| 28 |
#include <sys/types.h> |
| 29 |
#include <sys/socket.h> |
| 30 |
#include <netinet/in.h> |
| 31 |
#include <stdio.h> |
| 32 |
#include <stdlib.h> |
| 33 |
|
| 34 |
#undef FALSE |
| 35 |
#define FALSE 0 |
| 36 |
#undef TRUE |
| 37 |
#define TRUE 1 |
| 38 |
|
| 39 |
#define RPLAY_PORT 5555 |
| 40 |
#define RPTP_PORT 5556 |
| 41 |
|
| 42 |
#define OLD_RPLAY_PORT 55555 |
| 43 |
#define OLD_RPTP_PORT 55556 |
| 44 |
|
| 45 |
#define RPLAY_PACKET_ID 30 /* id sent with rplay 3.x packets */ |
| 46 |
|
| 47 |
/* Attributes: */ |
| 48 |
#define RPLAY_NULL 0 |
| 49 |
#define RPLAY_PLAY 1 |
| 50 |
#define RPLAY_STOP 2 |
| 51 |
#define RPLAY_PAUSE 3 |
| 52 |
#define RPLAY_CONTINUE 4 |
| 53 |
#define RPLAY_SOUND 5 |
| 54 |
#define RPLAY_VOLUME 6 |
| 55 |
#define RPLAY_NSOUNDS 7 |
| 56 |
#define RPLAY_COMMAND 8 |
| 57 |
#define RPLAY_APPEND 9 |
| 58 |
#define RPLAY_INSERT 10 |
| 59 |
#define RPLAY_DELETE 11 |
| 60 |
#define RPLAY_CHANGE 12 |
| 61 |
#define RPLAY_COUNT 13 |
| 62 |
#define RPLAY_LIST_COUNT 14 |
| 63 |
#define RPLAY_PRIORITY 15 |
| 64 |
#define RPLAY_RANDOM_SOUND 16 |
| 65 |
#define RPLAY_PING 17 |
| 66 |
#define RPLAY_RPTP_SERVER 18 |
| 67 |
#define RPLAY_RPTP_SERVER_PORT 19 |
| 68 |
#define RPLAY_RPTP_SEARCH 20 |
| 69 |
#define RPLAY_RPTP_FROM_SENDER 21 |
| 70 |
#define RPLAY_SAMPLE_RATE 22 |
| 71 |
#define RPLAY_RESET 23 |
| 72 |
#define RPLAY_DONE 24 |
| 73 |
#define RPLAY_CLIENT_DATA 25 |
| 74 |
#define RPLAY_LIST_NAME 26 |
| 75 |
#define RPLAY_PUT 27 |
| 76 |
#define RPLAY_ID 28 |
| 77 |
#define RPLAY_SEQUENCE 29 |
| 78 |
#define RPLAY_DATA 30 |
| 79 |
#define RPLAY_DATA_SIZE 31 |
| 80 |
|
| 81 |
/* audio formats */ |
| 82 |
#define RPLAY_FORMAT_NONE 0 |
| 83 |
#define RPLAY_FORMAT_LINEAR_8 1 /* 8-bit linear PCM */ |
| 84 |
#define RPLAY_FORMAT_ULINEAR_8 2 /* 8-bit unsigned linear PCM */ |
| 85 |
#define RPLAY_FORMAT_LINEAR_16 3 /* 16-bit linear PCM */ |
| 86 |
#define RPLAY_FORMAT_ULINEAR_16 4 /* 16-bit unsigned linear PCM */ |
| 87 |
#define RPLAY_FORMAT_ULAW 5 /* 8-bit ISDN u-law */ |
| 88 |
#define RPLAY_FORMAT_G721 6 /* CCITT G.721 4-bits ADPCM */ |
| 89 |
#define RPLAY_FORMAT_G723_3 7 /* CCITT G.723 3-bits ADPCM */ |
| 90 |
#define RPLAY_FORMAT_G723_5 8 /* CCITT G.723 5-bits ADPCM */ |
| 91 |
#define RPLAY_FORMAT_GSM 9 /* GSM 0.610 13 kbit/s RPE/LTP speech compression */ |
| 92 |
|
| 93 |
/* audio byte order */ |
| 94 |
#define RPLAY_BIG_ENDIAN 1 |
| 95 |
#define RPLAY_LITTLE_ENDIAN 2 |
| 96 |
|
| 97 |
/* Audio ports: */ |
| 98 |
#define RPLAY_AUDIO_PORT_NONE (1<<0) |
| 99 |
#define RPLAY_AUDIO_PORT_SPEAKER (1<<1) |
| 100 |
#define RPLAY_AUDIO_PORT_HEADPHONE (1<<2) |
| 101 |
#define RPLAY_AUDIO_PORT_LINEOUT (1<<3) |
| 102 |
|
| 103 |
/* Attribute restrictions: */ |
| 104 |
#define RPLAY_MIN_VOLUME 0 |
| 105 |
#define RPLAY_MAX_VOLUME 255 |
| 106 |
#define RPLAY_MIN_PRIORITY 0 |
| 107 |
#define RPLAY_MAX_PRIORITY 255 |
| 108 |
|
| 109 |
/* Attribute defaults: */ |
| 110 |
#define RPLAY_DEFAULT_VOLUME 127 |
| 111 |
#define RPLAY_DEFAULT_PRIORITY 0 |
| 112 |
#define RPLAY_DEFAULT_COUNT 1 |
| 113 |
#define RPLAY_DEFAULT_LIST_COUNT 1 |
| 114 |
#define RPLAY_DEFAULT_RANDOM_SOUND -1 |
| 115 |
#define RPLAY_DEFAULT_SAMPLE_RATE 0 |
| 116 |
#define RPLAY_DEFAULT_OFFSET 0 |
| 117 |
#define RPLAY_DEFAULT_BYTE_ORDER 0 |
| 118 |
#define RPLAY_DEFAULT_CHANNELS 0 |
| 119 |
#define RPLAY_DEFAULT_BITS 0 |
| 120 |
|
| 121 |
/* RPLAY errors used by rplay_errno: */ |
| 122 |
#define RPLAY_ERROR_NONE 0 |
| 123 |
#define RPLAY_ERROR_MEMORY 1 |
| 124 |
#define RPLAY_ERROR_HOST 2 |
| 125 |
#define RPLAY_ERROR_CONNECT 3 |
| 126 |
#define RPLAY_ERROR_SOCKET 4 |
| 127 |
#define RPLAY_ERROR_WRITE 5 |
| 128 |
#define RPLAY_ERROR_CLOSE 6 |
| 129 |
#define RPLAY_ERROR_PACKET_SIZE 7 |
| 130 |
#define RPLAY_ERROR_BROADCAST 8 |
| 131 |
#define RPLAY_ERROR_ATTRIBUTE 9 |
| 132 |
#define RPLAY_ERROR_COMMAND 10 |
| 133 |
#define RPLAY_ERROR_INDEX 11 |
| 134 |
#define RPLAY_ERROR_MODIFIER 12 |
| 135 |
|
| 136 |
/* RPTP errors used by rptp_errno: */ |
| 137 |
#define RPTP_ERROR_NONE 0 |
| 138 |
#define RPTP_ERROR_MEMORY 1 |
| 139 |
#define RPTP_ERROR_HOST 2 |
| 140 |
#define RPTP_ERROR_CONNECT 3 |
| 141 |
#define RPTP_ERROR_SOCKET 4 |
| 142 |
#define RPTP_ERROR_OPEN 5 |
| 143 |
#define RPTP_ERROR_READ 6 |
| 144 |
#define RPTP_ERROR_WRITE 7 |
| 145 |
#define RPTP_ERROR_PING 8 |
| 146 |
#define RPTP_ERROR_TIMEOUT 9 |
| 147 |
#define RPTP_ERROR_PROTOCOL 10 |
| 148 |
|
| 149 |
/* RPTP response types: */ |
| 150 |
#define RPTP_ERROR '-' |
| 151 |
#define RPTP_OK '+' |
| 152 |
#define RPTP_TIMEOUT '!' |
| 153 |
#define RPTP_NOTIFY '@' |
| 154 |
|
| 155 |
/* RPLAY 2.0 support: */ |
| 156 |
#define OLD_RPLAY_PLAY 1 |
| 157 |
#define OLD_RPLAY_STOP 2 |
| 158 |
#define OLD_RPLAY_PAUSE 3 |
| 159 |
#define OLD_RPLAY_CONTINUE 4 |
| 160 |
|
| 161 |
/* Definitions for the RPTP asynchronous I/O system: */ |
| 162 |
#define RPTP_ASYNC_READ 1 |
| 163 |
#define RPTP_ASYNC_WRITE 2 |
| 164 |
#define RPTP_ASYNC_RAW 4 |
| 165 |
#define RPTP_ASYNC_ENABLE 1 |
| 166 |
#define RPTP_ASYNC_DISABLE 2 |
| 167 |
|
| 168 |
/* These event can be used to specify a mask: */ |
| 169 |
#define RPTP_EVENT_OK (1 << 0) |
| 170 |
#define RPTP_EVENT_ERROR (1 << 1) |
| 171 |
#define RPTP_EVENT_TIMEOUT (1 << 2) |
| 172 |
#define RPTP_EVENT_OTHER (1 << 3) |
| 173 |
#define RPTP_EVENT_CONTINUE (1 << 4) |
| 174 |
#define RPTP_EVENT_DONE (1 << 5) |
| 175 |
#define RPTP_EVENT_PAUSE (1 << 6) |
| 176 |
#define RPTP_EVENT_PLAY (1 << 7) |
| 177 |
#define RPTP_EVENT_SKIP (1 << 8) |
| 178 |
#define RPTP_EVENT_STATE (1 << 9) |
| 179 |
#define RPTP_EVENT_STOP (1 << 10) |
| 180 |
#define RPTP_EVENT_VOLUME (1 << 11) |
| 181 |
#define RPTP_EVENT_CLOSE (1 << 12) |
| 182 |
#define RPTP_EVENT_FLOW (1 << 13) |
| 183 |
#define RPTP_EVENT_MODIFY (1 << 14) |
| 184 |
#define RPTP_EVENT_LEVEL (1 << 15) |
| 185 |
#define RPTP_EVENT_POSITION (1 << 16) |
| 186 |
#define RPTP_EVENT_ALL 0x0000ffff |
| 187 |
|
| 188 |
/* Size restrictions for RPTP: */ |
| 189 |
#define RPTP_MAX_LINE 1024 |
| 190 |
#define RPTP_MAX_ARGS 32 |
| 191 |
|
| 192 |
/* rplay object attributes: */ |
| 193 |
typedef struct _rplay_attrs |
| 194 |
{ |
| 195 |
struct _rplay_attrs *next; |
| 196 |
char *sound; |
| 197 |
int volume; |
| 198 |
int count; |
| 199 |
char *rptp_server; |
| 200 |
unsigned short rptp_server_port; |
| 201 |
int rptp_search; |
| 202 |
unsigned long sample_rate; |
| 203 |
char *client_data; |
| 204 |
} |
| 205 |
RPLAY_ATTRS; |
| 206 |
|
| 207 |
/* the rplay object */ |
| 208 |
typedef struct _rplay |
| 209 |
{ |
| 210 |
struct _rplay_attrs *attrs; |
| 211 |
struct _rplay_attrs **attrsp; |
| 212 |
char *buf; |
| 213 |
int len; |
| 214 |
int size; |
| 215 |
int command; |
| 216 |
int nsounds; |
| 217 |
int count; |
| 218 |
int priority; |
| 219 |
int random_sound; |
| 220 |
char *list_name; |
| 221 |
int id; |
| 222 |
unsigned long sequence; |
| 223 |
unsigned short data_size; |
| 224 |
char *data; |
| 225 |
} |
| 226 |
RPLAY; |
| 227 |
|
| 228 |
extern int rplay_errno; |
| 229 |
extern int rptp_errno; |
| 230 |
extern char *rplay_errlist[]; |
| 231 |
extern char *rptp_errlist[]; |
| 232 |
|
| 233 |
#ifdef __cplusplus |
| 234 |
#ifndef __STDC__ |
| 235 |
#define __STDC__ |
| 236 |
#endif |
| 237 |
extern "C" |
| 238 |
{ |
| 239 |
#endif |
| 240 |
|
| 241 |
#ifdef __STDC__ |
| 242 |
extern void * xmalloc(size_t size); |
| 243 |
extern RPLAY *rplay_create (int rplay_command); |
| 244 |
extern char *rplay_convert (char *buf); |
| 245 |
extern int rplay_pack (RPLAY * rp); |
| 246 |
extern RPLAY *rplay_unpack (char *buf); |
| 247 |
extern void rplay_destroy (RPLAY * rp); |
| 248 |
extern long rplay_set (RPLAY *,...); |
| 249 |
extern long rplay_get (RPLAY *,...); |
| 250 |
extern int rplay_open (char *host); |
| 251 |
extern int rplay_open_port (char *host, int port); |
| 252 |
extern int rplay_open_sockaddr_in (struct sockaddr_in *saddr); |
| 253 |
extern int rplay (int rplay_fd, RPLAY * rp); |
| 254 |
extern int rplay_close (int rplay_fd); |
| 255 |
extern void rplay_perror (char *message); |
| 256 |
extern int rplay_open_display (void); |
| 257 |
extern int rplay_display (char *sound); |
| 258 |
extern int rplay_local (char *sound); |
| 259 |
extern int rplay_host (char *host, char *sound); |
| 260 |
extern int rplay_host_volume (char *host, char *sound, int volume); |
| 261 |
extern int rplay_sound (int rplay_fd, char *sound); |
| 262 |
extern int rplay_ping (char *host); |
| 263 |
extern int rplay_ping_sockaddr_in (struct sockaddr_in *saddr); |
| 264 |
extern int rplay_ping_sockfd (int sock_fd); |
| 265 |
extern char *rplay_default_host (void); |
| 266 |
extern int rplay_default (char *sound); |
| 267 |
extern int rplay_open_default (void); |
| 268 |
extern int rptp_open (char *host, int port, char *response, int response_size); |
| 269 |
extern int rptp_read (int rptp_fd, char *buf, int nbytes); |
| 270 |
extern int rptp_write (int rptp_fd, char *buf, int nbytes); |
| 271 |
extern int rptp_close (int rptp_fd); |
| 272 |
extern void rptp_perror (char *message); |
| 273 |
extern int rptp_putline (int rptp_fd, char *fmt,...); |
| 274 |
extern int rptp_getline (int rptp_fd, char *buf, int nbytes); |
| 275 |
extern int rptp_command (int rptp_fd, char *command, char *response, int response_size); |
| 276 |
extern char *rptp_parse (char *response, char *name); |
| 277 |
extern int rptp_async_putline (int rptp_fd, void (*callback)(), char *fmt, ...); |
| 278 |
extern int rptp_async_write (int rptp_fd, void (*callback)(), char *ptr, int nbytes); |
| 279 |
extern void rptp_async_register(int rptp_fd, int what, void (*callback)()); |
| 280 |
extern void rptp_async_notify (int rptp_fd, int mask, void (*callback)()); |
| 281 |
extern void rptp_async_process (int rptp_fd, int what); |
| 282 |
extern int rptp_main_loop (void); |
| 283 |
extern void rptp_stop_main_loop (int); |
| 284 |
#else |
| 285 |
extern RPLAY *rplay_create ( /* int rplay_command */ ); |
| 286 |
extern char *rplay_convert ( /* char *buf */ ); |
| 287 |
extern int rplay_pack ( /* RPLAY *rp */ ); |
| 288 |
extern RPLAY *rplay_unpack ( /* char *buf */ ); |
| 289 |
extern void rplay_destroy ( /* RPLAY *rp */ ); |
| 290 |
extern int rplay_set ( /* RPLAY *, ... */ ); |
| 291 |
extern int rplay_get ( /* RPLAY *, ... */ ); |
| 292 |
extern int rplay_open ( /* char *host */ ); |
| 293 |
extern int rplay_open_port ( /* char *host, int port */ ); |
| 294 |
extern int rplay_open_sockaddr_in ( /* struct sockaddr_in *saddr */ ); |
| 295 |
extern int rplay ( /* int rplay_fd, RPLAY *rp */ ); |
| 296 |
extern int rplay_close ( /* int rplay_fd */ ); |
| 297 |
extern void rplay_perror ( /* char *message */ ); |
| 298 |
extern int rplay_open_display (); |
| 299 |
extern int rplay_display ( /* char *sound */ ); |
| 300 |
extern int rplay_local ( /* char *sound */ ); |
| 301 |
extern int rplay_host ( /* char *host, char *sound */ ); |
| 302 |
extern int rplay_host_volume ( /* char *host, char *sound, int volume */ ); |
| 303 |
extern int rplay_sound ( /* int rplay_fd, char *sound */ ); |
| 304 |
extern int rplay_ping ( /* char *host */ ); |
| 305 |
extern int rplay_ping_sockaddr_in ( /* struct sockaddr_in *saddr */ ); |
| 306 |
extern int rplay_ping_sockfd ( /* int sock_fd */ ); |
| 307 |
extern char *rplay_default_host (); |
| 308 |
extern int rplay_default ( /* char *sound */ ); |
| 309 |
extern int rplay_open_default (); |
| 310 |
extern int rptp_open ( /* char *host, int port, char *response, int response_size */ ); |
| 311 |
extern int rptp_read ( /* int rptp_fd, char *buf, int nbytes */ ); |
| 312 |
extern int rptp_write ( /* int rptp_fd, char *buf, int nbytes */ ); |
| 313 |
extern int rptp_close ( /* int rptp_fd */ ); |
| 314 |
extern void rptp_perror ( /* char *message */ ); |
| 315 |
extern int rptp_putline ( /* int rptp_fd, char *fmt, ... */ ); |
| 316 |
extern int rptp_getline ( /* int rptp_fd, char *buf, int nbytes */ ); |
| 317 |
extern int rptp_command ( /* int rptp_fd, char *command, char *response, int response_size */ ); |
| 318 |
extern char *rptp_parse ( /* char *response, char *name */ ); |
| 319 |
extern int rptp_async_putline ( /* int rptp_fd, void (callback *)(), char *fmt, ... */ ); |
| 320 |
extern int rptp_async_write ( /* int rptp_fd, void (callback *)(), char *ptr, int nbytes */ ); |
| 321 |
extern void rptp_async_register (/* int rptp_fd, int what, void (callback*)() */ ); |
| 322 |
extern void rptp_async_notify ( /* int rptp_fd, int what, void (*callback)() */ ); |
| 323 |
extern void rptp_async_process ( /* int rptp_fd, int what */ ); |
| 324 |
extern int rptp_main_loop (); |
| 325 |
extern void rptp_stop_main_loop (); |
| 326 |
#endif |
| 327 |
|
| 328 |
#ifdef __cplusplus |
| 329 |
} |
| 330 |
#endif |
| 331 |
|
| 332 |
#endif /* _rplay_h */ |