@reactoo/watchtogether-sdk-js 2.6.11 → 2.6.13
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/dist/watchtogether-sdk.js +225 -325
- package/dist/watchtogether-sdk.min.js +2 -2
- package/package.json +1 -1
- package/src/models/iot.js +10 -4
- package/src/models/utils.js +32 -0
- package/src/modules/wt-iot.js +11 -1
- package/src/modules/wt-room.js +4 -3
package/package.json
CHANGED
package/src/models/iot.js
CHANGED
|
@@ -49,10 +49,16 @@ let iot = function () {
|
|
|
49
49
|
__currentTopics.length = 0;
|
|
50
50
|
|
|
51
51
|
this.iot.__promise
|
|
52
|
-
.then(([suggestedTopic, instance]) =>
|
|
53
|
-
|
|
54
|
-
Promise.resolve(instance)
|
|
55
|
-
|
|
52
|
+
.then(([suggestedTopic, instance]) => {
|
|
53
|
+
if(!subscribeToSuggestedTopics) {
|
|
54
|
+
return Promise.resolve(instance)
|
|
55
|
+
}
|
|
56
|
+
const topics = [...suggestedTopic, ...__currentTopicsCopy];
|
|
57
|
+
__currentTopics = topics.filter((c, index) => {
|
|
58
|
+
return topics.indexOf(c) !== index;
|
|
59
|
+
});
|
|
60
|
+
return Promise.all(__currentTopics.map(topic => this.iot.subscribe(topic))).then(() => instance)
|
|
61
|
+
})
|
|
56
62
|
.then((instance) => {
|
|
57
63
|
this.iot.$on('error', this.iot.__reconnect, this);
|
|
58
64
|
this.iot.$on('updateCredentials', this.iot.__updateCredentials, this);
|
package/src/models/utils.js
CHANGED
|
@@ -119,5 +119,37 @@ export default {
|
|
|
119
119
|
stream.getVideoTracks().forEach(track => track.enabled = !muteVideo);
|
|
120
120
|
return stream;
|
|
121
121
|
});
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
getHostStream({
|
|
125
|
+
hasAudio,
|
|
126
|
+
hasVideo,
|
|
127
|
+
aDeviceId,
|
|
128
|
+
vDeviceId,
|
|
129
|
+
channelCount = 1} = {}
|
|
130
|
+
) {
|
|
131
|
+
|
|
132
|
+
let audioOnlyConstraints = {
|
|
133
|
+
audio: {
|
|
134
|
+
...(aDeviceId && {deviceId: {exact:aDeviceId}}),
|
|
135
|
+
channelCount
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
let videoOnlyConstraints = {
|
|
140
|
+
video: {
|
|
141
|
+
...(vDeviceId && {deviceId: {exact:vDeviceId}}),
|
|
142
|
+
frameRate: {ideal: 30, max: 30},
|
|
143
|
+
width: {min: 1280, ideal: 1920},
|
|
144
|
+
height: {min: 720, ideal: 1080},
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
let fullConstraints = {
|
|
149
|
+
...(hasAudio ? audioOnlyConstraints : {audio: false}),
|
|
150
|
+
...(hasVideo ? videoOnlyConstraints : {video: false})
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return navigator.mediaDevices.getUserMedia(fullConstraints);
|
|
122
154
|
}
|
|
123
155
|
}
|
package/src/modules/wt-iot.js
CHANGED
|
@@ -42,6 +42,7 @@ class Iot {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
updateWebSocketCredentials(accessKeyId, secretAccessKey, sessionToken, expiration) {
|
|
45
|
+
this.log('iot updateWebSocketCredentials');
|
|
45
46
|
if(this.device) {
|
|
46
47
|
this.device.updateWebSocketCredentials(accessKeyId, secretAccessKey, sessionToken);
|
|
47
48
|
this.startCredentialsExpirationCheck(expiration);
|
|
@@ -49,6 +50,7 @@ class Iot {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
connect(apiMqttUrl, apiMqttClientId, region, accessKeyId, secretAccessKey, sessionToken, expiration, forceDisconnect = false) {
|
|
53
|
+
this.log('iot connect');
|
|
52
54
|
return this.disconnect(forceDisconnect).then(() => {
|
|
53
55
|
return new Promise((resolve, reject) => {
|
|
54
56
|
this.device = device({
|
|
@@ -59,7 +61,7 @@ class Iot {
|
|
|
59
61
|
accessKeyId: accessKeyId,
|
|
60
62
|
secretKey: secretAccessKey,
|
|
61
63
|
sessionToken: sessionToken,
|
|
62
|
-
keepalive:
|
|
64
|
+
keepalive: 30,
|
|
63
65
|
maximumReconnectTimeMs: 8000,
|
|
64
66
|
enableMetrics: false,
|
|
65
67
|
debug: this.debugFlag,
|
|
@@ -126,33 +128,41 @@ class Iot {
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
subscribe(topic) {
|
|
131
|
+
this.log('iot subscribe', topic);
|
|
129
132
|
return this.device && this.device.subscribe(topic);
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
unsubscribe(topic) {
|
|
136
|
+
this.log('iot unsubscribe', topic);
|
|
133
137
|
return this.device && this.device.unsubscribe(topic);
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
send(topic, message) {
|
|
141
|
+
this.log('iot send', topic, message);
|
|
137
142
|
let msg = typeof message === 'object' ? JSON.stringify(message) : message;
|
|
138
143
|
return this.device && this.device.publish(topic, msg);
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
__reconnectCb() {
|
|
147
|
+
this.log('iot reconnect');
|
|
142
148
|
this.emit('reconnect');
|
|
143
149
|
}
|
|
144
150
|
__connectCb() {
|
|
151
|
+
this.log('iot connect');
|
|
145
152
|
this.connectionActive = true;
|
|
146
153
|
this.emit('connect');
|
|
147
154
|
}
|
|
148
155
|
__failureCb(err) {
|
|
156
|
+
this.log('iot failure');
|
|
149
157
|
this.emit('error', err);
|
|
150
158
|
}
|
|
151
159
|
__closeCb(responseObject) {
|
|
160
|
+
this.log('iot close');
|
|
152
161
|
this.connectionActive = false;
|
|
153
162
|
this.emit('close');
|
|
154
163
|
}
|
|
155
164
|
__offlineCb(responseObject) {
|
|
165
|
+
this.log('iot offline');
|
|
156
166
|
this.emit('offline');
|
|
157
167
|
}
|
|
158
168
|
|
package/src/modules/wt-room.js
CHANGED
|
@@ -1370,6 +1370,7 @@ class RoomSession {
|
|
|
1370
1370
|
|
|
1371
1371
|
let transceiver = config.pc?.getTransceivers()?.find(
|
|
1372
1372
|
t => t.receiver.track === ev.target);
|
|
1373
|
+
|
|
1373
1374
|
let mid = transceiver?.mid || ev.target.id;
|
|
1374
1375
|
|
|
1375
1376
|
if (config.stream) {
|
|
@@ -1850,9 +1851,9 @@ class RoomSession {
|
|
|
1850
1851
|
direction: 'sendonly',
|
|
1851
1852
|
streams: [config.stream],
|
|
1852
1853
|
sendEncodings: [
|
|
1853
|
-
{ rid: 'h', active: true, maxBitrate: bitRates.high },
|
|
1854
|
-
{ rid: 'm', active: true, maxBitrate: bitRates.medium, scaleResolutionDownBy: 2 },
|
|
1855
|
-
{ rid: 'l', active: true, maxBitrate: bitRates.low, scaleResolutionDownBy: 4 }
|
|
1854
|
+
{ rid: 'h', active: true, scalabilityMode: 'L1T2', maxBitrate: bitRates.high },
|
|
1855
|
+
{ rid: 'm', active: true, scalabilityMode: 'L1T2', maxBitrate: bitRates.medium, scaleResolutionDownBy: 2 },
|
|
1856
|
+
{ rid: 'l', active: true, scalabilityMode: 'L1T2', maxBitrate: bitRates.low, scaleResolutionDownBy: 4 }
|
|
1856
1857
|
]
|
|
1857
1858
|
})
|
|
1858
1859
|
}
|