livekit-client 2.18.5 → 2.18.6

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,6 +1,6 @@
1
1
  {
2
2
  "name": "livekit-client",
3
- "version": "2.18.5",
3
+ "version": "2.18.6",
4
4
  "description": "JavaScript/TypeScript client SDK for LiveKit",
5
5
  "main": "./dist/livekit-client.umd.js",
6
6
  "unpkg": "./dist/livekit-client.umd.js",
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import { DataTrackPacket, DataTrackPacketHeader, FrameMarker } from '.';
4
4
  import { DataTrackHandle } from '../handle';
5
5
  import { DataTrackTimestamp, WrapAroundUnsignedInt } from '../utils';
6
- import { EXT_FLAG_SHIFT } from './constants';
6
+ import { EXT_FLAG_SHIFT, EXT_WORDS_INDICATOR_SIZE } from './constants';
7
7
  import {
8
8
  DataTrackE2eeExtension,
9
9
  DataTrackExtensionTag,
@@ -72,7 +72,7 @@ describe('DataTrackPacket', () => {
72
72
 
73
73
  const packet = new DataTrackPacket(header, payloadBytes);
74
74
 
75
- expect(packet.toBinaryLengthBytes()).toStrictEqual(74);
75
+ expect(packet.toBinaryLengthBytes()).toStrictEqual(72);
76
76
  expect(packet.toBinary()).toStrictEqual(
77
77
  new Uint8Array([
78
78
  0xc, // Version 0, final, extension
@@ -120,8 +120,6 @@ describe('DataTrackPacket', () => {
120
120
  17,
121
121
 
122
122
  0, // Extension padding
123
- 0,
124
- 0,
125
123
 
126
124
  0xfa, // Payload
127
125
  0xfa,
@@ -174,7 +172,7 @@ describe('DataTrackPacket', () => {
174
172
 
175
173
  const packet = new DataTrackPacket(header, payloadBytes);
176
174
 
177
- expect(packet.toBinaryLengthBytes()).toStrictEqual(62);
175
+ expect(packet.toBinaryLengthBytes()).toStrictEqual(64);
178
176
  expect(packet.toBinary()).toStrictEqual(
179
177
  new Uint8Array([
180
178
  0x14, // Version 0, start, extension
@@ -190,7 +188,7 @@ describe('DataTrackPacket', () => {
190
188
  0,
191
189
  104,
192
190
  0, // RTP oriented extension words (big endian)
193
- 3,
191
+ 4,
194
192
 
195
193
  // E2ee extension
196
194
  1, // ID 1
@@ -210,6 +208,8 @@ describe('DataTrackPacket', () => {
210
208
  0x3c,
211
209
 
212
210
  0, // Extension padding
211
+ 0,
212
+ 0,
213
213
 
214
214
  0xfa, // Payload
215
215
  0xfa,
@@ -350,8 +350,8 @@ describe('DataTrackPacket', () => {
350
350
  const packetBytes = new Uint8Array([
351
351
  ...VALID_PACKET_BYTES,
352
352
 
353
- 0, // Extension word (big endian)
354
- 1,
353
+ 0, // Extension word (big endian) — data_budget = (0+1)*4 - 2 = 2, but no data follows
354
+ 0,
355
355
  ]);
356
356
  packetBytes[0] |= 1 << EXT_FLAG_SHIFT; // Extension flag - should have ext word indicator here
357
357
 
@@ -409,7 +409,7 @@ describe('DataTrackPacket', () => {
409
409
  0, // Extension words (big endian)
410
410
  extensionWords,
411
411
 
412
- ...new Array((extensionWords + 1) /* RTP oriented extension words */ * 4).fill(0), // Padding
412
+ ...new Array((extensionWords + 1) * 4 - EXT_WORDS_INDICATOR_SIZE).fill(0), // Padding
413
413
  ]);
414
414
  packetBytes[0] |= 1 << EXT_FLAG_SHIFT; // Extension flag
415
415
 
@@ -423,11 +423,11 @@ describe('DataTrackPacket', () => {
423
423
  ...VALID_PACKET_BYTES,
424
424
 
425
425
  0, // RTP oriented extension words (big endian)
426
- 3,
426
+ 4,
427
427
 
428
428
  // E2ee extension
429
429
  1, // ID 1
430
- 12, // Length 12
430
+ 13, // Length 13
431
431
  0xfa, // Key index
432
432
  0x3c, // Iv array
433
433
  0x3c,
@@ -443,6 +443,8 @@ describe('DataTrackPacket', () => {
443
443
  0x3c,
444
444
 
445
445
  0, // Padding
446
+ 0,
447
+ 0,
446
448
  ]);
447
449
  packetBytes[0] |= 1 << EXT_FLAG_SHIFT; // Extension flag
448
450
 
@@ -465,7 +467,7 @@ describe('DataTrackPacket', () => {
465
467
 
466
468
  // User timestamp extension
467
469
  2, // ID 2
468
- 7, // Length 7
470
+ 8, // Length 8
469
471
  0x44, // Timestamp (big endian)
470
472
  0x11,
471
473
  0x22,
@@ -474,9 +476,6 @@ describe('DataTrackPacket', () => {
474
476
  0x11,
475
477
  0x88,
476
478
  0x11,
477
-
478
- 0, // Padding
479
- 0,
480
479
  ]);
481
480
  packetBytes[0] |= 1 << EXT_FLAG_SHIFT; // Extension flag
482
481
 
@@ -505,11 +504,9 @@ describe('DataTrackPacket', () => {
505
504
  0x4,
506
505
  0x5,
507
506
  0x6,
508
- 0x0,
509
507
 
510
508
  0x0, // Padding
511
509
  0x0,
512
- 0x0,
513
510
  ]);
514
511
  packetBytes[0] |= 1 << EXT_FLAG_SHIFT; // Extension flag
515
512
 
@@ -525,12 +522,10 @@ describe('DataTrackPacket', () => {
525
522
  const packetBytes = new Uint8Array([
526
523
  ...VALID_PACKET_BYTES,
527
524
 
528
- 0, // RTP oriented extension words (big endian)
525
+ 0, // RTP oriented extension words (big endian, data_budget = 2)
529
526
  0,
530
527
 
531
- 0x0, // Padding, missing one byte
532
- 0x0,
533
- 0x0,
528
+ 0x0, // Only 1 byte, but 2 needed
534
529
  ]);
535
530
  packetBytes[0] |= 1 << EXT_FLAG_SHIFT; // Extension flag
536
531
 
@@ -65,8 +65,8 @@ export class DataTrackPacketHeader extends Serializable {
65
65
 
66
66
  private extensionsMetrics() {
67
67
  const lengthBytes = this.extensions.toBinaryLengthBytes();
68
- const lengthWords = Math.ceil(lengthBytes / 4);
69
- const paddingLengthBytes = lengthWords * 4 - lengthBytes;
68
+ const lengthWords = Math.ceil((EXT_WORDS_INDICATOR_SIZE + lengthBytes) / 4);
69
+ const paddingLengthBytes = lengthWords * 4 - EXT_WORDS_INDICATOR_SIZE - lengthBytes;
70
70
 
71
71
  return { lengthBytes, lengthWords, paddingLengthBytes };
72
72
  }
@@ -242,7 +242,7 @@ export class DataTrackPacketHeader extends Serializable {
242
242
  // potentially unintuitive so I wanted to call it out.
243
243
  const extensionWords = rtpOrientedExtensionWords + 1;
244
244
 
245
- let extensionLengthBytes = 4 * extensionWords;
245
+ let extensionLengthBytes = 4 * extensionWords - EXT_WORDS_INDICATOR_SIZE;
246
246
 
247
247
  if (byteIndex + extensionLengthBytes > dataView.byteLength) {
248
248
  throw DataTrackDeserializeError.headerOverrun();