1 /*** 2 This file is part of snapcast 3 Copyright (C) 2014-2020 Johannes Pohl 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 ***/ 18 19 20 #ifndef PUBLISH_AVAHI_H 21 #define PUBLISH_AVAHI_H 22 23 #include <avahi-client/client.h> 24 #include <avahi-client/publish.h> 25 26 #include <atomic> 27 #include <avahi-common/alternative.h> 28 #include <avahi-common/error.h> 29 #include <avahi-common/malloc.h> 30 #include <avahi-common/simple-watch.h> 31 #include <avahi-common/timeval.h> 32 #include <string> 33 #include <vector> 34 35 class PublishAvahi; 36 37 #include "publish_mdns.hpp" 38 39 class PublishAvahi : public PublishmDNS 40 { 41 public: 42 PublishAvahi(const std::string& serviceName, boost::asio::io_context& ioc); 43 ~PublishAvahi() override; 44 void publish(const std::vector<mDNSService>& services) override; 45 46 private: 47 static void entry_group_callback(AvahiEntryGroup* g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void* userdata); 48 static void client_callback(AvahiClient* c, AvahiClientState state, AVAHI_GCC_UNUSED void* userdata); 49 void create_services(AvahiClient* c); 50 void poll(); 51 AvahiClient* client_; 52 std::vector<mDNSService> services_; 53 boost::asio::steady_timer timer_; 54 }; 55 56 57 #endif 58