@needle-tools/engine 2.30.0-pre → 2.31.0-pre
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 +4 -0
- package/dist/needle-engine.d.ts +807 -753
- package/dist/needle-engine.js +336 -336
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +16 -16
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/engine_physics.d.ts +19 -8
- package/lib/engine/engine_physics.js +57 -48
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine-components/Camera.js +0 -1
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/Component.d.ts +10 -0
- package/lib/engine-components/Component.js +53 -0
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/Rigidbody.d.ts +1 -1
- package/lib/engine-components/Rigidbody.js +3 -3
- package/lib/engine-components/Rigidbody.js.map +1 -1
- package/lib/engine-components/ScreenCapture.d.ts +35 -6
- package/lib/engine-components/ScreenCapture.js +356 -103
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +4 -0
- package/lib/engine-components/VideoPlayer.js +22 -1
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/needle-engine.d.ts +1 -0
- package/lib/needle-engine.js +1 -0
- package/lib/needle-engine.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_physics.ts +74 -57
- package/src/engine-components/Camera.ts +0 -1
- package/src/engine-components/Component.ts +58 -0
- package/src/engine-components/RigidBody.ts +2 -2
- package/src/engine-components/ScreenCapture.ts +386 -114
- package/src/engine-components/VideoPlayer.ts +26 -2
- package/src/needle-engine.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rigidbody.js","sourceRoot":"","sources":["../../../engine-components/Rigidbody.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC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YAC9B,MAAM,EAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7C,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC5D,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;SACvF;IACL,CAAC;;AApKD;IADC,aAAa,EAAE;uCACC;AAGjB;IADC,aAAa,EAAE;4CAMf;AAQD;IADC,aAAa,EAAE;uCACC;AAEjB;IADC,aAAa,EAAE;8CACQ;AAExB;IADC,aAAa,EAAE;mDACiB;AAEjC;IADC,aAAa,EAAE;iDACc"}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
import { Behaviour } from "./Component";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { IPointerClickHandler } from "./ui/PointerEvents";
|
|
3
|
+
export declare enum ScreenCaptureDevice {
|
|
4
|
+
Screen = 0,
|
|
5
|
+
Camera = 1
|
|
6
|
+
}
|
|
7
|
+
export declare enum ScreenCaptureMode {
|
|
8
|
+
Idle = 0,
|
|
9
|
+
Sending = 1,
|
|
10
|
+
Receiving = 2
|
|
11
|
+
}
|
|
12
|
+
export declare enum AspectMode {
|
|
13
|
+
None = 0,
|
|
14
|
+
AdjustHeight = 1,
|
|
15
|
+
AdjustWidth = 2
|
|
16
|
+
}
|
|
17
|
+
export declare class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
18
|
+
onPointerClick(): void;
|
|
19
|
+
device: ScreenCaptureDevice;
|
|
20
|
+
aspectMode: AspectMode;
|
|
21
|
+
get isSending(): boolean | null;
|
|
22
|
+
get isReceiving(): boolean | null;
|
|
23
|
+
private _net?;
|
|
24
|
+
private _video?;
|
|
25
|
+
private _requestOpen;
|
|
26
|
+
private _currentStream;
|
|
27
|
+
private _currentMode;
|
|
28
|
+
awake(): void;
|
|
4
29
|
start(): void;
|
|
5
|
-
|
|
6
|
-
private captureStream;
|
|
7
|
-
open(force?: boolean): Promise<void>;
|
|
30
|
+
share(): Promise<void>;
|
|
8
31
|
close(): void;
|
|
9
|
-
private
|
|
32
|
+
private setVideo;
|
|
33
|
+
private onReceiveVideo;
|
|
34
|
+
private tryShareUserCamera;
|
|
35
|
+
private _targetObjects?;
|
|
36
|
+
private updateAspect;
|
|
37
|
+
private _updateAspectRoutineId;
|
|
38
|
+
private updateAspectImpl;
|
|
10
39
|
}
|
|
@@ -9,71 +9,246 @@ import { VideoPlayer } from "./VideoPlayer";
|
|
|
9
9
|
import Peer from "peerjs";
|
|
10
10
|
import { RoomEvents } from "../engine/engine_networking";
|
|
11
11
|
import { serializeable } from "../engine/engine_serialization";
|
|
12
|
+
import { EventDispatcher } from "three";
|
|
13
|
+
import { AudioSource } from "./AudioSource";
|
|
14
|
+
import { getWorldScale } from "../engine/engine_three_utils";
|
|
15
|
+
export var ScreenCaptureDevice;
|
|
16
|
+
(function (ScreenCaptureDevice) {
|
|
17
|
+
ScreenCaptureDevice[ScreenCaptureDevice["Screen"] = 0] = "Screen";
|
|
18
|
+
ScreenCaptureDevice[ScreenCaptureDevice["Camera"] = 1] = "Camera";
|
|
19
|
+
})(ScreenCaptureDevice || (ScreenCaptureDevice = {}));
|
|
20
|
+
export var ScreenCaptureMode;
|
|
21
|
+
(function (ScreenCaptureMode) {
|
|
22
|
+
ScreenCaptureMode[ScreenCaptureMode["Idle"] = 0] = "Idle";
|
|
23
|
+
ScreenCaptureMode[ScreenCaptureMode["Sending"] = 1] = "Sending";
|
|
24
|
+
ScreenCaptureMode[ScreenCaptureMode["Receiving"] = 2] = "Receiving";
|
|
25
|
+
})(ScreenCaptureMode || (ScreenCaptureMode = {}));
|
|
26
|
+
export var AspectMode;
|
|
27
|
+
(function (AspectMode) {
|
|
28
|
+
AspectMode[AspectMode["None"] = 0] = "None";
|
|
29
|
+
AspectMode[AspectMode["AdjustHeight"] = 1] = "AdjustHeight";
|
|
30
|
+
AspectMode[AspectMode["AdjustWidth"] = 2] = "AdjustWidth";
|
|
31
|
+
})(AspectMode || (AspectMode = {}));
|
|
32
|
+
function disposeStream(str) {
|
|
33
|
+
if (!str)
|
|
34
|
+
return;
|
|
35
|
+
for (const cap of str.getTracks())
|
|
36
|
+
cap.stop();
|
|
37
|
+
}
|
|
12
38
|
export class ScreenCapture extends Behaviour {
|
|
13
|
-
|
|
39
|
+
onPointerClick() {
|
|
40
|
+
if (this.isSending) {
|
|
41
|
+
this.close();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.share();
|
|
45
|
+
}
|
|
46
|
+
device = ScreenCaptureDevice.Screen;
|
|
47
|
+
aspectMode = AspectMode.AdjustHeight;
|
|
48
|
+
get isSending() {
|
|
49
|
+
return this._currentStream && this._currentMode === ScreenCaptureMode.Sending;
|
|
50
|
+
}
|
|
51
|
+
get isReceiving() {
|
|
52
|
+
return this._currentStream && this._currentMode === ScreenCaptureMode.Receiving;
|
|
53
|
+
}
|
|
54
|
+
_net;
|
|
55
|
+
_video;
|
|
56
|
+
_requestOpen = false;
|
|
57
|
+
_currentStream = null;
|
|
58
|
+
_currentMode = ScreenCaptureMode.Idle;
|
|
59
|
+
awake() {
|
|
60
|
+
AudioSource.registerWaitForAllowAudio(() => {
|
|
61
|
+
if (this._video && this._currentStream && this._currentMode === ScreenCaptureMode.Receiving) {
|
|
62
|
+
this._video.setVideo(this._currentStream);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
14
66
|
start() {
|
|
15
|
-
|
|
16
|
-
if (this.
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
requestOpen = false;
|
|
20
|
-
captureStream = null;
|
|
21
|
-
async open(force = false) {
|
|
22
|
-
if (this.captureStream && !force)
|
|
67
|
+
this._video = GameObject.getComponentInChildren(this.gameObject, VideoPlayer) ?? undefined;
|
|
68
|
+
if (!this._video) {
|
|
69
|
+
console.error("Missing VideoPlayer component");
|
|
23
70
|
return;
|
|
24
|
-
|
|
25
|
-
this.
|
|
71
|
+
}
|
|
72
|
+
const handle = PeerHandle.getOrCreate(this.context, this.guid);
|
|
73
|
+
this._net = new NetworkedVideo(this.context, handle);
|
|
74
|
+
this._net.enable();
|
|
75
|
+
//@ts-ignore
|
|
76
|
+
this._net.addEventListener(PeerEvent.ReceiveVideo, this.onReceiveVideo.bind(this));
|
|
77
|
+
}
|
|
78
|
+
async share() {
|
|
79
|
+
this._requestOpen = true;
|
|
26
80
|
try {
|
|
27
|
-
|
|
28
|
-
|
|
81
|
+
if (this._video) {
|
|
82
|
+
const settings = {
|
|
83
|
+
echoCancellation: true,
|
|
84
|
+
autoGainControl: false,
|
|
85
|
+
};
|
|
29
86
|
const displayMediaOptions = {
|
|
30
|
-
video:
|
|
31
|
-
audio:
|
|
87
|
+
video: settings,
|
|
88
|
+
audio: settings,
|
|
32
89
|
};
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
90
|
+
switch (this.device) {
|
|
91
|
+
case ScreenCaptureDevice.Camera:
|
|
92
|
+
this.tryShareUserCamera(displayMediaOptions);
|
|
93
|
+
break;
|
|
94
|
+
case ScreenCaptureDevice.Screen:
|
|
95
|
+
if (!navigator.mediaDevices.getDisplayMedia) {
|
|
96
|
+
console.error("No getDisplayMedia support");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const myVideo = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
|
|
100
|
+
if (this._requestOpen) {
|
|
101
|
+
this.setVideo(myVideo, ScreenCaptureMode.Sending);
|
|
102
|
+
}
|
|
103
|
+
else
|
|
104
|
+
disposeStream(myVideo);
|
|
105
|
+
break;
|
|
38
106
|
}
|
|
39
|
-
this.handleNetworkedVideo();
|
|
40
107
|
}
|
|
41
108
|
}
|
|
42
109
|
catch (err) {
|
|
43
|
-
|
|
110
|
+
if (err.name === "NotAllowedError") {
|
|
111
|
+
// user cancelled stream selection
|
|
112
|
+
console.log("Selection cancelled");
|
|
113
|
+
this._requestOpen = false;
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
console.error("Error opening video", err);
|
|
44
117
|
}
|
|
45
118
|
}
|
|
46
119
|
close() {
|
|
47
|
-
this.
|
|
48
|
-
if (this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.
|
|
120
|
+
this._requestOpen = false;
|
|
121
|
+
if (this._currentStream) {
|
|
122
|
+
console.warn("Close current stream / disposing resources");
|
|
123
|
+
disposeStream(this._currentStream);
|
|
124
|
+
this._net?.stopSendingVideo(this._currentStream);
|
|
125
|
+
this._currentMode = ScreenCaptureMode.Idle;
|
|
126
|
+
this._currentStream = null;
|
|
52
127
|
}
|
|
53
128
|
}
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
129
|
+
setVideo(stream, mode) {
|
|
130
|
+
if (stream === this._currentStream)
|
|
131
|
+
return;
|
|
132
|
+
this.close();
|
|
133
|
+
if (!stream || !this._video)
|
|
57
134
|
return;
|
|
135
|
+
this._currentStream = stream;
|
|
136
|
+
this._requestOpen = true;
|
|
137
|
+
this._currentMode = mode;
|
|
138
|
+
this._video.setVideo(stream);
|
|
139
|
+
if (mode === ScreenCaptureMode.Sending)
|
|
140
|
+
this._net?.startSendingVideo(stream);
|
|
141
|
+
this._targetObjects = undefined;
|
|
142
|
+
this.updateAspect();
|
|
143
|
+
}
|
|
144
|
+
onReceiveVideo(evt) {
|
|
145
|
+
this.setVideo(evt.stream, ScreenCaptureMode.Receiving);
|
|
146
|
+
}
|
|
147
|
+
async tryShareUserCamera(opts) {
|
|
148
|
+
// let newWindow = open('', 'example', 'width=300,height=300');
|
|
149
|
+
// if (window) {
|
|
150
|
+
// newWindow!.document.body.innerHTML = "Please allow access to your camera and microphone";
|
|
151
|
+
// }
|
|
152
|
+
// TODO: allow user to select device
|
|
153
|
+
const devices = (await navigator.mediaDevices.enumerateDevices()).filter(d => d.kind === "videoinput");
|
|
154
|
+
console.log("Request camera", devices);
|
|
155
|
+
for (const dev of devices) {
|
|
156
|
+
try {
|
|
157
|
+
if (!this._requestOpen)
|
|
158
|
+
break;
|
|
159
|
+
if (dev.kind !== "videoinput")
|
|
160
|
+
continue;
|
|
161
|
+
const id = dev.deviceId;
|
|
162
|
+
if (opts.video !== false) {
|
|
163
|
+
if (typeof opts.video === "undefined" || typeof opts.video === "boolean") {
|
|
164
|
+
opts.video = {};
|
|
165
|
+
}
|
|
166
|
+
opts.video.deviceId = id;
|
|
167
|
+
}
|
|
168
|
+
const userMedia = await navigator.mediaDevices.getUserMedia(opts);
|
|
169
|
+
if (this._requestOpen) {
|
|
170
|
+
this.setVideo(userMedia, ScreenCaptureMode.Sending);
|
|
171
|
+
}
|
|
172
|
+
else
|
|
173
|
+
disposeStream(userMedia);
|
|
174
|
+
console.log("Selected camera", dev);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
console.warn(err);
|
|
179
|
+
}
|
|
58
180
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
181
|
+
}
|
|
182
|
+
// private _cameraSelectionWindow : Window | null = null;
|
|
183
|
+
// private openWindowToSelectCamera(){
|
|
184
|
+
// }
|
|
185
|
+
_targetObjects;
|
|
186
|
+
updateAspect() {
|
|
187
|
+
this.startCoroutine(this.updateAspectImpl());
|
|
188
|
+
}
|
|
189
|
+
_updateAspectRoutineId = -1;
|
|
190
|
+
*updateAspectImpl() {
|
|
191
|
+
const id = ++this._updateAspectRoutineId;
|
|
192
|
+
while (this.aspectMode !== AspectMode.None && this._currentStream && id === this._updateAspectRoutineId) {
|
|
193
|
+
const video = this._video;
|
|
194
|
+
const stream = this._currentStream;
|
|
195
|
+
if (!video)
|
|
196
|
+
return;
|
|
197
|
+
if (!stream)
|
|
198
|
+
return;
|
|
199
|
+
let aspect = undefined;
|
|
200
|
+
for (const track of stream.getVideoTracks()) {
|
|
201
|
+
const settings = track.getSettings();
|
|
202
|
+
if (settings.width && settings.height) {
|
|
203
|
+
aspect = settings.width / settings.height;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (aspect === undefined)
|
|
208
|
+
return;
|
|
209
|
+
if (!this._targetObjects)
|
|
210
|
+
this._targetObjects = video.getTargetObjects();
|
|
211
|
+
for (const obj of this._targetObjects) {
|
|
212
|
+
let worldAspect = 1;
|
|
213
|
+
if (obj.parent) {
|
|
214
|
+
const parentScale = getWorldScale(obj.parent);
|
|
215
|
+
worldAspect = parentScale.x / parentScale.y;
|
|
216
|
+
}
|
|
217
|
+
switch (this.aspectMode) {
|
|
218
|
+
case AspectMode.AdjustHeight:
|
|
219
|
+
obj.scale.y = 1 / aspect * obj.scale.x * worldAspect;
|
|
220
|
+
break;
|
|
221
|
+
case AspectMode.AdjustWidth:
|
|
222
|
+
obj.scale.x = aspect * obj.scale.y * worldAspect;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
yield;
|
|
67
227
|
}
|
|
68
228
|
}
|
|
69
229
|
}
|
|
70
230
|
__decorate([
|
|
71
231
|
serializeable()
|
|
72
|
-
], ScreenCapture.prototype, "
|
|
73
|
-
|
|
74
|
-
(
|
|
75
|
-
|
|
76
|
-
|
|
232
|
+
], ScreenCapture.prototype, "device", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
serializeable()
|
|
235
|
+
], ScreenCapture.prototype, "aspectMode", void 0);
|
|
236
|
+
/////// PEER
|
|
237
|
+
var PeerEvent;
|
|
238
|
+
(function (PeerEvent) {
|
|
239
|
+
PeerEvent["Connected"] = "peer-user-connected";
|
|
240
|
+
PeerEvent["ReceiveVideo"] = "receive-video";
|
|
241
|
+
PeerEvent["Disconnected"] = "peer-user-disconnected";
|
|
242
|
+
})(PeerEvent || (PeerEvent = {}));
|
|
243
|
+
class ReceiveVideoEvent {
|
|
244
|
+
type = PeerEvent.ReceiveVideo;
|
|
245
|
+
stream;
|
|
246
|
+
target;
|
|
247
|
+
constructor(stream, target) {
|
|
248
|
+
this.stream = stream;
|
|
249
|
+
this.target = target;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
77
252
|
class PeerUserConnectedModel {
|
|
78
253
|
/** the peer handle id */
|
|
79
254
|
guid;
|
|
@@ -90,20 +265,44 @@ var CallDirection;
|
|
|
90
265
|
CallDirection["Incoming"] = "incoming";
|
|
91
266
|
CallDirection["Outgoing"] = "outgoing";
|
|
92
267
|
})(CallDirection || (CallDirection = {}));
|
|
93
|
-
class CallHandle {
|
|
268
|
+
class CallHandle extends EventDispatcher {
|
|
269
|
+
userId;
|
|
94
270
|
direction;
|
|
95
271
|
call;
|
|
96
|
-
stream;
|
|
97
|
-
|
|
272
|
+
get stream() { return this._stream; }
|
|
273
|
+
;
|
|
274
|
+
_stream = null;
|
|
275
|
+
_isDisposed = false;
|
|
276
|
+
close() {
|
|
277
|
+
if (this._isDisposed)
|
|
278
|
+
return;
|
|
279
|
+
this._isDisposed = true;
|
|
280
|
+
this.call.close();
|
|
281
|
+
disposeStream(this._stream);
|
|
282
|
+
}
|
|
283
|
+
get isOpen() {
|
|
284
|
+
return this.call.peerConnection?.connectionState === "connected"; // && this._stream?.active;
|
|
285
|
+
}
|
|
286
|
+
get isClosed() {
|
|
287
|
+
return !this.isOpen;
|
|
288
|
+
}
|
|
289
|
+
constructor(userId, call, direction) {
|
|
290
|
+
super();
|
|
291
|
+
this.userId = userId;
|
|
98
292
|
this.call = call;
|
|
99
293
|
this.direction = direction;
|
|
100
|
-
this.
|
|
294
|
+
this._stream = null;
|
|
101
295
|
call.on("stream", stream => {
|
|
102
|
-
|
|
296
|
+
console.log("Receive video", stream.getAudioTracks(), stream.getVideoTracks());
|
|
297
|
+
this._stream = stream;
|
|
298
|
+
if (direction === CallDirection.Incoming) {
|
|
299
|
+
const args = new ReceiveVideoEvent(stream, this);
|
|
300
|
+
this.dispatchEvent(args);
|
|
301
|
+
}
|
|
103
302
|
});
|
|
104
303
|
}
|
|
105
304
|
}
|
|
106
|
-
class PeerHandle {
|
|
305
|
+
class PeerHandle extends EventDispatcher {
|
|
107
306
|
static instances = new Map();
|
|
108
307
|
static getOrCreate(context, guid) {
|
|
109
308
|
// if (id === undefined) {
|
|
@@ -116,6 +315,11 @@ class PeerHandle {
|
|
|
116
315
|
PeerHandle.instances.set(guid, peer);
|
|
117
316
|
return peer;
|
|
118
317
|
}
|
|
318
|
+
getMyPeerId() {
|
|
319
|
+
if (this.context.connection.connectionId)
|
|
320
|
+
return this.getPeerIdFromUserId(this.context.connection.connectionId);
|
|
321
|
+
return undefined;
|
|
322
|
+
}
|
|
119
323
|
getPeerIdFromUserId(userConnectionId) {
|
|
120
324
|
// we build the peer id ourselves so we dont need to wait for peer to report it
|
|
121
325
|
return this.id + "-" + userConnectionId;
|
|
@@ -124,13 +328,8 @@ class PeerHandle {
|
|
|
124
328
|
return peerId.substring(this.id.length + 1);
|
|
125
329
|
}
|
|
126
330
|
makeCall(peerId, stream) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// return;
|
|
130
|
-
// }
|
|
131
|
-
// const peerId = this.getUserPeerId(userId);
|
|
132
|
-
console.log("CALL", peerId);
|
|
133
|
-
const call = this._peer?.call(peerId, stream);
|
|
331
|
+
const opts = { metadata: { userId: this.context.connection.connectionId } };
|
|
332
|
+
const call = this._peer?.call(peerId, stream, opts);
|
|
134
333
|
if (call)
|
|
135
334
|
return this.registerCall(call, CallDirection.Outgoing);
|
|
136
335
|
return undefined;
|
|
@@ -142,6 +341,7 @@ class PeerHandle {
|
|
|
142
341
|
_incomingCalls = [];
|
|
143
342
|
_outgoingCalls = [];
|
|
144
343
|
constructor(context, id) {
|
|
344
|
+
super();
|
|
145
345
|
this.context = context;
|
|
146
346
|
this.id = id;
|
|
147
347
|
this.setupPeer();
|
|
@@ -187,7 +387,7 @@ class PeerHandle {
|
|
|
187
387
|
return;
|
|
188
388
|
this._enabledPeer = true;
|
|
189
389
|
if (!this._peer) {
|
|
190
|
-
const peerId = this.
|
|
390
|
+
const peerId = this.getMyPeerId();
|
|
191
391
|
this._peer = new Peer(peerId);
|
|
192
392
|
}
|
|
193
393
|
if (this._enabled)
|
|
@@ -201,51 +401,74 @@ class PeerHandle {
|
|
|
201
401
|
// this.context.connection.beginListen(PeerEvent.Connected, this.onRemotePeerConnect.bind(this));
|
|
202
402
|
}
|
|
203
403
|
unsubscribePeerEvents() {
|
|
404
|
+
// TODO: unsubscribe
|
|
204
405
|
}
|
|
205
406
|
onPeerConnect(id) {
|
|
206
|
-
console.log("
|
|
207
|
-
this.context.connection.send(
|
|
407
|
+
console.log("Peer connected as", id);
|
|
408
|
+
this.context.connection.send(PeerEvent.Connected, new PeerUserConnectedModel(this, id));
|
|
208
409
|
}
|
|
209
410
|
onPeerReceivingCall(call) {
|
|
210
|
-
console.log("RECEIVE CALL");
|
|
211
411
|
call.answer();
|
|
212
412
|
this.registerCall(call, CallDirection.Incoming);
|
|
213
413
|
}
|
|
214
414
|
registerCall(call, direction) {
|
|
415
|
+
const meta = call.metadata;
|
|
416
|
+
if (!meta || !meta.userId) {
|
|
417
|
+
console.error("Missing call metadata", call);
|
|
418
|
+
}
|
|
419
|
+
const userId = meta.userId;
|
|
420
|
+
if (direction === CallDirection.Incoming)
|
|
421
|
+
console.log("Receive call from", call.metadata);
|
|
422
|
+
else
|
|
423
|
+
console.log("Make call to", call.metadata);
|
|
215
424
|
const arr = direction === CallDirection.Incoming ? this._incomingCalls : this._outgoingCalls;
|
|
216
|
-
const handle = new CallHandle(call, direction);
|
|
425
|
+
const handle = new CallHandle(userId, call, direction);
|
|
217
426
|
arr.push(handle);
|
|
218
427
|
call.on("error", err => {
|
|
219
|
-
console.error(err);
|
|
428
|
+
console.error("Call error", err);
|
|
220
429
|
});
|
|
221
430
|
call.on("close", () => {
|
|
431
|
+
console.log("Call ended", call.metadata);
|
|
432
|
+
call.close();
|
|
222
433
|
const index = arr.indexOf(handle);
|
|
223
434
|
if (index !== -1)
|
|
224
435
|
arr.splice(index, 1);
|
|
225
436
|
});
|
|
437
|
+
if (direction === CallDirection.Incoming) {
|
|
438
|
+
handle.addEventListener(PeerEvent.ReceiveVideo, e => {
|
|
439
|
+
this.dispatchEvent(e);
|
|
440
|
+
});
|
|
441
|
+
call.on("stream", () => {
|
|
442
|
+
// workaround for https://github.com/peers/peerjs/issues/636
|
|
443
|
+
let closeInterval = setInterval(() => {
|
|
444
|
+
if (!handle.isOpen) {
|
|
445
|
+
clearInterval(closeInterval);
|
|
446
|
+
handle.close();
|
|
447
|
+
}
|
|
448
|
+
}, 2000);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
226
451
|
return handle;
|
|
227
452
|
}
|
|
228
453
|
}
|
|
229
|
-
|
|
454
|
+
// type UserVideoCall = {
|
|
455
|
+
// call: Peer.MediaConnection;
|
|
456
|
+
// stream: MediaStream;
|
|
457
|
+
// userId: string;
|
|
458
|
+
// }
|
|
459
|
+
// type IncomingStreamArgs = {
|
|
460
|
+
// stream: MediaStream;
|
|
461
|
+
// userId: string;
|
|
462
|
+
// }
|
|
463
|
+
class NetworkedVideo extends EventDispatcher {
|
|
230
464
|
context;
|
|
231
465
|
peer;
|
|
466
|
+
// private _receiveVideoStreamListeners: Array<(info: IncomingStreamArgs) => void> = [];
|
|
232
467
|
_sendingVideoStreams = new Map();
|
|
233
468
|
constructor(context, peer) {
|
|
469
|
+
super();
|
|
234
470
|
this.context = context;
|
|
235
471
|
this.peer = peer;
|
|
236
|
-
// this.peer.on("open", (id) => {
|
|
237
|
-
// console.log("PEERID", id);
|
|
238
|
-
// });
|
|
239
|
-
// // this.peer.on("call", (call) => {
|
|
240
|
-
// // });
|
|
241
|
-
// // this.peer.on("connection", (conn) => {
|
|
242
|
-
// // });
|
|
243
|
-
// // this.peer.on("error", (err) => {
|
|
244
|
-
// // });
|
|
245
|
-
// // this.peer.on("disconnected", () => {
|
|
246
|
-
// // });
|
|
247
|
-
// // this.peer.on("close", () => {
|
|
248
|
-
// // });
|
|
249
472
|
}
|
|
250
473
|
startSendingVideo(stream) {
|
|
251
474
|
if (!this._sendingVideoStreams.has(stream)) {
|
|
@@ -255,54 +478,84 @@ class NetworkedVideo {
|
|
|
255
478
|
;
|
|
256
479
|
}
|
|
257
480
|
stopSendingVideo(_steam) {
|
|
481
|
+
if (_steam) {
|
|
482
|
+
const calls = this._sendingVideoStreams.get(_steam);
|
|
483
|
+
if (calls) {
|
|
484
|
+
for (const call of calls) {
|
|
485
|
+
call.close();
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
this._sendingVideoStreams.delete(_steam);
|
|
489
|
+
if (calls)
|
|
490
|
+
console.log("Currently sending", this._sendingVideoStreams);
|
|
491
|
+
}
|
|
258
492
|
}
|
|
259
493
|
onConnectRoomFn = this.onConnectRoom.bind(this);
|
|
260
494
|
onUserConnectedFn = this.onUserConnected.bind(this);
|
|
261
495
|
onUserLeftFn = this.onUserLeft.bind(this);
|
|
262
496
|
enable() {
|
|
263
|
-
this.
|
|
497
|
+
this.peer.enable();
|
|
498
|
+
this.context.connection.beginListen(PeerEvent.Connected, this.onUserConnectedFn);
|
|
499
|
+
this.peer.addEventListener("receive-video", this.onReceiveVideo.bind(this));
|
|
264
500
|
}
|
|
265
501
|
disable() {
|
|
502
|
+
this.peer.disable();
|
|
266
503
|
// this.context.connection.stopListening(RoomEvents.UserJoinedRoom, this.onUserConnectedFn);
|
|
267
504
|
// this.context.connection.stopListening(RoomEvents.UserLeftRoom, this.onUserLeftFn);
|
|
268
505
|
}
|
|
506
|
+
onReceiveVideo(evt) {
|
|
507
|
+
console.log("RECEIVE VIDEO", evt);
|
|
508
|
+
this.dispatchEvent({ type: "receive-video", target: this, stream: evt.stream, userId: evt.userId });
|
|
509
|
+
}
|
|
269
510
|
onConnectRoom() {
|
|
270
511
|
}
|
|
271
512
|
onUserConnected(user) {
|
|
272
513
|
// console.log(this.peer.id, user.guid)
|
|
273
514
|
if (this.peer.id === user.guid) {
|
|
274
515
|
console.log("USER CONNECTED", user);
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
// this.updateSendingCalls();
|
|
278
|
-
const call = this.peer.makeCall(user.peerId, this._sendingVideoStreams.keys().next().value);
|
|
279
|
-
// for (const userId of this.context.connection.usersInRoom()) {
|
|
280
|
-
// const id = this.peer.getPeerIdFromUserId(userId);
|
|
281
|
-
// if(id === user.peerId) console.log(userId);
|
|
282
|
-
// }
|
|
516
|
+
const stream = this._sendingVideoStreams.keys().next().value;
|
|
517
|
+
this.peer.makeCall(user.peerId, stream);
|
|
283
518
|
}
|
|
284
519
|
}
|
|
285
520
|
onUserLeft(_) {
|
|
521
|
+
this.stopCallsToUsersThatAreNotInTheRoomAnymore();
|
|
286
522
|
}
|
|
287
523
|
updateSendingCalls() {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
524
|
+
let startedNewCall = false;
|
|
525
|
+
for (const stream of this._sendingVideoStreams.keys()) {
|
|
526
|
+
const calls = this._sendingVideoStreams.get(stream) || [];
|
|
527
|
+
for (const userId of this.context.connection.usersInRoom()) {
|
|
528
|
+
if (userId === this.context.connection.connectionId)
|
|
529
|
+
continue;
|
|
530
|
+
const existing = calls.find(c => c.userId === userId);
|
|
531
|
+
if (!existing) {
|
|
532
|
+
const handle = this.peer.makeCall(this.peer.getPeerIdFromUserId(userId), stream);
|
|
533
|
+
if (handle) {
|
|
534
|
+
startedNewCall = true;
|
|
535
|
+
calls.push(handle);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
this._sendingVideoStreams.set(stream, calls);
|
|
540
|
+
}
|
|
541
|
+
this.stopCallsToUsersThatAreNotInTheRoomAnymore();
|
|
542
|
+
if (startedNewCall) {
|
|
543
|
+
console.log("Currently sending", this._sendingVideoStreams);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
stopCallsToUsersThatAreNotInTheRoomAnymore() {
|
|
547
|
+
for (const stream of this._sendingVideoStreams.keys()) {
|
|
548
|
+
const calls = this._sendingVideoStreams.get(stream);
|
|
549
|
+
if (!calls)
|
|
550
|
+
continue;
|
|
551
|
+
for (let i = calls.length - 1; i >= 0; i--) {
|
|
552
|
+
const call = calls[i];
|
|
553
|
+
if (!this.context.connection.userIsInRoom(call.userId)) {
|
|
554
|
+
call.close();
|
|
555
|
+
calls.splice(i, 1);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
306
559
|
}
|
|
307
560
|
}
|
|
308
561
|
//# sourceMappingURL=ScreenCapture.js.map
|