forked from BearWare/TeamTalk5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TeamTalk.cs
9298 lines (8880 loc) · 426 KB
/
TeamTalk.cs
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
/*
* Copyright (c) 2005-2018, BearWare.dk
*
* Contact Information:
*
* Bjoern D. Rasmussen
* Kirketoften 5
* DK-8260 Viby J
* Denmark
* Email: [email protected]
* Phone: +45 20 20 54 59
* Web: http://www.bearware.dk
*
* This source code is part of the TeamTalk SDK owned by
* BearWare.dk. Use of this file, or its compiled unit, requires a
* TeamTalk SDK License Key issued by BearWare.dk.
*
* The TeamTalk SDK License Agreement along with its Terms and
* Conditions are outlined in the file License.txt included with the
* TeamTalk SDK distribution.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using c_tt;
namespace BearWare
{
/** @addtogroup transmission
* @{ */
/** @brief The types of streams which are available for
* transmission. */
[Flags]
public enum StreamType : uint
{
/** @brief No stream. */
STREAMTYPE_NONE = 0x00000000,
/** @brief Voice stream type which is audio recorded from a
* sound input device. @see TeamTalkBase.InitSoundInputDevice() */
STREAMTYPE_VOICE = 0x00000001,
/** @brief Video capture stream type which is video recorded
* from a webcam. @see TeamTalkBase.InitVideoCaptureDevice() */
STREAMTYPE_VIDEOCAPTURE = 0x00000002,
/** @brief Audio stream type from a media file which is being
* streamed. @see TeamTalkBase.StartStreamingMediaFileToChannel() */
STREAMTYPE_MEDIAFILE_AUDIO = 0x00000004,
/** @brief Video stream type from a media file which is being
* streamed. @see TeamTalkBase.StartStreamingMediaFileToChannel() */
STREAMTYPE_MEDIAFILE_VIDEO = 0x00000008,
/** @brief Desktop window stream type which is a window (or
* bitmap) being transmitted. @see TeamTalkBase.SendDesktopWindow() */
STREAMTYPE_DESKTOP = 0x00000010,
/** @brief Desktop input stream type which is keyboard or
* mouse input being transmitted. @see
* TeamTalkBase.SendDesktopInput() */
STREAMTYPE_DESKTOPINPUT = 0x00000020,
/** @brief Shortcut to allow both audio and video media files. */
STREAMTYPE_MEDIAFILE = STREAMTYPE_MEDIAFILE_AUDIO |
STREAMTYPE_MEDIAFILE_VIDEO,
/** @brief Channel text messages as stream type.
*
* A channel text message is not a stream but is only included
* as a stream type in order to be able to block messages
* using @c transmitUsers in #BearWare.Channel struct.
*
* @see TeamTalkBase.DoUpdateChannel()
* @see ChannelType.CHANNEL_CLASSROOM. */
STREAMTYPE_CHANNELMSG = 0x00000040,
/** @brief Stream type for audio of local playback.
*
* TeamTalkBase.EnableAudioBlockEvent() can be used to intercept audio
* from a local media playback.
* @see TeamTalkBase.InitLocalPlayback() */
STREAMTYPE_LOCALMEDIAPLAYBACK_AUDIO = 0x00000080,
/** @brief Shortcut to allow voice, media files, desktop,
* webcamera and channel messages. */
STREAMTYPE_CLASSROOM_ALL = STREAMTYPE_VOICE |
STREAMTYPE_VIDEOCAPTURE |
STREAMTYPE_DESKTOP |
STREAMTYPE_MEDIAFILE |
STREAMTYPE_CHANNELMSG,
}
/** @} */
/** @addtogroup sounddevices
* @{ */
/**
* @brief The supported sound systems.
*
* @see SoundDevice
* @see TeamTalkBase.InitSoundInputDevice()
* @see TeamTalkBase.InitSoundOutputDevice()
* @see TeamTalkBase.InitSoundDuplexDevices() */
public enum SoundSystem : uint
{
/** @brief Sound system denoting invalid or not found. */
SOUNDSYSTEM_NONE = 0,
/** @brief Windows legacy audio system. Should be used on Windows Mobile. */
SOUNDSYSTEM_WINMM = 1,
/** @brief DirectSound audio system. Should be used on Windows. */
SOUNDSYSTEM_DSOUND = 2,
/**
* @brief Advanced Linux Sound Architecture (ALSA). Should be used on Linux.
*
* Often ALSA sound devices only support a limited number of
* sample rates so TeamTalk internally use software filters to
* resample the audio to the sample rate used by the selected
* audio codecs. */
SOUNDSYSTEM_ALSA = 3,
/** @brief Core Audio. Should be used on MacOS. */
SOUNDSYSTEM_COREAUDIO = 4,
/** @brief Windows Audio Session API (WASAPI). Should be used
* on Windows Vista/7/8/10.
*
* WASAPI audio devices typically only support a single sample
* rate so internally TeamTalk uses software filters to
* resample audio to the sample rate used by the selected
* audio codecs.
*
* Check @c supportedSampleRates and @c nDefaultSampleRate of
* #BearWare.SoundDevice to see which sample rates are supported. */
SOUNDSYSTEM_WASAPI = 5,
/** @brief Android sound API. */
SOUNDSYSTEM_OPENSLES_ANDROID = 7,
/** @brief iOS sound API.
*
* The following sound devices will appear when calling
* TeamTalkBase.GetSoundDevices(). Sound device ID 0 will be AudioUnit
* subtype Remote I/O Unit and sound device ID 1 will be
* AudioUnit subtype Voice-Processing I/O Unit.
*
* Note that iOS only supports one active Voice-Processing I/O
* Unit, i.e. only one #BearWare.TeamTalkBase instance can use the
* Voice-Processing I/O Unit.
*
* Add libraries @c AVFoundation.framework and
* @c AudioToolbox.framework.
*
* Duplex mode is not supported by AudioUnit iOS sound API. */
SOUNDSYSTEM_AUDIOUNIT = 8,
/** @brief Same as #BearWare.SoundSystem.SOUNDSYSTEM_AUDIOUNIT. */
SOUNDSYSTEM_AUDIOUNIT_IOS = SOUNDSYSTEM_AUDIOUNIT,
/** @brief PulseAudio API.
* PulseAudio is typically used on Ubuntu 22. */
SOUNDSYSTEM_PULSEAUDIO = 10,
}
/**
* @brief Features available on a sound device.
* Checkout @c uSoundDeviceFeatures on #BearWare.SoundDevice.
* */
[Flags]
public enum SoundDeviceFeature : uint
{
SOUNDDEVICEFEATURE_NONE = 0x0000,
/** @brief The #BearWare.SoundDevice can enable Acoustic
* Echo Canceler (AEC).
* Enable AEC use property @c bEnableAEC on
* #BearWare.SoundDeviceEffects.
* @see TeamTalkBase.SetSoundDeviceEffects() */
SOUNDDEVICEFEATURE_AEC = 0x0001,
/** @brief The #BearWare.SoundDevice can enable Automatic
* Gain Control (AGC).
* Enable AGC use property @c bEnableAGC on
* #BearWare.SoundDeviceEffects.
* @see TeamTalkBase.SetSoundDeviceEffects() */
SOUNDDEVICEFEATURE_AGC = 0x0002,
/** @brief The #BearWare.SoundDevice can enable denoising.
* Enable denoising use property @c bEnableDenoising on
* #BearWare.SoundDeviceEffects.
* @see TeamTalkBase.SetSoundDeviceEffects() */
SOUNDDEVICEFEATURE_DENOISE = 0x0004,
/** @brief The #BearWare.SoundDevice can position user in 3D.
* @see TeamTalkBase.SetUserPosition() */
SOUNDDEVICEFEATURE_3DPOSITION = 0x0008,
/** @brief The #BearWare.SoundDevice can run in duplex mode.
* @see TeamTalkBase.InitSoundDuplexDevices() */
SOUNDDEVICEFEATURE_DUPLEXMODE = 0x0010,
/** @brief The #BearWare.SoundDevice is the default communication device.
* This feature is only supported on #BearWare.SoundSystem.SOUNDSYSTEM_WASAPI. */
SOUNDDEVICEFEATURE_DEFAULTCOMDEVICE = 0x0020,
}
/**
* @brief A struct containing the properties of a sound device
* for either playback or recording.
*
* Use @a nDeviceID to pass to TeamTalkBase.InitSoundInputDevice() or
* TeamTalkBase.InitSoundOutputDevice().
*
* Note that the @a nDeviceID may change if the user application
* is restarted and a new sound device is added or removed from
* the computer.
*
* @see TeamTalkBase.GetSoundDevices */
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SoundDevice
{
/** @brief The ID of the sound device. Used for passing to
* TeamTalkBase.InitSoundInputDevice() and
* TeamTalkBase.InitSoundOutputDevice(). Note that @a nDeviceID might change
* if USB sound devices are plugged in or unplugged, therefore
* use @a szDeviceID to ensure proper device is used. */
public int nDeviceID;
/** @brief The sound system used by the sound device. */
public SoundSystem nSoundSystem;
/** @brief The name of the sound device. */
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TeamTalkBase.TT_STRLEN)]
public string szDeviceName;
/** @brief An identifier uniquely identifying the sound device
* even when new sound devices are being added and removed. In
* DirectSound, WASAPI and WinMM it would be the GUID of the sound
* device. Note that it may not always be available. */
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TeamTalkBase.TT_STRLEN)]
public string szDeviceID;
/**
* @brief A Windows specific ID to the sound device.
*
* For DirectSound and WinMM this is the ID of the device used
* in Win32's waveInGetDevCaps and waveOutGetDevCaps.
* Value will be -1 if no ID could be found This ID can also
* be used to find the corresponding mixer on Windows passing
* it as @a nWaveDeviceID. Note that this ID applies both to
* DirectSound and WinMM.
*
* For WASAPI this ID is the index of
* IMMDeviceEnumerator::EnumAudioEndpoints()
*
* @see WindowsMixer.GetWaveInName
* @see WindowsMixer.GetWaveOutName
* @see WindowsMixer.GetMixerCount */
public int nWaveDeviceID;
/** @brief Whether the sound device supports 3D-sound
* effects. @deprecated Use #BearWare.SoundDeviceFeature.SOUNDDEVICEFEATURE_3DPOSITION. */
public bool bSupports3D;
/** @brief The maximum number of input channels. */
public int nMaxInputChannels;
/** @brief The maximum number of output channels. */
public int nMaxOutputChannels;
/** @brief Supported sample rates by device for recording. A
* zero value terminates the list of supported sample rates or
* its maximum size of #BearWare.TeamTalkBase.TT_SAMPLERATES_MAX. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TeamTalkBase.TT_SAMPLERATES_MAX)]
public int[] inputSampleRates;
/** @brief Supported sample rates by device for playback. A
* zero value terminates the list of supported sample rates or
* its maximum size of #BearWare.TeamTalkBase.TT_SAMPLERATES_MAX. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TeamTalkBase.TT_SAMPLERATES_MAX)]
public int[] outputSampleRates;
/** @brief The default sample rate for the sound device. */
public int nDefaultSampleRate;
/** @brief Additional features available for this sound
* device. The sound device features can be used to enable
* additional features on the sound device.
* @see SoundDeviceFeature
* @see TeamTalkBase.SetSoundDeviceEffects() */
public SoundDeviceFeature uSoundDeviceFeatures;
}
/**
* @brief Set up audio effects supported by the sound device.
*
* The effects supported by a sound device are listed in the @c
* uSoundDeviceFeatures property of #BearWare.SoundDevice.
*
* To apply audio effects on a sound device call
* TeamTalkBase.SetSoundDeviceEffects() */
public struct SoundDeviceEffects
{
/**
* @brief Enable Automatic Gain Control.
*
* This effect can be enabled on a #BearWare.SoundDevice that has
* #BearWare.SoundDeviceFeature.SOUNDDEVICEFEATURE_AGC flag in @c uSoundDeviceFeatures.
*
* Supported platforms:
* - Windows
* - Automatic gain control is per #BearWare.TeamTalkBase instance.
* - #BearWare.TeamTalkBase instance must initialize sound devices using
* TeamTalkBase.InitSoundDuplexDevices()
* - Android
* - Automatic gain control will be applied on all active
* #BearWare.TeamTalkBase instances.
* @see SoundDeviceFeature.SOUNDDEVICEFEATURE_AGC */
public bool bEnableAGC;
/**
* @brief Enable noise suppression.
*
* This effect can be enabled on a #BearWare.SoundDevice that has
* #BearWare.SoundDeviceFeature.SOUNDDEVICEFEATURE_DENOISE flag in @c
* uSoundDeviceFeatures.
*
* Supported platforms:
* - Windows
* - Noise suppression is per TeamTalkBase instance.
* - #BearWare.TeamTalkBase instance must initialize sound devices using
* TeamTalkBase.InitSoundDuplexDevices()
* - Android
* - Noise suppression will be applied on all active
* #BearWare.TeamTalkBase instance.
* @see SoundDeviceFeature.SOUNDDEVICEFEATURE_DENOISE */
public bool bEnableDenoise;
/**
* @brief Enable echo cancellation.
*
* This effect can be enabled on a #BearWare.SoundDevice that has
* #BearWare.SoundDeviceFeature.SOUNDDEVICEFEATURE_AEC flag in @c uSoundDeviceFeatures.
*
* Supported platforms:
* - Windows
* - Echo cancellation is per TeamTalkBase instance.
* - #BearWare.TeamTalkBase instance must initialize sound devices using
* TeamTalkBase.InitSoundDuplexDevices()
* - Android
* - Echo cancellation will be applied on all active
* #BearWare.TeamTalkBase instance.
* @see SoundDeviceFeature.SOUNDDEVICEFEATURE_AEC */
public bool bEnableEchoCancellation;
}
/**
* @brief IDs for sound devices. */
public struct SoundDeviceConstants
{
/** @brief Sound device ID for iOS AudioUnit subtype Remote I/O
* Unit. @see SOUNDSYSTEM_AUDIOUNIT */
public const int TT_SOUNDDEVICE_ID_REMOTEIO = 0;
/** @brief Sound device ID for iOS AudioUnit subtype Voice-Processing
* I/O Unit.
* This sound device ID include the flag
* #BearWare.SoundDeviceConstants.TT_SOUNDDEVICE_ID_SHARED_FLAG since multiple streams cannot be
* recorded/played on the device. @see SoundSystem.SOUNDSYSTEM_AUDIOUNIT */
public const int TT_SOUNDDEVICE_ID_VOICEPREPROCESSINGIO = (1 | (int)TT_SOUNDDEVICE_ID_SHARED_FLAG);
/** @brief Sound device ID for Android OpenSL ES default audio
* device. Note that this sound device may also exist in the form
* where the @c nDeviceID as been or'ed with
* #BearWare.SoundDeviceConstants.TT_SOUNDDEVICE_ID_SHARED_FLAG. @see SOUNDSYSTEM_OPENSLES_ANDROID */
public const int TT_SOUNDDEVICE_ID_OPENSLES_DEFAULT = 0;
/** @brief Sound device ID for Android OpenSL ES voice communication
* mode. This device uses the OpenSL ES' AndroidConfiguration @c
* SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION @see
* SoundSystem.SOUNDSYSTEM_OPENSLES_ANDROID */
public const int TT_SOUNDDEVICE_ID_OPENSLES_VOICECOM = 1;
/** @brief Sound device ID for virtual TeamTalk sound device.
*
* This is a sound device which decodes received audio packets but
* does not send the decoded audio to a real sound device. When used
* for recording the virtual sound device injects silence.
*
* In duplex mode the virtual TeamTalk sound device can only
* be used as input/output device. @see SOUNDSYSTEM_NONE */
public const int TT_SOUNDDEVICE_ID_TEAMTALK_VIRTUAL = 1978;
/** @brief Flag/bit in @c nDeviceID telling if the #BearWare.SoundDevice is a
* shared version of an existing sound device.
*
* On Android the recording device can only be used by one TeamTalk
* instance. As a workaround for this issue a shared recording device
* has been introduced. Internally TeamTalk initializes
* #BearWare.SoundDeviceConstants.TT_SOUNDDEVICE_ID_OPENSLES_DEFAULT which then resample and
* distribution the audio data to multiple TeamTalk instances.
*
* The shared audio device on Android will show up as
* (TT_SOUNDDEVICE_ID_OPENSLES_DEFAULT | TT_SOUNDDEVICE_ID_SHARED_FLAG),
* i.e. 2048.
*/
public const uint TT_SOUNDDEVICE_ID_SHARED_FLAG = 0x00000800;
/** @brief Extract sound device ID of @c nDeviceID in #BearWare.SoundDevice by
* and'ing this value.
*
* let PhysicalDeviceID = (SoundDevice.nDeviceID & TT_SOUNDDEVICE_ID_MASK). */
public const uint TT_SOUNDDEVICE_ID_MASK = 0x000007FF;
}
/**
* @brief An enum encapsulation the minimum, maximum and default sound
* levels for input and output sound devices. */
public struct SoundLevel
{
/**
* @brief The maximum value of recorded audio.
* @see TeamTalkBase.GetSoundInputLevel
* @see TeamTalkBase.SetVoiceActivationLevel
* @see TeamTalkBase.GetVoiceActivationLevel */
public const int SOUND_VU_MAX = 100;
/**
* @brief The minimum value of recorded audio.
* @see TeamTalkBase.GetSoundInputLevel
* @see TeamTalkBase.SetVoiceActivationLevel
* @see TeamTalkBase.GetVoiceActivationLevel */
public const int SOUND_VU_MIN = 0;
/**
* @brief The maximum volume.
*
* @see BearWare.TeamTalkBase.SetSoundOutputVolume
* @see BearWare.TeamTalkBase.GetSoundOutputVolume
* @see BearWare.TeamTalkBase.SetUserVolume
* @see SOUND_VOLUME_DEFAULT */
public const int SOUND_VOLUME_MAX = 32000;
/**
* @brief The default volume. Use this whenever possible since
* it requires the least amount of CPU usage.
*
* @see BearWare.TeamTalkBase.SetSoundOutputVolume
* @see BearWare.TeamTalkBase.GetSoundOutputVolume
* @see BearWare.TeamTalkBase.SetUserVolume */
public const int SOUND_VOLUME_DEFAULT = 1000;
/**
* @brief The minimum volume.
* @see BearWare.TeamTalkBase.SetSoundOutputVolume
* @see BearWare.TeamTalkBase.GetSoundOutputVolume
* @see BearWare.TeamTalkBase.SetUserVolume */
public const int SOUND_VOLUME_MIN = 0;
/**
* @brief The maximum gain level.
*
* A gain level of 32000 gains the volume by a factor 32. A gain
* level of #BearWare.SoundLevel.SOUND_GAIN_DEFAULT means no gain.
*
* @see BearWare.TeamTalkBase.SetSoundInputGainLevel
* @see BearWare.TeamTalkBase.GetSoundInputGainLevel */
public const int SOUND_GAIN_MAX = 32000;
/**
* @brief The default gain level.
*
* A gain level of 1000 means no gain. Check #BearWare.SoundLevel.SOUND_GAIN_MAX
* and #BearWare.SoundLevel.SOUND_GAIN_MIN to see how to increase and lower gain
* level.
*
* @see BearWare.TeamTalkBase.SetSoundInputGainLevel
* @see BearWare.TeamTalkBase.GetSoundInputGainLevel */
public const int SOUND_GAIN_DEFAULT = 1000;
/**
* @brief The minimum gain level (since it's zero it means
* silence).
*
* A gain level of 100 is 1/10 of the default volume.
*
* @see BearWare.TeamTalkBase.SetSoundInputGainLevel
* @see BearWare.TeamTalkBase.GetSoundInputGainLevel */
public const int SOUND_GAIN_MIN = 0;
}
/**
* @brief An audio block containing the raw audio from a user who
* was talking.
*
* To enable audio blocks first call TeamTalkBase.EnableAudioBlockEvent()
* then whenever new audio is played the event
* TeamTalkBase.OnUserAudioBlock() is generated. Use
* TeamTalkBase.AcquireUserAudioBlock() to retrieve the audio block.
*
* Note that each user is limited to 128 kbytes of audio data.
*
* @see TeamTalkBase.EnableAudioBlockEvent()
* @see TeamTalkBase.AcquireUserAudioBlock()
* @see TeamTalkBase.ReleaseUserAudioBlock() */
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AudioBlock
{
/** @brief The ID of the stream. The stream id changes every time
* the user enables a new transmission using TeamTalkBase.EnableVoiceTransmission()
* or through voice activation. */
public int nStreamID;
/** @brief The sample rate of the raw audio. */
public int nSampleRate;
/** @brief The number of channels used (1 for mono, 2 for stereo). */
public int nChannels;
/** @brief The raw audio in 16-bit integer format array. The
* size of the array in bytes is @c sizeof(short) * @c
* nSamples * @c nChannels. */
public System.IntPtr lpRawAudio;
/** @brief The number of samples in the raw audio array. */
public int nSamples;
/** @brief The index of the first sample in @c lpRawAudio. Its
* value will be a multiple of @c nSamples. The sample index
* can be used to detect overflows of the internal
* buffer. When a user initially starts talking the @c
* nSampleIndex will be 0 and while the user is talking @c
* nSampleIndex will be greater than 0. When the user stops
* talking @c nSampleIndex will be reset to 0 again. */
public uint uSampleIndex;
/** @brief The stream types used to generate the AudioBlock's
* raw audio.
*
* When retrieving audio that has been mixed together from
* multiple sources it can be useful to know what stream types
* were mixed together to generate the AudioBlock.
*
* If 'uStreamTypes' is #BearWare.StreamType.STREAMTYPE_NONE it means that silence
* was inserted. Silence is inserted if no audio was available
* for mixing or the duration from last audio packet was
* received and until @c nStoppedDelayVoice of #BearWare.User has
* expired. @see #BearWare.TeamTalkBase.TT_MUXED_USERID */
StreamType uStreamTypes;
}
/** @} */
/** @addtogroup mediastream
* @{ */
/**
* @brief Status of media file being written to disk.
* @see CLIENTEVENT_USER_RECORD_MEDIAFILE */
public enum MediaFileStatus : uint
{
MFS_CLOSED = 0,
/** @brief Error while processing media file. */
MFS_ERROR = 1,
/** @brief Started processing media file. */
MFS_STARTED = 2,
/** @brief Finished processing media file. */
MFS_FINISHED = 3,
/** @brief Aborted processing of media file. */
MFS_ABORTED = 4,
/** @brief Paused processing of media file. */
MFS_PAUSED = 5,
/** @brief Playing media file with updated @c uElapsedMSec of
* #BearWare.MediaFileInfo. */
MFS_PLAYING = 6
}
/**
* @brief Media file formats supported for muxed audio recordings.
* @see TeamTalkBase.StartRecordingMuxedAudioFile() */
public enum AudioFileFormat : uint
{
/** @brief Used to denote nothing selected. */
AFF_NONE = 0,
/** @brief Store audio in the same format as the #BearWare.Channel's
* configured audio codec.
*
* Audio is stored in OGG format. OGG format is supported by
* https://www.xiph.org/ogg and can be played using VLC media player
* http://www.videolan.org
*
* Requires TeamTalk version 5.2.0.4730.
* @see TeamTalkBase.SetUserMediaStorageDir()
* @see TeamTalkBase.StartRecordingMuxedAudioFile() */
AFF_CHANNELCODEC_FORMAT = 1,
/** @brief Store in PCM 16-bit wave format. */
AFF_WAVE_FORMAT = 2,
/** @brief Store in MP3-format. */
AFF_MP3_16KBIT_FORMAT = 3,
/** @see #BearWare.AudioFileFormat.AFF_MP3_16KBIT_FORMAT */
AFF_MP3_32KBIT_FORMAT = 4,
/** @see #BearWare.AudioFileFormat.AFF_MP3_16KBIT_FORMAT */
AFF_MP3_64KBIT_FORMAT = 5,
/** @see #BearWare.AudioFileFormat.AFF_MP3_16KBIT_FORMAT */
AFF_MP3_128KBIT_FORMAT = 6,
/** @see #BearWare.AudioFileFormat.AFF_MP3_16KBIT_FORMAT */
AFF_MP3_256KBIT_FORMAT = 7,
/** @see #BearWare.AudioFileFormat.AFF_MP3_16KBIT_FORMAT */
AFF_MP3_320KBIT_FORMAT = 8,
}
/**
* @brief Struct describing the audio format used by a
* media file.
*
* @see TeamTalkBase.GetMediaFileInfo()
* @see MediaFileInfo
*/
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AudioFormat
{
/** @brief The audio file format, e.g. wave or MP3. */
public AudioFileFormat nAudioFmt;
/** @brief Sample rate of media file. */
public int nSampleRate;
/** @brief Channels used by media file, mono = 1, stereo = 2. */
public int nChannels;
}
/** @} */
/** @addtogroup videocapture
* @{ */
/**
* @brief The picture format used by a capture device.
*
* @see VideoFormat
* @see VideoCaptureDevice */
public enum FourCC : uint
{
/** @brief Internal use to denote no supported formats. */
FOURCC_NONE = 0,
/** @brief Prefered image format with the lowest bandwidth
* usage. A 640x480 pixel image takes up 460.800 bytes. */
FOURCC_I420 = 100,
/** @brief Image format where a 640x480 pixel images takes up
* 614.400 bytes. */
FOURCC_YUY2 = 101,
/** @brief The image format with the highest bandwidth
* usage. A 640x480 pixel images takes up 1.228.880 bytes. */
FOURCC_RGB32 = 102
}
/**
* @brief A struct containing the properties of a video capture
* format.
*
* A struct for holding a supported video capture format by a
* #BearWare.VideoCaptureDevice. */
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VideoFormat
{
/** @brief The width in pixels of the video device supported
* video format. */
public int nWidth;
/** @brief The height in pixels of the video device supported
* video format. */
public int nHeight;
/** @brief The numerator of the video capture device's video
* format. Divinding @a nFPS_Numerator with @a
* nFPS_Denominator gives the frame-rate. */
public int nFPS_Numerator;
/** @brief The denominator of the video capture device's video
* format. Divinding @a nFPS_Numerator with @a
* nFPS_Denominator gives the frame-rate.*/
public int nFPS_Denominator;
/** @brief Picture format for capturing. */
public FourCC picFourCC;
}
/**
* @brief A RGB32 image where the pixels can be accessed directly
* in an allocated @a imageBuffer.
*
* Use TeamTalkBase.AcquireUserCaptureFrame() to acquire a user's image and
* remember to call TeamTalkBase.ReleaseUserCaptureFrame() when the image has
* been processed so TeamTalk can release its resources. */
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VideoFrame
{
/** @brief The width in pixels of the image contained in @a
* frameBuffer. */
public int nWidth;
/** @brief The height in pixels of the image contained in @a
* imageBuffer. */
public int nHeight;
/** @brief A unique identifier for the frames which are part of the
* same video sequence. If the stream ID changes it means the
* frames which are being received are part of a new video sequence
* and @a nWidth and @a nHeight may have changed. The @a nStreamID
* will always be a positive integer value.*/
public int nStreamID;
/** @brief Whether the image acquired is a key-frame. If it is
* not a key-frame and there has been packet loss or a
* key-frame has not been acquired prior then the image may
* look blurred. */
public bool bKeyFrame;
/** @brief A buffer allocated internally by TeamTalkBase. */
public System.IntPtr frameBuffer;
/** @brief The size in bytes of the buffer allocate in @a
* frameBuffer. */
public int nFrameBufferSize;
}
/**
* @brief A struct containing the properties of a video capture
* device.
*
* The information retrieved from the video capture device is used
* to initialize the video capture device using the
* TeamTalkBase.InitVideoCaptureDevice() function.
*
* @see TeamTalkBase.GetVideoCaptureDevices */
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VideoCaptureDevice
{
/** @brief A string identifying the device. */
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TeamTalkBase.TT_STRLEN)]
public string szDeviceID;
/** @brief The name of the capture device. */
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TeamTalkBase.TT_STRLEN)]
public string szDeviceName;
/** @brief @brief The name of the API used to capture video.
*
* The following video capture APIs are supported:
* - AVFoundation (Mac OS)
* - DirectShow (Windows)
* - V4L2 (Linux)
*
* Mac OS's QTkit video capture API was removed in TeamTalk
* 5.2 because Apple's AppStore will reject apps which have
* dependencies to it.
*
* V4L support was removed in TeamTalk 5.2. */
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TeamTalkBase.TT_STRLEN)]
public string szCaptureAPI;
/** @brief The supported capture formats. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TeamTalkBase.TT_VIDEOFORMATS_MAX)]
public VideoFormat[] videoFormats;
/** @brief The number of capture formats available in @a
* captureFormats array. */
public int nVideoFormatsCount;
}
/** @} */
/** @addtogroup desktopshare
* @{ */
/**
* @brief The bitmap format used for a #BearWare.DesktopWindow. */
public enum BitmapFormat : uint
{
/** @brief Used to denote nothing selected. */
BMP_NONE = 0,
/** @brief The bitmap is a 256-colored bitmap requiring a
* palette. The default 256 colored palette is the Netscape
* browser-safe palette. Use TeamTalkBase.Palette_GetColorTable() to
* access or change the palette. The maximum size of a
* 8-bit bitmap is 4095 blocks of 120 by 34 pixels. */
BMP_RGB8_PALETTE = 1,
/** @brief The bitmap is a 16-bit colored bitmap. The maximum
* pixels. */
BMP_RGB16_555 = 2,
/** @brief The bitmap is a 24-bit colored bitmap. The maximum
* size of a 24-bit bitmap is 4095 blocks of 85 by 16
* pixels. */
BMP_RGB24 = 3,
/** @brief The bitmap is a 32-bit colored bitmap. The maximum
* size of a 32-bit bitmap is 4095 blocks of 51 by 20
* pixels. */
BMP_RGB32 = 4
}
/** @brief The protocols supported for transferring a
* #BearWare.DesktopWindow.
*
* So far only one, UDP-based, protocol is supported. */
public enum DesktopProtocol : uint
{
/** @brief Desktop protocol based on ZLIB for image
* compression and UDP for data transmission. */
DESKTOPPROTOCOL_ZLIB_1 = 1
}
/**
* @brief A struct containing the properties of a shared desktop window.
*
* The desktop window is a description of the bitmap which can be retrieved using
* TeamTalkBase.AcquireUserDesktopWindow() or the bitmap which should be transmitted using
* TeamTalkBase.SendDesktopWindow(). */
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DesktopWindow
{
/** @brief The width in pixels of the bitmap. */
public int nWidth;
/** @brief The height in pixels of the bitmap. */
public int nHeight;
/** @brief The format of the bitmap. */
public BitmapFormat bmpFormat;
/** @brief The number of bytes for each scan-line in the
* bitmap. Zero means 4-byte aligned. */
public int nBytesPerLine;
/** @brief The ID of the session which the bitmap belongs
* to. If the session ID changes it means the user has started
* a new session. This e.g. happens if the desktop session has
* been closed and restart or if the bitmap has been
* resized. Set @c nSessionID to 0 if the desktop window is
* used with TeamTalkBase.SendDesktopWindow(). */
public int nSessionID;
/** @brief The desktop protocol used for transmitting the desktop window. */
public DesktopProtocol nProtocol;
/** @brief A buffer pointing to the bitmap data (often refered to as Scan0). */
public IntPtr frameBuffer;
/** @brief The size in bytes of the buffer allocate in @a
* frameBuffer. Typically @c nBytesPerLine * @c nHeight. */
public int nFrameBufferSize;
}
/**
* @brief The state of a key (or mouse button), i.e. if it's
* pressed or released. @see DesktopInput */
public enum DesktopKeyState : uint
{
/** @brief The key is ignored. */
DESKTOPKEYSTATE_NONE = 0x00000000,
/** @brief The key is pressed. */
DESKTOPKEYSTATE_DOWN = 0x00000001,
/** @brief The key is released. */
DESKTOPKEYSTATE_UP = 0x00000002,
}
/**
* @brief A struct containing a mouse or keyboard event.
*
* The DesktopInput struct is used for desktop access where a
* remote user can control mouse or keybaord on a shared
* desktop. Check out section @ref desktopinput on how to use
* remote desktop access. */
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DesktopInput
{
/** @brief The X coordinate of the mouse. If used with
* WindowsHelper.Execute() and the mouse position should be
* ignored then set to #BearWare.DesktopInputConstants.DESKTOPINPUT_MOUSEPOS_IGNORE. */
public ushort uMousePosX;
/** @brief The Y coordinate of the mouse. If used with
* TeamTalkBase.DesktopInput_Execute() and the mouse position should be
* ignored then set to #BearWare.DesktopInputConstants.DESKTOPINPUT_MOUSEPOS_IGNORE. */
public ushort uMousePosY;
/** @brief The key-code (or mouse button) pressed. If used
* with TeamTalkBase.DesktopInput_Execute() and no key (or mouse button)
* is pressed then set to #BearWare.DesktopInputConstants.DESKTOPINPUT_KEYCODE_IGNORE.
* Read section @ref transdesktopinput on issues with
* key-codes and keyboard settings. */
public uint uKeyCode;
/** @brief The state of the key (or mouse button) pressed,
* i.e. if it's up or down. */
public DesktopKeyState uKeyState;
/** @brief When true initializes the desktop input to ignore mouse and key values. */
public DesktopInput(bool set_defaults)
{
if (set_defaults)
{
uMousePosX = uMousePosY = (ushort)DesktopInputConstants.DESKTOPINPUT_MOUSEPOS_IGNORE;
uKeyCode = DesktopInputConstants.DESKTOPINPUT_KEYCODE_IGNORE;
uKeyState = DesktopKeyState.DESKTOPKEYSTATE_NONE;
}
else
{
uMousePosX = uMousePosY = 0;
uKeyCode = 0;
uKeyState = DesktopKeyState.DESKTOPKEYSTATE_NONE;
}
}
}
/** @brief Constants for #BearWare.DesktopInput. */
public struct DesktopInputConstants
{
/** @ingroup desktopshare
*
* If @c uKeyCode in #BearWare.DesktopInput is set to
* #BearWare.DesktopInputConstants.DESKTOPINPUT_KEYCODE_IGNORE
* it means no key (or mouse button) was pressed in the
* desktop input event and WindowsHelper.DesktopInputExecute() will
* ignore the value. */
public const uint DESKTOPINPUT_KEYCODE_IGNORE = 0xFFFFFFFF;
/** @ingroup desktopshare
*
* If @c uMousePosX or @c uMousePosY in #BearWare.DesktopInput
* are set to
* #BearWare.DesktopInputConstants.DESKTOPINPUT_MOUSEPOS_IGNORE
* it means the mouse position is ignored when calling
* WindowsHelper.Execute(). */
public const ushort DESKTOPINPUT_MOUSEPOS_IGNORE = 0xFFFF;
/** @ingroup desktopshare
*
* If @c uKeyCode of #BearWare.DesktopInput is set to
* #BearWare.DesktopInputConstants.DESKTOPINPUT_KEYCODE_LMOUSEBTN
* then WindowsDesktopInput.Execute() will see the key-code as
* a left mouse button click. */
public const uint DESKTOPINPUT_KEYCODE_LMOUSEBTN = 0x1000;
/** @ingroup desktopshare
*
* If @c uKeyCode of #BearWare.DesktopInput is set to
* #BearWare.DesktopInputConstants.DESKTOPINPUT_KEYCODE_RMOUSEBTN
* then WindowsDesktopInput.Execute() will see the key-code as
* a right mouse button click. */
public const uint DESKTOPINPUT_KEYCODE_RMOUSEBTN = 0x1001;
/** @ingroup desktopshare
*
* If @c uKeyCode of #BearWare.DesktopInput is set to
* #BearWare.DesktopInputConstants.DESKTOPINPUT_KEYCODE_MMOUSEBTN
* then WindowsDesktopInput.Execute() will see the key-code as
* a middle mouse button click. */
public const uint DESKTOPINPUT_KEYCODE_MMOUSEBTN = 0x1002;
}
/** @} */
/** @addtogroup codecs
* @{ */
/** @brief Speex audio codec settings for Constant Bitrate mode
* (CBR).
*
* @deprecated Use #BearWare.OpusCodec.
*
* @see SpeexVBRCodec */
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
public struct SpeexCodec
{
/** @brief Set to 0 for 8 KHz (narrow band), set to 1 for 16 KHz
* (wide band), set to 2 for 32 KHz (ultra-wide band). */
[FieldOffset(0)]
public int nBandmode;
/** @brief A value from 1-10. As of DLL version 4.2 also 0 is
* supported.*/
[FieldOffset(4)]
public int nQuality;
/** @brief Milliseconds of audio data before each
* transmission.
*
* Speex uses 20 msec frame sizes. Recommended is 40 msec. Min
* is 20, max is 500 msec.
*
* The #BearWare.SoundSystem must be able to process audio packets at
* this interval. In most cases this makes less than 40 msec
* transmission interval unfeasible. */
[FieldOffset(8)]
public int nTxIntervalMSec;
/** @brief Playback should be done in stereo. Doing so will
* disable 3d-positioning.
*
* @see TeamTalkBase.SetUserPosition
* @see TeamTalkBase.SetUserStereo */
[FieldOffset(12)]
public bool bStereoPlayback;
}
/** @brief Speex audio codec settings for Variable Bitrate mode
* (VBR).
*
* @deprecated Use #BearWare.OpusCodec.
*/
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SpeexVBRCodec
{
/** @brief Set to 0 for 8 KHz (narrow band), set to 1 for 16 KHz
* (wide band), set to 2 for 32 KHz (ultra-wide band). */
public int nBandmode;
/** @brief A value from 0-10. If @c nBitRate is non-zero it
* will override this value. */
public int nQuality;
/** @brief The bitrate at which the audio codec should output
* encoded audio data. Dividing it by 8 gives roughly the
* number of bytes per second used for transmitting the
* encoded data. For limits check out
* #BearWare.SpeexConstants. Note that specifying @c nBitRate
* will override nQuality. */
public int nBitRate;
/** @brief The maximum bitrate at which the audio codec is
* allowed to output audio. Set to zero if it should be
* ignored. */
public int nMaxBitRate;
/** @brief Enable/disable discontinuous transmission. When
* enabled Speex will ignore silence, so the bitrate will
* become very low. */
public bool bDTX;
/** @brief Milliseconds of audio data before each transmission.
*
* Speex uses 20 msec frame sizes. Recommended is 40 msec. Min
* is 20, max is 500 msec.
*
* The #BearWare.SoundSystem must be able to process audio packets at
* this interval. In most cases this makes less than 40 msec
* transmission interval unfeasible. */
public int nTxIntervalMSec;
/** @brief Playback should be done in stereo. Doing so will
* disable 3d-positioning.
*
* @see TeamTalkBase.SetUserPosition
* @see TeamTalkBase.SetUserStereo */
public bool bStereoPlayback;
}
/** @brief Speex constants for #BearWare.SpeexCodec and #BearWare.SpeexVBRCodec. */
public struct SpeexConstants
{
/** @brief Use #BearWare.SpeexCodec or #BearWare.SpeexVBRCodec as 8 KHz */
public const int SPEEX_BANDMODE_NARROW = 0;
/** @brief Use #BearWare.SpeexCodec or #BearWare.SpeexVBRCodec as 16 KHz */
public const int SPEEX_BANDMODE_WIDE = 1;
/** @brief Use #BearWare.SpeexCodec or #BearWare.SpeexVBRCodec as 32 KHz */
public const int SPEEX_BANDMODE_UWIDE = 2;
/** @brief The minimum quality for Speex codec. */
public const int SPEEX_QUALITY_MIN = 0;
/** @brief The maximum quality for Speex codec. */
public const int SPEEX_QUALITY_MAX = 10;
/** @brief The minimum bitrate for Speex codec in 8 KHz
* mode, i.e. quality set to 0. */
public const int SPEEX_NB_MIN_BITRATE = 2150;