mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-03 00:29:35 +02:00
added Avahi Zeroconf
This commit is contained in:
parent
af7f230e97
commit
e8ffa1f243
10 changed files with 302 additions and 133 deletions
|
@ -10,21 +10,40 @@
|
|||
#include <avahi-common/error.h>
|
||||
#include <avahi-common/timeval.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
|
||||
struct AvahiService
|
||||
{
|
||||
AvahiService(const std::string& name, size_t port, int proto = AVAHI_PROTO_UNSPEC) : name_(name), port_(port), proto_(proto)
|
||||
{
|
||||
}
|
||||
|
||||
std::string name_;
|
||||
size_t port_;
|
||||
int proto_;
|
||||
};
|
||||
|
||||
|
||||
class PublishAvahi
|
||||
{
|
||||
public:
|
||||
PublishAvahi();
|
||||
PublishAvahi(const std::string& serviceName);
|
||||
~PublishAvahi();
|
||||
|
||||
private:
|
||||
void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata);
|
||||
void create_services(AvahiClient *c);
|
||||
void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata);
|
||||
void publish(const std::vector<AvahiService>& services);
|
||||
std::vector<AvahiService> services;
|
||||
|
||||
AvahiEntryGroup *group;
|
||||
AvahiSimplePoll *simple_poll;
|
||||
char* name;
|
||||
private:
|
||||
static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata);
|
||||
static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata);
|
||||
void create_services(AvahiClient *c);
|
||||
AvahiClient* client;
|
||||
std::string serviceName_;
|
||||
std::thread pollThread_;
|
||||
void worker();
|
||||
std::atomic<bool> active_;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue