@camera.ui/camera-ui-tuya 0.0.1
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/CHANGELOG.md +8 -0
- package/CONTRIBUTING.md +1 -0
- package/LICENSE.md +22 -0
- package/README.md +1 -0
- package/config.schema.json +284 -0
- package/dist/camera.d.ts +32 -0
- package/dist/camera.js +229 -0
- package/dist/camera.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +214 -0
- package/dist/index.js.map +1 -0
- package/dist/peer.d.ts +34 -0
- package/dist/peer.js +274 -0
- package/dist/peer.js.map +1 -0
- package/dist/tuya/cloud.d.ts +31 -0
- package/dist/tuya/cloud.js +207 -0
- package/dist/tuya/cloud.js.map +1 -0
- package/dist/tuya/const.d.ts +113 -0
- package/dist/tuya/const.js +2 -0
- package/dist/tuya/const.js.map +1 -0
- package/dist/tuya/device.d.ts +14 -0
- package/dist/tuya/device.js +68 -0
- package/dist/tuya/device.js.map +1 -0
- package/dist/tuya/mq.d.ts +25 -0
- package/dist/tuya/mq.js +85 -0
- package/dist/tuya/mq.js.map +1 -0
- package/dist/tuya/pulsar.d.ts +73 -0
- package/dist/tuya/pulsar.js +198 -0
- package/dist/tuya/pulsar.js.map +1 -0
- package/dist/tuya/utils.d.ts +16 -0
- package/dist/tuya/utils.js +276 -0
- package/dist/tuya/utils.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
All notable changes to this project will be documented in this file.
|
|
2
|
+
|
|
3
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
4
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
+
|
|
6
|
+
## [X.X.X] - ???
|
|
7
|
+
|
|
8
|
+
- Initial Release
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Contributing
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2024 seydx <dev@seydx.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @camera.ui/camera-ui-tuya
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": {
|
|
3
|
+
"type": "object",
|
|
4
|
+
"title": "Tuya Account",
|
|
5
|
+
"description": "Tuya Account",
|
|
6
|
+
"required": true,
|
|
7
|
+
"properties": {
|
|
8
|
+
"userId": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"title": "User ID",
|
|
11
|
+
"description": "You can find this information in Tuya IoT > Cloud > Devices > Linked Devices",
|
|
12
|
+
"required": true,
|
|
13
|
+
"store": true
|
|
14
|
+
},
|
|
15
|
+
"accessId": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"title": "Access ID",
|
|
18
|
+
"description": "This is localted on the main project",
|
|
19
|
+
"format": "password",
|
|
20
|
+
"required": true,
|
|
21
|
+
"store": true
|
|
22
|
+
},
|
|
23
|
+
"accessKey": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"title": "Access Key/Secret",
|
|
26
|
+
"description": "This is localted on the main project",
|
|
27
|
+
"format": "password",
|
|
28
|
+
"required": true,
|
|
29
|
+
"store": true
|
|
30
|
+
},
|
|
31
|
+
"country": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"title": "Country",
|
|
34
|
+
"description": "This is the country where you registered your devices",
|
|
35
|
+
"required": false,
|
|
36
|
+
"store": true,
|
|
37
|
+
"defaultValue": "United States of America",
|
|
38
|
+
"enum": [
|
|
39
|
+
"Afghanistan",
|
|
40
|
+
"Albania",
|
|
41
|
+
"Algeria",
|
|
42
|
+
"American Samoa",
|
|
43
|
+
"Andorra",
|
|
44
|
+
"Angola",
|
|
45
|
+
"Anguilla",
|
|
46
|
+
"Antarctica",
|
|
47
|
+
"Antigua and Barbuda",
|
|
48
|
+
"Argentina",
|
|
49
|
+
"Armenia",
|
|
50
|
+
"Aruba",
|
|
51
|
+
"Australia",
|
|
52
|
+
"Austria",
|
|
53
|
+
"Azerbaijan",
|
|
54
|
+
"Bahamas",
|
|
55
|
+
"Bahrain",
|
|
56
|
+
"Bangladesh",
|
|
57
|
+
"Barbados",
|
|
58
|
+
"Belarus",
|
|
59
|
+
"Belgium",
|
|
60
|
+
"Belize",
|
|
61
|
+
"Benin",
|
|
62
|
+
"Bermuda",
|
|
63
|
+
"Bhutan",
|
|
64
|
+
"Bolivia",
|
|
65
|
+
"Bosnia and Herzegovina",
|
|
66
|
+
"Botswana",
|
|
67
|
+
"Brazil",
|
|
68
|
+
"British Indian Ocean Territory",
|
|
69
|
+
"British Virgin Islands",
|
|
70
|
+
"Brunei",
|
|
71
|
+
"Bulgaria",
|
|
72
|
+
"Burkina Faso",
|
|
73
|
+
"Burundi",
|
|
74
|
+
"Cabo Verde",
|
|
75
|
+
"Cambodia",
|
|
76
|
+
"Cameroon",
|
|
77
|
+
"Canada",
|
|
78
|
+
"Cayman Islands",
|
|
79
|
+
"Central African Republic",
|
|
80
|
+
"Chad",
|
|
81
|
+
"Chile",
|
|
82
|
+
"China",
|
|
83
|
+
"Colombia",
|
|
84
|
+
"Comoros",
|
|
85
|
+
"Cook Islands",
|
|
86
|
+
"Costa Rica",
|
|
87
|
+
"Croatia",
|
|
88
|
+
"Curacao",
|
|
89
|
+
"Cyprus",
|
|
90
|
+
"Czech Republic",
|
|
91
|
+
"Côte d'Ivoire",
|
|
92
|
+
"Democratic Republic of the Congo",
|
|
93
|
+
"Denmark",
|
|
94
|
+
"Djibouti",
|
|
95
|
+
"Dominica",
|
|
96
|
+
"Dominican Republic (1-809)",
|
|
97
|
+
"Dominican Republic (1-829)",
|
|
98
|
+
"Dominican Republic (1-849)",
|
|
99
|
+
"East Timor",
|
|
100
|
+
"Ecuador",
|
|
101
|
+
"Egypt",
|
|
102
|
+
"El Salvador",
|
|
103
|
+
"Equatorial Guinea",
|
|
104
|
+
"Eritrea",
|
|
105
|
+
"Estonia",
|
|
106
|
+
"Ethiopia",
|
|
107
|
+
"Falkland Islands",
|
|
108
|
+
"Faroe Islands",
|
|
109
|
+
"Fiji",
|
|
110
|
+
"Finland",
|
|
111
|
+
"France",
|
|
112
|
+
"French Guiana",
|
|
113
|
+
"French Polynesia",
|
|
114
|
+
"Gabon",
|
|
115
|
+
"Gambia",
|
|
116
|
+
"Georgia",
|
|
117
|
+
"Germany",
|
|
118
|
+
"Ghana",
|
|
119
|
+
"Gibraltar",
|
|
120
|
+
"Greece",
|
|
121
|
+
"Greenland",
|
|
122
|
+
"Grenada",
|
|
123
|
+
"Guam",
|
|
124
|
+
"Guatemala",
|
|
125
|
+
"Guinea",
|
|
126
|
+
"Guinea-Bissau",
|
|
127
|
+
"Guyana",
|
|
128
|
+
"Haiti",
|
|
129
|
+
"Honduras",
|
|
130
|
+
"Hong Kong",
|
|
131
|
+
"Hungary",
|
|
132
|
+
"Iceland",
|
|
133
|
+
"India",
|
|
134
|
+
"Indonesia",
|
|
135
|
+
"Iraq",
|
|
136
|
+
"Ireland",
|
|
137
|
+
"Israel",
|
|
138
|
+
"Italy",
|
|
139
|
+
"Jamaica",
|
|
140
|
+
"Japan",
|
|
141
|
+
"Jordan",
|
|
142
|
+
"Kenya",
|
|
143
|
+
"Kiribati",
|
|
144
|
+
"Kuwait",
|
|
145
|
+
"Kyrgyzstan",
|
|
146
|
+
"Laos",
|
|
147
|
+
"Latvia",
|
|
148
|
+
"Lebanon",
|
|
149
|
+
"Lesotho",
|
|
150
|
+
"Liberia",
|
|
151
|
+
"Libya",
|
|
152
|
+
"Liechtenstein",
|
|
153
|
+
"Lithuania",
|
|
154
|
+
"Luxembourg",
|
|
155
|
+
"Macao",
|
|
156
|
+
"Macedonia",
|
|
157
|
+
"Madagascar",
|
|
158
|
+
"Malawi",
|
|
159
|
+
"Malaysia",
|
|
160
|
+
"Maldives",
|
|
161
|
+
"Mali",
|
|
162
|
+
"Malta",
|
|
163
|
+
"Marshall Islands",
|
|
164
|
+
"Martinique",
|
|
165
|
+
"Mauritania",
|
|
166
|
+
"Mauritius",
|
|
167
|
+
"Mayotte",
|
|
168
|
+
"Mexico",
|
|
169
|
+
"Micronesia",
|
|
170
|
+
"Moldova",
|
|
171
|
+
"Monaco",
|
|
172
|
+
"Mongolia",
|
|
173
|
+
"Montenegro",
|
|
174
|
+
"Montserrat",
|
|
175
|
+
"Morocco",
|
|
176
|
+
"Mozambique",
|
|
177
|
+
"Myanmar",
|
|
178
|
+
"Namibia",
|
|
179
|
+
"Nauru",
|
|
180
|
+
"Nepal",
|
|
181
|
+
"Netherlands",
|
|
182
|
+
"New Caledonia",
|
|
183
|
+
"New Zealand",
|
|
184
|
+
"Nicaragua",
|
|
185
|
+
"Niger",
|
|
186
|
+
"Nigeria",
|
|
187
|
+
"Niue",
|
|
188
|
+
"Northern Mariana Islands",
|
|
189
|
+
"Norway",
|
|
190
|
+
"Oman",
|
|
191
|
+
"Pakistan",
|
|
192
|
+
"Palau",
|
|
193
|
+
"Palestine",
|
|
194
|
+
"Panama",
|
|
195
|
+
"Papua New Guinea",
|
|
196
|
+
"Paraguay",
|
|
197
|
+
"Peru",
|
|
198
|
+
"Philippines",
|
|
199
|
+
"Poland",
|
|
200
|
+
"Portugal",
|
|
201
|
+
"Puerto Rico",
|
|
202
|
+
"Qatar",
|
|
203
|
+
"Republic of the Congo",
|
|
204
|
+
"Reunion",
|
|
205
|
+
"Romania",
|
|
206
|
+
"Russia",
|
|
207
|
+
"Rwanda",
|
|
208
|
+
"Saint Kitts and Nevis",
|
|
209
|
+
"Saint Lucia",
|
|
210
|
+
"Saint Martin",
|
|
211
|
+
"Saint Pierre and Miquelon",
|
|
212
|
+
"Saint Vincent and the Grenadines",
|
|
213
|
+
"Samoa",
|
|
214
|
+
"San Marino",
|
|
215
|
+
"Saudi Arabia",
|
|
216
|
+
"Sao Tome and Principe",
|
|
217
|
+
"Senegal",
|
|
218
|
+
"Serbia",
|
|
219
|
+
"Seychelles",
|
|
220
|
+
"Sierra Leone",
|
|
221
|
+
"Singapore",
|
|
222
|
+
"Sint Maarten",
|
|
223
|
+
"Slovakia",
|
|
224
|
+
"Slovenia",
|
|
225
|
+
"Solomon Islands",
|
|
226
|
+
"Somalia",
|
|
227
|
+
"South Africa",
|
|
228
|
+
"South Korea",
|
|
229
|
+
"Spain",
|
|
230
|
+
"Sri Lanka",
|
|
231
|
+
"Suriname",
|
|
232
|
+
"Swalbard and Jan Mayen",
|
|
233
|
+
"Swaziland",
|
|
234
|
+
"Sweden",
|
|
235
|
+
"Switzerland",
|
|
236
|
+
"Taiwan",
|
|
237
|
+
"Tajikistan",
|
|
238
|
+
"Tanzania",
|
|
239
|
+
"Thailand",
|
|
240
|
+
"Togo",
|
|
241
|
+
"Tokelau",
|
|
242
|
+
"Tonga",
|
|
243
|
+
"Trinidad and Tobago",
|
|
244
|
+
"Tunisia",
|
|
245
|
+
"Turkey",
|
|
246
|
+
"Turkmenistan",
|
|
247
|
+
"Turks and Caicos Islands",
|
|
248
|
+
"Tuvalu",
|
|
249
|
+
"United States of America",
|
|
250
|
+
"U.S. Virgin Islands",
|
|
251
|
+
"Uganda",
|
|
252
|
+
"Ukraine",
|
|
253
|
+
"United Arab Emirates",
|
|
254
|
+
"United Kingdom",
|
|
255
|
+
"Uruguay",
|
|
256
|
+
"Uzbekistan",
|
|
257
|
+
"Vanuatu",
|
|
258
|
+
"Vatican",
|
|
259
|
+
"Venezuela",
|
|
260
|
+
"Vietnam",
|
|
261
|
+
"Wallis and Futuna",
|
|
262
|
+
"Western Sahara",
|
|
263
|
+
"Yemen",
|
|
264
|
+
"Zambia",
|
|
265
|
+
"Zimbabwe",
|
|
266
|
+
"Åland Islands"
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
"homeWhitelist": {
|
|
270
|
+
"type": "array",
|
|
271
|
+
"title": "Home Whitelist",
|
|
272
|
+
"description": "An array of integer values for the home IDs you want to whitelist. If provided, only devices with matching Home IDs will be included",
|
|
273
|
+
"required": false,
|
|
274
|
+
"items": {
|
|
275
|
+
"type": "string",
|
|
276
|
+
"title": "Home ID",
|
|
277
|
+
"description": "The Home ID of the device"
|
|
278
|
+
},
|
|
279
|
+
"defaultValue": [],
|
|
280
|
+
"store": true
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
package/dist/camera.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WebRTCReceiver } from '@camera.ui/rtsp';
|
|
2
|
+
import type { AnswerSDP } from '@camera.ui/rtsp';
|
|
3
|
+
import type { CameraDelegate, CameraDevice, PluginLogger } from '@camera.ui/types';
|
|
4
|
+
import type Tuya from './index.js';
|
|
5
|
+
import type { TuyaCloud } from './tuya/cloud.js';
|
|
6
|
+
import type { TuyaDeviceConfig } from './tuya/const.js';
|
|
7
|
+
export declare class Camera extends WebRTCReceiver implements CameraDelegate {
|
|
8
|
+
cameraDevice: CameraDevice;
|
|
9
|
+
cloudCamera: TuyaDeviceConfig;
|
|
10
|
+
private platform;
|
|
11
|
+
private cloud;
|
|
12
|
+
private logger;
|
|
13
|
+
private ffmpegPath?;
|
|
14
|
+
private pc?;
|
|
15
|
+
private rtspServer;
|
|
16
|
+
private motionTimeout?;
|
|
17
|
+
private binaryTimeout?;
|
|
18
|
+
private previousDoorbellRing?;
|
|
19
|
+
private previousMotion?;
|
|
20
|
+
constructor(platform: Tuya, cloud: TuyaCloud, cloudCamera: TuyaDeviceConfig, logger: PluginLogger);
|
|
21
|
+
createCameraDevice(): Promise<void>;
|
|
22
|
+
onOffer(offerSdp: string): Promise<AnswerSDP>;
|
|
23
|
+
onCandidate(candidate: string): Promise<void>;
|
|
24
|
+
snapshot(): Promise<ArrayBuffer | undefined>;
|
|
25
|
+
reboot(): Promise<void>;
|
|
26
|
+
updateState(): void;
|
|
27
|
+
private triggerBinaryState;
|
|
28
|
+
private triggerMotion;
|
|
29
|
+
private createRTSPServer;
|
|
30
|
+
private createPeerCoonection;
|
|
31
|
+
private toBool;
|
|
32
|
+
}
|
package/dist/camera.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { RTSPSingleServer, WebRTCReceiver } from '@camera.ui/rtsp';
|
|
2
|
+
import { MediaStreamTrack, RTCIceCandidate, RTCPeerConnection, RTCRtpCodecParameters, RTCSessionDescription } from 'werift';
|
|
3
|
+
import { CustomPeerConnection } from './peer.js';
|
|
4
|
+
import { TuyaDevice } from './tuya/device.js';
|
|
5
|
+
export class Camera extends WebRTCReceiver {
|
|
6
|
+
cameraDevice;
|
|
7
|
+
cloudCamera;
|
|
8
|
+
platform;
|
|
9
|
+
cloud;
|
|
10
|
+
logger;
|
|
11
|
+
ffmpegPath;
|
|
12
|
+
pc;
|
|
13
|
+
rtspServer;
|
|
14
|
+
motionTimeout;
|
|
15
|
+
binaryTimeout;
|
|
16
|
+
previousDoorbellRing;
|
|
17
|
+
previousMotion;
|
|
18
|
+
constructor(platform, cloud, cloudCamera, logger) {
|
|
19
|
+
super();
|
|
20
|
+
this.platform = platform;
|
|
21
|
+
this.cloud = cloud;
|
|
22
|
+
this.cloudCamera = cloudCamera;
|
|
23
|
+
this.logger = logger;
|
|
24
|
+
}
|
|
25
|
+
async createCameraDevice() {
|
|
26
|
+
await this.createRTSPServer();
|
|
27
|
+
const sourceName = 'P2P';
|
|
28
|
+
const streamUrls = [this.rtspServer.streamUrl];
|
|
29
|
+
const cameraDevice = Array.from(this.platform.cameras.values()).find((camera) => camera.nativeId === this.cloudCamera.id);
|
|
30
|
+
if (!cameraDevice) {
|
|
31
|
+
this.logger.log('Adding camera', this.cloudCamera.name);
|
|
32
|
+
this.cameraDevice = await this.platform.api.deviceManager.createCamera({
|
|
33
|
+
name: this.cloudCamera.name,
|
|
34
|
+
nativeId: this.cloudCamera.id,
|
|
35
|
+
hasBinarySensor: TuyaDevice.isDoorbell(this.cloudCamera),
|
|
36
|
+
hasLight: TuyaDevice.hasLightSwitch(this.cloudCamera),
|
|
37
|
+
info: {
|
|
38
|
+
manufacturer: 'Tuya',
|
|
39
|
+
model: this.cloudCamera.model,
|
|
40
|
+
serialNumber: this.cloudCamera.id,
|
|
41
|
+
supportUrl: 'https://support.tuya.com/en/help',
|
|
42
|
+
},
|
|
43
|
+
sources: [
|
|
44
|
+
{
|
|
45
|
+
name: sourceName,
|
|
46
|
+
roles: ['high-resolution', 'snapshot'],
|
|
47
|
+
urls: streamUrls,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.cameraDevice = cameraDevice;
|
|
54
|
+
await this.cameraDevice.updateCameraSource(cameraDevice.streamSource._id, { urls: streamUrls });
|
|
55
|
+
}
|
|
56
|
+
this.cameraDevice.setDelegate('cameraDelegate', this);
|
|
57
|
+
const ffmpegPath = await this.platform.api.coreManager.getFFmpegPath();
|
|
58
|
+
this.rtspServer.changeFFmpegPath(ffmpegPath);
|
|
59
|
+
await this.cameraDevice.connect();
|
|
60
|
+
}
|
|
61
|
+
async onOffer(offerSdp) {
|
|
62
|
+
this.logger.debug(`${this.cameraDevice.name}: Preparing stream...`);
|
|
63
|
+
let timeout;
|
|
64
|
+
const cleanup = () => {
|
|
65
|
+
clearTimeout(timeout);
|
|
66
|
+
tuyaPeerConnection.onAudioRtcp.unsubscribe();
|
|
67
|
+
tuyaPeerConnection.onVideoRtcp.unsubscribe();
|
|
68
|
+
tuyaPeerConnection.onIceCandidate.unsubscribe();
|
|
69
|
+
tuyaPeerConnection.close();
|
|
70
|
+
pc.connectionStateChange.allUnsubscribe();
|
|
71
|
+
pc.onTrack.allUnsubscribe();
|
|
72
|
+
pc.close();
|
|
73
|
+
this.logger.debug(`${this.cameraDevice.name}: Stream stopped!`);
|
|
74
|
+
};
|
|
75
|
+
const tuyaPeerConnection = new CustomPeerConnection(this.platform, this.cameraDevice, this.cloudCamera, this.logger);
|
|
76
|
+
await tuyaPeerConnection.createPeerConnection();
|
|
77
|
+
const audioTrack = new MediaStreamTrack({ kind: 'audio' });
|
|
78
|
+
const videoTrack = new MediaStreamTrack({ kind: 'video' });
|
|
79
|
+
tuyaPeerConnection.onAudioRtp.subscribe((rtp) => {
|
|
80
|
+
audioTrack.writeRtp(rtp);
|
|
81
|
+
});
|
|
82
|
+
tuyaPeerConnection.onVideoRtp.subscribe((rtp) => {
|
|
83
|
+
videoTrack.writeRtp(rtp);
|
|
84
|
+
});
|
|
85
|
+
const pc = (this.pc = this.createPeerCoonection());
|
|
86
|
+
pc.onIceCandidate.subscribe((candidate) => {
|
|
87
|
+
this.events.emit('candidate', candidate.candidate);
|
|
88
|
+
});
|
|
89
|
+
pc.connectionStateChange.subscribe((ev) => {
|
|
90
|
+
this.logger.debug(`${this.cameraDevice.name}: connectionStateChange: ${ev}`);
|
|
91
|
+
if (ev === 'disconnected' || ev === 'failed' || ev === 'closed') {
|
|
92
|
+
cleanup();
|
|
93
|
+
}
|
|
94
|
+
if (ev === 'connecting') {
|
|
95
|
+
timeout = setTimeout(() => {
|
|
96
|
+
this.logger.warn(`${this.cameraDevice.name}: Connection timeout!`);
|
|
97
|
+
cleanup();
|
|
98
|
+
}, 10000);
|
|
99
|
+
}
|
|
100
|
+
if (ev === 'connected') {
|
|
101
|
+
this.logger.log(`${this.cameraDevice.name}: Stream started!`);
|
|
102
|
+
clearTimeout(timeout);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
pc.onTrack.subscribe((track) => {
|
|
106
|
+
if (track.kind === 'audio') {
|
|
107
|
+
track.onReceiveRtp.subscribe((rtp) => {
|
|
108
|
+
tuyaPeerConnection.returnAudioTrack.writeRtp(rtp);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
pc.addTransceiver(videoTrack, { direction: 'sendonly' });
|
|
113
|
+
pc.addTransceiver(audioTrack, { direction: 'sendonly' });
|
|
114
|
+
const offer = new RTCSessionDescription(offerSdp, 'offer');
|
|
115
|
+
await pc.setRemoteDescription(offer);
|
|
116
|
+
const answer = await pc.createAnswer();
|
|
117
|
+
await pc.setLocalDescription(answer);
|
|
118
|
+
return answer.sdp;
|
|
119
|
+
}
|
|
120
|
+
async onCandidate(candidate) {
|
|
121
|
+
await this.pc?.addIceCandidate(new RTCIceCandidate({ candidate }));
|
|
122
|
+
}
|
|
123
|
+
async snapshot() {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
async reboot() {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
updateState() {
|
|
130
|
+
if (TuyaDevice.hasMotionDetection(this.cloudCamera)) {
|
|
131
|
+
const motionDetectedStatus = TuyaDevice.getMotionDetectionStatus(this.cloudCamera);
|
|
132
|
+
if (motionDetectedStatus) {
|
|
133
|
+
if (!this.previousMotion) {
|
|
134
|
+
this.previousMotion = motionDetectedStatus.value;
|
|
135
|
+
}
|
|
136
|
+
else if (this.previousMotion !== motionDetectedStatus.value) {
|
|
137
|
+
this.previousMotion = motionDetectedStatus.value;
|
|
138
|
+
this.triggerMotion();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (TuyaDevice.isDoorbell(this.cloudCamera)) {
|
|
143
|
+
const doorbellRingStatus = TuyaDevice.getDoorbellRing(this.cloudCamera);
|
|
144
|
+
if (doorbellRingStatus) {
|
|
145
|
+
if (!this.previousDoorbellRing) {
|
|
146
|
+
this.previousDoorbellRing = doorbellRingStatus.value;
|
|
147
|
+
}
|
|
148
|
+
else if (this.previousDoorbellRing !== doorbellRingStatus.value) {
|
|
149
|
+
this.previousDoorbellRing = doorbellRingStatus.value;
|
|
150
|
+
this.triggerBinaryState();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (TuyaDevice.hasLightSwitch(this.cloudCamera)) {
|
|
155
|
+
const state = TuyaDevice.getLightSwitchStatus(this.cloudCamera)?.value;
|
|
156
|
+
this.cameraDevice.updateState('light', { state: this.toBool(state) });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
triggerBinaryState() {
|
|
160
|
+
clearTimeout(this.binaryTimeout);
|
|
161
|
+
this.cameraDevice.updateState('doorbell', { state: true });
|
|
162
|
+
this.binaryTimeout = setTimeout(() => {
|
|
163
|
+
this.cameraDevice.updateState('doorbell', { state: false });
|
|
164
|
+
}, 10 * 1000);
|
|
165
|
+
}
|
|
166
|
+
triggerMotion() {
|
|
167
|
+
const timeoutCallback = () => {
|
|
168
|
+
this.cameraDevice.updateState('motion', { state: false, detections: [] });
|
|
169
|
+
this.motionTimeout = undefined;
|
|
170
|
+
};
|
|
171
|
+
if (!this.motionTimeout) {
|
|
172
|
+
this.motionTimeout = setTimeout(timeoutCallback, 10 * 1000);
|
|
173
|
+
this.cameraDevice.updateState('motion', { state: true, detections: [] });
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// Cancel the timeout and start again.
|
|
177
|
+
clearTimeout(this.motionTimeout);
|
|
178
|
+
this.motionTimeout = setTimeout(timeoutCallback, 10 * 1000);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async createRTSPServer() {
|
|
182
|
+
const stream = {
|
|
183
|
+
name: 'Tuya',
|
|
184
|
+
receiver: this,
|
|
185
|
+
addBackchannel: true,
|
|
186
|
+
};
|
|
187
|
+
const rtspLogger = {
|
|
188
|
+
// log: this.logger.log.bind(this.logger),
|
|
189
|
+
warn: this.logger.warn.bind(this.logger),
|
|
190
|
+
error: this.logger.error.bind(this.logger),
|
|
191
|
+
// debug: this.logger.debug.bind(this.logger),
|
|
192
|
+
// trace: this.logger.trace.bind(this.logger),
|
|
193
|
+
};
|
|
194
|
+
this.rtspServer = await RTSPSingleServer.initialize({ stream }, rtspLogger);
|
|
195
|
+
await this.rtspServer.listen();
|
|
196
|
+
}
|
|
197
|
+
createPeerCoonection() {
|
|
198
|
+
return new RTCPeerConnection({
|
|
199
|
+
codecs: {
|
|
200
|
+
video: [
|
|
201
|
+
new RTCRtpCodecParameters({
|
|
202
|
+
mimeType: 'video/H264',
|
|
203
|
+
clockRate: 90000,
|
|
204
|
+
payloadType: 96,
|
|
205
|
+
rtcpFeedback: [{ type: 'transport-cc' }, { type: 'ccm', parameter: 'fir' }, { type: 'nack' }, { type: 'nack', parameter: 'pli' }, { type: 'goog-remb' }],
|
|
206
|
+
parameters: 'level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f',
|
|
207
|
+
}),
|
|
208
|
+
],
|
|
209
|
+
audio: [
|
|
210
|
+
new RTCRtpCodecParameters({
|
|
211
|
+
mimeType: 'audio/opus',
|
|
212
|
+
clockRate: 48000,
|
|
213
|
+
payloadType: 101,
|
|
214
|
+
channels: 2,
|
|
215
|
+
parameters: 'minptime=10;useinbandfec=1',
|
|
216
|
+
}),
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
bundlePolicy: 'max-bundle',
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
toBool(value) {
|
|
223
|
+
if (typeof value === 'string' && value.toLowerCase() === 'false') {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
return !!value;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=camera.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAE5H,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAS9C,MAAM,OAAO,MAAO,SAAQ,cAAc;IACjC,YAAY,CAAgB;IAC5B,WAAW,CAAmB;IAE7B,QAAQ,CAAO;IACf,KAAK,CAAY;IACjB,MAAM,CAAe;IACrB,UAAU,CAAU;IAEpB,EAAE,CAAqB;IACvB,UAAU,CAAoB;IAE9B,aAAa,CAAkB;IAC/B,aAAa,CAAkB;IAC/B,oBAAoB,CAAW;IAC/B,cAAc,CAAW;IAEjC,YAAY,QAAc,EAAE,KAAgB,EAAE,WAA6B,EAAE,MAAoB;QAC/F,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,K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,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;wBACxJ,UAAU,EAAE,wEAAwE;qBACrF,CAAC;iBACH;gBACD,KAAK,EAAE;oBACL,IAAI,qBAAqB,CAAC;wBACxB,QAAQ,EAAE,YAAY;wBACtB,SAAS,EAAE,KAAK;wBAChB,WAAW,EAAE,GAAG;wBAChB,QAAQ,EAAE,CAAC;wBACX,UAAU,EAAE,4BAA4B;qBACzC,CAAC;iBACH;aACF;YACD,YAAY,EAAE,YAAY;SAC3B,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,KAAc;QAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;YACjE,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,CAAC,CAAC,KAAK,CAAC;IACjB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TuyaCloud } from './tuya/cloud.js';
|
|
2
|
+
import { TuyaPulsar } from './tuya/pulsar.js';
|
|
3
|
+
import type { BasePlugin, CameraDevice, FormSubmitResponse, PluginAPI, PluginLogger } from '@camera.ui/types';
|
|
4
|
+
import type { Config } from './types.js';
|
|
5
|
+
export default class Tuya implements BasePlugin {
|
|
6
|
+
config: Config;
|
|
7
|
+
logger: PluginLogger;
|
|
8
|
+
api: PluginAPI;
|
|
9
|
+
cameras: Map<string, CameraDevice>;
|
|
10
|
+
private tuyaCameras;
|
|
11
|
+
cloud?: TuyaCloud;
|
|
12
|
+
pulsar?: TuyaPulsar;
|
|
13
|
+
private cleanOrphanedCamerasTimeout?;
|
|
14
|
+
constructor(logger: PluginLogger, api: PluginAPI);
|
|
15
|
+
configureCameras(cameras: CameraDevice[]): void;
|
|
16
|
+
onFormSubmit(actionId: string, payload: any): Promise<FormSubmitResponse | void>;
|
|
17
|
+
private start;
|
|
18
|
+
private stop;
|
|
19
|
+
private connect;
|
|
20
|
+
private handlePulsarMessage;
|
|
21
|
+
private addOrUpdateDevice;
|
|
22
|
+
private deviceRemoved;
|
|
23
|
+
private checkOrphanedCameras;
|
|
24
|
+
}
|