File: MumblePlugin.h

package info (click to toggle)
mumble 1.5.735-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 90,008 kB
  • sloc: cpp: 556,921; ansic: 81,662; python: 3,606; sh: 659; makefile: 506; asm: 371; cs: 306; sql: 228; javascript: 143; perl: 80; xml: 13
file content (1823 lines) | stat: -rw-r--r-- 83,310 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
// Copyright 2023 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// CONTROL OVER WHAT SECTIONS TO INCLUDE ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

// Whether or not to include default implementations
#ifdef MUMBLE_PLUGIN_NO_DEFAULT_FUNCTION_DEFINITIONS
#	undef EXTERNAL_MUMBLE_PLUGIN_DEFAULT_IMPLEMENTATIONS_
#	define EXTERNAL_MUMBLE_PLUGIN_DEFAULT_IMPLEMENTATIONS_
#endif

// Whether or not to create the MumbleAPI typedef
#undef MUMBLE_PLUGIN_CREATE_MUMBLE_API_TYPEDEF
#ifndef MUMBLE_PLUGIN_NO_API_TYPEDEF
#	define MUMBLE_PLUGIN_CREATE_MUMBLE_API_TYPEDEF
#endif


///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// MACRO DEFINITIONS //////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef EXTERNAL_MUMBLE_PLUGIN_MACROS_
#	define EXTERNAL_MUMBLE_PLUGIN_MACROS_

/*
 * Plugin version information
 */
#	define MUMBLE_PLUGIN_INTERFACE_MAJOR_MACRO 1
#	define MUMBLE_PLUGIN_INTERFACE_MINOR_MACRO 2
#	define MUMBLE_PLUGIN_INTERFACE_PATCH_MACRO 0

// Allow the selected API version be overwritten by external definitions
#	ifndef MUMBLE_PLUGIN_API_MAJOR_MACRO
#		define MUMBLE_PLUGIN_API_MAJOR_MACRO 1
#	endif
#	ifndef MUMBLE_PLUGIN_API_MINOR_MACRO
#		define MUMBLE_PLUGIN_API_MINOR_MACRO 2
#	endif
#	ifndef MUMBLE_PLUGIN_API_PATCH_MACRO
#		define MUMBLE_PLUGIN_API_PATCH_MACRO 0
#	endif

#	define MUMBLE_PLUGIN_FUNCTIONS_MAJOR_MACRO 1
#	define MUMBLE_PLUGIN_FUNCTIONS_MINOR_MACRO 1
#	define MUMBLE_PLUGIN_FUNCTIONS_PATCH_MACRO 0

/*
 * MUMBLE_PLUGIN_EXPORT
 */
#	if defined(__GNUC__) && !defined(__MINGW32__) // GCC on Unix-like systems
#		define MUMBLE_PLUGIN_EXPORT __attribute__((visibility("default")))
#	elif defined(_MSC_VER)
#		define MUMBLE_PLUGIN_EXPORT __declspec(dllexport)
#	elif defined(__MINGW32__)
#		define MUMBLE_PLUGIN_EXPORT __attribute__((dllexport))
#	else
#		error No MUMBLE_PLUGIN_EXPORT definition available
#	endif

/*
 * MUMBLE_PLUGIN_CALLING_CONVENTION
 */
#	if defined(_MSC_VER)
#		define MUMBLE_PLUGIN_CALLING_CONVENTION __cdecl
#	elif defined(__MINGW32__)
#		define MUMBLE_PLUGIN_CALLING_CONVENTION __attribute__((cdecl))
#	else
#		define MUMBLE_PLUGIN_CALLING_CONVENTION
#	endif

/*
 * MUMBLE_PLUGIN_HAS_QT
 */
#	if defined(QT_CORE_LIB) || defined(QT_VERSION)
#		define MUMBLE_PLUGIN_HAS_QT
#	endif


/*
 * MUMBLE_PLUGIN_VERSION_CHECK
 * Converts a major, minor and patch version number into a single integer to be used in preprocessor
 * if conditions
 */
#	define MUMBLE_PLUGIN_VERSION_CHECK(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))

/*
 * MUMBLE_PLUGIN_CONSTEXPR
 */
#	ifdef __cplusplus
#		define MUMBLE_PLUGIN_CONSTEXPR constexpr
#	else
#		define MUMBLE_PLUGIN_CONSTEXPR
#	endif

/*
 * MUMBLE_EXTERN_C_BEGIN / MUMBLE_EXTERN_C_END
 */
#	ifdef __cplusplus
#		define MUMBLE_EXTERN_C_BEGIN extern "C" {
#		define MUMBLE_EXTERN_C_END }
#	else
#		define MUMBLE_EXTERN_C_BEGIN
#		define MUMBLE_EXTERN_C_END
#	endif

// For more info on the necessity of the with/without pattern have a look
// at https://stackoverflow.com/a/3419392

/*
 * MUMBLE_CONCAT
 * Concatenates the given values WITHOUT macro expansion
 */
#	define MUMBLE_CONCAT(a, b) a##_##b
/**
 * MUMBLE_ECONCAT
 * Concatenates the given values WITH macro expansion
 */
#	define MUMBLE_ECONCAT(a, b) MUMBLE_CONCAT(a, b)
/**
 * MUMBLE_QUOTE
 * Quotes the given value WITHOUT macro expansion
 */
#	define MUMBLE_QUOTE(arg) #    arg
/**
 * MUMBLE_EQUOTE
 * Quotes the given value WITH macro expansion
 */
#	define MUMBLE_EQUOTE(arg) MUMBLE_QUOTE(arg)

#endif // EXTERNAL_MUMBLE_PLUGIN_MACROS_



///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// PLUGIN TYPES /////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef EXTERNAL_MUMBLE_PLUGIN_TYPES_
#	define EXTERNAL_MUMBLE_PLUGIN_TYPES_

#	include <stdint.h>
#	include <stddef.h>
#	include <stdbool.h>

#	ifdef __cplusplus
#		include <string>

#		ifdef MUMBLE_PLUGIN_HAS_QT
#			include <QString>
#		endif
#	endif

MUMBLE_EXTERN_C_BEGIN

/**
 * This enum's values correspond to special feature sets a plugin may provide.
 * They are meant to be or'ed together to represent the total feature set of a plugin.
 */
enum Mumble_PluginFeature {
	/**
	 * None of the below
	 */
	MUMBLE_FEATURE_NONE = 0,
	/**
	 * The plugin provides positional data from a game
	 */
	MUMBLE_FEATURE_POSITIONAL = 1 << 0,
	/**
	 * The plugin modifies the input/output audio itself
	 */
	MUMBLE_FEATURE_AUDIO = 1 << 1,
};

/**
 * This enum's values represent talking states a user can be in when using Mumble.
 */
enum Mumble_TalkingState {
	MUMBLE_TS_INVALID = -1,
	MUMBLE_TS_PASSIVE = 0,
	MUMBLE_TS_TALKING,
	MUMBLE_TS_WHISPERING,
	MUMBLE_TS_SHOUTING,
	MUMBLE_TS_TALKING_MUTED,
};

/**
 * This enum's values represent transmission modes a user might have configured. Transmission mode
 * in this context is referring to a method that determines when a user is speaking and thus when
 * to transmit audio packets.
 */
enum Mumble_TransmissionMode {
	MUMBLE_TM_CONTINOUS,
	MUMBLE_TM_VOICE_ACTIVATION,
	MUMBLE_TM_PUSH_TO_TALK,
};

/**
 * This enum's values represent the error codes that are being used by the MumbleAPI.
 * You can get a string-representation for each error code via the errorMessage function.
 */
enum Mumble_ErrorCode {
	MUMBLE_EC_INTERNAL_ERROR = -2,
	MUMBLE_EC_GENERIC_ERROR  = -1,
	MUMBLE_EC_OK             = 0,
	MUMBLE_EC_POINTER_NOT_FOUND,
	MUMBLE_EC_NO_ACTIVE_CONNECTION,
	MUMBLE_EC_USER_NOT_FOUND,
	MUMBLE_EC_CHANNEL_NOT_FOUND,
	MUMBLE_EC_CONNECTION_NOT_FOUND,
	MUMBLE_EC_UNKNOWN_TRANSMISSION_MODE,
	MUMBLE_EC_AUDIO_NOT_AVAILABLE,
	MUMBLE_EC_INVALID_SAMPLE,
	MUMBLE_EC_INVALID_PLUGIN_ID,
	MUMBLE_EC_INVALID_MUTE_TARGET,
	MUMBLE_EC_CONNECTION_UNSYNCHRONIZED,
	MUMBLE_EC_INVALID_API_VERSION,
	MUMBLE_EC_UNSYNCHRONIZED_BLOB,
	MUMBLE_EC_UNKNOWN_SETTINGS_KEY,
	MUMBLE_EC_WRONG_SETTINGS_TYPE,
	MUMBLE_EC_SETTING_WAS_REMOVED,
	MUMBLE_EC_DATA_TOO_BIG,
	MUMBLE_EC_DATA_ID_TOO_LONG,
	MUMBLE_EC_API_REQUEST_TIMEOUT,
	MUMBLE_EC_OPERATION_UNSUPPORTED_BY_SERVER,
};

/**
 * This enum's values represent error codes specific to the framework of handling positional data
 * gathering (needed for Mumble's positional audio feature).
 */
enum Mumble_PositionalDataErrorCode {
	/**
	 * Positional data has been initialized properly
	 */
	MUMBLE_PDEC_OK = 0,
	/**
	 * Positional data is temporarily unavailable (e.g. because the corresponding process isn't running) but might be
	 * at another point in time.
	 */
	MUMBLE_PDEC_ERROR_TEMP,
	/**
	 * Positional data is permanently unavailable (e.g. because the respective memory offsets are outdated).
	 */
	MUMBLE_PDEC_ERROR_PERM,
};

/**
 * This enum's values represent keys for specific settings inside Mumble.
 */
enum Mumble_SettingsKey {
	MUMBLE_SK_INVALID                           = -1,
	MUMBLE_SK_AUDIO_INPUT_VOICE_HOLD            = 0,
	MUMBLE_SK_AUDIO_INPUT_VAD_SILENCE_THRESHOLD = 1,
	MUMBLE_SK_AUDIO_INPUT_VAD_SPEECH_THRESHOLD  = 2,
	MUMBLE_SK_AUDIO_OUTPUT_PA_MINIMUM_DISTANCE  = 3,
	MUMBLE_SK_AUDIO_OUTPUT_PA_MAXIMUM_DISTANCE  = 4,
	MUMBLE_SK_AUDIO_OUTPUT_PA_BLOOM             = 5,
	MUMBLE_SK_AUDIO_OUTPUT_PA_MINIMUM_VOLUME    = 6,
};

/**
 * This enum's values represent the key-codes Mumble's API uses to reference keys on the keyboard.
 */
enum Mumble_KeyCode {
	MUMBLE_KC_INVALID = -1,

	// Non-printable characters first
	MUMBLE_KC_NULL       = 0,
	MUMBLE_KC_END        = 1,
	MUMBLE_KC_LEFT       = 2,
	MUMBLE_KC_RIGHT      = 4,
	MUMBLE_KC_UP         = 5,
	MUMBLE_KC_DOWN       = 6,
	MUMBLE_KC_DELETE     = 7,
	MUMBLE_KC_BACKSPACE  = 8,
	MUMBLE_KC_TAB        = 9,
	MUMBLE_KC_ENTER      = 10, // == '\n'
	MUMBLE_KC_ESCAPE     = 27,
	MUMBLE_KC_PAGE_UP    = 11,
	MUMBLE_KC_PAGE_DOWN  = 12,
	MUMBLE_KC_SHIFT      = 13,
	MUMBLE_KC_CONTROL    = 14,
	MUMBLE_KC_META       = 15,
	MUMBLE_KC_ALT        = 16,
	MUMBLE_KC_ALT_GR     = 17,
	MUMBLE_KC_CAPSLOCK   = 18,
	MUMBLE_KC_NUMLOCK    = 19,
	MUMBLE_KC_SUPER      = 20, // == windows key
	MUMBLE_KC_HOME       = 21, // == Pos1
	MUMBLE_KC_PRINT      = 22,
	MUMBLE_KC_SCROLLLOCK = 23,

	// Printable characters are assigned to their ASCII code
	MUMBLE_KC_SPACE             = ' ',
	MUMBLE_KC_EXCLAMATION_MARK  = '!',
	MUMBLE_KC_DOUBLE_QUOTE      = '"',
	MUMBLE_KC_HASHTAG           = '#',
	MUMBLE_KC_DOLLAR            = '$',
	MUMBLE_KC_PERCENT           = '%',
	MUMBLE_KC_AMPERSAND         = '&',
	MUMBLE_KC_SINGLE_QUOTE      = '\'',
	MUMBLE_KC_OPEN_PARENTHESIS  = '(',
	MUMBLE_KC_CLOSE_PARENTHESIS = ')',
	MUMBLE_KC_ASTERISK          = '*',
	MUMBLE_KC_PLUS              = '+',
	MUMBLE_KC_COMMA             = ',',
	MUMBLE_KC_MINUS             = '-',
	MUMBLE_KC_PERIOD            = '.',
	MUMBLE_KC_SLASH             = '/',
	MUMBLE_KC_0                 = '0',
	MUMBLE_KC_1                 = '1',
	MUMBLE_KC_2                 = '2',
	MUMBLE_KC_3                 = '3',
	MUMBLE_KC_4                 = '4',
	MUMBLE_KC_5                 = '5',
	MUMBLE_KC_6                 = '6',
	MUMBLE_KC_7                 = '7',
	MUMBLE_KC_8                 = '8',
	MUMBLE_KC_9                 = '9',
	MUMBLE_KC_COLON             = ':',
	MUMBLE_KC_SEMICOLON         = ';',
	MUMBLE_KC_LESS_THAN         = '<',
	MUMBLE_KC_EQUALS            = '=',
	MUMBLE_KC_GREATER_THAN      = '>',
	MUMBLE_KC_QUESTION_MARK     = '?',
	MUMBLE_KC_AT_SYMBOL         = '@',
	MUMBLE_KC_A                 = 'A',
	MUMBLE_KC_B                 = 'B',
	MUMBLE_KC_C                 = 'C',
	MUMBLE_KC_D                 = 'D',
	MUMBLE_KC_E                 = 'E',
	MUMBLE_KC_F                 = 'F',
	MUMBLE_KC_G                 = 'G',
	MUMBLE_KC_H                 = 'H',
	MUMBLE_KC_I                 = 'I',
	MUMBLE_KC_J                 = 'J',
	MUMBLE_KC_K                 = 'K',
	MUMBLE_KC_L                 = 'L',
	MUMBLE_KC_M                 = 'M',
	MUMBLE_KC_N                 = 'N',
	MUMBLE_KC_O                 = 'O',
	MUMBLE_KC_P                 = 'P',
	MUMBLE_KC_Q                 = 'Q',
	MUMBLE_KC_R                 = 'R',
	MUMBLE_KC_S                 = 'S',
	MUMBLE_KC_T                 = 'T',
	MUMBLE_KC_U                 = 'U',
	MUMBLE_KC_V                 = 'V',
	MUMBLE_KC_W                 = 'W',
	MUMBLE_KC_X                 = 'X',
	MUMBLE_KC_Y                 = 'Y',
	MUMBLE_KC_Z                 = 'Z',
	// leave out lowercase letters (for now)
	MUMBLE_KC_OPEN_BRACKET  = '[',
	MUMBLE_KC_BACKSLASH     = '\\',
	MUMBLE_KC_CLOSE_BRACKET = ']',
	MUMBLE_KC_CIRCUMFLEX    = '^',
	MUMBLE_KC_UNDERSCORE    = '_',
	MUMBLE_KC_GRAVE_AKCENT  = '`',
	MUMBLE_KC_OPEN_BRACE    = '{',
	MUMBLE_KC_VERTICAL_BAR  = '|',
	MUMBLE_KC_CLOSE_BRACE   = '}',
	MUMBLE_KC_TILDE         = '~',

	// Some characters from the extended ASCII code
	MUMBLE_KC_DEGREE_SIGN = 176,



	// F-keys
	// Start at a value of 256 as extended ASCII codes range up to 255
	MUMBLE_KC_F1  = 256,
	MUMBLE_KC_F2  = 257,
	MUMBLE_KC_F3  = 258,
	MUMBLE_KC_F4  = 259,
	MUMBLE_KC_F5  = 260,
	MUMBLE_KC_F6  = 261,
	MUMBLE_KC_F7  = 262,
	MUMBLE_KC_F8  = 263,
	MUMBLE_KC_F9  = 264,
	MUMBLE_KC_F10 = 265,
	MUMBLE_KC_F11 = 266,
	MUMBLE_KC_F12 = 267,
	MUMBLE_KC_F13 = 268,
	MUMBLE_KC_F14 = 269,
	MUMBLE_KC_F15 = 270,
	MUMBLE_KC_F16 = 271,
	MUMBLE_KC_F17 = 272,
	MUMBLE_KC_F18 = 273,
	MUMBLE_KC_F19 = 274,
};

/**
 * A struct for representing a version of the form major.minor.patch
 */
struct MumbleVersion {
	int32_t major;
	int32_t minor;
	int32_t patch;
#	ifdef __cplusplus
	explicit operator std::string() const {
		return std::string("v") + std::to_string(this->major) + std::string(".") + std::to_string(this->minor)
			   + std::string(".") + std::to_string(this->patch);
	}

#		ifdef MUMBLE_PLUGIN_HAS_QT
	explicit operator QString() const {
		return QString::fromLatin1("v%0.%1.%2").arg(this->major).arg(this->minor).arg(this->patch);
	}
#		endif
#	endif // __cplusplus
};

/**
 * This struct is used to return Strings from a plugin to Mumble. It is needed in order to
 * work around the limitation of std::string not being part of C (it holds important information
 * about the String's lifetime management requirements).
 */
struct MumbleStringWrapper {
	/**
	 * The pointer to the actual String data
	 */
	const char *data;
	/**
	 * The size of the pointed String data
	 */
	size_t size;
	/**
	 * Whether the wrapped String needs to be released
	 * after its usage. Instances for which this would be
	 * false: Static Strings, String literals
	 */
	bool needsReleasing;
};

MUMBLE_EXTERN_C_END

#endif // EXTERNAL_MUMBLE_PLUGIN_TYPES_


///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// Type aliases / Typedefs /////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef EXTERNAL_MUMBLE_PLUGIN_TYPEDEFS_
#	define EXTERNAL_MUMBLE_PLUGIN_TYPEDEFS_

/**
 * Typedef for the type of a talking state
 */
typedef enum Mumble_TalkingState mumble_talking_state_t;
/**
 * Typedef for the type of a transmission mode
 */
typedef enum Mumble_TransmissionMode mumble_transmission_mode_t;
/**
 * Typedef for the type of a version
 */
typedef struct MumbleVersion mumble_version_t;
/**
 * Typedef for the type of a connection
 */
typedef int32_t mumble_connection_t;
/**
 * Typedef for the type of a user
 */
typedef uint32_t mumble_userid_t;
/**
 * Typedef for the type of a channel
 */
typedef int32_t mumble_channelid_t;
/**
 * Typedef for the type of an error (code)
 */
typedef enum Mumble_ErrorCode mumble_error_t;
/**
 * Typedef for the type of a plugin ID
 */
typedef uint32_t mumble_plugin_id_t;
/**
 * Typedef for the type of a key to a setting in Mumble
 */
typedef enum Mumble_SettingsKey mumble_settings_key_t;
/**
 * Typedef for the type of a key-code
 */
typedef enum Mumble_KeyCode mumble_keycode_t;

#endif // EXTERNAL_MUMBLE_PLUGIN_TYPEDEFS_



///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// Non-enum Constants /////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef EXTERNAL_MUMBLE_PLUGIN_CONSTANTS_
#	define EXTERNAL_MUMBLE_PLUGIN_CONSTANTS_

/*
 * Version constants
 */

static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_INTERFACE_MAJOR = MUMBLE_PLUGIN_INTERFACE_MAJOR_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_INTERFACE_MINOR = MUMBLE_PLUGIN_INTERFACE_MINOR_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_INTERFACE_PATCH = MUMBLE_PLUGIN_INTERFACE_PATCH_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR mumble_version_t MUMBLE_PLUGIN_INTERFACE_VERSION = {
	MUMBLE_PLUGIN_INTERFACE_MAJOR, MUMBLE_PLUGIN_INTERFACE_MINOR, MUMBLE_PLUGIN_INTERFACE_PATCH
};

static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_API_MAJOR            = MUMBLE_PLUGIN_API_MAJOR_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_API_MINOR            = MUMBLE_PLUGIN_API_MINOR_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_API_PATCH            = MUMBLE_PLUGIN_API_PATCH_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR mumble_version_t MUMBLE_PLUGIN_API_VERSION = { MUMBLE_PLUGIN_API_MAJOR,
																					MUMBLE_PLUGIN_API_MINOR,
																					MUMBLE_PLUGIN_API_PATCH };

static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_FUNCTIONS_MAJOR = MUMBLE_PLUGIN_FUNCTIONS_MAJOR_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_FUNCTIONS_MINOR = MUMBLE_PLUGIN_FUNCTIONS_MINOR_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR int32_t MUMBLE_PLUGIN_FUNCTIONS_PATCH = MUMBLE_PLUGIN_FUNCTIONS_PATCH_MACRO;
static const MUMBLE_PLUGIN_CONSTEXPR mumble_version_t MUMBLE_PLUGIN_FUNCTIONS_VERSION = {
	MUMBLE_PLUGIN_FUNCTIONS_MAJOR, MUMBLE_PLUGIN_FUNCTIONS_MINOR, MUMBLE_PLUGIN_FUNCTIONS_PATCH
};

/**
 * The exit status of a successful operation
 */
static const MUMBLE_PLUGIN_CONSTEXPR mumble_error_t MUMBLE_STATUS_OK = MUMBLE_EC_OK;
/**
 * A version object that is considered to correspond to an unknown version
 */
static const MUMBLE_PLUGIN_CONSTEXPR mumble_version_t MUMBLE_VERSION_UNKNOWN = { 0, 0, 0 };

#endif // EXTERNAL_MUMBLE_PLUGIN_CONSTANTS_



///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// C convenience implementations /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef EXTERNAL_MUMBLE_PLUGIN_C_CONVENIENCE_IMPLS_
#	define EXTERNAL_MUMBLE_PLUGIN_C_CONVENIENCE_IMPLS_

/**
 * Obtains a String representation for the given numeric error code.
 * Note that the exact String representation corresponding to an error code may change and is thus
 * not part of the plugin API as such. This function acts merely as a convenience helper for printing
 * errors in a meaningful way.
 *
 * @param errorCode The error code to get the String representation for
 * @returns The error message coresponding to the given error code. The message
 * is encoded as a C-string and is static, meaning that it is safe to use the
 * returned pointer in your code.
 */
MUMBLE_PLUGIN_CONSTEXPR inline const char *mumble_errorMessage(int16_t errorCode) {
	switch (errorCode) {
		case MUMBLE_EC_GENERIC_ERROR:
			return "Generic error";
		case MUMBLE_EC_OK:
			return "Ok - this is not an error";
		case MUMBLE_EC_POINTER_NOT_FOUND:
			return "Can't find the passed pointer";
		case MUMBLE_EC_NO_ACTIVE_CONNECTION:
			return "There is currently no active connection to a server";
		case MUMBLE_EC_USER_NOT_FOUND:
			return "Can't find the requested user";
		case MUMBLE_EC_CHANNEL_NOT_FOUND:
			return "Can't find the requested channel";
		case MUMBLE_EC_CONNECTION_NOT_FOUND:
			return "Can't identify the requested connection";
		case MUMBLE_EC_UNKNOWN_TRANSMISSION_MODE:
			return "Unknown transmission mode encountered";
		case MUMBLE_EC_AUDIO_NOT_AVAILABLE:
			return "There is currently no audio output available";
		case MUMBLE_EC_INVALID_SAMPLE:
			return "Attempted to use invalid sample (can't play it)";
		case MUMBLE_EC_INVALID_PLUGIN_ID:
			return "Used an invalid plugin ID";
		case MUMBLE_EC_INVALID_MUTE_TARGET:
			return "Used an invalid mute-target";
		case MUMBLE_EC_CONNECTION_UNSYNCHRONIZED:
			return "The requested server connection has not yet finished synchronizing";
		case MUMBLE_EC_INVALID_API_VERSION:
			return "The used API version is invalid or not supported";
		case MUMBLE_EC_UNSYNCHRONIZED_BLOB:
			return "The requested blob (content) has not yet been synchronized between the client and the server";
		case MUMBLE_EC_UNKNOWN_SETTINGS_KEY:
			return "The used settings-key does not match any key known to Mumble";
		case MUMBLE_EC_WRONG_SETTINGS_TYPE:
			return "The referenced setting has a different type than requested";
		case MUMBLE_EC_SETTING_WAS_REMOVED:
			return "The referenced setting got removed from Mumble and is no longer used";
		case MUMBLE_EC_DATA_TOO_BIG:
			return "The given data is too large (exceeds limit)";
		case MUMBLE_EC_DATA_ID_TOO_LONG:
			return "The given data ID is too long (exceeds limit)";
		case MUMBLE_EC_API_REQUEST_TIMEOUT:
			return "A blocking API call took too long and was thus aborted (probably preventing a deadlock)";
		case MUMBLE_EC_OPERATION_UNSUPPORTED_BY_SERVER:
			return "The requested API operation depends on server-side functionality, not supported by the server "
				   "you're connected to";
	}

	return "Unknown error code";
}
#endif // EXTERNAL_MUMBLE_PLUGIN_C_CONVENIENCE_IMPLS_



///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////// C++ convenience implementations ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#if !defined(EXTERNAL_MUMBLE_PLUGIN_CPP_CONVENIENCE_IMPLS_) && defined(__cplusplus)
#	define EXTERNAL_MUMBLE_PLUGIN_CPP_CONVENIENCE_IMPLS_

/*
 * Comparison operator overloads for MumbleVersion structs
 */
constexpr bool operator<(const MumbleVersion &lhs, const MumbleVersion &rhs) {
	if (lhs.major != rhs.major) {
		return lhs.major < rhs.major;
	}
	if (lhs.minor != rhs.minor) {
		return lhs.minor < rhs.minor;
	}
	// Major and Minor are equal
	return lhs.patch < rhs.patch;
}

constexpr bool operator==(const MumbleVersion &lhs, const MumbleVersion &rhs) {
	return lhs.major == rhs.major && lhs.minor == rhs.minor && lhs.patch == rhs.patch;
}


constexpr bool operator!=(const MumbleVersion &lhs, const MumbleVersion &rhs) {
	return !(lhs == rhs);
}

constexpr bool operator>(const MumbleVersion &lhs, const MumbleVersion &rhs) {
	return !(lhs == rhs || lhs < rhs);
}

constexpr bool operator>=(const MumbleVersion &lhs, const MumbleVersion &rhs) {
	return lhs == rhs || lhs > rhs;
}

constexpr bool operator<=(const MumbleVersion &lhs, const MumbleVersion &rhs) {
	return lhs == rhs || lhs < rhs;
}

#endif // EXTERNAL_MUMBLE_PLUGIN_CPP_CONVENIENCE_IMPLS_



///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// Plugin functions //////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef EXTERNAL_MUMBLE_PLUGIN_FUNCTIONS_
#	define EXTERNAL_MUMBLE_PLUGIN_FUNCTIONS_

#	include <stdint.h>
#	include <stddef.h>
#	include <stdbool.h>

MUMBLE_EXTERN_C_BEGIN

// >>>>>>>>>>>>>>>>>>>> MANDATORY functions <<<<<<<<<<<<<<<<<<<<

/**
 * Gets called right after loading the plugin in order to let the plugin initialize.
 *
 * Registers the ID of this plugin.
 * @param id The ID for this plugin. This is the ID Mumble will reference this plugin with
 * and by which this plugin can identify itself when communicating with Mumble.
 * @returns The status of the initialization. If everything went fine, return STATUS_OK
 */
MUMBLE_PLUGIN_EXPORT mumble_error_t MUMBLE_PLUGIN_CALLING_CONVENTION mumble_init(mumble_plugin_id_t id);

/**
 * Gets called when unloading the plugin in order to allow it to clean up after itself.
 * Note that it is still safe to call API functions from within this callback.
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_shutdown();

/**
 * Gets the name of the plugin.
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @returns A String-wrapper containing the requested name
 */
MUMBLE_PLUGIN_EXPORT struct MumbleStringWrapper MUMBLE_PLUGIN_CALLING_CONVENTION mumble_getName();

/**
 * Gets the Version of the plugin-API this plugin intends to use.
 * Mumble will decide whether this plugin is loadable or not based on the return value of this function.
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @returns The respective API Version
 */
MUMBLE_PLUGIN_EXPORT mumble_version_t MUMBLE_PLUGIN_CALLING_CONVENTION mumble_getAPIVersion();

/**
 * Provides the MumbleAPI struct to the plugin. This struct contains function pointers that can be used
 * to interact with the Mumble client. It is up to the plugin to store this struct somewhere if it wants to make use
 * of it at some point.
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @param api A pointer to the MumbleAPI struct. The API struct must be cast to the version corresponding to the
 * user API version. If your plugin is e.g. using the 1.0.x API, then you have to cast this pointer to
 * MumbleAPI_v_1_0_x. Note also that you **must not store this pointer**. It will become invalid. Therefore
 * you have to copy the struct in order to use it later on.
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_registerAPIFunctions(void *apiStruct);

/**
 * Releases the resource pointed to by the given pointer. If the respective resource has been allocated before,
 * this would be the time to free/delete it.
 * The resources processed by this functions are only those that have been specifically allocated in order to return
 * them in one of the plugin functions to Mumble (e.g. the String returned by mumble_getName) and has nothing to do
 * with your plugin's internal resource management.
 * In short: Only resources passed from the plugin to Mumble via a return value may be processed by this function.
 *
 * NOTE1: This function may be called without the plugin being loaded
 *
 * NOTE2: that the pointer might be pointing to memory that had to be allocated without the plugin being loaded.
 * Therefore you should be very sure that there'll be another callback in which you want to free this memory,
 * should you decide to not do it here (which is hereby explicitly advised against).
 *
 * NOTE3: The pointer is const as Mumble won't mess with the memory allocated by the plugin (no modifications).
 * Nontheless this function is explicitly responsible for freeing the respective memory parts. If the memory has
 * been allocated using malloc(), it needs to be freed using free() which requires a const-cast. If however the
 * memory has been created using the new operator you have to cast the pointer back to its original type and then
 * use the  delete operator on it (no const-cast necessary in this case).
 * See https://stackoverflow.com/questions/2819535/unable-to-free-const-pointers-in-c
 * and https://stackoverflow.com/questions/941832/is-it-safe-to-delete-a-void-pointer
 *
 * @param pointer The pointer to the memory that needs free-ing
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_releaseResource(const void *pointer);



// >>>>>>>>>>>>>>>>>>>> GENERAL functions <<<<<<<<<<<<<<<<<<<<

/**
 * Tells the plugin some basic information about the Mumble client loading it.
 * This function will be the first one that is being called on this plugin - even before it is decided whether to load
 * the plugin at all.
 *
 * @param mumbleVersion The Version of the Mumble client
 * @param mumbleAPIVersion The Version of the plugin-API the Mumble client runs with
 * @param minimumExpectedAPIVersion The minimum Version the Mumble clients expects this plugin to meet in order to load
 * it
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_setMumbleInfo(
	mumble_version_t mumbleVersion, mumble_version_t mumbleAPIVersion, mumble_version_t minimumExpectedAPIVersion);

/**
 * Gets the Version of this plugin
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @returns The plugin's version
 */
MUMBLE_PLUGIN_EXPORT mumble_version_t MUMBLE_PLUGIN_CALLING_CONVENTION mumble_getVersion();

/**
 * Gets the name of the plugin author(s).
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @returns A String-wrapper containing the requested author name(s)
 */
MUMBLE_PLUGIN_EXPORT struct MumbleStringWrapper MUMBLE_PLUGIN_CALLING_CONVENTION mumble_getAuthor();

/**
 * Gets the description of the plugin.
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @returns A String-wrapper containing the requested description
 */
MUMBLE_PLUGIN_EXPORT struct MumbleStringWrapper MUMBLE_PLUGIN_CALLING_CONVENTION mumble_getDescription();

/**
 * Gets the feature set of this plugin. The feature set is described by bitwise or'ing the elements of the
 * Mumble_PluginFeature enum together.
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @returns The feature set of this plugin
 */
MUMBLE_PLUGIN_EXPORT uint32_t MUMBLE_PLUGIN_CALLING_CONVENTION mumble_getFeatures();

/**
 * Requests this plugin to deactivate the given (sub)set of provided features.
 * If this is not possible, the features that can't be deactivated shall be returned by this function.
 *
 * Example (check if FEATURE_POSITIONAL shall be deactivated):
 * @code
 * if (features & FEATURE_POSITIONAL) {
 *   // positional shall be deactivated
 * }
 * @endcode
 *
 * @param features The feature set that shall be deactivated
 * @returns The feature set that can't be disabled (bitwise or'ed). If all requested features can be disabled, return
 * FEATURE_NONE. If none of the requested features can be disabled return the unmodified features parameter.
 */
MUMBLE_PLUGIN_EXPORT uint32_t MUMBLE_PLUGIN_CALLING_CONVENTION mumble_deactivateFeatures(uint32_t features);


// >>>>>>>>>>>>>>>>>>>> POSITIONAL DATA functions <<<<<<<<<<<<<<<<<<<<

/*
 * If this plugin wants to provide positional data, the mumble_initPositionalData, mumble_fetchPositionalData
 * and mumble_shutdownPositionalData functions have to be implemented together (implementing only a subset
 * will yield the same result as if no support for positional data was implemened).
 */

/**
 * Indicates that Mumble wants to use this plugin to request positional data. Therefore it should check whether it is
 * currently able to do so and allocate memory that is needed for that process. As a parameter this function gets an
 * array of names and an array of PIDs. They are of same length and the PID at index i belongs to a program whose name
 * is listed at index i in the "name-array".
 *
 * @param programNames An array of pointers to the program names
 * @param programPIDs An array of the corresponding program PIDs
 * @param programCount The length of programNames and programPIDs
 * @returns The error code. If everything went fine PDEC_OK shall be returned. In that case Mumble will start
 * frequently calling fetchPositionalData. If this returns anything but PDEC_OK, Mumble will assume that the plugin is
 * (currently) uncapable of providing positional data. In this case this function must not have allocated any memory
 * that needs to be cleaned up later on. Depending on the returned error code, Mumble might try to call this function
 * again at some point.
 */
MUMBLE_PLUGIN_EXPORT uint8_t MUMBLE_PLUGIN_CALLING_CONVENTION mumble_initPositionalData(const char *const *programNames,
																						const uint64_t *programPIDs,
																						size_t programCount);

/**
 * Retrieves the positional data. If no data can be fetched, set all float-vectors to 0 and return false.
 *
 * @param[out] avatarPos A float-array of size 3 representing the cartesian position of the player/avatar in the ingame
 * world. One unit represents one meter of distance.
 * @param[out] avatarDir A float-array of size 3 representing the cartesian direction-vector of the player/avatar
 * ingame (where it is facing).
 * @param[out] avatarAxis A float-array of size 3 representing the vector pointing from the toes of the character to
 * its head. One unit represents one meter of distance.
 * @param[out] cameraPos A float-array of size 3 representing the cartesian position of the camera in the ingame world.
 * One unit represents one meter of distance.
 * @param[out] cameraDir A float-array of size 3 representing the cartesian direction-vector of the camera ingame
 * (where it is facing).
 * @param[out] cameraAxis A float-array of size 3 representing a vector from the bottom of the camera to its top. One
 * unit represents one meter of distance.
 * @param[out] context A pointer to where the pointer to a C-encoded string storing the context of the provided
 * positional data shall be written. This context should include information about the server (and team) the player is
 * on. Only players with identical context will be able to hear each other's audio. The returned pointer has to remain
 * valid until the next invokation of this function or until shutdownPositionalData is called.
 * @param[out] identity A pointer to where the pointer to a C-encoded string storing the identity of the player shall
 * be written. It can be polled by external scripts from the server and should uniquely identify the player in the
 * game. The pointer has to remain valid until the next invokation of this function or until shutdownPositionalData is
 * called.
 * @returns Whether this plugin can continue delivering positional data. If this function returns false,
 * shutdownPositionalData will be called.
 */
MUMBLE_PLUGIN_EXPORT bool MUMBLE_PLUGIN_CALLING_CONVENTION
	mumble_fetchPositionalData(float *avatarPos, float *avatarDir, float *avatarAxis, float *cameraPos,
							   float *cameraDir, float *cameraAxis, const char **context, const char **identity);

/**
 * Indicates that this plugin will not be asked for positional data any longer. Thus any memory allocated for this
 * purpose should be freed at this point.
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_shutdownPositionalData();

/**
 * The context in positional data is used to determine whether different positional data sets from different
 * clients belong to the same game (and same server). Only if the contexts matches up across these clients,
 * will Mumble activate the positional audio effects, as it will assume that these clients are playing the
 * same game together.
 * The context is set during fetching of the other positional data and is usually something like e.g. the
 * current server's name. In order to avoid clashes between different plugins (that most likely work for
 * different games), the context is prefixed by Mumble. If this function is not implemented, the name of
 * the plugin is used as a prefix (which tends to be the supported game's name), but sometimes a different
 * prefix is desirable. For these cases, a custom prefix can be provided through this function.
 *
 * NOTE that while it is possible to allocate a string for this purpose every time this function is called
 * and then letting mumble release the resource again (via mumble_releaseResource), it is generally not the
 * advised way of doing things (it may impact overall performance negatively, since this function will be
 * called very frequently). Instead you should either return a static string (if your language supports that
 * and if it actually fits your needs) or you should allocate a string during mumble_initPositionalData and
 * free it in mumble_shutdownPositionalData and when returning the string in this function, tell Mumble that
 * the string does not need releasing.
 *
 * @returns The context prefix to use for positional data fetched by this plugin.
 *
 * @since Plugin interface v1.1.0
 */
MUMBLE_PLUGIN_EXPORT struct MumbleStringWrapper MUMBLE_PLUGIN_CALLING_CONVENTION
	mumble_getPositionalDataContextPrefix();



// >>>>>>>>>>>>>>>>>>>> EVENTHANDLER / CALLBACK functions <<<<<<<<<<<<<<<<<<<<

/**
 * Called when connecting to a server.
 * Note that in most cases you'll want to use mumble_onServerSynchronized instead.
 * Note also that this callback will be called from a DIFFERENT THREAD!
 *
 * @param connection The ID of the newly established server-connection
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onServerConnected(mumble_connection_t connection);

/**
 * Called when disconnecting from a server.
 * Note that this callback is called from a DIFFERENT THREAD!
 *
 * @param connection The ID of the server-connection that has been terminated
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onServerDisconnected(mumble_connection_t connection);

/**
 * Called when the client has finished synchronizing with the server
 *
 * @param connection The ID of the server-connection that has been terminated
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onServerSynchronized(mumble_connection_t connection);

/**
 * Called whenever any user on the server enters a channel
 * This function will also be called when freshly connecting to a server as each user on that
 * server needs to be "added" to the respective channel as far as the local client is concerned.
 *
 * @param connection The ID of the server-connection this event is connected to
 * @param userID The ID of the user this event has been triggered for
 * @param previousChannelID The ID of the chanel the user is coming from. Negative IDs indicate that there is no
 * previous channel (e.g. the user freshly connected to the server) or the channel isn't available because of any other
 * reason.
 * @param newChannelID The ID of the channel the user has entered. If the ID is negative, the new channel could not be
 * retrieved. This means that the ID is invalid.
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onChannelEntered(mumble_connection_t connection,
																				   mumble_userid_t userID,
																				   mumble_channelid_t previousChannelID,
																				   mumble_channelid_t newChannelID);

/**
 * Called whenever a user leaves a channel.
 * This includes a client disconnecting from the server as this will also lead to the user not being in that channel
 * anymore.
 *
 * @param connection The ID of the server-connection this event is connected to
 * @param userID The ID of the user that left the channel
 * @param channelID The ID of the channel the user left. If the ID is negative, the channel could not be retrieved.
 * This means that the ID is invalid.
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onChannelExited(mumble_connection_t connection,
																				  mumble_userid_t userID,
																				  mumble_channelid_t channelID);

/**
 * Called when any user changes his/her talking state.
 *
 * @param connection The ID of the server-connection this event is connected to
 * @param userID The ID of the user whose talking state has been changed
 * @param talkingState The new TalkingState the user has switched to.
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onUserTalkingStateChanged(
	mumble_connection_t connection, mumble_userid_t userID, mumble_talking_state_t talkingState);

/**
 * Called whenever there is audio input.
 * Note that this callback will be called from the AUDIO THREAD.
 * Note also that blocking this callback will cause Mumble's audio processing to get suspended.
 *
 * @param inputPCM A pointer to a short-array holding the pulse-code-modulation (PCM) representing the audio input. Its
 * length is sampleCount * channelCount. The PCM format for stereo input is [LRLRLR...] where L and R are samples of
 * the left and right channel respectively.
 * @param sampleCount The amount of sample points per channel
 * @param channelCount The amount of channels in the audio
 * @param sampleRate The used sample rate in Hz
 * @param isSpeech A boolean flag indicating whether Mumble considers the input as part of speech (instead of
 * background noise)
 * @returns Whether this callback has modified the audio input-array
 */
MUMBLE_PLUGIN_EXPORT bool MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onAudioInput(short *inputPCM, uint32_t sampleCount,
																			   uint16_t channelCount,
																			   uint32_t sampleRate, bool isSpeech);

/**
 * Called whenever Mumble fetches data from an active audio source (could be a voice packet or a playing sample).
 * The provided audio buffer is the raw buffer without any processing applied to it yet.
 * Note that this callback will be called from the AUDIO THREAD.
 * Note also that blocking this callback will cause Mumble's audio processing to get suspended.
 *
 * @param outputPCM A pointer to a float-array holding the pulse-code-modulation (PCM) representing the audio output.
 * Its length is sampleCount * channelCount. The PCM format for stereo output is [LRLRLR...] where L and R are samples
 * of the left and right channel respectively.
 * @param sampleCount The amount of sample points per channel
 * @param channelCount The amount of channels in the audio
 * @param sampleRate The used sample rate in Hz
 * @param isSpeech Whether this audio belongs to a received voice packet (and will thus (most likely) contain speech)
 * @param userID If isSpeech is true, this contains the ID of the user this voice packet belongs to. If isSpeech is
 * false, the content of this parameter is unspecified and should not be accessed
 * @returns Whether this callback has modified the audio output-array
 */
MUMBLE_PLUGIN_EXPORT bool MUMBLE_PLUGIN_CALLING_CONVENTION
	mumble_onAudioSourceFetched(float *outputPCM, uint32_t sampleCount, uint16_t channelCount, uint32_t sampleRate,
								bool isSpeech, mumble_userid_t userID);

/**
 * Called whenever the fully mixed and processed audio is about to be handed to the audio backend (about to be played).
 * Note that this happens immediately before Mumble clips the audio buffer.
 * Note that this callback will be called from the AUDIO THREAD.
 * Note also that blocking this callback will cause Mumble's audio processing to get suspended.
 *
 * @param outputPCM A pointer to a float-array holding the pulse-code-modulation (PCM) representing the audio output.
 * Its length is sampleCount * channelCount. The PCM format for stereo output is [LRLRLR...] where L and R are samples
 * of the left and right channel respectively.
 * @param sampleCount The amount of sample points per channel
 * @param channelCount The amount of channels in the audio
 * @param sampleRate The used sample rate in Hz
 * @returns Whether this callback has modified the audio output-array
 */
MUMBLE_PLUGIN_EXPORT bool MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onAudioOutputAboutToPlay(float *outputPCM,
																						   uint32_t sampleCount,
																						   uint16_t channelCount,
																						   uint32_t sampleRate);

/**
 * Called whenever data has been received that has been sent by a plugin. This data should only be processed by the
 * intended plugin. For this reason a dataID is provided that should be used to determine whether the data is intended
 * for this plugin or not. As soon as the data has been processed, no further plugins will be notified about it.
 *
 * @param connection The ID of the server-connection the data is coming from
 * @param sender The ID of the user whose client's plugin has sent the data
 * @param data The sent data array. This can be an arbitrary sequence of bytes.
 * @param dataLength The length of the data array
 * @param dataID The ID of this data (C-encoded)
 * @return Whether the given data has been processed by this plugin
 */
MUMBLE_PLUGIN_EXPORT bool MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onReceiveData(mumble_connection_t connection,
																				mumble_userid_t sender,
																				const uint8_t *data, size_t dataLength,
																				const char *dataID);

/**
 * Called when a new user gets added to the user model. This is the case when that new user freshly connects to the
 * server the local user is on but also when the local user connects to a server other clients are already connected to
 * (in this case this method will be called for every client already on that server).
 *
 * @param connection An object used to identify the current connection
 * @param userID The ID of the user that has been added
 */

MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onUserAdded(mumble_connection_t connection,
																			  mumble_userid_t userID);

/**
 * Called when a user gets removed from the user model. This is the case when that user disconnects from the server the
 * local user is on but also when the local user disconnects from a server other clients are connected to (in this case
 * this method will be called for every client on that server).
 *
 * @param connection An object used to identify the current connection
 * @param userID The ID of the user that has been removed
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onUserRemoved(mumble_connection_t connection,
																				mumble_userid_t userID);

/**
 * Called when a new channel gets added to the user model. This is the case when a new channel is created on the server
 * the local user is on but also when the local user connects to a server that contains channels other than the
 * root-channel (in this case this method will be called for ever non-root channel on that server).
 *
 * @param connection An object used to identify the current connection
 * @param channelID The ID of the channel that has been added
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onChannelAdded(mumble_connection_t connection,
																				 mumble_channelid_t channelID);

/**
 * Called when a channel gets removed from the user model. This is the case when a channel is removed on the server the
 * local user is on but also when the local user disconnects from a server that contains channels other than the
 * root-channel (in this case this method will be called for ever non-root channel on that server).
 *
 * @param connection An object used to identify the current connection
 * @param channelID The ID of the channel that has been removed
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onChannelRemoved(mumble_connection_t connection,
																				   mumble_channelid_t channelID);

/**
 * Called when a channel gets renamed. This also applies when a new channel is created (thus assigning it an initial
 * name is also considered renaming).
 *
 * @param connection An object used to identify the current connection
 * @param channelID The ID of the channel that has been renamed
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onChannelRenamed(mumble_connection_t connection,
																				   mumble_channelid_t channelID);

/**
 * Called when a key has been pressed or released while Mumble has keyboard focus.
 * Note that this callback will only work if the user has explicitly given permission to monitor keyboard
 * events for this plugin. Thus if you want to use this callback, make sure your users know that they have to
 * enable that.
 *
 * @param keyCode The key code of the respective key. The character codes are defined
 * via the Mumble_KeyCode enum. For printable 7-bit ASCII characters these codes conform
 * to the ASCII code-page with the only difference that case is not distinguished. Therefore
 * always the upper-case letter code will be used for letters.
 * @param wasPres Whether the respective key has been pressed (instead of released)
 */
MUMBLE_PLUGIN_EXPORT void MUMBLE_PLUGIN_CALLING_CONVENTION mumble_onKeyEvent(uint32_t keyCode, bool wasPress);



// >>>>>>>>>>>>>>>>>>>> PLUGIN UPDATE functions <<<<<<<<<<<<<<<<<<<<

/**
 * This function is used to determine whether the plugin can find an update for itself that is available for download.
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @return Whether the plugin was able to find an update for itself
 */
MUMBLE_PLUGIN_EXPORT bool MUMBLE_PLUGIN_CALLING_CONVENTION mumble_hasUpdate();

/**
 * This function is used to retrieve the URL for downloading the newer/updated version of this plugin.
 *
 * NOTE: This function may be called without the plugin being loaded
 *
 * @returns A String-wrapper containing the requested URL
 */
MUMBLE_PLUGIN_EXPORT struct MumbleStringWrapper MUMBLE_PLUGIN_CALLING_CONVENTION mumble_getUpdateDownloadURL();



// >>>>>>>>>>>>>>>>>>>> DEFAULT functions <<<<<<<<<<<<<<<<<<<<
// These functions don't have to be implemented by you

/**
 * Gets the version of the plugin functions interface that this plugin uses or wants to use.
 * Based on this, Mumble will decide what kind of functions to look for and load from your plugin.
 */
MUMBLE_PLUGIN_EXPORT mumble_version_t mumble_getPluginFunctionsVersion();

MUMBLE_EXTERN_C_END
#endif // EXTERNAL_MUMBLE_PLUGIN_FUNCTIONS_


///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// DEFAULT IMPLEMENTATIONS /////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef EXTERNAL_MUMBLE_PLUGIN_DEFAULT_IMPLEMENTATIONS_
#	define EXTERNAL_MUMBLE_PLUGIN_DEFAULT_IMPLEMENTATIONS_

mumble_version_t mumble_getPluginFunctionsVersion() {
	return MUMBLE_PLUGIN_FUNCTIONS_VERSION;
}

#endif // EXTERNAL_MUMBLE_PLUGIN_DEFAULT_IMPLEMENTATIONS_



///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// Mumble API ///////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef EXTERNAL_MUMBLE_PLUGIN_MUMBLE_API_
#	define EXTERNAL_MUMBLE_PLUGIN_MUMBLE_API_

// Define a struct name that contains the respective version number
#	undef MUMBLE_API_STRUCT_NAME
#	define MUMBLE_API_STRUCT_NAME                                                                                     \
		MUMBLE_ECONCAT(                                                                                                \
			MUMBLE_ECONCAT(MUMBLE_ECONCAT(MumbleAPI_v, MUMBLE_PLUGIN_API_MAJOR_MACRO), MUMBLE_PLUGIN_API_MINOR_MACRO), \
			x)

#	undef MUMBLE_API_CAST
#	define MUMBLE_API_CAST(ptr) (*((MUMBLE_API_STRUCT_NAME *) ptr))

// Define some helper macros to make version-specific changes to the API functions
#	define SELECTED_API_VERSION                                                                  \
		MUMBLE_PLUGIN_VERSION_CHECK(MUMBLE_PLUGIN_API_MAJOR_MACRO, MUMBLE_PLUGIN_API_MINOR_MACRO, \
									MUMBLE_PLUGIN_API_PATCH_MACRO)
#	if SELECTED_API_VERSION >= MUMBLE_PLUGIN_VERSION_CHECK(1, 2, 0)
#		define PARAM_v1_2(arg) , arg
#	else
#		define PARAM_v1_2(arg)
#	endif

struct MUMBLE_API_STRUCT_NAME {
	/*
	 * GENERAL NOTES
	 *
	 * All functions that take in a connection as a parameter may only be called **after** the connection
	 * has finished synchronizing. The only exception from this is isConnectionSynchronized.
	 *
	 * Strings returned by the API are UTF-8 encoded
	 * Strings passed to the API are expected to be UTF-8 encoded
	 *
	 * All API functions are synchronized and will be executed in Mumble's "main thread" from which most plugin
	 * callbacks are called as well. Note however that an API call is BLOCKING if invoked from a different
	 * thread. This means that they can cause deadlocks if used without caution. An example that will lead
	 * to a deadlock is:
	 * - plugin callback gets called from the main thread
	 * - callback messages a separate thread to do something and waits for the action to have completed
	 * - Separate thread calls an API function
	 * - The function blocks and waits to be executed in the main thread which is currently blocked waiting
	 * - deadlock
	 */


	// -------- Memory management --------

	/**
	 * Frees the given pointer.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param pointer The pointer to free
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *freeMemory)(mumble_plugin_id_t callerID, const void *pointer);



	// -------- Getter functions --------

	/**
	 * Gets the connection ID of the server the user is currently active on (the user's audio output is directed at).
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param[out] connection A pointer to the memory location the ID should be written to
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then it is valid to access
	 * the value of the provided pointer
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getActiveServerConnection)(mumble_plugin_id_t callerID,
																				mumble_connection_t *connection);

	/**
	 * Checks whether the given connection has finished initializing yet.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param[out] A pointer to the boolean variable that'll hold the info whether the server has finished
	 * synchronization yet after this function has executed successfully.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *isConnectionSynchronized)(mumble_plugin_id_t callerID,
																			   mumble_connection_t connection,
																			   bool *synchronized);

	/**
	 * Fills in the information about the local user.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param[out] userID A pointer to the memory the user's ID shall be written to
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getLocalUserID)(mumble_plugin_id_t callerID,
																	 mumble_connection_t connection,
																	 mumble_userid_t *userID);

	/**
	 * Fills in the information about the given user's name.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param userID The user's ID whose name should be obtained
	 * @param[out] userName A pointer to where the pointer to the allocated string (C-encoded) should be written to.
	 * The allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be
	 * allocated if this function returns STATUS_OK.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getUserName)(mumble_plugin_id_t callerID,
																  mumble_connection_t connection,
																  mumble_userid_t userID, const char **userName);

	/**
	 * Fills in the information about the given channel's name.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param channelID The channel's ID whose name should be obtained
	 * @param[out] channelName A pointer to where the pointer to the allocated string (C-ecoded) should be written to.
	 * The allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be
	 * allocated if this function returns STATUS_OK.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getChannelName)(mumble_plugin_id_t callerID,
																	 mumble_connection_t connection,
																	 mumble_channelid_t channelID,
																	 const char **channelName);

	/**
	 * Gets an array of all users that are currently connected to the provided server. Passing a nullptr as any of the
	 * out-parameter will prevent that property to be set/allocated. If you are only interested in the user count you
	 * can thus pass nullptr as the users parameter and save time on allocating + freeing the channels-array while
	 * still getting the size out.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param[out] users A pointer to where the pointer of the allocated array shall be written. The
	 * allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be
	 * allocated if this function returns STATUS_OK.
	 * @param[out] userCount A pointer to where the size of the allocated user-array shall be written to
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getAllUsers)(mumble_plugin_id_t callerID,
																  mumble_connection_t connection,
																  mumble_userid_t **users, size_t *userCount);

	/**
	 * Gets an array of all channels on the provided server. Passing a nullptr as any of the out-parameter will prevent
	 * that property to be set/allocated. If you are only interested in the channel count you can thus pass nullptr as
	 * the channels parameter and save time on allocating + freeing the channels-array while still getting the size
	 * out.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param[out] channels A pointer to where the pointer of the allocated array shall be written. The
	 * allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be
	 * allocated if this function returns STATUS_OK.
	 * @param[out] channelCount A pointer to where the size of the allocated channel-array shall be written to
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getAllChannels)(mumble_plugin_id_t callerID,
																	 mumble_connection_t connection,
																	 mumble_channelid_t **channels,
																	 size_t *channelCount);

	/**
	 * Gets the ID of the channel the given user is currently connected to.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param userID The ID of the user to search for
	 * @param[out] A pointer to where the ID of the channel shall be written
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getChannelOfUser)(mumble_plugin_id_t callerID,
																	   mumble_connection_t connection,
																	   mumble_userid_t userID,
																	   mumble_channelid_t *channel);

	/**
	 * Gets an array of all users in the specified channel.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param channelID The ID of the channel whose users shall be retrieved
	 * @param[out] userList A pointer to where the pointer of the allocated array shall be written. The allocated
	 * memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be allocated if
	 * this function returns STATUS_OK.
	 * @param[out] userCount A pointer to where the size of the allocated user-array shall be written to
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getUsersInChannel)(mumble_plugin_id_t callerID,
																		mumble_connection_t connection,
																		mumble_channelid_t channelID,
																		mumble_userid_t **userList, size_t *userCount);

	/**
	 * Gets the current transmission mode of the local user.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param[out] transmissionMode A pointer to where the transmission mode shall be written.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getLocalUserTransmissionMode)(
		mumble_plugin_id_t callerID, mumble_transmission_mode_t *transmissionMode);

	/**
	 * Checks whether the given user is currently locally muted.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param userID The ID of the user to check for
	 * @param[out] muted A pointer to where the local mute state of that user shall be written
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *isUserLocallyMuted)(mumble_plugin_id_t callerID,
																		 mumble_connection_t connection,
																		 mumble_userid_t userID, bool *muted);

	/**
	 * Checks whether the local user is currently muted.
	 *	/// @param callerID The ID of the plugin calling this function
	 * @param[out] muted A pointer to where the mute state of the local user shall be written
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *isLocalUserMuted)(mumble_plugin_id_t callerID, bool *muted);

	/**
	 * Checks whether the local user is currently deafened.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param[out] deafened A pointer to where the deaf state of the local user shall be written
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *isLocalUserDeafened)(mumble_plugin_id_t callerID, bool *deafened);

	/**
	 * Gets the hash of the given user (can be used to recognize users between restarts)
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param userID The ID of the user to search for
	 * @param[out] hash A pointer to where the pointer to the allocated string (C-encoded) should be written to. The
	 * allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be
	 * allocated if this function returns STATUS_OK.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getUserHash)(mumble_plugin_id_t callerID,
																  mumble_connection_t connection,
																  mumble_userid_t userID, const char **hash);

	/**
	 * Gets the hash of the server for the given connection (can be used to recognize servers between restarts)
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection
	 * @param[out] hash A pointer to where the pointer to the allocated string (C-encoded) should be written to. The
	 * allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be
	 * allocated if this function returns STATUS_OK.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getServerHash)(mumble_plugin_id_t callerID,
																	mumble_connection_t connection, const char **hash);

	/**
	 * Gets the comment of the given user. Note that a user might have a comment configured that hasn't been
	 * synchronized to this client yet. In this case this function will return EC_UNSYNCHRONIZED_BLOB. As of now there
	 * is now way to request the synchronization to happen via the Plugin-API.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection
	 * @param userID the ID of the user whose comment should be obtained
	 * @param[out] comment A pointer to where the pointer to the allocated string (C-encoded) should be written to. The
	 * allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be
	 * allocated if this function returns STATUS_OK.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getUserComment)(mumble_plugin_id_t callerID,
																	 mumble_connection_t connection,
																	 mumble_userid_t userID, const char **comment);

	/**
	 * Gets the description of the given channel. Note that a channel might have a description configured that hasn't
	 * been synchronized to this client yet. In this case this function will return EC_UNSYNCHRONIZED_BLOB. As of now
	 * there is now way to request the synchronization to happen via the Plugin-API.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection
	 * @param channelID the ID of the channel whose comment should be obtained
	 * @param[out] description A pointer to where the pointer to the allocated string (C-encoded) should be written to.
	 * The allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will only be
	 * allocated if this function returns STATUS_OK.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getChannelDescription)(mumble_plugin_id_t callerID,
																			mumble_connection_t connection,
																			mumble_channelid_t channelID,
																			const char **description);


	// -------- Request functions --------

	/**
	 * Requests Mumble to set the local user's transmission mode to the specified one. If you only need to temporarily
	 * set the transmission mode to continous, use requestMicrophoneActivationOverwrite instead as this saves you the
	 * work of restoring the previous state afterwards.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param transmissionMode The requested transmission mode
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestLocalUserTransmissionMode)(
		mumble_plugin_id_t callerID, mumble_transmission_mode_t transmissionMode);

	/**
	 * Requests Mumble to move the given user into the given channel
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param userID The ID of the user that shall be moved
	 * @param channelID The ID of the channel to move the user to
	 * @param password The password of the target channel (UTF-8 encoded as a C-string). Pass NULL if the target
	 * channel does not require a password for entering
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestUserMove)(mumble_plugin_id_t callerID,
																	  mumble_connection_t connection,
																	  mumble_userid_t userID,
																	  mumble_channelid_t channelID,
																	  const char *password);

	/**
	 * Requests Mumble to overwrite the microphone activation so that the microphone is always on (same as if the user
	 * had chosen the continous transmission mode). If a plugin requests this overwrite, it is responsible for
	 * deactivating the overwrite again once it is no longer required
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param activate Whether to activate the overwrite (false deactivates an existing overwrite)
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestMicrophoneActivationOvewrite)(mumble_plugin_id_t callerID,
																						  bool activate);

	/**
	 * Requests Mumble to set the local mute state of the given client. Note that this only affects the **local** mute
	 * state opposed to a server-mute (client is globally muted by the server) or the client's own mute-state (client
	 * has muted its microphone and thus isn't transmitting any audio). Furthermore it must be noted that muting the
	 * local user with this function does not work (it doesn't make sense). If you try to do so, this function will
	 * fail. In order to make this work, this function will also fail if the server has not finished synchronizing with
	 * the client yet. For muting the local user, use requestLocalUserMute instead.
	 *
	 * @param callerID The ID of the plugin calling this function.
	 * @param connection The ID of the server-connection to use as a context
	 * @param userID The ID of the user that shall be muted
	 * @param muted Whether to locally mute the given client (opposed to unmuting it)
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestLocalMute)(mumble_plugin_id_t callerID,
																	   mumble_connection_t connection,
																	   mumble_userid_t userID, bool muted);

	/**
	 * Requests Mumble to set the mute state of the local user. In the UI this is referred to as "self-mute".
	 *
	 * @param callerID The ID of the plugin calling this function.
	 * @param muted Whether to locally mute the local user (opposed to unmuting it)
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestLocalUserMute)(mumble_plugin_id_t callerID, bool muted);

	/**
	 * Requests Mumble to set the deaf state of the local user. In the UI this is referred to as "self-deaf".
	 *
	 * @param callerID The ID of the plugin calling this function.
	 * @param deafened Whether to locally deafen the local user (opposed to undeafening it)
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestLocalUserDeaf)(mumble_plugin_id_t callerID, bool deafened);

	/**
	 * Sets the comment of the local user
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection
	 * @param comment The new comment to use (C-encoded). A subset of HTML formatting is supported.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer
	 * may be accessed
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *requestSetLocalUserComment)(mumble_plugin_id_t callerID,
																				 mumble_connection_t connection,
																				 const char *comment);



	// -------- Find functions --------

	/**
	 * Fills in the information about a user with the specified name, if such a user exists. The search is
	 * case-sensitive.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param userName The respective user's name
	 * @param[out] userID A pointer to the memory the user's ID shall be written to
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may
	 * be accessed.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *findUserByName)(mumble_plugin_id_t callerID,
																	 mumble_connection_t connection,
																	 const char *userName, mumble_userid_t *userID);

	/**
	 * Fills in the information about a channel with the specified name, if such a channel exists. The search is
	 * case-sensitive.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to use as a context
	 * @param channelName The respective channel's name
	 * @param[out] channelID A pointer to the memory the channel's ID shall be written to
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may
	 * be accessed.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *findChannelByName)(mumble_plugin_id_t callerID,
																		mumble_connection_t connection,
																		const char *channelName,
																		mumble_channelid_t *channelID);



	// -------- Settings --------

	/**
	 * Fills in the current value of the setting with the given key. Note that this function can only be used for
	 * settings whose value is a bool!
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param key The key to the desired setting
	 * @param[out] outValue A pointer to the memory the setting's value shall be written to.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may
	 * be accessed.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getMumbleSetting_bool)(mumble_plugin_id_t callerID,
																			mumble_settings_key_t key, bool *outValue);

	/**
	 * Fills in the current value of the setting with the given key. Note that this function can only be used for
	 * settings whose value is an int!
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param key The key to the desired setting
	 * @param[out] outValue A pointer to the memory the setting's value shall be written to.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may
	 * be accessed.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getMumbleSetting_int)(mumble_plugin_id_t callerID,
																		   mumble_settings_key_t key,
																		   int64_t *outValue);

	/**
	 * Fills in the current value of the setting with the given key. Note that this function can only be used for
	 * settings whose value is a double!
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param key The key to the desired setting
	 * @param[out] outValue A pointer to the memory the setting's value shall be written to.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may
	 * be accessed.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getMumbleSetting_double)(mumble_plugin_id_t callerID,
																			  mumble_settings_key_t key,
																			  double *outValue);

	/**
	 * Fills in the current value of the setting with the given key. Note that this function can only be used for
	 * settings whose value is a String!
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param key The key to the desired setting
	 * @param[out] outValue The memory address to which the pointer to the setting's value (the String) will be
	 * written. The allocated memory has to be freed by a call to freeMemory by the plugin eventually. The memory will
	 * only be allocated if this function returns STATUS_OK.
	 * @returns The error code. If everything went well, STATUS_OK will be returned. Only then the passed pointer may
	 * be accessed.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *getMumbleSetting_string)(mumble_plugin_id_t callerID,
																			  mumble_settings_key_t key,
																			  const char **outValue);


	/**
	 * Sets the value of the setting with the given key. Note that this function can only be used for settings whose
	 * value is a bool!
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param key The key to the desired setting
	 * @param value The value that should be set for the given setting
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *setMumbleSetting_bool)(mumble_plugin_id_t callerID,
																			mumble_settings_key_t key, bool value);

	/**
	 * Sets the value of the setting with the given key. Note that this function can only be used for settings whose
	 * value is an int!
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param key The key to the desired setting
	 * @param value The value that should be set for the given setting
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *setMumbleSetting_int)(mumble_plugin_id_t callerID,
																		   mumble_settings_key_t key, int64_t value);

	/**
	 * Sets the value of the setting with the given key. Note that this function can only be used for settings whose
	 * value is a double!
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param key The key to the desired setting
	 * @param value The value that should be set for the given setting
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *setMumbleSetting_double)(mumble_plugin_id_t callerID,
																			  mumble_settings_key_t key, double value);

	/**
	 * Sets the value of the setting with the given key. Note that this function can only be used for settings whose
	 * value is a string!
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param key The key to the desired setting
	 * @param value The value that should be set for the given setting
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *setMumbleSetting_string)(mumble_plugin_id_t callerID,
																			  mumble_settings_key_t key,
																			  const char *value);



	// -------- Miscellaneous --------

	/**
	 * Sends the provided data to the provided client(s). This kind of data can only be received by another plugin
	 * active on that client. The sent data can be seen by any active plugin on the receiving client. Therefore the
	 * sent data must not contain sensitive information or anything else that shouldn't be known by others.
	 *
	 * NOTE: Messages sent via this API function are rate-limited by the server. If the rate-limit is hit, the message
	 * will be dropped without an error message. The rate-limiting is global (e.g. it doesn't matter which plugin sent
	 * the respective messages - they all count to the same limit).
	 * Therefore if you have multiple messages to send, you should consider sending them asynchronously one at a time
	 * with a little delay in between (~1 second).
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param connection The ID of the server-connection to send the data through (the server the given users are on)
	 * @param users An array of user IDs to send the data to
	 * @param userCount The size of the provided user-array
	 * @param data The data array that shall be sent. This can be an arbitrary sequence of bytes. Note that the size of
	 * is restricted to <= 1KB.
	 * @param dataLength The length of the data array
	 * @param dataID The ID of the sent data. This has to be used by the receiving plugin(s) to figure out what to do
	 * with the data. This has to be a C-encoded String. It is recommended that the ID starts with a plugin-specific
	 * prefix in order to avoid name clashes. Note that the size of this string is restricted to <= 100 bytes.
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *sendData)(mumble_plugin_id_t callerID,
															   mumble_connection_t connection,
															   const mumble_userid_t *users, size_t userCount,
															   const uint8_t *data, size_t dataLength,
															   const char *dataID);

	/**
	 * Logs the given message (typically to Mumble's console). All passed strings have to be UTF-8 encoded.
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param message The message to log
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *log)(mumble_plugin_id_t callerID, const char *message);

	/**
	 * Plays the provided sample. It uses libsndfile as a backend so the respective file format needs to be supported
	 * by it in order for this to work out (see http://www.mega-nerd.com/libsndfile/).
	 *
	 * @param callerID The ID of the plugin calling this function
	 * @param samplePath The path to the sample that shall be played (UTF-8 encoded)
	 * @param volume The volume multiplier used when playing the sample (for no change use 1.0f)
	 * @returns The error code. If everything went well, STATUS_OK will be returned.
	 */
	mumble_error_t(MUMBLE_PLUGIN_CALLING_CONVENTION *playSample)(mumble_plugin_id_t callerID,
																 const char *samplePath PARAM_v1_2(float volume));
};

#	ifdef MUMBLE_PLUGIN_CREATE_MUMBLE_API_TYPEDEF
/**
 * Typedef for the Mumble API struct for convenient (unversioned) access
 */
typedef struct MUMBLE_API_STRUCT_NAME MumbleAPI;
typedef struct MUMBLE_API_STRUCT_NAME mumble_api_t;
#	endif

#	undef SELECTED_API_VERSION
#	undef PARAM_v1_2

#endif // EXTERNAL_MUMBLE_PLUGIN_MUMBLE_API_