hap-nodejs 1.0.0-beta.2 → 1.0.0-beta.3
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 +4 -3
- package/@types/simple-plist.d.ts +2 -1
- package/README.md +2 -1
- package/dist/BridgedCore.js +7 -5
- package/dist/BridgedCore.js.map +1 -1
- package/dist/Core.js +14 -8
- package/dist/Core.js.map +1 -1
- package/dist/accessories/AirConditioner_accessory.d.ts +2 -0
- package/dist/accessories/AirConditioner_accessory.d.ts.map +1 -0
- package/dist/accessories/AirConditioner_accessory.js +128 -0
- package/dist/accessories/AirConditioner_accessory.js.map +1 -0
- package/dist/accessories/AppleTVRemote_accessory.d.ts +2 -0
- package/dist/accessories/AppleTVRemote_accessory.d.ts.map +1 -0
- package/dist/accessories/AppleTVRemote_accessory.js +159 -0
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -0
- package/dist/accessories/Camera_accessory.d.ts +2 -0
- package/dist/accessories/Camera_accessory.d.ts.map +1 -0
- package/dist/accessories/Camera_accessory.js +630 -0
- package/dist/accessories/Camera_accessory.js.map +1 -0
- package/dist/accessories/Fan_accessory.d.ts +2 -0
- package/dist/accessories/Fan_accessory.d.ts.map +1 -0
- package/dist/accessories/Fan_accessory.js +80 -0
- package/dist/accessories/Fan_accessory.js.map +1 -0
- package/dist/accessories/GarageDoorOpener_accessory.d.ts +2 -0
- package/dist/accessories/GarageDoorOpener_accessory.d.ts.map +1 -0
- package/dist/accessories/GarageDoorOpener_accessory.js +78 -0
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -0
- package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +2 -0
- package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +1 -0
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +96 -0
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -0
- package/dist/accessories/Light_accessory.d.ts +2 -0
- package/dist/accessories/Light_accessory.d.ts.map +1 -0
- package/dist/accessories/Light_accessory.js +148 -0
- package/dist/accessories/Light_accessory.js.map +1 -0
- package/dist/accessories/Lock_accessory.d.ts +2 -0
- package/dist/accessories/Lock_accessory.d.ts.map +1 -0
- package/dist/accessories/Lock_accessory.js +76 -0
- package/dist/accessories/Lock_accessory.js.map +1 -0
- package/dist/accessories/MotionSensor_accessory.d.ts +2 -0
- package/dist/accessories/MotionSensor_accessory.d.ts.map +1 -0
- package/dist/accessories/MotionSensor_accessory.js +45 -0
- package/dist/accessories/MotionSensor_accessory.js.map +1 -0
- package/dist/accessories/Outlet_accessory.d.ts +2 -0
- package/dist/accessories/Outlet_accessory.d.ts.map +1 -0
- package/dist/accessories/Outlet_accessory.js +79 -0
- package/dist/accessories/Outlet_accessory.js.map +1 -0
- package/dist/accessories/SmartSpeaker_accessory.d.ts +2 -0
- package/dist/accessories/SmartSpeaker_accessory.d.ts.map +1 -0
- package/dist/accessories/SmartSpeaker_accessory.js +44 -0
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -0
- package/dist/accessories/Sprinkler_accessory.d.ts +2 -0
- package/dist/accessories/Sprinkler_accessory.d.ts.map +1 -0
- package/dist/accessories/Sprinkler_accessory.js +128 -0
- package/dist/accessories/Sprinkler_accessory.js.map +1 -0
- package/dist/accessories/TV_accessory.d.ts +2 -0
- package/dist/accessories/TV_accessory.d.ts.map +1 -0
- package/dist/accessories/TV_accessory.js +101 -0
- package/dist/accessories/TV_accessory.js.map +1 -0
- package/dist/accessories/TemperatureSensor_accessory.d.ts +2 -0
- package/dist/accessories/TemperatureSensor_accessory.d.ts.map +1 -0
- package/dist/accessories/TemperatureSensor_accessory.js +44 -0
- package/dist/accessories/TemperatureSensor_accessory.js.map +1 -0
- package/dist/accessories/Wi-FiRouter_accessory.d.ts +3 -0
- package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +1 -0
- package/dist/accessories/Wi-FiRouter_accessory.js +17 -0
- package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -0
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts +3 -0
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +1 -0
- package/dist/accessories/Wi-FiSatellite_accessory.js +19 -0
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -0
- package/dist/accessories/gstreamer-audioProducer.d.ts +25 -0
- package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -0
- package/dist/accessories/gstreamer-audioProducer.js +155 -0
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -0
- package/dist/accessories/types.d.ts +78 -0
- package/dist/accessories/types.d.ts.map +1 -0
- package/dist/accessories/types.js +88 -0
- package/dist/accessories/types.js.map +1 -0
- package/dist/index.d.ts +54 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -11
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +65 -124
- package/dist/internal-types.d.ts.map +1 -1
- package/dist/internal-types.js +66 -5
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +147 -60
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +566 -475
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/AccessoryLoader.d.ts +20 -8
- package/dist/lib/AccessoryLoader.d.ts.map +1 -1
- package/dist/lib/AccessoryLoader.js +115 -93
- package/dist/lib/AccessoryLoader.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +99 -5
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +564 -22
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.d.ts +3 -1
- package/dist/lib/Bridge.d.ts.map +1 -1
- package/dist/lib/Bridge.js +2 -0
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +918 -59
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +308 -257
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +114 -43
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +269 -405
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +339 -15
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +59 -50
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/Camera.d.ts +15 -6
- package/dist/lib/camera/Camera.d.ts.map +1 -1
- package/dist/lib/camera/Camera.js +6 -3
- package/dist/lib/camera/Camera.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +24 -19
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +230 -207
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +202 -43
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +303 -189
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +326 -0
- package/dist/lib/camera/RecordingManagement.d.ts.map +1 -0
- package/dist/lib/camera/RecordingManagement.js +833 -0
- package/dist/lib/camera/RecordingManagement.js.map +1 -0
- package/dist/lib/camera/index.d.ts +4 -3
- package/dist/lib/camera/index.d.ts.map +1 -1
- package/dist/lib/camera/index.js +1 -0
- package/dist/lib/camera/index.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +37 -11
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +101 -86
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +290 -12
- package/dist/lib/controller/CameraController.d.ts.map +1 -1
- package/dist/lib/controller/CameraController.js +403 -47
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/Controller.d.ts +31 -10
- package/dist/lib/controller/Controller.d.ts.map +1 -1
- package/dist/lib/controller/Controller.js +7 -0
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +47 -1
- package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
- package/dist/lib/controller/DoorbellController.js +65 -11
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +111 -42
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +228 -203
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.d.ts +4 -4
- package/dist/lib/datastream/DataStreamManagement.d.ts +25 -19
- package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +42 -35
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +63 -24
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +132 -86
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +154 -50
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +242 -147
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.d.ts +3 -3
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +181 -0
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +968 -499
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +58 -0
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +173 -6
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.d.ts +1 -0
- package/dist/lib/definitions/generate-definitions.d.ts.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +29 -21
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +62 -29
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/model/AccessoryInfo.d.ts +16 -13
- package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +88 -83
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.d.ts +3 -0
- package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
- package/dist/lib/model/ControllerStorage.js +7 -4
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.d.ts +3 -0
- package/dist/lib/model/HAPStorage.d.ts.map +1 -1
- package/dist/lib/model/HAPStorage.js +4 -0
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.d.ts +12 -11
- package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
- package/dist/lib/model/IdentifierCache.js +68 -65
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +12 -1
- package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +13 -5
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/clone.d.ts +2 -1
- package/dist/lib/util/clone.d.ts.map +1 -1
- package/dist/lib/util/clone.js +2 -0
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.d.ts +4 -1
- package/dist/lib/util/color-utils.d.ts.map +1 -1
- package/dist/lib/util/color-utils.js +5 -2
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts +62 -22
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +236 -180
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +35 -7
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +86 -78
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.d.ts +2 -0
- package/dist/lib/util/hapStatusError.d.ts.map +1 -1
- package/dist/lib/util/hapStatusError.js +5 -3
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.d.ts +7 -0
- package/dist/lib/util/net-utils.d.ts.map +1 -1
- package/dist/lib/util/net-utils.js +11 -4
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.d.ts +6 -1
- package/dist/lib/util/once.d.ts.map +1 -1
- package/dist/lib/util/once.js +9 -3
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.d.ts +15 -0
- package/dist/lib/util/promise-utils.d.ts.map +1 -0
- package/dist/lib/util/promise-utils.js +36 -0
- package/dist/lib/util/promise-utils.js.map +1 -0
- package/dist/lib/util/request-util.d.ts +16 -0
- package/dist/lib/util/request-util.d.ts.map +1 -1
- package/dist/lib/util/request-util.js +43 -27
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +7 -1
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +13 -7
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +95 -5
- package/dist/lib/util/tlv.d.ts.map +1 -1
- package/dist/lib/util/tlv.js +96 -24
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +2 -3
- package/dist/lib/util/uuid.d.ts.map +1 -1
- package/dist/lib/util/uuid.js +25 -19
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +271 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -1
- package/package.json +28 -27
- package/dist/lib/util/setupcode.d.ts +0 -5
- package/dist/lib/util/setupcode.d.ts.map +0 -1
- package/dist/lib/util/setupcode.js +0 -49
- package/dist/lib/util/setupcode.js.map +0 -1
- package/dist/lib/util/setupid.d.ts +0 -5
- package/dist/lib/util/setupid.d.ts.map +0 -1
- package/dist/lib/util/setupid.js +0 -52
- package/dist/lib/util/setupid.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SiriAudioSession = exports.SiriAudioSessionEvents = exports.HomeKitRemoteController = exports.RemoteController = exports.RemoteControllerEvents = exports.TargetUpdates = exports.
|
|
3
|
+
exports.SiriAudioSession = exports.SiriAudioSessionEvents = exports.HomeKitRemoteController = exports.RemoteController = exports.RemoteControllerEvents = exports.TargetUpdates = exports.AudioCodecTypes = exports.ButtonState = exports.TargetCategory = exports.ButtonType = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
6
|
var debug_1 = tslib_1.__importDefault(require("debug"));
|
|
@@ -9,7 +9,7 @@ var Characteristic_1 = require("../Characteristic");
|
|
|
9
9
|
var datastream_1 = require("../datastream");
|
|
10
10
|
var Service_1 = require("../Service");
|
|
11
11
|
var tlv = tslib_1.__importStar(require("../util/tlv"));
|
|
12
|
-
var debug = debug_1.default(
|
|
12
|
+
var debug = (0, debug_1.default)("HAP-NodeJS:Remote:Controller");
|
|
13
13
|
var TargetControlCommands;
|
|
14
14
|
(function (TargetControlCommands) {
|
|
15
15
|
TargetControlCommands[TargetControlCommands["MAXIMUM_TARGETS"] = 1] = "MAXIMUM_TARGETS";
|
|
@@ -22,6 +22,9 @@ var SupportedButtonConfigurationTypes;
|
|
|
22
22
|
SupportedButtonConfigurationTypes[SupportedButtonConfigurationTypes["BUTTON_ID"] = 1] = "BUTTON_ID";
|
|
23
23
|
SupportedButtonConfigurationTypes[SupportedButtonConfigurationTypes["BUTTON_TYPE"] = 2] = "BUTTON_TYPE";
|
|
24
24
|
})(SupportedButtonConfigurationTypes || (SupportedButtonConfigurationTypes = {}));
|
|
25
|
+
/**
|
|
26
|
+
* @group Apple TV Remote
|
|
27
|
+
*/
|
|
25
28
|
var ButtonType;
|
|
26
29
|
(function (ButtonType) {
|
|
27
30
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -62,6 +65,9 @@ var TargetConfigurationTypes;
|
|
|
62
65
|
TargetConfigurationTypes[TargetConfigurationTypes["TARGET_CATEGORY"] = 3] = "TARGET_CATEGORY";
|
|
63
66
|
TargetConfigurationTypes[TargetConfigurationTypes["BUTTON_CONFIGURATION"] = 4] = "BUTTON_CONFIGURATION";
|
|
64
67
|
})(TargetConfigurationTypes || (TargetConfigurationTypes = {}));
|
|
68
|
+
/**
|
|
69
|
+
* @group Apple TV Remote
|
|
70
|
+
*/
|
|
65
71
|
var TargetCategory;
|
|
66
72
|
(function (TargetCategory) {
|
|
67
73
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -81,6 +87,9 @@ var ButtonEvent;
|
|
|
81
87
|
ButtonEvent[ButtonEvent["TIMESTAMP"] = 3] = "TIMESTAMP";
|
|
82
88
|
ButtonEvent[ButtonEvent["ACTIVE_IDENTIFIER"] = 4] = "ACTIVE_IDENTIFIER";
|
|
83
89
|
})(ButtonEvent || (ButtonEvent = {}));
|
|
90
|
+
/**
|
|
91
|
+
* @group Apple TV Remote
|
|
92
|
+
*/
|
|
84
93
|
var ButtonState;
|
|
85
94
|
(function (ButtonState) {
|
|
86
95
|
ButtonState[ButtonState["UP"] = 0] = "UP";
|
|
@@ -102,6 +111,9 @@ var AudioCodecConfigurationTypes;
|
|
|
102
111
|
AudioCodecConfigurationTypes[AudioCodecConfigurationTypes["CODEC_TYPE"] = 1] = "CODEC_TYPE";
|
|
103
112
|
AudioCodecConfigurationTypes[AudioCodecConfigurationTypes["CODEC_PARAMETERS"] = 2] = "CODEC_PARAMETERS";
|
|
104
113
|
})(AudioCodecConfigurationTypes || (AudioCodecConfigurationTypes = {}));
|
|
114
|
+
/**
|
|
115
|
+
* @group Camera
|
|
116
|
+
*/
|
|
105
117
|
var AudioCodecTypes;
|
|
106
118
|
(function (AudioCodecTypes) {
|
|
107
119
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -120,19 +132,6 @@ var AudioCodecParametersTypes;
|
|
|
120
132
|
AudioCodecParametersTypes[AudioCodecParametersTypes["SAMPLE_RATE"] = 3] = "SAMPLE_RATE";
|
|
121
133
|
AudioCodecParametersTypes[AudioCodecParametersTypes["PACKET_TIME"] = 4] = "PACKET_TIME"; // only present in selected audio codec parameters tlv
|
|
122
134
|
})(AudioCodecParametersTypes || (AudioCodecParametersTypes = {}));
|
|
123
|
-
var AudioBitrate;
|
|
124
|
-
(function (AudioBitrate) {
|
|
125
|
-
AudioBitrate[AudioBitrate["VARIABLE"] = 0] = "VARIABLE";
|
|
126
|
-
AudioBitrate[AudioBitrate["CONSTANT"] = 1] = "CONSTANT";
|
|
127
|
-
})(AudioBitrate = exports.AudioBitrate || (exports.AudioBitrate = {}));
|
|
128
|
-
var AudioSamplerate;
|
|
129
|
-
(function (AudioSamplerate) {
|
|
130
|
-
AudioSamplerate[AudioSamplerate["KHZ_8"] = 0] = "KHZ_8";
|
|
131
|
-
AudioSamplerate[AudioSamplerate["KHZ_16"] = 1] = "KHZ_16";
|
|
132
|
-
AudioSamplerate[AudioSamplerate["KHZ_24"] = 2] = "KHZ_24";
|
|
133
|
-
// 3, 4, 5 are theoretically defined, but no idea to what kHz value they correspond to
|
|
134
|
-
// probably KHZ_32, KHZ_44_1, KHZ_48 (as supported by Secure Video recordings)
|
|
135
|
-
})(AudioSamplerate = exports.AudioSamplerate || (exports.AudioSamplerate = {}));
|
|
136
135
|
var SiriAudioSessionState;
|
|
137
136
|
(function (SiriAudioSessionState) {
|
|
138
137
|
SiriAudioSessionState[SiriAudioSessionState["STARTING"] = 0] = "STARTING";
|
|
@@ -140,6 +139,9 @@ var SiriAudioSessionState;
|
|
|
140
139
|
SiriAudioSessionState[SiriAudioSessionState["CLOSING"] = 2] = "CLOSING";
|
|
141
140
|
SiriAudioSessionState[SiriAudioSessionState["CLOSED"] = 3] = "CLOSED";
|
|
142
141
|
})(SiriAudioSessionState || (SiriAudioSessionState = {}));
|
|
142
|
+
/**
|
|
143
|
+
* @group Apple TV Remote
|
|
144
|
+
*/
|
|
143
145
|
var TargetUpdates;
|
|
144
146
|
(function (TargetUpdates) {
|
|
145
147
|
TargetUpdates[TargetUpdates["NAME"] = 0] = "NAME";
|
|
@@ -147,11 +149,14 @@ var TargetUpdates;
|
|
|
147
149
|
TargetUpdates[TargetUpdates["UPDATED_BUTTONS"] = 2] = "UPDATED_BUTTONS";
|
|
148
150
|
TargetUpdates[TargetUpdates["REMOVED_BUTTONS"] = 3] = "REMOVED_BUTTONS";
|
|
149
151
|
})(TargetUpdates = exports.TargetUpdates || (exports.TargetUpdates = {}));
|
|
152
|
+
/**
|
|
153
|
+
* @group Apple TV Remote
|
|
154
|
+
*/
|
|
150
155
|
var RemoteControllerEvents;
|
|
151
156
|
(function (RemoteControllerEvents) {
|
|
152
157
|
/**
|
|
153
158
|
* This event is emitted when the active state of the remote has changed.
|
|
154
|
-
* active = true indicates that there is currently an
|
|
159
|
+
* active = true indicates that there is currently an Apple TV listening of button presses and audio streams.
|
|
155
160
|
*/
|
|
156
161
|
RemoteControllerEvents["ACTIVE_CHANGE"] = "active-change";
|
|
157
162
|
/**
|
|
@@ -167,12 +172,12 @@ var RemoteControllerEvents;
|
|
|
167
172
|
*/
|
|
168
173
|
RemoteControllerEvents["TARGET_ADDED"] = "target-add";
|
|
169
174
|
/**
|
|
170
|
-
* This event is emitted when
|
|
175
|
+
* This event is emitted when an existing target was updated.
|
|
171
176
|
* The 'updates' array indicates what exactly was changed for the target.
|
|
172
177
|
*/
|
|
173
178
|
RemoteControllerEvents["TARGET_UPDATED"] = "target-update";
|
|
174
179
|
/**
|
|
175
|
-
* This event is emitted when
|
|
180
|
+
* This event is emitted when an existing configuration for a target was removed.
|
|
176
181
|
*/
|
|
177
182
|
RemoteControllerEvents["TARGET_REMOVED"] = "target-remove";
|
|
178
183
|
/**
|
|
@@ -184,20 +189,23 @@ var RemoteControllerEvents;
|
|
|
184
189
|
})(RemoteControllerEvents = exports.RemoteControllerEvents || (exports.RemoteControllerEvents = {}));
|
|
185
190
|
/**
|
|
186
191
|
* Handles everything needed to implement a fully working HomeKit remote controller.
|
|
192
|
+
*
|
|
193
|
+
* @group Apple TV Remote
|
|
187
194
|
*/
|
|
188
195
|
var RemoteController = /** @class */ (function (_super) {
|
|
189
196
|
tslib_1.__extends(RemoteController, _super);
|
|
190
197
|
/**
|
|
191
198
|
* Creates a new RemoteController.
|
|
192
199
|
* If siri voice input is supported the constructor to an SiriAudioStreamProducer needs to be supplied.
|
|
193
|
-
* Otherwise a remote without voice support will be created.
|
|
200
|
+
* Otherwise, a remote without voice support will be created.
|
|
194
201
|
*
|
|
195
202
|
* For every audio session a new SiriAudioStreamProducer will be constructed.
|
|
196
203
|
*
|
|
197
|
-
* @param audioProducerConstructor
|
|
204
|
+
* @param audioProducerConstructor - constructor for a SiriAudioStreamProducer
|
|
198
205
|
* @param producerOptions - if supplied this argument will be supplied as third argument of the SiriAudioStreamProducer
|
|
199
206
|
* constructor. This should be used to supply configurations to the stream producer.
|
|
200
207
|
*/
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
|
|
201
209
|
function RemoteController(audioProducerConstructor, producerOptions) {
|
|
202
210
|
var _this = _super.call(this) || this;
|
|
203
211
|
_this.buttons = {}; // internal mapping of buttonId to buttonType for supported buttons
|
|
@@ -214,13 +222,13 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
214
222
|
var audioConfiguration = _this.constructSupportedAudioConfiguration();
|
|
215
223
|
_this.supportedAudioConfiguration = RemoteController.buildSupportedAudioConfigurationTLV(audioConfiguration);
|
|
216
224
|
_this.selectedAudioConfiguration = {
|
|
217
|
-
codecType: 3 /* OPUS */,
|
|
225
|
+
codecType: 3 /* AudioCodecTypes.OPUS */,
|
|
218
226
|
parameters: {
|
|
219
227
|
channels: 1,
|
|
220
|
-
bitrate: 0 /* VARIABLE */,
|
|
221
|
-
samplerate: 1 /* KHZ_16 */,
|
|
228
|
+
bitrate: 0 /* AudioBitrate.VARIABLE */,
|
|
229
|
+
samplerate: 1 /* AudioSamplerate.KHZ_16 */,
|
|
222
230
|
rtpTime: 20,
|
|
223
|
-
}
|
|
231
|
+
},
|
|
224
232
|
};
|
|
225
233
|
_this.selectedAudioConfigurationString = RemoteController.buildSelectedAudioConfigurationTLV({
|
|
226
234
|
audioCodecConfiguration: _this.selectedAudioConfiguration,
|
|
@@ -231,12 +239,12 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
231
239
|
* @private
|
|
232
240
|
*/
|
|
233
241
|
RemoteController.prototype.controllerId = function () {
|
|
234
|
-
return "remote" /* REMOTE */;
|
|
242
|
+
return "remote" /* DefaultControllerType.REMOTE */;
|
|
235
243
|
};
|
|
236
244
|
/**
|
|
237
245
|
* Set a new target as active target. A value of 0 indicates that no target is selected currently.
|
|
238
246
|
*
|
|
239
|
-
* @param activeIdentifier
|
|
247
|
+
* @param activeIdentifier - target identifier
|
|
240
248
|
*/
|
|
241
249
|
RemoteController.prototype.setActiveIdentifier = function (activeIdentifier) {
|
|
242
250
|
var _this = this;
|
|
@@ -252,7 +260,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
252
260
|
if (this.activeAudioSession) {
|
|
253
261
|
this.handleSiriAudioStop();
|
|
254
262
|
}
|
|
255
|
-
setTimeout(function () { return _this.emit("active-identifier-change" /* ACTIVE_IDENTIFIER_CHANGE */, activeIdentifier); }, 0);
|
|
263
|
+
setTimeout(function () { return _this.emit("active-identifier-change" /* RemoteControllerEvents.ACTIVE_IDENTIFIER_CHANGE */, activeIdentifier); }, 0);
|
|
256
264
|
this.setInactive();
|
|
257
265
|
};
|
|
258
266
|
/**
|
|
@@ -264,7 +272,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
264
272
|
/**
|
|
265
273
|
* Checks if the supplied targetIdentifier is configured.
|
|
266
274
|
*
|
|
267
|
-
* @param targetIdentifier
|
|
275
|
+
* @param targetIdentifier - The target identifier.
|
|
268
276
|
*/
|
|
269
277
|
RemoteController.prototype.isConfigured = function (targetIdentifier) {
|
|
270
278
|
return this.targetConfigurations.has(targetIdentifier);
|
|
@@ -272,8 +280,8 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
272
280
|
/**
|
|
273
281
|
* Returns the targetIdentifier for a give device name
|
|
274
282
|
*
|
|
275
|
-
* @param name
|
|
276
|
-
* @returns
|
|
283
|
+
* @param name - The name of the device.
|
|
284
|
+
* @returns The targetIdentifier of the device or undefined if not existent.
|
|
277
285
|
*/
|
|
278
286
|
RemoteController.prototype.getTargetIdentifierByName = function (name) {
|
|
279
287
|
var e_1, _a;
|
|
@@ -297,24 +305,24 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
297
305
|
/**
|
|
298
306
|
* Sends a button event to press the supplied button.
|
|
299
307
|
*
|
|
300
|
-
* @param button
|
|
308
|
+
* @param button - button to be pressed
|
|
301
309
|
*/
|
|
302
310
|
RemoteController.prototype.pushButton = function (button) {
|
|
303
|
-
this.sendButtonEvent(button, 1 /* DOWN */);
|
|
311
|
+
this.sendButtonEvent(button, 1 /* ButtonState.DOWN */);
|
|
304
312
|
};
|
|
305
313
|
/**
|
|
306
314
|
* Sends a button event that the supplied button was released.
|
|
307
315
|
*
|
|
308
|
-
* @param button
|
|
316
|
+
* @param button - button which was released
|
|
309
317
|
*/
|
|
310
318
|
RemoteController.prototype.releaseButton = function (button) {
|
|
311
|
-
this.sendButtonEvent(button, 0 /* UP */);
|
|
319
|
+
this.sendButtonEvent(button, 0 /* ButtonState.UP */);
|
|
312
320
|
};
|
|
313
321
|
/**
|
|
314
322
|
* Presses a supplied button for a given time.
|
|
315
323
|
*
|
|
316
|
-
* @param button
|
|
317
|
-
* @param time
|
|
324
|
+
* @param button - button to be pressed and released
|
|
325
|
+
* @param time - time in milliseconds (defaults to 200ms)
|
|
318
326
|
*/
|
|
319
327
|
RemoteController.prototype.pushAndReleaseButton = function (button, time) {
|
|
320
328
|
var _this = this;
|
|
@@ -325,7 +333,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
325
333
|
/**
|
|
326
334
|
* This method adds and configures the remote services for a give accessory.
|
|
327
335
|
*
|
|
328
|
-
* @param accessory
|
|
336
|
+
* @param accessory - the give accessory this remote should be added to
|
|
329
337
|
* @deprecated - use {@link Accessory.configureController} instead
|
|
330
338
|
*/
|
|
331
339
|
RemoteController.prototype.addServicesToAccessory = function (accessory) {
|
|
@@ -339,20 +347,20 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
339
347
|
maximumTargets: 10,
|
|
340
348
|
ticksPerSecond: 1000,
|
|
341
349
|
supportedButtonConfiguration: [],
|
|
342
|
-
hardwareImplemented: this.audioSupported // siri is only allowed for hardware implemented remotes
|
|
350
|
+
hardwareImplemented: this.audioSupported, // siri is only allowed for hardware implemented remotes
|
|
343
351
|
};
|
|
344
352
|
var supportedButtons = [
|
|
345
|
-
1 /* MENU */, 2 /* PLAY_PAUSE */, 3 /* TV_HOME */, 4 /* SELECT */,
|
|
346
|
-
5 /* ARROW_UP */, 6 /* ARROW_RIGHT */, 7 /* ARROW_DOWN */, 8 /* ARROW_LEFT */,
|
|
347
|
-
9 /* VOLUME_UP */, 10 /* VOLUME_DOWN */, 12 /* POWER */, 13 /* GENERIC
|
|
353
|
+
1 /* ButtonType.MENU */, 2 /* ButtonType.PLAY_PAUSE */, 3 /* ButtonType.TV_HOME */, 4 /* ButtonType.SELECT */,
|
|
354
|
+
5 /* ButtonType.ARROW_UP */, 6 /* ButtonType.ARROW_RIGHT */, 7 /* ButtonType.ARROW_DOWN */, 8 /* ButtonType.ARROW_LEFT */,
|
|
355
|
+
9 /* ButtonType.VOLUME_UP */, 10 /* ButtonType.VOLUME_DOWN */, 12 /* ButtonType.POWER */, 13 /* ButtonType.GENERIC */,
|
|
348
356
|
];
|
|
349
357
|
if (this.audioSupported) { // add siri button if this remote supports it
|
|
350
|
-
supportedButtons.push(11 /* SIRI */);
|
|
358
|
+
supportedButtons.push(11 /* ButtonType.SIRI */);
|
|
351
359
|
}
|
|
352
360
|
supportedButtons.forEach(function (button) {
|
|
353
361
|
var buttonConfiguration = {
|
|
354
362
|
buttonID: 100 + button,
|
|
355
|
-
buttonType: button
|
|
363
|
+
buttonType: button,
|
|
356
364
|
};
|
|
357
365
|
configuration.supportedButtonConfiguration.push(buttonConfiguration);
|
|
358
366
|
_this.buttons[button] = buttonConfiguration.buttonID; // also saving mapping of type to id locally
|
|
@@ -363,23 +371,24 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
363
371
|
// the following parameters are expected from HomeKit for a remote
|
|
364
372
|
return {
|
|
365
373
|
audioCodecConfiguration: {
|
|
366
|
-
codecType: 3 /* OPUS */,
|
|
374
|
+
codecType: 3 /* AudioCodecTypes.OPUS */,
|
|
367
375
|
parameters: {
|
|
368
376
|
channels: 1,
|
|
369
|
-
bitrate: 0 /* VARIABLE */,
|
|
370
|
-
samplerate: 1 /* KHZ_16 */,
|
|
371
|
-
}
|
|
377
|
+
bitrate: 0 /* AudioBitrate.VARIABLE */,
|
|
378
|
+
samplerate: 1 /* AudioSamplerate.KHZ_16 */,
|
|
379
|
+
},
|
|
372
380
|
},
|
|
373
381
|
};
|
|
374
382
|
};
|
|
375
383
|
// --------------------------------- TARGET CONTROL ----------------------------------
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
376
385
|
RemoteController.prototype.handleTargetControlWrite = function (value, callback) {
|
|
377
|
-
var data = Buffer.from(value,
|
|
386
|
+
var data = Buffer.from(value, "base64");
|
|
378
387
|
var objects = tlv.decode(data);
|
|
379
|
-
var operation = objects[1 /* OPERATION */][0];
|
|
388
|
+
var operation = objects[1 /* TargetControlList.OPERATION */][0];
|
|
380
389
|
var targetConfiguration = undefined;
|
|
381
|
-
if (objects[2 /* TARGET_CONFIGURATION */]) { // if target configuration was sent, parse it
|
|
382
|
-
targetConfiguration = this.parseTargetConfigurationTLV(objects[2 /* TARGET_CONFIGURATION */]);
|
|
390
|
+
if (objects[2 /* TargetControlList.TARGET_CONFIGURATION */]) { // if target configuration was sent, parse it
|
|
391
|
+
targetConfiguration = this.parseTargetConfigurationTLV(objects[2 /* TargetControlList.TARGET_CONFIGURATION */]);
|
|
383
392
|
}
|
|
384
393
|
debug("Received TargetControl write operation %s", Operation[operation]);
|
|
385
394
|
var handler;
|
|
@@ -400,11 +409,11 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
400
409
|
handler = this.handleListTargets.bind(this);
|
|
401
410
|
break;
|
|
402
411
|
default:
|
|
403
|
-
callback(-70410 /* INVALID_VALUE_IN_REQUEST */, undefined);
|
|
412
|
+
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */, undefined);
|
|
404
413
|
return;
|
|
405
414
|
}
|
|
406
415
|
var status = handler(targetConfiguration);
|
|
407
|
-
if (status === 0 /* SUCCESS */) {
|
|
416
|
+
if (status === 0 /* HAPStatus.SUCCESS */) {
|
|
408
417
|
callback(undefined, this.targetConfigurationsString); // passing value for write response
|
|
409
418
|
if (operation === Operation.ADD && this.activeIdentifier === 0) {
|
|
410
419
|
this.setActiveIdentifier(targetConfiguration.targetIdentifier);
|
|
@@ -417,34 +426,34 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
417
426
|
RemoteController.prototype.handleAddTarget = function (targetConfiguration) {
|
|
418
427
|
var _this = this;
|
|
419
428
|
if (!targetConfiguration) {
|
|
420
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
429
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
421
430
|
}
|
|
422
431
|
this.targetConfigurations.set(targetConfiguration.targetIdentifier, targetConfiguration);
|
|
423
432
|
debug("Configured new target '" + targetConfiguration.targetName + "' with targetIdentifier '" + targetConfiguration.targetIdentifier + "'");
|
|
424
|
-
setTimeout(function () { return _this.emit("target-add" /* TARGET_ADDED */, targetConfiguration); }, 0);
|
|
433
|
+
setTimeout(function () { return _this.emit("target-add" /* RemoteControllerEvents.TARGET_ADDED */, targetConfiguration); }, 0);
|
|
425
434
|
this.updatedTargetConfiguration(); // set response
|
|
426
|
-
return 0 /* SUCCESS */;
|
|
435
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
427
436
|
};
|
|
428
437
|
RemoteController.prototype.handleUpdateTarget = function (targetConfiguration) {
|
|
429
438
|
var e_2, _a;
|
|
430
439
|
var _this = this;
|
|
431
440
|
if (!targetConfiguration) {
|
|
432
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
441
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
433
442
|
}
|
|
434
443
|
var updates = [];
|
|
435
444
|
var configuredTarget = this.targetConfigurations.get(targetConfiguration.targetIdentifier);
|
|
436
445
|
if (!configuredTarget) {
|
|
437
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
446
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
438
447
|
}
|
|
439
448
|
if (targetConfiguration.targetName) {
|
|
440
449
|
debug("Target name was updated '%s' => '%s' (%d)", configuredTarget.targetName, targetConfiguration.targetName, configuredTarget.targetIdentifier);
|
|
441
450
|
configuredTarget.targetName = targetConfiguration.targetName;
|
|
442
|
-
updates.push(0 /* NAME */);
|
|
451
|
+
updates.push(0 /* TargetUpdates.NAME */);
|
|
443
452
|
}
|
|
444
453
|
if (targetConfiguration.targetCategory) {
|
|
445
454
|
debug("Target category was updated '%d' => '%d' for target '%s' (%d)", configuredTarget.targetCategory, targetConfiguration.targetCategory, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
446
455
|
configuredTarget.targetCategory = targetConfiguration.targetCategory;
|
|
447
|
-
updates.push(1 /* CATEGORY */);
|
|
456
|
+
updates.push(1 /* TargetUpdates.CATEGORY */);
|
|
448
457
|
}
|
|
449
458
|
if (targetConfiguration.buttonConfiguration) {
|
|
450
459
|
debug("%d button configurations were updated for target '%s' (%d)", Object.keys(targetConfiguration.buttonConfiguration).length, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
@@ -463,20 +472,20 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
463
472
|
}
|
|
464
473
|
finally { if (e_2) throw e_2.error; }
|
|
465
474
|
}
|
|
466
|
-
updates.push(2 /* UPDATED_BUTTONS */);
|
|
475
|
+
updates.push(2 /* TargetUpdates.UPDATED_BUTTONS */);
|
|
467
476
|
}
|
|
468
|
-
setTimeout(function () { return _this.emit("target-update" /* TARGET_UPDATED */, targetConfiguration, updates); }, 0);
|
|
477
|
+
setTimeout(function () { return _this.emit("target-update" /* RemoteControllerEvents.TARGET_UPDATED */, targetConfiguration, updates); }, 0);
|
|
469
478
|
this.updatedTargetConfiguration(); // set response
|
|
470
|
-
return 0 /* SUCCESS */;
|
|
479
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
471
480
|
};
|
|
472
481
|
RemoteController.prototype.handleRemoveTarget = function (targetConfiguration) {
|
|
473
482
|
var _this = this;
|
|
474
483
|
if (!targetConfiguration) {
|
|
475
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
484
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
476
485
|
}
|
|
477
486
|
var configuredTarget = this.targetConfigurations.get(targetConfiguration.targetIdentifier);
|
|
478
487
|
if (!configuredTarget) {
|
|
479
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
488
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
480
489
|
}
|
|
481
490
|
if (targetConfiguration.buttonConfiguration) {
|
|
482
491
|
for (var key in targetConfiguration.buttonConfiguration) {
|
|
@@ -485,74 +494,74 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
485
494
|
}
|
|
486
495
|
}
|
|
487
496
|
debug("Removed %d button configurations of target '%s' (%d)", Object.keys(targetConfiguration.buttonConfiguration).length, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
488
|
-
setTimeout(function () { return _this.emit("target-update" /* TARGET_UPDATED */, configuredTarget, [3 /* REMOVED_BUTTONS */]); }, 0);
|
|
497
|
+
setTimeout(function () { return _this.emit("target-update" /* RemoteControllerEvents.TARGET_UPDATED */, configuredTarget, [3 /* TargetUpdates.REMOVED_BUTTONS */]); }, 0);
|
|
489
498
|
}
|
|
490
499
|
else {
|
|
491
500
|
this.targetConfigurations.delete(targetConfiguration.targetIdentifier);
|
|
492
501
|
debug("Target '%s' (%d) was removed", configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
493
|
-
setTimeout(function () { return _this.emit("target-remove" /* TARGET_REMOVED */, targetConfiguration.targetIdentifier); }, 0);
|
|
502
|
+
setTimeout(function () { return _this.emit("target-remove" /* RemoteControllerEvents.TARGET_REMOVED */, targetConfiguration.targetIdentifier); }, 0);
|
|
494
503
|
var keys = Object.keys(this.targetConfigurations);
|
|
495
504
|
this.setActiveIdentifier(keys.length === 0 ? 0 : parseInt(keys[0], 10)); // switch to next available remote
|
|
496
505
|
}
|
|
497
506
|
this.updatedTargetConfiguration(); // set response
|
|
498
|
-
return 0 /* SUCCESS */;
|
|
507
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
499
508
|
};
|
|
500
509
|
RemoteController.prototype.handleResetTargets = function (targetConfiguration) {
|
|
501
510
|
var _this = this;
|
|
502
511
|
if (targetConfiguration) {
|
|
503
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
512
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
504
513
|
}
|
|
505
514
|
debug("Resetting all target configurations");
|
|
506
515
|
this.targetConfigurations = new Map();
|
|
507
516
|
this.updatedTargetConfiguration(); // set response
|
|
508
|
-
setTimeout(function () { return _this.emit("targets-reset" /* TARGETS_RESET */); }, 0);
|
|
517
|
+
setTimeout(function () { return _this.emit("targets-reset" /* RemoteControllerEvents.TARGETS_RESET */); }, 0);
|
|
509
518
|
this.setActiveIdentifier(0); // resetting active identifier (also sets active to false)
|
|
510
|
-
return 0 /* SUCCESS */;
|
|
519
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
511
520
|
};
|
|
512
521
|
RemoteController.prototype.handleListTargets = function (targetConfiguration) {
|
|
513
522
|
if (targetConfiguration) {
|
|
514
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
523
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
515
524
|
}
|
|
516
525
|
// this.targetConfigurationsString is updated after each change, so we basically don't need to do anything here
|
|
517
526
|
debug("Returning " + Object.keys(this.targetConfigurations).length + " target configurations");
|
|
518
|
-
return 0 /* SUCCESS */;
|
|
527
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
519
528
|
};
|
|
520
529
|
RemoteController.prototype.handleActiveWrite = function (value, callback, connection) {
|
|
521
530
|
if (this.activeIdentifier === 0) {
|
|
522
531
|
debug("Tried to change active state. There is no active target set though");
|
|
523
|
-
callback(-70410 /* INVALID_VALUE_IN_REQUEST */);
|
|
532
|
+
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
524
533
|
return;
|
|
525
534
|
}
|
|
526
535
|
if (this.activeConnection) {
|
|
527
|
-
this.activeConnection.removeListener("closed" /* CLOSED */, this.activeConnectionDisconnectListener);
|
|
536
|
+
this.activeConnection.removeListener("closed" /* HAPConnectionEvent.CLOSED */, this.activeConnectionDisconnectListener);
|
|
528
537
|
this.activeConnection = undefined;
|
|
529
538
|
this.activeConnectionDisconnectListener = undefined;
|
|
530
539
|
}
|
|
531
540
|
this.activeConnection = value ? connection : undefined;
|
|
532
541
|
if (this.activeConnection) { // register listener when hap connection disconnects
|
|
533
542
|
this.activeConnectionDisconnectListener = this.handleActiveSessionDisconnected.bind(this, this.activeConnection);
|
|
534
|
-
this.activeConnection.on("closed" /* CLOSED */, this.activeConnectionDisconnectListener);
|
|
543
|
+
this.activeConnection.on("closed" /* HAPConnectionEvent.CLOSED */, this.activeConnectionDisconnectListener);
|
|
535
544
|
}
|
|
536
545
|
var activeTarget = this.targetConfigurations.get(this.activeIdentifier);
|
|
537
546
|
if (!activeTarget) {
|
|
538
|
-
callback(-70410 /* INVALID_VALUE_IN_REQUEST */);
|
|
547
|
+
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
539
548
|
return;
|
|
540
549
|
}
|
|
541
550
|
debug("Remote with activeTarget '%s' (%d) was set to %s", activeTarget.targetName, this.activeIdentifier, value ? "ACTIVE" : "INACTIVE");
|
|
542
551
|
callback();
|
|
543
|
-
this.emit("active-change" /* ACTIVE_CHANGE */, value);
|
|
552
|
+
this.emit("active-change" /* RemoteControllerEvents.ACTIVE_CHANGE */, value);
|
|
544
553
|
};
|
|
545
554
|
RemoteController.prototype.setInactive = function () {
|
|
546
555
|
var _this = this;
|
|
547
556
|
if (this.activeConnection === undefined) {
|
|
548
557
|
return;
|
|
549
558
|
}
|
|
550
|
-
this.activeConnection.removeListener("closed" /* CLOSED */, this.activeConnectionDisconnectListener);
|
|
559
|
+
this.activeConnection.removeListener("closed" /* HAPConnectionEvent.CLOSED */, this.activeConnectionDisconnectListener);
|
|
551
560
|
this.activeConnection = undefined;
|
|
552
561
|
this.activeConnectionDisconnectListener = undefined;
|
|
553
562
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.Active).updateValue(false);
|
|
554
563
|
debug("Remote was set to INACTIVE");
|
|
555
|
-
setTimeout(function () { return _this.emit("active-change" /* ACTIVE_CHANGE */, false); }, 0);
|
|
564
|
+
setTimeout(function () { return _this.emit("active-change" /* RemoteControllerEvents.ACTIVE_CHANGE */, false); }, 0);
|
|
556
565
|
};
|
|
557
566
|
RemoteController.prototype.handleActiveSessionDisconnected = function (connection) {
|
|
558
567
|
if (connection !== this.activeConnection) {
|
|
@@ -569,57 +578,56 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
569
578
|
if (this.activeIdentifier === 0) { // cannot press button if no device is selected
|
|
570
579
|
throw new Error("Tried sending button event although no target was selected");
|
|
571
580
|
}
|
|
572
|
-
if (!this.isActive()) { // cannot press button if device is not active (aka no
|
|
581
|
+
if (!this.isActive()) { // cannot press button if device is not active (aka no Apple TV is listening)
|
|
573
582
|
throw new Error("Tried sending button event although target was not marked as active");
|
|
574
583
|
}
|
|
575
|
-
if (button === 11 /* SIRI */ && this.audioSupported) {
|
|
576
|
-
if (buttonState === 1 /* DOWN */) { // start streaming session
|
|
584
|
+
if (button === 11 /* ButtonType.SIRI */ && this.audioSupported) {
|
|
585
|
+
if (buttonState === 1 /* ButtonState.DOWN */) { // start streaming session
|
|
577
586
|
this.handleSiriAudioStart();
|
|
578
587
|
}
|
|
579
|
-
else if (buttonState === 0 /* UP */) { // stop streaming session
|
|
588
|
+
else if (buttonState === 0 /* ButtonState.UP */) { // stop streaming session
|
|
580
589
|
this.handleSiriAudioStop();
|
|
581
590
|
}
|
|
582
591
|
return;
|
|
583
592
|
}
|
|
584
|
-
var buttonIdTlv = tlv.encode(1 /* BUTTON_ID */, buttonID);
|
|
585
|
-
var buttonStateTlv = tlv.encode(2 /* BUTTON_STATE */, buttonState);
|
|
586
|
-
var timestampTlv = tlv.encode(3 /* TIMESTAMP */, tlv.
|
|
587
|
-
|
|
588
|
-
// thus we just interpret timestamp as a regular number
|
|
589
|
-
);
|
|
590
|
-
var activeIdentifierTlv = tlv.encode(4 /* ACTIVE_IDENTIFIER */, tlv.writeUInt32(this.activeIdentifier));
|
|
593
|
+
var buttonIdTlv = tlv.encode(1 /* ButtonEvent.BUTTON_ID */, buttonID);
|
|
594
|
+
var buttonStateTlv = tlv.encode(2 /* ButtonEvent.BUTTON_STATE */, buttonState);
|
|
595
|
+
var timestampTlv = tlv.encode(3 /* ButtonEvent.TIMESTAMP */, tlv.writeVariableUIntLE(new Date().getTime()));
|
|
596
|
+
var activeIdentifierTlv = tlv.encode(4 /* ButtonEvent.ACTIVE_IDENTIFIER */, tlv.writeUInt32(this.activeIdentifier));
|
|
591
597
|
this.lastButtonEvent = Buffer.concat([
|
|
592
|
-
buttonIdTlv, buttonStateTlv, timestampTlv, activeIdentifierTlv
|
|
593
|
-
]).toString(
|
|
598
|
+
buttonIdTlv, buttonStateTlv, timestampTlv, activeIdentifierTlv,
|
|
599
|
+
]).toString("base64");
|
|
594
600
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ButtonEvent).sendEventNotification(this.lastButtonEvent);
|
|
595
601
|
};
|
|
596
602
|
RemoteController.prototype.parseTargetConfigurationTLV = function (data) {
|
|
597
603
|
var configTLV = tlv.decode(data);
|
|
598
|
-
var identifier = tlv.readUInt32(configTLV[1 /* TARGET_IDENTIFIER */]);
|
|
604
|
+
var identifier = tlv.readUInt32(configTLV[1 /* TargetConfigurationTypes.TARGET_IDENTIFIER */]);
|
|
599
605
|
var name = undefined;
|
|
600
|
-
if (configTLV[2 /* TARGET_NAME */])
|
|
601
|
-
name = configTLV[2 /* TARGET_NAME */].toString();
|
|
606
|
+
if (configTLV[2 /* TargetConfigurationTypes.TARGET_NAME */]) {
|
|
607
|
+
name = configTLV[2 /* TargetConfigurationTypes.TARGET_NAME */].toString();
|
|
608
|
+
}
|
|
602
609
|
var category = undefined;
|
|
603
|
-
if (configTLV[3 /* TARGET_CATEGORY */])
|
|
604
|
-
category = tlv.readUInt16(configTLV[3 /* TARGET_CATEGORY */]);
|
|
610
|
+
if (configTLV[3 /* TargetConfigurationTypes.TARGET_CATEGORY */]) {
|
|
611
|
+
category = tlv.readUInt16(configTLV[3 /* TargetConfigurationTypes.TARGET_CATEGORY */]);
|
|
612
|
+
}
|
|
605
613
|
var buttonConfiguration = {};
|
|
606
|
-
if (configTLV[4 /* BUTTON_CONFIGURATION */]) {
|
|
607
|
-
var buttonConfigurationTLV = tlv.decodeList(configTLV[4 /* BUTTON_CONFIGURATION */], 1 /* BUTTON_ID */);
|
|
614
|
+
if (configTLV[4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */]) {
|
|
615
|
+
var buttonConfigurationTLV = tlv.decodeList(configTLV[4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */], 1 /* ButtonConfigurationTypes.BUTTON_ID */);
|
|
608
616
|
buttonConfigurationTLV.forEach(function (entry) {
|
|
609
|
-
var buttonId = entry[1 /* BUTTON_ID */][0];
|
|
610
|
-
var buttonType = tlv.readUInt16(entry[2 /* BUTTON_TYPE */]);
|
|
617
|
+
var buttonId = entry[1 /* ButtonConfigurationTypes.BUTTON_ID */][0];
|
|
618
|
+
var buttonType = tlv.readUInt16(entry[2 /* ButtonConfigurationTypes.BUTTON_TYPE */]);
|
|
611
619
|
var buttonName;
|
|
612
|
-
if (entry[3 /* BUTTON_NAME */]) {
|
|
613
|
-
buttonName = entry[3 /* BUTTON_NAME */].toString();
|
|
620
|
+
if (entry[3 /* ButtonConfigurationTypes.BUTTON_NAME */]) {
|
|
621
|
+
buttonName = entry[3 /* ButtonConfigurationTypes.BUTTON_NAME */].toString();
|
|
614
622
|
}
|
|
615
623
|
else {
|
|
616
|
-
// @ts-
|
|
624
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
617
625
|
buttonName = ButtonType[buttonType];
|
|
618
626
|
}
|
|
619
627
|
buttonConfiguration[buttonId] = {
|
|
620
628
|
buttonID: buttonId,
|
|
621
629
|
buttonType: buttonType,
|
|
622
|
-
buttonName: buttonName
|
|
630
|
+
buttonName: buttonName,
|
|
623
631
|
};
|
|
624
632
|
});
|
|
625
633
|
}
|
|
@@ -627,27 +635,28 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
627
635
|
targetIdentifier: identifier,
|
|
628
636
|
targetName: name,
|
|
629
637
|
targetCategory: category,
|
|
630
|
-
buttonConfiguration: buttonConfiguration
|
|
638
|
+
buttonConfiguration: buttonConfiguration,
|
|
631
639
|
};
|
|
632
640
|
};
|
|
633
641
|
RemoteController.prototype.updatedTargetConfiguration = function () {
|
|
634
642
|
var e_3, _a, e_4, _b;
|
|
643
|
+
var _c;
|
|
635
644
|
var bufferList = [];
|
|
636
645
|
try {
|
|
637
|
-
for (var
|
|
638
|
-
var configuration =
|
|
639
|
-
var targetIdentifier = tlv.encode(1 /* TARGET_IDENTIFIER */, tlv.writeUInt32(configuration.targetIdentifier));
|
|
640
|
-
var targetName = tlv.encode(2 /* TARGET_NAME */, configuration.targetName);
|
|
641
|
-
var targetCategory = tlv.encode(3 /* TARGET_CATEGORY */, tlv.writeUInt16(configuration.targetCategory));
|
|
646
|
+
for (var _d = tslib_1.__values(Object.values(this.targetConfigurations)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
647
|
+
var configuration = _e.value;
|
|
648
|
+
var targetIdentifier = tlv.encode(1 /* TargetConfigurationTypes.TARGET_IDENTIFIER */, tlv.writeUInt32(configuration.targetIdentifier));
|
|
649
|
+
var targetName = tlv.encode(2 /* TargetConfigurationTypes.TARGET_NAME */, configuration.targetName);
|
|
650
|
+
var targetCategory = tlv.encode(3 /* TargetConfigurationTypes.TARGET_CATEGORY */, tlv.writeUInt16(configuration.targetCategory));
|
|
642
651
|
var buttonConfigurationBuffers = [];
|
|
643
652
|
try {
|
|
644
|
-
for (var
|
|
645
|
-
var value =
|
|
646
|
-
var tlvBuffer = tlv.encode(1 /* BUTTON_ID */, value.buttonID, 2 /* BUTTON_TYPE */, tlv.writeUInt16(value.buttonType));
|
|
653
|
+
for (var _f = (e_4 = void 0, tslib_1.__values(configuration.buttonConfiguration.values())), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
654
|
+
var value = _g.value;
|
|
655
|
+
var tlvBuffer = tlv.encode(1 /* ButtonConfigurationTypes.BUTTON_ID */, value.buttonID, 2 /* ButtonConfigurationTypes.BUTTON_TYPE */, tlv.writeUInt16(value.buttonType));
|
|
647
656
|
if (value.buttonName) {
|
|
648
657
|
tlvBuffer = Buffer.concat([
|
|
649
658
|
tlvBuffer,
|
|
650
|
-
tlv.encode(3 /* BUTTON_NAME */, value.buttonName)
|
|
659
|
+
tlv.encode(3 /* ButtonConfigurationTypes.BUTTON_NAME */, value.buttonName),
|
|
651
660
|
]);
|
|
652
661
|
}
|
|
653
662
|
buttonConfigurationBuffers.push(tlvBuffer);
|
|
@@ -656,43 +665,44 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
656
665
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
657
666
|
finally {
|
|
658
667
|
try {
|
|
659
|
-
if (
|
|
668
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
660
669
|
}
|
|
661
670
|
finally { if (e_4) throw e_4.error; }
|
|
662
671
|
}
|
|
663
|
-
var buttonConfiguration = tlv.encode(4 /* BUTTON_CONFIGURATION */, Buffer.concat(buttonConfigurationBuffers));
|
|
672
|
+
var buttonConfiguration = tlv.encode(4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */, Buffer.concat(buttonConfigurationBuffers));
|
|
664
673
|
var targetConfiguration = Buffer.concat([targetIdentifier, targetName, targetCategory, buttonConfiguration]);
|
|
665
|
-
bufferList.push(tlv.encode(2 /* TARGET_CONFIGURATION */, targetConfiguration));
|
|
674
|
+
bufferList.push(tlv.encode(2 /* TargetControlList.TARGET_CONFIGURATION */, targetConfiguration));
|
|
666
675
|
}
|
|
667
676
|
}
|
|
668
677
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
669
678
|
finally {
|
|
670
679
|
try {
|
|
671
|
-
if (
|
|
680
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
672
681
|
}
|
|
673
682
|
finally { if (e_3) throw e_3.error; }
|
|
674
683
|
}
|
|
675
|
-
this.targetConfigurationsString = Buffer.concat(bufferList).toString(
|
|
676
|
-
this.stateChangeDelegate
|
|
684
|
+
this.targetConfigurationsString = Buffer.concat(bufferList).toString("base64");
|
|
685
|
+
(_c = this.stateChangeDelegate) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
677
686
|
};
|
|
678
687
|
RemoteController.prototype.buildTargetControlSupportedConfigurationTLV = function (configuration) {
|
|
679
|
-
var maximumTargets = tlv.encode(1 /* MAXIMUM_TARGETS */, configuration.maximumTargets);
|
|
680
|
-
var ticksPerSecond = tlv.encode(2 /* TICKS_PER_SECOND */, tlv.
|
|
688
|
+
var maximumTargets = tlv.encode(1 /* TargetControlCommands.MAXIMUM_TARGETS */, configuration.maximumTargets);
|
|
689
|
+
var ticksPerSecond = tlv.encode(2 /* TargetControlCommands.TICKS_PER_SECOND */, tlv.writeVariableUIntLE(configuration.ticksPerSecond));
|
|
681
690
|
var supportedButtonConfigurationBuffers = [];
|
|
682
691
|
configuration.supportedButtonConfiguration.forEach(function (value) {
|
|
683
|
-
var tlvBuffer = tlv.encode(1 /* BUTTON_ID */, value.buttonID, 2 /* BUTTON_TYPE */, tlv.writeUInt16(value.buttonType));
|
|
692
|
+
var tlvBuffer = tlv.encode(1 /* SupportedButtonConfigurationTypes.BUTTON_ID */, value.buttonID, 2 /* SupportedButtonConfigurationTypes.BUTTON_TYPE */, tlv.writeUInt16(value.buttonType));
|
|
684
693
|
supportedButtonConfigurationBuffers.push(tlvBuffer);
|
|
685
694
|
});
|
|
686
|
-
var supportedButtonConfiguration = tlv.encode(3 /* SUPPORTED_BUTTON_CONFIGURATION */, Buffer.concat(supportedButtonConfigurationBuffers));
|
|
687
|
-
var type = tlv.encode(4 /* TYPE */, configuration.hardwareImplemented ? 1 : 0);
|
|
688
|
-
return Buffer.concat([maximumTargets, ticksPerSecond, supportedButtonConfiguration, type]).toString(
|
|
695
|
+
var supportedButtonConfiguration = tlv.encode(3 /* TargetControlCommands.SUPPORTED_BUTTON_CONFIGURATION */, Buffer.concat(supportedButtonConfigurationBuffers));
|
|
696
|
+
var type = tlv.encode(4 /* TargetControlCommands.TYPE */, configuration.hardwareImplemented ? 1 : 0);
|
|
697
|
+
return Buffer.concat([maximumTargets, ticksPerSecond, supportedButtonConfiguration, type]).toString("base64");
|
|
689
698
|
};
|
|
690
699
|
// --------------------------------- SIRI/DATA STREAM --------------------------------
|
|
700
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
691
701
|
RemoteController.prototype.handleTargetControlWhoAmI = function (connection, message) {
|
|
692
|
-
var targetIdentifier = message
|
|
702
|
+
var targetIdentifier = message.identifier;
|
|
693
703
|
this.dataStreamConnections.set(targetIdentifier, connection);
|
|
694
704
|
debug("Discovered HDS connection for targetIdentifier %s", targetIdentifier);
|
|
695
|
-
connection.addProtocolHandler("dataSend" /* DATA_SEND */, this);
|
|
705
|
+
connection.addProtocolHandler("dataSend" /* Protocols.DATA_SEND */, this);
|
|
696
706
|
};
|
|
697
707
|
RemoteController.prototype.handleSiriAudioStart = function () {
|
|
698
708
|
if (!this.audioSupported) {
|
|
@@ -713,6 +723,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
713
723
|
debug("Tried opening Siri audio stream however target is not connected via HDS");
|
|
714
724
|
return;
|
|
715
725
|
}
|
|
726
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
716
727
|
var audioSession = new SiriAudioSession(connection, this.selectedAudioConfiguration, this.audioProducerConstructor, this.audioProducerOptions);
|
|
717
728
|
if (!this.activeAudioSession) {
|
|
718
729
|
this.activeAudioSession = audioSession;
|
|
@@ -722,7 +733,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
722
733
|
// so no collision with the input device can happen
|
|
723
734
|
this.nextAudioSession = audioSession;
|
|
724
735
|
}
|
|
725
|
-
audioSession.on("close" /* CLOSE */, this.handleSiriAudioSessionClosed.bind(this, audioSession));
|
|
736
|
+
audioSession.on("close" /* SiriAudioSessionEvents.CLOSE */, this.handleSiriAudioSessionClosed.bind(this, audioSession));
|
|
726
737
|
audioSession.start();
|
|
727
738
|
};
|
|
728
739
|
RemoteController.prototype.handleSiriAudioStop = function () {
|
|
@@ -738,9 +749,10 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
738
749
|
}
|
|
739
750
|
debug("handleSiriAudioStop called although no audio session was started");
|
|
740
751
|
};
|
|
752
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
741
753
|
RemoteController.prototype.handleDataSendAckEvent = function (message) {
|
|
742
|
-
var streamId = message
|
|
743
|
-
var endOfStream = message
|
|
754
|
+
var streamId = message.streamId;
|
|
755
|
+
var endOfStream = message.endOfStream;
|
|
744
756
|
if (this.activeAudioSession && this.activeAudioSession.streamId === streamId) {
|
|
745
757
|
this.activeAudioSession.handleDataSendAckEvent(endOfStream);
|
|
746
758
|
}
|
|
@@ -751,9 +763,10 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
751
763
|
debug("Received dataSend acknowledgment event for unknown streamId '%s'", streamId);
|
|
752
764
|
}
|
|
753
765
|
};
|
|
766
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
754
767
|
RemoteController.prototype.handleDataSendCloseEvent = function (message) {
|
|
755
|
-
var streamId = message
|
|
756
|
-
var reason = message
|
|
768
|
+
var streamId = message.streamId;
|
|
769
|
+
var reason = message.reason;
|
|
757
770
|
if (this.activeAudioSession && this.activeAudioSession.streamId === streamId) {
|
|
758
771
|
this.activeAudioSession.handleDataSendCloseEvent(reason);
|
|
759
772
|
}
|
|
@@ -794,23 +807,24 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
794
807
|
}
|
|
795
808
|
};
|
|
796
809
|
// ------------------------------- AUDIO CONFIGURATION -------------------------------
|
|
810
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
797
811
|
RemoteController.prototype.handleSelectedAudioConfigurationWrite = function (value, callback) {
|
|
798
|
-
var data = Buffer.from(value,
|
|
812
|
+
var data = Buffer.from(value, "base64");
|
|
799
813
|
var objects = tlv.decode(data);
|
|
800
|
-
var selectedAudioStreamConfiguration = tlv.decode(objects[1 /* SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */]);
|
|
801
|
-
var codec = selectedAudioStreamConfiguration[1 /* CODEC_TYPE */][0];
|
|
802
|
-
var parameters = tlv.decode(selectedAudioStreamConfiguration[2 /* CODEC_PARAMETERS */]);
|
|
803
|
-
var channels = parameters[1 /* CHANNEL */][0];
|
|
804
|
-
var bitrate = parameters[2 /* BIT_RATE */][0];
|
|
805
|
-
var samplerate = parameters[3 /* SAMPLE_RATE */][0];
|
|
814
|
+
var selectedAudioStreamConfiguration = tlv.decode(objects[1 /* SelectedAudioInputStreamConfigurationTypes.SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */]);
|
|
815
|
+
var codec = selectedAudioStreamConfiguration[1 /* AudioCodecConfigurationTypes.CODEC_TYPE */][0];
|
|
816
|
+
var parameters = tlv.decode(selectedAudioStreamConfiguration[2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */]);
|
|
817
|
+
var channels = parameters[1 /* AudioCodecParametersTypes.CHANNEL */][0];
|
|
818
|
+
var bitrate = parameters[2 /* AudioCodecParametersTypes.BIT_RATE */][0];
|
|
819
|
+
var samplerate = parameters[3 /* AudioCodecParametersTypes.SAMPLE_RATE */][0];
|
|
806
820
|
this.selectedAudioConfiguration = {
|
|
807
821
|
codecType: codec,
|
|
808
822
|
parameters: {
|
|
809
823
|
channels: channels,
|
|
810
824
|
bitrate: bitrate,
|
|
811
825
|
samplerate: samplerate,
|
|
812
|
-
rtpTime: 20
|
|
813
|
-
}
|
|
826
|
+
rtpTime: 20,
|
|
827
|
+
},
|
|
814
828
|
};
|
|
815
829
|
this.selectedAudioConfigurationString = RemoteController.buildSelectedAudioConfigurationTLV({
|
|
816
830
|
audioCodecConfiguration: this.selectedAudioConfiguration,
|
|
@@ -819,24 +833,24 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
819
833
|
};
|
|
820
834
|
RemoteController.buildSupportedAudioConfigurationTLV = function (configuration) {
|
|
821
835
|
var codecConfigurationTLV = RemoteController.buildCodecConfigurationTLV(configuration.audioCodecConfiguration);
|
|
822
|
-
var supportedAudioStreamConfiguration = tlv.encode(1 /* AUDIO_CODEC_CONFIGURATION */, codecConfigurationTLV);
|
|
823
|
-
return supportedAudioStreamConfiguration.toString(
|
|
836
|
+
var supportedAudioStreamConfiguration = tlv.encode(1 /* SupportedAudioStreamConfigurationTypes.AUDIO_CODEC_CONFIGURATION */, codecConfigurationTLV);
|
|
837
|
+
return supportedAudioStreamConfiguration.toString("base64");
|
|
824
838
|
};
|
|
825
839
|
RemoteController.buildSelectedAudioConfigurationTLV = function (configuration) {
|
|
826
840
|
var codecConfigurationTLV = RemoteController.buildCodecConfigurationTLV(configuration.audioCodecConfiguration);
|
|
827
|
-
var supportedAudioStreamConfiguration = tlv.encode(1 /* SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */, codecConfigurationTLV);
|
|
828
|
-
return supportedAudioStreamConfiguration.toString(
|
|
841
|
+
var supportedAudioStreamConfiguration = tlv.encode(1 /* SelectedAudioInputStreamConfigurationTypes.SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */, codecConfigurationTLV);
|
|
842
|
+
return supportedAudioStreamConfiguration.toString("base64");
|
|
829
843
|
};
|
|
830
844
|
RemoteController.buildCodecConfigurationTLV = function (codecConfiguration) {
|
|
831
845
|
var parameters = codecConfiguration.parameters;
|
|
832
|
-
var parametersTLV = tlv.encode(1 /* CHANNEL */, parameters.channels, 2 /* BIT_RATE */, parameters.bitrate, 3 /* SAMPLE_RATE */, parameters.samplerate);
|
|
846
|
+
var parametersTLV = tlv.encode(1 /* AudioCodecParametersTypes.CHANNEL */, parameters.channels, 2 /* AudioCodecParametersTypes.BIT_RATE */, parameters.bitrate, 3 /* AudioCodecParametersTypes.SAMPLE_RATE */, parameters.samplerate);
|
|
833
847
|
if (parameters.rtpTime) {
|
|
834
848
|
parametersTLV = Buffer.concat([
|
|
835
849
|
parametersTLV,
|
|
836
|
-
tlv.encode(4 /* PACKET_TIME */, parameters.rtpTime)
|
|
850
|
+
tlv.encode(4 /* AudioCodecParametersTypes.PACKET_TIME */, parameters.rtpTime),
|
|
837
851
|
]);
|
|
838
852
|
}
|
|
839
|
-
return tlv.encode(1 /* CODEC_TYPE */, codecConfiguration.codecType, 2 /* CODEC_PARAMETERS */, parametersTLV);
|
|
853
|
+
return tlv.encode(1 /* AudioCodecConfigurationTypes.CODEC_TYPE */, codecConfiguration.codecType, 2 /* AudioCodecConfigurationTypes.CODEC_PARAMETERS */, parametersTLV);
|
|
840
854
|
};
|
|
841
855
|
// -----------------------------------------------------------------------------------
|
|
842
856
|
/**
|
|
@@ -844,20 +858,20 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
844
858
|
*/
|
|
845
859
|
RemoteController.prototype.constructServices = function () {
|
|
846
860
|
var _a;
|
|
847
|
-
this.targetControlManagementService = new Service_1.Service.TargetControlManagement(
|
|
861
|
+
this.targetControlManagementService = new Service_1.Service.TargetControlManagement("", "");
|
|
848
862
|
this.targetControlManagementService.setCharacteristic(Characteristic_1.Characteristic.TargetControlSupportedConfiguration, this.supportedConfiguration);
|
|
849
863
|
this.targetControlManagementService.setCharacteristic(Characteristic_1.Characteristic.TargetControlList, this.targetConfigurationsString);
|
|
850
864
|
this.targetControlManagementService.setPrimaryService();
|
|
851
865
|
// you can also expose multiple TargetControl services to control multiple apple tvs simultaneously.
|
|
852
866
|
// should we extend this class to support multiple TargetControl services or should users just create a second accessory?
|
|
853
|
-
this.targetControlService = new Service_1.Service.TargetControl(
|
|
867
|
+
this.targetControlService = new Service_1.Service.TargetControl("", "");
|
|
854
868
|
this.targetControlService.setCharacteristic(Characteristic_1.Characteristic.ActiveIdentifier, 0);
|
|
855
869
|
this.targetControlService.setCharacteristic(Characteristic_1.Characteristic.Active, false);
|
|
856
870
|
this.targetControlService.setCharacteristic(Characteristic_1.Characteristic.ButtonEvent, this.lastButtonEvent);
|
|
857
871
|
if (this.audioSupported) {
|
|
858
|
-
this.siriService = new Service_1.Service.Siri(
|
|
872
|
+
this.siriService = new Service_1.Service.Siri("", "");
|
|
859
873
|
this.siriService.setCharacteristic(Characteristic_1.Characteristic.SiriInputType, Characteristic_1.Characteristic.SiriInputType.PUSH_BUTTON_TRIGGERED_APPLE_TV);
|
|
860
|
-
this.audioStreamManagementService = new Service_1.Service.AudioStreamManagement(
|
|
874
|
+
this.audioStreamManagementService = new Service_1.Service.AudioStreamManagement("", "");
|
|
861
875
|
this.audioStreamManagementService.setCharacteristic(Characteristic_1.Characteristic.SupportedAudioStreamConfiguration, this.supportedAudioConfiguration);
|
|
862
876
|
this.audioStreamManagementService.setCharacteristic(Characteristic_1.Characteristic.SelectedAudioStreamConfiguration, this.selectedAudioConfigurationString);
|
|
863
877
|
this.dataStreamManagement = new datastream_1.DataStreamManagement();
|
|
@@ -869,7 +883,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
869
883
|
targetControl: this.targetControlService,
|
|
870
884
|
siri: this.siriService,
|
|
871
885
|
audioStreamManagement: this.audioStreamManagementService,
|
|
872
|
-
dataStreamTransportManagement: (_a = this.dataStreamManagement) === null || _a === void 0 ? void 0 : _a.getService()
|
|
886
|
+
dataStreamTransportManagement: (_a = this.dataStreamManagement) === null || _a === void 0 ? void 0 : _a.getService(),
|
|
873
887
|
};
|
|
874
888
|
};
|
|
875
889
|
/**
|
|
@@ -892,43 +906,43 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
892
906
|
throw new Error("Unexpected state: Services not configured!"); // playing it save
|
|
893
907
|
}
|
|
894
908
|
this.targetControlManagementService.getCharacteristic(Characteristic_1.Characteristic.TargetControlList)
|
|
895
|
-
.on("get" /* GET */, function (callback) {
|
|
909
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
896
910
|
callback(null, _this.targetConfigurationsString);
|
|
897
911
|
})
|
|
898
|
-
.on("set" /* SET */, this.handleTargetControlWrite.bind(this));
|
|
912
|
+
.on("set" /* CharacteristicEventTypes.SET */, this.handleTargetControlWrite.bind(this));
|
|
899
913
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ActiveIdentifier)
|
|
900
|
-
.on("get" /* GET */, function (callback) {
|
|
914
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
901
915
|
callback(undefined, _this.activeIdentifier);
|
|
902
916
|
});
|
|
903
917
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.Active)
|
|
904
|
-
.on("get" /* GET */, function (callback) {
|
|
918
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
905
919
|
callback(undefined, _this.isActive());
|
|
906
920
|
})
|
|
907
|
-
.on("set" /* SET */, function (value, callback, context, connection) {
|
|
921
|
+
.on("set" /* CharacteristicEventTypes.SET */, function (value, callback, context, connection) {
|
|
908
922
|
if (!connection) {
|
|
909
923
|
debug("Set event handler for Remote.Active cannot be called from plugin. Connection undefined!");
|
|
910
|
-
callback(-70410 /* INVALID_VALUE_IN_REQUEST */);
|
|
924
|
+
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
911
925
|
return;
|
|
912
926
|
}
|
|
913
927
|
_this.handleActiveWrite(value, callback, connection);
|
|
914
928
|
});
|
|
915
929
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ButtonEvent)
|
|
916
|
-
.on("get" /* GET */, function (callback) {
|
|
930
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
917
931
|
callback(undefined, _this.lastButtonEvent);
|
|
918
932
|
});
|
|
919
933
|
if (this.audioSupported) {
|
|
920
934
|
this.audioStreamManagementService.getCharacteristic(Characteristic_1.Characteristic.SelectedAudioStreamConfiguration)
|
|
921
|
-
.on("get" /* GET */, function (callback) {
|
|
935
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
922
936
|
callback(null, _this.selectedAudioConfigurationString);
|
|
923
937
|
})
|
|
924
|
-
.on("set" /* SET */, this.handleSelectedAudioConfigurationWrite.bind(this))
|
|
938
|
+
.on("set" /* CharacteristicEventTypes.SET */, this.handleSelectedAudioConfigurationWrite.bind(this))
|
|
925
939
|
.updateValue(this.selectedAudioConfigurationString);
|
|
926
940
|
this.dataStreamManagement
|
|
927
|
-
.onEventMessage("targetControl" /* TARGET_CONTROL */, "whoami" /* WHOAMI */, this.handleTargetControlWhoAmI.bind(this))
|
|
928
|
-
.onServerEvent("connection-closed" /* CONNECTION_CLOSED */, this.handleDataStreamConnectionClosed.bind(this));
|
|
941
|
+
.onEventMessage("targetControl" /* Protocols.TARGET_CONTROL */, "whoami" /* Topics.WHOAMI */, this.handleTargetControlWhoAmI.bind(this))
|
|
942
|
+
.onServerEvent("connection-closed" /* DataStreamServerEvent.CONNECTION_CLOSED */, this.handleDataStreamConnectionClosed.bind(this));
|
|
929
943
|
this.eventHandler = (_a = {},
|
|
930
|
-
_a["ack" /* ACK */] = this.handleDataSendAckEvent.bind(this),
|
|
931
|
-
_a["close" /* CLOSE */] = this.handleDataSendCloseEvent.bind(this),
|
|
944
|
+
_a["ack" /* Topics.ACK */] = this.handleDataSendAckEvent.bind(this),
|
|
945
|
+
_a["close" /* Topics.CLOSE */] = this.handleDataSendCloseEvent.bind(this),
|
|
932
946
|
_a);
|
|
933
947
|
}
|
|
934
948
|
};
|
|
@@ -967,7 +981,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
967
981
|
}
|
|
968
982
|
return {
|
|
969
983
|
activeIdentifier: this.activeIdentifier,
|
|
970
|
-
targetConfigurations: tslib_1.__spreadArray([], tslib_1.__read(this.targetConfigurations)).reduce(function (obj, _a) {
|
|
984
|
+
targetConfigurations: tslib_1.__spreadArray([], tslib_1.__read(this.targetConfigurations), false).reduce(function (obj, _a) {
|
|
971
985
|
var _b = tslib_1.__read(_a, 2), key = _b[0], value = _b[1];
|
|
972
986
|
obj[key] = value;
|
|
973
987
|
return obj;
|
|
@@ -998,7 +1012,8 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
998
1012
|
exports.RemoteController = RemoteController;
|
|
999
1013
|
// noinspection JSUnusedGlobalSymbols
|
|
1000
1014
|
/**
|
|
1001
|
-
* @deprecated - only there for backwards compatibility, please use {@
|
|
1015
|
+
* @deprecated - only there for backwards compatibility, please use {@link RemoteController} directly
|
|
1016
|
+
* @group Apple TV Remote
|
|
1002
1017
|
*/
|
|
1003
1018
|
var HomeKitRemoteController = /** @class */ (function (_super) {
|
|
1004
1019
|
tslib_1.__extends(HomeKitRemoteController, _super);
|
|
@@ -1008,19 +1023,28 @@ var HomeKitRemoteController = /** @class */ (function (_super) {
|
|
|
1008
1023
|
return HomeKitRemoteController;
|
|
1009
1024
|
}(RemoteController)); // backwards compatibility
|
|
1010
1025
|
exports.HomeKitRemoteController = HomeKitRemoteController;
|
|
1026
|
+
/**
|
|
1027
|
+
* @group Apple TV Remote
|
|
1028
|
+
*/
|
|
1011
1029
|
var SiriAudioSessionEvents;
|
|
1012
1030
|
(function (SiriAudioSessionEvents) {
|
|
1013
1031
|
SiriAudioSessionEvents["CLOSE"] = "close";
|
|
1014
1032
|
})(SiriAudioSessionEvents = exports.SiriAudioSessionEvents || (exports.SiriAudioSessionEvents = {}));
|
|
1015
1033
|
/**
|
|
1016
1034
|
* Represents an ongoing audio transmission
|
|
1035
|
+
* @group Apple TV Remote
|
|
1017
1036
|
*/
|
|
1018
1037
|
var SiriAudioSession = /** @class */ (function (_super) {
|
|
1019
1038
|
tslib_1.__extends(SiriAudioSession, _super);
|
|
1020
|
-
function SiriAudioSession(connection, selectedAudioConfiguration, producerConstructor,
|
|
1039
|
+
function SiriAudioSession(connection, selectedAudioConfiguration, producerConstructor,
|
|
1040
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any
|
|
1041
|
+
producerOptions) {
|
|
1021
1042
|
var _this = _super.call(this) || this;
|
|
1022
1043
|
_this.producerRunning = false; // indicates if the producer is running
|
|
1023
|
-
|
|
1044
|
+
/**
|
|
1045
|
+
* @private file private API
|
|
1046
|
+
*/
|
|
1047
|
+
_this.state = 0 /* SiriAudioSessionState.STARTING */;
|
|
1024
1048
|
_this.endOfStream = false;
|
|
1025
1049
|
_this.audioFrameQueue = [];
|
|
1026
1050
|
_this.maxQueueSize = 1024;
|
|
@@ -1028,7 +1052,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1028
1052
|
_this.connection = connection;
|
|
1029
1053
|
_this.selectedAudioConfiguration = selectedAudioConfiguration;
|
|
1030
1054
|
_this.producer = new producerConstructor(_this.handleSiriAudioFrame.bind(_this), _this.handleProducerError.bind(_this), producerOptions);
|
|
1031
|
-
_this.connection.on("closed" /* CLOSED */, _this.closeListener = _this.handleDataStreamConnectionClosed.bind(_this));
|
|
1055
|
+
_this.connection.on("closed" /* DataStreamConnectionEvent.CLOSED */, _this.closeListener = _this.handleDataStreamConnectionClosed.bind(_this));
|
|
1032
1056
|
return _this;
|
|
1033
1057
|
}
|
|
1034
1058
|
/**
|
|
@@ -1038,16 +1062,16 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1038
1062
|
var _this = this;
|
|
1039
1063
|
debug("Sending request to start siri audio stream");
|
|
1040
1064
|
// opening dataSend
|
|
1041
|
-
this.connection.sendRequest("dataSend" /* DATA_SEND */, "open" /* OPEN */, {
|
|
1065
|
+
this.connection.sendRequest("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, {
|
|
1042
1066
|
target: "controller",
|
|
1043
|
-
type: "audio.siri"
|
|
1067
|
+
type: "audio.siri",
|
|
1044
1068
|
}, function (error, status, message) {
|
|
1045
|
-
if (_this.state === 3 /* CLOSED */) {
|
|
1069
|
+
if (_this.state === 3 /* SiriAudioSessionState.CLOSED */) {
|
|
1046
1070
|
debug("Ignoring dataSend open response as the session is already closed");
|
|
1047
1071
|
return;
|
|
1048
1072
|
}
|
|
1049
|
-
assert_1.default.strictEqual(_this.state, 0 /* STARTING */);
|
|
1050
|
-
_this.state = 1 /* SENDING */;
|
|
1073
|
+
assert_1.default.strictEqual(_this.state, 0 /* SiriAudioSessionState.STARTING */);
|
|
1074
|
+
_this.state = 1 /* SiriAudioSessionState.SENDING */;
|
|
1051
1075
|
if (error || status) {
|
|
1052
1076
|
if (error) { // errors get produced by hap-nodejs
|
|
1053
1077
|
debug("Error occurred trying to start siri audio stream: %s", error.message);
|
|
@@ -1058,9 +1082,9 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1058
1082
|
_this.closed();
|
|
1059
1083
|
}
|
|
1060
1084
|
else {
|
|
1061
|
-
_this.streamId = message
|
|
1085
|
+
_this.streamId = message.streamId;
|
|
1062
1086
|
if (!_this.producerRunning) { // audio producer errored in the meantime
|
|
1063
|
-
_this.sendDataSendCloseEvent(
|
|
1087
|
+
_this.sendDataSendCloseEvent(3 /* HDSProtocolSpecificErrorReason.CANCELLED */);
|
|
1064
1088
|
}
|
|
1065
1089
|
else {
|
|
1066
1090
|
debug("Successfully setup siri audio stream with streamId %d", _this.streamId);
|
|
@@ -1073,19 +1097,19 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1073
1097
|
* @returns if the audio session is closing
|
|
1074
1098
|
*/
|
|
1075
1099
|
SiriAudioSession.prototype.isClosing = function () {
|
|
1076
|
-
return this.state >= 2 /* CLOSING */;
|
|
1100
|
+
return this.state >= 2 /* SiriAudioSessionState.CLOSING */;
|
|
1077
1101
|
};
|
|
1078
1102
|
/**
|
|
1079
1103
|
* Called when siri button is released (or active identifier is changed to another device)
|
|
1080
1104
|
*/
|
|
1081
1105
|
SiriAudioSession.prototype.stop = function () {
|
|
1082
|
-
assert_1.default(this.state <= 1 /* SENDING */, "state was higher than SENDING");
|
|
1106
|
+
(0, assert_1.default)(this.state <= 1 /* SiriAudioSessionState.SENDING */, "state was higher than SENDING");
|
|
1083
1107
|
debug("Stopping siri audio stream with streamId %d", this.streamId);
|
|
1084
1108
|
this.endOfStream = true; // mark as endOfStream
|
|
1085
1109
|
this.stopAudioProducer();
|
|
1086
|
-
if (this.state === 1 /* SENDING */) {
|
|
1110
|
+
if (this.state === 1 /* SiriAudioSessionState.SENDING */) {
|
|
1087
1111
|
this.handleSiriAudioFrame(undefined); // send out last few audio frames with endOfStream property set
|
|
1088
|
-
this.state = 2 /* CLOSING */; // we are waiting for an acknowledgment (triggered by endOfStream property)
|
|
1112
|
+
this.state = 2 /* SiriAudioSessionState.CLOSING */; // we are waiting for an acknowledgment (triggered by endOfStream property)
|
|
1089
1113
|
}
|
|
1090
1114
|
else { // if state is not SENDING (aka state is STARTING) the callback for DATA_SEND OPEN did not yet return (or never will)
|
|
1091
1115
|
this.closed();
|
|
@@ -1098,7 +1122,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1098
1122
|
this.producerTimer = setTimeout(function () {
|
|
1099
1123
|
debug("Didn't receive any frames from audio producer for stream with streamId %s. Canceling the stream now.", _this.streamId);
|
|
1100
1124
|
_this.producerTimer = undefined;
|
|
1101
|
-
_this.handleProducerError(
|
|
1125
|
+
_this.handleProducerError(3 /* HDSProtocolSpecificErrorReason.CANCELLED */);
|
|
1102
1126
|
}, 3000);
|
|
1103
1127
|
this.producerTimer.unref();
|
|
1104
1128
|
};
|
|
@@ -1112,7 +1136,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1112
1136
|
};
|
|
1113
1137
|
SiriAudioSession.prototype.handleSiriAudioFrame = function (frame) {
|
|
1114
1138
|
var _this = this;
|
|
1115
|
-
if (this.state >= 2 /* CLOSING */) {
|
|
1139
|
+
if (this.state >= 2 /* SiriAudioSessionState.CLOSING */) {
|
|
1116
1140
|
return;
|
|
1117
1141
|
}
|
|
1118
1142
|
if (this.producerTimer) { // if producerTimer is defined, then this is the first frame we are receiving
|
|
@@ -1122,7 +1146,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1122
1146
|
if (frame && this.audioFrameQueue.length < this.maxQueueSize) { // add frame to queue whilst it is not full
|
|
1123
1147
|
this.audioFrameQueue.push(frame);
|
|
1124
1148
|
}
|
|
1125
|
-
if (this.state !== 1 /* SENDING */) { // dataSend isn't open yet
|
|
1149
|
+
if (this.state !== 1 /* SiriAudioSessionState.SENDING */) { // dataSend isn't open yet
|
|
1126
1150
|
return;
|
|
1127
1151
|
}
|
|
1128
1152
|
var queued;
|
|
@@ -1134,7 +1158,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1134
1158
|
metadata: {
|
|
1135
1159
|
rms: new datastream_1.Float32(frame.rms),
|
|
1136
1160
|
sequenceNumber: new datastream_1.Int64(_this.sequenceNumber++),
|
|
1137
|
-
}
|
|
1161
|
+
},
|
|
1138
1162
|
};
|
|
1139
1163
|
packets.push(packetData);
|
|
1140
1164
|
});
|
|
@@ -1144,7 +1168,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1144
1168
|
endOfStream: this_1.endOfStream,
|
|
1145
1169
|
};
|
|
1146
1170
|
try {
|
|
1147
|
-
this_1.connection.sendEvent("dataSend" /* DATA_SEND */, "data" /* DATA */, message);
|
|
1171
|
+
this_1.connection.sendEvent("dataSend" /* Protocols.DATA_SEND */, "data" /* Topics.DATA */, message);
|
|
1148
1172
|
}
|
|
1149
1173
|
catch (error) {
|
|
1150
1174
|
debug("Error occurred when trying to send audio frame of hds connection: %s", error.message);
|
|
@@ -1163,30 +1187,31 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1163
1187
|
}
|
|
1164
1188
|
};
|
|
1165
1189
|
SiriAudioSession.prototype.handleProducerError = function (error) {
|
|
1166
|
-
if (this.state >= 2 /* CLOSING */) {
|
|
1190
|
+
if (this.state >= 2 /* SiriAudioSessionState.CLOSING */) {
|
|
1167
1191
|
return;
|
|
1168
1192
|
}
|
|
1169
1193
|
this.stopAudioProducer(); // ensure backend is closed
|
|
1170
|
-
if (this.state === 1 /* SENDING */) { // if state is less than sending dataSend isn't open (yet)
|
|
1194
|
+
if (this.state === 1 /* SiriAudioSessionState.SENDING */) { // if state is less than sending dataSend isn't open (yet)
|
|
1171
1195
|
this.sendDataSendCloseEvent(error); // cancel submission
|
|
1172
1196
|
}
|
|
1173
1197
|
};
|
|
1174
1198
|
SiriAudioSession.prototype.handleDataSendAckEvent = function (endOfStream) {
|
|
1175
1199
|
assert_1.default.strictEqual(endOfStream, true);
|
|
1176
1200
|
debug("Received acknowledgment for siri audio stream with streamId %s, closing it now", this.streamId);
|
|
1177
|
-
this.sendDataSendCloseEvent(
|
|
1201
|
+
this.sendDataSendCloseEvent(0 /* HDSProtocolSpecificErrorReason.NORMAL */);
|
|
1178
1202
|
};
|
|
1179
1203
|
SiriAudioSession.prototype.handleDataSendCloseEvent = function (reason) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1204
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1205
|
+
debug("Received close event from controller with reason %s for stream with streamId %s", datastream_1.HDSProtocolSpecificErrorReason[reason], this.streamId);
|
|
1206
|
+
if (this.state <= 1 /* SiriAudioSessionState.SENDING */) {
|
|
1182
1207
|
this.stopAudioProducer();
|
|
1183
1208
|
}
|
|
1184
1209
|
this.closed();
|
|
1185
1210
|
};
|
|
1186
1211
|
SiriAudioSession.prototype.sendDataSendCloseEvent = function (reason) {
|
|
1187
|
-
assert_1.default(this.state >= 1 /* SENDING */, "state was less than SENDING");
|
|
1188
|
-
assert_1.default(this.state <= 2 /* CLOSING */, "state was higher than CLOSING");
|
|
1189
|
-
this.connection.sendEvent("dataSend" /* DATA_SEND */, "close" /* CLOSE */, {
|
|
1212
|
+
(0, assert_1.default)(this.state >= 1 /* SiriAudioSessionState.SENDING */, "state was less than SENDING");
|
|
1213
|
+
(0, assert_1.default)(this.state <= 2 /* SiriAudioSessionState.CLOSING */, "state was higher than CLOSING");
|
|
1214
|
+
this.connection.sendEvent("dataSend" /* Protocols.DATA_SEND */, "close" /* Topics.CLOSE */, {
|
|
1190
1215
|
streamId: new datastream_1.Int64(this.streamId),
|
|
1191
1216
|
reason: new datastream_1.Int64(reason),
|
|
1192
1217
|
});
|
|
@@ -1194,17 +1219,17 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1194
1219
|
};
|
|
1195
1220
|
SiriAudioSession.prototype.handleDataStreamConnectionClosed = function () {
|
|
1196
1221
|
debug("Closing audio session with streamId %d", this.streamId);
|
|
1197
|
-
if (this.state <= 1 /* SENDING */) {
|
|
1222
|
+
if (this.state <= 1 /* SiriAudioSessionState.SENDING */) {
|
|
1198
1223
|
this.stopAudioProducer();
|
|
1199
1224
|
}
|
|
1200
1225
|
this.closed();
|
|
1201
1226
|
};
|
|
1202
1227
|
SiriAudioSession.prototype.closed = function () {
|
|
1203
1228
|
var lastState = this.state;
|
|
1204
|
-
this.state = 3 /* CLOSED */;
|
|
1205
|
-
if (lastState !== 3 /* CLOSED */) {
|
|
1206
|
-
this.emit("close" /* CLOSE */);
|
|
1207
|
-
this.connection.removeListener("closed" /* CLOSED */, this.closeListener);
|
|
1229
|
+
this.state = 3 /* SiriAudioSessionState.CLOSED */;
|
|
1230
|
+
if (lastState !== 3 /* SiriAudioSessionState.CLOSED */) {
|
|
1231
|
+
this.emit("close" /* SiriAudioSessionEvents.CLOSE */);
|
|
1232
|
+
this.connection.removeListener("closed" /* DataStreamConnectionEvent.CLOSED */, this.closeListener);
|
|
1208
1233
|
}
|
|
1209
1234
|
this.removeAllListeners();
|
|
1210
1235
|
};
|