warpr 1.0.20 → 1.0.21
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/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "warpr",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Warper is a WebRTC based ultra-low latency video streaming library.",
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@angular/common": "^
|
|
8
|
-
"@angular/core": "^
|
|
7
|
+
"@angular/common": "^19.2.6",
|
|
8
|
+
"@angular/core": "^19.2.6",
|
|
9
9
|
"uuid": "^11.1.0"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
@@ -6,7 +6,6 @@ import { CommonModule } from '@angular/common';
|
|
|
6
6
|
|
|
7
7
|
@Component({
|
|
8
8
|
selector: 'warpr-stream-host',
|
|
9
|
-
standalone: true,
|
|
10
9
|
imports: [CommonModule],
|
|
11
10
|
templateUrl: './stream-host.component.html',
|
|
12
11
|
styleUrl: './stream-host.component.scss'
|
|
@@ -35,7 +34,7 @@ export class StreamHostComponent {
|
|
|
35
34
|
private _streamingService: StreamingService) {
|
|
36
35
|
this._streamingService.Connected.Subscribe((sender, eventArgs) => this.OnConnected());
|
|
37
36
|
this._streamingService.FrameReceived.Subscribe((sender, eventArgs) => this.OnFrameReceived(eventArgs));
|
|
38
|
-
|
|
37
|
+
|
|
39
38
|
this._decoder = new VideoDecoder({
|
|
40
39
|
output: (frame) => this.OnFrameDecoded(frame),
|
|
41
40
|
error: (error) => console.log(error)
|
|
@@ -73,7 +72,7 @@ export class StreamHostComponent {
|
|
|
73
72
|
let message = new PointerInputMessage(event, this._pointerStates, this._canvas!.nativeElement, wheelDelta);
|
|
74
73
|
//console.log(message);
|
|
75
74
|
|
|
76
|
-
this._streamingService.
|
|
75
|
+
this._streamingService.SendControlMessage(message);
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
private OnWheelEvent(event: WheelEvent) {
|
|
@@ -146,7 +145,7 @@ export class StreamHostComponent {
|
|
|
146
145
|
|
|
147
146
|
console.log(`Resized to ${canvasSize.Width} x ${canvasSize.Height}`);
|
|
148
147
|
let message = new ResizeSurfaceMessage(canvasSize.Width, canvasSize.Height);
|
|
149
|
-
this._streamingService.
|
|
148
|
+
this._streamingService.SendControlMessage(message);
|
|
150
149
|
}
|
|
151
150
|
|
|
152
151
|
//Draw new frame
|
|
@@ -12,38 +12,49 @@ import { MessageAssembler } from '../infrastructure/message-assembler';
|
|
|
12
12
|
export class StreamingService {
|
|
13
13
|
|
|
14
14
|
private _peerConnection?: RTCPeerConnection;
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
private
|
|
15
|
+
private _controlConnection?: RTCDataChannel;
|
|
16
|
+
|
|
17
|
+
private _streamConnection?: RTCDataChannel;
|
|
18
|
+
private _messageBuilder?: MessageAssembler;
|
|
19
|
+
|
|
20
|
+
private _auxConnection?: RTCDataChannel;
|
|
18
21
|
|
|
19
22
|
private readonly _events = new EventOwner();
|
|
20
23
|
public readonly FrameReceived = new EventPublisher<StreamingService, EncodedFrame>(this._events);
|
|
21
24
|
public readonly Connected = new EventPublisher<StreamingService, any>(this._events);
|
|
22
25
|
|
|
26
|
+
public readonly ControlMessageReceived = new EventPublisher<StreamingService, any>(this._events);
|
|
27
|
+
public readonly AuxMessageReceived = new EventPublisher<StreamingService, any>(this._events);
|
|
28
|
+
|
|
23
29
|
constructor(
|
|
24
30
|
private _messagingService: MessagingService) {
|
|
25
31
|
|
|
26
|
-
_messagingService.MessageReceived.Subscribe((sender: IMessagingClient<WarprSignalingMessage>, message: WarprSignalingMessage) => this.
|
|
32
|
+
_messagingService.MessageReceived.Subscribe((sender: IMessagingClient<WarprSignalingMessage>, message: WarprSignalingMessage) => this.OnSignalingMessageReceived(sender, message));
|
|
27
33
|
_messagingService.Connect();
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
private Reconnect(configuration: RTCConfiguration) {
|
|
31
37
|
console.log("Establishing peer connection...");
|
|
32
38
|
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this._peerConnection?.close();
|
|
39
|
+
this._controlConnection?.close();
|
|
40
|
+
this._streamConnection?.close();
|
|
36
41
|
this._messageBuilder = new MessageAssembler();
|
|
42
|
+
this._auxConnection?.close();
|
|
43
|
+
this._peerConnection?.close();
|
|
37
44
|
|
|
38
45
|
this._peerConnection = new RTCPeerConnection(configuration);
|
|
39
46
|
this._peerConnection.onicecandidate = (event) => this.OnIceCandidateAdded(event.candidate?.candidate);
|
|
40
47
|
this._peerConnection.ondatachannel = (event) => this.OnDataChannel(event);
|
|
41
48
|
this._peerConnection.onconnectionstatechange = (event) => this.OnConnectionStateChanged();
|
|
42
49
|
}
|
|
43
|
-
|
|
44
|
-
public
|
|
50
|
+
|
|
51
|
+
public SendControlMessage(message: any) {
|
|
45
52
|
let json = JSON.stringify(message);
|
|
46
|
-
this.
|
|
53
|
+
this._controlConnection?.send(json);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public SendAuxMessage(message: any) {
|
|
57
|
+
this._auxConnection?.send(message);
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
private OnConnectionStateChanged() {
|
|
@@ -54,14 +65,22 @@ export class StreamingService {
|
|
|
54
65
|
console.log(`WebRTC data channel ${event.channel.label} connected.`);
|
|
55
66
|
|
|
56
67
|
switch (event.channel.label) {
|
|
57
|
-
case "
|
|
58
|
-
this.
|
|
68
|
+
case "control":
|
|
69
|
+
this._controlConnection = event.channel;
|
|
70
|
+
this._controlConnection.binaryType = "arraybuffer"
|
|
71
|
+
this._controlConnection.onmessage = (event) => this._events.Raise(this.ControlMessageReceived, this, event.data);
|
|
59
72
|
this._events.Raise(this.Connected, this, null);
|
|
60
73
|
break;
|
|
61
|
-
case "
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
74
|
+
case "stream":
|
|
75
|
+
this._streamConnection = event.channel;
|
|
76
|
+
this._streamConnection.binaryType = "arraybuffer"
|
|
77
|
+
this._streamConnection.onmessage = (event) => this.OnLowLatencyMessage(event);
|
|
78
|
+
break;
|
|
79
|
+
case "aux":
|
|
80
|
+
this._auxConnection = event.channel;
|
|
81
|
+
this._auxConnection.binaryType = "arraybuffer"
|
|
82
|
+
this._auxConnection.onmessage = (event) => this._events.Raise(this.AuxMessageReceived, this, event.data);
|
|
83
|
+
this._events.Raise(this.Connected, this, null);
|
|
65
84
|
break;
|
|
66
85
|
}
|
|
67
86
|
}
|
|
@@ -97,7 +116,7 @@ export class StreamingService {
|
|
|
97
116
|
this._messagingService.SendMessage(message);
|
|
98
117
|
}
|
|
99
118
|
|
|
100
|
-
private async
|
|
119
|
+
private async OnSignalingMessageReceived(sender: IMessagingClient<WarprSignalingMessage>, message: WarprSignalingMessage) {
|
|
101
120
|
|
|
102
121
|
switch (message.$type) {
|
|
103
122
|
case WarprSignalingMessageType.PairingCompleteMessage:
|