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.
- package/@types/bonjour-hap.d.ts +53 -50
- package/@types/simple-plist.d.ts +4 -0
- package/README.md +19 -16
- package/dist/accessories/AirConditioner_accessory.js +32 -30
- package/dist/accessories/AirConditioner_accessory.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +86 -74
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +138 -143
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +24 -20
- package/dist/accessories/Fan_accessory.js.map +1 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +37 -35
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +46 -44
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +36 -34
- package/dist/accessories/Light_accessory.js.map +1 -1
- package/dist/accessories/Lock_accessory.js +28 -27
- package/dist/accessories/Lock_accessory.js.map +1 -1
- package/dist/accessories/MotionSensor_accessory.js +18 -15
- package/dist/accessories/MotionSensor_accessory.js.map +1 -1
- package/dist/accessories/Outlet_accessory.js +24 -22
- package/dist/accessories/Outlet_accessory.js.map +1 -1
- package/dist/accessories/SmartSpeaker_accessory.js +22 -20
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
- package/dist/accessories/Sprinkler_accessory.js +39 -36
- package/dist/accessories/Sprinkler_accessory.js.map +1 -1
- package/dist/accessories/TV_accessory.js +47 -45
- package/dist/accessories/TV_accessory.js.map +1 -1
- package/dist/accessories/TemperatureSensor_accessory.js +17 -14
- package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +14 -11
- package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +16 -13
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.d.ts +3 -3
- package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.js +39 -38
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
- package/dist/accessories/types.d.ts +63 -63
- package/dist/accessories/types.d.ts.map +1 -1
- package/dist/accessories/types.js +87 -83
- package/dist/accessories/types.js.map +1 -1
- package/dist/index.d.ts +28 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -40
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +1 -1
- package/dist/internal-types.d.ts.map +1 -1
- package/dist/internal-types.js +21 -19
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +37 -38
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +299 -289
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +7 -7
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +136 -128
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.d.ts +1 -1
- package/dist/lib/Bridge.d.ts.map +1 -1
- package/dist/lib/Bridge.js +6 -2
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +41 -40
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +210 -206
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +30 -35
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +229 -225
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +22 -22
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +71 -67
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +1 -2
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +44 -28
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +33 -34
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +149 -181
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +17 -19
- package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +153 -162
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.d.ts +3 -3
- package/dist/lib/camera/index.d.ts.map +1 -1
- package/dist/lib/camera/index.js +6 -3
- package/dist/lib/camera/index.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +33 -33
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +146 -154
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +20 -22
- package/dist/lib/controller/CameraController.d.ts.map +1 -1
- package/dist/lib/controller/CameraController.js +78 -74
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/Controller.d.ts +4 -4
- package/dist/lib/controller/Controller.d.ts.map +1 -1
- package/dist/lib/controller/Controller.js +8 -5
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +4 -5
- package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
- package/dist/lib/controller/DoorbellController.js +13 -9
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +37 -39
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +199 -210
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.d.ts +5 -5
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/controller/index.js +8 -5
- package/dist/lib/controller/index.js.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.d.ts +2 -2
- package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +40 -40
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +0 -1
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +77 -57
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +22 -27
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +164 -159
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.d.ts +3 -3
- package/dist/lib/datastream/index.d.ts.map +1 -1
- package/dist/lib/datastream/index.js +6 -3
- package/dist/lib/datastream/index.js.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +1203 -957
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +695 -620
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.d.ts +3 -3
- package/dist/lib/definitions/generate-definitions.d.ts.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +259 -247
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +181 -176
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/definitions/index.d.ts +2 -2
- package/dist/lib/definitions/index.d.ts.map +1 -1
- package/dist/lib/definitions/index.js +5 -2
- package/dist/lib/definitions/index.js.map +1 -1
- package/dist/lib/gen/HomeKit.d.ts +7 -0
- package/dist/lib/gen/HomeKit.d.ts.map +1 -0
- package/dist/lib/gen/HomeKit.js +8 -0
- package/dist/lib/gen/HomeKit.js.map +1 -0
- package/dist/lib/model/AccessoryInfo.d.ts +3 -4
- package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +55 -52
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.d.ts +3 -3
- package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
- package/dist/lib/model/ControllerStorage.js +23 -18
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.d.ts +2 -2
- package/dist/lib/model/HAPStorage.d.ts.map +1 -1
- package/dist/lib/model/HAPStorage.js +11 -4
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.d.ts +1 -1
- package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
- package/dist/lib/model/IdentifierCache.js +27 -19
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +9 -9
- package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +29 -27
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/checkName.d.ts +2 -2
- package/dist/lib/util/checkName.d.ts.map +1 -1
- package/dist/lib/util/checkName.js +9 -6
- package/dist/lib/util/checkName.js.map +1 -1
- package/dist/lib/util/clone.d.ts.map +1 -1
- package/dist/lib/util/clone.js +5 -1
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.d.ts +1 -1
- package/dist/lib/util/color-utils.d.ts.map +1 -1
- package/dist/lib/util/color-utils.js +9 -4
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts +22 -23
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +116 -109
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +2 -3
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +40 -31
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.d.ts +1 -1
- package/dist/lib/util/hapStatusError.d.ts.map +1 -1
- package/dist/lib/util/hapStatusError.js +8 -4
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.d.ts +1 -1
- package/dist/lib/util/net-utils.js +23 -17
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.d.ts.map +1 -1
- package/dist/lib/util/once.js +6 -2
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.d.ts +1 -1
- package/dist/lib/util/promise-utils.d.ts.map +1 -1
- package/dist/lib/util/promise-utils.js +10 -3
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.d.ts +2 -3
- package/dist/lib/util/request-util.d.ts.map +1 -1
- package/dist/lib/util/request-util.js +19 -11
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +0 -1
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +11 -6
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +0 -1
- package/dist/lib/util/tlv.d.ts.map +1 -1
- package/dist/lib/util/tlv.js +43 -28
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +0 -1
- package/dist/lib/util/uuid.d.ts.map +1 -1
- package/dist/lib/util/uuid.js +38 -26
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +24 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -3
- package/dist/types.js.map +1 -1
- package/package.json +47 -52
- package/dist/lib/dbus/align.d.ts +0 -2
- package/dist/lib/dbus/align.d.ts.map +0 -1
- package/dist/lib/dbus/align.js +0 -12
- package/dist/lib/dbus/align.js.map +0 -1
- package/dist/lib/dbus/bus.d.ts +0 -38
- package/dist/lib/dbus/bus.d.ts.map +0 -1
- package/dist/lib/dbus/bus.js +0 -222
- package/dist/lib/dbus/bus.js.map +0 -1
- package/dist/lib/dbus/constants.d.ts +0 -43
- package/dist/lib/dbus/constants.d.ts.map +0 -1
- package/dist/lib/dbus/constants.js +0 -53
- package/dist/lib/dbus/constants.js.map +0 -1
- package/dist/lib/dbus/dbus-buffer.d.ts +0 -30
- package/dist/lib/dbus/dbus-buffer.d.ts.map +0 -1
- package/dist/lib/dbus/dbus-buffer.js +0 -175
- package/dist/lib/dbus/dbus-buffer.js.map +0 -1
- package/dist/lib/dbus/handshake.d.ts +0 -2
- package/dist/lib/dbus/handshake.d.ts.map +0 -1
- package/dist/lib/dbus/handshake.js +0 -130
- package/dist/lib/dbus/handshake.js.map +0 -1
- package/dist/lib/dbus/index.d.ts +0 -3
- package/dist/lib/dbus/index.d.ts.map +0 -1
- package/dist/lib/dbus/index.js +0 -123
- package/dist/lib/dbus/index.js.map +0 -1
- package/dist/lib/dbus/introspect.d.ts +0 -30
- package/dist/lib/dbus/introspect.d.ts.map +0 -1
- package/dist/lib/dbus/introspect.js +0 -208
- package/dist/lib/dbus/introspect.js.map +0 -1
- package/dist/lib/dbus/marshall.d.ts +0 -2
- package/dist/lib/dbus/marshall.d.ts.map +0 -1
- package/dist/lib/dbus/marshall.js +0 -97
- package/dist/lib/dbus/marshall.js.map +0 -1
- package/dist/lib/dbus/marshallers.d.ts +0 -10
- package/dist/lib/dbus/marshallers.d.ts.map +0 -1
- package/dist/lib/dbus/marshallers.js +0 -329
- package/dist/lib/dbus/marshallers.js.map +0 -1
- package/dist/lib/dbus/message.d.ts +0 -4
- package/dist/lib/dbus/message.d.ts.map +0 -1
- package/dist/lib/dbus/message.js +0 -116
- package/dist/lib/dbus/message.js.map +0 -1
- package/dist/lib/dbus/put.d.ts +0 -21
- package/dist/lib/dbus/put.d.ts.map +0 -1
- package/dist/lib/dbus/put.js +0 -120
- package/dist/lib/dbus/put.js.map +0 -1
- package/dist/lib/dbus/readline.d.ts +0 -2
- package/dist/lib/dbus/readline.d.ts.map +0 -1
- package/dist/lib/dbus/readline.js +0 -27
- package/dist/lib/dbus/readline.js.map +0 -1
- package/dist/lib/dbus/signature.d.ts +0 -2
- package/dist/lib/dbus/signature.d.ts.map +0 -1
- package/dist/lib/dbus/signature.js +0 -59
- package/dist/lib/dbus/signature.js.map +0 -1
- package/dist/lib/dbus/stdifaces.d.ts +0 -3
- package/dist/lib/dbus/stdifaces.d.ts.map +0 -1
- package/dist/lib/dbus/stdifaces.js +0 -206
- package/dist/lib/dbus/stdifaces.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SiriAudioSession = exports.SiriAudioSessionEvents = exports.RemoteController = exports.RemoteControllerEvents = exports.TargetUpdates = exports.AudioCodecTypes = exports.ButtonState = exports.TargetCategory = exports.ButtonType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const Characteristic_1 = require("../Characteristic");
|
|
9
|
+
const datastream_1 = require("../datastream");
|
|
10
|
+
const Service_1 = require("../Service");
|
|
11
|
+
const tlv = tslib_1.__importStar(require("../util/tlv"));
|
|
12
|
+
const debug = (0, debug_1.default)("HAP-NodeJS:Remote:Controller");
|
|
11
13
|
var TargetControlCommands;
|
|
12
14
|
(function (TargetControlCommands) {
|
|
13
15
|
TargetControlCommands[TargetControlCommands["MAXIMUM_TARGETS"] = 1] = "MAXIMUM_TARGETS";
|
|
@@ -15,7 +17,6 @@ var TargetControlCommands;
|
|
|
15
17
|
TargetControlCommands[TargetControlCommands["SUPPORTED_BUTTON_CONFIGURATION"] = 3] = "SUPPORTED_BUTTON_CONFIGURATION";
|
|
16
18
|
TargetControlCommands[TargetControlCommands["TYPE"] = 4] = "TYPE";
|
|
17
19
|
})(TargetControlCommands || (TargetControlCommands = {}));
|
|
18
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
19
20
|
var SupportedButtonConfigurationTypes;
|
|
20
21
|
(function (SupportedButtonConfigurationTypes) {
|
|
21
22
|
SupportedButtonConfigurationTypes[SupportedButtonConfigurationTypes["BUTTON_ID"] = 1] = "BUTTON_ID";
|
|
@@ -24,9 +25,9 @@ var SupportedButtonConfigurationTypes;
|
|
|
24
25
|
/**
|
|
25
26
|
* @group Apple TV Remote
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
-
export var ButtonType;
|
|
28
|
+
var ButtonType;
|
|
29
29
|
(function (ButtonType) {
|
|
30
|
+
// noinspection JSUnusedGlobalSymbols
|
|
30
31
|
ButtonType[ButtonType["UNDEFINED"] = 0] = "UNDEFINED";
|
|
31
32
|
ButtonType[ButtonType["MENU"] = 1] = "MENU";
|
|
32
33
|
ButtonType[ButtonType["PLAY_PAUSE"] = 2] = "PLAY_PAUSE";
|
|
@@ -41,8 +42,7 @@ export var ButtonType;
|
|
|
41
42
|
ButtonType[ButtonType["SIRI"] = 11] = "SIRI";
|
|
42
43
|
ButtonType[ButtonType["POWER"] = 12] = "POWER";
|
|
43
44
|
ButtonType[ButtonType["GENERIC"] = 13] = "GENERIC";
|
|
44
|
-
})(ButtonType || (ButtonType = {}));
|
|
45
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
45
|
+
})(ButtonType || (exports.ButtonType = ButtonType = {}));
|
|
46
46
|
var TargetControlList;
|
|
47
47
|
(function (TargetControlList) {
|
|
48
48
|
TargetControlList[TargetControlList["OPERATION"] = 1] = "OPERATION";
|
|
@@ -50,6 +50,7 @@ var TargetControlList;
|
|
|
50
50
|
})(TargetControlList || (TargetControlList = {}));
|
|
51
51
|
var Operation;
|
|
52
52
|
(function (Operation) {
|
|
53
|
+
// noinspection JSUnusedGlobalSymbols
|
|
53
54
|
Operation[Operation["UNDEFINED"] = 0] = "UNDEFINED";
|
|
54
55
|
Operation[Operation["LIST"] = 1] = "LIST";
|
|
55
56
|
Operation[Operation["ADD"] = 2] = "ADD";
|
|
@@ -57,7 +58,6 @@ var Operation;
|
|
|
57
58
|
Operation[Operation["RESET"] = 4] = "RESET";
|
|
58
59
|
Operation[Operation["UPDATE"] = 5] = "UPDATE";
|
|
59
60
|
})(Operation || (Operation = {}));
|
|
60
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
61
61
|
var TargetConfigurationTypes;
|
|
62
62
|
(function (TargetConfigurationTypes) {
|
|
63
63
|
TargetConfigurationTypes[TargetConfigurationTypes["TARGET_IDENTIFIER"] = 1] = "TARGET_IDENTIFIER";
|
|
@@ -68,20 +68,18 @@ var TargetConfigurationTypes;
|
|
|
68
68
|
/**
|
|
69
69
|
* @group Apple TV Remote
|
|
70
70
|
*/
|
|
71
|
-
|
|
72
|
-
export var TargetCategory;
|
|
71
|
+
var TargetCategory;
|
|
73
72
|
(function (TargetCategory) {
|
|
73
|
+
// noinspection JSUnusedGlobalSymbols
|
|
74
74
|
TargetCategory[TargetCategory["UNDEFINED"] = 0] = "UNDEFINED";
|
|
75
75
|
TargetCategory[TargetCategory["APPLE_TV"] = 24] = "APPLE_TV";
|
|
76
|
-
})(TargetCategory || (TargetCategory = {}));
|
|
77
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
76
|
+
})(TargetCategory || (exports.TargetCategory = TargetCategory = {}));
|
|
78
77
|
var ButtonConfigurationTypes;
|
|
79
78
|
(function (ButtonConfigurationTypes) {
|
|
80
79
|
ButtonConfigurationTypes[ButtonConfigurationTypes["BUTTON_ID"] = 1] = "BUTTON_ID";
|
|
81
80
|
ButtonConfigurationTypes[ButtonConfigurationTypes["BUTTON_TYPE"] = 2] = "BUTTON_TYPE";
|
|
82
81
|
ButtonConfigurationTypes[ButtonConfigurationTypes["BUTTON_NAME"] = 3] = "BUTTON_NAME";
|
|
83
82
|
})(ButtonConfigurationTypes || (ButtonConfigurationTypes = {}));
|
|
84
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
85
83
|
var ButtonEvent;
|
|
86
84
|
(function (ButtonEvent) {
|
|
87
85
|
ButtonEvent[ButtonEvent["BUTTON_ID"] = 1] = "BUTTON_ID";
|
|
@@ -92,25 +90,22 @@ var ButtonEvent;
|
|
|
92
90
|
/**
|
|
93
91
|
* @group Apple TV Remote
|
|
94
92
|
*/
|
|
95
|
-
|
|
96
|
-
export var ButtonState;
|
|
93
|
+
var ButtonState;
|
|
97
94
|
(function (ButtonState) {
|
|
98
95
|
ButtonState[ButtonState["UP"] = 0] = "UP";
|
|
99
96
|
ButtonState[ButtonState["DOWN"] = 1] = "DOWN";
|
|
100
|
-
})(ButtonState || (ButtonState = {}));
|
|
101
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
97
|
+
})(ButtonState || (exports.ButtonState = ButtonState = {}));
|
|
102
98
|
var SelectedAudioInputStreamConfigurationTypes;
|
|
103
99
|
(function (SelectedAudioInputStreamConfigurationTypes) {
|
|
104
100
|
SelectedAudioInputStreamConfigurationTypes[SelectedAudioInputStreamConfigurationTypes["SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION"] = 1] = "SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION";
|
|
105
101
|
})(SelectedAudioInputStreamConfigurationTypes || (SelectedAudioInputStreamConfigurationTypes = {}));
|
|
106
102
|
// ----------
|
|
107
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
108
103
|
var SupportedAudioStreamConfigurationTypes;
|
|
109
104
|
(function (SupportedAudioStreamConfigurationTypes) {
|
|
105
|
+
// noinspection JSUnusedGlobalSymbols
|
|
110
106
|
SupportedAudioStreamConfigurationTypes[SupportedAudioStreamConfigurationTypes["AUDIO_CODEC_CONFIGURATION"] = 1] = "AUDIO_CODEC_CONFIGURATION";
|
|
111
107
|
SupportedAudioStreamConfigurationTypes[SupportedAudioStreamConfigurationTypes["COMFORT_NOISE_SUPPORT"] = 2] = "COMFORT_NOISE_SUPPORT";
|
|
112
108
|
})(SupportedAudioStreamConfigurationTypes || (SupportedAudioStreamConfigurationTypes = {}));
|
|
113
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
114
109
|
var AudioCodecConfigurationTypes;
|
|
115
110
|
(function (AudioCodecConfigurationTypes) {
|
|
116
111
|
AudioCodecConfigurationTypes[AudioCodecConfigurationTypes["CODEC_TYPE"] = 1] = "CODEC_TYPE";
|
|
@@ -119,9 +114,9 @@ var AudioCodecConfigurationTypes;
|
|
|
119
114
|
/**
|
|
120
115
|
* @group Camera
|
|
121
116
|
*/
|
|
122
|
-
|
|
123
|
-
export var AudioCodecTypes;
|
|
117
|
+
var AudioCodecTypes;
|
|
124
118
|
(function (AudioCodecTypes) {
|
|
119
|
+
// noinspection JSUnusedGlobalSymbols
|
|
125
120
|
AudioCodecTypes[AudioCodecTypes["PCMU"] = 0] = "PCMU";
|
|
126
121
|
AudioCodecTypes[AudioCodecTypes["PCMA"] = 1] = "PCMA";
|
|
127
122
|
AudioCodecTypes[AudioCodecTypes["AAC_ELD"] = 2] = "AAC_ELD";
|
|
@@ -129,16 +124,14 @@ export var AudioCodecTypes;
|
|
|
129
124
|
AudioCodecTypes[AudioCodecTypes["MSBC"] = 4] = "MSBC";
|
|
130
125
|
AudioCodecTypes[AudioCodecTypes["AMR"] = 5] = "AMR";
|
|
131
126
|
AudioCodecTypes[AudioCodecTypes["AMR_WB"] = 6] = "AMR_WB";
|
|
132
|
-
})(AudioCodecTypes || (AudioCodecTypes = {}));
|
|
133
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
127
|
+
})(AudioCodecTypes || (exports.AudioCodecTypes = AudioCodecTypes = {}));
|
|
134
128
|
var AudioCodecParametersTypes;
|
|
135
129
|
(function (AudioCodecParametersTypes) {
|
|
136
130
|
AudioCodecParametersTypes[AudioCodecParametersTypes["CHANNEL"] = 1] = "CHANNEL";
|
|
137
131
|
AudioCodecParametersTypes[AudioCodecParametersTypes["BIT_RATE"] = 2] = "BIT_RATE";
|
|
138
132
|
AudioCodecParametersTypes[AudioCodecParametersTypes["SAMPLE_RATE"] = 3] = "SAMPLE_RATE";
|
|
139
|
-
AudioCodecParametersTypes[AudioCodecParametersTypes["PACKET_TIME"] = 4] = "PACKET_TIME";
|
|
133
|
+
AudioCodecParametersTypes[AudioCodecParametersTypes["PACKET_TIME"] = 4] = "PACKET_TIME"; // only present in selected audio codec parameters tlv
|
|
140
134
|
})(AudioCodecParametersTypes || (AudioCodecParametersTypes = {}));
|
|
141
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
142
135
|
var SiriAudioSessionState;
|
|
143
136
|
(function (SiriAudioSessionState) {
|
|
144
137
|
SiriAudioSessionState[SiriAudioSessionState["STARTING"] = 0] = "STARTING";
|
|
@@ -149,19 +142,17 @@ var SiriAudioSessionState;
|
|
|
149
142
|
/**
|
|
150
143
|
* @group Apple TV Remote
|
|
151
144
|
*/
|
|
152
|
-
|
|
153
|
-
export var TargetUpdates;
|
|
145
|
+
var TargetUpdates;
|
|
154
146
|
(function (TargetUpdates) {
|
|
155
147
|
TargetUpdates[TargetUpdates["NAME"] = 0] = "NAME";
|
|
156
148
|
TargetUpdates[TargetUpdates["CATEGORY"] = 1] = "CATEGORY";
|
|
157
149
|
TargetUpdates[TargetUpdates["UPDATED_BUTTONS"] = 2] = "UPDATED_BUTTONS";
|
|
158
150
|
TargetUpdates[TargetUpdates["REMOVED_BUTTONS"] = 3] = "REMOVED_BUTTONS";
|
|
159
|
-
})(TargetUpdates || (TargetUpdates = {}));
|
|
151
|
+
})(TargetUpdates || (exports.TargetUpdates = TargetUpdates = {}));
|
|
160
152
|
/**
|
|
161
153
|
* @group Apple TV Remote
|
|
162
154
|
*/
|
|
163
|
-
|
|
164
|
-
export var RemoteControllerEvents;
|
|
155
|
+
var RemoteControllerEvents;
|
|
165
156
|
(function (RemoteControllerEvents) {
|
|
166
157
|
/**
|
|
167
158
|
* This event is emitted when the active state of the remote has changed.
|
|
@@ -195,17 +186,18 @@ export var RemoteControllerEvents;
|
|
|
195
186
|
* when the accessory gets unpaired.
|
|
196
187
|
*/
|
|
197
188
|
RemoteControllerEvents["TARGETS_RESET"] = "targets-reset";
|
|
198
|
-
})(RemoteControllerEvents || (RemoteControllerEvents = {}));
|
|
189
|
+
})(RemoteControllerEvents || (exports.RemoteControllerEvents = RemoteControllerEvents = {}));
|
|
199
190
|
/**
|
|
200
191
|
* Handles everything needed to implement a fully working HomeKit remote controller.
|
|
201
192
|
*
|
|
202
193
|
* @group Apple TV Remote
|
|
203
194
|
*/
|
|
204
|
-
// eslint-disable-next-line
|
|
205
|
-
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
196
|
+
class RemoteController extends events_1.EventEmitter {
|
|
206
197
|
stateChangeDelegate;
|
|
207
198
|
audioSupported;
|
|
208
199
|
audioProducerConstructor;
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
209
201
|
audioProducerOptions;
|
|
210
202
|
targetControlManagementService;
|
|
211
203
|
targetControlService;
|
|
@@ -215,8 +207,8 @@ export class RemoteController extends EventEmitter {
|
|
|
215
207
|
buttons = {}; // internal mapping of buttonId to buttonType for supported buttons
|
|
216
208
|
supportedConfiguration;
|
|
217
209
|
targetConfigurations = new Map();
|
|
218
|
-
targetConfigurationsString =
|
|
219
|
-
lastButtonEvent =
|
|
210
|
+
targetConfigurationsString = "";
|
|
211
|
+
lastButtonEvent = "";
|
|
220
212
|
activeIdentifier = 0; // id of 0 means no device selected
|
|
221
213
|
activeConnection; // session which marked this remote as active and listens for events and siri
|
|
222
214
|
activeConnectionDisconnectListener;
|
|
@@ -243,8 +235,9 @@ export class RemoteController extends EventEmitter {
|
|
|
243
235
|
*
|
|
244
236
|
* @param audioProducerConstructor - constructor for a SiriAudioStreamProducer
|
|
245
237
|
* @param producerOptions - if supplied this argument will be supplied as third argument of the SiriAudioStreamProducer
|
|
246
|
-
*
|
|
238
|
+
* constructor. This should be used to supply configurations to the stream producer.
|
|
247
239
|
*/
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
|
|
248
241
|
constructor(audioProducerConstructor, producerOptions) {
|
|
249
242
|
super();
|
|
250
243
|
this.audioSupported = audioProducerConstructor !== undefined;
|
|
@@ -283,11 +276,11 @@ export class RemoteController extends EventEmitter {
|
|
|
283
276
|
return;
|
|
284
277
|
}
|
|
285
278
|
if (activeIdentifier !== 0 && !this.targetConfigurations.has(activeIdentifier)) {
|
|
286
|
-
throw
|
|
279
|
+
throw Error("Tried setting unconfigured targetIdentifier to active");
|
|
287
280
|
}
|
|
288
|
-
debug(
|
|
281
|
+
debug("%d is now the active target", activeIdentifier);
|
|
289
282
|
this.activeIdentifier = activeIdentifier;
|
|
290
|
-
this.targetControlService.getCharacteristic(Characteristic.ActiveIdentifier).updateValue(activeIdentifier);
|
|
283
|
+
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ActiveIdentifier).updateValue(activeIdentifier);
|
|
291
284
|
if (this.activeAudioSession) {
|
|
292
285
|
this.handleSiriAudioStop();
|
|
293
286
|
}
|
|
@@ -317,7 +310,7 @@ export class RemoteController extends EventEmitter {
|
|
|
317
310
|
getTargetIdentifierByName(name) {
|
|
318
311
|
for (const [activeIdentifier, configuration] of Object.entries(this.targetConfigurations)) {
|
|
319
312
|
if (configuration.targetName === name) {
|
|
320
|
-
return
|
|
313
|
+
return parseInt(activeIdentifier, 10);
|
|
321
314
|
}
|
|
322
315
|
}
|
|
323
316
|
return undefined;
|
|
@@ -358,23 +351,14 @@ export class RemoteController extends EventEmitter {
|
|
|
358
351
|
hardwareImplemented: this.audioSupported, // siri is only allowed for hardware implemented remotes
|
|
359
352
|
};
|
|
360
353
|
const supportedButtons = [
|
|
361
|
-
1 /* ButtonType.MENU */,
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
4 /* ButtonType.SELECT */,
|
|
365
|
-
5 /* ButtonType.ARROW_UP */,
|
|
366
|
-
6 /* ButtonType.ARROW_RIGHT */,
|
|
367
|
-
7 /* ButtonType.ARROW_DOWN */,
|
|
368
|
-
8 /* ButtonType.ARROW_LEFT */,
|
|
369
|
-
9 /* ButtonType.VOLUME_UP */,
|
|
370
|
-
10 /* ButtonType.VOLUME_DOWN */,
|
|
371
|
-
12 /* ButtonType.POWER */,
|
|
372
|
-
13 /* ButtonType.GENERIC */,
|
|
354
|
+
1 /* ButtonType.MENU */, 2 /* ButtonType.PLAY_PAUSE */, 3 /* ButtonType.TV_HOME */, 4 /* ButtonType.SELECT */,
|
|
355
|
+
5 /* ButtonType.ARROW_UP */, 6 /* ButtonType.ARROW_RIGHT */, 7 /* ButtonType.ARROW_DOWN */, 8 /* ButtonType.ARROW_LEFT */,
|
|
356
|
+
9 /* ButtonType.VOLUME_UP */, 10 /* ButtonType.VOLUME_DOWN */, 12 /* ButtonType.POWER */, 13 /* ButtonType.GENERIC */,
|
|
373
357
|
];
|
|
374
358
|
if (this.audioSupported) { // add siri button if this remote supports it
|
|
375
359
|
supportedButtons.push(11 /* ButtonType.SIRI */);
|
|
376
360
|
}
|
|
377
|
-
supportedButtons.forEach(
|
|
361
|
+
supportedButtons.forEach(button => {
|
|
378
362
|
const buttonConfiguration = {
|
|
379
363
|
buttonID: 100 + button,
|
|
380
364
|
buttonType: button,
|
|
@@ -398,15 +382,16 @@ export class RemoteController extends EventEmitter {
|
|
|
398
382
|
};
|
|
399
383
|
}
|
|
400
384
|
// --------------------------------- TARGET CONTROL ----------------------------------
|
|
385
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
401
386
|
handleTargetControlWrite(value, callback) {
|
|
402
|
-
const data = Buffer.from(value,
|
|
403
|
-
const objects = decode(data);
|
|
387
|
+
const data = Buffer.from(value, "base64");
|
|
388
|
+
const objects = tlv.decode(data);
|
|
404
389
|
const operation = objects[1 /* TargetControlList.OPERATION */][0];
|
|
405
|
-
let targetConfiguration;
|
|
390
|
+
let targetConfiguration = undefined;
|
|
406
391
|
if (objects[2 /* TargetControlList.TARGET_CONFIGURATION */]) { // if target configuration was sent, parse it
|
|
407
392
|
targetConfiguration = this.parseTargetConfigurationTLV(objects[2 /* TargetControlList.TARGET_CONFIGURATION */]);
|
|
408
393
|
}
|
|
409
|
-
debug(
|
|
394
|
+
debug("Received TargetControl write operation %s", Operation[operation]);
|
|
410
395
|
let handler;
|
|
411
396
|
switch (operation) {
|
|
412
397
|
case Operation.ADD:
|
|
@@ -436,7 +421,7 @@ export class RemoteController extends EventEmitter {
|
|
|
436
421
|
}
|
|
437
422
|
}
|
|
438
423
|
else {
|
|
439
|
-
callback(new Error(
|
|
424
|
+
callback(new Error(status + ""));
|
|
440
425
|
}
|
|
441
426
|
}
|
|
442
427
|
handleAddTarget(targetConfiguration) {
|
|
@@ -444,7 +429,7 @@ export class RemoteController extends EventEmitter {
|
|
|
444
429
|
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
445
430
|
}
|
|
446
431
|
this.targetConfigurations.set(targetConfiguration.targetIdentifier, targetConfiguration);
|
|
447
|
-
debug(
|
|
432
|
+
debug("Configured new target '" + targetConfiguration.targetName + "' with targetIdentifier '" + targetConfiguration.targetIdentifier + "'");
|
|
448
433
|
setTimeout(() => this.emit("target-add" /* RemoteControllerEvents.TARGET_ADDED */, targetConfiguration), 0);
|
|
449
434
|
this.updatedTargetConfiguration(); // set response
|
|
450
435
|
return 0 /* HAPStatus.SUCCESS */;
|
|
@@ -459,17 +444,17 @@ export class RemoteController extends EventEmitter {
|
|
|
459
444
|
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
460
445
|
}
|
|
461
446
|
if (targetConfiguration.targetName) {
|
|
462
|
-
debug(
|
|
447
|
+
debug("Target name was updated '%s' => '%s' (%d)", configuredTarget.targetName, targetConfiguration.targetName, configuredTarget.targetIdentifier);
|
|
463
448
|
configuredTarget.targetName = targetConfiguration.targetName;
|
|
464
449
|
updates.push(0 /* TargetUpdates.NAME */);
|
|
465
450
|
}
|
|
466
451
|
if (targetConfiguration.targetCategory) {
|
|
467
|
-
debug(
|
|
452
|
+
debug("Target category was updated '%d' => '%d' for target '%s' (%d)", configuredTarget.targetCategory, targetConfiguration.targetCategory, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
468
453
|
configuredTarget.targetCategory = targetConfiguration.targetCategory;
|
|
469
454
|
updates.push(1 /* TargetUpdates.CATEGORY */);
|
|
470
455
|
}
|
|
471
456
|
if (targetConfiguration.buttonConfiguration) {
|
|
472
|
-
debug(
|
|
457
|
+
debug("%d button configurations were updated for target '%s' (%d)", Object.keys(targetConfiguration.buttonConfiguration).length, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
473
458
|
for (const configuration of Object.values(targetConfiguration.buttonConfiguration)) {
|
|
474
459
|
const savedConfiguration = configuredTarget.buttonConfiguration[configuration.buttonID];
|
|
475
460
|
savedConfiguration.buttonType = configuration.buttonType;
|
|
@@ -495,15 +480,15 @@ export class RemoteController extends EventEmitter {
|
|
|
495
480
|
delete configuredTarget.buttonConfiguration[key];
|
|
496
481
|
}
|
|
497
482
|
}
|
|
498
|
-
debug(
|
|
483
|
+
debug("Removed %d button configurations of target '%s' (%d)", Object.keys(targetConfiguration.buttonConfiguration).length, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
499
484
|
setTimeout(() => this.emit("target-update" /* RemoteControllerEvents.TARGET_UPDATED */, configuredTarget, [3 /* TargetUpdates.REMOVED_BUTTONS */]), 0);
|
|
500
485
|
}
|
|
501
486
|
else {
|
|
502
487
|
this.targetConfigurations.delete(targetConfiguration.targetIdentifier);
|
|
503
|
-
debug(
|
|
488
|
+
debug("Target '%s' (%d) was removed", configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
504
489
|
setTimeout(() => this.emit("target-remove" /* RemoteControllerEvents.TARGET_REMOVED */, targetConfiguration.targetIdentifier), 0);
|
|
505
490
|
const keys = Object.keys(this.targetConfigurations);
|
|
506
|
-
this.setActiveIdentifier(keys.length === 0 ? 0 :
|
|
491
|
+
this.setActiveIdentifier(keys.length === 0 ? 0 : parseInt(keys[0], 10)); // switch to next available remote
|
|
507
492
|
}
|
|
508
493
|
this.updatedTargetConfiguration(); // set response
|
|
509
494
|
return 0 /* HAPStatus.SUCCESS */;
|
|
@@ -512,7 +497,7 @@ export class RemoteController extends EventEmitter {
|
|
|
512
497
|
if (targetConfiguration) {
|
|
513
498
|
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
514
499
|
}
|
|
515
|
-
debug(
|
|
500
|
+
debug("Resetting all target configurations");
|
|
516
501
|
this.targetConfigurations = new Map();
|
|
517
502
|
this.updatedTargetConfiguration(); // set response
|
|
518
503
|
setTimeout(() => this.emit("targets-reset" /* RemoteControllerEvents.TARGETS_RESET */), 0);
|
|
@@ -524,12 +509,12 @@ export class RemoteController extends EventEmitter {
|
|
|
524
509
|
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
525
510
|
}
|
|
526
511
|
// this.targetConfigurationsString is updated after each change, so we basically don't need to do anything here
|
|
527
|
-
debug(
|
|
512
|
+
debug("Returning " + Object.keys(this.targetConfigurations).length + " target configurations");
|
|
528
513
|
return 0 /* HAPStatus.SUCCESS */;
|
|
529
514
|
}
|
|
530
515
|
handleActiveWrite(value, callback, connection) {
|
|
531
516
|
if (this.activeIdentifier === 0) {
|
|
532
|
-
debug(
|
|
517
|
+
debug("Tried to change active state. There is no active target set though");
|
|
533
518
|
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
534
519
|
return;
|
|
535
520
|
}
|
|
@@ -548,7 +533,7 @@ export class RemoteController extends EventEmitter {
|
|
|
548
533
|
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
549
534
|
return;
|
|
550
535
|
}
|
|
551
|
-
debug(
|
|
536
|
+
debug("Remote with activeTarget '%s' (%d) was set to %s", activeTarget.targetName, this.activeIdentifier, value ? "ACTIVE" : "INACTIVE");
|
|
552
537
|
callback();
|
|
553
538
|
this.emit("active-change" /* RemoteControllerEvents.ACTIVE_CHANGE */, value);
|
|
554
539
|
}
|
|
@@ -559,27 +544,27 @@ export class RemoteController extends EventEmitter {
|
|
|
559
544
|
this.activeConnection.removeListener("closed" /* HAPConnectionEvent.CLOSED */, this.activeConnectionDisconnectListener);
|
|
560
545
|
this.activeConnection = undefined;
|
|
561
546
|
this.activeConnectionDisconnectListener = undefined;
|
|
562
|
-
this.targetControlService.getCharacteristic(Characteristic.Active).updateValue(false);
|
|
563
|
-
debug(
|
|
547
|
+
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.Active).updateValue(false);
|
|
548
|
+
debug("Remote was set to INACTIVE");
|
|
564
549
|
setTimeout(() => this.emit("active-change" /* RemoteControllerEvents.ACTIVE_CHANGE */, false), 0);
|
|
565
550
|
}
|
|
566
551
|
handleActiveSessionDisconnected(connection) {
|
|
567
552
|
if (connection !== this.activeConnection) {
|
|
568
553
|
return;
|
|
569
554
|
}
|
|
570
|
-
debug(
|
|
555
|
+
debug("Active hap session disconnected!");
|
|
571
556
|
this.setInactive();
|
|
572
557
|
}
|
|
573
558
|
sendButtonEvent(button, buttonState) {
|
|
574
559
|
const buttonID = this.buttons[button];
|
|
575
560
|
if (buttonID === undefined || buttonID === 0) {
|
|
576
|
-
throw new Error(
|
|
561
|
+
throw new Error("Tried sending button event for unsupported button (" + button + ")");
|
|
577
562
|
}
|
|
578
563
|
if (this.activeIdentifier === 0) { // cannot press button if no device is selected
|
|
579
|
-
throw new Error(
|
|
564
|
+
throw new Error("Tried sending button event although no target was selected");
|
|
580
565
|
}
|
|
581
566
|
if (!this.isActive()) { // cannot press button if device is not active (aka no Apple TV is listening)
|
|
582
|
-
throw new Error(
|
|
567
|
+
throw new Error("Tried sending button event although target was not marked as active");
|
|
583
568
|
}
|
|
584
569
|
if (button === 11 /* ButtonType.SIRI */ && this.audioSupported) {
|
|
585
570
|
if (buttonState === 1 /* ButtonState.DOWN */) { // start streaming session
|
|
@@ -590,47 +575,44 @@ export class RemoteController extends EventEmitter {
|
|
|
590
575
|
}
|
|
591
576
|
return;
|
|
592
577
|
}
|
|
593
|
-
const buttonIdTlv = encode(1 /* ButtonEvent.BUTTON_ID */, buttonID);
|
|
594
|
-
const buttonStateTlv = encode(2 /* ButtonEvent.BUTTON_STATE */, buttonState);
|
|
595
|
-
const timestampTlv = encode(3 /* ButtonEvent.TIMESTAMP */, writeVariableUIntLE(new Date().getTime()));
|
|
596
|
-
const activeIdentifierTlv = encode(4 /* ButtonEvent.ACTIVE_IDENTIFIER */, writeUInt32(this.activeIdentifier));
|
|
578
|
+
const buttonIdTlv = tlv.encode(1 /* ButtonEvent.BUTTON_ID */, buttonID);
|
|
579
|
+
const buttonStateTlv = tlv.encode(2 /* ButtonEvent.BUTTON_STATE */, buttonState);
|
|
580
|
+
const timestampTlv = tlv.encode(3 /* ButtonEvent.TIMESTAMP */, tlv.writeVariableUIntLE(new Date().getTime()));
|
|
581
|
+
const activeIdentifierTlv = tlv.encode(4 /* ButtonEvent.ACTIVE_IDENTIFIER */, tlv.writeUInt32(this.activeIdentifier));
|
|
597
582
|
this.lastButtonEvent = Buffer.concat([
|
|
598
|
-
buttonIdTlv,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
activeIdentifierTlv,
|
|
602
|
-
]).toString('base64');
|
|
603
|
-
this.targetControlService.getCharacteristic(Characteristic.ButtonEvent).sendEventNotification(this.lastButtonEvent);
|
|
583
|
+
buttonIdTlv, buttonStateTlv, timestampTlv, activeIdentifierTlv,
|
|
584
|
+
]).toString("base64");
|
|
585
|
+
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ButtonEvent).sendEventNotification(this.lastButtonEvent);
|
|
604
586
|
}
|
|
605
587
|
parseTargetConfigurationTLV(data) {
|
|
606
|
-
const configTLV = decode(data);
|
|
607
|
-
const identifier = readUInt32(configTLV[1 /* TargetConfigurationTypes.TARGET_IDENTIFIER */]);
|
|
608
|
-
let name;
|
|
588
|
+
const configTLV = tlv.decode(data);
|
|
589
|
+
const identifier = tlv.readUInt32(configTLV[1 /* TargetConfigurationTypes.TARGET_IDENTIFIER */]);
|
|
590
|
+
let name = undefined;
|
|
609
591
|
if (configTLV[2 /* TargetConfigurationTypes.TARGET_NAME */]) {
|
|
610
592
|
name = configTLV[2 /* TargetConfigurationTypes.TARGET_NAME */].toString();
|
|
611
593
|
}
|
|
612
|
-
let category;
|
|
594
|
+
let category = undefined;
|
|
613
595
|
if (configTLV[3 /* TargetConfigurationTypes.TARGET_CATEGORY */]) {
|
|
614
|
-
category = readUInt16(configTLV[3 /* TargetConfigurationTypes.TARGET_CATEGORY */]);
|
|
596
|
+
category = tlv.readUInt16(configTLV[3 /* TargetConfigurationTypes.TARGET_CATEGORY */]);
|
|
615
597
|
}
|
|
616
598
|
const buttonConfiguration = {};
|
|
617
599
|
if (configTLV[4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */]) {
|
|
618
|
-
const buttonConfigurationTLV = decodeList(configTLV[4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */], 1 /* ButtonConfigurationTypes.BUTTON_ID */);
|
|
619
|
-
buttonConfigurationTLV.forEach(
|
|
600
|
+
const buttonConfigurationTLV = tlv.decodeList(configTLV[4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */], 1 /* ButtonConfigurationTypes.BUTTON_ID */);
|
|
601
|
+
buttonConfigurationTLV.forEach(entry => {
|
|
620
602
|
const buttonId = entry[1 /* ButtonConfigurationTypes.BUTTON_ID */][0];
|
|
621
|
-
const buttonType = readUInt16(entry[2 /* ButtonConfigurationTypes.BUTTON_TYPE */]);
|
|
603
|
+
const buttonType = tlv.readUInt16(entry[2 /* ButtonConfigurationTypes.BUTTON_TYPE */]);
|
|
622
604
|
let buttonName;
|
|
623
605
|
if (entry[3 /* ButtonConfigurationTypes.BUTTON_NAME */]) {
|
|
624
606
|
buttonName = entry[3 /* ButtonConfigurationTypes.BUTTON_NAME */].toString();
|
|
625
607
|
}
|
|
626
608
|
else {
|
|
627
|
-
// @ts-expect-error
|
|
609
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
628
610
|
buttonName = ButtonType[buttonType];
|
|
629
611
|
}
|
|
630
612
|
buttonConfiguration[buttonId] = {
|
|
631
613
|
buttonID: buttonId,
|
|
632
|
-
buttonType,
|
|
633
|
-
buttonName,
|
|
614
|
+
buttonType: buttonType,
|
|
615
|
+
buttonName: buttonName,
|
|
634
616
|
};
|
|
635
617
|
});
|
|
636
618
|
}
|
|
@@ -638,72 +620,73 @@ export class RemoteController extends EventEmitter {
|
|
|
638
620
|
targetIdentifier: identifier,
|
|
639
621
|
targetName: name,
|
|
640
622
|
targetCategory: category,
|
|
641
|
-
buttonConfiguration,
|
|
623
|
+
buttonConfiguration: buttonConfiguration,
|
|
642
624
|
};
|
|
643
625
|
}
|
|
644
626
|
updatedTargetConfiguration() {
|
|
645
627
|
const bufferList = [];
|
|
646
628
|
for (const configuration of Object.values(this.targetConfigurations)) {
|
|
647
|
-
const targetIdentifier = encode(1 /* TargetConfigurationTypes.TARGET_IDENTIFIER */, writeUInt32(configuration.targetIdentifier));
|
|
648
|
-
const targetName = encode(2 /* TargetConfigurationTypes.TARGET_NAME */, configuration.targetName);
|
|
649
|
-
const targetCategory = encode(3 /* TargetConfigurationTypes.TARGET_CATEGORY */, writeUInt16(configuration.targetCategory));
|
|
629
|
+
const targetIdentifier = tlv.encode(1 /* TargetConfigurationTypes.TARGET_IDENTIFIER */, tlv.writeUInt32(configuration.targetIdentifier));
|
|
630
|
+
const targetName = tlv.encode(2 /* TargetConfigurationTypes.TARGET_NAME */, configuration.targetName);
|
|
631
|
+
const targetCategory = tlv.encode(3 /* TargetConfigurationTypes.TARGET_CATEGORY */, tlv.writeUInt16(configuration.targetCategory));
|
|
650
632
|
const buttonConfigurationBuffers = [];
|
|
651
633
|
for (const value of configuration.buttonConfiguration.values()) {
|
|
652
|
-
let tlvBuffer = encode(1 /* ButtonConfigurationTypes.BUTTON_ID */, value.buttonID, 2 /* ButtonConfigurationTypes.BUTTON_TYPE */, writeUInt16(value.buttonType));
|
|
634
|
+
let tlvBuffer = tlv.encode(1 /* ButtonConfigurationTypes.BUTTON_ID */, value.buttonID, 2 /* ButtonConfigurationTypes.BUTTON_TYPE */, tlv.writeUInt16(value.buttonType));
|
|
653
635
|
if (value.buttonName) {
|
|
654
636
|
tlvBuffer = Buffer.concat([
|
|
655
637
|
tlvBuffer,
|
|
656
|
-
encode(3 /* ButtonConfigurationTypes.BUTTON_NAME */, value.buttonName),
|
|
638
|
+
tlv.encode(3 /* ButtonConfigurationTypes.BUTTON_NAME */, value.buttonName),
|
|
657
639
|
]);
|
|
658
640
|
}
|
|
659
641
|
buttonConfigurationBuffers.push(tlvBuffer);
|
|
660
642
|
}
|
|
661
|
-
const buttonConfiguration = encode(4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */, Buffer.concat(buttonConfigurationBuffers));
|
|
643
|
+
const buttonConfiguration = tlv.encode(4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */, Buffer.concat(buttonConfigurationBuffers));
|
|
662
644
|
const targetConfiguration = Buffer.concat([targetIdentifier, targetName, targetCategory, buttonConfiguration]);
|
|
663
|
-
bufferList.push(encode(2 /* TargetControlList.TARGET_CONFIGURATION */, targetConfiguration));
|
|
645
|
+
bufferList.push(tlv.encode(2 /* TargetControlList.TARGET_CONFIGURATION */, targetConfiguration));
|
|
664
646
|
}
|
|
665
|
-
this.targetConfigurationsString = Buffer.concat(bufferList).toString(
|
|
647
|
+
this.targetConfigurationsString = Buffer.concat(bufferList).toString("base64");
|
|
666
648
|
this.stateChangeDelegate?.();
|
|
667
649
|
}
|
|
668
650
|
buildTargetControlSupportedConfigurationTLV(configuration) {
|
|
669
|
-
const maximumTargets = encode(1 /* TargetControlCommands.MAXIMUM_TARGETS */, configuration.maximumTargets);
|
|
670
|
-
const ticksPerSecond = encode(2 /* TargetControlCommands.TICKS_PER_SECOND */, writeVariableUIntLE(configuration.ticksPerSecond));
|
|
651
|
+
const maximumTargets = tlv.encode(1 /* TargetControlCommands.MAXIMUM_TARGETS */, configuration.maximumTargets);
|
|
652
|
+
const ticksPerSecond = tlv.encode(2 /* TargetControlCommands.TICKS_PER_SECOND */, tlv.writeVariableUIntLE(configuration.ticksPerSecond));
|
|
671
653
|
const supportedButtonConfigurationBuffers = [];
|
|
672
|
-
configuration.supportedButtonConfiguration.forEach(
|
|
673
|
-
const tlvBuffer = encode(1 /* SupportedButtonConfigurationTypes.BUTTON_ID */, value.buttonID, 2 /* SupportedButtonConfigurationTypes.BUTTON_TYPE */, writeUInt16(value.buttonType));
|
|
654
|
+
configuration.supportedButtonConfiguration.forEach(value => {
|
|
655
|
+
const tlvBuffer = tlv.encode(1 /* SupportedButtonConfigurationTypes.BUTTON_ID */, value.buttonID, 2 /* SupportedButtonConfigurationTypes.BUTTON_TYPE */, tlv.writeUInt16(value.buttonType));
|
|
674
656
|
supportedButtonConfigurationBuffers.push(tlvBuffer);
|
|
675
657
|
});
|
|
676
|
-
const supportedButtonConfiguration = encode(3 /* TargetControlCommands.SUPPORTED_BUTTON_CONFIGURATION */, Buffer.concat(supportedButtonConfigurationBuffers));
|
|
677
|
-
const type = encode(4 /* TargetControlCommands.TYPE */, configuration.hardwareImplemented ? 1 : 0);
|
|
678
|
-
return Buffer.concat([maximumTargets, ticksPerSecond, supportedButtonConfiguration, type]).toString(
|
|
658
|
+
const supportedButtonConfiguration = tlv.encode(3 /* TargetControlCommands.SUPPORTED_BUTTON_CONFIGURATION */, Buffer.concat(supportedButtonConfigurationBuffers));
|
|
659
|
+
const type = tlv.encode(4 /* TargetControlCommands.TYPE */, configuration.hardwareImplemented ? 1 : 0);
|
|
660
|
+
return Buffer.concat([maximumTargets, ticksPerSecond, supportedButtonConfiguration, type]).toString("base64");
|
|
679
661
|
}
|
|
680
662
|
// --------------------------------- SIRI/DATA STREAM --------------------------------
|
|
663
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
681
664
|
handleTargetControlWhoAmI(connection, message) {
|
|
682
665
|
const targetIdentifier = message.identifier;
|
|
683
666
|
this.dataStreamConnections.set(targetIdentifier, connection);
|
|
684
|
-
debug(
|
|
667
|
+
debug("Discovered HDS connection for targetIdentifier %s", targetIdentifier);
|
|
685
668
|
connection.addProtocolHandler("dataSend" /* Protocols.DATA_SEND */, this);
|
|
686
669
|
}
|
|
687
670
|
handleSiriAudioStart() {
|
|
688
671
|
if (!this.audioSupported) {
|
|
689
|
-
throw new Error(
|
|
672
|
+
throw new Error("Cannot start siri stream on remote where siri is not supported");
|
|
690
673
|
}
|
|
691
674
|
if (!this.isActive()) {
|
|
692
|
-
debug(
|
|
675
|
+
debug("Tried opening Siri audio stream, however no controller is connected!");
|
|
693
676
|
return;
|
|
694
677
|
}
|
|
695
678
|
if (this.activeAudioSession && (!this.activeAudioSession.isClosing() || this.nextAudioSession)) {
|
|
696
679
|
// there is already a session running, which is not in closing state and/or there is even already a
|
|
697
680
|
// nextAudioSession running. ignoring start request
|
|
698
|
-
debug(
|
|
681
|
+
debug("Tried opening Siri audio stream, however there is already one in progress");
|
|
699
682
|
return;
|
|
700
683
|
}
|
|
701
684
|
const connection = this.dataStreamConnections.get(this.activeIdentifier); // get connection for current target
|
|
702
685
|
if (connection === undefined) { // target seems not connected, ignore it
|
|
703
|
-
debug(
|
|
686
|
+
debug("Tried opening Siri audio stream however target is not connected via HDS");
|
|
704
687
|
return;
|
|
705
688
|
}
|
|
706
|
-
// eslint-disable-next-line
|
|
689
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
707
690
|
const audioSession = new SiriAudioSession(connection, this.selectedAudioConfiguration, this.audioProducerConstructor, this.audioProducerOptions);
|
|
708
691
|
if (!this.activeAudioSession) {
|
|
709
692
|
this.activeAudioSession = audioSession;
|
|
@@ -713,7 +696,6 @@ export class RemoteController extends EventEmitter {
|
|
|
713
696
|
// so no collision with the input device can happen
|
|
714
697
|
this.nextAudioSession = audioSession;
|
|
715
698
|
}
|
|
716
|
-
// eslint-disable-next-line ts/no-use-before-define
|
|
717
699
|
audioSession.on("close" /* SiriAudioSessionEvents.CLOSE */, this.handleSiriAudioSessionClosed.bind(this, audioSession));
|
|
718
700
|
audioSession.start();
|
|
719
701
|
}
|
|
@@ -728,8 +710,9 @@ export class RemoteController extends EventEmitter {
|
|
|
728
710
|
return;
|
|
729
711
|
}
|
|
730
712
|
}
|
|
731
|
-
debug(
|
|
713
|
+
debug("handleSiriAudioStop called although no audio session was started");
|
|
732
714
|
}
|
|
715
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
733
716
|
handleDataSendAckEvent(message) {
|
|
734
717
|
const streamId = message.streamId;
|
|
735
718
|
const endOfStream = message.endOfStream;
|
|
@@ -740,9 +723,10 @@ export class RemoteController extends EventEmitter {
|
|
|
740
723
|
this.nextAudioSession.handleDataSendAckEvent(endOfStream);
|
|
741
724
|
}
|
|
742
725
|
else {
|
|
743
|
-
debug(
|
|
726
|
+
debug("Received dataSend acknowledgment event for unknown streamId '%s'", streamId);
|
|
744
727
|
}
|
|
745
728
|
}
|
|
729
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
746
730
|
handleDataSendCloseEvent(message) {
|
|
747
731
|
const streamId = message.streamId;
|
|
748
732
|
const reason = message.reason;
|
|
@@ -753,7 +737,7 @@ export class RemoteController extends EventEmitter {
|
|
|
753
737
|
this.nextAudioSession.handleDataSendCloseEvent(reason);
|
|
754
738
|
}
|
|
755
739
|
else {
|
|
756
|
-
debug(
|
|
740
|
+
debug("Received dataSend close event for unknown streamId '%s'", streamId);
|
|
757
741
|
}
|
|
758
742
|
}
|
|
759
743
|
handleSiriAudioSessionClosed(session) {
|
|
@@ -768,28 +752,29 @@ export class RemoteController extends EventEmitter {
|
|
|
768
752
|
handleDataStreamConnectionClosed(connection) {
|
|
769
753
|
for (const [targetIdentifier, connection0] of this.dataStreamConnections) {
|
|
770
754
|
if (connection === connection0) {
|
|
771
|
-
debug(
|
|
755
|
+
debug("HDS connection disconnected for targetIdentifier %s", targetIdentifier);
|
|
772
756
|
this.dataStreamConnections.delete(targetIdentifier);
|
|
773
757
|
break;
|
|
774
758
|
}
|
|
775
759
|
}
|
|
776
760
|
}
|
|
777
761
|
// ------------------------------- AUDIO CONFIGURATION -------------------------------
|
|
762
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
778
763
|
handleSelectedAudioConfigurationWrite(value, callback) {
|
|
779
|
-
const data = Buffer.from(value,
|
|
780
|
-
const objects = decode(data);
|
|
781
|
-
const selectedAudioStreamConfiguration = decode(objects[1 /* SelectedAudioInputStreamConfigurationTypes.SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */]);
|
|
764
|
+
const data = Buffer.from(value, "base64");
|
|
765
|
+
const objects = tlv.decode(data);
|
|
766
|
+
const selectedAudioStreamConfiguration = tlv.decode(objects[1 /* SelectedAudioInputStreamConfigurationTypes.SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */]);
|
|
782
767
|
const codec = selectedAudioStreamConfiguration[1 /* AudioCodecConfigurationTypes.CODEC_TYPE */][0];
|
|
783
|
-
const parameters = decode(selectedAudioStreamConfiguration[2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */]);
|
|
768
|
+
const parameters = tlv.decode(selectedAudioStreamConfiguration[2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */]);
|
|
784
769
|
const channels = parameters[1 /* AudioCodecParametersTypes.CHANNEL */][0];
|
|
785
770
|
const bitrate = parameters[2 /* AudioCodecParametersTypes.BIT_RATE */][0];
|
|
786
771
|
const samplerate = parameters[3 /* AudioCodecParametersTypes.SAMPLE_RATE */][0];
|
|
787
772
|
this.selectedAudioConfiguration = {
|
|
788
773
|
codecType: codec,
|
|
789
774
|
parameters: {
|
|
790
|
-
channels,
|
|
791
|
-
bitrate,
|
|
792
|
-
samplerate,
|
|
775
|
+
channels: channels,
|
|
776
|
+
bitrate: bitrate,
|
|
777
|
+
samplerate: samplerate,
|
|
793
778
|
rtpTime: 20,
|
|
794
779
|
},
|
|
795
780
|
};
|
|
@@ -800,47 +785,47 @@ export class RemoteController extends EventEmitter {
|
|
|
800
785
|
}
|
|
801
786
|
static buildSupportedAudioConfigurationTLV(configuration) {
|
|
802
787
|
const codecConfigurationTLV = RemoteController.buildCodecConfigurationTLV(configuration.audioCodecConfiguration);
|
|
803
|
-
const supportedAudioStreamConfiguration = encode(1 /* SupportedAudioStreamConfigurationTypes.AUDIO_CODEC_CONFIGURATION */, codecConfigurationTLV);
|
|
804
|
-
return supportedAudioStreamConfiguration.toString(
|
|
788
|
+
const supportedAudioStreamConfiguration = tlv.encode(1 /* SupportedAudioStreamConfigurationTypes.AUDIO_CODEC_CONFIGURATION */, codecConfigurationTLV);
|
|
789
|
+
return supportedAudioStreamConfiguration.toString("base64");
|
|
805
790
|
}
|
|
806
791
|
static buildSelectedAudioConfigurationTLV(configuration) {
|
|
807
792
|
const codecConfigurationTLV = RemoteController.buildCodecConfigurationTLV(configuration.audioCodecConfiguration);
|
|
808
|
-
const supportedAudioStreamConfiguration = encode(1 /* SelectedAudioInputStreamConfigurationTypes.SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */, codecConfigurationTLV);
|
|
809
|
-
return supportedAudioStreamConfiguration.toString(
|
|
793
|
+
const supportedAudioStreamConfiguration = tlv.encode(1 /* SelectedAudioInputStreamConfigurationTypes.SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */, codecConfigurationTLV);
|
|
794
|
+
return supportedAudioStreamConfiguration.toString("base64");
|
|
810
795
|
}
|
|
811
796
|
static buildCodecConfigurationTLV(codecConfiguration) {
|
|
812
797
|
const parameters = codecConfiguration.parameters;
|
|
813
|
-
let parametersTLV = encode(1 /* AudioCodecParametersTypes.CHANNEL */, parameters.channels, 2 /* AudioCodecParametersTypes.BIT_RATE */, parameters.bitrate, 3 /* AudioCodecParametersTypes.SAMPLE_RATE */, parameters.samplerate);
|
|
798
|
+
let parametersTLV = tlv.encode(1 /* AudioCodecParametersTypes.CHANNEL */, parameters.channels, 2 /* AudioCodecParametersTypes.BIT_RATE */, parameters.bitrate, 3 /* AudioCodecParametersTypes.SAMPLE_RATE */, parameters.samplerate);
|
|
814
799
|
if (parameters.rtpTime) {
|
|
815
800
|
parametersTLV = Buffer.concat([
|
|
816
801
|
parametersTLV,
|
|
817
|
-
encode(4 /* AudioCodecParametersTypes.PACKET_TIME */, parameters.rtpTime),
|
|
802
|
+
tlv.encode(4 /* AudioCodecParametersTypes.PACKET_TIME */, parameters.rtpTime),
|
|
818
803
|
]);
|
|
819
804
|
}
|
|
820
|
-
return encode(1 /* AudioCodecConfigurationTypes.CODEC_TYPE */, codecConfiguration.codecType, 2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */, parametersTLV);
|
|
805
|
+
return tlv.encode(1 /* AudioCodecConfigurationTypes.CODEC_TYPE */, codecConfiguration.codecType, 2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */, parametersTLV);
|
|
821
806
|
}
|
|
822
807
|
// -----------------------------------------------------------------------------------
|
|
823
808
|
/**
|
|
824
809
|
* @private
|
|
825
810
|
*/
|
|
826
811
|
constructServices() {
|
|
827
|
-
this.targetControlManagementService = new Service.TargetControlManagement(
|
|
828
|
-
this.targetControlManagementService.setCharacteristic(Characteristic.TargetControlSupportedConfiguration, this.supportedConfiguration);
|
|
829
|
-
this.targetControlManagementService.setCharacteristic(Characteristic.TargetControlList, this.targetConfigurationsString);
|
|
812
|
+
this.targetControlManagementService = new Service_1.Service.TargetControlManagement("", "");
|
|
813
|
+
this.targetControlManagementService.setCharacteristic(Characteristic_1.Characteristic.TargetControlSupportedConfiguration, this.supportedConfiguration);
|
|
814
|
+
this.targetControlManagementService.setCharacteristic(Characteristic_1.Characteristic.TargetControlList, this.targetConfigurationsString);
|
|
830
815
|
this.targetControlManagementService.setPrimaryService();
|
|
831
816
|
// you can also expose multiple TargetControl services to control multiple apple tvs simultaneously.
|
|
832
817
|
// should we extend this class to support multiple TargetControl services or should users just create a second accessory?
|
|
833
|
-
this.targetControlService = new Service.TargetControl(
|
|
834
|
-
this.targetControlService.setCharacteristic(Characteristic.ActiveIdentifier, 0);
|
|
835
|
-
this.targetControlService.setCharacteristic(Characteristic.Active, false);
|
|
836
|
-
this.targetControlService.setCharacteristic(Characteristic.ButtonEvent, this.lastButtonEvent);
|
|
818
|
+
this.targetControlService = new Service_1.Service.TargetControl("", "");
|
|
819
|
+
this.targetControlService.setCharacteristic(Characteristic_1.Characteristic.ActiveIdentifier, 0);
|
|
820
|
+
this.targetControlService.setCharacteristic(Characteristic_1.Characteristic.Active, false);
|
|
821
|
+
this.targetControlService.setCharacteristic(Characteristic_1.Characteristic.ButtonEvent, this.lastButtonEvent);
|
|
837
822
|
if (this.audioSupported) {
|
|
838
|
-
this.siriService = new Service.Siri(
|
|
839
|
-
this.siriService.setCharacteristic(Characteristic.SiriInputType, Characteristic.SiriInputType.PUSH_BUTTON_TRIGGERED_APPLE_TV);
|
|
840
|
-
this.audioStreamManagementService = new Service.AudioStreamManagement(
|
|
841
|
-
this.audioStreamManagementService.setCharacteristic(Characteristic.SupportedAudioStreamConfiguration, this.supportedAudioConfiguration);
|
|
842
|
-
this.audioStreamManagementService.setCharacteristic(Characteristic.SelectedAudioStreamConfiguration, this.selectedAudioConfigurationString);
|
|
843
|
-
this.dataStreamManagement = new DataStreamManagement();
|
|
823
|
+
this.siriService = new Service_1.Service.Siri("", "");
|
|
824
|
+
this.siriService.setCharacteristic(Characteristic_1.Characteristic.SiriInputType, Characteristic_1.Characteristic.SiriInputType.PUSH_BUTTON_TRIGGERED_APPLE_TV);
|
|
825
|
+
this.audioStreamManagementService = new Service_1.Service.AudioStreamManagement("", "");
|
|
826
|
+
this.audioStreamManagementService.setCharacteristic(Characteristic_1.Characteristic.SupportedAudioStreamConfiguration, this.supportedAudioConfiguration);
|
|
827
|
+
this.audioStreamManagementService.setCharacteristic(Characteristic_1.Characteristic.SelectedAudioStreamConfiguration, this.selectedAudioConfigurationString);
|
|
828
|
+
this.dataStreamManagement = new datastream_1.DataStreamManagement();
|
|
844
829
|
this.siriService.addLinkedService(this.dataStreamManagement.getService());
|
|
845
830
|
this.siriService.addLinkedService(this.audioStreamManagementService);
|
|
846
831
|
}
|
|
@@ -860,43 +845,43 @@ export class RemoteController extends EventEmitter {
|
|
|
860
845
|
this.targetControlService = serviceMap.targetControl;
|
|
861
846
|
this.siriService = serviceMap.siri;
|
|
862
847
|
this.audioStreamManagementService = serviceMap.audioStreamManagement;
|
|
863
|
-
this.dataStreamManagement = new DataStreamManagement(serviceMap.dataStreamTransportManagement);
|
|
848
|
+
this.dataStreamManagement = new datastream_1.DataStreamManagement(serviceMap.dataStreamTransportManagement);
|
|
864
849
|
}
|
|
865
850
|
/**
|
|
866
851
|
* @private
|
|
867
852
|
*/
|
|
868
853
|
configureServices() {
|
|
869
854
|
if (!this.targetControlManagementService || !this.targetControlService) {
|
|
870
|
-
throw new Error(
|
|
855
|
+
throw new Error("Unexpected state: Services not configured!"); // playing it save
|
|
871
856
|
}
|
|
872
|
-
this.targetControlManagementService.getCharacteristic(Characteristic.TargetControlList)
|
|
873
|
-
.on("get" /* CharacteristicEventTypes.GET */,
|
|
857
|
+
this.targetControlManagementService.getCharacteristic(Characteristic_1.Characteristic.TargetControlList)
|
|
858
|
+
.on("get" /* CharacteristicEventTypes.GET */, callback => {
|
|
874
859
|
callback(null, this.targetConfigurationsString);
|
|
875
860
|
})
|
|
876
861
|
.on("set" /* CharacteristicEventTypes.SET */, this.handleTargetControlWrite.bind(this));
|
|
877
|
-
this.targetControlService.getCharacteristic(Characteristic.ActiveIdentifier)
|
|
878
|
-
.on("get" /* CharacteristicEventTypes.GET */,
|
|
862
|
+
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ActiveIdentifier)
|
|
863
|
+
.on("get" /* CharacteristicEventTypes.GET */, callback => {
|
|
879
864
|
callback(undefined, this.activeIdentifier);
|
|
880
865
|
});
|
|
881
|
-
this.targetControlService.getCharacteristic(Characteristic.Active)
|
|
882
|
-
.on("get" /* CharacteristicEventTypes.GET */,
|
|
866
|
+
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.Active)
|
|
867
|
+
.on("get" /* CharacteristicEventTypes.GET */, callback => {
|
|
883
868
|
callback(undefined, this.isActive());
|
|
884
869
|
})
|
|
885
870
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback, context, connection) => {
|
|
886
871
|
if (!connection) {
|
|
887
|
-
debug(
|
|
872
|
+
debug("Set event handler for Remote.Active cannot be called from plugin. Connection undefined!");
|
|
888
873
|
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
889
874
|
return;
|
|
890
875
|
}
|
|
891
876
|
this.handleActiveWrite(value, callback, connection);
|
|
892
877
|
});
|
|
893
|
-
this.targetControlService.getCharacteristic(Characteristic.ButtonEvent)
|
|
878
|
+
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ButtonEvent)
|
|
894
879
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
895
880
|
callback(undefined, this.lastButtonEvent);
|
|
896
881
|
});
|
|
897
882
|
if (this.audioSupported) {
|
|
898
|
-
this.audioStreamManagementService.getCharacteristic(Characteristic.SelectedAudioStreamConfiguration)
|
|
899
|
-
.on("get" /* CharacteristicEventTypes.GET */,
|
|
883
|
+
this.audioStreamManagementService.getCharacteristic(Characteristic_1.Characteristic.SelectedAudioStreamConfiguration)
|
|
884
|
+
.on("get" /* CharacteristicEventTypes.GET */, callback => {
|
|
900
885
|
callback(null, this.selectedAudioConfigurationString);
|
|
901
886
|
})
|
|
902
887
|
.on("set" /* CharacteristicEventTypes.SET */, this.handleSelectedAudioConfigurationWrite.bind(this))
|
|
@@ -931,9 +916,9 @@ export class RemoteController extends EventEmitter {
|
|
|
931
916
|
* @private
|
|
932
917
|
*/
|
|
933
918
|
handleFactoryReset() {
|
|
934
|
-
debug(
|
|
919
|
+
debug("Running factory reset. Resetting targets...");
|
|
935
920
|
this.handleResetTargets(undefined);
|
|
936
|
-
this.lastButtonEvent =
|
|
921
|
+
this.lastButtonEvent = "";
|
|
937
922
|
}
|
|
938
923
|
/**
|
|
939
924
|
* @private
|
|
@@ -956,7 +941,7 @@ export class RemoteController extends EventEmitter {
|
|
|
956
941
|
deserialize(serialized) {
|
|
957
942
|
this.activeIdentifier = serialized.activeIdentifier;
|
|
958
943
|
this.targetConfigurations = Object.entries(serialized.targetConfigurations).reduce((map, [key, value]) => {
|
|
959
|
-
const identifier =
|
|
944
|
+
const identifier = parseInt(key, 10);
|
|
960
945
|
map.set(identifier, value);
|
|
961
946
|
return map;
|
|
962
947
|
}, new Map());
|
|
@@ -969,27 +954,27 @@ export class RemoteController extends EventEmitter {
|
|
|
969
954
|
this.stateChangeDelegate = delegate;
|
|
970
955
|
}
|
|
971
956
|
}
|
|
957
|
+
exports.RemoteController = RemoteController;
|
|
972
958
|
/**
|
|
973
959
|
* @group Apple TV Remote
|
|
974
960
|
*/
|
|
975
|
-
|
|
976
|
-
export var SiriAudioSessionEvents;
|
|
961
|
+
var SiriAudioSessionEvents;
|
|
977
962
|
(function (SiriAudioSessionEvents) {
|
|
978
963
|
SiriAudioSessionEvents["CLOSE"] = "close";
|
|
979
|
-
})(SiriAudioSessionEvents || (SiriAudioSessionEvents = {}));
|
|
964
|
+
})(SiriAudioSessionEvents || (exports.SiriAudioSessionEvents = SiriAudioSessionEvents = {}));
|
|
980
965
|
/**
|
|
981
966
|
* Represents an ongoing audio transmission
|
|
982
967
|
* @group Apple TV Remote
|
|
983
968
|
*/
|
|
984
|
-
// eslint-disable-next-line
|
|
985
|
-
|
|
969
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
970
|
+
class SiriAudioSession extends events_1.EventEmitter {
|
|
986
971
|
connection;
|
|
987
972
|
selectedAudioConfiguration;
|
|
988
973
|
producer;
|
|
989
974
|
producerRunning = false; // indicates if the producer is running
|
|
990
975
|
producerTimer; // producer has a 3s timeout to produce the first frame, otherwise transmission will be cancelled
|
|
991
976
|
/**
|
|
992
|
-
* @private
|
|
977
|
+
* @private file private API
|
|
993
978
|
*/
|
|
994
979
|
state = 0 /* SiriAudioSessionState.STARTING */;
|
|
995
980
|
streamId; // present when state >= SENDING
|
|
@@ -998,11 +983,12 @@ export class SiriAudioSession extends EventEmitter {
|
|
|
998
983
|
maxQueueSize = 1024;
|
|
999
984
|
sequenceNumber = 0;
|
|
1000
985
|
closeListener;
|
|
1001
|
-
constructor(connection, selectedAudioConfiguration, producerConstructor,
|
|
986
|
+
constructor(connection, selectedAudioConfiguration, producerConstructor,
|
|
987
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any
|
|
988
|
+
producerOptions) {
|
|
1002
989
|
super();
|
|
1003
990
|
this.connection = connection;
|
|
1004
991
|
this.selectedAudioConfiguration = selectedAudioConfiguration;
|
|
1005
|
-
// eslint-disable-next-line new-cap
|
|
1006
992
|
this.producer = new producerConstructor(this.handleSiriAudioFrame.bind(this), this.handleProducerError.bind(this), producerOptions);
|
|
1007
993
|
this.connection.on("closed" /* DataStreamConnectionEvent.CLOSED */, this.closeListener = this.handleDataStreamConnectionClosed.bind(this));
|
|
1008
994
|
}
|
|
@@ -1010,24 +996,24 @@ export class SiriAudioSession extends EventEmitter {
|
|
|
1010
996
|
* Called when siri button is pressed
|
|
1011
997
|
*/
|
|
1012
998
|
start() {
|
|
1013
|
-
debug(
|
|
999
|
+
debug("Sending request to start siri audio stream");
|
|
1014
1000
|
// opening dataSend
|
|
1015
1001
|
this.connection.sendRequest("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, {
|
|
1016
|
-
target:
|
|
1017
|
-
type:
|
|
1002
|
+
target: "controller",
|
|
1003
|
+
type: "audio.siri",
|
|
1018
1004
|
}, (error, status, message) => {
|
|
1019
1005
|
if (this.state === 3 /* SiriAudioSessionState.CLOSED */) {
|
|
1020
|
-
debug(
|
|
1006
|
+
debug("Ignoring dataSend open response as the session is already closed");
|
|
1021
1007
|
return;
|
|
1022
1008
|
}
|
|
1023
|
-
|
|
1009
|
+
assert_1.default.strictEqual(this.state, 0 /* SiriAudioSessionState.STARTING */);
|
|
1024
1010
|
this.state = 1 /* SiriAudioSessionState.SENDING */;
|
|
1025
1011
|
if (error || status) {
|
|
1026
1012
|
if (error) { // errors get produced by hap-nodejs
|
|
1027
|
-
debug(
|
|
1013
|
+
debug("Error occurred trying to start siri audio stream: %s", error.message);
|
|
1028
1014
|
}
|
|
1029
1015
|
else if (status) { // status codes are those returned by the hds response
|
|
1030
|
-
debug(
|
|
1016
|
+
debug("Controller responded with non-zero status code: %s", datastream_1.HDSStatus[status]);
|
|
1031
1017
|
}
|
|
1032
1018
|
this.closed();
|
|
1033
1019
|
}
|
|
@@ -1037,7 +1023,7 @@ export class SiriAudioSession extends EventEmitter {
|
|
|
1037
1023
|
this.sendDataSendCloseEvent(3 /* HDSProtocolSpecificErrorReason.CANCELLED */);
|
|
1038
1024
|
}
|
|
1039
1025
|
else {
|
|
1040
|
-
debug(
|
|
1026
|
+
debug("Successfully setup siri audio stream with streamId %d", this.streamId);
|
|
1041
1027
|
}
|
|
1042
1028
|
}
|
|
1043
1029
|
});
|
|
@@ -1053,8 +1039,8 @@ export class SiriAudioSession extends EventEmitter {
|
|
|
1053
1039
|
* Called when siri button is released (or active identifier is changed to another device)
|
|
1054
1040
|
*/
|
|
1055
1041
|
stop() {
|
|
1056
|
-
|
|
1057
|
-
debug(
|
|
1042
|
+
(0, assert_1.default)(this.state <= 1 /* SiriAudioSessionState.SENDING */, "state was higher than SENDING");
|
|
1043
|
+
debug("Stopping siri audio stream with streamId %d", this.streamId);
|
|
1058
1044
|
this.endOfStream = true; // mark as endOfStream
|
|
1059
1045
|
this.stopAudioProducer();
|
|
1060
1046
|
if (this.state === 1 /* SiriAudioSessionState.SENDING */) {
|
|
@@ -1069,7 +1055,7 @@ export class SiriAudioSession extends EventEmitter {
|
|
|
1069
1055
|
this.producer.startAudioProduction(this.selectedAudioConfiguration);
|
|
1070
1056
|
this.producerRunning = true;
|
|
1071
1057
|
this.producerTimer = setTimeout(() => {
|
|
1072
|
-
debug(
|
|
1058
|
+
debug("Didn't receive any frames from audio producer for stream with streamId %s. Canceling the stream now.", this.streamId);
|
|
1073
1059
|
this.producerTimer = undefined;
|
|
1074
1060
|
this.handleProducerError(3 /* HDSProtocolSpecificErrorReason.CANCELLED */);
|
|
1075
1061
|
}, 3000);
|
|
@@ -1097,33 +1083,35 @@ export class SiriAudioSession extends EventEmitter {
|
|
|
1097
1083
|
if (this.state !== 1 /* SiriAudioSessionState.SENDING */) { // dataSend isn't open yet
|
|
1098
1084
|
return;
|
|
1099
1085
|
}
|
|
1100
|
-
let queued
|
|
1101
|
-
while (queued !== null) { // send packets
|
|
1086
|
+
let queued;
|
|
1087
|
+
while ((queued = this.popSome()) !== null) { // send packets
|
|
1102
1088
|
const packets = [];
|
|
1103
|
-
queued.forEach(
|
|
1089
|
+
queued.forEach(frame => {
|
|
1104
1090
|
const packetData = {
|
|
1105
1091
|
data: frame.data,
|
|
1106
1092
|
metadata: {
|
|
1107
|
-
rms: new Float32(frame.rms),
|
|
1108
|
-
sequenceNumber: new Int64(this.sequenceNumber++),
|
|
1093
|
+
rms: new datastream_1.Float32(frame.rms),
|
|
1094
|
+
sequenceNumber: new datastream_1.Int64(this.sequenceNumber++),
|
|
1109
1095
|
},
|
|
1110
1096
|
};
|
|
1111
1097
|
packets.push(packetData);
|
|
1112
1098
|
});
|
|
1113
1099
|
const message = {
|
|
1114
|
-
packets,
|
|
1115
|
-
streamId: new Int64(this.streamId),
|
|
1100
|
+
packets: packets,
|
|
1101
|
+
streamId: new datastream_1.Int64(this.streamId),
|
|
1116
1102
|
endOfStream: this.endOfStream,
|
|
1117
1103
|
};
|
|
1118
1104
|
try {
|
|
1119
1105
|
this.connection.sendEvent("dataSend" /* Protocols.DATA_SEND */, "data" /* Topics.DATA */, message);
|
|
1120
1106
|
}
|
|
1121
1107
|
catch (error) {
|
|
1122
|
-
debug(
|
|
1108
|
+
debug("Error occurred when trying to send audio frame of hds connection: %s", error.message);
|
|
1123
1109
|
this.stopAudioProducer();
|
|
1124
1110
|
this.closed();
|
|
1125
1111
|
}
|
|
1126
|
-
|
|
1112
|
+
if (this.endOfStream) {
|
|
1113
|
+
break; // popSome() returns empty list if endOfStream=true
|
|
1114
|
+
}
|
|
1127
1115
|
}
|
|
1128
1116
|
}
|
|
1129
1117
|
handleProducerError(error) {
|
|
@@ -1136,29 +1124,29 @@ export class SiriAudioSession extends EventEmitter {
|
|
|
1136
1124
|
}
|
|
1137
1125
|
}
|
|
1138
1126
|
handleDataSendAckEvent(endOfStream) {
|
|
1139
|
-
|
|
1140
|
-
debug(
|
|
1127
|
+
assert_1.default.strictEqual(endOfStream, true);
|
|
1128
|
+
debug("Received acknowledgment for siri audio stream with streamId %s, closing it now", this.streamId);
|
|
1141
1129
|
this.sendDataSendCloseEvent(0 /* HDSProtocolSpecificErrorReason.NORMAL */);
|
|
1142
1130
|
}
|
|
1143
1131
|
handleDataSendCloseEvent(reason) {
|
|
1144
|
-
// @ts-expect-error
|
|
1145
|
-
debug(
|
|
1132
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1133
|
+
debug("Received close event from controller with reason %s for stream with streamId %s", datastream_1.HDSProtocolSpecificErrorReason[reason], this.streamId);
|
|
1146
1134
|
if (this.state <= 1 /* SiriAudioSessionState.SENDING */) {
|
|
1147
1135
|
this.stopAudioProducer();
|
|
1148
1136
|
}
|
|
1149
1137
|
this.closed();
|
|
1150
1138
|
}
|
|
1151
1139
|
sendDataSendCloseEvent(reason) {
|
|
1152
|
-
|
|
1153
|
-
|
|
1140
|
+
(0, assert_1.default)(this.state >= 1 /* SiriAudioSessionState.SENDING */, "state was less than SENDING");
|
|
1141
|
+
(0, assert_1.default)(this.state <= 2 /* SiriAudioSessionState.CLOSING */, "state was higher than CLOSING");
|
|
1154
1142
|
this.connection.sendEvent("dataSend" /* Protocols.DATA_SEND */, "close" /* Topics.CLOSE */, {
|
|
1155
|
-
streamId: new Int64(this.streamId),
|
|
1156
|
-
reason: new Int64(reason),
|
|
1143
|
+
streamId: new datastream_1.Int64(this.streamId),
|
|
1144
|
+
reason: new datastream_1.Int64(reason),
|
|
1157
1145
|
});
|
|
1158
1146
|
this.closed();
|
|
1159
1147
|
}
|
|
1160
1148
|
handleDataStreamConnectionClosed() {
|
|
1161
|
-
debug(
|
|
1149
|
+
debug("Closing audio session with streamId %d", this.streamId);
|
|
1162
1150
|
if (this.state <= 1 /* SiriAudioSessionState.SENDING */) {
|
|
1163
1151
|
this.stopAudioProducer();
|
|
1164
1152
|
}
|
|
@@ -1186,4 +1174,5 @@ export class SiriAudioSession extends EventEmitter {
|
|
|
1186
1174
|
return result;
|
|
1187
1175
|
}
|
|
1188
1176
|
}
|
|
1177
|
+
exports.SiriAudioSession = SiriAudioSession;
|
|
1189
1178
|
//# sourceMappingURL=RemoteController.js.map
|