hap-nodejs 1.1.1-beta.5 → 1.1.1-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/@types/bonjour-hap.d.ts +53 -50
  2. package/@types/simple-plist.d.ts +4 -0
  3. package/README.md +19 -16
  4. package/dist/accessories/AirConditioner_accessory.js +32 -30
  5. package/dist/accessories/AirConditioner_accessory.js.map +1 -1
  6. package/dist/accessories/AppleTVRemote_accessory.js +86 -74
  7. package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
  8. package/dist/accessories/Camera_accessory.js +138 -143
  9. package/dist/accessories/Camera_accessory.js.map +1 -1
  10. package/dist/accessories/Fan_accessory.js +24 -20
  11. package/dist/accessories/Fan_accessory.js.map +1 -1
  12. package/dist/accessories/GarageDoorOpener_accessory.js +37 -35
  13. package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
  14. package/dist/accessories/Light-AdaptiveLighting_accessory.js +46 -44
  15. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
  16. package/dist/accessories/Light_accessory.js +36 -34
  17. package/dist/accessories/Light_accessory.js.map +1 -1
  18. package/dist/accessories/Lock_accessory.js +28 -27
  19. package/dist/accessories/Lock_accessory.js.map +1 -1
  20. package/dist/accessories/MotionSensor_accessory.js +18 -15
  21. package/dist/accessories/MotionSensor_accessory.js.map +1 -1
  22. package/dist/accessories/Outlet_accessory.js +24 -22
  23. package/dist/accessories/Outlet_accessory.js.map +1 -1
  24. package/dist/accessories/SmartSpeaker_accessory.js +22 -20
  25. package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
  26. package/dist/accessories/Sprinkler_accessory.js +39 -36
  27. package/dist/accessories/Sprinkler_accessory.js.map +1 -1
  28. package/dist/accessories/TV_accessory.js +47 -45
  29. package/dist/accessories/TV_accessory.js.map +1 -1
  30. package/dist/accessories/TemperatureSensor_accessory.js +17 -14
  31. package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
  32. package/dist/accessories/Wi-FiRouter_accessory.d.ts +1 -1
  33. package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +1 -1
  34. package/dist/accessories/Wi-FiRouter_accessory.js +14 -11
  35. package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
  36. package/dist/accessories/Wi-FiSatellite_accessory.d.ts +1 -1
  37. package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +1 -1
  38. package/dist/accessories/Wi-FiSatellite_accessory.js +16 -13
  39. package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
  40. package/dist/accessories/gstreamer-audioProducer.d.ts +3 -3
  41. package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -1
  42. package/dist/accessories/gstreamer-audioProducer.js +39 -38
  43. package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
  44. package/dist/accessories/types.d.ts +63 -63
  45. package/dist/accessories/types.d.ts.map +1 -1
  46. package/dist/accessories/types.js +87 -83
  47. package/dist/accessories/types.js.map +1 -1
  48. package/dist/index.d.ts +28 -26
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +34 -40
  51. package/dist/index.js.map +1 -1
  52. package/dist/internal-types.d.ts +1 -1
  53. package/dist/internal-types.d.ts.map +1 -1
  54. package/dist/internal-types.js +21 -19
  55. package/dist/internal-types.js.map +1 -1
  56. package/dist/lib/Accessory.d.ts +37 -38
  57. package/dist/lib/Accessory.d.ts.map +1 -1
  58. package/dist/lib/Accessory.js +299 -289
  59. package/dist/lib/Accessory.js.map +1 -1
  60. package/dist/lib/Advertiser.d.ts +7 -7
  61. package/dist/lib/Advertiser.d.ts.map +1 -1
  62. package/dist/lib/Advertiser.js +136 -128
  63. package/dist/lib/Advertiser.js.map +1 -1
  64. package/dist/lib/Bridge.d.ts +1 -1
  65. package/dist/lib/Bridge.d.ts.map +1 -1
  66. package/dist/lib/Bridge.js +6 -2
  67. package/dist/lib/Bridge.js.map +1 -1
  68. package/dist/lib/Characteristic.d.ts +41 -40
  69. package/dist/lib/Characteristic.d.ts.map +1 -1
  70. package/dist/lib/Characteristic.js +210 -206
  71. package/dist/lib/Characteristic.js.map +1 -1
  72. package/dist/lib/HAPServer.d.ts +30 -35
  73. package/dist/lib/HAPServer.d.ts.map +1 -1
  74. package/dist/lib/HAPServer.js +229 -225
  75. package/dist/lib/HAPServer.js.map +1 -1
  76. package/dist/lib/Service.d.ts +22 -22
  77. package/dist/lib/Service.d.ts.map +1 -1
  78. package/dist/lib/Service.js +71 -67
  79. package/dist/lib/Service.js.map +1 -1
  80. package/dist/lib/camera/RTPProxy.d.ts +1 -2
  81. package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
  82. package/dist/lib/camera/RTPProxy.js +44 -28
  83. package/dist/lib/camera/RTPProxy.js.map +1 -1
  84. package/dist/lib/camera/RTPStreamManagement.d.ts +33 -34
  85. package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
  86. package/dist/lib/camera/RTPStreamManagement.js +149 -181
  87. package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
  88. package/dist/lib/camera/RecordingManagement.d.ts +17 -19
  89. package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
  90. package/dist/lib/camera/RecordingManagement.js +153 -162
  91. package/dist/lib/camera/RecordingManagement.js.map +1 -1
  92. package/dist/lib/camera/index.d.ts +3 -3
  93. package/dist/lib/camera/index.d.ts.map +1 -1
  94. package/dist/lib/camera/index.js +6 -3
  95. package/dist/lib/camera/index.js.map +1 -1
  96. package/dist/lib/controller/AdaptiveLightingController.d.ts +33 -33
  97. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
  98. package/dist/lib/controller/AdaptiveLightingController.js +146 -154
  99. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
  100. package/dist/lib/controller/CameraController.d.ts +20 -22
  101. package/dist/lib/controller/CameraController.d.ts.map +1 -1
  102. package/dist/lib/controller/CameraController.js +78 -74
  103. package/dist/lib/controller/CameraController.js.map +1 -1
  104. package/dist/lib/controller/Controller.d.ts +4 -4
  105. package/dist/lib/controller/Controller.d.ts.map +1 -1
  106. package/dist/lib/controller/Controller.js +8 -5
  107. package/dist/lib/controller/Controller.js.map +1 -1
  108. package/dist/lib/controller/DoorbellController.d.ts +4 -5
  109. package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
  110. package/dist/lib/controller/DoorbellController.js +13 -9
  111. package/dist/lib/controller/DoorbellController.js.map +1 -1
  112. package/dist/lib/controller/RemoteController.d.ts +37 -39
  113. package/dist/lib/controller/RemoteController.d.ts.map +1 -1
  114. package/dist/lib/controller/RemoteController.js +199 -210
  115. package/dist/lib/controller/RemoteController.js.map +1 -1
  116. package/dist/lib/controller/index.d.ts +5 -5
  117. package/dist/lib/controller/index.d.ts.map +1 -1
  118. package/dist/lib/controller/index.js +8 -5
  119. package/dist/lib/controller/index.js.map +1 -1
  120. package/dist/lib/datastream/DataStreamManagement.d.ts +2 -2
  121. package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -1
  122. package/dist/lib/datastream/DataStreamManagement.js +40 -40
  123. package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
  124. package/dist/lib/datastream/DataStreamParser.d.ts +0 -1
  125. package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
  126. package/dist/lib/datastream/DataStreamParser.js +77 -57
  127. package/dist/lib/datastream/DataStreamParser.js.map +1 -1
  128. package/dist/lib/datastream/DataStreamServer.d.ts +22 -27
  129. package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
  130. package/dist/lib/datastream/DataStreamServer.js +164 -159
  131. package/dist/lib/datastream/DataStreamServer.js.map +1 -1
  132. package/dist/lib/datastream/index.d.ts +3 -3
  133. package/dist/lib/datastream/index.d.ts.map +1 -1
  134. package/dist/lib/datastream/index.js +6 -3
  135. package/dist/lib/datastream/index.js.map +1 -1
  136. package/dist/lib/definitions/CharacteristicDefinitions.d.ts +1 -1
  137. package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
  138. package/dist/lib/definitions/CharacteristicDefinitions.js +1203 -957
  139. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
  140. package/dist/lib/definitions/ServiceDefinitions.d.ts +1 -1
  141. package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
  142. package/dist/lib/definitions/ServiceDefinitions.js +695 -620
  143. package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
  144. package/dist/lib/definitions/generate-definitions.d.ts +3 -3
  145. package/dist/lib/definitions/generate-definitions.d.ts.map +1 -1
  146. package/dist/lib/definitions/generate-definitions.js +259 -247
  147. package/dist/lib/definitions/generate-definitions.js.map +1 -1
  148. package/dist/lib/definitions/generator-configuration.d.ts +1 -1
  149. package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
  150. package/dist/lib/definitions/generator-configuration.js +181 -176
  151. package/dist/lib/definitions/generator-configuration.js.map +1 -1
  152. package/dist/lib/definitions/index.d.ts +2 -2
  153. package/dist/lib/definitions/index.d.ts.map +1 -1
  154. package/dist/lib/definitions/index.js +5 -2
  155. package/dist/lib/definitions/index.js.map +1 -1
  156. package/dist/lib/gen/HomeKit.d.ts +7 -0
  157. package/dist/lib/gen/HomeKit.d.ts.map +1 -0
  158. package/dist/lib/gen/HomeKit.js +8 -0
  159. package/dist/lib/gen/HomeKit.js.map +1 -0
  160. package/dist/lib/model/AccessoryInfo.d.ts +3 -4
  161. package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
  162. package/dist/lib/model/AccessoryInfo.js +55 -52
  163. package/dist/lib/model/AccessoryInfo.js.map +1 -1
  164. package/dist/lib/model/ControllerStorage.d.ts +3 -3
  165. package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
  166. package/dist/lib/model/ControllerStorage.js +23 -18
  167. package/dist/lib/model/ControllerStorage.js.map +1 -1
  168. package/dist/lib/model/HAPStorage.d.ts +2 -2
  169. package/dist/lib/model/HAPStorage.d.ts.map +1 -1
  170. package/dist/lib/model/HAPStorage.js +11 -4
  171. package/dist/lib/model/HAPStorage.js.map +1 -1
  172. package/dist/lib/model/IdentifierCache.d.ts +1 -1
  173. package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
  174. package/dist/lib/model/IdentifierCache.js +27 -19
  175. package/dist/lib/model/IdentifierCache.js.map +1 -1
  176. package/dist/lib/tv/AccessControlManagement.d.ts +9 -9
  177. package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
  178. package/dist/lib/tv/AccessControlManagement.js +29 -27
  179. package/dist/lib/tv/AccessControlManagement.js.map +1 -1
  180. package/dist/lib/util/checkName.d.ts +2 -2
  181. package/dist/lib/util/checkName.d.ts.map +1 -1
  182. package/dist/lib/util/checkName.js +9 -6
  183. package/dist/lib/util/checkName.js.map +1 -1
  184. package/dist/lib/util/clone.d.ts.map +1 -1
  185. package/dist/lib/util/clone.js +5 -1
  186. package/dist/lib/util/clone.js.map +1 -1
  187. package/dist/lib/util/color-utils.d.ts +1 -1
  188. package/dist/lib/util/color-utils.d.ts.map +1 -1
  189. package/dist/lib/util/color-utils.js +9 -4
  190. package/dist/lib/util/color-utils.js.map +1 -1
  191. package/dist/lib/util/eventedhttp.d.ts +22 -23
  192. package/dist/lib/util/eventedhttp.d.ts.map +1 -1
  193. package/dist/lib/util/eventedhttp.js +116 -109
  194. package/dist/lib/util/eventedhttp.js.map +1 -1
  195. package/dist/lib/util/hapCrypto.d.ts +2 -3
  196. package/dist/lib/util/hapCrypto.d.ts.map +1 -1
  197. package/dist/lib/util/hapCrypto.js +40 -31
  198. package/dist/lib/util/hapCrypto.js.map +1 -1
  199. package/dist/lib/util/hapStatusError.d.ts +1 -1
  200. package/dist/lib/util/hapStatusError.d.ts.map +1 -1
  201. package/dist/lib/util/hapStatusError.js +8 -4
  202. package/dist/lib/util/hapStatusError.js.map +1 -1
  203. package/dist/lib/util/net-utils.d.ts +1 -1
  204. package/dist/lib/util/net-utils.js +23 -17
  205. package/dist/lib/util/net-utils.js.map +1 -1
  206. package/dist/lib/util/once.d.ts.map +1 -1
  207. package/dist/lib/util/once.js +6 -2
  208. package/dist/lib/util/once.js.map +1 -1
  209. package/dist/lib/util/promise-utils.d.ts +1 -1
  210. package/dist/lib/util/promise-utils.d.ts.map +1 -1
  211. package/dist/lib/util/promise-utils.js +10 -3
  212. package/dist/lib/util/promise-utils.js.map +1 -1
  213. package/dist/lib/util/request-util.d.ts +2 -3
  214. package/dist/lib/util/request-util.d.ts.map +1 -1
  215. package/dist/lib/util/request-util.js +19 -11
  216. package/dist/lib/util/request-util.js.map +1 -1
  217. package/dist/lib/util/time.d.ts +0 -1
  218. package/dist/lib/util/time.d.ts.map +1 -1
  219. package/dist/lib/util/time.js +11 -6
  220. package/dist/lib/util/time.js.map +1 -1
  221. package/dist/lib/util/tlv.d.ts +0 -1
  222. package/dist/lib/util/tlv.d.ts.map +1 -1
  223. package/dist/lib/util/tlv.js +43 -28
  224. package/dist/lib/util/tlv.js.map +1 -1
  225. package/dist/lib/util/uuid.d.ts +0 -1
  226. package/dist/lib/util/uuid.d.ts.map +1 -1
  227. package/dist/lib/util/uuid.js +38 -26
  228. package/dist/lib/util/uuid.js.map +1 -1
  229. package/dist/types.d.ts +24 -24
  230. package/dist/types.d.ts.map +1 -1
  231. package/dist/types.js +5 -3
  232. package/dist/types.js.map +1 -1
  233. package/package.json +47 -52
  234. package/dist/lib/dbus/align.d.ts +0 -2
  235. package/dist/lib/dbus/align.d.ts.map +0 -1
  236. package/dist/lib/dbus/align.js +0 -12
  237. package/dist/lib/dbus/align.js.map +0 -1
  238. package/dist/lib/dbus/bus.d.ts +0 -38
  239. package/dist/lib/dbus/bus.d.ts.map +0 -1
  240. package/dist/lib/dbus/bus.js +0 -222
  241. package/dist/lib/dbus/bus.js.map +0 -1
  242. package/dist/lib/dbus/constants.d.ts +0 -43
  243. package/dist/lib/dbus/constants.d.ts.map +0 -1
  244. package/dist/lib/dbus/constants.js +0 -53
  245. package/dist/lib/dbus/constants.js.map +0 -1
  246. package/dist/lib/dbus/dbus-buffer.d.ts +0 -30
  247. package/dist/lib/dbus/dbus-buffer.d.ts.map +0 -1
  248. package/dist/lib/dbus/dbus-buffer.js +0 -175
  249. package/dist/lib/dbus/dbus-buffer.js.map +0 -1
  250. package/dist/lib/dbus/handshake.d.ts +0 -2
  251. package/dist/lib/dbus/handshake.d.ts.map +0 -1
  252. package/dist/lib/dbus/handshake.js +0 -130
  253. package/dist/lib/dbus/handshake.js.map +0 -1
  254. package/dist/lib/dbus/index.d.ts +0 -3
  255. package/dist/lib/dbus/index.d.ts.map +0 -1
  256. package/dist/lib/dbus/index.js +0 -123
  257. package/dist/lib/dbus/index.js.map +0 -1
  258. package/dist/lib/dbus/introspect.d.ts +0 -30
  259. package/dist/lib/dbus/introspect.d.ts.map +0 -1
  260. package/dist/lib/dbus/introspect.js +0 -208
  261. package/dist/lib/dbus/introspect.js.map +0 -1
  262. package/dist/lib/dbus/marshall.d.ts +0 -2
  263. package/dist/lib/dbus/marshall.d.ts.map +0 -1
  264. package/dist/lib/dbus/marshall.js +0 -97
  265. package/dist/lib/dbus/marshall.js.map +0 -1
  266. package/dist/lib/dbus/marshallers.d.ts +0 -10
  267. package/dist/lib/dbus/marshallers.d.ts.map +0 -1
  268. package/dist/lib/dbus/marshallers.js +0 -329
  269. package/dist/lib/dbus/marshallers.js.map +0 -1
  270. package/dist/lib/dbus/message.d.ts +0 -4
  271. package/dist/lib/dbus/message.d.ts.map +0 -1
  272. package/dist/lib/dbus/message.js +0 -116
  273. package/dist/lib/dbus/message.js.map +0 -1
  274. package/dist/lib/dbus/put.d.ts +0 -21
  275. package/dist/lib/dbus/put.d.ts.map +0 -1
  276. package/dist/lib/dbus/put.js +0 -120
  277. package/dist/lib/dbus/put.js.map +0 -1
  278. package/dist/lib/dbus/readline.d.ts +0 -2
  279. package/dist/lib/dbus/readline.d.ts.map +0 -1
  280. package/dist/lib/dbus/readline.js +0 -27
  281. package/dist/lib/dbus/readline.js.map +0 -1
  282. package/dist/lib/dbus/signature.d.ts +0 -2
  283. package/dist/lib/dbus/signature.d.ts.map +0 -1
  284. package/dist/lib/dbus/signature.js +0 -59
  285. package/dist/lib/dbus/signature.js.map +0 -1
  286. package/dist/lib/dbus/stdifaces.d.ts +0 -3
  287. package/dist/lib/dbus/stdifaces.d.ts.map +0 -1
  288. package/dist/lib/dbus/stdifaces.js +0 -206
  289. package/dist/lib/dbus/stdifaces.js.map +0 -1
@@ -1,24 +1,25 @@
1
- import assert from 'node:assert';
2
- import { Buffer } from 'node:buffer';
3
- import { randomBytes } from 'node:crypto';
4
- import { isIPv4 } from 'node:net';
5
- import createDebug from 'debug';
6
- import { Characteristic } from '../Characteristic.js';
7
- import { CameraController } from '../controller/index.js';
8
- import { Service } from '../Service.js';
9
- import { HapStatusError } from '../util/hapStatusError.js';
10
- import { once } from '../util/once.js';
11
- import { decode, encode, writeUInt16, writeUInt32 } from '../util/tlv.js';
12
- import { unparse, write } from '../util/uuid.js';
13
- import RTPProxy from './RTPProxy.js';
14
- const debug = createDebug('HAP-NodeJS:Camera:RTPStreamManagement');
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RTPStreamManagement = exports.StreamRequestTypes = exports.AudioStreamingSamplerate = exports.AudioStreamingCodecType = exports.SRTPCryptoSuites = exports.AudioSamplerate = exports.AudioBitrate = exports.VideoCodecPacketizationMode = exports.H264Level = exports.H264Profile = exports.VideoCodecType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const assert_1 = tslib_1.__importDefault(require("assert"));
6
+ const crypto_1 = tslib_1.__importDefault(require("crypto"));
7
+ const debug_1 = tslib_1.__importDefault(require("debug"));
8
+ const net_1 = tslib_1.__importDefault(require("net"));
9
+ const Characteristic_1 = require("../Characteristic");
10
+ const controller_1 = require("../controller");
11
+ const Service_1 = require("../Service");
12
+ const hapStatusError_1 = require("../util/hapStatusError");
13
+ const once_1 = require("../util/once");
14
+ const tlv = tslib_1.__importStar(require("../util/tlv"));
15
+ const uuid = tslib_1.__importStar(require("../util/uuid"));
16
+ const RTPProxy_1 = tslib_1.__importDefault(require("./RTPProxy"));
17
+ const debug = (0, debug_1.default)("HAP-NodeJS:Camera:RTPStreamManagement");
15
18
  // ---------------------------------- TLV DEFINITIONS START ----------------------------------
16
- // eslint-disable-next-line no-restricted-syntax
17
19
  var StreamingStatusTypes;
18
20
  (function (StreamingStatusTypes) {
19
21
  StreamingStatusTypes[StreamingStatusTypes["STATUS"] = 1] = "STATUS";
20
22
  })(StreamingStatusTypes || (StreamingStatusTypes = {}));
21
- // eslint-disable-next-line no-restricted-syntax
22
23
  var StreamingStatus;
23
24
  (function (StreamingStatus) {
24
25
  StreamingStatus[StreamingStatus["AVAILABLE"] = 0] = "AVAILABLE";
@@ -26,19 +27,16 @@ var StreamingStatus;
26
27
  StreamingStatus[StreamingStatus["UNAVAILABLE"] = 2] = "UNAVAILABLE";
27
28
  })(StreamingStatus || (StreamingStatus = {}));
28
29
  // ----------
29
- // eslint-disable-next-line no-restricted-syntax
30
30
  var SupportedVideoStreamConfigurationTypes;
31
31
  (function (SupportedVideoStreamConfigurationTypes) {
32
32
  SupportedVideoStreamConfigurationTypes[SupportedVideoStreamConfigurationTypes["VIDEO_CODEC_CONFIGURATION"] = 1] = "VIDEO_CODEC_CONFIGURATION";
33
33
  })(SupportedVideoStreamConfigurationTypes || (SupportedVideoStreamConfigurationTypes = {}));
34
- // eslint-disable-next-line no-restricted-syntax
35
34
  var VideoCodecConfigurationTypes;
36
35
  (function (VideoCodecConfigurationTypes) {
37
36
  VideoCodecConfigurationTypes[VideoCodecConfigurationTypes["CODEC_TYPE"] = 1] = "CODEC_TYPE";
38
37
  VideoCodecConfigurationTypes[VideoCodecConfigurationTypes["CODEC_PARAMETERS"] = 2] = "CODEC_PARAMETERS";
39
38
  VideoCodecConfigurationTypes[VideoCodecConfigurationTypes["ATTRIBUTES"] = 3] = "ATTRIBUTES";
40
39
  })(VideoCodecConfigurationTypes || (VideoCodecConfigurationTypes = {}));
41
- // eslint-disable-next-line no-restricted-syntax
42
40
  var VideoCodecParametersTypes;
43
41
  (function (VideoCodecParametersTypes) {
44
42
  VideoCodecParametersTypes[VideoCodecParametersTypes["PROFILE_ID"] = 1] = "PROFILE_ID";
@@ -47,7 +45,6 @@ var VideoCodecParametersTypes;
47
45
  VideoCodecParametersTypes[VideoCodecParametersTypes["CVO_ENABLED"] = 4] = "CVO_ENABLED";
48
46
  VideoCodecParametersTypes[VideoCodecParametersTypes["CVO_ID"] = 5] = "CVO_ID";
49
47
  })(VideoCodecParametersTypes || (VideoCodecParametersTypes = {}));
50
- // eslint-disable-next-line no-restricted-syntax
51
48
  var VideoAttributesTypes;
52
49
  (function (VideoAttributesTypes) {
53
50
  VideoAttributesTypes[VideoAttributesTypes["IMAGE_WIDTH"] = 1] = "IMAGE_WIDTH";
@@ -57,61 +54,53 @@ var VideoAttributesTypes;
57
54
  /**
58
55
  * @group Camera
59
56
  */
60
- // eslint-disable-next-line no-restricted-syntax
61
- export var VideoCodecType;
57
+ var VideoCodecType;
62
58
  (function (VideoCodecType) {
63
59
  VideoCodecType[VideoCodecType["H264"] = 0] = "H264";
64
60
  // while the namespace is already reserved for H265 it isn't currently supported.
65
61
  // H265 = 0x01,
66
- })(VideoCodecType || (VideoCodecType = {}));
62
+ })(VideoCodecType || (exports.VideoCodecType = VideoCodecType = {}));
67
63
  /**
68
64
  * @group Camera
69
65
  */
70
- // eslint-disable-next-line no-restricted-syntax
71
- export var H264Profile;
66
+ var H264Profile;
72
67
  (function (H264Profile) {
73
68
  H264Profile[H264Profile["BASELINE"] = 0] = "BASELINE";
74
69
  H264Profile[H264Profile["MAIN"] = 1] = "MAIN";
75
70
  H264Profile[H264Profile["HIGH"] = 2] = "HIGH";
76
- })(H264Profile || (H264Profile = {}));
71
+ })(H264Profile || (exports.H264Profile = H264Profile = {}));
77
72
  /**
78
73
  * @group Camera
79
74
  */
80
- // eslint-disable-next-line no-restricted-syntax
81
- export var H264Level;
75
+ var H264Level;
82
76
  (function (H264Level) {
83
77
  H264Level[H264Level["LEVEL3_1"] = 0] = "LEVEL3_1";
84
78
  H264Level[H264Level["LEVEL3_2"] = 1] = "LEVEL3_2";
85
79
  H264Level[H264Level["LEVEL4_0"] = 2] = "LEVEL4_0";
86
- })(H264Level || (H264Level = {}));
80
+ })(H264Level || (exports.H264Level = H264Level = {}));
87
81
  /**
88
82
  * @group Camera
89
83
  */
90
- // eslint-disable-next-line no-restricted-syntax
91
- export var VideoCodecPacketizationMode;
84
+ var VideoCodecPacketizationMode;
92
85
  (function (VideoCodecPacketizationMode) {
93
86
  VideoCodecPacketizationMode[VideoCodecPacketizationMode["NON_INTERLEAVED"] = 0] = "NON_INTERLEAVED";
94
- })(VideoCodecPacketizationMode || (VideoCodecPacketizationMode = {}));
95
- // eslint-disable-next-line no-restricted-syntax
87
+ })(VideoCodecPacketizationMode || (exports.VideoCodecPacketizationMode = VideoCodecPacketizationMode = {}));
96
88
  var VideoCodecCVO;
97
89
  (function (VideoCodecCVO) {
98
90
  VideoCodecCVO[VideoCodecCVO["UNSUPPORTED"] = 0] = "UNSUPPORTED";
99
91
  VideoCodecCVO[VideoCodecCVO["SUPPORTED"] = 1] = "SUPPORTED";
100
92
  })(VideoCodecCVO || (VideoCodecCVO = {}));
101
93
  // ----------
102
- // eslint-disable-next-line no-restricted-syntax
103
94
  var SupportedAudioStreamConfigurationTypes;
104
95
  (function (SupportedAudioStreamConfigurationTypes) {
105
96
  SupportedAudioStreamConfigurationTypes[SupportedAudioStreamConfigurationTypes["AUDIO_CODEC_CONFIGURATION"] = 1] = "AUDIO_CODEC_CONFIGURATION";
106
97
  SupportedAudioStreamConfigurationTypes[SupportedAudioStreamConfigurationTypes["COMFORT_NOISE_SUPPORT"] = 2] = "COMFORT_NOISE_SUPPORT";
107
98
  })(SupportedAudioStreamConfigurationTypes || (SupportedAudioStreamConfigurationTypes = {}));
108
- // eslint-disable-next-line no-restricted-syntax
109
99
  var AudioCodecConfigurationTypes;
110
100
  (function (AudioCodecConfigurationTypes) {
111
101
  AudioCodecConfigurationTypes[AudioCodecConfigurationTypes["CODEC_TYPE"] = 1] = "CODEC_TYPE";
112
102
  AudioCodecConfigurationTypes[AudioCodecConfigurationTypes["CODEC_PARAMETERS"] = 2] = "CODEC_PARAMETERS";
113
103
  })(AudioCodecConfigurationTypes || (AudioCodecConfigurationTypes = {}));
114
- // eslint-disable-next-line no-restricted-syntax
115
104
  var AudioCodecTypes;
116
105
  (function (AudioCodecTypes) {
117
106
  AudioCodecTypes[AudioCodecTypes["PCMU"] = 0] = "PCMU";
@@ -122,37 +111,33 @@ var AudioCodecTypes;
122
111
  AudioCodecTypes[AudioCodecTypes["AMR"] = 5] = "AMR";
123
112
  AudioCodecTypes[AudioCodecTypes["AMR_WB"] = 6] = "AMR_WB";
124
113
  })(AudioCodecTypes || (AudioCodecTypes = {}));
125
- // eslint-disable-next-line no-restricted-syntax
126
114
  var AudioCodecParametersTypes;
127
115
  (function (AudioCodecParametersTypes) {
128
116
  AudioCodecParametersTypes[AudioCodecParametersTypes["CHANNEL"] = 1] = "CHANNEL";
129
117
  AudioCodecParametersTypes[AudioCodecParametersTypes["BIT_RATE"] = 2] = "BIT_RATE";
130
118
  AudioCodecParametersTypes[AudioCodecParametersTypes["SAMPLE_RATE"] = 3] = "SAMPLE_RATE";
131
- AudioCodecParametersTypes[AudioCodecParametersTypes["PACKET_TIME"] = 4] = "PACKET_TIME";
119
+ AudioCodecParametersTypes[AudioCodecParametersTypes["PACKET_TIME"] = 4] = "PACKET_TIME"; // only present in selected audio codec parameters tlv
132
120
  })(AudioCodecParametersTypes || (AudioCodecParametersTypes = {}));
133
121
  /**
134
122
  * @group Camera
135
123
  */
136
- // eslint-disable-next-line no-restricted-syntax
137
- export var AudioBitrate;
124
+ var AudioBitrate;
138
125
  (function (AudioBitrate) {
139
126
  AudioBitrate[AudioBitrate["VARIABLE"] = 0] = "VARIABLE";
140
127
  AudioBitrate[AudioBitrate["CONSTANT"] = 1] = "CONSTANT";
141
- })(AudioBitrate || (AudioBitrate = {}));
128
+ })(AudioBitrate || (exports.AudioBitrate = AudioBitrate = {}));
142
129
  /**
143
130
  * @group Camera
144
131
  */
145
- // eslint-disable-next-line no-restricted-syntax
146
- export var AudioSamplerate;
132
+ var AudioSamplerate;
147
133
  (function (AudioSamplerate) {
148
134
  AudioSamplerate[AudioSamplerate["KHZ_8"] = 0] = "KHZ_8";
149
135
  AudioSamplerate[AudioSamplerate["KHZ_16"] = 1] = "KHZ_16";
150
136
  AudioSamplerate[AudioSamplerate["KHZ_24"] = 2] = "KHZ_24";
151
137
  // 3, 4, 5 are theoretically defined, but no idea to what kHz value they correspond to
152
138
  // probably KHZ_32, KHZ_44_1, KHZ_48 (as supported by Secure Video recordings)
153
- })(AudioSamplerate || (AudioSamplerate = {}));
139
+ })(AudioSamplerate || (exports.AudioSamplerate = AudioSamplerate = {}));
154
140
  // ----------
155
- // eslint-disable-next-line no-restricted-syntax
156
141
  var SupportedRTPConfigurationTypes;
157
142
  (function (SupportedRTPConfigurationTypes) {
158
143
  SupportedRTPConfigurationTypes[SupportedRTPConfigurationTypes["SRTP_CRYPTO_SUITE"] = 2] = "SRTP_CRYPTO_SUITE";
@@ -160,15 +145,13 @@ var SupportedRTPConfigurationTypes;
160
145
  /**
161
146
  * @group Camera
162
147
  */
163
- // eslint-disable-next-line no-restricted-syntax
164
- export var SRTPCryptoSuites;
148
+ var SRTPCryptoSuites;
165
149
  (function (SRTPCryptoSuites) {
166
150
  SRTPCryptoSuites[SRTPCryptoSuites["AES_CM_128_HMAC_SHA1_80"] = 0] = "AES_CM_128_HMAC_SHA1_80";
167
151
  SRTPCryptoSuites[SRTPCryptoSuites["AES_CM_256_HMAC_SHA1_80"] = 1] = "AES_CM_256_HMAC_SHA1_80";
168
152
  SRTPCryptoSuites[SRTPCryptoSuites["NONE"] = 2] = "NONE";
169
- })(SRTPCryptoSuites || (SRTPCryptoSuites = {}));
153
+ })(SRTPCryptoSuites || (exports.SRTPCryptoSuites = SRTPCryptoSuites = {}));
170
154
  // ----------
171
- // eslint-disable-next-line no-restricted-syntax
172
155
  var SetupEndpointsTypes;
173
156
  (function (SetupEndpointsTypes) {
174
157
  SetupEndpointsTypes[SetupEndpointsTypes["SESSION_ID"] = 1] = "SESSION_ID";
@@ -176,7 +159,6 @@ var SetupEndpointsTypes;
176
159
  SetupEndpointsTypes[SetupEndpointsTypes["VIDEO_SRTP_PARAMETERS"] = 4] = "VIDEO_SRTP_PARAMETERS";
177
160
  SetupEndpointsTypes[SetupEndpointsTypes["AUDIO_SRTP_PARAMETERS"] = 5] = "AUDIO_SRTP_PARAMETERS";
178
161
  })(SetupEndpointsTypes || (SetupEndpointsTypes = {}));
179
- // eslint-disable-next-line no-restricted-syntax
180
162
  var AddressTypes;
181
163
  (function (AddressTypes) {
182
164
  AddressTypes[AddressTypes["ADDRESS_VERSION"] = 1] = "ADDRESS_VERSION";
@@ -184,20 +166,17 @@ var AddressTypes;
184
166
  AddressTypes[AddressTypes["VIDEO_RTP_PORT"] = 3] = "VIDEO_RTP_PORT";
185
167
  AddressTypes[AddressTypes["AUDIO_RTP_PORT"] = 4] = "AUDIO_RTP_PORT";
186
168
  })(AddressTypes || (AddressTypes = {}));
187
- // eslint-disable-next-line no-restricted-syntax
188
169
  var IPAddressVersion;
189
170
  (function (IPAddressVersion) {
190
171
  IPAddressVersion[IPAddressVersion["IPV4"] = 0] = "IPV4";
191
172
  IPAddressVersion[IPAddressVersion["IPV6"] = 1] = "IPV6";
192
173
  })(IPAddressVersion || (IPAddressVersion = {}));
193
- // eslint-disable-next-line no-restricted-syntax
194
174
  var SRTPParametersTypes;
195
175
  (function (SRTPParametersTypes) {
196
176
  SRTPParametersTypes[SRTPParametersTypes["SRTP_CRYPTO_SUITE"] = 1] = "SRTP_CRYPTO_SUITE";
197
177
  SRTPParametersTypes[SRTPParametersTypes["MASTER_KEY"] = 2] = "MASTER_KEY";
198
- SRTPParametersTypes[SRTPParametersTypes["MASTER_SALT"] = 3] = "MASTER_SALT";
178
+ SRTPParametersTypes[SRTPParametersTypes["MASTER_SALT"] = 3] = "MASTER_SALT"; // 14 bytes
199
179
  })(SRTPParametersTypes || (SRTPParametersTypes = {}));
200
- // eslint-disable-next-line no-restricted-syntax
201
180
  var SetupEndpointsResponseTypes;
202
181
  (function (SetupEndpointsResponseTypes) {
203
182
  SetupEndpointsResponseTypes[SetupEndpointsResponseTypes["SESSION_ID"] = 1] = "SESSION_ID";
@@ -208,7 +187,6 @@ var SetupEndpointsResponseTypes;
208
187
  SetupEndpointsResponseTypes[SetupEndpointsResponseTypes["VIDEO_SSRC"] = 6] = "VIDEO_SSRC";
209
188
  SetupEndpointsResponseTypes[SetupEndpointsResponseTypes["AUDIO_SSRC"] = 7] = "AUDIO_SSRC";
210
189
  })(SetupEndpointsResponseTypes || (SetupEndpointsResponseTypes = {}));
211
- // eslint-disable-next-line no-restricted-syntax
212
190
  var SetupEndpointsStatus;
213
191
  (function (SetupEndpointsStatus) {
214
192
  SetupEndpointsStatus[SetupEndpointsStatus["SUCCESS"] = 0] = "SUCCESS";
@@ -216,14 +194,12 @@ var SetupEndpointsStatus;
216
194
  SetupEndpointsStatus[SetupEndpointsStatus["ERROR"] = 2] = "ERROR";
217
195
  })(SetupEndpointsStatus || (SetupEndpointsStatus = {}));
218
196
  // ----------
219
- // eslint-disable-next-line no-restricted-syntax
220
197
  var SelectedRTPStreamConfigurationTypes;
221
198
  (function (SelectedRTPStreamConfigurationTypes) {
222
199
  SelectedRTPStreamConfigurationTypes[SelectedRTPStreamConfigurationTypes["SESSION_CONTROL"] = 1] = "SESSION_CONTROL";
223
200
  SelectedRTPStreamConfigurationTypes[SelectedRTPStreamConfigurationTypes["SELECTED_VIDEO_PARAMETERS"] = 2] = "SELECTED_VIDEO_PARAMETERS";
224
201
  SelectedRTPStreamConfigurationTypes[SelectedRTPStreamConfigurationTypes["SELECTED_AUDIO_PARAMETERS"] = 3] = "SELECTED_AUDIO_PARAMETERS";
225
202
  })(SelectedRTPStreamConfigurationTypes || (SelectedRTPStreamConfigurationTypes = {}));
226
- // eslint-disable-next-line no-restricted-syntax
227
203
  var SessionControlTypes;
228
204
  (function (SessionControlTypes) {
229
205
  SessionControlTypes[SessionControlTypes["SESSION_IDENTIFIER"] = 1] = "SESSION_IDENTIFIER";
@@ -237,7 +213,6 @@ var SessionControlCommand;
237
213
  SessionControlCommand[SessionControlCommand["RESUME_SESSION"] = 3] = "RESUME_SESSION";
238
214
  SessionControlCommand[SessionControlCommand["RECONFIGURE_SESSION"] = 4] = "RECONFIGURE_SESSION";
239
215
  })(SessionControlCommand || (SessionControlCommand = {}));
240
- // eslint-disable-next-line no-restricted-syntax
241
216
  var SelectedVideoParametersTypes;
242
217
  (function (SelectedVideoParametersTypes) {
243
218
  SelectedVideoParametersTypes[SelectedVideoParametersTypes["CODEC_TYPE"] = 1] = "CODEC_TYPE";
@@ -245,7 +220,6 @@ var SelectedVideoParametersTypes;
245
220
  SelectedVideoParametersTypes[SelectedVideoParametersTypes["ATTRIBUTES"] = 3] = "ATTRIBUTES";
246
221
  SelectedVideoParametersTypes[SelectedVideoParametersTypes["RTP_PARAMETERS"] = 4] = "RTP_PARAMETERS";
247
222
  })(SelectedVideoParametersTypes || (SelectedVideoParametersTypes = {}));
248
- // eslint-disable-next-line no-restricted-syntax
249
223
  var VideoRTPParametersTypes;
250
224
  (function (VideoRTPParametersTypes) {
251
225
  VideoRTPParametersTypes[VideoRTPParametersTypes["PAYLOAD_TYPE"] = 1] = "PAYLOAD_TYPE";
@@ -254,7 +228,6 @@ var VideoRTPParametersTypes;
254
228
  VideoRTPParametersTypes[VideoRTPParametersTypes["MIN_RTCP_INTERVAL"] = 4] = "MIN_RTCP_INTERVAL";
255
229
  VideoRTPParametersTypes[VideoRTPParametersTypes["MAX_MTU"] = 5] = "MAX_MTU";
256
230
  })(VideoRTPParametersTypes || (VideoRTPParametersTypes = {}));
257
- // eslint-disable-next-line no-restricted-syntax
258
231
  var SelectedAudioParametersTypes;
259
232
  (function (SelectedAudioParametersTypes) {
260
233
  SelectedAudioParametersTypes[SelectedAudioParametersTypes["CODEC_TYPE"] = 1] = "CODEC_TYPE";
@@ -262,7 +235,6 @@ var SelectedAudioParametersTypes;
262
235
  SelectedAudioParametersTypes[SelectedAudioParametersTypes["RTP_PARAMETERS"] = 3] = "RTP_PARAMETERS";
263
236
  SelectedAudioParametersTypes[SelectedAudioParametersTypes["COMFORT_NOISE"] = 4] = "COMFORT_NOISE";
264
237
  })(SelectedAudioParametersTypes || (SelectedAudioParametersTypes = {}));
265
- // eslint-disable-next-line no-restricted-syntax
266
238
  var AudioRTPParametersTypes;
267
239
  (function (AudioRTPParametersTypes) {
268
240
  AudioRTPParametersTypes[AudioRTPParametersTypes["PAYLOAD_TYPE"] = 1] = "PAYLOAD_TYPE";
@@ -271,14 +243,14 @@ var AudioRTPParametersTypes;
271
243
  AudioRTPParametersTypes[AudioRTPParametersTypes["MIN_RTCP_INTERVAL"] = 4] = "MIN_RTCP_INTERVAL";
272
244
  AudioRTPParametersTypes[AudioRTPParametersTypes["COMFORT_NOISE_PAYLOAD_TYPE"] = 6] = "COMFORT_NOISE_PAYLOAD_TYPE";
273
245
  })(AudioRTPParametersTypes || (AudioRTPParametersTypes = {}));
246
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
274
247
  function isLegacySRTPOptions(options) {
275
- return 'srtp' in options;
248
+ return "srtp" in options;
276
249
  }
277
250
  /**
278
251
  * @group Camera
279
252
  */
280
- // eslint-disable-next-line no-restricted-syntax
281
- export var AudioStreamingCodecType;
253
+ var AudioStreamingCodecType;
282
254
  (function (AudioStreamingCodecType) {
283
255
  AudioStreamingCodecType["PCMU"] = "PCMU";
284
256
  AudioStreamingCodecType["PCMA"] = "PCMA";
@@ -287,31 +259,29 @@ export var AudioStreamingCodecType;
287
259
  AudioStreamingCodecType["MSBC"] = "mSBC";
288
260
  AudioStreamingCodecType["AMR"] = "AMR";
289
261
  AudioStreamingCodecType["AMR_WB"] = "AMR-WB";
290
- })(AudioStreamingCodecType || (AudioStreamingCodecType = {}));
262
+ })(AudioStreamingCodecType || (exports.AudioStreamingCodecType = AudioStreamingCodecType = {}));
291
263
  /**
292
264
  * @group Camera
293
265
  */
294
- // eslint-disable-next-line no-restricted-syntax
295
- export var AudioStreamingSamplerate;
266
+ var AudioStreamingSamplerate;
296
267
  (function (AudioStreamingSamplerate) {
297
268
  AudioStreamingSamplerate[AudioStreamingSamplerate["KHZ_8"] = 8] = "KHZ_8";
298
269
  AudioStreamingSamplerate[AudioStreamingSamplerate["KHZ_16"] = 16] = "KHZ_16";
299
270
  AudioStreamingSamplerate[AudioStreamingSamplerate["KHZ_24"] = 24] = "KHZ_24";
300
- })(AudioStreamingSamplerate || (AudioStreamingSamplerate = {}));
271
+ })(AudioStreamingSamplerate || (exports.AudioStreamingSamplerate = AudioStreamingSamplerate = {}));
301
272
  /**
302
273
  * @group Camera
303
274
  */
304
- // eslint-disable-next-line no-restricted-syntax
305
- export var StreamRequestTypes;
275
+ var StreamRequestTypes;
306
276
  (function (StreamRequestTypes) {
307
277
  StreamRequestTypes["RECONFIGURE"] = "reconfigure";
308
278
  StreamRequestTypes["START"] = "start";
309
279
  StreamRequestTypes["STOP"] = "stop";
310
- })(StreamRequestTypes || (StreamRequestTypes = {}));
280
+ })(StreamRequestTypes || (exports.StreamRequestTypes = StreamRequestTypes = {}));
311
281
  /**
312
282
  * @group Camera
313
283
  */
314
- export class RTPStreamManagement {
284
+ class RTPStreamManagement {
315
285
  id;
316
286
  delegate;
317
287
  service;
@@ -327,18 +297,18 @@ export class RTPStreamManagement {
327
297
  activeConnectionClosedListener;
328
298
  sessionIdentifier = undefined;
329
299
  /**
330
- * @private
300
+ * @private private API
331
301
  */
332
302
  streamStatus = 0 /* StreamingStatus.AVAILABLE */; // use _updateStreamStatus to update this property
333
303
  ipVersion; // ip version for the current session
334
- selectedConfiguration = ''; // base64 representation of the currently selected configuration
335
- setupEndpointsResponse = ''; // response of the SetupEndpoints Characteristic
304
+ selectedConfiguration = ""; // base64 representation of the currently selected configuration
305
+ setupEndpointsResponse = ""; // response of the SetupEndpoints Characteristic
336
306
  /**
337
- * @private
307
+ * @private deprecated API
338
308
  */
339
309
  audioProxy;
340
310
  /**
341
- * @private
311
+ * @private deprecated API
342
312
  */
343
313
  videoProxy;
344
314
  /**
@@ -362,7 +332,7 @@ export class RTPStreamManagement {
362
332
  this.supportedCryptoSuites.push(2 /* SRTPCryptoSuites.NONE */);
363
333
  }
364
334
  if (!options.video) {
365
- throw new Error('Video parameters cannot be undefined in options');
335
+ throw new Error("Video parameters cannot be undefined in options");
366
336
  }
367
337
  this.supportedRTPConfiguration = RTPStreamManagement._supportedRTPConfiguration(this.supportedCryptoSuites);
368
338
  this.supportedVideoStreamConfiguration = RTPStreamManagement._supportedVideoStreamConfiguration(options.video);
@@ -383,7 +353,7 @@ export class RTPStreamManagement {
383
353
  handleFactoryReset() {
384
354
  this.resetSelectedStreamConfiguration();
385
355
  this.resetSetupEndpointsResponse();
386
- this.service.updateCharacteristic(Characteristic.Active, true);
356
+ this.service.updateCharacteristic(Characteristic_1.Characteristic.Active, true);
387
357
  // on a factory reset the assumption is that all connections were already terminated and thus "handleStopStream" was already called
388
358
  }
389
359
  destroy() {
@@ -392,46 +362,46 @@ export class RTPStreamManagement {
392
362
  }
393
363
  }
394
364
  constructService(id) {
395
- const managementService = new Service.CameraRTPStreamManagement('', id.toString());
365
+ const managementService = new Service_1.Service.CameraRTPStreamManagement("", id.toString());
396
366
  // this service is required only when recording is enabled. We don't really have access to this info here,
397
367
  // so we just add the characteristic. Doesn't really hurt.
398
- managementService.setCharacteristic(Characteristic.Active, true);
368
+ managementService.setCharacteristic(Characteristic_1.Characteristic.Active, true);
399
369
  return managementService;
400
370
  }
401
371
  setupServiceHandlers() {
402
- if (!this.service.testCharacteristic(Characteristic.Active)) {
372
+ if (!this.service.testCharacteristic(Characteristic_1.Characteristic.Active)) {
403
373
  // the active characteristic might not be present on some older configurations.
404
- this.service.setCharacteristic(Characteristic.Active, true);
374
+ this.service.setCharacteristic(Characteristic_1.Characteristic.Active, true);
405
375
  }
406
- this.service.getCharacteristic(Characteristic.Active)
376
+ this.service.getCharacteristic(Characteristic_1.Characteristic.Active)
407
377
  .on("change" /* CharacteristicEventTypes.CHANGE */, () => this.stateChangeDelegate?.())
408
378
  .setProps({ adminOnlyAccess: [1 /* Access.WRITE */] });
409
379
  // ensure that configurations are up-to-date and reflected in the characteristic values
410
- this.service.setCharacteristic(Characteristic.SupportedRTPConfiguration, this.supportedRTPConfiguration);
411
- this.service.setCharacteristic(Characteristic.SupportedVideoStreamConfiguration, this.supportedVideoStreamConfiguration);
412
- this.service.setCharacteristic(Characteristic.SupportedAudioStreamConfiguration, this.supportedAudioStreamConfiguration);
380
+ this.service.setCharacteristic(Characteristic_1.Characteristic.SupportedRTPConfiguration, this.supportedRTPConfiguration);
381
+ this.service.setCharacteristic(Characteristic_1.Characteristic.SupportedVideoStreamConfiguration, this.supportedVideoStreamConfiguration);
382
+ this.service.setCharacteristic(Characteristic_1.Characteristic.SupportedAudioStreamConfiguration, this.supportedAudioStreamConfiguration);
413
383
  this._updateStreamStatus(0 /* StreamingStatus.AVAILABLE */); // reset streaming status to available
414
- this.service.setCharacteristic(Characteristic.SetupEndpoints, this.setupEndpointsResponse); // reset SetupEndpoints to default
415
- this.service.getCharacteristic(Characteristic.SelectedRTPStreamConfiguration)
416
- .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
384
+ this.service.setCharacteristic(Characteristic_1.Characteristic.SetupEndpoints, this.setupEndpointsResponse); // reset SetupEndpoints to default
385
+ this.service.getCharacteristic(Characteristic_1.Characteristic.SelectedRTPStreamConfiguration)
386
+ .on("get" /* CharacteristicEventTypes.GET */, callback => {
417
387
  if (this.streamingIsDisabled()) {
418
- callback(null, encode(1 /* SelectedRTPStreamConfigurationTypes.SESSION_CONTROL */, encode(2 /* SessionControlTypes.COMMAND */, SessionControlCommand.SUSPEND_SESSION)).toString('base64'));
388
+ callback(null, tlv.encode(1 /* SelectedRTPStreamConfigurationTypes.SESSION_CONTROL */, tlv.encode(2 /* SessionControlTypes.COMMAND */, SessionControlCommand.SUSPEND_SESSION)).toString("base64"));
419
389
  return;
420
390
  }
421
391
  callback(null, this.selectedConfiguration);
422
392
  })
423
393
  .on("set" /* CharacteristicEventTypes.SET */, this._handleSelectedStreamConfigurationWrite.bind(this));
424
- this.service.getCharacteristic(Characteristic.SetupEndpoints)
425
- .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
394
+ this.service.getCharacteristic(Characteristic_1.Characteristic.SetupEndpoints)
395
+ .on("get" /* CharacteristicEventTypes.GET */, callback => {
426
396
  if (this.streamingIsDisabled()) {
427
- callback(null, encode(2 /* SetupEndpointsResponseTypes.STATUS */, 2 /* SetupEndpointsStatus.ERROR */).toString('base64'));
397
+ callback(null, tlv.encode(2 /* SetupEndpointsResponseTypes.STATUS */, 2 /* SetupEndpointsStatus.ERROR */).toString("base64"));
428
398
  return;
429
399
  }
430
400
  callback(null, this.setupEndpointsResponse);
431
401
  })
432
402
  .on("set" /* CharacteristicEventTypes.SET */, (value, callback, context, connection) => {
433
403
  if (!connection) {
434
- debug('Set event handler for SetupEndpoints cannot be called from plugin. Connection undefined!');
404
+ debug("Set event handler for SetupEndpoints cannot be called from plugin. Connection undefined!");
435
405
  callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
436
406
  return;
437
407
  }
@@ -459,16 +429,12 @@ export class RTPStreamManagement {
459
429
  }
460
430
  }
461
431
  streamingIsDisabled(callback) {
462
- if (!this.service.getCharacteristic(Characteristic.Active).value) {
463
- if (typeof callback === 'function') {
464
- callback(new HapStatusError(-70412 /* HAPStatus.NOT_ALLOWED_IN_CURRENT_STATE */));
465
- }
432
+ if (!this.service.getCharacteristic(Characteristic_1.Characteristic.Active).value) {
433
+ callback && callback(new hapStatusError_1.HapStatusError(-70412 /* HAPStatus.NOT_ALLOWED_IN_CURRENT_STATE */));
466
434
  return true;
467
435
  }
468
436
  if (this.disabledThroughOperatingMode?.()) {
469
- if (typeof callback === 'function') {
470
- callback(new HapStatusError(-70412 /* HAPStatus.NOT_ALLOWED_IN_CURRENT_STATE */));
471
- }
437
+ callback && callback(new hapStatusError_1.HapStatusError(-70412 /* HAPStatus.NOT_ALLOWED_IN_CURRENT_STATE */));
472
438
  return true;
473
439
  }
474
440
  return false;
@@ -477,10 +443,10 @@ export class RTPStreamManagement {
477
443
  if (this.streamingIsDisabled(callback)) {
478
444
  return;
479
445
  }
480
- const data = Buffer.from(value, 'base64');
481
- const objects = decode(data);
482
- const sessionControl = decode(objects[1 /* SelectedRTPStreamConfigurationTypes.SESSION_CONTROL */]);
483
- const sessionIdentifier = unparse(sessionControl[1 /* SessionControlTypes.SESSION_IDENTIFIER */]);
446
+ const data = Buffer.from(value, "base64");
447
+ const objects = tlv.decode(data);
448
+ const sessionControl = tlv.decode(objects[1 /* SelectedRTPStreamConfigurationTypes.SESSION_CONTROL */]);
449
+ const sessionIdentifier = uuid.unparse(sessionControl[1 /* SessionControlTypes.SESSION_IDENTIFIER */]);
484
450
  const requestType = sessionControl[2 /* SessionControlTypes.COMMAND */][0];
485
451
  if (sessionIdentifier !== this.sessionIdentifier) {
486
452
  debug(`Received unknown session Identifier with request to ${SessionControlCommand[requestType]}`);
@@ -497,13 +463,13 @@ export class RTPStreamManagement {
497
463
  };
498
464
  switch (requestType) {
499
465
  case SessionControlCommand.START_SESSION: {
500
- const selectedVideoParameters = decode(objects[2 /* SelectedRTPStreamConfigurationTypes.SELECTED_VIDEO_PARAMETERS */]);
501
- const selectedAudioParameters = decode(objects[3 /* SelectedRTPStreamConfigurationTypes.SELECTED_AUDIO_PARAMETERS */]);
466
+ const selectedVideoParameters = tlv.decode(objects[2 /* SelectedRTPStreamConfigurationTypes.SELECTED_VIDEO_PARAMETERS */]);
467
+ const selectedAudioParameters = tlv.decode(objects[3 /* SelectedRTPStreamConfigurationTypes.SELECTED_AUDIO_PARAMETERS */]);
502
468
  this._handleStartStream(selectedVideoParameters, selectedAudioParameters, streamCallback);
503
469
  break;
504
470
  }
505
471
  case SessionControlCommand.RECONFIGURE_SESSION: {
506
- const reconfiguredVideoParameters = decode(objects[2 /* SelectedRTPStreamConfigurationTypes.SELECTED_VIDEO_PARAMETERS */]);
472
+ const reconfiguredVideoParameters = tlv.decode(objects[2 /* SelectedRTPStreamConfigurationTypes.SELECTED_VIDEO_PARAMETERS */]);
507
473
  this.handleReconfigureStream(reconfiguredVideoParameters, streamCallback);
508
474
  break;
509
475
  }
@@ -515,36 +481,38 @@ export class RTPStreamManagement {
515
481
  default:
516
482
  debug(`Unhandled request type ${SessionControlCommand[requestType]}`);
517
483
  callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
484
+ return;
518
485
  }
519
486
  }
520
487
  _handleStartStream(videoConfiguration, audioConfiguration, callback) {
521
488
  // selected video configuration
489
+ // noinspection JSUnusedLocalSymbols
522
490
  const videoCodec = videoConfiguration[1 /* SelectedVideoParametersTypes.CODEC_TYPE */]; // always 0x00 for h264
523
491
  const videoParametersTLV = videoConfiguration[2 /* SelectedVideoParametersTypes.CODEC_PARAMETERS */];
524
492
  const videoAttributesTLV = videoConfiguration[3 /* SelectedVideoParametersTypes.ATTRIBUTES */];
525
493
  const videoRTPParametersTLV = videoConfiguration[4 /* SelectedVideoParametersTypes.RTP_PARAMETERS */];
526
494
  // video parameters
527
- const videoParameters = decode(videoParametersTLV);
495
+ const videoParameters = tlv.decode(videoParametersTLV);
528
496
  const h264Profile = videoParameters[1 /* VideoCodecParametersTypes.PROFILE_ID */][0];
529
497
  const h264Level = videoParameters[2 /* VideoCodecParametersTypes.LEVEL */][0];
530
498
  const packetizationMode = videoParameters[3 /* VideoCodecParametersTypes.PACKETIZATION_MODE */][0];
531
499
  const cvoEnabled = videoParameters[4 /* VideoCodecParametersTypes.CVO_ENABLED */];
532
- let cvoId;
500
+ let cvoId = undefined;
533
501
  if (cvoEnabled && cvoEnabled[0] === 1 /* VideoCodecCVO.SUPPORTED */) {
534
502
  cvoId = videoParameters[5 /* VideoCodecParametersTypes.CVO_ID */].readUInt8(0);
535
503
  }
536
504
  // video attributes
537
- const videoAttributes = decode(videoAttributesTLV);
505
+ const videoAttributes = tlv.decode(videoAttributesTLV);
538
506
  const width = videoAttributes[1 /* VideoAttributesTypes.IMAGE_WIDTH */].readUInt16LE(0);
539
507
  const height = videoAttributes[2 /* VideoAttributesTypes.IMAGE_HEIGHT */].readUInt16LE(0);
540
508
  const frameRate = videoAttributes[3 /* VideoAttributesTypes.FRAME_RATE */].readUInt8(0);
541
509
  // video rtp parameters
542
- const videoRTPParameters = decode(videoRTPParametersTLV);
510
+ const videoRTPParameters = tlv.decode(videoRTPParametersTLV);
543
511
  const videoPayloadType = videoRTPParameters[1 /* VideoRTPParametersTypes.PAYLOAD_TYPE */].readUInt8(0); // 99
544
512
  const videoSSRC = videoRTPParameters[2 /* VideoRTPParametersTypes.SYNCHRONIZATION_SOURCE */].readUInt32LE(0);
545
513
  const videoMaximumBitrate = videoRTPParameters[3 /* VideoRTPParametersTypes.MAX_BIT_RATE */].readUInt16LE(0);
546
514
  const videoRTCPInterval = videoRTPParameters[4 /* VideoRTPParametersTypes.MIN_RTCP_INTERVAL */].readFloatLE(0);
547
- let maxMTU = this.ipVersion === 'ipv6' ? 1228 : 1378; // default values ipv4: 1378 bytes; ipv6: 1228 bytes
515
+ let maxMTU = this.ipVersion === "ipv6" ? 1228 : 1378; // default values ipv4: 1378 bytes; ipv6: 1228 bytes
548
516
  if (videoRTPParameters[5 /* VideoRTPParametersTypes.MAX_MTU */]) {
549
517
  maxMTU = videoRTPParameters[5 /* VideoRTPParametersTypes.MAX_MTU */].readUInt16LE(0);
550
518
  }
@@ -554,13 +522,13 @@ export class RTPStreamManagement {
554
522
  const audioRTPParametersTLV = audioConfiguration[3 /* SelectedAudioParametersTypes.RTP_PARAMETERS */];
555
523
  const comfortNoise = !!audioConfiguration[4 /* SelectedAudioParametersTypes.COMFORT_NOISE */].readUInt8(0);
556
524
  // audio parameters
557
- const audioParameters = decode(audioParametersTLV);
525
+ const audioParameters = tlv.decode(audioParametersTLV);
558
526
  const channels = audioParameters[1 /* AudioCodecParametersTypes.CHANNEL */][0];
559
527
  const audioBitrate = audioParameters[2 /* AudioCodecParametersTypes.BIT_RATE */][0];
560
528
  const samplerate = audioParameters[3 /* AudioCodecParametersTypes.SAMPLE_RATE */][0];
561
529
  const rtpPacketTime = audioParameters[4 /* AudioCodecParametersTypes.PACKET_TIME */].readUInt8(0);
562
530
  // audio rtp parameters
563
- const audioRTPParameters = decode(audioRTPParametersTLV);
531
+ const audioRTPParameters = tlv.decode(audioRTPParametersTLV);
564
532
  const audioPayloadType = audioRTPParameters[1 /* AudioRTPParametersTypes.PAYLOAD_TYPE */].readUInt8(0); // 110
565
533
  const audioSSRC = audioRTPParameters[2 /* AudioRTPParametersTypes.SYNCHRONIZATION_SOURCE */].readUInt32LE(0);
566
534
  const audioMaximumBitrate = audioRTPParameters[3 /* AudioRTPParametersTypes.MAX_BIT_RATE */].readUInt16LE(0);
@@ -576,10 +544,10 @@ export class RTPStreamManagement {
576
544
  codec: videoCodec.readUInt8(0),
577
545
  profile: h264Profile,
578
546
  level: h264Level,
579
- packetizationMode,
580
- cvoId,
581
- width,
582
- height,
547
+ packetizationMode: packetizationMode,
548
+ cvoId: cvoId,
549
+ width: width,
550
+ height: height,
583
551
  fps: frameRate,
584
552
  pt: videoPayloadType,
585
553
  ssrc: videoSSRC,
@@ -653,18 +621,18 @@ export class RTPStreamManagement {
653
621
  const videoAttributesTLV = videoConfiguration[3 /* SelectedVideoParametersTypes.ATTRIBUTES */];
654
622
  const videoRTPParametersTLV = videoConfiguration[4 /* SelectedVideoParametersTypes.RTP_PARAMETERS */];
655
623
  // video attributes
656
- const videoAttributes = decode(videoAttributesTLV);
624
+ const videoAttributes = tlv.decode(videoAttributesTLV);
657
625
  const width = videoAttributes[1 /* VideoAttributesTypes.IMAGE_WIDTH */].readUInt16LE(0);
658
626
  const height = videoAttributes[2 /* VideoAttributesTypes.IMAGE_HEIGHT */].readUInt16LE(0);
659
627
  const frameRate = videoAttributes[3 /* VideoAttributesTypes.FRAME_RATE */].readUInt8(0);
660
628
  // video rtp parameters
661
- const videoRTPParameters = decode(videoRTPParametersTLV);
629
+ const videoRTPParameters = tlv.decode(videoRTPParametersTLV);
662
630
  const videoMaximumBitrate = videoRTPParameters[3 /* VideoRTPParametersTypes.MAX_BIT_RATE */].readUInt16LE(0);
663
631
  // seems to be always zero, use default of 0.5
664
632
  const videoRTCPInterval = videoRTPParameters[4 /* VideoRTPParametersTypes.MIN_RTCP_INTERVAL */].readFloatLE(0) || 0.5;
665
633
  const reconfiguredVideoInfo = {
666
- width,
667
- height,
634
+ width: width,
635
+ height: height,
668
636
  fps: frameRate,
669
637
  max_bit_rate: videoMaximumBitrate,
670
638
  rtcp_interval: videoRTCPInterval,
@@ -688,15 +656,15 @@ export class RTPStreamManagement {
688
656
  if (this.streamingIsDisabled(callback)) {
689
657
  return;
690
658
  }
691
- const data = Buffer.from(value, 'base64');
692
- const objects = decode(data);
693
- const sessionIdentifier = unparse(objects[1 /* SetupEndpointsTypes.SESSION_ID */]);
659
+ const data = Buffer.from(value, "base64");
660
+ const objects = tlv.decode(data);
661
+ const sessionIdentifier = uuid.unparse(objects[1 /* SetupEndpointsTypes.SESSION_ID */]);
694
662
  if (this.streamStatus !== 0 /* StreamingStatus.AVAILABLE */) {
695
- this.setupEndpointsResponse = encode(1 /* SetupEndpointsResponseTypes.SESSION_ID */, write(sessionIdentifier), 2 /* SetupEndpointsResponseTypes.STATUS */, 1 /* SetupEndpointsStatus.BUSY */).toString('base64');
663
+ this.setupEndpointsResponse = tlv.encode(1 /* SetupEndpointsResponseTypes.SESSION_ID */, uuid.write(sessionIdentifier), 2 /* SetupEndpointsResponseTypes.STATUS */, 1 /* SetupEndpointsStatus.BUSY */).toString("base64");
696
664
  callback();
697
665
  return;
698
666
  }
699
- assert(this.activeConnection == null, 'Found non-nil `activeConnection` when trying to setup streaming endpoints, even though streamStatus is reported to be AVAILABLE!');
667
+ (0, assert_1.default)(this.activeConnection == null, "Found non-nil `activeConnection` when trying to setup streaming endpoints, even though streamStatus is reported to be AVAILABLE!");
700
668
  this.activeConnection = connection;
701
669
  this.activeConnection.setMaxListeners(this.activeConnection.getMaxListeners() + 1);
702
670
  this.activeConnection.on("closed" /* HAPConnectionEvent.CLOSED */, this.activeConnectionClosedListener);
@@ -704,29 +672,29 @@ export class RTPStreamManagement {
704
672
  this._updateStreamStatus(1 /* StreamingStatus.IN_USE */);
705
673
  // Address
706
674
  const targetAddressPayload = objects[3 /* SetupEndpointsTypes.CONTROLLER_ADDRESS */];
707
- const processedAddressInfo = decode(targetAddressPayload);
675
+ const processedAddressInfo = tlv.decode(targetAddressPayload);
708
676
  const addressVersion = processedAddressInfo[1 /* AddressTypes.ADDRESS_VERSION */][0];
709
- const controllerAddress = processedAddressInfo[2 /* AddressTypes.ADDRESS */].toString('utf8');
677
+ const controllerAddress = processedAddressInfo[2 /* AddressTypes.ADDRESS */].toString("utf8");
710
678
  const targetVideoPort = processedAddressInfo[3 /* AddressTypes.VIDEO_RTP_PORT */].readUInt16LE(0);
711
679
  const targetAudioPort = processedAddressInfo[4 /* AddressTypes.AUDIO_RTP_PORT */].readUInt16LE(0);
712
680
  // Video SRTP Params
713
681
  const videoSRTPPayload = objects[4 /* SetupEndpointsTypes.VIDEO_SRTP_PARAMETERS */];
714
- const processedVideoInfo = decode(videoSRTPPayload);
682
+ const processedVideoInfo = tlv.decode(videoSRTPPayload);
715
683
  const videoCryptoSuite = processedVideoInfo[1 /* SRTPParametersTypes.SRTP_CRYPTO_SUITE */][0];
716
684
  const videoMasterKey = processedVideoInfo[2 /* SRTPParametersTypes.MASTER_KEY */];
717
685
  const videoMasterSalt = processedVideoInfo[3 /* SRTPParametersTypes.MASTER_SALT */];
718
686
  // Audio SRTP Params
719
687
  const audioSRTPPayload = objects[5 /* SetupEndpointsTypes.AUDIO_SRTP_PARAMETERS */];
720
- const processedAudioInfo = decode(audioSRTPPayload);
688
+ const processedAudioInfo = tlv.decode(audioSRTPPayload);
721
689
  const audioCryptoSuite = processedAudioInfo[1 /* SRTPParametersTypes.SRTP_CRYPTO_SUITE */][0];
722
690
  const audioMasterKey = processedAudioInfo[2 /* SRTPParametersTypes.MASTER_KEY */];
723
691
  const audioMasterSalt = processedAudioInfo[3 /* SRTPParametersTypes.MASTER_SALT */];
724
- debug('Session: ', sessionIdentifier, '\nControllerAddress: ', controllerAddress, '\nVideoPort: ', targetVideoPort, '\nAudioPort: ', targetAudioPort, '\nVideo Crypto: ', videoCryptoSuite, '\nVideo Master Key: ', videoMasterKey, '\nVideo Master Salt: ', videoMasterSalt, '\nAudio Crypto: ', audioCryptoSuite, '\nAudio Master Key: ', audioMasterKey, '\nAudio Master Salt: ', audioMasterSalt);
692
+ debug("Session: ", sessionIdentifier, "\nControllerAddress: ", controllerAddress, "\nVideoPort: ", targetVideoPort, "\nAudioPort: ", targetAudioPort, "\nVideo Crypto: ", videoCryptoSuite, "\nVideo Master Key: ", videoMasterKey, "\nVideo Master Salt: ", videoMasterSalt, "\nAudio Crypto: ", audioCryptoSuite, "\nAudio Master Key: ", audioMasterKey, "\nAudio Master Salt: ", audioMasterSalt);
725
693
  const prepareRequest = {
726
694
  sessionID: sessionIdentifier,
727
695
  sourceAddress: connection.localAddress,
728
696
  targetAddress: controllerAddress,
729
- addressVersion: addressVersion === 1 /* IPAddressVersion.IPV6 */ ? 'ipv6' : 'ipv4',
697
+ addressVersion: addressVersion === 1 /* IPAddressVersion.IPV6 */ ? "ipv6" : "ipv4",
730
698
  video: {
731
699
  port: targetVideoPort,
732
700
  srtpCryptoSuite: videoCryptoSuite,
@@ -742,11 +710,11 @@ export class RTPStreamManagement {
742
710
  };
743
711
  const promises = [];
744
712
  if (this.requireProxy) {
745
- prepareRequest.targetAddress = connection.getLocalAddress(addressVersion === 1 /* IPAddressVersion.IPV6 */ ? 'ipv6' : 'ipv4'); // ip versions must be the same
746
- this.videoProxy = new RTPProxy({
713
+ prepareRequest.targetAddress = connection.getLocalAddress(addressVersion === 1 /* IPAddressVersion.IPV6 */ ? "ipv6" : "ipv4"); // ip versions must be the same
714
+ this.videoProxy = new RTPProxy_1.default({
747
715
  outgoingAddress: controllerAddress,
748
716
  outgoingPort: targetVideoPort,
749
- outgoingSSRC: randomBytes(4).readUInt32LE(0), // videoSSRC
717
+ outgoingSSRC: crypto_1.default.randomBytes(4).readUInt32LE(0), // videoSSRC
750
718
  disabled: false,
751
719
  });
752
720
  promises.push(this.videoProxy.setup().then(() => {
@@ -754,10 +722,10 @@ export class RTPStreamManagement {
754
722
  prepareRequest.video.proxy_rtcp = this.videoProxy.incomingRTCPPort();
755
723
  }));
756
724
  if (!this.disableAudioProxy) {
757
- this.audioProxy = new RTPProxy({
725
+ this.audioProxy = new RTPProxy_1.default({
758
726
  outgoingAddress: controllerAddress,
759
727
  outgoingPort: targetAudioPort,
760
- outgoingSSRC: randomBytes(4).readUInt32LE(0), // audioSSRC
728
+ outgoingSSRC: crypto_1.default.randomBytes(4).readUInt32LE(0), // audioSSRC
761
729
  disabled: this.videoOnly,
762
730
  });
763
731
  promises.push(this.audioProxy.setup().then(() => {
@@ -767,10 +735,10 @@ export class RTPStreamManagement {
767
735
  }
768
736
  }
769
737
  Promise.all(promises).then(() => {
770
- this.delegate.prepareStream(prepareRequest, once((error, response) => {
738
+ this.delegate.prepareStream(prepareRequest, (0, once_1.once)((error, response) => {
771
739
  if (error || !response) {
772
740
  debug(`PrepareStream request encountered an error: ${error ? error.message : undefined}`);
773
- this.setupEndpointsResponse = encode(1 /* SetupEndpointsResponseTypes.SESSION_ID */, write(sessionIdentifier), 2 /* SetupEndpointsResponseTypes.STATUS */, 2 /* SetupEndpointsStatus.ERROR */).toString('base64');
741
+ this.setupEndpointsResponse = tlv.encode(1 /* SetupEndpointsResponseTypes.SESSION_ID */, uuid.write(sessionIdentifier), 2 /* SetupEndpointsResponseTypes.STATUS */, 2 /* SetupEndpointsStatus.ERROR */).toString("base64");
774
742
  this.handleSessionClosed();
775
743
  callback(error);
776
744
  }
@@ -794,12 +762,12 @@ export class RTPStreamManagement {
794
762
  let videoSSRC;
795
763
  let audioSSRC;
796
764
  if (!this.videoOnly && !response.audio) {
797
- throw new Error('Audio was enabled but not supplied in PrepareStreamResponse!');
765
+ throw new Error("Audio was enabled but not supplied in PrepareStreamResponse!");
798
766
  }
799
767
  // Provide default values if audio was not supplied
800
768
  const audio = response.audio || {
801
769
  port: request.audio.port,
802
- ssrc: CameraController.generateSynchronisationSource(),
770
+ ssrc: controller_1.CameraController.generateSynchronisationSource(),
803
771
  srtp_key: request.audio.srtp_key,
804
772
  srtp_salt: request.audio.srtp_salt,
805
773
  };
@@ -807,7 +775,7 @@ export class RTPStreamManagement {
807
775
  const videoInfo = response.video;
808
776
  const audioInfo = audio;
809
777
  if (response.addressOverride) {
810
- addressVersion = isIPv4(response.addressOverride) ? 'ipv4' : 'ipv6';
778
+ addressVersion = net_1.default.isIPv4(response.addressOverride) ? "ipv4" : "ipv6";
811
779
  address = response.addressOverride;
812
780
  }
813
781
  else {
@@ -820,11 +788,11 @@ export class RTPStreamManagement {
820
788
  audioPort = audioInfo.port;
821
789
  if (request.video.srtpCryptoSuite !== 2 /* SRTPCryptoSuites.NONE */
822
790
  && (videoInfo.srtp_key === undefined || videoInfo.srtp_salt === undefined)) {
823
- throw new Error('SRTP was selected for the prepared video stream, but no \'srtp_key\' or \'srtp_salt\' was specified!');
791
+ throw new Error("SRTP was selected for the prepared video stream, but no 'srtp_key' or 'srtp_salt' was specified!");
824
792
  }
825
793
  if (request.audio.srtpCryptoSuite !== 2 /* SRTPCryptoSuites.NONE */
826
794
  && (audioInfo.srtp_key === undefined || audioInfo.srtp_salt === undefined)) {
827
- throw new Error('SRTP was selected for the prepared audio stream, but no \'srtp_key\' or \'srtp_salt\' was specified!');
795
+ throw new Error("SRTP was selected for the prepared audio stream, but no 'srtp_key' or 'srtp_salt' was specified!");
828
796
  }
829
797
  videoCryptoSuite = request.video.srtpCryptoSuite;
830
798
  videoSRTPKey = videoInfo.srtp_key || Buffer.alloc(0); // key and salt are zero-length for cryptoSuite = NONE
@@ -866,39 +834,39 @@ export class RTPStreamManagement {
866
834
  }
867
835
  }
868
836
  this.ipVersion = addressVersion; // we need to save this in order to calculate some default mtu values later
869
- const accessoryAddress = encode(1 /* AddressTypes.ADDRESS_VERSION */, addressVersion === 'ipv4' ? 0 /* IPAddressVersion.IPV4 */ : 1 /* IPAddressVersion.IPV6 */, 2 /* AddressTypes.ADDRESS */, address, 3 /* AddressTypes.VIDEO_RTP_PORT */, writeUInt16(videoPort), 4 /* AddressTypes.AUDIO_RTP_PORT */, writeUInt16(audioPort));
870
- const videoSRTPParameters = encode(1 /* SRTPParametersTypes.SRTP_CRYPTO_SUITE */, videoCryptoSuite, 2 /* SRTPParametersTypes.MASTER_KEY */, videoSRTPKey, 3 /* SRTPParametersTypes.MASTER_SALT */, videoSRTPSalt);
871
- const audioSRTPParameters = encode(1 /* SRTPParametersTypes.SRTP_CRYPTO_SUITE */, audioCryptoSuite, 2 /* SRTPParametersTypes.MASTER_KEY */, audioSRTPKey, 3 /* SRTPParametersTypes.MASTER_SALT */, audioSRTPSalt);
872
- this.setupEndpointsResponse = encode(1 /* SetupEndpointsResponseTypes.SESSION_ID */, write(identifier), 2 /* SetupEndpointsResponseTypes.STATUS */, 0 /* SetupEndpointsStatus.SUCCESS */, 3 /* SetupEndpointsResponseTypes.ACCESSORY_ADDRESS */, accessoryAddress, 4 /* SetupEndpointsResponseTypes.VIDEO_SRTP_PARAMETERS */, videoSRTPParameters, 5 /* SetupEndpointsResponseTypes.AUDIO_SRTP_PARAMETERS */, audioSRTPParameters, 6 /* SetupEndpointsResponseTypes.VIDEO_SSRC */, writeUInt32(videoSSRC), 7 /* SetupEndpointsResponseTypes.AUDIO_SSRC */, writeUInt32(audioSSRC)).toString('base64');
837
+ const accessoryAddress = tlv.encode(1 /* AddressTypes.ADDRESS_VERSION */, addressVersion === "ipv4" ? 0 /* IPAddressVersion.IPV4 */ : 1 /* IPAddressVersion.IPV6 */, 2 /* AddressTypes.ADDRESS */, address, 3 /* AddressTypes.VIDEO_RTP_PORT */, tlv.writeUInt16(videoPort), 4 /* AddressTypes.AUDIO_RTP_PORT */, tlv.writeUInt16(audioPort));
838
+ const videoSRTPParameters = tlv.encode(1 /* SRTPParametersTypes.SRTP_CRYPTO_SUITE */, videoCryptoSuite, 2 /* SRTPParametersTypes.MASTER_KEY */, videoSRTPKey, 3 /* SRTPParametersTypes.MASTER_SALT */, videoSRTPSalt);
839
+ const audioSRTPParameters = tlv.encode(1 /* SRTPParametersTypes.SRTP_CRYPTO_SUITE */, audioCryptoSuite, 2 /* SRTPParametersTypes.MASTER_KEY */, audioSRTPKey, 3 /* SRTPParametersTypes.MASTER_SALT */, audioSRTPSalt);
840
+ this.setupEndpointsResponse = tlv.encode(1 /* SetupEndpointsResponseTypes.SESSION_ID */, uuid.write(identifier), 2 /* SetupEndpointsResponseTypes.STATUS */, 0 /* SetupEndpointsStatus.SUCCESS */, 3 /* SetupEndpointsResponseTypes.ACCESSORY_ADDRESS */, accessoryAddress, 4 /* SetupEndpointsResponseTypes.VIDEO_SRTP_PARAMETERS */, videoSRTPParameters, 5 /* SetupEndpointsResponseTypes.AUDIO_SRTP_PARAMETERS */, audioSRTPParameters, 6 /* SetupEndpointsResponseTypes.VIDEO_SSRC */, tlv.writeUInt32(videoSSRC), 7 /* SetupEndpointsResponseTypes.AUDIO_SSRC */, tlv.writeUInt32(audioSSRC)).toString("base64");
873
841
  callback();
874
842
  }
875
843
  _updateStreamStatus(status) {
876
844
  this.streamStatus = status;
877
- this.service.updateCharacteristic(Characteristic.StreamingStatus, encode(1 /* StreamingStatusTypes.STATUS */, this.streamStatus).toString('base64'));
845
+ this.service.updateCharacteristic(Characteristic_1.Characteristic.StreamingStatus, tlv.encode(1 /* StreamingStatusTypes.STATUS */, this.streamStatus).toString("base64"));
878
846
  }
879
847
  static _supportedRTPConfiguration(supportedCryptoSuites) {
880
848
  if (supportedCryptoSuites.length === 1 && supportedCryptoSuites[0] === 2 /* SRTPCryptoSuites.NONE */) {
881
- debug('Client claims it doesn\'t support SRTP. The stream may stops working with future iOS releases.');
849
+ debug("Client claims it doesn't support SRTP. The stream may stops working with future iOS releases.");
882
850
  }
883
- return encode(2 /* SupportedRTPConfigurationTypes.SRTP_CRYPTO_SUITE */, supportedCryptoSuites).toString('base64');
851
+ return tlv.encode(2 /* SupportedRTPConfigurationTypes.SRTP_CRYPTO_SUITE */, supportedCryptoSuites).toString("base64");
884
852
  }
885
853
  static _supportedVideoStreamConfiguration(videoOptions) {
886
854
  if (!videoOptions.codec) {
887
- throw new Error('Video codec cannot be undefined');
855
+ throw new Error("Video codec cannot be undefined");
888
856
  }
889
857
  if (!videoOptions.resolutions) {
890
- throw new Error('Video resolutions cannot be undefined');
858
+ throw new Error("Video resolutions cannot be undefined");
891
859
  }
892
- let codecParameters = encode(1 /* VideoCodecParametersTypes.PROFILE_ID */, videoOptions.codec.profiles, 2 /* VideoCodecParametersTypes.LEVEL */, videoOptions.codec.levels, 3 /* VideoCodecParametersTypes.PACKETIZATION_MODE */, 0 /* VideoCodecPacketizationMode.NON_INTERLEAVED */);
860
+ let codecParameters = tlv.encode(1 /* VideoCodecParametersTypes.PROFILE_ID */, videoOptions.codec.profiles, 2 /* VideoCodecParametersTypes.LEVEL */, videoOptions.codec.levels, 3 /* VideoCodecParametersTypes.PACKETIZATION_MODE */, 0 /* VideoCodecPacketizationMode.NON_INTERLEAVED */);
893
861
  if (videoOptions.cvoId != null) {
894
862
  codecParameters = Buffer.concat([
895
863
  codecParameters,
896
- encode(4 /* VideoCodecParametersTypes.CVO_ENABLED */, 1 /* VideoCodecCVO.SUPPORTED */, 5 /* VideoCodecParametersTypes.CVO_ID */, videoOptions.cvoId),
864
+ tlv.encode(4 /* VideoCodecParametersTypes.CVO_ENABLED */, 1 /* VideoCodecCVO.SUPPORTED */, 5 /* VideoCodecParametersTypes.CVO_ID */, videoOptions.cvoId),
897
865
  ]);
898
866
  }
899
- const videoStreamConfiguration = encode(1 /* VideoCodecConfigurationTypes.CODEC_TYPE */, 0 /* VideoCodecType.H264 */, 2 /* VideoCodecConfigurationTypes.CODEC_PARAMETERS */, codecParameters, 3 /* VideoCodecConfigurationTypes.ATTRIBUTES */, videoOptions.resolutions.map((resolution) => {
867
+ const videoStreamConfiguration = tlv.encode(1 /* VideoCodecConfigurationTypes.CODEC_TYPE */, 0 /* VideoCodecType.H264 */, 2 /* VideoCodecConfigurationTypes.CODEC_PARAMETERS */, codecParameters, 3 /* VideoCodecConfigurationTypes.ATTRIBUTES */, videoOptions.resolutions.map(resolution => {
900
868
  if (resolution.length !== 3) {
901
- throw new Error('Unexpected video resolution');
869
+ throw new Error("Unexpected video resolution");
902
870
  }
903
871
  const width = Buffer.alloc(2);
904
872
  const height = Buffer.alloc(2);
@@ -906,16 +874,16 @@ export class RTPStreamManagement {
906
874
  width.writeUInt16LE(resolution[0], 0);
907
875
  height.writeUInt16LE(resolution[1], 0);
908
876
  frameRate.writeUInt8(resolution[2], 0);
909
- return encode(1 /* VideoAttributesTypes.IMAGE_WIDTH */, width, 2 /* VideoAttributesTypes.IMAGE_HEIGHT */, height, 3 /* VideoAttributesTypes.FRAME_RATE */, frameRate);
877
+ return tlv.encode(1 /* VideoAttributesTypes.IMAGE_WIDTH */, width, 2 /* VideoAttributesTypes.IMAGE_HEIGHT */, height, 3 /* VideoAttributesTypes.FRAME_RATE */, frameRate);
910
878
  }));
911
- return encode(1 /* SupportedVideoStreamConfigurationTypes.VIDEO_CODEC_CONFIGURATION */, videoStreamConfiguration).toString('base64');
879
+ return tlv.encode(1 /* SupportedVideoStreamConfigurationTypes.VIDEO_CODEC_CONFIGURATION */, videoStreamConfiguration).toString("base64");
912
880
  }
913
881
  checkForLegacyAudioCodecRepresentation(codecs) {
914
882
  const codecMap = {};
915
- codecs.slice().forEach((codec) => {
883
+ codecs.slice().forEach(codec => {
916
884
  const previous = codecMap[codec.type];
917
885
  if (previous) {
918
- if (typeof previous.samplerate === 'number') {
886
+ if (typeof previous.samplerate === "number") {
919
887
  previous.samplerate = [previous.samplerate];
920
888
  }
921
889
  previous.samplerate = previous.samplerate.concat(codec.samplerate);
@@ -936,14 +904,14 @@ export class RTPStreamManagement {
936
904
  const supportedCodecs = (audioOptions && audioOptions.codecs) || [];
937
905
  this.checkForLegacyAudioCodecRepresentation(supportedCodecs);
938
906
  if (supportedCodecs.length === 0) { // Fake a Codec if we haven't got anything
939
- debug('Client doesn\'t support any audio codec that HomeKit supports.');
907
+ debug("Client doesn't support any audio codec that HomeKit supports.");
940
908
  this.videoOnly = true;
941
909
  supportedCodecs.push({
942
910
  type: "OPUS" /* AudioStreamingCodecType.OPUS */, // Opus @16K required by Apple Watch AFAIK
943
911
  samplerate: [16 /* AudioStreamingSamplerate.KHZ_16 */, 24 /* AudioStreamingSamplerate.KHZ_24 */], // 16 and 24 must be supported
944
912
  });
945
913
  }
946
- const codecConfigurations = supportedCodecs.map((codec) => {
914
+ const codecConfigurations = supportedCodecs.map(codec => {
947
915
  let type;
948
916
  switch (codec.type) {
949
917
  case "OPUS" /* AudioStreamingCodecType.OPUS */:
@@ -968,9 +936,9 @@ export class RTPStreamManagement {
968
936
  type = 6 /* AudioCodecTypes.AMR_WB */;
969
937
  break;
970
938
  default:
971
- throw new Error(`Unsupported codec: ${codec.type}`);
939
+ throw new Error("Unsupported codec: " + codec.type);
972
940
  }
973
- const providedSamplerates = (typeof codec.samplerate === 'number' ? [codec.samplerate] : codec.samplerate).map((rate) => {
941
+ const providedSamplerates = (typeof codec.samplerate === "number" ? [codec.samplerate] : codec.samplerate).map(rate => {
974
942
  let samplerate;
975
943
  switch (rate) {
976
944
  case 8 /* AudioStreamingSamplerate.KHZ_8 */:
@@ -983,33 +951,32 @@ export class RTPStreamManagement {
983
951
  samplerate = 2 /* AudioSamplerate.KHZ_24 */;
984
952
  break;
985
953
  default:
986
- // eslint-disable-next-line no-console
987
- console.log('Unsupported sample rate: ', codec.samplerate);
954
+ console.log("Unsupported sample rate: ", codec.samplerate);
988
955
  samplerate = -1;
989
956
  }
990
957
  return samplerate;
991
958
  }).filter(rate => rate !== -1);
992
959
  if (providedSamplerates.length === 0) {
993
- throw new Error('Audio samplerate cannot be empty!');
960
+ throw new Error("Audio samplerate cannot be empty!");
994
961
  }
995
- const audioParameters = encode(1 /* AudioCodecParametersTypes.CHANNEL */, Math.max(1, codec.audioChannels || 1), 2 /* AudioCodecParametersTypes.BIT_RATE */, codec.bitrate || 0 /* AudioBitrate.VARIABLE */, 3 /* AudioCodecParametersTypes.SAMPLE_RATE */, providedSamplerates);
996
- return encode(1 /* AudioCodecConfigurationTypes.CODEC_TYPE */, type, 2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */, audioParameters);
962
+ const audioParameters = tlv.encode(1 /* AudioCodecParametersTypes.CHANNEL */, Math.max(1, codec.audioChannels || 1), 2 /* AudioCodecParametersTypes.BIT_RATE */, codec.bitrate || 0 /* AudioBitrate.VARIABLE */, 3 /* AudioCodecParametersTypes.SAMPLE_RATE */, providedSamplerates);
963
+ return tlv.encode(1 /* AudioCodecConfigurationTypes.CODEC_TYPE */, type, 2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */, audioParameters);
997
964
  });
998
- return encode(1 /* SupportedAudioStreamConfigurationTypes.AUDIO_CODEC_CONFIGURATION */, codecConfigurations, 2 /* SupportedAudioStreamConfigurationTypes.COMFORT_NOISE_SUPPORT */, comfortNoise ? 1 : 0).toString('base64');
965
+ return tlv.encode(1 /* SupportedAudioStreamConfigurationTypes.AUDIO_CODEC_CONFIGURATION */, codecConfigurations, 2 /* SupportedAudioStreamConfigurationTypes.COMFORT_NOISE_SUPPORT */, comfortNoise ? 1 : 0).toString("base64");
999
966
  }
1000
967
  resetSetupEndpointsResponse() {
1001
- this.setupEndpointsResponse = encode(2 /* SetupEndpointsResponseTypes.STATUS */, 2 /* SetupEndpointsStatus.ERROR */).toString('base64');
1002
- this.service.updateCharacteristic(Characteristic.SetupEndpoints, this.setupEndpointsResponse);
968
+ this.setupEndpointsResponse = tlv.encode(2 /* SetupEndpointsResponseTypes.STATUS */, 2 /* SetupEndpointsStatus.ERROR */).toString("base64");
969
+ this.service.updateCharacteristic(Characteristic_1.Characteristic.SetupEndpoints, this.setupEndpointsResponse);
1003
970
  }
1004
971
  resetSelectedStreamConfiguration() {
1005
- this.selectedConfiguration = encode(1 /* SelectedRTPStreamConfigurationTypes.SESSION_CONTROL */, encode(2 /* SessionControlTypes.COMMAND */, SessionControlCommand.SUSPEND_SESSION)).toString('base64');
1006
- this.service.updateCharacteristic(Characteristic.SelectedRTPStreamConfiguration, this.selectedConfiguration);
972
+ this.selectedConfiguration = tlv.encode(1 /* SelectedRTPStreamConfigurationTypes.SESSION_CONTROL */, tlv.encode(2 /* SessionControlTypes.COMMAND */, SessionControlCommand.SUSPEND_SESSION)).toString("base64");
973
+ this.service.updateCharacteristic(Characteristic_1.Characteristic.SelectedRTPStreamConfiguration, this.selectedConfiguration);
1007
974
  }
1008
975
  /**
1009
976
  * @private
1010
977
  */
1011
978
  serialize() {
1012
- const characteristicValue = this.service.getCharacteristic(Characteristic.Active).value;
979
+ const characteristicValue = this.service.getCharacteristic(Characteristic_1.Characteristic.Active).value;
1013
980
  if (characteristicValue === true) {
1014
981
  return undefined;
1015
982
  }
@@ -1022,8 +989,8 @@ export class RTPStreamManagement {
1022
989
  * @private
1023
990
  */
1024
991
  deserialize(serialized) {
1025
- assert(serialized.id === this.id, `Tried to initialize RTPStreamManagement ${this.id} with data from management with id ${serialized.id}!`);
1026
- this.service.updateCharacteristic(Characteristic.Active, serialized.active);
992
+ (0, assert_1.default)(serialized.id === this.id, `Tried to initialize RTPStreamManagement ${this.id} with data from management with id ${serialized.id}!`);
993
+ this.service.updateCharacteristic(Characteristic_1.Characteristic.Active, serialized.active);
1027
994
  }
1028
995
  /**
1029
996
  * @private
@@ -1032,4 +999,5 @@ export class RTPStreamManagement {
1032
999
  this.stateChangeDelegate = delegate;
1033
1000
  }
1034
1001
  }
1002
+ exports.RTPStreamManagement = RTPStreamManagement;
1035
1003
  //# sourceMappingURL=RTPStreamManagement.js.map