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