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 #ifndef SERVER_SETTINGS_H 20 #define SERVER_SETTINGS_H 21 22 #include "json_message.hpp" 23 24 25 namespace msg 26 { 27 28 class ServerSettings : public JsonMessage 29 { 30 public: ServerSettings()31 ServerSettings() : JsonMessage(message_type::kServerSettings) 32 { 33 setBufferMs(0); 34 setLatency(0); 35 setVolume(100); 36 setMuted(false); 37 } 38 39 ~ServerSettings() override = default; 40 getBufferMs()41 int32_t getBufferMs() 42 { 43 return get("bufferMs", 0); 44 } 45 getLatency()46 int32_t getLatency() 47 { 48 return get("latency", 0); 49 } 50 getVolume()51 uint16_t getVolume() 52 { 53 return get("volume", static_cast<uint16_t>(100)); 54 } 55 isMuted()56 bool isMuted() 57 { 58 return get("muted", false); 59 } 60 61 62 setBufferMs(int32_t bufferMs)63 void setBufferMs(int32_t bufferMs) 64 { 65 msg["bufferMs"] = bufferMs; 66 } 67 setLatency(int32_t latency)68 void setLatency(int32_t latency) 69 { 70 msg["latency"] = latency; 71 } 72 setVolume(uint16_t volume)73 void setVolume(uint16_t volume) 74 { 75 msg["volume"] = volume; 76 } 77 setMuted(bool muted)78 void setMuted(bool muted) 79 { 80 msg["muted"] = muted; 81 } 82 }; 83 } // namespace msg 84 85 86 #endif 87