@reactoo/watchtogether-sdk-js 2.7.7 → 2.7.9
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 +1785 -203
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/index.html +91 -35
- package/package.json +2 -2
- package/src/models/asset.js +24 -12
- package/src/models/room-session.js +7 -5
- package/src/models/user.js +21 -9
- package/src/modules/wt-room.js +170 -65
- package/src/modules/wt-utils.js +9 -1
package/example/index.html
CHANGED
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
|
|
33
33
|
//https://studio.reactoo.com/room/edf441b3-7415-49c4-9557-273cb93bc746/LJj4W2Cz-nG3U-lb0R-TAaY-o7Thmb8xHSbE
|
|
34
34
|
|
|
35
|
-
let roomId = "c22ada04-6c95-4524-91d8-e915bcef2e61"; //It will create room automatically if not set
|
|
36
|
-
let pinHash = "OayoOVzK-XmWr-BTID-fVwH-eH44Tn3xSWeR";//'967ca05f-7fab-a205-5913-39393bbbe923';
|
|
35
|
+
let roomId = "c22ada04-6c95-4524-91d8-e915bcef2e61"; // It will create room automatically if not set
|
|
36
|
+
let pinHash = "OayoOVzK-XmWr-BTID-fVwH-eH44Tn3xSWeR";// '967ca05f-7fab-a205-5913-39393bbbe923';
|
|
37
37
|
|
|
38
38
|
let participants = document.querySelector('.participants');
|
|
39
39
|
var video = document.querySelector('.contentVideo');
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
return Instance.room.getSessionByConstructId(constructId).selectSubStream(handleId, substream, source);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function overrideSimulcastSettings(handleId, mid, source, settings) {
|
|
56
|
+
return Instance.room.getSessionByConstructId(constructId).overrideSimulcastSettings(handleId, mid, source, settings);
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
function hento() {
|
|
56
60
|
//Instance.system.getSettings();
|
|
57
61
|
Instance.system.getClient()
|
|
@@ -222,42 +226,94 @@
|
|
|
222
226
|
})
|
|
223
227
|
.then(r => Instance.room.createSession({constructId, roomId:r.roomId, pinHash: r.pinHash, role:'participant', options: {
|
|
224
228
|
simulcast: true,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
229
|
+
simulcastSettings: {
|
|
230
|
+
"default" : {
|
|
231
|
+
mode: "controlled", // controlled, manual, browserController
|
|
232
|
+
defaultSubstream: 0, // 2 lowest quality, 0 highest quality
|
|
233
|
+
bitrates: [
|
|
234
|
+
{
|
|
235
|
+
"rid": "l",
|
|
236
|
+
"active": true,
|
|
237
|
+
"maxBitrate": 180000,
|
|
238
|
+
"maxFramerate": 20,
|
|
239
|
+
"scaleResolutionDownBy": 3.3333333333333335,
|
|
240
|
+
"priority": "low"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"rid": "m",
|
|
244
|
+
"active": true,
|
|
245
|
+
"maxBitrate": 500000,
|
|
246
|
+
"maxFramerate": 25,
|
|
247
|
+
"scaleResolutionDownBy": 1.3333333333333335,
|
|
248
|
+
"priority": "low"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"rid": "h",
|
|
252
|
+
"active": true,
|
|
253
|
+
"maxBitrate": 2000000,
|
|
254
|
+
"maxFramerate": 30,
|
|
255
|
+
"priority": "low"
|
|
256
|
+
}
|
|
257
|
+
]
|
|
244
258
|
},
|
|
245
|
-
{
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
259
|
+
"*camera*" : {
|
|
260
|
+
mode: "controlled",
|
|
261
|
+
defaultSubstream: 0,
|
|
262
|
+
bitrates: [
|
|
263
|
+
{
|
|
264
|
+
"rid": "l",
|
|
265
|
+
"active": true,
|
|
266
|
+
"maxBitrate": 180000,
|
|
267
|
+
"maxFramerate": 20,
|
|
268
|
+
"scaleResolutionDownBy": 3.3333333333333335,
|
|
269
|
+
"priority": "low"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"rid": "m",
|
|
273
|
+
"active": true,
|
|
274
|
+
"maxBitrate": 500000,
|
|
275
|
+
"maxFramerate": 25,
|
|
276
|
+
"scaleResolutionDownBy": 1.3333333333333335,
|
|
277
|
+
"priority": "low"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"rid": "h",
|
|
281
|
+
"active": true,
|
|
282
|
+
"maxBitrate": 2000000,
|
|
283
|
+
"maxFramerate": 30,
|
|
284
|
+
"priority": "low"
|
|
285
|
+
}
|
|
286
|
+
]
|
|
252
287
|
},
|
|
253
|
-
{
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
288
|
+
"*screen*": {
|
|
289
|
+
mode: "manual",
|
|
290
|
+
defaultSubstream: 0,
|
|
291
|
+
bitrates: [
|
|
292
|
+
{
|
|
293
|
+
"rid": "l",
|
|
294
|
+
"active": true,
|
|
295
|
+
"maxBitrate": 270000,
|
|
296
|
+
"maxFramerate": 5,
|
|
297
|
+
"scaleResolutionDownBy": 1.3333333333333335,
|
|
298
|
+
"priority": "low"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
"rid": "m",
|
|
302
|
+
"active": true,
|
|
303
|
+
"maxBitrate": 500000,
|
|
304
|
+
"maxFramerate": 10,
|
|
305
|
+
"priority": "low"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"rid": "h",
|
|
309
|
+
"active": true,
|
|
310
|
+
"maxBitrate": 2000000,
|
|
311
|
+
"maxFramerate": 30,
|
|
312
|
+
"priority": "low"
|
|
313
|
+
}
|
|
314
|
+
]
|
|
259
315
|
}
|
|
260
|
-
|
|
316
|
+
},
|
|
261
317
|
//subscriptionRules: {participant: {videoWall: [], watchTogether: []}}
|
|
262
318
|
}}))
|
|
263
319
|
.then(session => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactoo/watchtogether-sdk-js",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.9",
|
|
4
4
|
"description": "Javascript SDK for Reactoo",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"unpkg": "dist/watchtogether-sdk.min.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"aws-iot-device-sdk": "^2.2.11",
|
|
46
46
|
"serialize-error": "9.1.0",
|
|
47
47
|
"swagger-client": "3.18.0",
|
|
48
|
-
"webrtc-adapter": "^
|
|
48
|
+
"webrtc-adapter": "^9.0.1"
|
|
49
49
|
},
|
|
50
50
|
"browserslist": [
|
|
51
51
|
"> 0.5%",
|
package/src/models/asset.js
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import {generateUUID} from "../modules/wt-utils";
|
|
3
|
+
import {generateUUID, chunkArray} from "../modules/wt-utils";
|
|
4
4
|
|
|
5
5
|
let asset = function() {
|
|
6
6
|
return {
|
|
7
7
|
getAssetList: ({type = 'instanceType', instanceType, assetType, size = 20, startKey = null, roomId, ids}) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
return chunkArray(ids, 50)
|
|
9
|
+
.reduce((promiseChain, idsChunk) => {
|
|
10
|
+
return promiseChain.then(chainResponse => {
|
|
11
|
+
let apiParams = {
|
|
12
|
+
type,
|
|
13
|
+
...(instanceType && {instanceType: instanceType === true ? this.__instanceType : instanceType }),
|
|
14
|
+
...(assetType && {assetType}),
|
|
15
|
+
...(size && !ids && {size}),
|
|
16
|
+
...(idsChunk?.length && {ids: idsChunk.join(',')}),
|
|
17
|
+
...(roomId && {roomId}),
|
|
18
|
+
...(startKey && {startKey})
|
|
19
|
+
};
|
|
20
|
+
return this.__privates.auth.__client
|
|
21
|
+
.then(client => client.apis.asset.getAssetList(apiParams))
|
|
22
|
+
.then(response => type === 'ids' ? {
|
|
23
|
+
data: {
|
|
24
|
+
items: [...chainResponse.data.items, ...response.data.items],
|
|
25
|
+
size: chainResponse.data.size + response.data.size,
|
|
26
|
+
startKey: null,
|
|
27
|
+
},
|
|
28
|
+
} : response);
|
|
29
|
+
});
|
|
30
|
+
}, Promise.resolve({data: {items: [], size: 0, startKey: null}}));
|
|
19
31
|
},
|
|
20
32
|
getAssetById: (id) => {
|
|
21
33
|
return this.__privates.auth.__client
|
|
@@ -21,7 +21,7 @@ import syncModule from "../modules/sync-modules/sync-module";
|
|
|
21
21
|
let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
|
|
22
22
|
|
|
23
23
|
let primaryRoomId = roomId;
|
|
24
|
-
let {simulcast = null,
|
|
24
|
+
let {simulcast = null, simulcastSettings = null, enableDtx = null, subscriptionRules = null} = options;
|
|
25
25
|
let publicCustomEvents = ['changePlayerSource', 'chatMessage', 'userUpdate', 'reconnecting', 'connecting', 'remoteMuted', 'scaling'];
|
|
26
26
|
|
|
27
27
|
const addEvents = (events) => {
|
|
@@ -118,10 +118,8 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
|
|
|
118
118
|
roomData.data.webrtcVersion,
|
|
119
119
|
(roomData.data.bitrate ? parseInt(roomData.data.bitrate) : 0),
|
|
120
120
|
roomData.data.recordingFilename,
|
|
121
|
-
simulcast !== null ? simulcast : roomData?.data?.simulcast,
|
|
122
|
-
|
|
123
|
-
simulcastMode !== null ? simulcastMode : roomData?.data?.simulcast?.mode,
|
|
124
|
-
simulcastDefaultManualSubstream !== null ? simulcastDefaultManualSubstream : roomData?.data?.simulcast?.defaultManualSubstream,
|
|
121
|
+
simulcast !== null ? simulcast : !!roomData?.data?.simulcast,
|
|
122
|
+
simulcastSettings !== null ? simulcastSettings : roomData?.data?.simulcast,
|
|
125
123
|
enableDtx !== null ? enableDtx : roomData?.data?.enableDtx,
|
|
126
124
|
)
|
|
127
125
|
})
|
|
@@ -384,6 +382,10 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
|
|
|
384
382
|
}).catch(() => null)
|
|
385
383
|
},
|
|
386
384
|
|
|
385
|
+
overrideSimulcastSettings: (handleId, mid, source, settings) => {
|
|
386
|
+
return room.overrideSimulcastSettings(handleId, mid, source, settings);
|
|
387
|
+
},
|
|
388
|
+
|
|
387
389
|
sendSystemMessage: (action, value = {}, to, set_master) => {
|
|
388
390
|
return room.sendMessage(room.handleId, {
|
|
389
391
|
body: {
|
package/src/models/user.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import {generateUUID} from "../modules/wt-utils";
|
|
3
|
+
import {generateUUID, chunkArray} from "../modules/wt-utils";
|
|
4
4
|
import {serializeError} from "serialize-error";
|
|
5
5
|
|
|
6
6
|
let user = function () {
|
|
@@ -95,14 +95,26 @@ let user = function () {
|
|
|
95
95
|
.then(client => client.apis.user.getUserById({id}))
|
|
96
96
|
},
|
|
97
97
|
getUsersByIds: ({ids = [], size = null, startKey = null } = {}) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
return chunkArray(ids, 50)
|
|
99
|
+
.reduce((promiseChain, idsChunk) => {
|
|
100
|
+
return promiseChain.then(chainResponse => {
|
|
101
|
+
let apiParams = {
|
|
102
|
+
type : 'ids',
|
|
103
|
+
...(size && {size}),
|
|
104
|
+
...(idsChunk?.length && {ids: idsChunk.join(',')}),
|
|
105
|
+
...(startKey && {startKey})
|
|
106
|
+
};
|
|
107
|
+
return this.__privates.auth.__client
|
|
108
|
+
.then(client => client.apis.user.getUsers(apiParams))
|
|
109
|
+
.then(response => ({
|
|
110
|
+
data: {
|
|
111
|
+
items: [...chainResponse.data.items, ...response.data.items],
|
|
112
|
+
size: chainResponse.data.size + response.data.size,
|
|
113
|
+
startKey: null,
|
|
114
|
+
},
|
|
115
|
+
}));
|
|
116
|
+
});
|
|
117
|
+
}, Promise.resolve({data: {items: [], size: 0, startKey: null}}));
|
|
106
118
|
},
|
|
107
119
|
getUsers: ({type, userId, roomId, size = 20, startKey = null} = {}) => {
|
|
108
120
|
let apiParams = {
|