1 ////////////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (c) 2004-2021 musikcube team 4 // 5 // All rights reserved. 6 // 7 // Redistribution and use in source and binary forms, with or without 8 // modification, are permitted provided that the following conditions are met: 9 // 10 // * Redistributions of source code must retain the above copyright notice, 11 // this list of conditions and the following disclaimer. 12 // 13 // * Redistributions in binary form must reproduce the above copyright 14 // notice, this list of conditions and the following disclaimer in the 15 // documentation and/or other materials provided with the distribution. 16 // 17 // * Neither the name of the author nor the names of other contributors may 18 // be used to endorse or promote products derived from this software 19 // without specific prior written permission. 20 // 21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 // POSSIBILITY OF SUCH DAMAGE. 32 // 33 ////////////////////////////////////////////////////////////////////////////// 34 35 #pragma once 36 37 #include <string> 38 #include "Util.h" 39 40 //#define ENABLE_DEBUG 1 41 42 namespace defaults { 43 static const int websocket_server_port = 7905; 44 static const int http_server_port = 7906; 45 static const std::string password = ""; 46 static const int transcoder_cache_count = 50; 47 static const int transcoder_max_active_count = 4; 48 static const bool use_ipv6 = false; 49 static const bool transcoder_synchronous = false; 50 static const bool transcoder_synchronous_fallback = false; 51 } 52 53 namespace prefs { 54 static const std::string websocket_server_enabled = "websocket_server_enabled"; 55 static const std::string websocket_server_port = "websocket_server_port"; 56 static const std::string http_server_enabled = "http_server_enabled"; 57 static const std::string http_server_port = "http_server_port"; 58 static const std::string use_ipv6 = "use_ipv6"; 59 static const std::string transcoder_cache_count = "transcoder_cache_count"; 60 static const std::string transcoder_max_active_count = "transcoder_max_active_count"; 61 static const std::string transcoder_synchronous = "transcoder_synchronous"; 62 static const std::string transcoder_synchronous_fallback = "transcoder_synchronous_fallback"; 63 } 64 65 namespace message { 66 static const std::string name = "name"; 67 static const std::string id = "id"; 68 static const std::string device_id = "device_id"; 69 static const std::string type = "type"; 70 static const std::string options = "options"; 71 } 72 73 namespace key { 74 static const std::string error = "error"; 75 static const std::string state = "state"; 76 static const std::string volume = "volume"; 77 static const std::string position = "position"; 78 static const std::string repeat_mode = "repeat_mode"; 79 static const std::string shuffled = "shuffled"; 80 static const std::string muted = "muted"; 81 static const std::string play_queue_count = "track_count"; 82 static const std::string play_queue_position = "play_queue_position"; 83 static const std::string playing_duration = "playing_duration"; 84 static const std::string playing_current_time = "playing_current_time"; 85 static const std::string playing_track = "playing_track"; 86 static const std::string title = "title"; 87 static const std::string external_id = "external_id"; 88 static const std::string external_ids = "external_ids"; 89 static const std::string filename = "filename"; 90 static const std::string duration = "duration"; 91 static const std::string artist = "artist"; 92 static const std::string album = "album"; 93 static const std::string album_artist = "album_artist"; 94 static const std::string genre = "genre"; 95 static const std::string thumbnail_id = "thumbnail_id"; 96 static const std::string visual_genre_id = "visual_genre_id"; 97 static const std::string genre_id = "genre_id"; 98 static const std::string visual_artist_id = "visual_artist_id"; 99 static const std::string artist_id = "artist_id"; 100 static const std::string track_num = "track"; 101 static const std::string album_artist_id = "album_artist_id"; 102 static const std::string album_id = "album_id"; 103 static const std::string category = "category"; 104 static const std::string category_id = "category_id"; 105 static const std::string filter = "filter"; 106 static const std::string id = "id"; 107 static const std::string ids = "ids"; 108 static const std::string value = "value"; 109 static const std::string data = "data"; 110 static const std::string limit = "limit"; 111 static const std::string offset = "offset"; 112 static const std::string count_only = "count_only"; 113 static const std::string ids_only = "ids_only"; 114 static const std::string count = "count"; 115 static const std::string success = "success"; 116 static const std::string index = "index"; 117 static const std::string delta = "delta"; 118 static const std::string relative = "relative"; 119 static const std::string password = "password"; 120 static const std::string raw_query_data = "raw_query_data"; 121 static const std::string authenticated = "authenticated"; 122 static const std::string environment = "environment"; 123 static const std::string playlist_id = "playlist_id"; 124 static const std::string playlist_name = "playlist_name"; 125 static const std::string subquery = "subquery"; 126 static const std::string type = "type"; 127 static const std::string sort_order = "sort_order"; 128 static const std::string sort_orders = "sort_orders"; 129 static const std::string predicate_category = "predicate_category"; 130 static const std::string predicate_id = "predicate_id"; 131 static const std::string predicates = "predicates"; 132 static const std::string sdk_version = "sdk_version"; 133 static const std::string api_version = "api_version"; 134 static const std::string app_version = "app_version"; 135 static const std::string driver_name = "driver_name"; 136 static const std::string all = "all"; 137 static const std::string selected = "selected"; 138 static const std::string devices = "devices"; 139 static const std::string device_name = "device_name"; 140 static const std::string device_id = "device_id"; 141 static const std::string replaygain_mode = "replaygain_mode"; 142 static const std::string preamp_gain = "preamp_gain"; 143 static const std::string enabled = "enabled"; 144 static const std::string bands = "bands"; 145 static const std::string time = "time"; 146 } 147 148 namespace value { 149 static const std::string invalid = "invalid"; 150 static const std::string unauthenticated = "unauthenticated"; 151 static const std::string up = "up"; 152 static const std::string down = "down"; 153 static const std::string delta = "delta"; 154 static const std::string reindex = "reindex"; 155 static const std::string rebuild = "rebuild"; 156 static const std::string live = "live"; 157 static const std::string snapshot = "snapshot"; 158 } 159 160 namespace type { 161 static const std::string request = "request"; 162 static const std::string response = "response"; 163 static const std::string broadcast = "broadcast"; 164 } 165 166 namespace request { 167 static const std::string authenticate = "authenticate"; 168 static const std::string ping = "ping"; 169 static const std::string send_raw_query = "send_raw_query"; 170 static const std::string pause_or_resume = "pause_or_resume"; 171 static const std::string stop = "stop"; 172 static const std::string previous = "previous"; 173 static const std::string next = "next"; 174 static const std::string play_at_index = "play_at_index"; 175 static const std::string toggle_shuffle = "toggle_shuffle"; 176 static const std::string toggle_repeat = "toggle_repeat"; 177 static const std::string set_volume = "set_volume"; 178 static const std::string seek_to = "seek_to"; 179 static const std::string seek_relative = "seek_relative"; 180 static const std::string toggle_mute = "toggle_mute"; 181 static const std::string get_playback_overview = "get_playback_overview"; 182 static const std::string get_current_time = "get_current_time"; 183 static const std::string list_categories = "list_categories"; 184 static const std::string query_category = "query_category"; 185 static const std::string query_tracks = "query_tracks"; 186 static const std::string query_tracks_by_external_ids = "query_tracks_by_external_ids"; 187 static const std::string query_albums = "query_albums"; 188 static const std::string query_tracks_by_category = "query_tracks_by_category"; 189 static const std::string play_all_tracks = "play_all_tracks"; 190 static const std::string play_snapshot_tracks = "play_snapshot_tracks"; 191 static const std::string play_tracks = "play_tracks"; 192 static const std::string play_tracks_by_category = "play_tracks_by_category"; 193 static const std::string query_play_queue_tracks = "query_play_queue_tracks"; 194 static const std::string get_environment = "get_environment"; 195 static const std::string save_playlist = "save_playlist"; 196 static const std::string rename_playlist = "rename_playlist"; 197 static const std::string delete_playlist = "delete_playlist"; 198 static const std::string append_to_playlist = "append_to_playlist"; 199 static const std::string remove_tracks_from_playlist = "remove_tracks_from_playlist"; 200 static const std::string run_indexer = "run_indexer"; 201 static const std::string list_output_drivers = "list_output_drivers"; 202 static const std::string set_default_output_driver = "set_default_output_driver"; 203 static const std::string get_gain_settings = "get_gain_settings"; 204 static const std::string set_gain_settings = "set_gain_settings"; 205 static const std::string get_equalizer_settings = "get_equalizer_settings"; 206 static const std::string set_equalizer_settings = "set_equalizer_settings"; 207 static const std::string get_transport_type = "get_transport_type"; 208 static const std::string set_transport_type = "set_transport_type"; 209 static const std::string snapshot_play_queue = "snapshot_play_queue"; 210 static const std::string invalidate_play_queue_snapshot = "invalidate_play_queue_snapshot"; 211 } 212 213 namespace fragment { 214 static const std::string audio = "audio"; 215 static const std::string id = "id"; 216 static const std::string external_id = "external_id"; 217 static const std::string thumbnail = "thumbnail"; 218 } 219 220 namespace broadcast { 221 static const std::string playback_overview_changed = "playback_overview_changed"; 222 static const std::string play_queue_changed = "play_queue_changed"; 223 } 224 225 static auto PLAYBACK_STATE_TO_STRING = makeBimap<musik::core::sdk::PlaybackState, std::string>({ 226 { musik::core::sdk::PlaybackState::Stopped, "stopped" }, 227 { musik::core::sdk::PlaybackState::Playing, "playing" }, 228 { musik::core::sdk::PlaybackState::Prepared, "prepared" }, 229 { musik::core::sdk::PlaybackState::Paused, "paused" } 230 }); 231 232 static auto REPEAT_MODE_TO_STRING = makeBimap<musik::core::sdk::RepeatMode, std::string>({ 233 { musik::core::sdk::RepeatMode::None, "none" }, 234 { musik::core::sdk::RepeatMode::Track, "track" }, 235 { musik::core::sdk::RepeatMode::List, "list" } 236 }); 237 238 static auto REPLAYGAIN_MODE_TO_STRING = makeBimap<musik::core::sdk::ReplayGainMode, std::string>({ 239 { musik::core::sdk::ReplayGainMode::Disabled, "disabled" }, 240 { musik::core::sdk::ReplayGainMode::Album, "album" }, 241 { musik::core::sdk::ReplayGainMode::Track, "track" }, 242 }); 243 244 static auto TRANSPORT_TYPE_TO_STRING = makeBimap<musik::core::sdk::TransportType, std::string>({ 245 { musik::core::sdk::TransportType::Gapless, "gapless" }, 246 { musik::core::sdk::TransportType::Crossfade, "crossfade" }, 247 }); 248 249 static const int ApiVersion = 20; 250