mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
Merge pull request #198 from chme/mpdzeroconf
[mpd] Announce mpd support with avahi/zeroconf
This commit is contained in:
commit
9cc4927d50
19
src/main.c
19
src/main.c
@ -221,14 +221,16 @@ daemonize(int background, char *pidfile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
register_services(char *ffid, int no_rsp, int no_daap)
|
register_services(char *ffid, int no_rsp, int no_daap, int mdns_no_mpd)
|
||||||
{
|
{
|
||||||
cfg_t *lib;
|
cfg_t *lib;
|
||||||
|
cfg_t *mpd;
|
||||||
char *libname;
|
char *libname;
|
||||||
char *password;
|
char *password;
|
||||||
char *txtrecord[10];
|
char *txtrecord[10];
|
||||||
char records[9][128];
|
char records[9][128];
|
||||||
int port;
|
int port;
|
||||||
|
int mpd_port;
|
||||||
uint32_t hash;
|
uint32_t hash;
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
@ -318,6 +320,16 @@ register_services(char *ffid, int no_rsp, int no_daap)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* Register MPD serivce */
|
||||||
|
mpd = cfg_getsec(cfg, "mpd");
|
||||||
|
mpd_port = cfg_getint(mpd, "port");
|
||||||
|
if (!mdns_no_mpd && mpd_port > 0)
|
||||||
|
{
|
||||||
|
ret = mdns_register(libname, "_mpd._tcp", mpd_port, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,6 +458,7 @@ main(int argc, char **argv)
|
|||||||
int background;
|
int background;
|
||||||
int mdns_no_rsp;
|
int mdns_no_rsp;
|
||||||
int mdns_no_daap;
|
int mdns_no_daap;
|
||||||
|
int mdns_no_mpd;
|
||||||
int loglevel;
|
int loglevel;
|
||||||
char *logdomains;
|
char *logdomains;
|
||||||
char *logfile;
|
char *logfile;
|
||||||
@ -484,6 +497,7 @@ main(int argc, char **argv)
|
|||||||
ffid = NULL;
|
ffid = NULL;
|
||||||
mdns_no_rsp = 0;
|
mdns_no_rsp = 0;
|
||||||
mdns_no_daap = 0;
|
mdns_no_daap = 0;
|
||||||
|
mdns_no_mpd = 1; // only announce if mpd protocol support is activated
|
||||||
|
|
||||||
while ((option = getopt_long(argc, argv, "D:d:c:P:fb:v", option_map, NULL)) != -1)
|
while ((option = getopt_long(argc, argv, "D:d:c:P:fb:v", option_map, NULL)) != -1)
|
||||||
{
|
{
|
||||||
@ -747,6 +761,7 @@ main(int argc, char **argv)
|
|||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
goto mpd_fail;
|
goto mpd_fail;
|
||||||
}
|
}
|
||||||
|
mdns_no_mpd = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Start Remote pairing service */
|
/* Start Remote pairing service */
|
||||||
@ -760,7 +775,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Register mDNS services */
|
/* Register mDNS services */
|
||||||
ret = register_services(ffid, mdns_no_rsp, mdns_no_daap);
|
ret = register_services(ffid, mdns_no_rsp, mdns_no_daap, mdns_no_mpd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Copyright (C) 2009-2011 Julien BLACHE <jb@jblache.org>
|
* Copyright (C) 2009-2011 Julien BLACHE <jb@jblache.org>
|
||||||
*
|
*
|
||||||
* Pieces coming from mt-daapd:
|
* Pieces coming from mt-daapd:
|
||||||
* Copyright (C) 2005 Sebastian Dröge <slomo@ubuntu.com>
|
* Copyright (C) 2005 Sebastian Dröge <slomo@ubuntu.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -1032,11 +1032,14 @@ mdns_register(char *name, char *type, int port, char **txt)
|
|||||||
ge->port = port;
|
ge->port = port;
|
||||||
|
|
||||||
txt_sl = NULL;
|
txt_sl = NULL;
|
||||||
for (i = 0; txt[i]; i++)
|
if (txt)
|
||||||
{
|
{
|
||||||
txt_sl = avahi_string_list_add(txt_sl, txt[i]);
|
for (i = 0; txt[i]; i++)
|
||||||
|
{
|
||||||
|
txt_sl = avahi_string_list_add(txt_sl, txt[i]);
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_MDNS, "Added key %s\n", txt[i]);
|
DPRINTF(E_DBG, L_MDNS, "Added key %s\n", txt[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ge->txt = txt_sl;
|
ge->txt = txt_sl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user