Debian Codegraph @

src/stream.c

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 * Copyright (c) 2015, 2020 Moritz Grimm <[email protected]>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:410:9`!
18 # include "config.h"cxx . . $ `<file>/src/config.h`/
19 #endif /* HAVE_CONFIG_H */
20
21 #include <errno.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <strings.h>
26 #include <unistd.h>
27
28 #include <shout/shout.h>
29
30 #include "cfg.h"cxx . . $ `<file>/src/cfg.h`/
31 #include "log.h"cxx . . $ `<file>/src/log.h`/
32 #include "mdata.h"cxx . . $ `<file>/src/mdata.h`/
33 #include "stream.h"cxx . . $ `<file>/src/stream.h`/
34 #include "util.h"cxx . . $ `<file>/src/util.h`/
35 #include "xalloc.h"cxx . . $ `<file>/src/xalloc.h`/
36
37 struct streamcxx . . $ stream# {
38 char *namecxx . . $ stream#name.;
39 shout_tcxx . . $ shout_t# *shoutcxx . . $ stream#shout.;
40 };
41
42 static int _stream_cfg_servercxx . . $ _stream_cfg_server(c443eb575b46b194).(struct streamcxx . . $ stream# *, cfg_server_tcxx . . $ cfg_server_t#);
43 static int _stream_cfg_tlscxx . . $ _stream_cfg_tls(c443eb575b46b194).(struct streamcxx . . $ stream# *, cfg_server_tcxx . . $ cfg_server_t#);
44 static int _stream_cfg_streamcxx . . $ _stream_cfg_stream(f4fbcbd51144f382).(struct streamcxx . . $ stream# *, cfg_stream_tcxx . . $ cfg_stream_t#);
45 static void _stream_resetcxx . . $ _stream_reset(42ea99e01043689b).(struct streamcxx . . $ stream# *);
46
47 static int
48 _stream_cfg_servercxx . . $ _stream_cfg_server(c443eb575b46b194).(struct streamcxx . . $ stream# *s, cfg_server_tcxx . . $ cfg_server_t# cfg_server)
49 {
50 switch (cfg_server_get_protocolcxx . . $ cfg_server_get_protocol(ce88fb6a1143ebde).(cfg_server)) {
51 case CFG_PROTO_HTTPcxx . . $ CFG_PROTO_HTTP.:
52 case CFG_PROTO_HTTPScxx . . $ CFG_PROTO_HTTPS.:
53 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
54 shout_set_protocolcxx . . $ shout_set_protocol(a4527779c380fa7a).(s->shoutcxx . . $ stream#shout., SHOUT_PROTOCOL_HTTPcxx . . $ `<external>/4820953943157644765/shout.h:98:9`!)) {
55 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: protocol: %s",
56 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
57 return (-1);
58 }
59 break;
60 case CFG_PROTO_ICYcxx . . $ CFG_PROTO_ICY.:
61 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
62 shout_set_protocolcxx . . $ shout_set_protocol(a4527779c380fa7a).(s->shoutcxx . . $ stream#shout., SHOUT_PROTOCOL_ICYcxx . . $ `<external>/4820953943157644765/shout.h:100:9`!)) {
63 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: protocol: %s",
64 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
65 return (-1);
66 }
67 break;
68 #ifdef SHOUT_PROTOCOL_ROARAUDIOcxx . . $ `<external>/4820953943157644765/shout.h:101:9`!
69 case CFG_PROTO_ROARAUDIOcxx . . $ CFG_PROTO_ROARAUDIO.:
70 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
71 shout_set_protocolcxx . . $ shout_set_protocol(a4527779c380fa7a).(s->shoutcxx . . $ stream#shout., SHOUT_PROTOCOL_ROARAUDIOcxx . . $ `<external>/4820953943157644765/shout.h:101:9`!)) {
72 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: protocol: %s",
73 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
74 return (-1);
75 }
76 break;
77 #endif /* SHOUT_PROTOCOL_ROARAUDIO */
78 default:
79 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: protocol: unsupported: %s",
80 s->namecxx . . $ stream#name., cfg_server_get_protocol_strcxx . . $ cfg_server_get_protocol_str(7a685941053ada3e).(cfg_server));
81 return (-1);
82 }
83 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
84 shout_set_hostcxx . . $ shout_set_host(90064ee551601614).(s->shoutcxx . . $ stream#shout., cfg_server_get_hostnamecxx . . $ cfg_server_get_hostname(7a685941053ada3e).(cfg_server))) {
85 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: hostname: %s",
86 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
87 return (-1);
88 }
89 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
90 shout_set_portcxx . . $ shout_set_port(5a00a829e05aca42).(s->shoutcxx . . $ stream#shout., (unsigned short)cfg_server_get_portcxx . . $ cfg_server_get_port(50e7fa731851397f).(cfg_server))) {
91 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: port: %s",
92 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
93 return (-1);
94 }
95 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
96 shout_set_usercxx . . $ shout_set_user(90064ee551601614).(s->shoutcxx . . $ stream#shout., cfg_server_get_usercxx . . $ cfg_server_get_user(7a685941053ada3e).(cfg_server))) {
97 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: user: %s",
98 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
99 return (-1);
100 }
101 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
102 shout_set_passwordcxx . . $ shout_set_password(90064ee551601614).(s->shoutcxx . . $ stream#shout., cfg_server_get_passwordcxx . . $ cfg_server_get_password(7a685941053ada3e).(cfg_server))) {
103 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: password: %s",
104 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
105 return (-1);
106 }
107
108 return (0);
109 }
110
111 static int
112 _stream_cfg_tlscxx . . $ _stream_cfg_tls(c443eb575b46b194).(struct streamcxx . . $ stream# *s, cfg_server_tcxx . . $ cfg_server_t# cfg_server)
113 {
114 #ifdef SHOUT_TLS_AUTOcxx . . $ `<external>/4820953943157644765/shout.h:105:9`!
115 int tls_req;
116
117 switch (cfg_server_get_tlscxx . . $ cfg_server_get_tls(5c3b75bb9fe26255).(cfg_server)) {
118 case CFG_TLS_NONEcxx . . $ CFG_TLS_NONE.:
119 tls_req = SHOUT_TLS_DISABLEDcxx . . $ `<external>/4820953943157644765/shout.h:104:9`!;
120 break;
121 case CFG_TLS_MAYcxx . . $ CFG_TLS_MAY.:
122 tls_req = SHOUT_TLS_AUTOcxx . . $ `<external>/4820953943157644765/shout.h:105:9`!;
123 break;
124 case CFG_TLS_REQUIREDcxx . . $ CFG_TLS_REQUIRED.:
125 if (CFG_PROTO_HTTPScxx . . $ CFG_PROTO_HTTPS. == cfg_server_get_protocolcxx . . $ cfg_server_get_protocol(ce88fb6a1143ebde).(cfg_server))
126 tls_req = SHOUT_TLS_RFC2818cxx . . $ `<external>/4820953943157644765/shout.h:107:9`!;
127 else
128 tls_req = SHOUT_TLS_AUTO_NO_PLAINcxx . . $ `<external>/4820953943157644765/shout.h:106:9`!;
129 break;
130 default:
131 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: tls: invalid", s->namecxx . . $ stream#name.);
132 return (-1);
133 }
134 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! != shout_set_tlscxx . . $ shout_set_tls(b80403a096bc2328).(s->shoutcxx . . $ stream#shout., tls_req)) {
135 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: tls: %s", s->namecxx . . $ stream#name.,
136 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
137 return (-1);
138 }
139 if (cfg_server_get_ca_dircxx . . $ cfg_server_get_ca_dir(7a685941053ada3e).(cfg_server)) {
140 if (0 > accesscxx . . $ access(cb7559238bb26814).(cfg_server_get_ca_dircxx . . $ cfg_server_get_ca_dir(7a685941053ada3e).(cfg_server), R_OKcxx . . $ `<external>/12628407106812493757/unistd.h:281:9`!|X_OKcxx . . $ `<external>/12628407106812493757/unistd.h:283:9`!)) {
141 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: ca_dir: %s: not accessible",
142 s->namecxx . . $ stream#name., cfg_server_get_ca_dircxx . . $ cfg_server_get_ca_dir(7a685941053ada3e).(cfg_server));
143 return (-1);
144 }
145 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
146 shout_set_ca_directorycxx . . $ shout_set_ca_directory(90064ee551601614).(s->shoutcxx . . $ stream#shout., cfg_server_get_ca_dircxx . . $ cfg_server_get_ca_dir(7a685941053ada3e).(cfg_server))) {
147 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: ca_dir: %s: %s", s->namecxx . . $ stream#name.,
148 cfg_server_get_ca_dircxx . . $ cfg_server_get_ca_dir(7a685941053ada3e).(cfg_server),
149 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
150 return (-1);
151 }
152 }
153 if (cfg_server_get_ca_filecxx . . $ cfg_server_get_ca_file(7a685941053ada3e).(cfg_server)) {
154 if (0 > accesscxx . . $ access(cb7559238bb26814).(cfg_server_get_ca_filecxx . . $ cfg_server_get_ca_file(7a685941053ada3e).(cfg_server), R_OKcxx . . $ `<external>/12628407106812493757/unistd.h:281:9`!)) {
155 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: ca_file: %s: not readable",
156 s->namecxx . . $ stream#name., cfg_server_get_ca_filecxx . . $ cfg_server_get_ca_file(7a685941053ada3e).(cfg_server));
157 return (-1);
158 }
159 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
160 shout_set_ca_filecxx . . $ shout_set_ca_file(90064ee551601614).(s->shoutcxx . . $ stream#shout., cfg_server_get_ca_filecxx . . $ cfg_server_get_ca_file(7a685941053ada3e).(cfg_server))) {
161 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: ca_file: %s: %s", s->namecxx . . $ stream#name.,
162 cfg_server_get_ca_filecxx . . $ cfg_server_get_ca_file(7a685941053ada3e).(cfg_server),
163 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
164 return (-1);
165 }
166 }
167 if (cfg_server_get_client_certcxx . . $ cfg_server_get_client_cert(7a685941053ada3e).(cfg_server)) {
168 if (0 > accesscxx . . $ access(cb7559238bb26814).(cfg_server_get_client_certcxx . . $ cfg_server_get_client_cert(7a685941053ada3e).(cfg_server), R_OKcxx . . $ `<external>/12628407106812493757/unistd.h:281:9`!)) {
169 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: client_cert: %s: not readable", s->namecxx . . $ stream#name.,
170 cfg_server_get_client_certcxx . . $ cfg_server_get_client_cert(7a685941053ada3e).(cfg_server));
171 return (-1);
172 }
173 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
174 shout_set_client_certificatecxx . . $ shout_set_client_certificate(90064ee551601614).(s->shoutcxx . . $ stream#shout., cfg_server_get_client_certcxx . . $ cfg_server_get_client_cert(7a685941053ada3e).(cfg_server))) {
175 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: client_cert: %s: %s", s->namecxx . . $ stream#name.,
176 cfg_server_get_client_certcxx . . $ cfg_server_get_client_cert(7a685941053ada3e).(cfg_server),
177 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
178 return (-1);
179 }
180 }
181 if (cfg_server_get_tls_cipher_suitecxx . . $ cfg_server_get_tls_cipher_suite(7a685941053ada3e).(cfg_server) &&
182 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
183 shout_set_allowed_cipherscxx . . $ shout_set_allowed_ciphers(90064ee551601614).(s->shoutcxx . . $ stream#shout., cfg_server_get_tls_cipher_suitecxx . . $ cfg_server_get_tls_cipher_suite(7a685941053ada3e).(cfg_server))) {
184 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: tls_cipher_suite: %s", s->namecxx . . $ stream#name.,
185 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
186 return (-1);
187 }
188 #else /* SHOUT_TLS_AUTO */
189 # warning "libshout library does not support TLS"
190 switch (cfg_server_get_tls(cfg_server)) {
191 case CFG_TLS_MAY:
192 log_warning("stream: %s: TLS optional but not supported by libshout",
193 s->name);
194 break;
195 case CFG_TLS_REQUIRED:
196 log_error("stream: %s: TLS required but not supported by libshout",
197 s->name);
198 return (-1);
199 default:
200 break;
201 }
202 #endif /* SHOUT_TLS_AUTO */
203
204 return (0);
205 }
206
207 static int
208 _stream_cfg_streamcxx . . $ _stream_cfg_stream(f4fbcbd51144f382).(struct streamcxx . . $ stream# *s, cfg_stream_tcxx . . $ cfg_stream_t# cfg_stream)
209 {
210 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
211 shout_set_mountcxx . . $ shout_set_mount(90064ee551601614).(s->shoutcxx . . $ stream#shout., cfg_stream_get_mountpointcxx . . $ cfg_stream_get_mountpoint(2200fed2ef732c87).(cfg_stream))) {
212 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: mountpoint: %s",
213 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
214 return (-1);
215 }
216 switch (cfg_stream_get_formatcxx . . $ cfg_stream_get_format(a1a4274431071f63).(cfg_stream)) {
217 case CFG_STREAM_OGGcxx . . $ CFG_STREAM_OGG.:
218 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
219 shout_set_content_formatcxx . . $ shout_set_content_format(433c36945c79d63f).(s->shoutcxx . . $ stream#shout., SHOUT_FORMAT_OGGcxx . . $ `<external>/4820953943157644765/shout.h:72:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)) {
220 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: format: %s: %s",
221 s->namecxx . . $ stream#name., cfg_stream_get_format_strcxx . . $ cfg_stream_get_format_str(2200fed2ef732c87).(cfg_stream),
222 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
223 return (-1);
224 }
225 break;
226 case CFG_STREAM_MP3cxx . . $ CFG_STREAM_MP3.:
227 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
•228 shout_set_content_formatcxx . . $ shout_set_content_format(433c36945c79d63f).(s->shoutcxx . . $ stream#shout., SHOUT_FORMAT_MP3cxx . . $ `<external>/4820953943157644765/shout.h:73:9`!, SHOUT_USAGE_AUDIOcxx . . $ `<external>/4820953943157644765/shout.h:83:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)) {
229 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: format: %s: %s",
230 s->namecxx . . $ stream#name., cfg_stream_get_format_strcxx . . $ cfg_stream_get_format_str(2200fed2ef732c87).(cfg_stream),
231 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
232 return (-1);
233 }
234 break;
235 case CFG_STREAM_WEBMcxx . . $ CFG_STREAM_WEBM.:
236 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
237 shout_set_content_formatcxx . . $ shout_set_content_format(433c36945c79d63f).(s->shoutcxx . . $ stream#shout., SHOUT_FORMAT_WEBMcxx . . $ `<external>/4820953943157644765/shout.h:74:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)) {
238 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: format: %s: %s",
239 s->namecxx . . $ stream#name., cfg_stream_get_format_strcxx . . $ cfg_stream_get_format_str(2200fed2ef732c87).(cfg_stream),
240 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
241 return (-1);
242 }
243 break;
244 #ifdef SHOUT_FORMAT_MATROSKAcxx . . $ `<external>/4820953943157644765/shout.h:76:9`!
245 case CFG_STREAM_MATROSKAcxx . . $ CFG_STREAM_MATROSKA.:
246 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
247 shout_set_content_formatcxx . . $ shout_set_content_format(433c36945c79d63f).(s->shoutcxx . . $ stream#shout., SHOUT_FORMAT_MATROSKAcxx . . $ `<external>/4820953943157644765/shout.h:76:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)) {
248 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: format: %s: %s",
249 s->namecxx . . $ stream#name., cfg_stream_get_format_strcxx . . $ cfg_stream_get_format_str(2200fed2ef732c87).(cfg_stream),
250 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
251 return (-1);
252 }
253 break;
254 #endif /* SHOUT_FORMAT_MATROSKA */
255 default:
256 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: format: %s: unsupported",
257 s->namecxx . . $ stream#name., cfg_stream_get_format_strcxx . . $ cfg_stream_get_format_str(2200fed2ef732c87).(cfg_stream));
258 return (-1);
259 }
260 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
261 shout_set_publiccxx . . $ shout_set_public(a4527779c380fa7a).(s->shoutcxx . . $ stream#shout., (unsigned int)cfg_stream_get_publiccxx . . $ cfg_stream_get_public(b112842c4d681374).(cfg_stream))) {
262 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: public: %s",
263 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
264 return (-1);
265 }
266 if (cfg_stream_get_stream_namecxx . . $ cfg_stream_get_stream_name(2200fed2ef732c87).(cfg_stream) &&
267 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
268 shout_set_metacxx . . $ shout_set_meta(6cf4d911e1916907).(s->shoutcxx . . $ stream#shout., SHOUT_META_NAMEcxx . . $ `<external>/4820953943157644765/shout.h:120:9`!, cfg_stream_get_stream_namecxx . . $ cfg_stream_get_stream_name(2200fed2ef732c87).(cfg_stream))) {
269 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: name: %s",
270 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
271 return (-1);
272 }
273 if (cfg_stream_get_stream_urlcxx . . $ cfg_stream_get_stream_url(2200fed2ef732c87).(cfg_stream) &&
274 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
275 shout_set_metacxx . . $ shout_set_meta(6cf4d911e1916907).(s->shoutcxx . . $ stream#shout., SHOUT_META_URLcxx . . $ `<external>/4820953943157644765/shout.h:121:9`!, cfg_stream_get_stream_urlcxx . . $ cfg_stream_get_stream_url(2200fed2ef732c87).(cfg_stream))) {
276 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: url: %s",
277 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
278 return (-1);
279 }
280 if (cfg_stream_get_stream_genrecxx . . $ cfg_stream_get_stream_genre(2200fed2ef732c87).(cfg_stream) &&
281 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
282 shout_set_metacxx . . $ shout_set_meta(6cf4d911e1916907).(s->shoutcxx . . $ stream#shout., SHOUT_META_GENREcxx . . $ `<external>/4820953943157644765/shout.h:122:9`!, cfg_stream_get_stream_genrecxx . . $ cfg_stream_get_stream_genre(2200fed2ef732c87).(cfg_stream))) {
283 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: genre: %s",
284 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
285 return (-1);
286 }
287 if (cfg_stream_get_stream_descriptioncxx . . $ cfg_stream_get_stream_description(2200fed2ef732c87).(cfg_stream) &&
288 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
289 shout_set_metacxx . . $ shout_set_meta(6cf4d911e1916907).(s->shoutcxx . . $ stream#shout., SHOUT_META_DESCRIPTIONcxx . . $ `<external>/4820953943157644765/shout.h:123:9`!, cfg_stream_get_stream_descriptioncxx . . $ cfg_stream_get_stream_description(2200fed2ef732c87).(cfg_stream))) {
290 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: description: %s",
291 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
292 return (-1);
293 }
294 if (cfg_stream_get_stream_qualitycxx . . $ cfg_stream_get_stream_quality(2200fed2ef732c87).(cfg_stream) &&
295 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
296 shout_set_audio_infocxx . . $ shout_set_audio_info(6cf4d911e1916907).(s->shoutcxx . . $ stream#shout., SHOUT_AI_QUALITYcxx . . $ `<external>/4820953943157644765/shout.h:118:9`!, cfg_stream_get_stream_qualitycxx . . $ cfg_stream_get_stream_quality(2200fed2ef732c87).(cfg_stream))) {
297 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: ai_quality: %s",
298 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
299 return (-1);
300 }
301 if (cfg_stream_get_stream_bitratecxx . . $ cfg_stream_get_stream_bitrate(2200fed2ef732c87).(cfg_stream) &&
302 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
303 shout_set_audio_infocxx . . $ shout_set_audio_info(6cf4d911e1916907).(s->shoutcxx . . $ stream#shout., SHOUT_AI_BITRATEcxx . . $ `<external>/4820953943157644765/shout.h:115:9`!, cfg_stream_get_stream_bitratecxx . . $ cfg_stream_get_stream_bitrate(2200fed2ef732c87).(cfg_stream))) {
304 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: ai_bitrate: %s",
305 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
306 return (-1);
307 }
308 if (cfg_stream_get_stream_sampleratecxx . . $ cfg_stream_get_stream_samplerate(2200fed2ef732c87).(cfg_stream) &&
309 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
310 shout_set_audio_infocxx . . $ shout_set_audio_info(6cf4d911e1916907).(s->shoutcxx . . $ stream#shout., SHOUT_AI_SAMPLERATEcxx . . $ `<external>/4820953943157644765/shout.h:116:9`!, cfg_stream_get_stream_sampleratecxx . . $ cfg_stream_get_stream_samplerate(2200fed2ef732c87).(cfg_stream))) {
311 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: ai_samplerate: %s",
312 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
313 return (-1);
314 }
315 if (cfg_stream_get_stream_channelscxx . . $ cfg_stream_get_stream_channels(2200fed2ef732c87).(cfg_stream) &&
316 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
317 shout_set_audio_infocxx . . $ shout_set_audio_info(6cf4d911e1916907).(s->shoutcxx . . $ stream#shout., SHOUT_AI_CHANNELScxx . . $ `<external>/4820953943157644765/shout.h:117:9`!, cfg_stream_get_stream_channelscxx . . $ cfg_stream_get_stream_channels(2200fed2ef732c87).(cfg_stream))) {
318 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: ai_channels: %s",
319 s->namecxx . . $ stream#name., shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
320 return (-1);
321 }
322
323 return (0);
324 }
325
326 void
327 _stream_resetcxx . . $ _stream_reset(42ea99e01043689b).(struct streamcxx . . $ stream# *s)
328 {
329 if (!s->shoutcxx . . $ stream#shout.)
330 return;
331 shout_freecxx . . $ shout_free(ef95c6087b523e5).(s->shoutcxx . . $ stream#shout.);
332 s->shoutcxx . . $ stream#shout. = shout_newcxx . . $ shout_new(f526e492225f228d).();
333 if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! == s->shoutcxx . . $ stream#shout.) {
334 log_syserrcxx . . $ log_syserr(7edabc5ef8d007a9).(ALERTcxx . . $ ALERT., ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!, "shout_new");
335 exitcxx . . $ exit(3ca292c338df9bb3).(1);
336 }
337 }
338
339 int
340 stream_initcxx . . $ stream_init(b126dc7c1de90089).(void)
341 {
342 shout_initcxx . . $ shout_init(49f6e7a06ebc5aa8).();
343 return (0);
344 }
345
346 void
347 stream_exitcxx . . $ stream_exit(49f6e7a06ebc5aa8).(void)
348 {
349 shout_shutdowncxx . . $ shout_shutdown(49f6e7a06ebc5aa8).();
350 }
351
352 struct streamcxx . . $ stream# *
353 stream_createcxx . . $ stream_create(ed53485bf0dc7f57).(const char *name)
354 {
355 struct streamcxx . . $ stream# *s;
356
357 s = xcalloccxx . . $ `src/xalloc.h:23:9`!(1UL, sizeof(*s));
358 s->namecxx . . $ stream#name. = xstrdupcxx . . $ `src/xalloc.h:25:9`!(name);
359 s->shoutcxx . . $ stream#shout. = shout_newcxx . . $ shout_new(f526e492225f228d).();
360 if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! == s->shoutcxx . . $ stream#shout.) {
361 log_syserrcxx . . $ log_syserr(7edabc5ef8d007a9).(ALERTcxx . . $ ALERT., ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!, "shout_new");
362 exitcxx . . $ exit(3ca292c338df9bb3).(1);
363 }
364
365 return (s);
366 }
367
368 void
369 stream_destroycxx . . $ stream_destroy(a819560812e4e895).(struct streamcxx . . $ stream# **s_p)
370 {
371 struct streamcxx . . $ stream# *s = *s_p;
372
373 shout_freecxx . . $ shout_free(ef95c6087b523e5).(s->shoutcxx . . $ stream#shout.);
374 xfreecxx . . $ `src/xalloc.h:26:9`!(s->name);
375 xfreecxx . . $ `src/xalloc.h:26:9`!(s);
376 *s_p = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
377 }
378
379 int
380 stream_configurecxx . . $ stream_configure(e560f6a86f1dbfd1).(struct streamcxx . . $ stream# *s)
381 {
382 cfg_stream_list_tcxx . . $ cfg_stream_list_t# streams;
383 cfg_server_list_tcxx . . $ cfg_server_list_t# servers;
384 cfg_stream_tcxx . . $ cfg_stream_t# cfg_stream;
385 cfg_server_tcxx . . $ cfg_server_t# cfg_server;
386 cfg_intake_tcxx . . $ cfg_intake_t# cfg_intake;
387 const char *server;
388
389 streams = cfg_get_streamscxx . . $ cfg_get_streams(f0c21fd0bbd2a8b).();
390 cfg_stream = cfg_stream_list_findcxx . . $ cfg_stream_list_find(47cc06abd3dd2318).(streams, s->namecxx . . $ stream#name.);
391 if (!cfg_stream) {
392 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: no configuration", s->namecxx . . $ stream#name.);
393 return (-1);
394 }
395 servers = cfg_get_serverscxx . . $ cfg_get_servers(ad3818a383472c4a).();
396 server = cfg_stream_get_servercxx . . $ cfg_stream_get_server(2200fed2ef732c87).(cfg_stream);
397 if (!server)
398 server = CFG_DEFAULTcxx . . $ `src/cfg.h:27:9`!;
399 cfg_server = cfg_server_list_findcxx . . $ cfg_server_list_find(a98fd320ccd4534).(servers, server);
400 if (!cfg_server) {
401 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: no configuration: %s",
402 s->namecxx . . $ stream#name., cfg_stream_get_servercxx . . $ cfg_stream_get_server(2200fed2ef732c87).(cfg_stream));
403 return (-1);
404 }
405
406 if (0 != _stream_cfg_servercxx . . $ _stream_cfg_server(c443eb575b46b194).(s, cfg_server) ||
407 0 != _stream_cfg_tlscxx . . $ _stream_cfg_tls(c443eb575b46b194).(s, cfg_server) ||
408 0 != _stream_cfg_streamcxx . . $ _stream_cfg_stream(f4fbcbd51144f382).(s, cfg_stream)) {
409 _stream_resetcxx . . $ _stream_reset(42ea99e01043689b).(s);
410 return (-1);
411 }
412
413 cfg_intake = stream_get_cfg_intakecxx . . $ stream_get_cfg_intake(b24beca3dc86be4b).(s);
414 if (0 > cfg_intake_validatecxx . . $ cfg_intake_validate(4f7d28fe13f0586b).(cfg_intake, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)) {
415 log_errorcxx . . $ log_error(581fddd72a8db8fc).("stream: %s: referencing unconfigured intake (%s)",
416 s->namecxx . . $ stream#name., cfg_intake_get_namecxx . . $ cfg_intake_get_name(56a97a66344ba534).(cfg_intake));
417 _stream_resetcxx . . $ _stream_reset(42ea99e01043689b).(s);
418 return (-1);
419 }
420
421 return (0);
422 }
423
424 int
425 stream_set_metadatacxx . . $ stream_set_metadata(b6629ca60a85dc43).(struct streamcxx . . $ stream# *s, mdata_tcxx . . $ mdata_t# md, char **md_str)
426 {
427 shout_metadata_tcxx . . $ shout_metadata_t# *shout_md = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
428 int ret;
429
430 if (cfg_get_metadata_no_updatescxx . . $ cfg_get_metadata_no_updates(b126dc7c1de90089).())
431 return (0);
432
433 if (md == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
434 return (-1);
435
436 if ((shout_md = shout_metadata_newcxx . . $ shout_metadata_new(5463827fa718234f).()) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
437 log_syserrcxx . . $ log_syserr(7edabc5ef8d007a9).(ALERTcxx . . $ ALERT., ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!, "shout_metadata_new");
438 exitcxx . . $ exit(3ca292c338df9bb3).(1);
439 }
440
441 /*
442 * We can do this, because we know how libshout works. This adds
443 * "charset=UTF-8" to the HTTP metadata update request and has the
444 * desired effect of letting newer-than-2.3.1 versions of Icecast know
445 * which encoding we're using.
446 */
447 if (shout_metadata_addcxx . . $ shout_metadata_add(76c721faaa6cf1d3).(shout_md, "charset", "UTF-8") != SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`!) {
448 /* Assume SHOUTERR_MALLOC */
449 log_syserrcxx . . $ log_syserr(7edabc5ef8d007a9).(ALERTcxx . . $ ALERT., ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!, "shout_metadata_add");
450 exitcxx . . $ exit(3ca292c338df9bb3).(1);
451 }
452
453 if (cfg_get_metadata_format_strcxx . . $ cfg_get_metadata_format_str(33a1f659e94feb42).()) {
454 char buf[BUFSIZcxx . . $ `<external>/232824719582829767/stdio.h:104:9`!];
455
456 mdata_strformatcxx . . $ mdata_strformat(2d1219fb966f86b0).(md, buf, sizeof(buf),
457 cfg_get_metadata_format_strcxx . . $ cfg_get_metadata_format_str(33a1f659e94feb42).());
458 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! !=
459 shout_metadata_addcxx . . $ shout_metadata_add(76c721faaa6cf1d3).(shout_md, "song", buf)) {
460 log_syserrcxx . . $ log_syserr(7edabc5ef8d007a9).(ALERTcxx . . $ ALERT., ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!, "shout_metadata_add");
461 exitcxx . . $ exit(3ca292c338df9bb3).(1);
462 }
463 log_infocxx . . $ log_info(581fddd72a8db8fc).("stream metadata: formatted: %s", buf);
464 } else {
465 if (mdata_get_artistcxx . . $ mdata_get_artist(42a08b9e3d38b1e0).(md) && mdata_get_titlecxx . . $ mdata_get_title(42a08b9e3d38b1e0).(md)) {
466 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! != shout_metadata_addcxx . . $ shout_metadata_add(76c721faaa6cf1d3).(shout_md,
467 "artist", mdata_get_artistcxx . . $ mdata_get_artist(42a08b9e3d38b1e0).(md)) ||
468 SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! != shout_metadata_addcxx . . $ shout_metadata_add(76c721faaa6cf1d3).(shout_md,
469 "title", mdata_get_titlecxx . . $ mdata_get_title(42a08b9e3d38b1e0).(md))) {
470 log_syserrcxx . . $ log_syserr(7edabc5ef8d007a9).(ALERTcxx . . $ ALERT., ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!,
471 "shout_metadata_add");
472 exitcxx . . $ exit(3ca292c338df9bb3).(1);
473 }
474 log_infocxx . . $ log_info(581fddd72a8db8fc).("stream metadata: artist=\"%s\" title=\"%s\"",
475 mdata_get_artistcxx . . $ mdata_get_artist(42a08b9e3d38b1e0).(md),
476 mdata_get_titlecxx . . $ mdata_get_title(42a08b9e3d38b1e0).(md));
477 } else if (mdata_get_songinfocxx . . $ mdata_get_songinfo(42a08b9e3d38b1e0).(md)) {
478 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! != shout_metadata_addcxx . . $ shout_metadata_add(76c721faaa6cf1d3).(shout_md,
479 "song", mdata_get_songinfocxx . . $ mdata_get_songinfo(42a08b9e3d38b1e0).(md))) {
480 log_syserrcxx . . $ log_syserr(7edabc5ef8d007a9).(ALERTcxx . . $ ALERT., ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!,
481 "shout_metadata_add");
482 exitcxx . . $ exit(3ca292c338df9bb3).(1);
483 }
484 log_infocxx . . $ log_info(581fddd72a8db8fc).("stream metadata: songinfo: %s",
485 mdata_get_songinfocxx . . $ mdata_get_songinfo(42a08b9e3d38b1e0).(md));
486 } else {
487 if (SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! != shout_metadata_addcxx . . $ shout_metadata_add(76c721faaa6cf1d3).(shout_md,
488 "song", mdata_get_namecxx . . $ mdata_get_name(42a08b9e3d38b1e0).(md))) {
489 log_syserrcxx . . $ log_syserr(7edabc5ef8d007a9).(ALERTcxx . . $ ALERT., ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!,
490 "shout_metadata_add");
491 exitcxx . . $ exit(3ca292c338df9bb3).(1);
492 }
493 log_infocxx . . $ log_info(581fddd72a8db8fc).("stream metadata: name: %s",
494 mdata_get_namecxx . . $ mdata_get_name(42a08b9e3d38b1e0).(md));
495 }
496 }
497
498 if ((ret = shout_set_metadatacxx . . $ shout_set_metadata(644618d2cba200a0).(s->shoutcxx . . $ stream#shout., shout_md)) != SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`!)
499 log_warningcxx . . $ log_warning(581fddd72a8db8fc).("shout_set_metadata: %s", shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
500
501 shout_metadata_freecxx . . $ shout_metadata_free(4760528b29b2c378).(shout_md);
502
503 if (ret == SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`!) {
504 if (md_str != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! && *md_str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
505 *md_str = mdata_get_songinfocxx . . $ mdata_get_songinfo(42a08b9e3d38b1e0).(md) ?
506 xstrdupcxx . . $ `src/xalloc.h:25:9`!(mdata_get_songinfo(md)) :
507 xstrdupcxx . . $ `src/xalloc.h:25:9`!(mdata_get_name(md));
508 }
509
510 return (ret == SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`! ? 0 : -1);
511 }
512
513 int
514 stream_get_connectedcxx . . $ stream_get_connected(e560f6a86f1dbfd1).(struct streamcxx . . $ stream# *s)
515 {
516 return (shout_get_connectedcxx . . $ shout_get_connected(c784d17d7881087b).(s->shoutcxx . . $ stream#shout.) == SHOUTERR_CONNECTEDcxx . . $ `<external>/4820953943157644765/shout.h:64:9`! ? 1 : 0);
517 }
518
519 cfg_stream_tcxx . . $ cfg_stream_t#
520 stream_get_cfg_streamcxx . . $ stream_get_cfg_stream(5d068d841fd5888b).(struct streamcxx . . $ stream# *s)
521 {
522 return (cfg_stream_list_findcxx . . $ cfg_stream_list_find(47cc06abd3dd2318).(cfg_get_streamscxx . . $ cfg_get_streams(f0c21fd0bbd2a8b).(), s->namecxx . . $ stream#name.));
523 }
524
525 cfg_intake_tcxx . . $ cfg_intake_t#
526 stream_get_cfg_intakecxx . . $ stream_get_cfg_intake(b24beca3dc86be4b).(struct streamcxx . . $ stream# *s)
527 {
528 cfg_stream_tcxx . . $ cfg_stream_t# cfg_stream;
529 const char *intake;
530
531 cfg_stream = cfg_stream_list_getcxx . . $ cfg_stream_list_get(47cc06abd3dd2318).(cfg_get_streamscxx . . $ cfg_get_streams(f0c21fd0bbd2a8b).(), s->namecxx . . $ stream#name.);
532 intake = cfg_stream_get_intakecxx . . $ cfg_stream_get_intake(2200fed2ef732c87).(cfg_stream);
533 if (!intake)
534 intake = CFG_DEFAULTcxx . . $ `src/cfg.h:27:9`!;
535 return (cfg_intake_list_getcxx . . $ cfg_intake_list_get(4b9d0036e0282c96).(cfg_get_intakescxx . . $ cfg_get_intakes(6d1209736ac34f33).(), intake));
536 }
537
538 cfg_server_tcxx . . $ cfg_server_t#
539 stream_get_cfg_servercxx . . $ stream_get_cfg_server(c04f5d5f4c377bea).(struct streamcxx . . $ stream# *s)
540 {
541 cfg_stream_tcxx . . $ cfg_stream_t# cfg_stream;
542 const char *server;
543
544 cfg_stream = cfg_stream_list_getcxx . . $ cfg_stream_list_get(47cc06abd3dd2318).(cfg_get_streamscxx . . $ cfg_get_streams(f0c21fd0bbd2a8b).(), s->namecxx . . $ stream#name.);
545 server = cfg_stream_get_servercxx . . $ cfg_stream_get_server(2200fed2ef732c87).(cfg_stream);
546 if (!server)
547 server = CFG_DEFAULTcxx . . $ `src/cfg.h:27:9`!;
548 return (cfg_server_list_getcxx . . $ cfg_server_list_get(a98fd320ccd4534).(cfg_get_serverscxx . . $ cfg_get_servers(ad3818a383472c4a).(), server));
549 }
550
551 int
552 stream_connectcxx . . $ stream_connect(e560f6a86f1dbfd1).(struct streamcxx . . $ stream# *s)
553 {
554 if (shout_opencxx . . $ shout_open(c784d17d7881087b).(s->shoutcxx . . $ stream#shout.) == SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`!)
555 return (0);
556
557 log_warningcxx . . $ log_warning(581fddd72a8db8fc).("stream: %s: connect: [%s]:%d: error %d: %s", s->namecxx . . $ stream#name.,
558 shout_get_hostcxx . . $ shout_get_host(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.), shout_get_portcxx . . $ shout_get_port(a899a48bc201c18c).(s->shoutcxx . . $ stream#shout.),
559 shout_get_errnocxx . . $ shout_get_errno(c784d17d7881087b).(s->shoutcxx . . $ stream#shout.), shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
560
561 return (-1);
562 }
563
564 void
565 stream_disconnectcxx . . $ stream_disconnect(42ea99e01043689b).(struct streamcxx . . $ stream# *s)
566 {
567 if (!stream_get_connectedcxx . . $ stream_get_connected(e560f6a86f1dbfd1).(s))
568 return;
569 shout_closecxx . . $ shout_close(c784d17d7881087b).(s->shoutcxx . . $ stream#shout.);
570 }
571
572 void
573 stream_synccxx . . $ stream_sync(42ea99e01043689b).(struct streamcxx . . $ stream# *s)
574 {
575 shout_synccxx . . $ shout_sync(ef95c6087b523e5).(s->shoutcxx . . $ stream#shout.);
576 }
577
578 int
579 stream_sendcxx . . $ stream_send(5edb09aac611db9a).(struct streamcxx . . $ stream# *s, const char *data, size_t len)
580 {
581 if (shout_sendcxx . . $ shout_send(d93ecdd302cbe201).(s->shoutcxx . . $ stream#shout., (const unsigned char *)data, len)
582 == SHOUTERR_SUCCESScxx . . $ `<external>/4820953943157644765/shout.h:57:9`!)
583 return (0);
584
585 log_warningcxx . . $ log_warning(581fddd72a8db8fc).("stream: %s: send: %s: error %d: %s", s->namecxx . . $ stream#name.,
586 shout_get_hostcxx . . $ shout_get_host(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.), shout_get_errnocxx . . $ shout_get_errno(c784d17d7881087b).(s->shoutcxx . . $ stream#shout.),
587 shout_get_errorcxx . . $ shout_get_error(457fbc9c03d8198e).(s->shoutcxx . . $ stream#shout.));
588
589 stream_disconnectcxx . . $ stream_disconnect(42ea99e01043689b).(s);
590
591 return (-1);
592 }