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