mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-28 17:57:05 +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
|
||||
Copyright (C) 2014-2024 Johannes Pohl
|
||||
Copyright (C) 2014-2025 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
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
class BrowseAvahi;
|
||||
|
||||
// local headers
|
||||
#include "browse_mdns.hpp"
|
||||
|
||||
|
@ -31,11 +29,15 @@ class BrowseAvahi;
|
|||
#include <avahi-common/simple-watch.h>
|
||||
|
||||
|
||||
/// Avahi based mDNS browser
|
||||
class BrowseAvahi : public BrowsemDNS
|
||||
{
|
||||
public:
|
||||
/// c'tor
|
||||
BrowseAvahi();
|
||||
/// d'tor
|
||||
~BrowseAvahi();
|
||||
|
||||
bool browse(const std::string& serviceName, mDNSResult& result, int timeout) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -40,6 +40,7 @@ using namespace std;
|
|||
|
||||
static constexpr auto LOG_TAG = "Bonjour";
|
||||
|
||||
/// DNSServiceRefDeleter
|
||||
struct DNSServiceRefDeleter
|
||||
{
|
||||
void operator()(DNSServiceRef* ref)
|
||||
|
@ -51,6 +52,7 @@ struct DNSServiceRefDeleter
|
|||
|
||||
using DNSServiceHandle = std::unique_ptr<DNSServiceRef, DNSServiceRefDeleter>;
|
||||
|
||||
/// @return @p error as string
|
||||
string BonjourGetError(DNSServiceErrorType error)
|
||||
{
|
||||
switch (error)
|
||||
|
@ -154,11 +156,13 @@ string BonjourGetError(DNSServiceErrorType error)
|
|||
}
|
||||
}
|
||||
|
||||
/// mDNS reply
|
||||
struct mDNSReply
|
||||
{
|
||||
string name, regtype, domain;
|
||||
};
|
||||
|
||||
/// mDNS resolve
|
||||
struct mDNSResolve
|
||||
{
|
||||
string fullName;
|
||||
|
@ -169,6 +173,7 @@ struct mDNSResolve
|
|||
if ((err) != kDNSServiceErr_NoError) \
|
||||
throw SnapException(BonjourGetError(err) + ":" + to_string(__LINE__));
|
||||
|
||||
/// run service @p service
|
||||
void runService(const DNSServiceHandle& service)
|
||||
{
|
||||
if (!*service)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***
|
||||
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
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -18,7 +18,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
class BrowseBonjour;
|
||||
|
||||
// local headers
|
||||
#include "browse_mdns.hpp"
|
||||
|
@ -27,6 +26,7 @@ class BrowseBonjour;
|
|||
#include <dns_sd.h>
|
||||
|
||||
|
||||
/// Bonjour based mDNS browser
|
||||
class BrowseBonjour : public BrowsemDNS
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***
|
||||
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
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,37 +22,28 @@
|
|||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
enum IPVersion
|
||||
/// IP versions IPv4 and IPv6
|
||||
enum class IPVersion
|
||||
{
|
||||
IPv4 = 0,
|
||||
IPv6 = 1
|
||||
IPv4 = 0, ///< IPv4
|
||||
IPv6 = 1 ///< IPv6
|
||||
};
|
||||
|
||||
|
||||
/// mDNS record
|
||||
struct mDNSResult
|
||||
{
|
||||
mDNSResult() : ip_version(IPv4), iface_idx(0), port(0), valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
IPVersion ip_version;
|
||||
int iface_idx;
|
||||
std::string ip;
|
||||
std::string host;
|
||||
uint16_t port;
|
||||
bool valid;
|
||||
IPVersion ip_version{IPVersion::IPv4}; ///< IP version
|
||||
int iface_idx{0}; ///< interface index
|
||||
std::string ip; ///< IP address
|
||||
std::string host; ///< host
|
||||
uint16_t port{0}; ///< port
|
||||
bool valid{false}; ///< valid
|
||||
};
|
||||
|
||||
/// mDNS browser interface
|
||||
class BrowsemDNS
|
||||
{
|
||||
public:
|
||||
/// get mDNS record for @p serviceName
|
||||
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
|
||||
#include "player/file_player.hpp"
|
||||
|
||||
#include "browseZeroConf/browse_mdns.hpp"
|
||||
#include "browseZeroConf/browse_zeroconf.hpp"
|
||||
#include "common/aixlog.hpp"
|
||||
#include "common/message/client_info.hpp"
|
||||
#include "common/message/error.hpp"
|
||||
|
|
Loading…
Add table
Reference in a new issue