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