Engage Engine API  1.251.9091
Loading...
Searching...
No Matches
Engage.cs
1//
2// Copyright (c) 2019 Rally Tactical Systems, Inc.
3// All rights reserved.
4//
5
6using Newtonsoft.Json.Linq;
7using System;
8using System.Collections.Concurrent;
9using System.Collections.Generic;
10using System.Diagnostics;
11using System.Linq;
12using System.Runtime.InteropServices;
13using System.Text;
14using System.Threading.Tasks;
15
16public class Engage
17{
18 #region Interfaces and such
19 public class GroupDescriptor
20 {
21 public string id;
22 public string name;
23 public bool isEncrypted;
24 public bool allowsFullDuplex;
25 }
26
27 public interface IEngineNotifications
28 {
29 void onEngineStarted(string eventExtraJson);
30 void onEngineStopped(string eventExtraJson);
31 void onEngineAudioDevicesRefreshed(string eventExtraJson);
32 void onEngineGroupByGroupPcmPowerLevels(string eventExtraJson);
33 void onEngineAudioDevicesEvent(string eventExtraJson);
34 }
35
36 public interface ILicenseNotifications
37 {
38 void onLicenseChanged(string eventExtraJson);
39 void onLicenseExpired(string eventExtraJson);
40 void onLicenseExpiring(double secondsLeft, string eventExtraJson);
41 }
42
43 public interface ILoggingNotifications
44 {
45 void onEngageLogMessage(int level, string tag, string message);
46 }
47
48 public interface IRallypointNotifications
49 {
50 void onRallypointPausingConnectionAttempt(string id, string eventExtraJson);
51 void onRallypointConnecting(string id, string eventExtraJson);
52 void onRallypointConnected(string id, string eventExtraJson);
53 void onRallypointDisconnected(string id, string eventExtraJson);
54 void onRallypointRoundtripReport(string id, int rtMs, int rtRating, string eventExtraJson);
55 }
56
57 public interface IGroupNotifications
58 {
59 void onGroupCreated(string id, string eventExtraJson);
60 void onGroupCreateFailed(string id, string eventExtraJson);
61 void onGroupDeleted(string id, string eventExtraJson);
62 void onGroupConnected(string id, string eventExtraJson);
63 void onGroupConnectFailed(string id, string eventExtraJson);
64 void onGroupDisconnected(string id, string eventExtraJson);
65 void onGroupJoined(string id, string eventExtraJson);
66 void onGroupJoinFailed(string id, string eventExtraJson);
67 void onGroupLeft(string id, string eventExtraJson);
68 void onGroupMemberCountChanged(string id, int newCount, string eventExtraJson);
69 void onGroupRxStarted(string id, string eventExtraJson);
70 void onGroupRxEnded(string id, string eventExtraJson);
71 void onGroupRxMuted(string id, string eventExtraJson);
72 void onGroupRxUnmuted(string id, string eventExtraJson);
73 void onGroupTxMuted(string id, string eventExtraJson);
74 void onGroupTxUnmuted(string id, string eventExtraJson);
75 void onGroupRxSpeakersChanged(string id, string groupTalkerJson, string eventExtraJson);
76 void onGroupTxStarted(string id, string eventExtraJson);
77 void onGroupTxEnded(string id, string eventExtraJson);
78 void onGroupTxFailed(string id, string eventExtraJson);
79 void onGroupTxUsurpedByPriority(string id, string eventExtraJson);
80 void onGroupMaxTxTimeExceeded(string id, string eventExtraJson);
81 void onGroupNodeDiscovered(string id, string nodeJson, string eventExtraJson);
82 void onGroupNodeRediscovered(string id, string nodeJson, string eventExtraJson);
83 void onGroupNodeUndiscovered(string id, string nodeJson, string eventExtraJson);
84 void onGroupAssetDiscovered(string id, string nodeJson, string eventExtraJson);
85 void onGroupAssetRediscovered(string id, string nodeJson, string eventExtraJson);
86 void onGroupAssetUndiscovered(string id, string nodeJson, string eventExtraJson);
87 void onGroupBlobSent(string id, string eventExtraJson);
88 void onGroupBlobSendFailed(string id, string eventExtraJson);
89 void onGroupBlobReceived(string id, string blobInfoJson, byte[] blob, int blobSize, string eventExtraJson);
90 void onGroupRtpSent(string id, string eventExtraJson);
91 void onGroupRtpSendFailed(string id, string eventExtraJson);
92 void onGroupRtpReceived(string id, string rtpInfoJson, byte[] payload, int payloadSize, string eventExtraJson);
93 void onGroupRawSent(string id, string eventExtraJson);
94 void onGroupRawSendFailed(string id, string eventExtraJson);
95 void onGroupRawReceived(string id, byte[] raw, int rawSize, string eventExtraJson);
96
97 void onGroupTimelineEventStarted(string id, string eventJson, string eventExtraJson);
98 void onGroupTimelineEventUpdated(string id, string eventJson, string eventExtraJson);
99 void onGroupTimelineEventEnded(string id, string eventJson, string eventExtraJson);
100 void onGroupTimelineReport(string id, string reportJson, string eventExtraJson);
101 void onGroupTimelineReportFailed(string id, string eventExtraJson);
102 void onGroupTimelineGroomed(string id, string eventListJson, string eventExtraJson);
103
104 void onGroupHealthReport(string id, string healthReportJson, string eventExtraJson);
105 void onGroupHealthReportFailed(string id, string eventExtraJson);
106
107 void onGroupStatsReport(string id, string statsReportJson, string eventExtraJson);
108 void onGroupStatsReportFailed(string id, string eventExtraJson);
109
110 void onGroupRxVolumeChanged(string id, int leftLevelPerc, int rightLevelPerc, string eventExtraJson);
111 void onGroupRxDtmf(string id, string dtmfJson, string eventExtraJson);
112
113 void onGroupReconfigured(string id, string eventExtraJson);
114 void onGroupReconfigurationFailed(string id, string eventExtraJson);
115
116 void onGroupAudioRecordingStarted(string id, string eventExtraJson);
117 void onGroupAudioRecordingFailed(string id, string eventExtraJson);
118 void onGroupAudioRecordingEnded(string id, string eventExtraJson);
119 }
120
122 {
123 void onHumanBiometricsReceived(string groupId, string nodeId, string hbmJson, string eventExtraJson);
124 }
125
126 public interface IBridgeNotifications
127 {
128 void onBridgeCreated(string id, string eventExtraJson);
129 void onBridgeCreateFailed(string id, string eventExtraJson);
130 void onBridgeDeleted(string id, string eventExtraJson);
131 }
132
134 {
135 void onAudioRecordingStarted(string id, string eventExtraJson);
136 void onAudioRecordingFailed(string id, string eventExtraJson);
137 void onAudioRecordingEnded(string id, string eventExtraJson);
138 }
139 #endregion
140
141
142 // The Engage DLL
143 private const string ENGAGE_DLL = "engage-shared.dll";
144
145 // Limits
146 public const int ENGAGE_MAX_GROUP_ID_SZ = 64;
147 public const int ENGAGE_MAX_GROUP_NAME_SZ = 128;
148
149 // Result codes
150 public const int ENGAGE_RESULT_OK = 0;
151 public const int ENGAGE_RESULT_INVALID_PARAMETERS = -1;
152 public const int ENGAGE_RESULT_NOT_INITIALIZED = -2;
153 public const int ENGAGE_RESULT_ALREADY_INITIALIZED = -3;
154 public const int ENGAGE_RESULT_GENERAL_FAILURE = -4;
155 public const int ENGAGE_RESULT_NOT_STARTED = -5;
156 public const int ENGAGE_RESULT_ALREADY_STARTED = -6;
157 public const int ENGAGE_RESULT_INSUFFICIENT_DESTINATION_SPACE = -7;
158 public const int ENGAGE_RESULT_CRYPTO_MODULE_INITIALIZATION_FAILURE = -8;
159 public const int ENGAGE_RESULT_HIGH_RES_TIMER_ALREADY_EXISTS = -9;
160
161 // Jitter Buffer Latency types
162 public enum JitterBufferLatency : int
163 {
164 STANDARD = 0,
165 LOW_LATENCY = 1
166 }
167
168 // Connection Types
169 public enum ConnectionType : int
170 {
171 UNDEFINED = 0,
172 IP_MULTICAST = 1,
173 RALLYPOINT = 2
174 }
175
176 // TX status codes
177 public enum TxStatus : int
178 {
179 ERR_UNDEFINED = 0,
180 OK_STARTED = 1,
181 OK_ENDED = 2,
182 ERR_NOT_AN_AUDIO_GROUP = -1,
183 ERR_NOT_JOINED = -2,
184 ERR_NOT_CONNECTED = -3,
185 ERR_ALREADY_TRANSMITTING = -4,
186 ERR_INVALID_PARAMS = -5,
187 ERR_PRIORITY_TOO_LOW = -6,
188 ERR_RX_ACTIVE_ON_NON_FDX = -7,
189 ERR_CANNOT_SUBSCRIBE_TO_MIC = -8,
190 ERR_INVALID_ID = -9,
191 ERR_TX_ENDED_WITH_FAILURE = -10,
192 ERR_OTHERS_ACTIVE = -11
193 }
194
195 // License status codes
196 public enum LicensingStatusCode : int
197 {
198 OK = 0,
199 ERR_NULL_ENTITLEMENT_KEY = -1,
200 ERR_NULL_LICENSE_KEY = -2,
201 ERR_INVALID_LICENSE_KEY_LEN = -3,
202 ERR_LICENSE_KEY_VERIFICATION_FAILURE = -4,
203 ERR_ACTIVATION_CODE_VERIFICATION_FAILURE = -5,
204 ERR_INVALID_EXPIRATION_DATE = -6,
205 ERR_GENERAL_FAILURE = -7,
206 ERR_NOT_INITIALIZED = -8,
207 ERR_REQUIRES_ACTIVATION = -9,
208 ERR_LICENSE_NOT_SUITED_FOR_ACTIVATION = -10
209 }
210
211 // Logging levels
212 public enum LoggingLevel : int
213 {
214 FATAL = 0,
215 ERROR = 1,
216 WARNING = 2,
217 INFORMATION = 3,
218 DEBUG = 4
219 }
220
221 // Blob payload types
222 public const byte ENGAGE_BLOB_PT_UNDEFINED = 0;
223 public const byte ENGAGE_BLOB_PT_APP_TEXT_UTF8 = 1;
224 public const byte ENGAGE_BLOB_PT_JSON_TEXT_UTF8 = 2;
225 public const byte ENGAGE_BLOB_PT_APP_BINARY = 3;
226 public const byte ENGAGE_BLOB_PT_ENGAGE_BINARY_HUMAN_BIOMETRICS = 4;
227
228 // Human biometrics types
229 public const byte ENGAGE_HBM_HEART_RATE = 1;
230 public const byte ENGAGE_HBM_SKIN_TEMP = 2;
231 public const byte ENGAGE_HBM_CORE_TEMP = 3;
232 public const byte ENGAGE_HBM_HYDRATION = 4;
233 public const byte ENGAGE_HBM_BLOOD_OXYGENATION = 5;
234 public const byte ENGAGE_HBM_FATIGUE_LEVEL = 6;
235 public const byte ENGAGE_HBM_TASK_EFFECTIVENESS = 7;
236
237 // Group sources
238 public const String GROUP_SOURCE_ENGAGE_INTERNAL = "com.rallytac.engage.internal";
239 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_CORE = "com.rallytac.magellan.core";
240 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_CISTECH = "com.rallytac.engage.magellan.cistech";
241 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_TRELLISWARE = "com.rallytac.engage.magellan.trellisware";
242 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_SILVUS = "com.rallytac.engage.magellan.silvus";
243 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_PERSISTENT = "com.rallytac.engage.magellan.persistent";
244 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_DOMO = "com.rallytac.engage.magellan.domo";
245 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_KENWOOD = "com.rallytac.engage.magellan.kenwood";
246 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_TAIT = "com.rallytac.engage.magellan.tait";
247 public const String GROUP_SOURCE_ENGAGE_MAGELLAN_VOCALITY= "com.rallytac.engage.magellan.vocality";
248
249 // Group disconnected reasons
250 public const String GROUP_DISCONNECTED_REASON_NO_REAON = "NoReason";
251 public const String GROUP_DISCONNECTED_REASON_NO_LINK = "NoLink";
252 public const String GROUP_DISCONNECTED_REASON_UNREGISTERED = "Unregistered";
253 public const String GROUP_DISCONNECTED_REASON_NOT_ALLOWED = "NotAllowed";
254 public const String GROUP_DISCONNECTED_REASON_GENERAL_DENIAL = "GeneralDenial";
255
256 // Presence descriptor group item status flags
257 public const int ENGAGE_PDGI_FLAG_JOINED = 0x0001;
258 public const int ENGAGE_PDGI_FLAG_CONNECTED = 0x0002;
259 public const int ENGAGE_PDGI_FLAG_RX_MUTED = 0x0004;
260 public const int ENGAGE_PDGI_FLAG_TX_MUTED = 0x0008;
261
262 // NetworkTxPriority
263 public enum NetworkTxPriority : int
264 {
265 PRI_BEST_EFFORT = 0,
266 PRI_SIGNALING = 2,
267 PRI_VIDEO = 3,
268 PRI_VOICE = 4
269 }
270
271 public class JsonFields
272 {
274 {
275 public static String objectName = "fipsCrypto";
276 public static String enabled = "enabled";
277 public static String path = "path";
278 }
279
280 public class Tls
281 {
282 public static String objectName = "tls";
283 public static String verifyPeers = "verifyPeers";
284 public static String allowSelfSignedCertificates = "allowSelfSignedCertificates";
285 public static String caCertificates = "caCertificates";
286 public static String subjectRestrictions = "subjectRestrictions";
287 public static String issuerRestrictions = "issuerRestrictions";
288 }
289
290 public class WatchdogSettings
291 {
292 public static String objectName = "watchdog";
293 public static String enabled = "enabled";
294 public static String intervalMs = "intervalMs";
295 public static String hangDetectionMs = "hangDetectionMs";
296 public static String abortOnHang = "abortOnHang";
297 public static String slowExecutionThresholdMs = "slowExecutionThresholdMs";
298 }
299
301 {
302 public static String objectName = "groupCreationDetail";
303 public static String id = "id";
304 public static String status = "status";
305 }
306
307 public class GroupTxDetail
308 {
309 public static String objectName = "groupTxDetail";
310 public static String id = "id";
311 public static String status = "status";
312 public static String localPriority = "localPriority";
313 public static String remotePriority = "remotePriority";
314 public static String nonFdxMsHangRemaining = "nonFdxMsHangRemaining";
315 }
316
318 {
319 public static String objectName = "rallypointConnectionDetail";
320 public static String internalId = "internalId";
321 public static String host = "host";
322 public static String port = "port";
323 public static String msToNextConnectionAttempt = "msToNextConnectionAttempt";
324 }
325
327 {
328 public static String objectName = "groupConnectionDetail";
329 public static String id = "id";
330 public static String connectionType = "connectionType";
331 public static String peer = "peer";
332 public static String asFailover = "asFailover";
333 public static String reason = "reason";
334 }
335
337 {
338 public static String objectName = "certStoreCertificateElement";
339 public static String arrayName = "certificates";
340 public static String id = "id";
341 public static String hasPrivateKey = "hasPrivateKey";
342 public static String tags = "tags";
343 }
344
346 {
347 public static String objectName = "certStoreDescriptor";
348 public static String id = "id";
349 public static String fileName = "fileName";
350 public static String version = "version";
351 public static String flags = "flags";
352 public static String certificates = "certificates";
353 }
354
355 public class ListOfAudioDevice
356 {
357 public static String objectName = "list";
358 }
359
360 public class AudioDevice
361 {
362 public static String objectName = "audioDevice";
363 public static String deviceId = "deviceId";
364 public static String samplingRate = "samplingRate";
365 public static String msPerBuffer = "msPerBuffer";
366 public static String bufferCount = "bufferCount";
367 public static String channels = "channels";
368 public static String direction = "direction";
369 public static String boostPercentage = "boostPercentage";
370 public static String isAdad = "isAdad";
371 public static String name = "name";
372 public static String manufacturer = "manufacturer";
373 public static String model = "model";
374 public static String hardwareId = "hardwareId";
375 public static String serialNumber = "serialNumber";
376 public static String isDefault = "isDefault";
377 public static String extra = "extra";
378 public static String type = "type";
379 public static String isPresent = "isPresent";
380 }
381
383 {
384 public static String objectName = "list";
385 }
386
388 {
389 public static String objectName = "networkInterfaceDevice";
390 public static String name = "name";
391 public static String friendlyName = "friendlyName";
392 public static String description = "description";
393 public static String family = "family";
394 public static String address = "address";
395 public static String available = "available";
396 public static String isLoopback = "isLoopback";
397 public static String supportsMulticast = "supportsMulticast";
398 public static String hardwareAddress = "hardwareAddress";
399 }
400
401 public class AdvancedTxParams
402 {
403 public static String objectName = "advancedTxParams";
404 public static String flags = "flags";
405 public static String priority = "priority";
406 public static String subchannelTag = "subchannelTag";
407 public static String includeNodeId = "includeNodeId";
408 public static String alias = "alias";
409 public static String muted = "muted";
410 public static String txId = "txId";
411 public static String aliasSpecializer = "aliasSpecializer";
412 public static String receiverRxMuteForAliasSpecializer = "receiverRxMuteForAliasSpecializer";
413 public static String reBegin = "reBegin";
414
415 public class AudioUri
416 {
417 public static String objectName = "audioUri";
418 public static String uri = "uri";
419 public static String repeatCount = "repeatCount";
420 }
421 }
422
423 public class License
424 {
425 public static String objectName = "license";
426 public static String entitlement = "entitlement";
427 public static String key = "key";
428 public static String activationCode = "activationCode";
429 public static String deviceId = "deviceId";
430 public static String type = "type";
431 public static String expires = "expires";
432 public static String expiresFormatted = "expiresFormatted";
433 public static String manufacturerId = "manufacturerId";
434 }
435
436 public class TalkerInformation
437 {
438 public static String objectName = "talkerInformation";
439 public static String alias = "alias";
440 public static String nodeId = "nodeId";
441 public static String rxFlags = "rxFlags";
442 public static String txPriority = "txPriority";
443 public static String txId = "txId";
444 public static String aliasSpecializer = "aliasSpecializer";
445 public static String rxMuted = "rxMuted";
446 }
447
448 public class GroupTalkers
449 {
450 public static String objectName = "GroupTalkers";
451 public static String list = "list";
452 }
453
454 public class EnginePolicy
455 {
456 public class Database
457 {
458 public static String objectName = "database";
459 public static String enabled = "enabled";
460 public static String type = "type";
461 public static String fixedFileName = "fixedFileName";
462 }
463
464 public class Internals
465 {
466 public static String objectName = "internals";
467 public static String housekeeperIntervalMs = "housekeeperIntervalMs";
468 public static String logTaskQueueStatsIntervalMs = "logTaskQueueStatsIntervalMs";
469 public static String maxTxSecs = "maxTxSecs";
470 public static String maxRxSecs = "maxRxSecs";
471 public static String enableLazySpeakerClosure = "enableLazySpeakerClosure";
472 public static String rtpExpirationCheckIntervalMs = "rtpExpirationCheckIntervalMs";
473 public static String delayedMicrophoneClosureSecs = "delayedMicrophoneClosureSecs";
474 }
475
476 public class Timelines
477 {
478 public static String objectName = "timelines";
479 public static String enabled = "enabled";
480 public static String maxEventAgeSecs = "maxEventAgeSecs";
481 public static String storageRoot = "storageRoot";
482 public static String maxStorageMb = "maxStorageMb";
483 public static String maxMemMb = "maxMemMb";
484 public static String maxAudioEventMemMb = "maxAudioEventMemMb";
485 public static String maxDiskMb = "maxDiskMb";
486 public static String maxEvents = "maxEvents";
487 public static String groomingIntervalSecs = "groomingIntervalSecs";
488 public static String autosaveIntervalSecs = "autosaveIntervalSecs";
489 public static String disableSigningAndVerification = "disableSigningAndVerification";
490 public static String ephemeral = "ephemeral";
491 }
492
493 public class Security
494 {
495 public static String objectName = "security";
496 }
497
498 public class Certificate
499 {
500 public static String objectName = "certificate";
501 public static String certificate = "certificate";
502 public static String key = "key";
503 }
504
505 public class Licensing
506 {
507 public static String objectName = "licensing";
508 public static String entitlement = "entitlement";
509 public static String key = "key";
510 public static String activationCode = "activationCode";
511 public static String manufacturerId = "manufacturerId";
512 }
513
514 public class Networking
515 {
516 public static String objectName = "networking";
517 public static String defaultNic = "defaultNic";
518 public static String maxOutputQueuePackets = "maxOutputQueuePackets";
519 public static String rtpJitterMinMs = "rtpJitterMinMs";
520 public static String rtpJitterMaxFactor = "rtpJitterMaxFactor";
521 public static String rtpJitterMaxMs = "rtpJitterMaxMs";
522 public static String rtpLatePacketSequenceRange = "rtpLatePacketSequenceRange";
523 public static String rtpJitterTrimPercentage = "rtpJitterTrimPercentage";
524 public static String rtpJitterUnderrunReductionThresholdMs = "rtpJitterUnderrunReductionThresholdMs";
525 public static String rtpJitterUnderrunReductionAger = "rtpJitterUnderrunReductionAger";
526 public static String rtpJitterForceTrimAtMs = "rtpJitterForceTrimAtMs";
527 public static String rtpLatePacketTimestampRangeMs = "rtpLatePacketTimestampRangeMs";
528 public static String rtpInboundProcessorInactivityMs = "rtpInboundProcessorInactivityMs";
529 public static String multicastRejoinSecs = "multicastRejoinSecs";
530 public static String rpLeafConnectTimeoutSecs = "rpLeafConnectTimeoutSecs";
531 public static String maxReconnectPauseMs = "maxReconnectPauseMs";
532 public static String reconnectFailurePauseIncrementMs = "reconnectFailurePauseIncrementMs";
533 public static String sendFailurePauseMs = "sendFailurePauseMs";
534 public static String rallypointRtTestIntervalMs = "rallypointRtTestIntervalMs";
535 public static String logRtpJitterBufferStats = "logRtpJitterBufferStats";
536 public static String preventMulticastFailover = "preventMulticastFailover";
537 public static String rtcpPresenceTimeoutMs = "rtcpPresenceTimeoutMs";
538 public static String rtpJtterLatencyMode = "rtpJtterLatencyMode";
539 public static String rtpJitterMaxExceededClipPerc = "rtpJitterMaxExceededClipPerc";
540 public static String rtpJitterMaxExceededClipHangMs = "rtpJitterMaxExceededClipHangMs";
541 public static String rtpZombieLifetimeMs = "rtpZombieLifetimeMs";
542 public static String rtpMaxTrimMs = "rtpMaxTrimMs";
543 }
544
545 public class Audio
546 {
547 public static String objectName = "audio";
548 public static String enabled = "enabled";
549 public static String internalRate = "internalRate";
550 public static String internalChannels = "internalChannels";
551 public static String allowOutputOnTransmit = "allowOutputOnTransmit";
552 public static String muteTxOnTx = "muteTxOnTx";
553 public static String denoiseInput = "denoiseInput";
554 public static String denoiseOutput = "denoiseOutput";
555 public static String saveInputPcm = "saveInputPcm";
556 public static String saveOutputPcm = "saveOutputPcm";
557
558 public class Aec
559 {
560 public static String objectName = "aec";
561 public static String enabled = "enabled";
562 public static String mode = "mode";
563 public static String speakerTailMs = "speakerTailMs";
564 public static String cng = "cng";
565 }
566
567 public class Vad
568 {
569 public static String objectName = "vad";
570 public static String enabled = "enabled";
571 public static String mode = "mode";
572 }
573
574 public class Android
575 {
576 public static String objectName = "android";
577 public static String api = "api";
578 }
579
580 public class InputAgc
581 {
582 public static String objectName = "inputAgc";
583 public static String enabled = "enabled";
584 public static String minLevel = "minLevel";
585 public static String maxLevel = "maxLevel";
586 public static String compressionGainDb = "compressionGainDb";
587 public static String enableLimiter = "enableLimiter";
588 public static String targetLevelDb = "targetLevelDb";
589 }
590
591 public class OutputAgc
592 {
593 public static String objectName = "outputAgc";
594 public static String enabled = "enabled";
595 public static String minLevel = "minLevel";
596 public static String maxLevel = "maxLevel";
597 public static String compressionGainDb = "compressionGainDb";
598 public static String enableLimiter = "enableLimiter";
599 public static String targetLevelDb = "targetLevelDb";
600 }
601 }
602
603 public class Discovery
604 {
605 public static String objectName = "discovery";
606
607 public class Magellan
608 {
609 public static String objectName = "magellan";
610 public static String enabled = "enabled";
611 }
612
613 public class Ssdp
614 {
615 public static String objectName = "ssdp";
616 public static String enabled = "enabled";
617 public static String ageTimeoutMs = "ageTimeoutMs";
618 public static String address = "address";
619 }
620
621 public class Cistech
622 {
623 public static String objectName = "cistech";
624 public static String enabled = "enabled";
625 public static String ageTimeoutMs = "ageTimeoutMs";
626 public static String address = "address";
627 }
628
629 public class Trellisware
630 {
631 public static String objectName = "trellisware";
632 public static String enabled = "enabled";
633 }
634 }
635
636 public static String dataDirectory = "dataDirectory";
637 }
638
639 public class Mission
640 {
641 public static String id = "id";
642 public static String name = "name";
643 public static String description = "description";
644 public static String modPin = "modPin";
645 public static String certStoreId = "certStoreId";
646 public static String multicastFailoverPolicy = "multicastFailoverPolicy";
647 }
648
649 public class Rallypoint
650 {
651 public static String objectName = "rallypoint";
652 public static String arrayName = "rallypoints";
653
654 public class Host
655 {
656 public static String objectName = "host";
657 public static String address = "address";
658 public static String port = "port";
659 }
660
661 public static String certificate = "certificate";
662 public static String certificateKey = "certificateKey";
663 public static String verifyPeer = "verifyPeer";
664 public static String allowSelfSignedCertificate = "allowSelfSignedCertificate";
665 public static String transactionTimeoutMs = "transactionTimeoutMs";
666 public static String connectionTimeoutSecs = "connectionTimeoutSecs";
667 public static String disableMessageSigning = "disableMessageSigning";
668 public static String use = "use";
669 }
670
671 public class Address
672 {
673 public static String objectName = "address";
674 public static String address = "address";
675 public static String port = "port";
676 }
677
678 public class Rx
679 {
680 public static String objectName = "rx";
681 public static String address = "address";
682 public static String port = "port";
683 }
684
685 public class Tx
686 {
687 public static String objectName = "tx";
688 public static String address = "address";
689 public static String port = "port";
690 }
691
692 public class RangerPackets
693 {
694 public static String objectName = "rangerPackets";
695 public static String hangTimerSecs = "hangTimerSecs";
696 public static String count = "count";
697 }
698
699 public class RtpProfile
700 {
701 public static String objectName = "rtpProfile";
702 public static String mode = "mode";
703 public static String jitterMaxMs = "jitterMaxMs";
704 public static String jitterMinMs = "jitterMinMs";
705 public static String jitterMaxFactor = "jitterMaxFactor";
706 public static String latePacketSequenceRange = "latePacketSequenceRange";
707 public static String latePacketTimestampRangeMs = "latePacketTimestampRangeMs";
708 public static String jitterTrimPercentage = "jitterTrimPercentage";
709 public static String jitterUnderrunReductionThresholdMs = "jitterUnderrunReductionThresholdMs";
710 public static String jitterUnderrunReductionAger = "jitterUnderrunReductionAger";
711 public static String jitterForceTrimAtMs = "jitterForceTrimAtMs";
712 public static String jitterMaxTrimMs = "jitterMaxTrimMs";
713 public static String jitterMaxExceededClipPerc = "jitterMaxExceededClipPerc";
714 public static String jitterMaxExceededClipHangMs = "jitterMaxExceededClipHangMs";
715 public static String inboundProcessorInactivityMs = "inboundProcessorInactivityMs";
716 public static String rtcpPresenceTimeoutMs = "rtcpPresenceTimeoutMs";
717 public static String zombieLifetimeMs = "zombieLifetimeMs";
718 public static String signalledInboundProcessorInactivityMs = "signalledInboundProcessorInactivityMs";
719 }
720
721 public class Group
722 {
723 public static String objectName = "group";
724 public static String arrayName = "groups";
725 public static String id = "id";
726 public static String name = "name";
727 public static String spokenName = "spokenName";
728 public static String type = "type";
729 public static String source = "source";
730 public static String cryptoPassword = "cryptoPassword";
731 public static String alias = "alias";
732 public static String maxRxSecs = "maxRxSecs";
733 public static String enableMulticastFailover = "enableMulticastFailover";
734 public static String multicastFailoverSecs = "multicastFailoverSecs";
735 public static String interfaceName = "interfaceName";
736 public static String anonymousAlias = "anonymousAlias";
737 public static String lbCrypto = "lbCrypto";
738 public static String rtpProfile = "rtpProfile";
739 public static String specializerAffinities = "specializerAffinities";
740 public static String languageCode = "languageCode";
741
742 public class Timeline
743 {
744 public static String objectName = "timeline";
745 public static String enabled = "enabled";
746 }
747
748 public class Audio
749 {
750 public static String objectName = "audio";
751 public static String inputId = "inputId";
752 public static String outputId = "outputId";
753 }
754
756 {
757 public static String objectName = "priorityTranslation";
758 public static String priority = "priority";
759 public static String rx = "rx";
760 public static String tx = "tx";
761 }
762 }
763
764 public class TxAudio
765 {
766 public static String objectName = "txAudio";
767 public static String fdx = "fdx";
768 public static String encoder = "encoder";
769 public static String framingMs = "framingMs";
770 public static String maxTxSecs = "maxTxSecs";
771 public static String noHdrExt = "noHdrExt";
772 public static String customRtpPayloadType = "customRtpPayloadType";
773 public static String encoderName = "encoderName";
774 public static String extensionSendInterval = "extensionSendInterval";
775 public static String initialHeaderBurst = "initialHeaderBurst";
776 public static String trailingHeaderBurst = "initialHeaderBurst";
777 public static String enableSmoothing = "enableSmoothing";
778 public static String dtx = "dtx";
779 public static String smoothedHangTimeMs = "smoothedHangTimeMs";
780 public static String resetRtpOnTx = "resetRtpOnTx";
781 public static String startTxNotifications = "startTxNotifications";
782 }
783
784 public class NetworkTxOptions
785 {
786 public static String objectName = "txOptions";
787 public static String priority = "priority";
788 public static String ttl = "ttl";
789 }
790
791 public class Presence
792 {
793 public static String objectName = "presence";
794 public static String format = "format";
795 public static String intervalSecs = "intervalSecs";
796 public static String listenOnly = "listenOnly";
797 public static String minIntervalSecs = "minIntervalSecs";
798 }
799
801 {
802 public static String objectName = "presence";
803 public static String self = "self";
804 public static String comment = "comment";
805 public static String custom = "custom";
806
807 public class GroupItem
808 {
809 public static String arrayName = "groupAliases";
810 public static String id = "groupId";
811 public static String alias = "alias";
812 public static String status = "status";
813 }
814 }
815
816 public class Identity
817 {
818 public static String objectName = "identity";
819 public static String nodeId = "nodeId";
820 public static String userId = "userId";
821 public static String displayName = "displayName";
822 public static String type = "type";
823 public static String format = "format";
824 public static String avatar = "avatar";
825 }
826
827 public class Location
828 {
829 public static String objectName = "location";
830 public static String longitude = "longitude";
831 public static String latitude = "latitude";
832 public static String altitude = "altitude";
833 public static String direction = "direction";
834 public static String speed = "speed";
835 }
836
837 public class Connectivity
838 {
839 public static String objectName = "connectivity";
840 public static String type = "type";
841 public static String strength = "strength";
842 public static String rating = "rating";
843 }
844
845 public class Power
846 {
847 public static String objectName = "power";
848 public static String source = "source";
849 public static String state = "state";
850 public static String level = "level";
851 }
852
853 public class RtpHeader
854 {
855 public static String objectName = "rtpHeader";
856 public static String pt = "pt";
857 public static String marker = "marker";
858 public static String seq = "seq";
859 public static String ssrc = "ssrc";
860 public static String ts = "ts";
861 }
862
863 public class BlobInfo
864 {
865 public static String objectName = "blobHeader";
866 public static String source = "source";
867 public static String target = "target";
868 public static String payloadType = "payloadType";
869 public static String blobSize = "size";
870 public static String rtpHeader = "rtpHeader";
871 }
872
873 public class RiffDescriptor
874 {
875 public static String objectName = "descriptor";
876 public static String file = "file";
877 public static String verified = "verified";
878 public static String channels = "channels";
879 public static String sampleCount = "sampleCount";
880 public static String meta = "meta";
881 public static String certificate = "certificate";
882 public static String signature = "signature";
883 }
884
885 public class TimelineEvent
886 {
887 public class Audio
888 {
889 public static String objectName = "audio";
890 public static String ms = "ms";
891 public static String samples = "samples";
892 }
893
894 public static String objectName = "event";
895 public static String alias = "alias";
896 public static String direction = "direction";
897 public static String ended = "ended";
898 public static String groupId = "groupId";
899 public static String id = "id";
900 public static String inProgress = "inProgress";
901 public static String nodeId = "nodeId";
902 public static String started = "started";
903 public static String thisNodeId = "thisNodeId";
904 public static String type = "type";
905 public static String uri = "uri";
906 public static String jsonAttachment = "jsonAttachment";
907 public static String blobAttachment = "blobAttachment";
908 }
909
910 public class TimelineQuery
911 {
912 public static String maxCount = "maxCount";
913 public static String mostRecentFirst = "mostRecentFirst";
914 public static String startedOnOrAfter = "startedOnOrAfter";
915 public static String endedOnOrBefore = "endedOnOrBefore";
916 public static String onlyDirection = "onlyDirection";
917 public static String onlyType = "onlyType";
918 public static String onlyCommitted = "onlyCommitted";
919 public static String onlyAlias = "onlyAlias";
920 public static String onlyNodeId = "onlyNodeId";
921 public static String onlyTxId = "onlyTxId";
922 public static String sql = "sql";
923 }
924
925 public class TimelineReport
926 {
927 public static String success = "success";
928 public static String errorMessage = "errorMessage";
929 public static String started = "started";
930 public static String ended = "ended";
931 public static String execMs = "execMs";
932 public static String records = "records";
933 public static String events = "events";
934 public static String count = "count";
935 }
936 }
937
938 #region Callback delegate types
939 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
940 private delegate void EngageVoidCallback(string eventExtraJson);
941
942 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
943 private delegate void EngageStringCallback(string s, string eventExtraJson);
944
945 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
946 private delegate void EngageString2Callback(string s1, string s2, string eventExtraJson);
947
948 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
949 private delegate void EngageStringAndIntCallback(string s, int i, string eventExtraJson);
950
951 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
952 private delegate void EngageString2AndInt2Callback(string s, int i1, int i2, string eventExtraJson);
953
954 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
955 private delegate void EngageStringAndArgvCallback(string s, IntPtr ptr, string eventExtraJson);
956
957 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
958 private delegate void EngageStringAndBlobCallback(string s, IntPtr ptr, int i, string eventExtraJson);
959
960 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
961 private delegate void EngageString2AndBlobCallback(string s, string j, IntPtr ptr, int i, string eventExtraJson);
962
963 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
964 private delegate void EngageStringAndTwoIntCallback(string s, int i1, int i2, string eventExtraJson);
965
966 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
967 private delegate void EngageLoggingCallback(int level, string tag, string message);
968 #endregion
969
970 #region Structures
971 [StructLayout(LayoutKind.Sequential, Pack = 1)]
973 {
974 [MarshalAs(UnmanagedType.ByValArray, SizeConst = ENGAGE_MAX_GROUP_ID_SZ)]
975 public byte[] id;
976
977 [MarshalAs(UnmanagedType.ByValArray, SizeConst = ENGAGE_MAX_GROUP_NAME_SZ)]
978 public byte[] name;
979
980 [MarshalAs(UnmanagedType.U1)]
981 public Boolean isEncrypted;
982
983 [MarshalAs(UnmanagedType.U1)]
984 public Boolean allowsFullDuplex;
985 }
986
987 [StructLayout(LayoutKind.Sequential, Pack = 1)]
988 private struct EngageEvents_t
989 {
990 public EngageVoidCallback PFN_ENGAGE_ENGINE_STARTED;
991 public EngageVoidCallback PFN_ENGAGE_ENGINE_STOPPED;
992
993 public EngageStringCallback PFN_ENGAGE_RP_PAUSING_CONNECTION_ATTEMPT;
994 public EngageStringCallback PFN_ENGAGE_RP_CONNECTING;
995 public EngageStringCallback PFN_ENGAGE_RP_CONNECTED;
996 public EngageStringCallback PFN_ENGAGE_RP_DISCONNECTED;
997 public EngageStringAndTwoIntCallback PFN_ENGAGE_RP_ROUNDTRIP_REPORT;
998
999 public EngageStringCallback PFN_ENGAGE_GROUP_CREATED;
1000 public EngageStringCallback PFN_ENGAGE_GROUP_CREATE_FAILED;
1001 public EngageStringCallback PFN_ENGAGE_GROUP_DELETED;
1002
1003 public EngageStringCallback PFN_ENGAGE_GROUP_CONNECTED;
1004 public EngageStringCallback PFN_ENGAGE_GROUP_CONNECT_FAILED;
1005 public EngageStringCallback PFN_ENGAGE_GROUP_DISCONNECTED;
1006
1007 public EngageStringCallback PFN_ENGAGE_GROUP_JOINED;
1008 public EngageStringCallback PFN_ENGAGE_GROUP_JOIN_FAILED;
1009 public EngageStringCallback PFN_ENGAGE_GROUP_LEFT;
1010
1011 public EngageStringAndIntCallback PFN_ENGAGE_GROUP_MEMBER_COUNT_CHANGED;
1012
1013 public EngageString2Callback PFN_ENGAGE_GROUP_NODE_DISCOVERED;
1014 public EngageString2Callback PFN_ENGAGE_GROUP_NODE_REDISCOVERED;
1015 public EngageString2Callback PFN_ENGAGE_GROUP_NODE_UNDISCOVERED;
1016
1017 public EngageStringCallback PFN_ENGAGE_GROUP_RX_STARTED;
1018 public EngageStringCallback PFN_ENGAGE_GROUP_RX_ENDED;
1019 public EngageString2Callback PFN_ENGAGE_GROUP_RX_SPEAKERS_CHANGED;
1020 public EngageStringCallback PFN_ENGAGE_GROUP_RX_MUTED;
1021 public EngageStringCallback PFN_ENGAGE_GROUP_RX_UNMUTED;
1022
1023 public EngageStringCallback PFN_ENGAGE_GROUP_TX_STARTED;
1024 public EngageStringCallback PFN_ENGAGE_GROUP_TX_ENDED;
1025 public EngageStringCallback PFN_ENGAGE_GROUP_TX_FAILED;
1026 public EngageStringCallback PFN_ENGAGE_GROUP_TX_USURPED_BY_PRIORITY;
1027 public EngageStringCallback PFN_ENGAGE_GROUP_MAX_TX_TIME_EXCEEDED;
1028 public EngageStringCallback PFN_ENGAGE_GROUP_TX_MUTED;
1029 public EngageStringCallback PFN_ENGAGE_GROUP_TX_UNMUTED;
1030
1031 public EngageString2Callback PFN_ENGAGE_GROUP_ASSET_DISCOVERED;
1032 public EngageString2Callback PFN_ENGAGE_GROUP_ASSET_REDISCOVERED;
1033 public EngageString2Callback PFN_ENGAGE_GROUP_ASSET_UNDISCOVERED;
1034
1035 public EngageVoidCallback PFN_ENGAGE_LICENSE_CHANGED;
1036 public EngageVoidCallback PFN_ENGAGE_LICENSE_EXPIRED;
1037 public EngageStringCallback PFN_ENGAGE_LICENSE_EXPIRING;
1038
1039 public EngageStringCallback PFN_ENGAGE_GROUP_BLOB_SENT;
1040 public EngageStringCallback PFN_ENGAGE_GROUP_BLOB_SEND_FAILED;
1041 public EngageString2AndBlobCallback PFN_ENGAGE_GROUP_BLOB_RECEIVED;
1042
1043 public EngageStringCallback PFN_ENGAGE_GROUP_RTP_SENT;
1044 public EngageStringCallback PFN_ENGAGE_GROUP_RTP_SEND_FAILED;
1045 public EngageString2AndBlobCallback PFN_ENGAGE_GROUP_RTP_RECEIVED;
1046
1047 public EngageStringCallback PFN_ENGAGE_GROUP_RAW_SENT;
1048 public EngageStringCallback PFN_ENGAGE_GROUP_RAW_SEND_FAILED;
1049 public EngageStringAndBlobCallback PFN_ENGAGE_GROUP_RAW_RECEIVED;
1050
1051 public EngageString2Callback PFN_ENGAGE_GROUP_TIMELINE_EVENT_STARTED;
1052 public EngageString2Callback PFN_ENGAGE_GROUP_TIMELINE_EVENT_UPDATED;
1053 public EngageString2Callback PFN_ENGAGE_GROUP_TIMELINE_EVENT_ENDED;
1054 public EngageString2Callback PFN_ENGAGE_GROUP_TIMELINE_REPORT;
1055 public EngageStringCallback PFN_ENGAGE_GROUP_TIMELINE_REPORT_FAILED;
1056 public EngageString2Callback PFN_ENGAGE_GROUP_TIMELINE_GROOMED;
1057
1058 public EngageString2Callback PFN_ENGAGE_GROUP_HEALTH_REPORT;
1059 public EngageStringCallback PFN_ENGAGE_GROUP_HEALTH_REPORT_FAILED;
1060
1061 public EngageStringCallback PFN_ENGAGE_BRIDGE_CREATED;
1062 public EngageStringCallback PFN_ENGAGE_BRIDGE_CREATE_FAILED;
1063 public EngageStringCallback PFN_ENGAGE_BRIDGE_DELETED;
1064
1065 public EngageString2Callback PFN_ENGAGE_GROUP_STATS_REPORT;
1066 public EngageStringCallback PFN_ENGAGE_GROUP_STATS_REPORT_FAILED;
1067
1068 public EngageString2AndInt2Callback PFN_ENGAGE_GROUP_RX_VOLUME_CHANGED;
1069 public EngageString2Callback PFN_ENGAGE_GROUP_RX_DTMF;
1070
1071 public EngageVoidCallback PFN_ENGAGE_ENGINE_AUDIO_DEVICES_REFRESHED;
1072 public EngageVoidCallback PFN_ENGAGE_ENGINE_GROUP_BY_GROUP_PCM_POWER_LEVEL_REPORT;
1073 public EngageVoidCallback PFN_ENGAGE_ENGINE_AUDIO_DEVICE_EVENT;
1074
1075 public EngageStringCallback PFN_ENGAGE_GROUP_RECONFIGURED;
1076 public EngageStringCallback PFN_ENGAGE_GROUP_RECONFIGURATION_FAILED;
1077
1078 public EngageStringCallback PFN_ENGAGE_AUDIO_RECORDING_STARTED;
1079 public EngageStringCallback PFN_ENGAGE_AUDIO_RECORDING_FAILED;
1080 public EngageStringCallback PFN_ENGAGE_AUDIO_RECORDING_ENDED;
1081 }
1082
1083 [StructLayout(LayoutKind.Sequential, Pack = 1)] // 9 bytes
1084 public struct DataSeriesHeader
1085 {
1086 [MarshalAs(UnmanagedType.U1)]
1087 public byte t;
1088
1089 [MarshalAs(UnmanagedType.U4)]
1090 public uint ts;
1091
1092 [MarshalAs(UnmanagedType.U1)]
1093 public byte it;
1094
1095 [MarshalAs(UnmanagedType.U1)]
1096 public byte im;
1097
1098 [MarshalAs(UnmanagedType.U1)]
1099 public byte vt;
1100
1101 [MarshalAs(UnmanagedType.U1)]
1102 public byte ss;
1103 }
1104
1105 [StructLayout(LayoutKind.Sequential, Pack = 1)] // 2 bytes
1106 public struct DataElementUint8
1107 {
1108 [MarshalAs(UnmanagedType.U1)]
1109 public byte ofs;
1110
1111 [MarshalAs(UnmanagedType.U1)]
1112 public byte val;
1113 }
1114
1115 [StructLayout(LayoutKind.Sequential, Pack = 1)] // 3 bytes
1116 public struct DataElementUint16
1117 {
1118 [MarshalAs(UnmanagedType.U1)]
1119 public byte ofs;
1120
1121 [MarshalAs(UnmanagedType.U2)]
1122 public ushort val;
1123 }
1124
1125 [StructLayout(LayoutKind.Sequential, Pack = 1)] // 5 bytes
1126 public struct DataElementUint32
1127 {
1128 [MarshalAs(UnmanagedType.U1)]
1129 public byte ofs;
1130
1131 [MarshalAs(UnmanagedType.U4)]
1132 public uint val;
1133 }
1134
1135 [StructLayout(LayoutKind.Sequential, Pack = 1)] // 9 bytes
1136 public struct DataElementUint64
1137 {
1138 [MarshalAs(UnmanagedType.U1)]
1139 public byte ofs;
1140
1141 [MarshalAs(UnmanagedType.U8)]
1142 public ulong val;
1143 }
1144 #endregion
1145
1146 #region Library functions
1147 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1148 private static extern void engageWin32LibraryInit();
1149
1150 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1151 private static extern void engageWin32LibraryDeinit();
1152
1153 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1154 private static extern int engageRegisterEventCallbacks(ref EngageEvents_t callbacks);
1155
1156 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1157 private static extern int engageEnableNotifications(int enable);
1158
1159 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1160 private static extern int engageInitialize(string enginePolicyConfiguration, string userIdentity, string tempStoragePath);
1161
1162 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1163 private static extern int engageShutdown();
1164
1165 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1166 private static extern int engageStart();
1167
1168 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1169 private static extern int engageStop();
1170
1171 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1172 private static extern int engageCreateGroup(string jsonConfiguration);
1173
1174 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1175 private static extern int engageDeleteGroup(string id);
1176
1177 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1178 private static extern int engageJoinGroup(string id);
1179
1180 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1181 private static extern int engageLeaveGroup(string id);
1182
1183 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1184 private static extern int engageSetGroupRules(string id, string jsonParams);
1185
1186 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1187 private static extern int engageBeginGroupTx(string id, int txPriority, int txFlags);
1188
1189 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1190 private static extern int engageBeginGroupTxAdvanced(string id, string jsonParams);
1191
1192 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1193 private static extern int engageEndGroupTx(string id);
1194
1195 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1196 private static extern int engageSetGroupRxTag(string id, int tag);
1197
1198 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1199 private static extern int engageMuteGroupRx(string id);
1200
1201 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1202 private static extern int engageUnmuteGroupRx(string id);
1203
1204 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1205 private static extern int engageMuteGroupTx(string id);
1206
1207 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1208 private static extern int engageUnmuteGroupTx(string id);
1209
1210 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1211 private static extern int engageSetGroupRxVolume(string id, int left, int right);
1212
1213 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1214 private static extern IntPtr engageGetVersion();
1215
1216 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1217 private static extern IntPtr engageGetHardwareReport();
1218
1219 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1220 private static extern IntPtr engageGetActiveLicenseDescriptor();
1221
1222 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1223 private static extern IntPtr engageGetLicenseDescriptor(string entitlement, string key, string activationCode, string manufacturerId);
1224
1225 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1226 private static extern int engageUpdateLicense(string entitlement, string key, string activationCode, string manufacturerId);
1227
1228 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1229 private static extern int engageUpdatePresenceDescriptor(string id, string jsonDescriptor, int forceBeacon);
1230
1231 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1232 private static extern int engageSendGroupBlob(string id, IntPtr blob, int blobSize, string jsonBlobParams);
1233
1234 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1235 private static extern int engageSendGroupRtp(string id, IntPtr payload, int payloadSize, string jsonRtpHeader);
1236
1237 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1238 private static extern int engageSendGroupRaw(string id, IntPtr raw, int rawSize, string jsonRtpHeader);
1239
1240 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1241 private static extern int engageQueryGroupTimeline(string id, string jsonParams);
1242
1243 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1244 private static extern int engageSetLogLevel(int level);
1245
1246 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1247 private static extern int engageSetLogTagExtension(string tagExtension);
1248
1249 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1250 private static extern int engageSetLoggingOutputOverride(EngageLoggingCallback hookFn);
1251
1252 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1253 private static extern int engageEnableSyslog(int enable);
1254
1255 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1256 private static extern int engageWatchdog(int enable);
1257
1258 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1259 private static extern int engageLogMsg(int level, string tag, string msg);
1260
1261 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1262 private static extern IntPtr engageGetNetworkInterfaceDevices();
1263
1264 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1265 private static extern IntPtr engageGetAudioDevices();
1266
1267 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1268 private static extern IntPtr engageGenerateMission(string keyPhrase, int audioGroupCount, string rallypointHost, string missionName);
1269
1270 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1271 private static extern IntPtr engageGenerateMissionUsingCertStore(string keyPhrase, int audioGroupCount, string rallypointHost, string missionName, string certStoreFn, string certStorePasswordHexByteString, string certStoreElement);
1272
1273 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1274 private static extern int engageSetMissionId(string missionId);
1275
1276 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1277 private static extern int engageOpenCertStore(string fileName, string passwordHexByteString);
1278
1279 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1280 private static extern IntPtr engageGetCertStoreDescriptor();
1281
1282 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1283 private static extern int engageCloseCertStore();
1284
1285 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1286 private static extern int engageSetCertStoreCertificatePem(string id, string certificatePem, string privateKeyPem, string tags);
1287
1288 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1289 private static extern int engageSetCertStoreCertificateP12(string id,IntPtr data, int size, string password, string tags);
1290
1291 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1292 private static extern int engageDeleteCertStoreCertificate(string id);
1293
1294 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1295 private static extern IntPtr engageGetCertStoreCertificatePem(string id);
1296
1297 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1298 private static extern IntPtr engageGetCertificateDescriptorFromPem(string pem);
1299
1300 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1301 private static extern IntPtr engageGetArrayOfCertificateDescriptorsFromPem(string pem);
1302
1303 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1304 private static extern int engageImportCertStoreElementFromCertStore(string id, string srcId, string srcFileName, string srcPasswordHexByteString, string tags);
1305
1306 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1307 private static extern IntPtr engageQueryCertStoreContents(string fileName, string passwordHexByteString);
1308
1309 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1310 private static extern int engageQueryGroupHealth(string id);
1311
1312 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1313 private static extern int engageQueryGroupStats(string id);
1314
1315 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1316 private static extern int engageCreateBridge(string jsonConfiguration);
1317
1318 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1319 private static extern int engageDeleteBridge(string id);
1320
1321 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1322 private static extern int engageEncrypt(IntPtr src, int size, IntPtr dst, string passwordHexByteString);
1323
1324 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1325 private static extern int engageDecrypt(IntPtr src, int size, IntPtr dst, string passwordHexByteString);
1326
1327 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1328 private static extern int engagePlatformNotifyChanges(string jsonChangesArray);
1329
1330 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1331 private static extern IntPtr engageBeginFileRecording(string jsonParams);
1332
1333 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1334 private static extern IntPtr engageEndFileRecording(string id);
1335
1336 //[DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1337 //private static extern int engageCompress(IntPtr src, int srcSize, IntPtr dst, int maxDstSize);
1338
1339 //[DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1340 //private static extern int engageDecompress(IntPtr src, int srcSize, IntPtr dst, int maxDstSize);
1341
1342 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1343 private static extern int engageSetFipsCrypto(string jsonParams);
1344
1345 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1346 private static extern int engageIsCryptoFipsValidated();
1347
1348 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1349 private static extern IntPtr engageGetDeviceId();
1350
1351 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1352 private static extern int engageSetCertStore(IntPtr buff, int size, string passwordHexByteString);
1353
1354 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1355 private static extern int engageVerifyRiff(string fn);
1356
1357 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1358 private static extern IntPtr engageGetRiffDescriptor(string fn);
1359
1360 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1361 private static extern int engageBeginGroupPcmPowerTracking(string id);
1362
1363 [DllImport(ENGAGE_DLL, CallingConvention = CallingConvention.Cdecl)]
1364 private static extern int engageEndGroupPcmPowerTracking(string id);
1365
1366 #endregion
1367
1368 #region Internal functions
1369 private static string[] stringArrayFromArgvStrPtrArray(IntPtr ptr)
1370 {
1371 string[] rc = null;
1372 int count = 0;
1373 IntPtr arrayPtr;
1374 IntPtr strPtr;
1375
1376 // First count how many we have
1377 arrayPtr = ptr;
1378 while (true)
1379 {
1380 strPtr = Marshal.ReadIntPtr(arrayPtr);
1381 if (strPtr == (IntPtr)0)
1382 {
1383 break;
1384 }
1385
1386 count++;
1387 arrayPtr += Marshal.SizeOf(arrayPtr);
1388 }
1389
1390 // Now, allocate the array and copy over the strings
1391 if (count > 0)
1392 {
1393 rc = new string[count];
1394
1395 int idx = 0;
1396 arrayPtr = ptr;
1397 while (true)
1398 {
1399 strPtr = Marshal.ReadIntPtr(arrayPtr);
1400 if (strPtr == (IntPtr)0)
1401 {
1402 break;
1403 }
1404
1405 rc[idx] = Marshal.PtrToStringAnsi(strPtr);
1406
1407 arrayPtr += Marshal.SizeOf(arrayPtr);
1408 idx++;
1409 }
1410 }
1411
1412 return rc;
1413 }
1414
1415 private int registerEventCallbacks()
1416 {
1417 EngageEvents_t cb = new EngageEvents_t();
1418
1419 cb.PFN_ENGAGE_ENGINE_STARTED = on_ENGAGE_ENGINE_STARTED;
1420 cb.PFN_ENGAGE_ENGINE_STOPPED = on_ENGAGE_ENGINE_STOPPED;
1421 cb.PFN_ENGAGE_ENGINE_AUDIO_DEVICES_REFRESHED = on_ENGAGE_ENGINE_AUDIO_DEVICES_REFRESHED;
1422 cb.PFN_ENGAGE_ENGINE_GROUP_BY_GROUP_PCM_POWER_LEVEL_REPORT = on_ENGAGE_ENGINE_GROUP_BY_GROUP_PCM_POWER_LEVEL_REPORT;
1423 cb.PFN_ENGAGE_ENGINE_AUDIO_DEVICE_EVENT = on_ENGAGE_ENGINE_AUDIO_DEVICE_EVENT;
1424
1425 cb.PFN_ENGAGE_RP_PAUSING_CONNECTION_ATTEMPT = on_ENGAGE_RP_PAUSING_CONNECTION_ATTEMPT;
1426 cb.PFN_ENGAGE_RP_CONNECTING = on_ENGAGE_RP_CONNECTING;
1427 cb.PFN_ENGAGE_RP_CONNECTED = on_ENGAGE_RP_CONNECTED;
1428 cb.PFN_ENGAGE_RP_DISCONNECTED = on_ENGAGE_RP_DISCONNECTED;
1429 cb.PFN_ENGAGE_RP_ROUNDTRIP_REPORT = on_ENGAGE_RP_ROUNDTRIP_REPORT;
1430
1431 cb.PFN_ENGAGE_GROUP_CREATED = on_ENGAGE_GROUP_CREATED;
1432 cb.PFN_ENGAGE_GROUP_CREATE_FAILED = on_ENGAGE_GROUP_CREATE_FAILED;
1433 cb.PFN_ENGAGE_GROUP_DELETED = on_ENGAGE_GROUP_DELETED;
1434
1435 cb.PFN_ENGAGE_GROUP_CONNECTED = on_ENGAGE_GROUP_CONNECTED;
1436 cb.PFN_ENGAGE_GROUP_CONNECT_FAILED = on_ENGAGE_GROUP_CONNECT_FAILED;
1437 cb.PFN_ENGAGE_GROUP_DISCONNECTED = on_ENGAGE_GROUP_DISCONNECTED;
1438
1439 cb.PFN_ENGAGE_GROUP_JOINED = on_ENGAGE_GROUP_JOINED;
1440 cb.PFN_ENGAGE_GROUP_JOIN_FAILED = on_ENGAGE_GROUP_JOIN_FAILED;
1441 cb.PFN_ENGAGE_GROUP_LEFT = on_ENGAGE_GROUP_LEFT;
1442
1443 // TODO: FIXME!
1444 cb.PFN_ENGAGE_GROUP_MEMBER_COUNT_CHANGED = null;
1445 //cb.PFN_ENGAGE_GROUP_MEMBER_COUNT_CHANGED = on_ENGAGE_GROUP_MEMBER_COUNT_CHANGED;
1446
1447 cb.PFN_ENGAGE_GROUP_RX_STARTED = on_ENGAGE_GROUP_RX_STARTED;
1448 cb.PFN_ENGAGE_GROUP_RX_ENDED = on_ENGAGE_GROUP_RX_ENDED;
1449
1450 cb.PFN_ENGAGE_GROUP_RX_MUTED = on_ENGAGE_GROUP_RX_MUTED;
1451 cb.PFN_ENGAGE_GROUP_RX_UNMUTED = on_ENGAGE_GROUP_RX_UNMUTED;
1452
1453 cb.PFN_ENGAGE_GROUP_TX_MUTED = on_ENGAGE_GROUP_TX_MUTED;
1454 cb.PFN_ENGAGE_GROUP_TX_UNMUTED = on_ENGAGE_GROUP_TX_UNMUTED;
1455
1456 cb.PFN_ENGAGE_GROUP_RX_SPEAKERS_CHANGED = on_ENGAGE_GROUP_RX_SPEAKERS_CHANGED;
1457
1458 cb.PFN_ENGAGE_GROUP_TX_STARTED = on_ENGAGE_GROUP_TX_STARTED;
1459 cb.PFN_ENGAGE_GROUP_TX_ENDED = on_ENGAGE_GROUP_TX_ENDED;
1460 cb.PFN_ENGAGE_GROUP_TX_FAILED = on_ENGAGE_GROUP_TX_FAILED;
1461 cb.PFN_ENGAGE_GROUP_TX_USURPED_BY_PRIORITY = on_ENGAGE_GROUP_TX_USURPED_BY_PRIORITY;
1462 cb.PFN_ENGAGE_GROUP_MAX_TX_TIME_EXCEEDED = on_ENGAGE_GROUP_MAX_TX_TIME_EXCEEDED;
1463
1464 cb.PFN_ENGAGE_GROUP_NODE_DISCOVERED = on_ENGAGE_GROUP_NODE_DISCOVERED;
1465 cb.PFN_ENGAGE_GROUP_NODE_REDISCOVERED = on_ENGAGE_GROUP_NODE_REDISCOVERED;
1466 cb.PFN_ENGAGE_GROUP_NODE_UNDISCOVERED = on_ENGAGE_GROUP_NODE_UNDISCOVERED;
1467
1468 cb.PFN_ENGAGE_GROUP_ASSET_DISCOVERED = on_ENGAGE_GROUP_ASSET_DISCOVERED;
1469 cb.PFN_ENGAGE_GROUP_ASSET_REDISCOVERED = on_ENGAGE_GROUP_ASSET_REDISCOVERED;
1470 cb.PFN_ENGAGE_GROUP_ASSET_UNDISCOVERED = on_ENGAGE_GROUP_ASSET_UNDISCOVERED;
1471
1472 cb.PFN_ENGAGE_LICENSE_CHANGED = on_ENGAGE_LICENSE_CHANGED;
1473 cb.PFN_ENGAGE_LICENSE_EXPIRED = on_ENGAGE_LICENSE_EXPIRED;
1474 cb.PFN_ENGAGE_LICENSE_EXPIRING = on_ENGAGE_LICENSE_EXPIRING;
1475
1476 cb.PFN_ENGAGE_GROUP_BLOB_SENT = on_ENGAGE_GROUP_BLOB_SENT;
1477 cb.PFN_ENGAGE_GROUP_BLOB_SEND_FAILED = on_ENGAGE_GROUP_BLOB_SEND_FAILED;
1478 cb.PFN_ENGAGE_GROUP_BLOB_RECEIVED = on_ENGAGE_GROUP_BLOB_RECEIVED;
1479
1480 cb.PFN_ENGAGE_GROUP_RTP_SENT = on_ENGAGE_GROUP_RTP_SENT;
1481 cb.PFN_ENGAGE_GROUP_RTP_SEND_FAILED = on_ENGAGE_GROUP_RTP_SEND_FAILED;
1482 cb.PFN_ENGAGE_GROUP_RTP_RECEIVED = on_ENGAGE_GROUP_RTP_RECEIVED;
1483
1484 cb.PFN_ENGAGE_GROUP_RAW_SENT = on_ENGAGE_GROUP_RAW_SENT;
1485 cb.PFN_ENGAGE_GROUP_RAW_SEND_FAILED = on_ENGAGE_GROUP_RAW_SEND_FAILED;
1486 cb.PFN_ENGAGE_GROUP_RAW_RECEIVED = on_ENGAGE_GROUP_RAW_RECEIVED;
1487
1488 cb.PFN_ENGAGE_GROUP_TIMELINE_EVENT_STARTED = on_ENGAGE_GROUP_TIMELINE_EVENT_STARTED;
1489 cb.PFN_ENGAGE_GROUP_TIMELINE_EVENT_UPDATED = on_ENGAGE_GROUP_TIMELINE_EVENT_UPDATED;
1490 cb.PFN_ENGAGE_GROUP_TIMELINE_EVENT_ENDED = on_ENGAGE_GROUP_TIMELINE_EVENT_ENDED;
1491
1492 cb.PFN_ENGAGE_GROUP_TIMELINE_REPORT = on_ENGAGE_GROUP_TIMELINE_REPORT;
1493 cb.PFN_ENGAGE_GROUP_TIMELINE_REPORT_FAILED = on_ENGAGE_GROUP_TIMELINE_REPORT_FAILED;
1494 cb.PFN_ENGAGE_GROUP_TIMELINE_GROOMED = on_ENGAGE_GROUP_TIMELINE_GROOMED;
1495
1496 cb.PFN_ENGAGE_GROUP_HEALTH_REPORT = on_ENGAGE_GROUP_HEALTH_REPORT;
1497 cb.PFN_ENGAGE_GROUP_HEALTH_REPORT_FAILED = on_ENGAGE_GROUP_HEALTH_REPORT_FAILED;
1498
1499 cb.PFN_ENGAGE_BRIDGE_CREATED = on_ENGAGE_BRIDGE_CREATED;
1500 cb.PFN_ENGAGE_BRIDGE_CREATE_FAILED = on_ENGAGE_BRIDGE_CREATE_FAILED;
1501 cb.PFN_ENGAGE_BRIDGE_DELETED = on_ENGAGE_BRIDGE_DELETED;
1502
1503 cb.PFN_ENGAGE_GROUP_RX_VOLUME_CHANGED = on_ENGAGE_GROUP_RX_VOLUME_CHANGED;
1504 cb.PFN_ENGAGE_GROUP_RX_DTMF = on_ENGAGE_GROUP_RX_DTMF;
1505
1506 cb.PFN_ENGAGE_GROUP_RECONFIGURED = on_ENGAGE_GROUP_RECONFIGURED;
1507 cb.PFN_ENGAGE_GROUP_RECONFIGURATION_FAILED = on_ENGAGE_GROUP_RECONFIGURATION_FAILED;
1508
1509 cb.PFN_ENGAGE_AUDIO_RECORDING_STARTED = on_ENGAGE_AUDIO_RECORDING_STARTED;
1510 cb.PFN_ENGAGE_AUDIO_RECORDING_FAILED = on_ENGAGE_AUDIO_RECORDING_FAILED;
1511 cb.PFN_ENGAGE_AUDIO_RECORDING_ENDED = on_ENGAGE_AUDIO_RECORDING_ENDED;
1512
1513 return engageRegisterEventCallbacks(ref cb);
1514 }
1515
1516 private string makeUserJsonConfiguration(string alias, string displayName, int txPriority)
1517 {
1518 StringBuilder sb = new StringBuilder();
1519
1520 // Note: Alias is maxed at 16, so if we precede it with "C#", we
1521 // can only use 14 hex characters for our random number portion of the ID.
1522
1523 string myAlias = alias;
1524 string myDisplayName = displayName;
1525 int myTransmitPirority = txPriority;
1526
1527 if (myAlias == null || myAlias.Length == 0)
1528 {
1529 myAlias = String.Format("C#{0:X14}", new Random().Next());
1530 }
1531
1532 if (myDisplayName == null || myDisplayName.Length == 0)
1533 {
1534 myDisplayName = "C# User " + myAlias;
1535 }
1536
1537 if(myTransmitPirority < 0)
1538 {
1539 myTransmitPirority = 0;
1540 }
1541
1542 sb.Append("{");
1543 sb.Append("\"alias\":");
1544 sb.Append("\"" + myAlias + "\"");
1545
1546 sb.Append(",\"displayName\":");
1547 sb.Append("\"" + myDisplayName + "\"");
1548
1549 sb.Append(",\"txPriority\":");
1550 sb.Append(myTransmitPirority);
1551 sb.Append("}");
1552
1553 return sb.ToString();
1554 }
1555 #endregion
1556
1557 #region Member variables
1558 private static List<IEngineNotifications> _engineNotificationSubscribers = new List<IEngineNotifications>();
1559 private static List<IRallypointNotifications> _rallypointNotificationSubscribers = new List<IRallypointNotifications>();
1560 private static List<IGroupNotifications> _groupNotificationSubscribers = new List<IGroupNotifications>();
1561 private static List<ILicenseNotifications> _licenseNotificationSubscribers = new List<ILicenseNotifications>();
1562 private static List<IHumanBiometricsNotifications> _humanBiometricsNotifications = new List<IHumanBiometricsNotifications>();
1563 private static List<IBridgeNotifications> _bridgeNotificationSubscribers = new List<IBridgeNotifications>();
1564 private static List<ILoggingNotifications> _loggingNotificationSubscribers = new List<ILoggingNotifications>();
1565 private static List<IAudioRecordingNotifications> _audioRecordingNotificationSubscribers = new List<IAudioRecordingNotifications>();
1566 #endregion
1567
1568 #region Callback delegates
1569 private EngageVoidCallback on_ENGAGE_ENGINE_STARTED = (string eventExtraJson) =>
1570 {
1571 lock (_engineNotificationSubscribers)
1572 {
1573 foreach (IEngineNotifications n in _engineNotificationSubscribers)
1574 {
1575 n.onEngineStarted(eventExtraJson);
1576 }
1577 }
1578 };
1579
1580 private EngageVoidCallback on_ENGAGE_ENGINE_STOPPED = (string eventExtraJson) =>
1581 {
1582 lock (_engineNotificationSubscribers)
1583 {
1584 foreach (IEngineNotifications n in _engineNotificationSubscribers)
1585 {
1586 n.onEngineStopped(eventExtraJson);
1587 }
1588 }
1589 };
1590
1591 private EngageVoidCallback on_ENGAGE_ENGINE_AUDIO_DEVICES_REFRESHED = (string eventExtraJson) =>
1592 {
1593 lock (_engineNotificationSubscribers)
1594 {
1595 foreach (IEngineNotifications n in _engineNotificationSubscribers)
1596 {
1597 n.onEngineAudioDevicesRefreshed(eventExtraJson);
1598 }
1599 }
1600 };
1601
1602 private EngageVoidCallback on_ENGAGE_ENGINE_GROUP_BY_GROUP_PCM_POWER_LEVEL_REPORT = (string eventExtraJson) =>
1603 {
1604 lock (_engineNotificationSubscribers)
1605 {
1606 foreach (IEngineNotifications n in _engineNotificationSubscribers)
1607 {
1608 n.onEngineGroupByGroupPcmPowerLevels(eventExtraJson);
1609 }
1610 }
1611 };
1612
1613 private EngageVoidCallback on_ENGAGE_ENGINE_AUDIO_DEVICE_EVENT = (string eventExtraJson) =>
1614 {
1615 lock (_engineNotificationSubscribers)
1616 {
1617 foreach (IEngineNotifications n in _engineNotificationSubscribers)
1618 {
1619 n.onEngineAudioDevicesEvent(eventExtraJson);
1620 }
1621 }
1622 };
1623
1624 private EngageStringCallback on_ENGAGE_RP_PAUSING_CONNECTION_ATTEMPT = (string id, string eventExtraJson) =>
1625 {
1626 lock (_rallypointNotificationSubscribers)
1627 {
1628 foreach (IRallypointNotifications n in _rallypointNotificationSubscribers)
1629 {
1630 n.onRallypointPausingConnectionAttempt(id, eventExtraJson);
1631 }
1632 }
1633 };
1634
1635 private EngageStringCallback on_ENGAGE_RP_CONNECTING = (string id, string eventExtraJson) =>
1636 {
1637 lock (_rallypointNotificationSubscribers)
1638 {
1639 foreach (IRallypointNotifications n in _rallypointNotificationSubscribers)
1640 {
1641 n.onRallypointConnecting(id, eventExtraJson);
1642 }
1643 }
1644 };
1645
1646 private EngageStringCallback on_ENGAGE_RP_CONNECTED = (string id, string eventExtraJson) =>
1647 {
1648 lock (_rallypointNotificationSubscribers)
1649 {
1650 foreach (IRallypointNotifications n in _rallypointNotificationSubscribers)
1651 {
1652 n.onRallypointConnected(id, eventExtraJson);
1653 }
1654 }
1655 };
1656
1657 private EngageStringCallback on_ENGAGE_RP_DISCONNECTED = (string id, string eventExtraJson) =>
1658 {
1659 lock (_rallypointNotificationSubscribers)
1660 {
1661 foreach (IRallypointNotifications n in _rallypointNotificationSubscribers)
1662 {
1663 n.onRallypointDisconnected(id, eventExtraJson);
1664 }
1665 }
1666 };
1667
1668 private EngageStringAndTwoIntCallback on_ENGAGE_RP_ROUNDTRIP_REPORT = (string id, int rtMs, int rtRating, string eventExtraJson) =>
1669 {
1670 lock (_rallypointNotificationSubscribers)
1671 {
1672 foreach (IRallypointNotifications n in _rallypointNotificationSubscribers)
1673 {
1674 n.onRallypointRoundtripReport(id, rtMs, rtRating, eventExtraJson);
1675 }
1676 }
1677 };
1678
1679 private EngageLoggingCallback on_ENGAGE_LOG_MESSAGE_HOOK_CALLBACK = (int level, string tag, string message) =>
1680 {
1681 lock (_loggingNotificationSubscribers)
1682 {
1683 foreach (ILoggingNotifications n in _loggingNotificationSubscribers)
1684 {
1685 n.onEngageLogMessage(level, tag, message);
1686 }
1687 }
1688 };
1689
1690
1691 private EngageStringCallback on_ENGAGE_GROUP_CREATED = (string id, string eventExtraJson) =>
1692 {
1693 lock (_groupNotificationSubscribers)
1694 {
1695 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1696 {
1697 n.onGroupCreated(id, eventExtraJson);
1698 }
1699 }
1700 };
1701
1702 private EngageStringCallback on_ENGAGE_GROUP_CREATE_FAILED = (string id, string eventExtraJson) =>
1703 {
1704 lock (_groupNotificationSubscribers)
1705 {
1706 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1707 {
1708 n.onGroupCreateFailed(id, eventExtraJson);
1709 }
1710 }
1711 };
1712
1713 private EngageStringCallback on_ENGAGE_GROUP_DELETED = (string id, string eventExtraJson) =>
1714 {
1715 lock (_groupNotificationSubscribers)
1716 {
1717 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1718 {
1719 n.onGroupDeleted(id, eventExtraJson);
1720 }
1721 }
1722 };
1723
1724 private EngageStringCallback on_ENGAGE_GROUP_CONNECTED = (string id, string eventExtraJson) =>
1725 {
1726 lock (_groupNotificationSubscribers)
1727 {
1728 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1729 {
1730 n.onGroupConnected(id, eventExtraJson);
1731 }
1732 }
1733 };
1734
1735 private EngageStringCallback on_ENGAGE_GROUP_CONNECT_FAILED = (string id, string eventExtraJson) =>
1736 {
1737 lock (_groupNotificationSubscribers)
1738 {
1739 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1740 {
1741 n.onGroupConnectFailed(id, eventExtraJson);
1742 }
1743 }
1744 };
1745
1746 private EngageStringCallback on_ENGAGE_GROUP_DISCONNECTED = (string id, string eventExtraJson) =>
1747 {
1748 lock (_groupNotificationSubscribers)
1749 {
1750 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1751 {
1752 n.onGroupDisconnected(id, eventExtraJson);
1753 }
1754 }
1755 };
1756
1757 private EngageStringCallback on_ENGAGE_GROUP_JOINED = (string id, string eventExtraJson) =>
1758 {
1759 lock (_groupNotificationSubscribers)
1760 {
1761 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1762 {
1763 n.onGroupJoined(id, eventExtraJson);
1764 }
1765 }
1766 };
1767
1768 private EngageStringCallback on_ENGAGE_GROUP_JOIN_FAILED = (string id, string eventExtraJson) =>
1769 {
1770 lock (_groupNotificationSubscribers)
1771 {
1772 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1773 {
1774 n.onGroupJoinFailed(id, eventExtraJson);
1775 }
1776 }
1777 };
1778
1779 private EngageStringCallback on_ENGAGE_GROUP_LEFT = (string id, string eventExtraJson) =>
1780 {
1781 lock (_groupNotificationSubscribers)
1782 {
1783 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1784 {
1785 n.onGroupLeft(id, eventExtraJson);
1786 }
1787 }
1788 };
1789
1790 private EngageStringAndIntCallback on_ENGAGE_GROUP_MEMBER_COUNT_CHANGED = (string id, int newCount, string eventExtraJson) =>
1791 {
1792 lock (_groupNotificationSubscribers)
1793 {
1794 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1795 {
1796 n.onGroupMemberCountChanged(id, newCount, eventExtraJson);
1797 }
1798 }
1799 };
1800
1801 private EngageStringCallback on_ENGAGE_GROUP_RX_STARTED = (string id, string eventExtraJson) =>
1802 {
1803 lock (_groupNotificationSubscribers)
1804 {
1805 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1806 {
1807 n.onGroupRxStarted(id, eventExtraJson);
1808 }
1809 }
1810 };
1811
1812 private EngageStringCallback on_ENGAGE_GROUP_RX_ENDED = (string id, string eventExtraJson) =>
1813 {
1814 lock (_groupNotificationSubscribers)
1815 {
1816 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1817 {
1818 n.onGroupRxEnded(id, eventExtraJson);
1819 }
1820 }
1821 };
1822
1823 private EngageStringCallback on_ENGAGE_GROUP_RX_MUTED = (string id, string eventExtraJson) =>
1824 {
1825 lock (_groupNotificationSubscribers)
1826 {
1827 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1828 {
1829 n.onGroupRxMuted(id, eventExtraJson);
1830 }
1831 }
1832 };
1833
1834 private EngageStringCallback on_ENGAGE_GROUP_RX_UNMUTED = (string id, string eventExtraJson) =>
1835 {
1836 lock (_groupNotificationSubscribers)
1837 {
1838 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1839 {
1840 n.onGroupRxUnmuted(id, eventExtraJson);
1841 }
1842 }
1843 };
1844
1845 private EngageStringCallback on_ENGAGE_GROUP_TX_MUTED = (string id, string eventExtraJson) =>
1846 {
1847 lock (_groupNotificationSubscribers)
1848 {
1849 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1850 {
1851 n.onGroupTxMuted(id, eventExtraJson);
1852 }
1853 }
1854 };
1855
1856 private EngageStringCallback on_ENGAGE_GROUP_TX_UNMUTED = (string id, string eventExtraJson) =>
1857 {
1858 lock (_groupNotificationSubscribers)
1859 {
1860 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1861 {
1862 n.onGroupTxUnmuted(id, eventExtraJson);
1863 }
1864 }
1865 };
1866
1867 private EngageString2Callback on_ENGAGE_GROUP_RX_SPEAKERS_CHANGED = (string id, string speakerjson, string eventExtraJson) =>
1868 {
1869 lock (_groupNotificationSubscribers)
1870 {
1871 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1872 {
1873 n.onGroupRxSpeakersChanged(id, speakerjson, eventExtraJson);
1874 }
1875 }
1876 };
1877
1878 private EngageStringCallback on_ENGAGE_GROUP_TX_STARTED = (string id, string eventExtraJson) =>
1879 {
1880 lock (_groupNotificationSubscribers)
1881 {
1882 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1883 {
1884 n.onGroupTxStarted(id, eventExtraJson);
1885 }
1886 }
1887 };
1888
1889 private EngageStringCallback on_ENGAGE_GROUP_TX_ENDED = (string id, string eventExtraJson) =>
1890 {
1891 lock (_groupNotificationSubscribers)
1892 {
1893 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1894 {
1895 n.onGroupTxEnded(id, eventExtraJson);
1896 }
1897 }
1898 };
1899
1900 private EngageStringCallback on_ENGAGE_GROUP_TX_FAILED = (string id, string eventExtraJson) =>
1901 {
1902 lock (_groupNotificationSubscribers)
1903 {
1904 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1905 {
1906 n.onGroupTxFailed(id, eventExtraJson);
1907 }
1908 }
1909 };
1910
1911 private EngageStringCallback on_ENGAGE_GROUP_TX_USURPED_BY_PRIORITY = (string id, string eventExtraJson) =>
1912 {
1913 lock (_groupNotificationSubscribers)
1914 {
1915 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1916 {
1917 n.onGroupTxUsurpedByPriority(id, eventExtraJson);
1918 }
1919 }
1920 };
1921
1922 private EngageStringCallback on_ENGAGE_GROUP_MAX_TX_TIME_EXCEEDED = (string id, string eventExtraJson) =>
1923 {
1924 lock (_groupNotificationSubscribers)
1925 {
1926 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1927 {
1928 n.onGroupMaxTxTimeExceeded(id, eventExtraJson);
1929 }
1930 }
1931 };
1932
1933 private EngageString2Callback on_ENGAGE_GROUP_NODE_DISCOVERED = (string id, string nodeJson, string eventExtraJson) =>
1934 {
1935 lock (_groupNotificationSubscribers)
1936 {
1937 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1938 {
1939 n.onGroupNodeDiscovered(id, nodeJson, eventExtraJson);
1940 }
1941 }
1942 };
1943
1944 private EngageString2Callback on_ENGAGE_GROUP_NODE_REDISCOVERED = (string id, string nodeJson, string eventExtraJson) =>
1945 {
1946 lock (_groupNotificationSubscribers)
1947 {
1948 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1949 {
1950 n.onGroupNodeRediscovered(id, nodeJson, eventExtraJson);
1951 }
1952 }
1953 };
1954
1955 private EngageString2Callback on_ENGAGE_GROUP_NODE_UNDISCOVERED = (string id, string nodeJson, string eventExtraJson) =>
1956 {
1957 lock (_groupNotificationSubscribers)
1958 {
1959 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1960 {
1961 n.onGroupNodeUndiscovered(id, nodeJson, eventExtraJson);
1962 }
1963 }
1964 };
1965
1966 private EngageString2Callback on_ENGAGE_GROUP_ASSET_DISCOVERED = (string id, string nodeJson, string eventExtraJson) =>
1967 {
1968 lock (_groupNotificationSubscribers)
1969 {
1970 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1971 {
1972 n.onGroupAssetDiscovered(id, nodeJson, eventExtraJson);
1973 }
1974 }
1975 };
1976
1977 private EngageString2Callback on_ENGAGE_GROUP_ASSET_REDISCOVERED = (string id, string nodeJson, string eventExtraJson) =>
1978 {
1979 lock (_groupNotificationSubscribers)
1980 {
1981 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1982 {
1983 n.onGroupAssetRediscovered(id, nodeJson, eventExtraJson);
1984 }
1985 }
1986 };
1987
1988 private EngageString2Callback on_ENGAGE_GROUP_ASSET_UNDISCOVERED = (string id, string nodeJson, string eventExtraJson) =>
1989 {
1990 lock (_groupNotificationSubscribers)
1991 {
1992 foreach (IGroupNotifications n in _groupNotificationSubscribers)
1993 {
1994 n.onGroupAssetUndiscovered(id, nodeJson, eventExtraJson);
1995 }
1996 }
1997 };
1998
1999 private EngageVoidCallback on_ENGAGE_LICENSE_CHANGED = (string eventExtraJson) =>
2000 {
2001 lock (_licenseNotificationSubscribers)
2002 {
2003 foreach (ILicenseNotifications n in _licenseNotificationSubscribers)
2004 {
2005 n.onLicenseChanged(eventExtraJson);
2006 }
2007 }
2008 };
2009
2010 private EngageVoidCallback on_ENGAGE_LICENSE_EXPIRED = (string eventExtraJson) =>
2011 {
2012 lock (_licenseNotificationSubscribers)
2013 {
2014 foreach (ILicenseNotifications n in _licenseNotificationSubscribers)
2015 {
2016 n.onLicenseExpired(eventExtraJson);
2017 }
2018 }
2019 };
2020
2021 private EngageStringCallback on_ENGAGE_LICENSE_EXPIRING = (string secondsLeft, string eventExtraJson) =>
2022 {
2023 lock (_licenseNotificationSubscribers)
2024 {
2025 foreach (ILicenseNotifications n in _licenseNotificationSubscribers)
2026 {
2027 n.onLicenseExpiring(Double.Parse(secondsLeft), eventExtraJson);
2028 }
2029 }
2030 };
2031
2032 private EngageStringCallback on_ENGAGE_GROUP_BLOB_SENT = (string id, string eventExtraJson) =>
2033 {
2034 lock (_groupNotificationSubscribers)
2035 {
2036 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2037 {
2038 n.onGroupBlobSent(id, eventExtraJson);
2039 }
2040 }
2041 };
2042
2043 private EngageStringCallback on_ENGAGE_GROUP_BLOB_SEND_FAILED = (string id, string eventExtraJson) =>
2044 {
2045 lock (_groupNotificationSubscribers)
2046 {
2047 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2048 {
2049 n.onGroupBlobSendFailed(id, eventExtraJson);
2050 }
2051 }
2052 };
2053
2054 private EngageString2AndBlobCallback on_ENGAGE_GROUP_BLOB_RECEIVED = (string id, string blobInfoJson, IntPtr blob, int blobSize, string eventExtraJson) =>
2055 {
2056 byte[] csBlob = new byte[blobSize];
2057 Marshal.Copy(blob, csBlob, 0, blobSize);
2058
2059 lock (_groupNotificationSubscribers)
2060 {
2061 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2062 {
2063 n.onGroupBlobReceived(id, blobInfoJson, csBlob, blobSize, eventExtraJson);
2064 }
2065 }
2066
2067 // Fire some additional goodies based on the blob info payload type
2068 JObject blobInfo = JObject.Parse(blobInfoJson);
2069 if(blobInfo != null)
2070 {
2071 int payloadType = (int)blobInfo["payloadType"];
2072 string nodeId = (string)blobInfo["source"];
2073
2074 // Human biometrics ... ?
2075 if (payloadType == Engage.ENGAGE_BLOB_PT_ENGAGE_BINARY_HUMAN_BIOMETRICS)
2076 {
2077 lock (_humanBiometricsNotifications)
2078 {
2079 if (_humanBiometricsNotifications.Count > 0)
2080 {
2081 // Get the array of biometrics items from the blob
2082 string hbmJson = humanBiometricsFromBlob(csBlob);
2083
2084 if (hbmJson != null)
2085 {
2086 foreach (IHumanBiometricsNotifications n in _humanBiometricsNotifications)
2087 {
2088 n.onHumanBiometricsReceived(id, nodeId, hbmJson, eventExtraJson);
2089 }
2090 }
2091 }
2092 }
2093 }
2094 }
2095 };
2096
2097 private EngageStringCallback on_ENGAGE_GROUP_RTP_SENT = (string id, string eventExtraJson) =>
2098 {
2099 lock (_groupNotificationSubscribers)
2100 {
2101 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2102 {
2103 n.onGroupRtpSent(id, eventExtraJson);
2104 }
2105 }
2106 };
2107
2108 private EngageStringCallback on_ENGAGE_GROUP_RTP_SEND_FAILED = (string id, string eventExtraJson) =>
2109 {
2110 lock (_groupNotificationSubscribers)
2111 {
2112 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2113 {
2114 n.onGroupRtpSendFailed(id, eventExtraJson);
2115 }
2116 }
2117 };
2118
2119 private EngageString2AndBlobCallback on_ENGAGE_GROUP_RTP_RECEIVED = (string id, string rtpHeaderJson, IntPtr payload, int payloadSize, string eventExtraJson) =>
2120 {
2121 lock (_groupNotificationSubscribers)
2122 {
2123 byte[] csPayload = new byte[payloadSize];
2124 Marshal.Copy(payload, csPayload, 0, payloadSize);
2125
2126 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2127 {
2128 n.onGroupRtpReceived(id, rtpHeaderJson, csPayload, payloadSize, eventExtraJson);
2129 }
2130 }
2131 };
2132
2133 private EngageStringCallback on_ENGAGE_GROUP_RAW_SENT = (string id, string eventExtraJson) =>
2134 {
2135 lock (_groupNotificationSubscribers)
2136 {
2137 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2138 {
2139 n.onGroupRawSent(id, eventExtraJson);
2140 }
2141 }
2142 };
2143
2144 private EngageStringCallback on_ENGAGE_GROUP_RAW_SEND_FAILED = (string id, string eventExtraJson) =>
2145 {
2146 lock (_groupNotificationSubscribers)
2147 {
2148 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2149 {
2150 n.onGroupRawSendFailed(id, eventExtraJson);
2151 }
2152 }
2153 };
2154
2155 private EngageStringAndBlobCallback on_ENGAGE_GROUP_RAW_RECEIVED = (string id, IntPtr raw, int rawSize, string eventExtraJson) =>
2156 {
2157 lock (_groupNotificationSubscribers)
2158 {
2159 byte[] csRaw = new byte[rawSize];
2160 Marshal.Copy(raw, csRaw, 0, rawSize);
2161
2162 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2163 {
2164 n.onGroupRawReceived(id, csRaw, rawSize, eventExtraJson);
2165 }
2166 }
2167 };
2168
2169 private EngageString2Callback on_ENGAGE_GROUP_TIMELINE_EVENT_STARTED = (string id, string eventJson, string eventExtraJson) =>
2170 {
2171 lock (_groupNotificationSubscribers)
2172 {
2173 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2174 {
2175 n.onGroupTimelineEventStarted(id, eventJson, eventExtraJson);
2176 }
2177 }
2178 };
2179
2180 private EngageString2Callback on_ENGAGE_GROUP_TIMELINE_EVENT_UPDATED = (string id, string eventJson, string eventExtraJson) =>
2181 {
2182 lock (_groupNotificationSubscribers)
2183 {
2184 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2185 {
2186 n.onGroupTimelineEventUpdated(id, eventJson, eventExtraJson);
2187 }
2188 }
2189 };
2190
2191 private EngageString2Callback on_ENGAGE_GROUP_TIMELINE_EVENT_ENDED = (string id, string eventJson, string eventExtraJson) =>
2192 {
2193 lock (_groupNotificationSubscribers)
2194 {
2195 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2196 {
2197 n.onGroupTimelineEventEnded(id, eventJson, eventExtraJson);
2198 }
2199 }
2200 };
2201
2202 private EngageString2Callback on_ENGAGE_GROUP_TIMELINE_REPORT = (string id, string reportJson, string eventExtraJson) =>
2203 {
2204 lock (_groupNotificationSubscribers)
2205 {
2206 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2207 {
2208 n.onGroupTimelineReport(id, reportJson, eventExtraJson);
2209 }
2210 }
2211 };
2212
2213 private EngageStringCallback on_ENGAGE_GROUP_TIMELINE_REPORT_FAILED = (string id, string eventExtraJson) =>
2214 {
2215 lock (_groupNotificationSubscribers)
2216 {
2217 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2218 {
2219 n.onGroupTimelineReportFailed(id, eventExtraJson);
2220 }
2221 }
2222 };
2223
2224 private EngageString2Callback on_ENGAGE_GROUP_TIMELINE_GROOMED = (string id, string eventListJson, string eventExtraJson) =>
2225 {
2226 lock (_groupNotificationSubscribers)
2227 {
2228 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2229 {
2230 n.onGroupTimelineGroomed(id, eventListJson, eventExtraJson);
2231 }
2232 }
2233 };
2234
2235 private EngageString2Callback on_ENGAGE_GROUP_HEALTH_REPORT = (string id, string healthReportJson, string eventExtraJson) =>
2236 {
2237 lock (_groupNotificationSubscribers)
2238 {
2239 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2240 {
2241 n.onGroupHealthReport(id, healthReportJson, eventExtraJson);
2242 }
2243 }
2244 };
2245
2246 private EngageStringCallback on_ENGAGE_GROUP_HEALTH_REPORT_FAILED = (string id, string eventExtraJson) =>
2247 {
2248 lock (_groupNotificationSubscribers)
2249 {
2250 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2251 {
2252 n.onGroupHealthReportFailed(id, eventExtraJson);
2253 }
2254 }
2255 };
2256
2257 private EngageString2Callback on_ENGAGE_GROUP_STATS_REPORT = (string id, string statsReportJson, string eventExtraJson) =>
2258 {
2259 lock (_groupNotificationSubscribers)
2260 {
2261 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2262 {
2263 n.onGroupStatsReport(id, statsReportJson, eventExtraJson);
2264 }
2265 }
2266 };
2267
2268 private EngageStringCallback on_ENGAGE_GROUP_STATS_REPORT_FAILED = (string id, string eventExtraJson) =>
2269 {
2270 lock (_groupNotificationSubscribers)
2271 {
2272 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2273 {
2274 n.onGroupStatsReportFailed(id, eventExtraJson);
2275 }
2276 }
2277 };
2278
2279 private EngageStringCallback on_ENGAGE_BRIDGE_CREATED = (string id, string eventExtraJson) =>
2280 {
2281 lock (_bridgeNotificationSubscribers)
2282 {
2283 foreach (IBridgeNotifications n in _bridgeNotificationSubscribers)
2284 {
2285 n.onBridgeCreated(id, eventExtraJson);
2286 }
2287 }
2288 };
2289
2290 private EngageStringCallback on_ENGAGE_BRIDGE_CREATE_FAILED = (string id, string eventExtraJson) =>
2291 {
2292 lock (_bridgeNotificationSubscribers)
2293 {
2294 foreach (IBridgeNotifications n in _bridgeNotificationSubscribers)
2295 {
2296 n.onBridgeCreateFailed(id, eventExtraJson);
2297 }
2298 }
2299 };
2300
2301 private EngageStringCallback on_ENGAGE_BRIDGE_DELETED = (string id, string eventExtraJson) =>
2302 {
2303 lock (_bridgeNotificationSubscribers)
2304 {
2305 foreach (IBridgeNotifications n in _bridgeNotificationSubscribers)
2306 {
2307 n.onBridgeDeleted(id, eventExtraJson);
2308 }
2309 }
2310 };
2311
2312 private EngageString2AndInt2Callback on_ENGAGE_GROUP_RX_VOLUME_CHANGED = (string id, int leftLevelPerc, int rightLevelPerc, string eventExtraJson) =>
2313 {
2314 lock (_groupNotificationSubscribers)
2315 {
2316 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2317 {
2318 n.onGroupRxVolumeChanged(id, leftLevelPerc, rightLevelPerc, eventExtraJson);
2319 }
2320 }
2321 };
2322
2323 private EngageString2Callback on_ENGAGE_GROUP_RX_DTMF = (string id, string dtmfJson, string eventExtraJson) =>
2324 {
2325 lock (_groupNotificationSubscribers)
2326 {
2327 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2328 {
2329 n.onGroupRxDtmf(id, dtmfJson, eventExtraJson);
2330 }
2331 }
2332 };
2333
2334 private EngageStringCallback on_ENGAGE_GROUP_RECONFIGURED = (string id, string eventExtraJson) =>
2335 {
2336 lock (_groupNotificationSubscribers)
2337 {
2338 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2339 {
2340 n.onGroupReconfigured(id, eventExtraJson);
2341 }
2342 }
2343 };
2344
2345 private EngageStringCallback on_ENGAGE_GROUP_RECONFIGURATION_FAILED = (string id, string eventExtraJson) =>
2346 {
2347 lock (_groupNotificationSubscribers)
2348 {
2349 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2350 {
2351 n.onGroupReconfigurationFailed(id, eventExtraJson);
2352 }
2353 }
2354 };
2355
2356 private EngageStringCallback on_ENGAGE_AUDIO_RECORDING_STARTED = (string id, string eventExtraJson) =>
2357 {
2358 lock (_groupNotificationSubscribers)
2359 {
2360 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2361 {
2362 n.onGroupAudioRecordingStarted(id, eventExtraJson);
2363 }
2364 }
2365 };
2366
2367 private EngageStringCallback on_ENGAGE_AUDIO_RECORDING_FAILED = (string id, string eventExtraJson) =>
2368 {
2369 lock (_groupNotificationSubscribers)
2370 {
2371 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2372 {
2373 n.onGroupAudioRecordingFailed(id, eventExtraJson);
2374 }
2375 }
2376 };
2377
2378 private EngageStringCallback on_ENGAGE_AUDIO_RECORDING_ENDED = (string id, string eventExtraJson) =>
2379 {
2380 lock (_groupNotificationSubscribers)
2381 {
2382 foreach (IGroupNotifications n in _groupNotificationSubscribers)
2383 {
2384 n.onGroupAudioRecordingEnded(id, eventExtraJson);
2385 }
2386 }
2387 };
2388
2389 #endregion
2390
2391 #region Public functions
2392 public Engage()
2393 {
2394 engageEnableNotifications(0);
2395 engageWin32LibraryInit();
2396 engageEnableNotifications(1);
2397 }
2398
2399 ~Engage()
2400 {
2401 engageEnableNotifications(0);
2402 engageShutdown();
2403 engageWin32LibraryDeinit();
2404 }
2405
2406 public void subscribe(IEngineNotifications n)
2407 {
2408 lock(_engineNotificationSubscribers)
2409 {
2410 _engineNotificationSubscribers.Add(n);
2411 }
2412 }
2413
2414 public void unsubscribe(IEngineNotifications n)
2415 {
2416 lock (_engineNotificationSubscribers)
2417 {
2418 _engineNotificationSubscribers.Remove(n);
2419 }
2420 }
2421
2422 public void subscribe(IRallypointNotifications n)
2423 {
2424 lock (_rallypointNotificationSubscribers)
2425 {
2426 _rallypointNotificationSubscribers.Add(n);
2427 }
2428 }
2429
2430 public void unsubscribe(IRallypointNotifications n)
2431 {
2432 lock (_rallypointNotificationSubscribers)
2433 {
2434 _rallypointNotificationSubscribers.Remove(n);
2435 }
2436 }
2437
2438 public void subscribe(IGroupNotifications n)
2439 {
2440 lock (_groupNotificationSubscribers)
2441 {
2442 _groupNotificationSubscribers.Add(n);
2443 }
2444 }
2445
2446 public void unsubscribe(IGroupNotifications n)
2447 {
2448 lock (_groupNotificationSubscribers)
2449 {
2450 _groupNotificationSubscribers.Remove(n);
2451 }
2452 }
2453
2454 public void subscribe(ILicenseNotifications n)
2455 {
2456 lock (_licenseNotificationSubscribers)
2457 {
2458 _licenseNotificationSubscribers.Add(n);
2459 }
2460 }
2461
2462 public void unsubscribe(ILicenseNotifications n)
2463 {
2464 lock (_licenseNotificationSubscribers)
2465 {
2466 _licenseNotificationSubscribers.Remove(n);
2467 }
2468 }
2469
2470 public void subscribe(IHumanBiometricsNotifications n)
2471 {
2472 lock (_humanBiometricsNotifications)
2473 {
2474 _humanBiometricsNotifications.Add(n);
2475 }
2476 }
2477
2478 public void unsubscribe(IHumanBiometricsNotifications n)
2479 {
2480 lock (_humanBiometricsNotifications)
2481 {
2482 _humanBiometricsNotifications.Remove(n);
2483 }
2484 }
2485
2486 public void subscribe(IBridgeNotifications n)
2487 {
2488 lock (_bridgeNotificationSubscribers)
2489 {
2490 _bridgeNotificationSubscribers.Add(n);
2491 }
2492 }
2493
2494 public void unsubscribe(IBridgeNotifications n)
2495 {
2496 lock (_bridgeNotificationSubscribers)
2497 {
2498 _bridgeNotificationSubscribers.Remove(n);
2499 }
2500 }
2501
2502 public void subscribe(ILoggingNotifications n)
2503 {
2504 lock (_loggingNotificationSubscribers)
2505 {
2506 _loggingNotificationSubscribers.Add(n);
2507
2508 if(_loggingNotificationSubscribers.Count() == 1)
2509 {
2510 engageSetLoggingOutputOverride(on_ENGAGE_LOG_MESSAGE_HOOK_CALLBACK);
2511 }
2512 }
2513 }
2514
2515 public void unsubscribe(ILoggingNotifications n)
2516 {
2517 lock (_loggingNotificationSubscribers)
2518 {
2519 _loggingNotificationSubscribers.Remove(n);
2520
2521 if(_loggingNotificationSubscribers.Count() == 0)
2522 {
2523 engageSetLoggingOutputOverride(null);
2524 }
2525 }
2526 }
2527
2528 public void subscribe(IAudioRecordingNotifications n)
2529 {
2530 lock (_audioRecordingNotificationSubscribers)
2531 {
2532 _audioRecordingNotificationSubscribers.Add(n);
2533 }
2534 }
2535
2536 public void unsubscribe(IAudioRecordingNotifications n)
2537 {
2538 lock (_audioRecordingNotificationSubscribers)
2539 {
2540 _audioRecordingNotificationSubscribers.Remove(n);
2541 }
2542 }
2543
2544 public void win32Init()
2545 {
2546 engageWin32LibraryInit();
2547 }
2548
2549 public void win32DeInit()
2550 {
2551 engageWin32LibraryDeinit();
2552 }
2553
2554 public int initialize(string enginePolicyConfiguration, string userIdentity, string tempStoragePath)
2555 {
2556 int rc;
2557
2558 rc = registerEventCallbacks();
2559 if(rc != ENGAGE_RESULT_OK)
2560 {
2561 return rc;
2562 }
2563
2564 return engageInitialize(enginePolicyConfiguration, userIdentity, tempStoragePath);
2565 }
2566
2567 public int shutdown()
2568 {
2569 engageShutdown();
2570
2571 return 0;
2572 }
2573
2574 public int start()
2575 {
2576 return engageStart();
2577 }
2578
2579 public int stop()
2580 {
2581 return engageStop();
2582 }
2583
2584 public int createGroup(string jsonConfiguration)
2585 {
2586 return engageCreateGroup(jsonConfiguration);
2587 }
2588
2589 public int deleteGroup(string id)
2590 {
2591 return engageDeleteGroup(id);
2592 }
2593
2594 public int joinGroup(string id)
2595 {
2596 return engageJoinGroup(id);
2597 }
2598
2599 public int leaveGroup(string id)
2600 {
2601 return engageLeaveGroup(id);
2602 }
2603
2604 public int setGroupRules(string id, string jsonParams)
2605 {
2606 return engageSetGroupRules(id, jsonParams);
2607 }
2608
2609 public int beginGroupTx(string id, int txPriority, int txFlags)
2610 {
2611 return engageBeginGroupTx(id, txPriority, txFlags);
2612 }
2613
2614 public int beginGroupTxAdvanced(string id, string jsonParams)
2615 {
2616 return engageBeginGroupTxAdvanced(id, jsonParams);
2617 }
2618
2619 public int endGroupTx(string id)
2620 {
2621 return engageEndGroupTx(id);
2622 }
2623
2624 public int setGroupRxTag(string id, int tag)
2625 {
2626 return engageSetGroupRxTag(id, tag);
2627 }
2628
2629 public int muteGroupRx(string id)
2630 {
2631 return engageMuteGroupRx(id);
2632 }
2633
2634 public int unmuteGroupRx(string id)
2635 {
2636 return engageUnmuteGroupRx(id);
2637 }
2638
2639 public int muteGroupTx(string id)
2640 {
2641 return engageMuteGroupTx(id);
2642 }
2643
2644 public int unmuteGroupTx(string id)
2645 {
2646 return engageUnmuteGroupTx(id);
2647 }
2648
2649 public int setGroupRxVolume(string id, int left, int right)
2650 {
2651 return engageSetGroupRxVolume(id, left, right);
2652 }
2653
2654 public int queryGroupTimeline(string id, string jsonParams)
2655 {
2656 return engageQueryGroupTimeline(id, jsonParams);
2657 }
2658
2659 public int queryGroupHealth(string id)
2660 {
2661 return engageQueryGroupHealth(id);
2662 }
2663
2664 public int queryGroupStats(string id)
2665 {
2666 return engageQueryGroupStats(id);
2667 }
2668
2669 public int logMsg(int level, string tag, string msg)
2670 {
2671 return engageLogMsg(level, tag, msg);
2672 }
2673
2674 public int setLogLevel(int level)
2675 {
2676 return engageSetLogLevel(level);
2677 }
2678
2679 public int setLogTagExtensionLevel(string tagExtension)
2680 {
2681 return engageSetLogTagExtension(tagExtension);
2682 }
2683
2684 public int enableSyslog(bool enable)
2685 {
2686 return engageEnableSyslog(enable ? 1 : 0);
2687 }
2688
2689 public int enableWatchdog(bool enable)
2690 {
2691 return engageWatchdog(enable ? 1 : 0);
2692 }
2693
2694 public String getVersion()
2695 {
2696 IntPtr ptr = engageGetVersion();
2697
2698 if (ptr == IntPtr.Zero)
2699 {
2700 return null;
2701 }
2702 else
2703 {
2704 return Marshal.PtrToStringAnsi(ptr);
2705 }
2706 }
2707
2708 public String getHardwareReport()
2709 {
2710 IntPtr ptr = engageGetHardwareReport();
2711
2712 if (ptr == IntPtr.Zero)
2713 {
2714 return null;
2715 }
2716 else
2717 {
2718 return Marshal.PtrToStringAnsi(ptr);
2719 }
2720 }
2721
2722 public String getActiveLicenseDescriptor()
2723 {
2724 IntPtr ptr = engageGetActiveLicenseDescriptor();
2725
2726 if (ptr == IntPtr.Zero)
2727 {
2728 return null;
2729 }
2730 else
2731 {
2732 return Marshal.PtrToStringAnsi(ptr);
2733 }
2734 }
2735
2736 public String getLicenseDescriptor(string entitlement, string key, string activationCode, string manufacturerId)
2737 {
2738 IntPtr ptr = engageGetLicenseDescriptor(entitlement, key, activationCode, manufacturerId);
2739
2740 if (ptr == IntPtr.Zero)
2741 {
2742 return null;
2743 }
2744 else
2745 {
2746 return Marshal.PtrToStringAnsi(ptr);
2747 }
2748 }
2749
2750 public int updateLicense(string entitlement, string key, string activationCode, string manufacturerId)
2751 {
2752 return engageUpdateLicense(entitlement, key, activationCode, manufacturerId);
2753 }
2754
2755 public String getNetworkInterfaceDevices()
2756 {
2757 IntPtr ptr = engageGetNetworkInterfaceDevices();
2758
2759 if (ptr == IntPtr.Zero)
2760 {
2761 return null;
2762 }
2763 else
2764 {
2765 return Marshal.PtrToStringAnsi(ptr);
2766 }
2767 }
2768
2769 public String getAudioDevices()
2770 {
2771 IntPtr ptr = engageGetAudioDevices();
2772
2773 if (ptr == IntPtr.Zero)
2774 {
2775 return null;
2776 }
2777 else
2778 {
2779 return Marshal.PtrToStringAnsi(ptr);
2780 }
2781 }
2782
2783 public int setMissionId(string missionId)
2784 {
2785 return engageSetMissionId(missionId);
2786 }
2787
2788 public int openCertStore(string fileName, string passwordHexByteString)
2789 {
2790 return engageOpenCertStore(fileName, passwordHexByteString);
2791 }
2792
2793 public String getCertStoreDescriptor()
2794 {
2795 IntPtr ptr = engageGetCertStoreDescriptor();
2796
2797 if (ptr == IntPtr.Zero)
2798 {
2799 return null;
2800 }
2801 else
2802 {
2803 return Marshal.PtrToStringAnsi(ptr);
2804 }
2805 }
2806
2807 public int closeCertStore()
2808 {
2809 return engageCloseCertStore();
2810 }
2811
2812 public int setCertStoreCertificatePem(string id, string certificatePem, string privateKeyPem, string tags)
2813 {
2814 return engageSetCertStoreCertificatePem(id, certificatePem, privateKeyPem, tags);
2815 }
2816
2817 public int setCertStoreCertificateP12(string id, byte[] data, int size, string password, string tags)
2818 {
2819 IntPtr pinned_data = Marshal.AllocHGlobal(size);
2820 Marshal.Copy(data, 0, pinned_data, size);
2821 int rc = engageSetCertStoreCertificateP12(id, pinned_data, size, password, tags);
2822 Marshal.FreeHGlobal(pinned_data);
2823
2824 return rc;
2825 }
2826
2827 public int deleteCertStoreCertificate(string id)
2828 {
2829 return engageDeleteCertStoreCertificate(id);
2830 }
2831
2832 public String getCertStoreCertificatePem(string id)
2833 {
2834 IntPtr ptr = engageGetCertStoreCertificatePem(id);
2835
2836 if (ptr == IntPtr.Zero)
2837 {
2838 return null;
2839 }
2840 else
2841 {
2842 return Marshal.PtrToStringAnsi(ptr);
2843 }
2844 }
2845
2846 public String getArrayOfCertificateDescriptorsFromPem(string pem)
2847 {
2848 IntPtr ptr = engageGetArrayOfCertificateDescriptorsFromPem(pem);
2849
2850 if (ptr == IntPtr.Zero)
2851 {
2852 return null;
2853 }
2854 else
2855 {
2856 return Marshal.PtrToStringAnsi(ptr);
2857 }
2858 }
2859
2860 public String getCertificateDescriptorFromPem(string pem)
2861 {
2862 IntPtr ptr = engageGetCertificateDescriptorFromPem(pem);
2863
2864 if (ptr == IntPtr.Zero)
2865 {
2866 return null;
2867 }
2868 else
2869 {
2870 return Marshal.PtrToStringAnsi(ptr);
2871 }
2872 }
2873
2874 public int importCertStoreElementFromCertStore(string id, string srcId, string srcFileName, string srcPasswordHexByteString, string tags)
2875 {
2876 return engageImportCertStoreElementFromCertStore(id, srcId, srcFileName, srcPasswordHexByteString, tags);
2877 }
2878
2879 public String queryCertStoreContents(string fileName, string passwordHexByteString)
2880 {
2881 IntPtr ptr = engageQueryCertStoreContents(fileName, passwordHexByteString);
2882
2883 if (ptr == IntPtr.Zero)
2884 {
2885 return null;
2886 }
2887 else
2888 {
2889 return Marshal.PtrToStringAnsi(ptr);
2890 }
2891 }
2892
2893 public int encrypt(byte[] src, int size, out byte[] dst, string passwordHexByteString)
2894 {
2895 // Make a copy of the source
2896 IntPtr pinned_src = Marshal.AllocHGlobal(size);
2897 Marshal.Copy(src, 0, pinned_src, size);
2898
2899 // Allocate a destination - at least the size of the source + 16 for AES sizing + 16 for IV
2900 IntPtr pinned_dst = Marshal.AllocHGlobal(size + 16 + 16);
2901
2902 int bytesEncrypted = engageEncrypt(pinned_src, size, pinned_dst, passwordHexByteString);
2903
2904 if(bytesEncrypted > 0)
2905 {
2906 dst = new byte[bytesEncrypted];
2907 Marshal.Copy(pinned_dst, dst, 0, bytesEncrypted);
2908 }
2909 else
2910 {
2911 dst = null;
2912 }
2913
2914 // Cleanup
2915 Marshal.FreeHGlobal(pinned_src);
2916 Marshal.FreeHGlobal(pinned_dst);
2917
2918 return bytesEncrypted;
2919 }
2920
2921 public int decrypt(byte[] src, int size, out byte[] dst, string passwordHexByteString)
2922 {
2923 // Make a copy of the source
2924 IntPtr pinned_src = Marshal.AllocHGlobal(size);
2925 Marshal.Copy(src, 0, pinned_src, size);
2926
2927 // Allocate a destination - at least the size of the source + 16 for AES sizing
2928 IntPtr pinned_dst = Marshal.AllocHGlobal(size + 16);
2929
2930 int bytesDecrypted = engageDecrypt(pinned_src, size, pinned_dst, passwordHexByteString);
2931
2932 if (bytesDecrypted > 0)
2933 {
2934 dst = new byte[bytesDecrypted];
2935 Marshal.Copy(pinned_dst, dst, 0, bytesDecrypted);
2936 }
2937 else
2938 {
2939 dst = null;
2940 }
2941
2942 // Cleanup
2943 Marshal.FreeHGlobal(pinned_src);
2944 Marshal.FreeHGlobal(pinned_dst);
2945
2946 return bytesDecrypted;
2947 }
2948
2949 /*
2950 public int compress(byte[] src, int size, out byte[] dst)
2951 {
2952 int compressedSize = 0;
2953
2954 IntPtr pinned_src = Marshal.AllocHGlobal(size);
2955 Marshal.Copy(src, 0, pinned_src, size);
2956
2957 int dstLen = (size + 64);
2958 IntPtr pinned_dst = 0;
2959
2960 while( true )
2961 {
2962 dstLen *= 2;
2963
2964 if(pinned_dst != 0)
2965 {
2966 Marshal.FreeHGlobal(pinned_dst);
2967 }
2968
2969 pinned_dst = Marshal.AllocHGlobal(dstLen);
2970
2971 compressedSize = engageCompress(pinned_src, size, pinned_dst, dstLen);
2972
2973 if(compressedSize > 0)
2974 {
2975 dst = new byte[compressedSize];
2976 Marshal.Copy(pinned_dst, dst, 0, compressedSize);
2977 break;
2978 }
2979 else
2980 {
2981 if(compressedSize != ENGAGE_RESULT_INSUFFICIENT_DESTINATION_SPACE)
2982 {
2983 compressedSize = 0;
2984 break;
2985 }
2986 }
2987 }
2988
2989 Marshal.FreeHGlobal(pinned_src);
2990
2991 if(pinned_dst != 0)
2992 {
2993 Marshal.FreeHGlobal(pinned_dst);
2994 }
2995
2996 return compressedSize;
2997 }
2998
2999 public int decompress(byte[] src, int size, out byte[] dst)
3000 {
3001 int decompressedSize = 0;
3002
3003 IntPtr pinned_src = Marshal.AllocHGlobal(size);
3004 Marshal.Copy(src, 0, pinned_src, size);
3005
3006 int dstLen = ((size + 64) * 4);
3007 IntPtr pinned_dst = 0;
3008
3009 while( true )
3010 {
3011 dstLen *= 2;
3012
3013 if(pinned_dst != 0)
3014 {
3015 Marshal.FreeHGlobal(pinned_dst);
3016 }
3017
3018 pinned_dst = Marshal.AllocHGlobal(dstLen);
3019
3020 decompressedSize = engageDecompress(pinned_src, size, pinned_dst, dstLen);
3021
3022 if(decompressedSize > 0)
3023 {
3024 dst = new byte[decompressedSize];
3025 Marshal.Copy(pinned_dst, dst, 0, decompressedSize);
3026 break;
3027 }
3028 else
3029 {
3030 if(decompressedSize != ENGAGE_RESULT_INSUFFICIENT_DESTINATION_SPACE)
3031 {
3032 decompressedSize = 0;
3033 break;
3034 }
3035 }
3036 }
3037
3038 Marshal.FreeHGlobal(pinned_src);
3039
3040 if(pinned_dst != 0)
3041 {
3042 Marshal.FreeHGlobal(pinned_dst);
3043 }
3044
3045 return decompressedSize;
3046 }
3047 */
3048
3049 public String generateMission(string keyPhrase, int audioGroupCount, string rallypointHost, string missionName)
3050 {
3051 IntPtr ptr = engageGenerateMission(keyPhrase, audioGroupCount, rallypointHost, missionName);
3052
3053 if (ptr == IntPtr.Zero)
3054 {
3055 return null;
3056 }
3057 else
3058 {
3059 return Marshal.PtrToStringAnsi(ptr);
3060 }
3061 }
3062
3063 public String generateMissionUsingCertStore(string keyPhrase, int audioGroupCount, string rallypointHost, string missionName, string certStoreFn, string certStorePasswordHexByteString, string certStoreElement)
3064 {
3065 IntPtr ptr = engageGenerateMissionUsingCertStore(keyPhrase, audioGroupCount, rallypointHost, missionName, certStoreFn, certStorePasswordHexByteString, certStoreElement);
3066
3067 if (ptr == IntPtr.Zero)
3068 {
3069 return null;
3070 }
3071 else
3072 {
3073 return Marshal.PtrToStringAnsi(ptr);
3074 }
3075 }
3076
3077 public int updatePresenceDescriptor(string id, string jsonDescriptor, bool forceBeacon)
3078 {
3079 return engageUpdatePresenceDescriptor(id, jsonDescriptor, (forceBeacon ? 1 : 0));
3080 }
3081
3082 public int setFipsCrypto(string jsonParams)
3083 {
3084 return engageSetFipsCrypto(jsonParams);
3085 }
3086
3087 public bool isCryptoFipsValidated()
3088 {
3089 return (engageIsCryptoFipsValidated() == 1 ? true : false);
3090 }
3091
3092 public int beginGroupPcmPowerTracking(string id)
3093 {
3094 return engageBeginGroupPcmPowerTracking(id);
3095 }
3096
3097 public int endGroupPcmPowerTracking(string id)
3098 {
3099 return engageEndGroupPcmPowerTracking(id);
3100 }
3101
3102 #endregion
3103
3104 #region Helpers
3105
3106 public static uint swapEndianness(uint x)
3107 {
3108 return ((x & 0x000000ff) << 24) + // First byte
3109 ((x & 0x0000ff00) << 8) + // Second byte
3110 ((x & 0x00ff0000) >> 8) + // Third byte
3111 ((x & 0xff000000) >> 24); // Fourth byte
3112 }
3113
3114 public static string humanBiometricsFromBlob(byte[] blob)
3115 {
3116 JArray dataSeriesArray;
3117
3118 try
3119 {
3120 // Create our enclosing human biometrics object - its a JSON array
3121 dataSeriesArray = new JArray();
3122
3123 // The total number of bytes we have available to us
3124 int bytesLeftInTheBlob = blob.Length;
3125
3126 // Lock down the blob's memory
3127 GCHandle pinnedBlob = GCHandle.Alloc(blob, GCHandleType.Pinned);
3128
3129 // Get the pointer to the start of the byte array
3130 IntPtr ptr = pinnedBlob.AddrOfPinnedObject();
3131
3132 // Our blob may have multiple elements, so we'll loop
3133 while(bytesLeftInTheBlob > 0)
3134 {
3135 // Marshal in the header
3136 DataSeriesHeader hdr = (DataSeriesHeader)Marshal.PtrToStructure(ptr, typeof(DataSeriesHeader));
3137
3138 // On little endian CPUs we need to swap from big endian (network byte order)
3139 if (BitConverter.IsLittleEndian)
3140 {
3141 hdr.ts = swapEndianness(hdr.ts);
3142 }
3143
3144 // Make a series element
3145 JObject se = new JObject();
3146
3147 // Fill out its basic data
3148 se["t"] = (int)hdr.t;
3149 se["ts"] = hdr.ts;
3150 se["it"] = (int)hdr.it;
3151 se["im"] = (int)hdr.im;
3152 se["vt"] = (int)hdr.vt;
3153
3154 // Jump forward by the size of the header (9 bytes) to point at the beginning of the data
3155 ptr = IntPtr.Add(ptr, 9);
3156 bytesLeftInTheBlob -= 9;
3157
3158 // Now go through the data if we have any
3159 if (hdr.ss > 0)
3160 {
3161 JArray s = new JArray();
3162
3163 if (hdr.vt == 1)
3164 {
3165 for (byte x = 0; x < hdr.ss; x++)
3166 {
3167 DataElementUint8 de = (DataElementUint8)Marshal.PtrToStructure(ptr, typeof(DataElementUint8));
3168
3169 s.Add((int)de.ofs);
3170 s.Add((int)de.val);
3171
3172 ptr = IntPtr.Add(ptr, 2);
3173 bytesLeftInTheBlob -= 2;
3174 }
3175 }
3176 else if (hdr.vt == 2)
3177 {
3178 // TODO : process 16-bit numbers
3179 }
3180 else if (hdr.vt == 3)
3181 {
3182 // TODO : process 32-bit numbers
3183 }
3184 else if (hdr.vt == 4)
3185 {
3186 // TODO : process 64-bit numbers
3187 }
3188
3189 // Plug the series array into the current seriesElement
3190 se["s"] = s;
3191 }
3192
3193 // Add the series element
3194 dataSeriesArray.Add(se);
3195 }
3196
3197 pinnedBlob.Free();
3198 }
3199 catch(Exception e)
3200 {
3201 dataSeriesArray = null;
3202 Trace.WriteLine(e.StackTrace);
3203 }
3204
3205 string rc = null;
3206
3207 if(dataSeriesArray != null)
3208 {
3209 JObject hbmData = new JObject();
3210 hbmData["data"] = dataSeriesArray;
3211 rc = hbmData.ToString();
3212 }
3213
3214 return rc;
3215 }
3216
3217 public int platformNotifyChanges(string jsonChangesArray)
3218 {
3219 return engagePlatformNotifyChanges(jsonChangesArray);
3220 }
3221
3222 public String getDeviceId()
3223 {
3224 IntPtr ptr = engageGetDeviceId();
3225
3226 if (ptr == IntPtr.Zero)
3227 {
3228 return null;
3229 }
3230 else
3231 {
3232 return Marshal.PtrToStringAnsi(ptr);
3233 }
3234 }
3235
3236 public int verifyRiff(string fn)
3237 {
3238 return engageVerifyRiff(fn);
3239 }
3240
3241 public String getRiffDescriptor(string fn)
3242 {
3243 IntPtr ptr = engageGetRiffDescriptor(fn);
3244
3245 if (ptr == IntPtr.Zero)
3246 {
3247 return null;
3248 }
3249 else
3250 {
3251 return Marshal.PtrToStringAnsi(ptr);
3252 }
3253 }
3254
3255 #endregion
3256}
struct _EngageEvents_t EngageEvents_t
Event Handlers Struct.
Event Handlers Struct.