Add cls pointer to the logger
[deb_shairplay.git] / src / include / raop.h
1 #ifndef RAOP_H
2 #define RAOP_H
3
4 #if defined (WIN32) && defined(DLL_EXPORT)
5 # define RAOP_API __declspec(dllexport)
6 #else
7 # define RAOP_API
8 #endif
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14
15 /* Define syslog style log levels */
16 #define RAOP_LOG_EMERG 0 /* system is unusable */
17 #define RAOP_LOG_ALERT 1 /* action must be taken immediately */
18 #define RAOP_LOG_CRIT 2 /* critical conditions */
19 #define RAOP_LOG_ERR 3 /* error conditions */
20 #define RAOP_LOG_WARNING 4 /* warning conditions */
21 #define RAOP_LOG_NOTICE 5 /* normal but significant condition */
22 #define RAOP_LOG_INFO 6 /* informational */
23 #define RAOP_LOG_DEBUG 7 /* debug-level messages */
24
25
26 typedef struct raop_s raop_t;
27
28 typedef void (*raop_log_callback_t)(void *cls, int level, const char *msg);
29
30 struct raop_callbacks_s {
31 void* cls;
32
33 /* Compulsory callback functions */
34 void* (*audio_init)(void *cls, int bits, int channels, int samplerate);
35 void (*audio_process)(void *cls, void *session, const void *buffer, int buflen);
36 void (*audio_destroy)(void *cls, void *session);
37
38 /* Optional but recommended callback functions */
39 void (*audio_flush)(void *cls, void *session);
40 void (*audio_set_volume)(void *cls, void *session, float volume);
41 void (*audio_set_metadata)(void *cls, void *session, const void *buffer, int buflen);
42 void (*audio_set_coverart)(void *cls, void *session, const void *buffer, int buflen);
43 };
44 typedef struct raop_callbacks_s raop_callbacks_t;
45
46 RAOP_API raop_t *raop_init(int max_clients, raop_callbacks_t *callbacks, const char *pemkey);
47 RAOP_API raop_t *raop_init_from_keyfile(int max_clients, raop_callbacks_t *callbacks, const char *keyfile);
48
49 RAOP_API void raop_set_log_level(raop_t *raop, int level);
50 RAOP_API void raop_set_log_callback(raop_t *raop, raop_log_callback_t callback, void *cls);
51
52 RAOP_API int raop_start(raop_t *raop, unsigned short *port, const char *hwaddr, int hwaddrlen, const char *password);
53 RAOP_API int raop_is_running(raop_t *raop);
54 RAOP_API void raop_stop(raop_t *raop);
55
56 RAOP_API void raop_destroy(raop_t *raop);
57
58 #ifdef __cplusplus
59 }
60 #endif
61 #endif