hap-nodejs 0.11.0-beta.9 → 0.11.0
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/README.md +1 -0
- package/dist/BridgedCore.js +4 -4
- package/dist/BridgedCore.js.map +1 -1
- package/dist/Core.js +2 -2
- package/dist/Core.js.map +1 -1
- package/dist/accessories/AirConditioner_accessory.js +18 -18
- package/dist/accessories/AirConditioner_accessory.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +6 -6
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +96 -87
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +6 -6
- package/dist/accessories/Fan_accessory.js.map +1 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +4 -4
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +2 -2
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +11 -11
- package/dist/accessories/Light_accessory.js.map +1 -1
- package/dist/accessories/Lock_accessory.js +4 -4
- package/dist/accessories/Lock_accessory.js.map +1 -1
- package/dist/accessories/MotionSensor_accessory.js +3 -3
- package/dist/accessories/MotionSensor_accessory.js.map +1 -1
- package/dist/accessories/Outlet_accessory.js +4 -4
- package/dist/accessories/Outlet_accessory.js.map +1 -1
- package/dist/accessories/SmartSpeaker_accessory.js +5 -5
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
- package/dist/accessories/Sprinkler_accessory.js +7 -7
- package/dist/accessories/Sprinkler_accessory.js.map +1 -1
- package/dist/accessories/TV_accessory.js +9 -9
- package/dist/accessories/TV_accessory.js.map +1 -1
- package/dist/accessories/TemperatureSensor_accessory.js +2 -2
- package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +2 -2
- package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +2 -2
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.d.ts +2 -2
- package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.js +20 -20
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
- package/dist/index.d.ts +30 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -25
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +65 -126
- 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 +97 -21
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +315 -327
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/AccessoryLoader.d.ts +12 -0
- package/dist/lib/AccessoryLoader.d.ts.map +1 -1
- package/dist/lib/AccessoryLoader.js +18 -6
- package/dist/lib/AccessoryLoader.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +32 -0
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +136 -58
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.d.ts +2 -0
- package/dist/lib/Bridge.d.ts.map +1 -1
- package/dist/lib/Bridge.js +3 -1
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +872 -40
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +172 -141
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +113 -20
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +226 -231
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +329 -13
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +45 -40
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/Camera.d.ts +13 -4
- package/dist/lib/camera/Camera.d.ts.map +1 -1
- package/dist/lib/camera/Camera.js +3 -0
- package/dist/lib/camera/Camera.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +5 -0
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +2 -1
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +156 -33
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +204 -164
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +61 -11
- package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +171 -138
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.js +4 -4
- package/dist/lib/camera/index.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +28 -2
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +77 -68
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +44 -13
- package/dist/lib/controller/CameraController.d.ts.map +1 -1
- package/dist/lib/controller/CameraController.js +43 -34
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/Controller.d.ts +28 -7
- 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 +5 -1
- package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
- package/dist/lib/controller/DoorbellController.js +5 -3
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +108 -39
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +190 -175
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.js +5 -5
- package/dist/lib/controller/index.js.map +1 -1
- 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 +36 -30
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +39 -0
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +125 -88
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +121 -46
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +134 -100
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.js +3 -3
- package/dist/lib/datastream/index.js.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +799 -799
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +77 -77
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +60 -59
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +15 -15
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/definitions/index.js +2 -2
- package/dist/lib/definitions/index.js.map +1 -1
- package/dist/lib/model/AccessoryInfo.d.ts +10 -4
- package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +21 -17
- 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 +8 -5
- 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 -1
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.d.ts +1 -0
- package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
- package/dist/lib/model/IdentifierCache.js +3 -2
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +11 -0
- package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +15 -7
- 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 +5 -4
- 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 +52 -9
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +141 -135
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +30 -2
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +28 -4
- 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 +4 -2
- 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 +5 -0
- package/dist/lib/util/once.d.ts.map +1 -1
- package/dist/lib/util/once.js +6 -1
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.d.ts +13 -0
- package/dist/lib/util/promise-utils.d.ts.map +1 -1
- package/dist/lib/util/promise-utils.js +27 -1
- package/dist/lib/util/promise-utils.js.map +1 -1
- 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 +42 -27
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +6 -0
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +8 -2
- 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 +90 -21
- 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 +1 -1
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +267 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -1
- package/package.json +10 -7
|
@@ -1,14 +1,14 @@
|
|
|
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
|
-
var assert_1 =
|
|
6
|
-
var debug_1 =
|
|
5
|
+
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
var debug_1 = tslib_1.__importDefault(require("debug"));
|
|
7
7
|
var events_1 = require("events");
|
|
8
8
|
var Characteristic_1 = require("../Characteristic");
|
|
9
9
|
var datastream_1 = require("../datastream");
|
|
10
10
|
var Service_1 = require("../Service");
|
|
11
|
-
var tlv =
|
|
11
|
+
var tlv = tslib_1.__importStar(require("../util/tlv"));
|
|
12
12
|
var debug = (0, debug_1.default)("HAP-NodeJS:Remote:Controller");
|
|
13
13
|
var TargetControlCommands;
|
|
14
14
|
(function (TargetControlCommands) {
|
|
@@ -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,17 +189,19 @@ 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
|
*/
|
|
@@ -215,11 +222,11 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
215
222
|
var audioConfiguration = _this.constructSupportedAudioConfiguration();
|
|
216
223
|
_this.supportedAudioConfiguration = RemoteController.buildSupportedAudioConfigurationTLV(audioConfiguration);
|
|
217
224
|
_this.selectedAudioConfiguration = {
|
|
218
|
-
codecType: 3 /* OPUS */,
|
|
225
|
+
codecType: 3 /* AudioCodecTypes.OPUS */,
|
|
219
226
|
parameters: {
|
|
220
227
|
channels: 1,
|
|
221
|
-
bitrate: 0 /* VARIABLE */,
|
|
222
|
-
samplerate: 1 /* KHZ_16 */,
|
|
228
|
+
bitrate: 0 /* AudioBitrate.VARIABLE */,
|
|
229
|
+
samplerate: 1 /* AudioSamplerate.KHZ_16 */,
|
|
223
230
|
rtpTime: 20,
|
|
224
231
|
},
|
|
225
232
|
};
|
|
@@ -232,12 +239,12 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
232
239
|
* @private
|
|
233
240
|
*/
|
|
234
241
|
RemoteController.prototype.controllerId = function () {
|
|
235
|
-
return "remote" /* REMOTE */;
|
|
242
|
+
return "remote" /* DefaultControllerType.REMOTE */;
|
|
236
243
|
};
|
|
237
244
|
/**
|
|
238
245
|
* Set a new target as active target. A value of 0 indicates that no target is selected currently.
|
|
239
246
|
*
|
|
240
|
-
* @param activeIdentifier
|
|
247
|
+
* @param activeIdentifier - target identifier
|
|
241
248
|
*/
|
|
242
249
|
RemoteController.prototype.setActiveIdentifier = function (activeIdentifier) {
|
|
243
250
|
var _this = this;
|
|
@@ -253,7 +260,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
253
260
|
if (this.activeAudioSession) {
|
|
254
261
|
this.handleSiriAudioStop();
|
|
255
262
|
}
|
|
256
|
-
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);
|
|
257
264
|
this.setInactive();
|
|
258
265
|
};
|
|
259
266
|
/**
|
|
@@ -265,7 +272,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
265
272
|
/**
|
|
266
273
|
* Checks if the supplied targetIdentifier is configured.
|
|
267
274
|
*
|
|
268
|
-
* @param targetIdentifier
|
|
275
|
+
* @param targetIdentifier - The target identifier.
|
|
269
276
|
*/
|
|
270
277
|
RemoteController.prototype.isConfigured = function (targetIdentifier) {
|
|
271
278
|
return this.targetConfigurations.has(targetIdentifier);
|
|
@@ -273,14 +280,14 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
273
280
|
/**
|
|
274
281
|
* Returns the targetIdentifier for a give device name
|
|
275
282
|
*
|
|
276
|
-
* @param name
|
|
277
|
-
* @returns
|
|
283
|
+
* @param name - The name of the device.
|
|
284
|
+
* @returns The targetIdentifier of the device or undefined if not existent.
|
|
278
285
|
*/
|
|
279
286
|
RemoteController.prototype.getTargetIdentifierByName = function (name) {
|
|
280
287
|
var e_1, _a;
|
|
281
288
|
try {
|
|
282
|
-
for (var _b =
|
|
283
|
-
var _d =
|
|
289
|
+
for (var _b = tslib_1.__values(Object.entries(this.targetConfigurations)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
290
|
+
var _d = tslib_1.__read(_c.value, 2), activeIdentifier = _d[0], configuration = _d[1];
|
|
284
291
|
if (configuration.targetName === name) {
|
|
285
292
|
return parseInt(activeIdentifier, 10);
|
|
286
293
|
}
|
|
@@ -298,24 +305,24 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
298
305
|
/**
|
|
299
306
|
* Sends a button event to press the supplied button.
|
|
300
307
|
*
|
|
301
|
-
* @param button
|
|
308
|
+
* @param button - button to be pressed
|
|
302
309
|
*/
|
|
303
310
|
RemoteController.prototype.pushButton = function (button) {
|
|
304
|
-
this.sendButtonEvent(button, 1 /* DOWN */);
|
|
311
|
+
this.sendButtonEvent(button, 1 /* ButtonState.DOWN */);
|
|
305
312
|
};
|
|
306
313
|
/**
|
|
307
314
|
* Sends a button event that the supplied button was released.
|
|
308
315
|
*
|
|
309
|
-
* @param button
|
|
316
|
+
* @param button - button which was released
|
|
310
317
|
*/
|
|
311
318
|
RemoteController.prototype.releaseButton = function (button) {
|
|
312
|
-
this.sendButtonEvent(button, 0 /* UP */);
|
|
319
|
+
this.sendButtonEvent(button, 0 /* ButtonState.UP */);
|
|
313
320
|
};
|
|
314
321
|
/**
|
|
315
322
|
* Presses a supplied button for a given time.
|
|
316
323
|
*
|
|
317
|
-
* @param button
|
|
318
|
-
* @param time
|
|
324
|
+
* @param button - button to be pressed and released
|
|
325
|
+
* @param time - time in milliseconds (defaults to 200ms)
|
|
319
326
|
*/
|
|
320
327
|
RemoteController.prototype.pushAndReleaseButton = function (button, time) {
|
|
321
328
|
var _this = this;
|
|
@@ -326,7 +333,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
326
333
|
/**
|
|
327
334
|
* This method adds and configures the remote services for a give accessory.
|
|
328
335
|
*
|
|
329
|
-
* @param accessory
|
|
336
|
+
* @param accessory - the give accessory this remote should be added to
|
|
330
337
|
* @deprecated - use {@link Accessory.configureController} instead
|
|
331
338
|
*/
|
|
332
339
|
RemoteController.prototype.addServicesToAccessory = function (accessory) {
|
|
@@ -343,12 +350,12 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
343
350
|
hardwareImplemented: this.audioSupported, // siri is only allowed for hardware implemented remotes
|
|
344
351
|
};
|
|
345
352
|
var supportedButtons = [
|
|
346
|
-
1 /* MENU */, 2 /* PLAY_PAUSE */, 3 /* TV_HOME */, 4 /* SELECT */,
|
|
347
|
-
5 /* ARROW_UP */, 6 /* ARROW_RIGHT */, 7 /* ARROW_DOWN */, 8 /* ARROW_LEFT */,
|
|
348
|
-
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 */,
|
|
349
356
|
];
|
|
350
357
|
if (this.audioSupported) { // add siri button if this remote supports it
|
|
351
|
-
supportedButtons.push(11 /* SIRI */);
|
|
358
|
+
supportedButtons.push(11 /* ButtonType.SIRI */);
|
|
352
359
|
}
|
|
353
360
|
supportedButtons.forEach(function (button) {
|
|
354
361
|
var buttonConfiguration = {
|
|
@@ -364,11 +371,11 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
364
371
|
// the following parameters are expected from HomeKit for a remote
|
|
365
372
|
return {
|
|
366
373
|
audioCodecConfiguration: {
|
|
367
|
-
codecType: 3 /* OPUS */,
|
|
374
|
+
codecType: 3 /* AudioCodecTypes.OPUS */,
|
|
368
375
|
parameters: {
|
|
369
376
|
channels: 1,
|
|
370
|
-
bitrate: 0 /* VARIABLE */,
|
|
371
|
-
samplerate: 1 /* KHZ_16 */,
|
|
377
|
+
bitrate: 0 /* AudioBitrate.VARIABLE */,
|
|
378
|
+
samplerate: 1 /* AudioSamplerate.KHZ_16 */,
|
|
372
379
|
},
|
|
373
380
|
},
|
|
374
381
|
};
|
|
@@ -378,10 +385,10 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
378
385
|
RemoteController.prototype.handleTargetControlWrite = function (value, callback) {
|
|
379
386
|
var data = Buffer.from(value, "base64");
|
|
380
387
|
var objects = tlv.decode(data);
|
|
381
|
-
var operation = objects[1 /* OPERATION */][0];
|
|
388
|
+
var operation = objects[1 /* TargetControlList.OPERATION */][0];
|
|
382
389
|
var targetConfiguration = undefined;
|
|
383
|
-
if (objects[2 /* TARGET_CONFIGURATION */]) { // if target configuration was sent, parse it
|
|
384
|
-
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 */]);
|
|
385
392
|
}
|
|
386
393
|
debug("Received TargetControl write operation %s", Operation[operation]);
|
|
387
394
|
var handler;
|
|
@@ -402,11 +409,11 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
402
409
|
handler = this.handleListTargets.bind(this);
|
|
403
410
|
break;
|
|
404
411
|
default:
|
|
405
|
-
callback(-70410 /* INVALID_VALUE_IN_REQUEST */, undefined);
|
|
412
|
+
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */, undefined);
|
|
406
413
|
return;
|
|
407
414
|
}
|
|
408
415
|
var status = handler(targetConfiguration);
|
|
409
|
-
if (status === 0 /* SUCCESS */) {
|
|
416
|
+
if (status === 0 /* HAPStatus.SUCCESS */) {
|
|
410
417
|
callback(undefined, this.targetConfigurationsString); // passing value for write response
|
|
411
418
|
if (operation === Operation.ADD && this.activeIdentifier === 0) {
|
|
412
419
|
this.setActiveIdentifier(targetConfiguration.targetIdentifier);
|
|
@@ -419,39 +426,39 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
419
426
|
RemoteController.prototype.handleAddTarget = function (targetConfiguration) {
|
|
420
427
|
var _this = this;
|
|
421
428
|
if (!targetConfiguration) {
|
|
422
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
429
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
423
430
|
}
|
|
424
431
|
this.targetConfigurations.set(targetConfiguration.targetIdentifier, targetConfiguration);
|
|
425
432
|
debug("Configured new target '" + targetConfiguration.targetName + "' with targetIdentifier '" + targetConfiguration.targetIdentifier + "'");
|
|
426
|
-
setTimeout(function () { return _this.emit("target-add" /* TARGET_ADDED */, targetConfiguration); }, 0);
|
|
433
|
+
setTimeout(function () { return _this.emit("target-add" /* RemoteControllerEvents.TARGET_ADDED */, targetConfiguration); }, 0);
|
|
427
434
|
this.updatedTargetConfiguration(); // set response
|
|
428
|
-
return 0 /* SUCCESS */;
|
|
435
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
429
436
|
};
|
|
430
437
|
RemoteController.prototype.handleUpdateTarget = function (targetConfiguration) {
|
|
431
438
|
var e_2, _a;
|
|
432
439
|
var _this = this;
|
|
433
440
|
if (!targetConfiguration) {
|
|
434
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
441
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
435
442
|
}
|
|
436
443
|
var updates = [];
|
|
437
444
|
var configuredTarget = this.targetConfigurations.get(targetConfiguration.targetIdentifier);
|
|
438
445
|
if (!configuredTarget) {
|
|
439
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
446
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
440
447
|
}
|
|
441
448
|
if (targetConfiguration.targetName) {
|
|
442
449
|
debug("Target name was updated '%s' => '%s' (%d)", configuredTarget.targetName, targetConfiguration.targetName, configuredTarget.targetIdentifier);
|
|
443
450
|
configuredTarget.targetName = targetConfiguration.targetName;
|
|
444
|
-
updates.push(0 /* NAME */);
|
|
451
|
+
updates.push(0 /* TargetUpdates.NAME */);
|
|
445
452
|
}
|
|
446
453
|
if (targetConfiguration.targetCategory) {
|
|
447
454
|
debug("Target category was updated '%d' => '%d' for target '%s' (%d)", configuredTarget.targetCategory, targetConfiguration.targetCategory, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
448
455
|
configuredTarget.targetCategory = targetConfiguration.targetCategory;
|
|
449
|
-
updates.push(1 /* CATEGORY */);
|
|
456
|
+
updates.push(1 /* TargetUpdates.CATEGORY */);
|
|
450
457
|
}
|
|
451
458
|
if (targetConfiguration.buttonConfiguration) {
|
|
452
459
|
debug("%d button configurations were updated for target '%s' (%d)", Object.keys(targetConfiguration.buttonConfiguration).length, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
453
460
|
try {
|
|
454
|
-
for (var _b =
|
|
461
|
+
for (var _b = tslib_1.__values(Object.values(targetConfiguration.buttonConfiguration)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
455
462
|
var configuration = _c.value;
|
|
456
463
|
var savedConfiguration = configuredTarget.buttonConfiguration[configuration.buttonID];
|
|
457
464
|
savedConfiguration.buttonType = configuration.buttonType;
|
|
@@ -465,20 +472,20 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
465
472
|
}
|
|
466
473
|
finally { if (e_2) throw e_2.error; }
|
|
467
474
|
}
|
|
468
|
-
updates.push(2 /* UPDATED_BUTTONS */);
|
|
475
|
+
updates.push(2 /* TargetUpdates.UPDATED_BUTTONS */);
|
|
469
476
|
}
|
|
470
|
-
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);
|
|
471
478
|
this.updatedTargetConfiguration(); // set response
|
|
472
|
-
return 0 /* SUCCESS */;
|
|
479
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
473
480
|
};
|
|
474
481
|
RemoteController.prototype.handleRemoveTarget = function (targetConfiguration) {
|
|
475
482
|
var _this = this;
|
|
476
483
|
if (!targetConfiguration) {
|
|
477
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
484
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
478
485
|
}
|
|
479
486
|
var configuredTarget = this.targetConfigurations.get(targetConfiguration.targetIdentifier);
|
|
480
487
|
if (!configuredTarget) {
|
|
481
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
488
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
482
489
|
}
|
|
483
490
|
if (targetConfiguration.buttonConfiguration) {
|
|
484
491
|
for (var key in targetConfiguration.buttonConfiguration) {
|
|
@@ -487,74 +494,74 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
487
494
|
}
|
|
488
495
|
}
|
|
489
496
|
debug("Removed %d button configurations of target '%s' (%d)", Object.keys(targetConfiguration.buttonConfiguration).length, configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
490
|
-
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);
|
|
491
498
|
}
|
|
492
499
|
else {
|
|
493
500
|
this.targetConfigurations.delete(targetConfiguration.targetIdentifier);
|
|
494
501
|
debug("Target '%s' (%d) was removed", configuredTarget.targetName, configuredTarget.targetIdentifier);
|
|
495
|
-
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);
|
|
496
503
|
var keys = Object.keys(this.targetConfigurations);
|
|
497
504
|
this.setActiveIdentifier(keys.length === 0 ? 0 : parseInt(keys[0], 10)); // switch to next available remote
|
|
498
505
|
}
|
|
499
506
|
this.updatedTargetConfiguration(); // set response
|
|
500
|
-
return 0 /* SUCCESS */;
|
|
507
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
501
508
|
};
|
|
502
509
|
RemoteController.prototype.handleResetTargets = function (targetConfiguration) {
|
|
503
510
|
var _this = this;
|
|
504
511
|
if (targetConfiguration) {
|
|
505
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
512
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
506
513
|
}
|
|
507
514
|
debug("Resetting all target configurations");
|
|
508
515
|
this.targetConfigurations = new Map();
|
|
509
516
|
this.updatedTargetConfiguration(); // set response
|
|
510
|
-
setTimeout(function () { return _this.emit("targets-reset" /* TARGETS_RESET */); }, 0);
|
|
517
|
+
setTimeout(function () { return _this.emit("targets-reset" /* RemoteControllerEvents.TARGETS_RESET */); }, 0);
|
|
511
518
|
this.setActiveIdentifier(0); // resetting active identifier (also sets active to false)
|
|
512
|
-
return 0 /* SUCCESS */;
|
|
519
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
513
520
|
};
|
|
514
521
|
RemoteController.prototype.handleListTargets = function (targetConfiguration) {
|
|
515
522
|
if (targetConfiguration) {
|
|
516
|
-
return -70410 /* INVALID_VALUE_IN_REQUEST */;
|
|
523
|
+
return -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */;
|
|
517
524
|
}
|
|
518
525
|
// this.targetConfigurationsString is updated after each change, so we basically don't need to do anything here
|
|
519
526
|
debug("Returning " + Object.keys(this.targetConfigurations).length + " target configurations");
|
|
520
|
-
return 0 /* SUCCESS */;
|
|
527
|
+
return 0 /* HAPStatus.SUCCESS */;
|
|
521
528
|
};
|
|
522
529
|
RemoteController.prototype.handleActiveWrite = function (value, callback, connection) {
|
|
523
530
|
if (this.activeIdentifier === 0) {
|
|
524
531
|
debug("Tried to change active state. There is no active target set though");
|
|
525
|
-
callback(-70410 /* INVALID_VALUE_IN_REQUEST */);
|
|
532
|
+
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
526
533
|
return;
|
|
527
534
|
}
|
|
528
535
|
if (this.activeConnection) {
|
|
529
|
-
this.activeConnection.removeListener("closed" /* CLOSED */, this.activeConnectionDisconnectListener);
|
|
536
|
+
this.activeConnection.removeListener("closed" /* HAPConnectionEvent.CLOSED */, this.activeConnectionDisconnectListener);
|
|
530
537
|
this.activeConnection = undefined;
|
|
531
538
|
this.activeConnectionDisconnectListener = undefined;
|
|
532
539
|
}
|
|
533
540
|
this.activeConnection = value ? connection : undefined;
|
|
534
541
|
if (this.activeConnection) { // register listener when hap connection disconnects
|
|
535
542
|
this.activeConnectionDisconnectListener = this.handleActiveSessionDisconnected.bind(this, this.activeConnection);
|
|
536
|
-
this.activeConnection.on("closed" /* CLOSED */, this.activeConnectionDisconnectListener);
|
|
543
|
+
this.activeConnection.on("closed" /* HAPConnectionEvent.CLOSED */, this.activeConnectionDisconnectListener);
|
|
537
544
|
}
|
|
538
545
|
var activeTarget = this.targetConfigurations.get(this.activeIdentifier);
|
|
539
546
|
if (!activeTarget) {
|
|
540
|
-
callback(-70410 /* INVALID_VALUE_IN_REQUEST */);
|
|
547
|
+
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
541
548
|
return;
|
|
542
549
|
}
|
|
543
550
|
debug("Remote with activeTarget '%s' (%d) was set to %s", activeTarget.targetName, this.activeIdentifier, value ? "ACTIVE" : "INACTIVE");
|
|
544
551
|
callback();
|
|
545
|
-
this.emit("active-change" /* ACTIVE_CHANGE */, value);
|
|
552
|
+
this.emit("active-change" /* RemoteControllerEvents.ACTIVE_CHANGE */, value);
|
|
546
553
|
};
|
|
547
554
|
RemoteController.prototype.setInactive = function () {
|
|
548
555
|
var _this = this;
|
|
549
556
|
if (this.activeConnection === undefined) {
|
|
550
557
|
return;
|
|
551
558
|
}
|
|
552
|
-
this.activeConnection.removeListener("closed" /* CLOSED */, this.activeConnectionDisconnectListener);
|
|
559
|
+
this.activeConnection.removeListener("closed" /* HAPConnectionEvent.CLOSED */, this.activeConnectionDisconnectListener);
|
|
553
560
|
this.activeConnection = undefined;
|
|
554
561
|
this.activeConnectionDisconnectListener = undefined;
|
|
555
562
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.Active).updateValue(false);
|
|
556
563
|
debug("Remote was set to INACTIVE");
|
|
557
|
-
setTimeout(function () { return _this.emit("active-change" /* ACTIVE_CHANGE */, false); }, 0);
|
|
564
|
+
setTimeout(function () { return _this.emit("active-change" /* RemoteControllerEvents.ACTIVE_CHANGE */, false); }, 0);
|
|
558
565
|
};
|
|
559
566
|
RemoteController.prototype.handleActiveSessionDisconnected = function (connection) {
|
|
560
567
|
if (connection !== this.activeConnection) {
|
|
@@ -571,22 +578,22 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
571
578
|
if (this.activeIdentifier === 0) { // cannot press button if no device is selected
|
|
572
579
|
throw new Error("Tried sending button event although no target was selected");
|
|
573
580
|
}
|
|
574
|
-
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)
|
|
575
582
|
throw new Error("Tried sending button event although target was not marked as active");
|
|
576
583
|
}
|
|
577
|
-
if (button === 11 /* SIRI */ && this.audioSupported) {
|
|
578
|
-
if (buttonState === 1 /* DOWN */) { // start streaming session
|
|
584
|
+
if (button === 11 /* ButtonType.SIRI */ && this.audioSupported) {
|
|
585
|
+
if (buttonState === 1 /* ButtonState.DOWN */) { // start streaming session
|
|
579
586
|
this.handleSiriAudioStart();
|
|
580
587
|
}
|
|
581
|
-
else if (buttonState === 0 /* UP */) { // stop streaming session
|
|
588
|
+
else if (buttonState === 0 /* ButtonState.UP */) { // stop streaming session
|
|
582
589
|
this.handleSiriAudioStop();
|
|
583
590
|
}
|
|
584
591
|
return;
|
|
585
592
|
}
|
|
586
|
-
var buttonIdTlv = tlv.encode(1 /* BUTTON_ID */, buttonID);
|
|
587
|
-
var buttonStateTlv = tlv.encode(2 /* BUTTON_STATE */, buttonState);
|
|
588
|
-
var timestampTlv = tlv.encode(3 /* TIMESTAMP */, tlv.
|
|
589
|
-
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));
|
|
590
597
|
this.lastButtonEvent = Buffer.concat([
|
|
591
598
|
buttonIdTlv, buttonStateTlv, timestampTlv, activeIdentifierTlv,
|
|
592
599
|
]).toString("base64");
|
|
@@ -594,24 +601,24 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
594
601
|
};
|
|
595
602
|
RemoteController.prototype.parseTargetConfigurationTLV = function (data) {
|
|
596
603
|
var configTLV = tlv.decode(data);
|
|
597
|
-
var identifier = tlv.readUInt32(configTLV[1 /* TARGET_IDENTIFIER */]);
|
|
604
|
+
var identifier = tlv.readUInt32(configTLV[1 /* TargetConfigurationTypes.TARGET_IDENTIFIER */]);
|
|
598
605
|
var name = undefined;
|
|
599
|
-
if (configTLV[2 /* TARGET_NAME */]) {
|
|
600
|
-
name = configTLV[2 /* TARGET_NAME */].toString();
|
|
606
|
+
if (configTLV[2 /* TargetConfigurationTypes.TARGET_NAME */]) {
|
|
607
|
+
name = configTLV[2 /* TargetConfigurationTypes.TARGET_NAME */].toString();
|
|
601
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 */]);
|
|
605
612
|
}
|
|
606
613
|
var buttonConfiguration = {};
|
|
607
|
-
if (configTLV[4 /* BUTTON_CONFIGURATION */]) {
|
|
608
|
-
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 */);
|
|
609
616
|
buttonConfigurationTLV.forEach(function (entry) {
|
|
610
|
-
var buttonId = entry[1 /* BUTTON_ID */][0];
|
|
611
|
-
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 */]);
|
|
612
619
|
var buttonName;
|
|
613
|
-
if (entry[3 /* BUTTON_NAME */]) {
|
|
614
|
-
buttonName = entry[3 /* BUTTON_NAME */].toString();
|
|
620
|
+
if (entry[3 /* ButtonConfigurationTypes.BUTTON_NAME */]) {
|
|
621
|
+
buttonName = entry[3 /* ButtonConfigurationTypes.BUTTON_NAME */].toString();
|
|
615
622
|
}
|
|
616
623
|
else {
|
|
617
624
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
@@ -636,20 +643,20 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
636
643
|
var _c;
|
|
637
644
|
var bufferList = [];
|
|
638
645
|
try {
|
|
639
|
-
for (var _d =
|
|
646
|
+
for (var _d = tslib_1.__values(Object.values(this.targetConfigurations)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
640
647
|
var configuration = _e.value;
|
|
641
|
-
var targetIdentifier = tlv.encode(1 /* TARGET_IDENTIFIER */, tlv.writeUInt32(configuration.targetIdentifier));
|
|
642
|
-
var targetName = tlv.encode(2 /* TARGET_NAME */, configuration.targetName);
|
|
643
|
-
var targetCategory = tlv.encode(3 /* TARGET_CATEGORY */, tlv.writeUInt16(configuration.targetCategory));
|
|
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));
|
|
644
651
|
var buttonConfigurationBuffers = [];
|
|
645
652
|
try {
|
|
646
|
-
for (var _f = (e_4 = void 0,
|
|
653
|
+
for (var _f = (e_4 = void 0, tslib_1.__values(configuration.buttonConfiguration.values())), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
647
654
|
var value = _g.value;
|
|
648
|
-
var tlvBuffer = tlv.encode(1 /* BUTTON_ID */, value.buttonID, 2 /* BUTTON_TYPE */, tlv.writeUInt16(value.buttonType));
|
|
655
|
+
var tlvBuffer = tlv.encode(1 /* ButtonConfigurationTypes.BUTTON_ID */, value.buttonID, 2 /* ButtonConfigurationTypes.BUTTON_TYPE */, tlv.writeUInt16(value.buttonType));
|
|
649
656
|
if (value.buttonName) {
|
|
650
657
|
tlvBuffer = Buffer.concat([
|
|
651
658
|
tlvBuffer,
|
|
652
|
-
tlv.encode(3 /* BUTTON_NAME */, value.buttonName),
|
|
659
|
+
tlv.encode(3 /* ButtonConfigurationTypes.BUTTON_NAME */, value.buttonName),
|
|
653
660
|
]);
|
|
654
661
|
}
|
|
655
662
|
buttonConfigurationBuffers.push(tlvBuffer);
|
|
@@ -662,9 +669,9 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
662
669
|
}
|
|
663
670
|
finally { if (e_4) throw e_4.error; }
|
|
664
671
|
}
|
|
665
|
-
var buttonConfiguration = tlv.encode(4 /* BUTTON_CONFIGURATION */, Buffer.concat(buttonConfigurationBuffers));
|
|
672
|
+
var buttonConfiguration = tlv.encode(4 /* TargetConfigurationTypes.BUTTON_CONFIGURATION */, Buffer.concat(buttonConfigurationBuffers));
|
|
666
673
|
var targetConfiguration = Buffer.concat([targetIdentifier, targetName, targetCategory, buttonConfiguration]);
|
|
667
|
-
bufferList.push(tlv.encode(2 /* TARGET_CONFIGURATION */, targetConfiguration));
|
|
674
|
+
bufferList.push(tlv.encode(2 /* TargetControlList.TARGET_CONFIGURATION */, targetConfiguration));
|
|
668
675
|
}
|
|
669
676
|
}
|
|
670
677
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -678,15 +685,15 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
678
685
|
(_c = this.stateChangeDelegate) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
679
686
|
};
|
|
680
687
|
RemoteController.prototype.buildTargetControlSupportedConfigurationTLV = function (configuration) {
|
|
681
|
-
var maximumTargets = tlv.encode(1 /* MAXIMUM_TARGETS */, configuration.maximumTargets);
|
|
682
|
-
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));
|
|
683
690
|
var supportedButtonConfigurationBuffers = [];
|
|
684
691
|
configuration.supportedButtonConfiguration.forEach(function (value) {
|
|
685
|
-
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));
|
|
686
693
|
supportedButtonConfigurationBuffers.push(tlvBuffer);
|
|
687
694
|
});
|
|
688
|
-
var supportedButtonConfiguration = tlv.encode(3 /* SUPPORTED_BUTTON_CONFIGURATION */, Buffer.concat(supportedButtonConfigurationBuffers));
|
|
689
|
-
var type = tlv.encode(4 /* TYPE */, configuration.hardwareImplemented ? 1 : 0);
|
|
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);
|
|
690
697
|
return Buffer.concat([maximumTargets, ticksPerSecond, supportedButtonConfiguration, type]).toString("base64");
|
|
691
698
|
};
|
|
692
699
|
// --------------------------------- SIRI/DATA STREAM --------------------------------
|
|
@@ -695,7 +702,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
695
702
|
var targetIdentifier = message.identifier;
|
|
696
703
|
this.dataStreamConnections.set(targetIdentifier, connection);
|
|
697
704
|
debug("Discovered HDS connection for targetIdentifier %s", targetIdentifier);
|
|
698
|
-
connection.addProtocolHandler("dataSend" /* DATA_SEND */, this);
|
|
705
|
+
connection.addProtocolHandler("dataSend" /* Protocols.DATA_SEND */, this);
|
|
699
706
|
};
|
|
700
707
|
RemoteController.prototype.handleSiriAudioStart = function () {
|
|
701
708
|
if (!this.audioSupported) {
|
|
@@ -726,7 +733,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
726
733
|
// so no collision with the input device can happen
|
|
727
734
|
this.nextAudioSession = audioSession;
|
|
728
735
|
}
|
|
729
|
-
audioSession.on("close" /* CLOSE */, this.handleSiriAudioSessionClosed.bind(this, audioSession));
|
|
736
|
+
audioSession.on("close" /* SiriAudioSessionEvents.CLOSE */, this.handleSiriAudioSessionClosed.bind(this, audioSession));
|
|
730
737
|
audioSession.start();
|
|
731
738
|
};
|
|
732
739
|
RemoteController.prototype.handleSiriAudioStop = function () {
|
|
@@ -782,8 +789,8 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
782
789
|
RemoteController.prototype.handleDataStreamConnectionClosed = function (connection) {
|
|
783
790
|
var e_5, _a;
|
|
784
791
|
try {
|
|
785
|
-
for (var _b =
|
|
786
|
-
var _d =
|
|
792
|
+
for (var _b = tslib_1.__values(this.dataStreamConnections), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
793
|
+
var _d = tslib_1.__read(_c.value, 2), targetIdentifier = _d[0], connection0 = _d[1];
|
|
787
794
|
if (connection === connection0) {
|
|
788
795
|
debug("HDS connection disconnected for targetIdentifier %s", targetIdentifier);
|
|
789
796
|
this.dataStreamConnections.delete(targetIdentifier);
|
|
@@ -804,12 +811,12 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
804
811
|
RemoteController.prototype.handleSelectedAudioConfigurationWrite = function (value, callback) {
|
|
805
812
|
var data = Buffer.from(value, "base64");
|
|
806
813
|
var objects = tlv.decode(data);
|
|
807
|
-
var selectedAudioStreamConfiguration = tlv.decode(objects[1 /* SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */]);
|
|
808
|
-
var codec = selectedAudioStreamConfiguration[1 /* CODEC_TYPE */][0];
|
|
809
|
-
var parameters = tlv.decode(selectedAudioStreamConfiguration[2 /* CODEC_PARAMETERS */]);
|
|
810
|
-
var channels = parameters[1 /* CHANNEL */][0];
|
|
811
|
-
var bitrate = parameters[2 /* BIT_RATE */][0];
|
|
812
|
-
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];
|
|
813
820
|
this.selectedAudioConfiguration = {
|
|
814
821
|
codecType: codec,
|
|
815
822
|
parameters: {
|
|
@@ -826,24 +833,24 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
826
833
|
};
|
|
827
834
|
RemoteController.buildSupportedAudioConfigurationTLV = function (configuration) {
|
|
828
835
|
var codecConfigurationTLV = RemoteController.buildCodecConfigurationTLV(configuration.audioCodecConfiguration);
|
|
829
|
-
var supportedAudioStreamConfiguration = tlv.encode(1 /* AUDIO_CODEC_CONFIGURATION */, codecConfigurationTLV);
|
|
836
|
+
var supportedAudioStreamConfiguration = tlv.encode(1 /* SupportedAudioStreamConfigurationTypes.AUDIO_CODEC_CONFIGURATION */, codecConfigurationTLV);
|
|
830
837
|
return supportedAudioStreamConfiguration.toString("base64");
|
|
831
838
|
};
|
|
832
839
|
RemoteController.buildSelectedAudioConfigurationTLV = function (configuration) {
|
|
833
840
|
var codecConfigurationTLV = RemoteController.buildCodecConfigurationTLV(configuration.audioCodecConfiguration);
|
|
834
|
-
var supportedAudioStreamConfiguration = tlv.encode(1 /* SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */, codecConfigurationTLV);
|
|
841
|
+
var supportedAudioStreamConfiguration = tlv.encode(1 /* SelectedAudioInputStreamConfigurationTypes.SELECTED_AUDIO_INPUT_STREAM_CONFIGURATION */, codecConfigurationTLV);
|
|
835
842
|
return supportedAudioStreamConfiguration.toString("base64");
|
|
836
843
|
};
|
|
837
844
|
RemoteController.buildCodecConfigurationTLV = function (codecConfiguration) {
|
|
838
845
|
var parameters = codecConfiguration.parameters;
|
|
839
|
-
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);
|
|
840
847
|
if (parameters.rtpTime) {
|
|
841
848
|
parametersTLV = Buffer.concat([
|
|
842
849
|
parametersTLV,
|
|
843
|
-
tlv.encode(4 /* PACKET_TIME */, parameters.rtpTime),
|
|
850
|
+
tlv.encode(4 /* AudioCodecParametersTypes.PACKET_TIME */, parameters.rtpTime),
|
|
844
851
|
]);
|
|
845
852
|
}
|
|
846
|
-
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);
|
|
847
854
|
};
|
|
848
855
|
// -----------------------------------------------------------------------------------
|
|
849
856
|
/**
|
|
@@ -899,43 +906,43 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
899
906
|
throw new Error("Unexpected state: Services not configured!"); // playing it save
|
|
900
907
|
}
|
|
901
908
|
this.targetControlManagementService.getCharacteristic(Characteristic_1.Characteristic.TargetControlList)
|
|
902
|
-
.on("get" /* GET */, function (callback) {
|
|
909
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
903
910
|
callback(null, _this.targetConfigurationsString);
|
|
904
911
|
})
|
|
905
|
-
.on("set" /* SET */, this.handleTargetControlWrite.bind(this));
|
|
912
|
+
.on("set" /* CharacteristicEventTypes.SET */, this.handleTargetControlWrite.bind(this));
|
|
906
913
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ActiveIdentifier)
|
|
907
|
-
.on("get" /* GET */, function (callback) {
|
|
914
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
908
915
|
callback(undefined, _this.activeIdentifier);
|
|
909
916
|
});
|
|
910
917
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.Active)
|
|
911
|
-
.on("get" /* GET */, function (callback) {
|
|
918
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
912
919
|
callback(undefined, _this.isActive());
|
|
913
920
|
})
|
|
914
|
-
.on("set" /* SET */, function (value, callback, context, connection) {
|
|
921
|
+
.on("set" /* CharacteristicEventTypes.SET */, function (value, callback, context, connection) {
|
|
915
922
|
if (!connection) {
|
|
916
923
|
debug("Set event handler for Remote.Active cannot be called from plugin. Connection undefined!");
|
|
917
|
-
callback(-70410 /* INVALID_VALUE_IN_REQUEST */);
|
|
924
|
+
callback(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
918
925
|
return;
|
|
919
926
|
}
|
|
920
927
|
_this.handleActiveWrite(value, callback, connection);
|
|
921
928
|
});
|
|
922
929
|
this.targetControlService.getCharacteristic(Characteristic_1.Characteristic.ButtonEvent)
|
|
923
|
-
.on("get" /* GET */, function (callback) {
|
|
930
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
924
931
|
callback(undefined, _this.lastButtonEvent);
|
|
925
932
|
});
|
|
926
933
|
if (this.audioSupported) {
|
|
927
934
|
this.audioStreamManagementService.getCharacteristic(Characteristic_1.Characteristic.SelectedAudioStreamConfiguration)
|
|
928
|
-
.on("get" /* GET */, function (callback) {
|
|
935
|
+
.on("get" /* CharacteristicEventTypes.GET */, function (callback) {
|
|
929
936
|
callback(null, _this.selectedAudioConfigurationString);
|
|
930
937
|
})
|
|
931
|
-
.on("set" /* SET */, this.handleSelectedAudioConfigurationWrite.bind(this))
|
|
938
|
+
.on("set" /* CharacteristicEventTypes.SET */, this.handleSelectedAudioConfigurationWrite.bind(this))
|
|
932
939
|
.updateValue(this.selectedAudioConfigurationString);
|
|
933
940
|
this.dataStreamManagement
|
|
934
|
-
.onEventMessage("targetControl" /* TARGET_CONTROL */, "whoami" /* WHOAMI */, this.handleTargetControlWhoAmI.bind(this))
|
|
935
|
-
.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));
|
|
936
943
|
this.eventHandler = (_a = {},
|
|
937
|
-
_a["ack" /* ACK */] = this.handleDataSendAckEvent.bind(this),
|
|
938
|
-
_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),
|
|
939
946
|
_a);
|
|
940
947
|
}
|
|
941
948
|
};
|
|
@@ -974,8 +981,8 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
974
981
|
}
|
|
975
982
|
return {
|
|
976
983
|
activeIdentifier: this.activeIdentifier,
|
|
977
|
-
targetConfigurations:
|
|
978
|
-
var _b =
|
|
984
|
+
targetConfigurations: tslib_1.__spreadArray([], tslib_1.__read(this.targetConfigurations), false).reduce(function (obj, _a) {
|
|
985
|
+
var _b = tslib_1.__read(_a, 2), key = _b[0], value = _b[1];
|
|
979
986
|
obj[key] = value;
|
|
980
987
|
return obj;
|
|
981
988
|
}, {}),
|
|
@@ -987,7 +994,7 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
987
994
|
RemoteController.prototype.deserialize = function (serialized) {
|
|
988
995
|
this.activeIdentifier = serialized.activeIdentifier;
|
|
989
996
|
this.targetConfigurations = Object.entries(serialized.targetConfigurations).reduce(function (map, _a) {
|
|
990
|
-
var _b =
|
|
997
|
+
var _b = tslib_1.__read(_a, 2), key = _b[0], value = _b[1];
|
|
991
998
|
var identifier = parseInt(key, 10);
|
|
992
999
|
map.set(identifier, value);
|
|
993
1000
|
return map;
|
|
@@ -1005,31 +1012,39 @@ var RemoteController = /** @class */ (function (_super) {
|
|
|
1005
1012
|
exports.RemoteController = RemoteController;
|
|
1006
1013
|
// noinspection JSUnusedGlobalSymbols
|
|
1007
1014
|
/**
|
|
1008
|
-
* @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
|
|
1009
1017
|
*/
|
|
1010
1018
|
var HomeKitRemoteController = /** @class */ (function (_super) {
|
|
1011
|
-
|
|
1019
|
+
tslib_1.__extends(HomeKitRemoteController, _super);
|
|
1012
1020
|
function HomeKitRemoteController() {
|
|
1013
1021
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1014
1022
|
}
|
|
1015
1023
|
return HomeKitRemoteController;
|
|
1016
1024
|
}(RemoteController)); // backwards compatibility
|
|
1017
1025
|
exports.HomeKitRemoteController = HomeKitRemoteController;
|
|
1026
|
+
/**
|
|
1027
|
+
* @group Apple TV Remote
|
|
1028
|
+
*/
|
|
1018
1029
|
var SiriAudioSessionEvents;
|
|
1019
1030
|
(function (SiriAudioSessionEvents) {
|
|
1020
1031
|
SiriAudioSessionEvents["CLOSE"] = "close";
|
|
1021
1032
|
})(SiriAudioSessionEvents = exports.SiriAudioSessionEvents || (exports.SiriAudioSessionEvents = {}));
|
|
1022
1033
|
/**
|
|
1023
1034
|
* Represents an ongoing audio transmission
|
|
1035
|
+
* @group Apple TV Remote
|
|
1024
1036
|
*/
|
|
1025
1037
|
var SiriAudioSession = /** @class */ (function (_super) {
|
|
1026
|
-
|
|
1038
|
+
tslib_1.__extends(SiriAudioSession, _super);
|
|
1027
1039
|
function SiriAudioSession(connection, selectedAudioConfiguration, producerConstructor,
|
|
1028
1040
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any
|
|
1029
1041
|
producerOptions) {
|
|
1030
1042
|
var _this = _super.call(this) || this;
|
|
1031
1043
|
_this.producerRunning = false; // indicates if the producer is running
|
|
1032
|
-
|
|
1044
|
+
/**
|
|
1045
|
+
* @private file private API
|
|
1046
|
+
*/
|
|
1047
|
+
_this.state = 0 /* SiriAudioSessionState.STARTING */;
|
|
1033
1048
|
_this.endOfStream = false;
|
|
1034
1049
|
_this.audioFrameQueue = [];
|
|
1035
1050
|
_this.maxQueueSize = 1024;
|
|
@@ -1037,7 +1052,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1037
1052
|
_this.connection = connection;
|
|
1038
1053
|
_this.selectedAudioConfiguration = selectedAudioConfiguration;
|
|
1039
1054
|
_this.producer = new producerConstructor(_this.handleSiriAudioFrame.bind(_this), _this.handleProducerError.bind(_this), producerOptions);
|
|
1040
|
-
_this.connection.on("closed" /* CLOSED */, _this.closeListener = _this.handleDataStreamConnectionClosed.bind(_this));
|
|
1055
|
+
_this.connection.on("closed" /* DataStreamConnectionEvent.CLOSED */, _this.closeListener = _this.handleDataStreamConnectionClosed.bind(_this));
|
|
1041
1056
|
return _this;
|
|
1042
1057
|
}
|
|
1043
1058
|
/**
|
|
@@ -1047,16 +1062,16 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1047
1062
|
var _this = this;
|
|
1048
1063
|
debug("Sending request to start siri audio stream");
|
|
1049
1064
|
// opening dataSend
|
|
1050
|
-
this.connection.sendRequest("dataSend" /* DATA_SEND */, "open" /* OPEN */, {
|
|
1065
|
+
this.connection.sendRequest("dataSend" /* Protocols.DATA_SEND */, "open" /* Topics.OPEN */, {
|
|
1051
1066
|
target: "controller",
|
|
1052
1067
|
type: "audio.siri",
|
|
1053
1068
|
}, function (error, status, message) {
|
|
1054
|
-
if (_this.state === 3 /* CLOSED */) {
|
|
1069
|
+
if (_this.state === 3 /* SiriAudioSessionState.CLOSED */) {
|
|
1055
1070
|
debug("Ignoring dataSend open response as the session is already closed");
|
|
1056
1071
|
return;
|
|
1057
1072
|
}
|
|
1058
|
-
assert_1.default.strictEqual(_this.state, 0 /* STARTING */);
|
|
1059
|
-
_this.state = 1 /* SENDING */;
|
|
1073
|
+
assert_1.default.strictEqual(_this.state, 0 /* SiriAudioSessionState.STARTING */);
|
|
1074
|
+
_this.state = 1 /* SiriAudioSessionState.SENDING */;
|
|
1060
1075
|
if (error || status) {
|
|
1061
1076
|
if (error) { // errors get produced by hap-nodejs
|
|
1062
1077
|
debug("Error occurred trying to start siri audio stream: %s", error.message);
|
|
@@ -1069,7 +1084,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1069
1084
|
else {
|
|
1070
1085
|
_this.streamId = message.streamId;
|
|
1071
1086
|
if (!_this.producerRunning) { // audio producer errored in the meantime
|
|
1072
|
-
_this.sendDataSendCloseEvent(3 /* CANCELLED */);
|
|
1087
|
+
_this.sendDataSendCloseEvent(3 /* HDSProtocolSpecificErrorReason.CANCELLED */);
|
|
1073
1088
|
}
|
|
1074
1089
|
else {
|
|
1075
1090
|
debug("Successfully setup siri audio stream with streamId %d", _this.streamId);
|
|
@@ -1082,19 +1097,19 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1082
1097
|
* @returns if the audio session is closing
|
|
1083
1098
|
*/
|
|
1084
1099
|
SiriAudioSession.prototype.isClosing = function () {
|
|
1085
|
-
return this.state >= 2 /* CLOSING */;
|
|
1100
|
+
return this.state >= 2 /* SiriAudioSessionState.CLOSING */;
|
|
1086
1101
|
};
|
|
1087
1102
|
/**
|
|
1088
1103
|
* Called when siri button is released (or active identifier is changed to another device)
|
|
1089
1104
|
*/
|
|
1090
1105
|
SiriAudioSession.prototype.stop = function () {
|
|
1091
|
-
(0, 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");
|
|
1092
1107
|
debug("Stopping siri audio stream with streamId %d", this.streamId);
|
|
1093
1108
|
this.endOfStream = true; // mark as endOfStream
|
|
1094
1109
|
this.stopAudioProducer();
|
|
1095
|
-
if (this.state === 1 /* SENDING */) {
|
|
1110
|
+
if (this.state === 1 /* SiriAudioSessionState.SENDING */) {
|
|
1096
1111
|
this.handleSiriAudioFrame(undefined); // send out last few audio frames with endOfStream property set
|
|
1097
|
-
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)
|
|
1098
1113
|
}
|
|
1099
1114
|
else { // if state is not SENDING (aka state is STARTING) the callback for DATA_SEND OPEN did not yet return (or never will)
|
|
1100
1115
|
this.closed();
|
|
@@ -1107,7 +1122,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1107
1122
|
this.producerTimer = setTimeout(function () {
|
|
1108
1123
|
debug("Didn't receive any frames from audio producer for stream with streamId %s. Canceling the stream now.", _this.streamId);
|
|
1109
1124
|
_this.producerTimer = undefined;
|
|
1110
|
-
_this.handleProducerError(3 /* CANCELLED */);
|
|
1125
|
+
_this.handleProducerError(3 /* HDSProtocolSpecificErrorReason.CANCELLED */);
|
|
1111
1126
|
}, 3000);
|
|
1112
1127
|
this.producerTimer.unref();
|
|
1113
1128
|
};
|
|
@@ -1121,7 +1136,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1121
1136
|
};
|
|
1122
1137
|
SiriAudioSession.prototype.handleSiriAudioFrame = function (frame) {
|
|
1123
1138
|
var _this = this;
|
|
1124
|
-
if (this.state >= 2 /* CLOSING */) {
|
|
1139
|
+
if (this.state >= 2 /* SiriAudioSessionState.CLOSING */) {
|
|
1125
1140
|
return;
|
|
1126
1141
|
}
|
|
1127
1142
|
if (this.producerTimer) { // if producerTimer is defined, then this is the first frame we are receiving
|
|
@@ -1131,7 +1146,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1131
1146
|
if (frame && this.audioFrameQueue.length < this.maxQueueSize) { // add frame to queue whilst it is not full
|
|
1132
1147
|
this.audioFrameQueue.push(frame);
|
|
1133
1148
|
}
|
|
1134
|
-
if (this.state !== 1 /* SENDING */) { // dataSend isn't open yet
|
|
1149
|
+
if (this.state !== 1 /* SiriAudioSessionState.SENDING */) { // dataSend isn't open yet
|
|
1135
1150
|
return;
|
|
1136
1151
|
}
|
|
1137
1152
|
var queued;
|
|
@@ -1153,7 +1168,7 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1153
1168
|
endOfStream: this_1.endOfStream,
|
|
1154
1169
|
};
|
|
1155
1170
|
try {
|
|
1156
|
-
this_1.connection.sendEvent("dataSend" /* DATA_SEND */, "data" /* DATA */, message);
|
|
1171
|
+
this_1.connection.sendEvent("dataSend" /* Protocols.DATA_SEND */, "data" /* Topics.DATA */, message);
|
|
1157
1172
|
}
|
|
1158
1173
|
catch (error) {
|
|
1159
1174
|
debug("Error occurred when trying to send audio frame of hds connection: %s", error.message);
|
|
@@ -1172,31 +1187,31 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1172
1187
|
}
|
|
1173
1188
|
};
|
|
1174
1189
|
SiriAudioSession.prototype.handleProducerError = function (error) {
|
|
1175
|
-
if (this.state >= 2 /* CLOSING */) {
|
|
1190
|
+
if (this.state >= 2 /* SiriAudioSessionState.CLOSING */) {
|
|
1176
1191
|
return;
|
|
1177
1192
|
}
|
|
1178
1193
|
this.stopAudioProducer(); // ensure backend is closed
|
|
1179
|
-
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)
|
|
1180
1195
|
this.sendDataSendCloseEvent(error); // cancel submission
|
|
1181
1196
|
}
|
|
1182
1197
|
};
|
|
1183
1198
|
SiriAudioSession.prototype.handleDataSendAckEvent = function (endOfStream) {
|
|
1184
1199
|
assert_1.default.strictEqual(endOfStream, true);
|
|
1185
1200
|
debug("Received acknowledgment for siri audio stream with streamId %s, closing it now", this.streamId);
|
|
1186
|
-
this.sendDataSendCloseEvent(0 /* NORMAL */);
|
|
1201
|
+
this.sendDataSendCloseEvent(0 /* HDSProtocolSpecificErrorReason.NORMAL */);
|
|
1187
1202
|
};
|
|
1188
1203
|
SiriAudioSession.prototype.handleDataSendCloseEvent = function (reason) {
|
|
1189
1204
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1190
1205
|
debug("Received close event from controller with reason %s for stream with streamId %s", datastream_1.HDSProtocolSpecificErrorReason[reason], this.streamId);
|
|
1191
|
-
if (this.state <= 1 /* SENDING */) {
|
|
1206
|
+
if (this.state <= 1 /* SiriAudioSessionState.SENDING */) {
|
|
1192
1207
|
this.stopAudioProducer();
|
|
1193
1208
|
}
|
|
1194
1209
|
this.closed();
|
|
1195
1210
|
};
|
|
1196
1211
|
SiriAudioSession.prototype.sendDataSendCloseEvent = function (reason) {
|
|
1197
|
-
(0, assert_1.default)(this.state >= 1 /* SENDING */, "state was less than SENDING");
|
|
1198
|
-
(0, assert_1.default)(this.state <= 2 /* CLOSING */, "state was higher than CLOSING");
|
|
1199
|
-
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 */, {
|
|
1200
1215
|
streamId: new datastream_1.Int64(this.streamId),
|
|
1201
1216
|
reason: new datastream_1.Int64(reason),
|
|
1202
1217
|
});
|
|
@@ -1204,17 +1219,17 @@ var SiriAudioSession = /** @class */ (function (_super) {
|
|
|
1204
1219
|
};
|
|
1205
1220
|
SiriAudioSession.prototype.handleDataStreamConnectionClosed = function () {
|
|
1206
1221
|
debug("Closing audio session with streamId %d", this.streamId);
|
|
1207
|
-
if (this.state <= 1 /* SENDING */) {
|
|
1222
|
+
if (this.state <= 1 /* SiriAudioSessionState.SENDING */) {
|
|
1208
1223
|
this.stopAudioProducer();
|
|
1209
1224
|
}
|
|
1210
1225
|
this.closed();
|
|
1211
1226
|
};
|
|
1212
1227
|
SiriAudioSession.prototype.closed = function () {
|
|
1213
1228
|
var lastState = this.state;
|
|
1214
|
-
this.state = 3 /* CLOSED */;
|
|
1215
|
-
if (lastState !== 3 /* CLOSED */) {
|
|
1216
|
-
this.emit("close" /* CLOSE */);
|
|
1217
|
-
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);
|
|
1218
1233
|
}
|
|
1219
1234
|
this.removeAllListeners();
|
|
1220
1235
|
};
|