]> git.mxchange.org Git - flightgear.git/blob - utils/fgcom/fgcom.hxx
FGCom: add silence threshold setting
[flightgear.git] / utils / fgcom / fgcom.hxx
1 /*
2  * fgcom - VoIP-Client for the FlightGear-Radio-Infrastructure
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  * MA  02110-1301, USA.
18  *
19  */
20
21 #ifndef __FGCOM_H__
22 #define __FGCOM_H__
23
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <errno.h>
27 #include <iaxclient.h>
28 #include <math.h>
29 #include <string.h>
30
31 #ifdef _MSC_VER
32 #pragma warning ( disable : 4244 ) // from double to float
33 #pragma warning ( disable : 4996 ) // depreciaed, really
34 #include <io.h> // for open. read, ...
35 #else
36 #include <signal.h>
37 #endif
38
39
40 #define DEFAULT_USER            "guest"
41 #define DEFAULT_PASSWORD        "guest"
42 #define DEFAULT_FG_SERVER       "localhost"
43 #define DEFAULT_FG_PORT         16661
44 #define DEFAULT_CODE            1
45 #define ATIS_CODE               99
46 #define DEFAULT_VOIP_SERVER     "fgcom.flightgear.org"
47 #define DEFAULT_CODEC           'u'
48 #define DEFAULT_IAX_CODEC       IAXC_FORMAT_ULAW
49 #define DEFAULT_IAX_AUDIO       AUDIO_INTERNAL
50 #define DEFAULT_MAX_CALLS       2
51 #define DEFAULT_MILLISLEEP      100
52 #define DEFAULT_RANGE           100.0
53 #define DEFAULT_LOWER_FRQ_LIMIT 108.0
54 #define DEFAULT_UPPER_FRQ_LIMIT 140.0
55 #define MAXBUFLEN               1024
56 #define DEFAULT_ALARM_TIMER     5
57 #define ALLOC_CHUNK_SIZE        5 //Size of a memory chunk to allocate
58 #define MX_REPORT_BUF           1024
59 #define MX_PATH_SIZE            2000
60
61
62 /* avoid name clash with winerror.h */
63 #define FGC_SUCCESS(__x__)              (__x__ == 0)
64 #define FGC_FAILED(__x__)               (__x__ < 0)
65
66 #ifndef SPECIAL_FREQUENCIES_FILE
67 #define SPECIAL_FREQUENCIES_FILE "fgcom-data\\special_frequencies.txt"
68 #endif
69 #ifndef DEFAULT_POSITIONS_FILE
70 #define DEFAULT_POSITIONS_FILE "fgcom-data\\positions.txt"
71 #endif
72
73 #ifdef _MSC_VER
74 #define snprintf _snprintf
75 #define inline __inline
76 #ifdef WIN64
77 typedef __int64 ssize_t;
78 #else
79 typedef int ssize_t;
80 #endif
81 #endif
82
83 #ifndef FGCOM_VERSION
84 #ifndef FLIGHTGEAR_VERSION
85 #define FGCOM_VERSION FLIGHTGEAR_VERSION
86 #else
87 #define FGCOM_VERSION "2.99"
88 #endif
89 #endif
90
91 struct airport
92 {
93   char icao[5];
94   float frequency;
95   double lat;
96   double lon;
97   char type[33];
98   char text[129];
99   struct airport *next;
100 };
101
102 struct pos
103 {
104   double lon;
105   double lat;
106 };
107
108 struct fgdata
109 {
110   float COM1_FRQ;
111   float COM2_FRQ;
112   float NAV1_FRQ;
113   float NAV2_FRQ;
114   int COM1_SRV;
115   int COM2_SRV;
116   int NAV1_SRV;
117   int NAV2_SRV;
118   int PTT;
119   int TRANSPONDER;
120   float IAS;
121   float GS;
122   double LON;
123   double LAT;
124   int ALT;
125   float HEAD;
126   float OUTPUT_VOL;
127   float SILENCE_THD;
128   char* CALLSIGN;
129 };
130
131 /* function declaratons */
132 void quit (int signal);
133 void alarm_handler (int signal);
134 void strtoupper (const char *str, char *buf, size_t len);
135 void usage (char *prog);
136 int create_socket (int port);
137 void fatal_error (const char *err);
138 int iaxc_callback (iaxc_event e);
139 void event_state (int state, char *remote, char *remote_name, char *local,
140                   char *local_context);
141 void event_text (int type, char *message);
142 void event_register (int id, int reply, int count);
143 void report (char *text);
144 const char *map_state (int state);
145 void event_unknown (int type);
146 void event_netstats (struct iaxc_ev_netstats stat);
147 void event_level (double in, double out);
148 void icao2number (char *icao, float frequency, char *buf);
149 void icao2atisnumber (char *icao, float frequency, char *buf);
150 void ptt (int mode);
151 double distance (double lat1, double lon1, double lat2, double lon2);
152 int split (char *string, char *fields[], int nfields, const char *sep);
153 char *readln (FILE * fp, char *buf, int len);
154 double *read_special_frequencies(const char *file);
155 struct airport *read_airports (const char *file);
156 const char *icaobypos (struct airport *airports, double frequency,
157                        double plane_lat, double plane_lon, double range);
158 void vor (char *icao, double frequency, int mode);
159 char *report_devices (int in);
160 int set_device (const char *name, int out);
161 struct pos posbyicao (struct airport *airports, char *icao);
162 void parse_fgdata (struct fgdata *data, char *buf);
163 int check_special_frq (double frq);
164 void do_iaxc_call (const char *username, const char *password,
165                    const char *voipserver, char *number);
166 #endif