]> git.ipfire.org Git - thirdparty/shairport-sync.git/blame - metadata_hub.h
Update check_classic_systemd_full.yml
[thirdparty/shairport-sync.git] / metadata_hub.h
CommitLineData
6af24f7c
MB
1#pragma once
2#include "common.h"
3#include "config.h"
4#include <pthread.h>
5
aaee366f
MB
6#define number_of_watchers 2
7
85ba78b6 8typedef enum {
cbbe84d8
MB
9 PS_NOT_AVAILABLE = 0,
10 PS_STOPPED,
6af24f7c 11 PS_PAUSED,
64d36693 12 PS_PLAYING,
6af24f7c
MB
13} play_status_type;
14
85ba78b6 15typedef enum {
604ca8de
MB
16 AM_INACTIVE = 0,
17 AM_ACTIVE,
5af61798 18} active_state_type;
604ca8de 19
85ba78b6 20typedef enum {
cbbe84d8
MB
21 SS_NOT_AVAILABLE = 0,
22 SS_OFF,
6af24f7c
MB
23 SS_ON,
24} shuffle_status_type;
25
85ba78b6 26typedef enum {
cbbe84d8
MB
27 RS_NOT_AVAILABLE = 0,
28 RS_OFF,
29 RS_ONE,
6af24f7c
MB
30 RS_ALL,
31} repeat_status_type;
32
86b6d7bf
MB
33int string_update(char **str, int *changed, char *s);
34int int_update(int *receptacle, int *changed, int value);
cb69c1dd 35
aaee366f
MB
36struct metadata_bundle;
37
38typedef void (*metadata_watcher)(struct metadata_bundle *argc, void *userdata);
39
6af24f7c 40typedef struct metadata_bundle {
c02e53ea 41
cb69c1dd
MB
42 char *client_ip; // IP number used by the audio source (i.e. the "client"), which is also the DACP
43 // server
86b6d7bf
MB
44 int client_ip_changed;
45
3e4b67e9
MB
46 char *client_name; // the name of the client device, if available
47 int client_name_changed;
48
cb69c1dd 49 char *server_ip; // IP number used by Shairport Sync
86b6d7bf 50 int server_ip_changed;
d6536a8e 51
d67909b8
MB
52 char *stream_type; // Realtime or Buffered
53 int stream_type_changed;
86b6d7bf
MB
54
55 char *progress_string; // progress string, emitted by the source from time to time
56 int progress_string_changed;
57
a9c1e5c4
MB
58 char *frame_position_string; // frame position string emitted by SPS on request
59 int frame_position_string_changed;
60
37f060f4
MB
61 char *first_frame_position_string; // first frame position string emitted by SPS on request
62 int first_frame_position_string_changed;
63
f9845d01 64 int player_thread_active; // true if a play thread is running
4aab0a6f
MB
65 int dacp_server_active; // true if there's a reachable DACP server (assumed to be the Airplay
66 // client) ; false otherwise
340e365a
MB
67 int advanced_dacp_server_active; // true if there's a reachable DACP server with iTunes
68 // capabilitiues
69 // ; false otherwise
cf6b98df
MB
70 int dacp_server_has_been_active; // basically this is a delayed version of dacp_server_active,
71 // used detect transitions between server activity being on or off
72 // e.g. to reease metadata when a server goes inactive, but not if it's permanently
73 // inactive.
85ba78b6
MB
74 play_status_type play_status;
75 shuffle_status_type shuffle_status;
76 repeat_status_type repeat_status;
6af24f7c 77
86b6d7bf
MB
78 // the following pertain to the track playing
79
80 char *cover_art_pathname;
81 int cover_art_pathname_changed;
d6536a8e 82
789ba1ee 83 uint64_t item_id; // seems to be a track ID -- see itemid in DACP.c
86b6d7bf 84 int item_id_changed;
d67909b8 85 int item_id_is_valid;
86b6d7bf
MB
86
87 unsigned char
88 item_composite_id[16]; // seems to be nowplaying 4 ids: dbid, plid, playlistItem, itemid
89 int item_composite_id_changed;
d67909b8
MB
90 int item_composite_id_is_valid;
91
d67909b8
MB
92 int song_data_kind;
93 int song_data_kind_changed;
94 int song_data_kind_is_valid;
d6536a8e 95
86b6d7bf
MB
96 char *track_name;
97 int track_name_changed;
98
99 char *artist_name;
100 int artist_name_changed;
101
102 char *album_artist_name;
103 int album_artist_name_changed;
104
105 char *album_name;
106 int album_name_changed;
107
108 char *genre;
109 int genre_changed;
110
111 char *comment;
112 int comment_changed;
113
114 char *composer;
115 int composer_changed;
116
117 char *file_kind;
118 int file_kind_changed;
119
120 char *song_description;
121 int song_description_changed;
122
123 char *song_album_artist;
124 int song_album_artist_changed;
125
126 char *sort_name;
127 int sort_name_changed;
128
129 char *sort_artist;
130 int sort_artist_changed;
131
132 char *sort_album;
133 int sort_album_changed;
134
135 char *sort_composer;
136 int sort_composer_changed;
137
138 uint32_t songtime_in_milliseconds;
139 int songtime_in_milliseconds_changed;
d67909b8 140 int songtime_in_milliseconds_is_valid;
e0aa75a8 141
86b6d7bf 142 // end
6b5a1b39 143
85ba78b6 144 play_status_type
e0aa75a8 145 player_state; // this is the state of the actual player itself, which can be a bit noisy.
85ba78b6 146 active_state_type active_state;
e0aa75a8
MB
147
148 int speaker_volume; // this is the actual speaker volume, allowing for the main volume and the
149 // speaker volume control
fe8198a2 150 double airplay_volume;
d692fab9 151
aaee366f
MB
152 metadata_watcher watchers[number_of_watchers]; // functions to call if the metadata is changed.
153 void *watchers_data[number_of_watchers]; // their individual data
154
6af24f7c
MB
155} metadata_bundle;
156
85ba78b6 157extern struct metadata_bundle metadata_store;
6af24f7c 158
aaee366f 159void add_metadata_watcher(metadata_watcher fn, void *userdata);
aaee366f 160
0801290a 161void metadata_hub_init(void);
f1d45034 162void metadata_hub_stop(void);
7c762e65 163void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t length);
bef287d9
MB
164void metadata_hub_reset_track_metadata(void);
165void metadata_hub_release_track_artwork(void);
72dd8f50 166
a0bb2993
MB
167// these functions lock and unlock the read-write mutex on the metadata hub and run the watchers
168// afterwards
2d7ae4bc 169void _metadata_hub_modify_prolog(const char *filename, const int linenumber);
ca562872
MB
170void _metadata_hub_modify_epilog(
171 int modified, const char *filename,
172 const int linenumber); // set to true if modifications occurred, 0 otherwise
7fa1d3cb 173
18b9116d 174/*
7fa1d3cb 175// these are for safe reading
2d7ae4bc
MB
176void _metadata_hub_read_prolog(const char *filename, const int linenumber);
177void _metadata_hub_read_epilog(const char *filename, const int linenumber);
18b9116d 178*/
2d7ae4bc
MB
179
180#define metadata_hub_modify_prolog(void) _metadata_hub_modify_prolog(__FILE__, __LINE__)
ca562872
MB
181#define metadata_hub_modify_epilog(modified) \
182 _metadata_hub_modify_epilog(modified, __FILE__, __LINE__)
2d7ae4bc
MB
183
184#define metadata_hub_read_prolog(void) _metadata_hub_read_prolog(__FILE__, __LINE__)
185#define metadata_hub_read_epilog(void) _metadata_hub_modify_epilog(__FILE__, __LINE__)