livekit-client 1.2.0 → 1.2.1
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/livekit-client.esm.mjs +51 -14
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/room/PCTransport.d.ts +9 -0
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +3 -3
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/room/PCTransport.ts +39 -0
- package/src/room/participant/LocalParticipant.ts +26 -4
- package/src/room/participant/publishUtils.ts +1 -1
@@ -1,9 +1,16 @@
|
|
1
1
|
/** @internal */
|
2
|
+
interface TrackBitrateInfo {
|
3
|
+
sid: string;
|
4
|
+
codec: string;
|
5
|
+
maxbr: number;
|
6
|
+
}
|
7
|
+
/** @internal */
|
2
8
|
export default class PCTransport {
|
3
9
|
pc: RTCPeerConnection;
|
4
10
|
pendingCandidates: RTCIceCandidateInit[];
|
5
11
|
restartingIce: boolean;
|
6
12
|
renegotiate: boolean;
|
13
|
+
trackBitrates: TrackBitrateInfo[];
|
7
14
|
onOffer?: (offer: RTCSessionDescriptionInit) => void;
|
8
15
|
constructor(config?: RTCConfiguration);
|
9
16
|
get isICEConnected(): boolean;
|
@@ -11,6 +18,8 @@ export default class PCTransport {
|
|
11
18
|
setRemoteDescription(sd: RTCSessionDescriptionInit): Promise<void>;
|
12
19
|
negotiate: import("ts-debounce").DebouncedFunction<() => void>;
|
13
20
|
createAndSendOffer(options?: RTCOfferOptions): Promise<void>;
|
21
|
+
setTrackCodecBitrate(sid: string, codec: string, maxbr: number): void;
|
14
22
|
close(): void;
|
15
23
|
}
|
24
|
+
export {};
|
16
25
|
//# sourceMappingURL=PCTransport.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PCTransport.d.ts","sourceRoot":"","sources":["../../../src/room/PCTransport.ts"],"names":[],"mappings":"AAGA,gBAAgB;AAChB,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,EAAE,EAAE,iBAAiB,CAAC;IAEtB,iBAAiB,EAAE,mBAAmB,EAAE,CAAM;IAE9C,aAAa,EAAE,OAAO,CAAS;IAE/B,WAAW,EAAE,OAAO,CAAS;IAE7B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;gBAEzC,MAAM,CAAC,EAAE,gBAAgB;IAIrC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAEK,eAAe,CAAC,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9D,oBAAoB,CAAC,EAAE,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxE,SAAS,sDAED;IAEF,kBAAkB,CAAC,OAAO,CAAC,EAAE,eAAe;
|
1
|
+
{"version":3,"file":"PCTransport.d.ts","sourceRoot":"","sources":["../../../src/room/PCTransport.ts"],"names":[],"mappings":"AAGA,gBAAgB;AAChB,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gBAAgB;AAChB,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,EAAE,EAAE,iBAAiB,CAAC;IAEtB,iBAAiB,EAAE,mBAAmB,EAAE,CAAM;IAE9C,aAAa,EAAE,OAAO,CAAS;IAE/B,WAAW,EAAE,OAAO,CAAS;IAE7B,aAAa,EAAE,gBAAgB,EAAE,CAAM;IAEvC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;gBAEzC,MAAM,CAAC,EAAE,gBAAgB;IAIrC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAEK,eAAe,CAAC,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9D,oBAAoB,CAAC,EAAE,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxE,SAAS,sDAED;IAEF,kBAAkB,CAAC,OAAO,CAAC,EAAE,eAAe;IAwDlD,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAQ9D,KAAK;CAGN"}
|
@@ -34,19 +34,19 @@ export default class LocalParticipant extends Participant {
|
|
34
34
|
* If a track has already published, it'll mute or unmute the track.
|
35
35
|
* Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
|
36
36
|
*/
|
37
|
-
setCameraEnabled(enabled: boolean, options?: VideoCaptureOptions): Promise<LocalTrackPublication | undefined>;
|
37
|
+
setCameraEnabled(enabled: boolean, options?: VideoCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
|
38
38
|
/**
|
39
39
|
* Enable or disable a participant's microphone track.
|
40
40
|
*
|
41
41
|
* If a track has already published, it'll mute or unmute the track.
|
42
42
|
* Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
|
43
43
|
*/
|
44
|
-
setMicrophoneEnabled(enabled: boolean, options?: AudioCaptureOptions): Promise<LocalTrackPublication | undefined>;
|
44
|
+
setMicrophoneEnabled(enabled: boolean, options?: AudioCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
|
45
45
|
/**
|
46
46
|
* Start or stop sharing a participant's screen
|
47
47
|
* Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
|
48
48
|
*/
|
49
|
-
setScreenShareEnabled(enabled: boolean, options?: ScreenShareCaptureOptions): Promise<LocalTrackPublication | undefined>;
|
49
|
+
setScreenShareEnabled(enabled: boolean, options?: ScreenShareCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
|
50
50
|
/** @internal */
|
51
51
|
setPermissions(permissions: ParticipantPermission): boolean;
|
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AAgB;IAChB,OAAO,CAAC,YAAY,CAWlB;IAEF,OAAO,CAAC,qBAAqB,CAG3B;IAEF,OAAO,CAAC,sBAAsB,CAG5B;IAEF,OAAO,CAAC,6BAA6B,CAwBnC;IAEF,OAAO,CAAC,2BAA2B,CAUjC;IAEF,OAAO,CAAC,gBAAgB,CA2CtB;IAEF,OAAO,CAAC,sBAAsB;IAwB9B,OAAO,CAAC,iBAAiB;IA4CzB,gBAAgB;IAChB,mBAAmB,IAAI,sBAAsB,EAAE;IAa/C,gBAAgB;IAChB,gBAAgB,IAAI,eAAe,EAAE;CAoBtC"}
|
package/package.json
CHANGED
package/src/room/PCTransport.ts
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
import { debounce } from 'ts-debounce';
|
2
2
|
import log from '../logger';
|
3
3
|
|
4
|
+
/** @internal */
|
5
|
+
interface TrackBitrateInfo {
|
6
|
+
sid: string;
|
7
|
+
codec: string;
|
8
|
+
maxbr: number;
|
9
|
+
}
|
10
|
+
|
4
11
|
/** @internal */
|
5
12
|
export default class PCTransport {
|
6
13
|
pc: RTCPeerConnection;
|
@@ -11,6 +18,8 @@ export default class PCTransport {
|
|
11
18
|
|
12
19
|
renegotiate: boolean = false;
|
13
20
|
|
21
|
+
trackBitrates: TrackBitrateInfo[] = [];
|
22
|
+
|
14
23
|
onOffer?: (offer: RTCSessionDescriptionInit) => void;
|
15
24
|
|
16
25
|
constructor(config?: RTCConfiguration) {
|
@@ -78,10 +87,40 @@ export default class PCTransport {
|
|
78
87
|
// actually negotiate
|
79
88
|
log.debug('starting to negotiate');
|
80
89
|
const offer = await this.pc.createOffer(options);
|
90
|
+
|
91
|
+
// mung sdp for codec bitrate setting that can't apply by sendEncoding
|
92
|
+
this.trackBitrates.forEach((trackbr) => {
|
93
|
+
let sdp = offer.sdp ?? '';
|
94
|
+
const sidIndex = sdp.search(new RegExp(`msid.* ${trackbr.sid}`));
|
95
|
+
if (sidIndex < 0) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
|
99
|
+
const mlineStart = sdp.substring(0, sidIndex).lastIndexOf('m=');
|
100
|
+
const mlineEnd = sdp.indexOf('m=', sidIndex);
|
101
|
+
const mediaSection = sdp.substring(mlineStart, mlineEnd);
|
102
|
+
|
103
|
+
const mungedMediaSection = mediaSection.replace(
|
104
|
+
new RegExp(`a=rtpmap:(\\d+) ${trackbr.codec}/\\d+`, 'i'),
|
105
|
+
`$&\r\na=fmtp:$1 x-google-max-bitrate=${trackbr.maxbr}`,
|
106
|
+
);
|
107
|
+
sdp = sdp.substring(0, mlineStart) + mungedMediaSection + sdp.substring(mlineEnd);
|
108
|
+
offer.sdp = sdp;
|
109
|
+
});
|
110
|
+
this.trackBitrates = [];
|
111
|
+
|
81
112
|
await this.pc.setLocalDescription(offer);
|
82
113
|
this.onOffer(offer);
|
83
114
|
}
|
84
115
|
|
116
|
+
setTrackCodecBitrate(sid: string, codec: string, maxbr: number) {
|
117
|
+
this.trackBitrates.push({
|
118
|
+
sid,
|
119
|
+
codec,
|
120
|
+
maxbr,
|
121
|
+
});
|
122
|
+
}
|
123
|
+
|
85
124
|
close() {
|
86
125
|
this.pc.close();
|
87
126
|
}
|
@@ -125,8 +125,9 @@ export default class LocalParticipant extends Participant {
|
|
125
125
|
setCameraEnabled(
|
126
126
|
enabled: boolean,
|
127
127
|
options?: VideoCaptureOptions,
|
128
|
+
publishOptions?: TrackPublishOptions,
|
128
129
|
): Promise<LocalTrackPublication | undefined> {
|
129
|
-
return this.setTrackEnabled(Track.Source.Camera, enabled, options);
|
130
|
+
return this.setTrackEnabled(Track.Source.Camera, enabled, options, publishOptions);
|
130
131
|
}
|
131
132
|
|
132
133
|
/**
|
@@ -138,8 +139,9 @@ export default class LocalParticipant extends Participant {
|
|
138
139
|
setMicrophoneEnabled(
|
139
140
|
enabled: boolean,
|
140
141
|
options?: AudioCaptureOptions,
|
142
|
+
publishOptions?: TrackPublishOptions,
|
141
143
|
): Promise<LocalTrackPublication | undefined> {
|
142
|
-
return this.setTrackEnabled(Track.Source.Microphone, enabled, options);
|
144
|
+
return this.setTrackEnabled(Track.Source.Microphone, enabled, options, publishOptions);
|
143
145
|
}
|
144
146
|
|
145
147
|
/**
|
@@ -149,8 +151,9 @@ export default class LocalParticipant extends Participant {
|
|
149
151
|
setScreenShareEnabled(
|
150
152
|
enabled: boolean,
|
151
153
|
options?: ScreenShareCaptureOptions,
|
154
|
+
publishOptions?: TrackPublishOptions,
|
152
155
|
): Promise<LocalTrackPublication | undefined> {
|
153
|
-
return this.setTrackEnabled(Track.Source.ScreenShare, enabled, options);
|
156
|
+
return this.setTrackEnabled(Track.Source.ScreenShare, enabled, options, publishOptions);
|
154
157
|
}
|
155
158
|
|
156
159
|
/** @internal */
|
@@ -172,21 +175,25 @@ export default class LocalParticipant extends Participant {
|
|
172
175
|
source: Extract<Track.Source, Track.Source.Camera>,
|
173
176
|
enabled: boolean,
|
174
177
|
options?: VideoCaptureOptions,
|
178
|
+
publishOptions?: TrackPublishOptions,
|
175
179
|
): Promise<LocalTrackPublication | undefined>;
|
176
180
|
private async setTrackEnabled(
|
177
181
|
source: Extract<Track.Source, Track.Source.Microphone>,
|
178
182
|
enabled: boolean,
|
179
183
|
options?: AudioCaptureOptions,
|
184
|
+
publishOptions?: TrackPublishOptions,
|
180
185
|
): Promise<LocalTrackPublication | undefined>;
|
181
186
|
private async setTrackEnabled(
|
182
187
|
source: Extract<Track.Source, Track.Source.ScreenShare>,
|
183
188
|
enabled: boolean,
|
184
189
|
options?: ScreenShareCaptureOptions,
|
190
|
+
publishOptions?: TrackPublishOptions,
|
185
191
|
): Promise<LocalTrackPublication | undefined>;
|
186
192
|
private async setTrackEnabled(
|
187
193
|
source: Track.Source,
|
188
194
|
enabled: true,
|
189
195
|
options?: VideoCaptureOptions | AudioCaptureOptions | ScreenShareCaptureOptions,
|
196
|
+
publishOptions?: TrackPublishOptions,
|
190
197
|
) {
|
191
198
|
log.debug('setTrackEnabled', { source, enabled });
|
192
199
|
let track = this.getTrack(source);
|
@@ -224,7 +231,7 @@ export default class LocalParticipant extends Participant {
|
|
224
231
|
}
|
225
232
|
const publishPromises: Array<Promise<LocalTrackPublication>> = [];
|
226
233
|
for (const localTrack of localTracks) {
|
227
|
-
publishPromises.push(this.publishTrack(localTrack));
|
234
|
+
publishPromises.push(this.publishTrack(localTrack, publishOptions));
|
228
235
|
}
|
229
236
|
const publishedTracks = await Promise.all(publishPromises);
|
230
237
|
// for screen share publications including audio, this will only return the screen share publication, not the screen share audio one
|
@@ -544,6 +551,14 @@ export default class LocalParticipant extends Participant {
|
|
544
551
|
track.codec = opts.videoCodec;
|
545
552
|
}
|
546
553
|
|
554
|
+
if (track.codec === 'av1' && encodings && encodings[0]?.maxBitrate) {
|
555
|
+
this.engine.publisher.setTrackCodecBitrate(
|
556
|
+
req.cid,
|
557
|
+
track.codec,
|
558
|
+
encodings[0].maxBitrate / 1000,
|
559
|
+
);
|
560
|
+
}
|
561
|
+
|
547
562
|
this.engine.negotiate();
|
548
563
|
|
549
564
|
// store RTPSender
|
@@ -642,6 +657,13 @@ export default class LocalParticipant extends Participant {
|
|
642
657
|
this.setPreferredCodec(transceiver, track.kind, opts.videoCodec);
|
643
658
|
track.setSimulcastTrackSender(opts.videoCodec, transceiver.sender);
|
644
659
|
|
660
|
+
if (videoCodec === 'av1' && encodings[0]?.maxBitrate) {
|
661
|
+
this.engine.publisher.setTrackCodecBitrate(
|
662
|
+
req.cid,
|
663
|
+
videoCodec,
|
664
|
+
encodings[0].maxBitrate / 1000,
|
665
|
+
);
|
666
|
+
}
|
645
667
|
this.engine.negotiate();
|
646
668
|
log.debug(`published ${opts.videoCodec} for track ${track.sid}`, { encodings, trackInfo: ti });
|
647
669
|
}
|
@@ -106,7 +106,7 @@ export function computeVideoEncodings(
|
|
106
106
|
encodings.push({
|
107
107
|
rid: videoRids[2 - i],
|
108
108
|
scaleResolutionDownBy: 2 ** i,
|
109
|
-
maxBitrate: videoEncoding ? videoEncoding.maxBitrate /
|
109
|
+
maxBitrate: videoEncoding ? videoEncoding.maxBitrate / 3 ** i : 0,
|
110
110
|
/* @ts-ignore */
|
111
111
|
maxFramerate: original.encoding.maxFramerate,
|
112
112
|
/* @ts-ignore */
|