@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.
@@ -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;
@@ -0,0 +1,8 @@
1
+ import { Role } from './common';
2
+ export declare type GetNodeRequest = {
3
+ channelId: string;
4
+ role: Role;
5
+ };
6
+ export declare type GetNodeResponse = {
7
+ webSocketUrl: string;
8
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@livedigital/client",
3
3
  "author": "vlprojects",
4
4
  "license": "MIT",
5
- "version": "2.2.0",
5
+ "version": "2.3.2",
6
6
  "private": false,
7
7
  "bugs": {
8
8
  "url": "https://github.com/vlprojects/livedigital-sdk/issues"
@@ -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: { width, height } } = this.appData.producerData;
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 {
@@ -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({ channelId: params.channelId });
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({ channelId }: { channelId: string }): Promise<{ webSocketUrl: string }> {
427
+ private async getAvailableNode(params: GetNodeRequest): Promise<{ webSocketUrl: string }> {
424
428
  try {
425
- const response = await this.network.loadBalancerClient.getNode({ channelId });
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/common';
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({ channelId }: { channelId: string }): Promise<GetNodeResponse> {
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: { channelId },
33
+ params,
34
34
  });
35
35
 
36
36
  return data;
@@ -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 = {
@@ -0,0 +1,10 @@
1
+ import { Role } from './common';
2
+
3
+ export type GetNodeRequest = {
4
+ channelId: string;
5
+ role: Role;
6
+ };
7
+
8
+ export type GetNodeResponse = {
9
+ webSocketUrl: string;
10
+ };