mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 18:27:12 +02:00
Fix cyclic include
This commit is contained in:
parent
8cddeb7f6e
commit
f24c4b01b7
6 changed files with 54 additions and 29 deletions
|
@ -1,6 +1,6 @@
|
||||||
/***
|
/***
|
||||||
This file is part of snapcast
|
This file is part of snapcast
|
||||||
Copyright (C) 2014-2024 Johannes Pohl
|
Copyright (C) 2014-2025 Johannes Pohl
|
||||||
|
|
||||||
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
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class BrowseAvahi;
|
|
||||||
|
|
||||||
// local headers
|
// local headers
|
||||||
#include "browse_mdns.hpp"
|
#include "browse_mdns.hpp"
|
||||||
|
|
||||||
|
@ -31,11 +29,15 @@ class BrowseAvahi;
|
||||||
#include <avahi-common/simple-watch.h>
|
#include <avahi-common/simple-watch.h>
|
||||||
|
|
||||||
|
|
||||||
|
/// Avahi based mDNS browser
|
||||||
class BrowseAvahi : public BrowsemDNS
|
class BrowseAvahi : public BrowsemDNS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// c'tor
|
||||||
BrowseAvahi();
|
BrowseAvahi();
|
||||||
|
/// d'tor
|
||||||
~BrowseAvahi();
|
~BrowseAvahi();
|
||||||
|
|
||||||
bool browse(const std::string& serviceName, mDNSResult& result, int timeout) override;
|
bool browse(const std::string& serviceName, mDNSResult& result, int timeout) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -40,6 +40,7 @@ using namespace std;
|
||||||
|
|
||||||
static constexpr auto LOG_TAG = "Bonjour";
|
static constexpr auto LOG_TAG = "Bonjour";
|
||||||
|
|
||||||
|
/// DNSServiceRefDeleter
|
||||||
struct DNSServiceRefDeleter
|
struct DNSServiceRefDeleter
|
||||||
{
|
{
|
||||||
void operator()(DNSServiceRef* ref)
|
void operator()(DNSServiceRef* ref)
|
||||||
|
@ -51,6 +52,7 @@ struct DNSServiceRefDeleter
|
||||||
|
|
||||||
using DNSServiceHandle = std::unique_ptr<DNSServiceRef, DNSServiceRefDeleter>;
|
using DNSServiceHandle = std::unique_ptr<DNSServiceRef, DNSServiceRefDeleter>;
|
||||||
|
|
||||||
|
/// @return @p error as string
|
||||||
string BonjourGetError(DNSServiceErrorType error)
|
string BonjourGetError(DNSServiceErrorType error)
|
||||||
{
|
{
|
||||||
switch (error)
|
switch (error)
|
||||||
|
@ -154,11 +156,13 @@ string BonjourGetError(DNSServiceErrorType error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// mDNS reply
|
||||||
struct mDNSReply
|
struct mDNSReply
|
||||||
{
|
{
|
||||||
string name, regtype, domain;
|
string name, regtype, domain;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// mDNS resolve
|
||||||
struct mDNSResolve
|
struct mDNSResolve
|
||||||
{
|
{
|
||||||
string fullName;
|
string fullName;
|
||||||
|
@ -169,6 +173,7 @@ struct mDNSResolve
|
||||||
if ((err) != kDNSServiceErr_NoError) \
|
if ((err) != kDNSServiceErr_NoError) \
|
||||||
throw SnapException(BonjourGetError(err) + ":" + to_string(__LINE__));
|
throw SnapException(BonjourGetError(err) + ":" + to_string(__LINE__));
|
||||||
|
|
||||||
|
/// run service @p service
|
||||||
void runService(const DNSServiceHandle& service)
|
void runService(const DNSServiceHandle& service)
|
||||||
{
|
{
|
||||||
if (!*service)
|
if (!*service)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/***
|
/***
|
||||||
This file is part of snapcast
|
This file is part of snapcast
|
||||||
Copyright (C) 2014-2024 Johannes Pohl
|
Copyright (C) 2014-2025 Johannes Pohl
|
||||||
|
|
||||||
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
|
||||||
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class BrowseBonjour;
|
|
||||||
|
|
||||||
// local headers
|
// local headers
|
||||||
#include "browse_mdns.hpp"
|
#include "browse_mdns.hpp"
|
||||||
|
@ -27,6 +26,7 @@ class BrowseBonjour;
|
||||||
#include <dns_sd.h>
|
#include <dns_sd.h>
|
||||||
|
|
||||||
|
|
||||||
|
/// Bonjour based mDNS browser
|
||||||
class BrowseBonjour : public BrowsemDNS
|
class BrowseBonjour : public BrowsemDNS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/***
|
/***
|
||||||
This file is part of snapcast
|
This file is part of snapcast
|
||||||
Copyright (C) 2014-2024 Johannes Pohl
|
Copyright (C) 2014-2025 Johannes Pohl
|
||||||
|
|
||||||
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
|
||||||
|
@ -22,37 +22,28 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
enum IPVersion
|
/// IP versions IPv4 and IPv6
|
||||||
|
enum class IPVersion
|
||||||
{
|
{
|
||||||
IPv4 = 0,
|
IPv4 = 0, ///< IPv4
|
||||||
IPv6 = 1
|
IPv6 = 1 ///< IPv6
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// mDNS record
|
||||||
struct mDNSResult
|
struct mDNSResult
|
||||||
{
|
{
|
||||||
mDNSResult() : ip_version(IPv4), iface_idx(0), port(0), valid(false)
|
IPVersion ip_version{IPVersion::IPv4}; ///< IP version
|
||||||
{
|
int iface_idx{0}; ///< interface index
|
||||||
}
|
std::string ip; ///< IP address
|
||||||
|
std::string host; ///< host
|
||||||
IPVersion ip_version;
|
uint16_t port{0}; ///< port
|
||||||
int iface_idx;
|
bool valid{false}; ///< valid
|
||||||
std::string ip;
|
|
||||||
std::string host;
|
|
||||||
uint16_t port;
|
|
||||||
bool valid;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// mDNS browser interface
|
||||||
class BrowsemDNS
|
class BrowsemDNS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// get mDNS record for @p serviceName
|
||||||
virtual bool browse(const std::string& serviceName, mDNSResult& result, int timeout) = 0;
|
virtual bool browse(const std::string& serviceName, mDNSResult& result, int timeout) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(HAS_AVAHI)
|
|
||||||
#include "browse_avahi.hpp"
|
|
||||||
using BrowseZeroConf = BrowseAvahi;
|
|
||||||
#elif defined(HAS_BONJOUR)
|
|
||||||
#include "browse_bonjour.hpp"
|
|
||||||
using BrowseZeroConf = BrowseBonjour;
|
|
||||||
#endif
|
|
||||||
|
|
27
client/browseZeroConf/browse_zeroconf.hpp
Normal file
27
client/browseZeroConf/browse_zeroconf.hpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/***
|
||||||
|
This file is part of snapcast
|
||||||
|
Copyright (C) 2014-2024 Johannes Pohl
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
***/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(HAS_AVAHI)
|
||||||
|
#include "browse_avahi.hpp"
|
||||||
|
using BrowseZeroConf = BrowseAvahi;
|
||||||
|
#elif defined(HAS_BONJOUR)
|
||||||
|
#include "browse_bonjour.hpp"
|
||||||
|
using BrowseZeroConf = BrowseBonjour;
|
||||||
|
#endif
|
|
@ -56,7 +56,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "player/file_player.hpp"
|
#include "player/file_player.hpp"
|
||||||
|
|
||||||
#include "browseZeroConf/browse_mdns.hpp"
|
#include "browseZeroConf/browse_zeroconf.hpp"
|
||||||
#include "common/aixlog.hpp"
|
#include "common/aixlog.hpp"
|
||||||
#include "common/message/client_info.hpp"
|
#include "common/message/client_info.hpp"
|
||||||
#include "common/message/error.hpp"
|
#include "common/message/error.hpp"
|
||||||
|
|
Loading…
Add table
Reference in a new issue