@livedigital/client 2.2.0 → 2.3.2
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/engine/network/LoadBalancerClient.d.ts +2 -4
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/common.d.ts +1 -4
- package/dist/types/network.d.ts +8 -0
- package/package.json +1 -1
- package/src/engine/PeerConsumer.ts +14 -1
- package/src/engine/index.ts +7 -3
- package/src/engine/network/LoadBalancerClient.ts +3 -3
- package/src/types/common.ts +1 -5
- package/src/types/network.ts +10 -0
package/dist/types/common.d.ts
CHANGED
|
@@ -7,9 +7,6 @@ export declare type SocketResponse = {
|
|
|
7
7
|
errorCode?: string;
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
};
|
|
10
|
-
export declare type GetNodeResponse = {
|
|
11
|
-
webSocketUrl: string;
|
|
12
|
-
};
|
|
13
10
|
export declare type ProduceParams = {
|
|
14
11
|
kind: MediaKind;
|
|
15
12
|
rtpParameters: RtpParameters;
|
|
@@ -52,9 +49,9 @@ export declare type JoinChannelParams = {
|
|
|
52
49
|
channelId: string;
|
|
53
50
|
appId: string;
|
|
54
51
|
sdkSecret: string;
|
|
52
|
+
role: Role;
|
|
55
53
|
uid?: string;
|
|
56
54
|
appData?: Record<string, unknown>;
|
|
57
|
-
role: Role;
|
|
58
55
|
};
|
|
59
56
|
export declare type ChannelEvent = {
|
|
60
57
|
eventName: string;
|
package/package.json
CHANGED
|
@@ -90,17 +90,30 @@ class PeerConsumer {
|
|
|
90
90
|
|
|
91
91
|
setSpatialLayersParams(): void {
|
|
92
92
|
const { encodings } = this.appData.producerData;
|
|
93
|
+
if (!encodings) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
this.availableSpatialLayers = encodings.map((encoding) => this.parseSpatialLayerParams(encoding));
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
setCurrentSpatialLayerParams(): void {
|
|
97
101
|
const { encodings } = this.appData.producerData;
|
|
102
|
+
if (!encodings) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
98
106
|
this.currentSpatialLayerParams = this.parseSpatialLayerParams(encodings[this.currentSpatialLayer]);
|
|
99
107
|
this.logger.debug('setCurrentSpatialLayerParams()', { currentSpatialLayerParams: this.currentSpatialLayerParams });
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
parseSpatialLayerParams(encoding: RtpEncodingParameters): SpatialLayerParams {
|
|
103
|
-
const { trackTransformParams
|
|
111
|
+
const { trackTransformParams } = this.appData.producerData;
|
|
112
|
+
if (!trackTransformParams) {
|
|
113
|
+
return encoding;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const { width, height } = trackTransformParams;
|
|
104
117
|
const coefficient = encoding.scaleResolutionDownBy || 1;
|
|
105
118
|
if (width && height) {
|
|
106
119
|
return {
|
package/src/engine/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import Logger from './Logger';
|
|
|
22
22
|
import {
|
|
23
23
|
CHANNEL_EVENTS, CLIENT_EVENTS, MEDIASOUP_EVENTS, PEER_EVENTS, SocketIOEvents,
|
|
24
24
|
} from '../constants/events';
|
|
25
|
+
import { GetNodeRequest } from '../types/network';
|
|
25
26
|
import VideoTrack from './media/tracks/VideoTrack';
|
|
26
27
|
import AudioTrack from './media/tracks/AudioTrack';
|
|
27
28
|
import PeerTrack from './media/tracks/PeerTrack';
|
|
@@ -144,7 +145,10 @@ class Engine {
|
|
|
144
145
|
try {
|
|
145
146
|
this.logger.debug('join()', { params });
|
|
146
147
|
this.isRoomJoining = true;
|
|
147
|
-
const { webSocketUrl } = await this.getAvailableNode({
|
|
148
|
+
const { webSocketUrl } = await this.getAvailableNode({
|
|
149
|
+
channelId: params.channelId,
|
|
150
|
+
role: params.role,
|
|
151
|
+
});
|
|
148
152
|
this.network.socket.connect(webSocketUrl);
|
|
149
153
|
await this.waitForSocketConnection();
|
|
150
154
|
await this.performJoin(params);
|
|
@@ -420,9 +424,9 @@ class Engine {
|
|
|
420
424
|
return this.app;
|
|
421
425
|
}
|
|
422
426
|
|
|
423
|
-
private async getAvailableNode(
|
|
427
|
+
private async getAvailableNode(params: GetNodeRequest): Promise<{ webSocketUrl: string }> {
|
|
424
428
|
try {
|
|
425
|
-
const response = await this.network.loadBalancerClient.getNode(
|
|
429
|
+
const response = await this.network.loadBalancerClient.getNode(params);
|
|
426
430
|
return { webSocketUrl: response.webSocketUrl };
|
|
427
431
|
} catch (error) {
|
|
428
432
|
this.logger.error('getAvailableNode()', { error: 'No available nodes' });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios, { AxiosInstance } from 'axios';
|
|
2
2
|
import qs from 'qs';
|
|
3
|
-
import { GetNodeResponse } from '../../types/
|
|
3
|
+
import { GetNodeRequest, GetNodeResponse } from '../../types/network';
|
|
4
4
|
|
|
5
5
|
export type LoadBalancerApiClientParams = {
|
|
6
6
|
baseURL?: string;
|
|
@@ -24,13 +24,13 @@ class LoadBalancerApiClient {
|
|
|
24
24
|
this.customNode = customNode;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
async getNode(
|
|
27
|
+
async getNode(params: GetNodeRequest): Promise<GetNodeResponse> {
|
|
28
28
|
if (this.customNode) {
|
|
29
29
|
return this.customNode;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const { data } = await this.api.get<GetNodeResponse>('/nodes/best', {
|
|
33
|
-
params
|
|
33
|
+
params,
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
return data;
|
package/src/types/common.ts
CHANGED
|
@@ -13,10 +13,6 @@ export type SocketResponse = {
|
|
|
13
13
|
[key: string]: unknown;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export type GetNodeResponse = {
|
|
17
|
-
webSocketUrl: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
16
|
export type ProduceParams = {
|
|
21
17
|
kind: MediaKind,
|
|
22
18
|
rtpParameters: RtpParameters,
|
|
@@ -66,9 +62,9 @@ export type JoinChannelParams = {
|
|
|
66
62
|
channelId: string,
|
|
67
63
|
appId: string,
|
|
68
64
|
sdkSecret: string,
|
|
65
|
+
role: Role,
|
|
69
66
|
uid?: string,
|
|
70
67
|
appData?: Record<string, unknown>,
|
|
71
|
-
role: Role,
|
|
72
68
|
};
|
|
73
69
|
|
|
74
70
|
export type ChannelEvent = {
|