1 // config functions for butt 2 // 3 // Copyright 2007-2018 by Daniel Noethen. 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 2, or (at your option) 8 // 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 16 #ifndef CFG_H 17 #define CFG_H 18 19 #include "port_audio.h" 20 #include "parseconfig.h" 21 22 enum { 23 24 SHOUTCAST = 0, 25 ICECAST = 1 26 }; 27 28 enum { 29 CHOICE_STEREO = 0, 30 CHOICE_MONO = 1 31 }; 32 33 enum { 34 CHOICE_MP3 = 0, 35 CHOICE_OGG = 1, 36 CHOICE_OPUS = 2, 37 CHOICE_AAC = 3, 38 CHOICE_FLAC = 4, 39 CHOICE_WAV = 5 40 }; 41 42 enum { 43 LANG_SYSTEM = 0, 44 LANG_DE = 1, 45 LANG_EN = 2 46 }; 47 48 extern const char CONFIG_FILE[]; 49 typedef struct 50 { 51 char *name; 52 char *addr; 53 char *pwd; 54 char *mount; //mountpoint for icecast server 55 char *usr; //user for icecast server 56 char *cert_hash; //sha256 hash of trusted certificate 57 int port; 58 int type; //SHOUTCAST or ICECAST 59 int tls; //use tls: 0 = no, 1 = yes 60 }server_t; 61 62 63 typedef struct 64 { 65 char *name; 66 char *desc; //description 67 char *genre; 68 char *url; 69 char *irc; 70 char *icq; 71 char *aim; 72 char *pub; 73 }icy_t; 74 75 76 typedef struct 77 { 78 int selected_srv; 79 int selected_icy; 80 81 struct 82 { 83 char *srv; 84 char *icy; 85 char *srv_ent; 86 char *icy_ent; 87 char *song; 88 char *song_path; 89 FILE *song_fd; 90 char *song_prefix; 91 char *song_suffix; 92 int song_update; //1 = song info will be read from file 93 int read_last_line; 94 int app_update; 95 int app_update_service; 96 int num_of_srv; 97 int num_of_icy; 98 int bg_color, txt_color; 99 int connect_at_startup; 100 int force_reconnecting; 101 int silence_threshold; // timeout duration of automatic stream/record stop 102 int signal_threshold; // timeout duration of automatic stream/record start 103 int check_for_update; 104 float gain; 105 char *log_file; 106 char *ic_charset; 107 }main; 108 109 struct 110 { 111 int dev_count; 112 int dev_num; 113 snd_dev_t **pcm_list; 114 int samplerate; 115 int resolution; 116 int channel; 117 int left_ch; 118 int right_ch; 119 int bitrate; 120 int mono_to_stereo; 121 int buffer_ms; 122 int resample_mode; 123 int aac_aot; 124 float silence_level; 125 float signal_level; 126 int aac_overwrite_aot; 127 int disable_dithering; 128 char *codec; 129 }audio; 130 131 struct 132 { 133 int channel; 134 int bitrate; 135 int quality; 136 int samplerate; 137 char *codec; 138 char *filename; 139 char *folder; 140 char *path; 141 char *path_fmt; 142 FILE *fd; 143 int start_rec; 144 int stop_rec; 145 int rec_after_launch; 146 int split_time; 147 int sync_to_hour; 148 int silence_threshold; 149 int signal_threshold; 150 }rec; 151 152 struct 153 { 154 char *cert_file; 155 char *cert_dir; 156 }tls; 157 158 struct 159 { 160 int equalizer; 161 double gain1, gain2, gain3, gain4, gain5; 162 int compressor; 163 double threshold, ratio, attack, release, makeup_gain; 164 }dsp; 165 166 struct 167 { 168 int attach; 169 int ontop; 170 int lcd_auto; 171 int hide_log_window; 172 int remember_pos; 173 int x_pos, y_pos; 174 int lang; 175 }gui; 176 177 server_t **srv; 178 icy_t **icy; 179 180 }config_t; 181 182 183 184 extern char *cfg_path; //Path to config file 185 extern config_t cfg; //Holds config parameters 186 187 int cfg_write_file(char *path); //Writes current config_t struct to path or cfg_path if path is NULL 188 int cfg_set_values(char *path); //Reads config file from path or cfg_path if path is NULL and fills the config_t struct 189 int cfg_create_default(void); //Creates a default config file, if there isn't one yet 190 191 #endif 192 193