livekit-client 1.9.6 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/dist/livekit-client.esm.mjs +1318 -885
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/api/SignalClient.d.ts +2 -1
  6. package/dist/src/api/SignalClient.d.ts.map +1 -1
  7. package/dist/src/index.d.ts +1 -0
  8. package/dist/src/index.d.ts.map +1 -1
  9. package/dist/src/proto/livekit_models.d.ts +108 -10
  10. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  11. package/dist/src/proto/livekit_rtc.d.ts +513 -194
  12. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  13. package/dist/src/room/Room.d.ts +3 -2
  14. package/dist/src/room/Room.d.ts.map +1 -1
  15. package/dist/src/room/events.d.ts +5 -1
  16. package/dist/src/room/events.d.ts.map +1 -1
  17. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  18. package/dist/src/room/participant/Participant.d.ts +2 -2
  19. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  20. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  21. package/dist/src/room/participant/publishUtils.d.ts +8 -0
  22. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  23. package/dist/src/room/track/LocalTrack.d.ts +32 -0
  24. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  25. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  26. package/dist/src/room/track/RemoteTrackPublication.d.ts +4 -1
  27. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  28. package/dist/src/room/track/TrackPublication.d.ts +2 -1
  29. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  30. package/dist/src/room/track/options.d.ts +1 -1
  31. package/dist/src/room/track/options.d.ts.map +1 -1
  32. package/dist/src/room/track/processor/types.d.ts +19 -0
  33. package/dist/src/room/track/processor/types.d.ts.map +1 -0
  34. package/dist/src/utils/browserParser.d.ts.map +1 -1
  35. package/dist/ts4.2/src/api/SignalClient.d.ts +2 -1
  36. package/dist/ts4.2/src/index.d.ts +1 -0
  37. package/dist/ts4.2/src/proto/livekit_models.d.ts +126 -12
  38. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +617 -254
  39. package/dist/ts4.2/src/room/Room.d.ts +3 -2
  40. package/dist/ts4.2/src/room/events.d.ts +5 -1
  41. package/dist/ts4.2/src/room/participant/Participant.d.ts +2 -2
  42. package/dist/ts4.2/src/room/participant/publishUtils.d.ts +8 -0
  43. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +32 -0
  44. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +4 -1
  45. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +2 -1
  46. package/dist/ts4.2/src/room/track/options.d.ts +1 -1
  47. package/dist/ts4.2/src/room/track/processor/types.d.ts +19 -0
  48. package/package.json +14 -13
  49. package/src/api/SignalClient.ts +8 -1
  50. package/src/index.ts +1 -0
  51. package/src/proto/google/protobuf/timestamp.ts +3 -3
  52. package/src/proto/livekit_models.ts +254 -161
  53. package/src/proto/livekit_rtc.ts +334 -180
  54. package/src/room/Room.ts +26 -1
  55. package/src/room/events.ts +4 -0
  56. package/src/room/participant/LocalParticipant.ts +23 -3
  57. package/src/room/participant/Participant.ts +2 -1
  58. package/src/room/participant/RemoteParticipant.ts +4 -1
  59. package/src/room/participant/publishUtils.ts +68 -12
  60. package/src/room/track/LocalTrack.ts +120 -16
  61. package/src/room/track/LocalVideoTrack.ts +96 -33
  62. package/src/room/track/RemoteTrackPublication.ts +8 -1
  63. package/src/room/track/Track.ts +3 -3
  64. package/src/room/track/TrackPublication.ts +2 -1
  65. package/src/room/track/options.ts +1 -1
  66. package/src/room/track/processor/types.ts +20 -0
  67. package/src/utils/browserParser.ts +1 -4
@@ -4302,6 +4302,43 @@ var ReconnectReason;
4302
4302
  ReconnectReason[ReconnectReason["RR_SWITCH_CANDIDATE"] = 4] = "RR_SWITCH_CANDIDATE";
4303
4303
  ReconnectReason[ReconnectReason["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
4304
4304
  })(ReconnectReason || (ReconnectReason = {}));
4305
+ var SubscriptionError;
4306
+ (function (SubscriptionError) {
4307
+ SubscriptionError[SubscriptionError["SE_UNKOWN"] = 0] = "SE_UNKOWN";
4308
+ SubscriptionError[SubscriptionError["SE_CODEC_UNSUPPORTED"] = 1] = "SE_CODEC_UNSUPPORTED";
4309
+ SubscriptionError[SubscriptionError["SE_TRACK_NOTFOUND"] = 2] = "SE_TRACK_NOTFOUND";
4310
+ SubscriptionError[SubscriptionError["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
4311
+ })(SubscriptionError || (SubscriptionError = {}));
4312
+ function subscriptionErrorFromJSON(object) {
4313
+ switch (object) {
4314
+ case 0:
4315
+ case "SE_UNKOWN":
4316
+ return SubscriptionError.SE_UNKOWN;
4317
+ case 1:
4318
+ case "SE_CODEC_UNSUPPORTED":
4319
+ return SubscriptionError.SE_CODEC_UNSUPPORTED;
4320
+ case 2:
4321
+ case "SE_TRACK_NOTFOUND":
4322
+ return SubscriptionError.SE_TRACK_NOTFOUND;
4323
+ case -1:
4324
+ case "UNRECOGNIZED":
4325
+ default:
4326
+ return SubscriptionError.UNRECOGNIZED;
4327
+ }
4328
+ }
4329
+ function subscriptionErrorToJSON(object) {
4330
+ switch (object) {
4331
+ case SubscriptionError.SE_UNKOWN:
4332
+ return "SE_UNKOWN";
4333
+ case SubscriptionError.SE_CODEC_UNSUPPORTED:
4334
+ return "SE_CODEC_UNSUPPORTED";
4335
+ case SubscriptionError.SE_TRACK_NOTFOUND:
4336
+ return "SE_TRACK_NOTFOUND";
4337
+ case SubscriptionError.UNRECOGNIZED:
4338
+ default:
4339
+ return "UNRECOGNIZED";
4340
+ }
4341
+ }
4305
4342
  var ParticipantInfo_State;
4306
4343
  (function (ParticipantInfo_State) {
4307
4344
  /** JOINING - websocket' connected, but not offered yet */
@@ -4582,73 +4619,73 @@ const Room$1 = {
4582
4619
  const tag = reader.uint32();
4583
4620
  switch (tag >>> 3) {
4584
4621
  case 1:
4585
- if (tag != 10) {
4622
+ if (tag !== 10) {
4586
4623
  break;
4587
4624
  }
4588
4625
  message.sid = reader.string();
4589
4626
  continue;
4590
4627
  case 2:
4591
- if (tag != 18) {
4628
+ if (tag !== 18) {
4592
4629
  break;
4593
4630
  }
4594
4631
  message.name = reader.string();
4595
4632
  continue;
4596
4633
  case 3:
4597
- if (tag != 24) {
4634
+ if (tag !== 24) {
4598
4635
  break;
4599
4636
  }
4600
4637
  message.emptyTimeout = reader.uint32();
4601
4638
  continue;
4602
4639
  case 4:
4603
- if (tag != 32) {
4640
+ if (tag !== 32) {
4604
4641
  break;
4605
4642
  }
4606
4643
  message.maxParticipants = reader.uint32();
4607
4644
  continue;
4608
4645
  case 5:
4609
- if (tag != 40) {
4646
+ if (tag !== 40) {
4610
4647
  break;
4611
4648
  }
4612
4649
  message.creationTime = longToNumber$1(reader.int64());
4613
4650
  continue;
4614
4651
  case 6:
4615
- if (tag != 50) {
4652
+ if (tag !== 50) {
4616
4653
  break;
4617
4654
  }
4618
4655
  message.turnPassword = reader.string();
4619
4656
  continue;
4620
4657
  case 7:
4621
- if (tag != 58) {
4658
+ if (tag !== 58) {
4622
4659
  break;
4623
4660
  }
4624
4661
  message.enabledCodecs.push(Codec.decode(reader, reader.uint32()));
4625
4662
  continue;
4626
4663
  case 8:
4627
- if (tag != 66) {
4664
+ if (tag !== 66) {
4628
4665
  break;
4629
4666
  }
4630
4667
  message.metadata = reader.string();
4631
4668
  continue;
4632
4669
  case 9:
4633
- if (tag != 72) {
4670
+ if (tag !== 72) {
4634
4671
  break;
4635
4672
  }
4636
4673
  message.numParticipants = reader.uint32();
4637
4674
  continue;
4638
4675
  case 11:
4639
- if (tag != 88) {
4676
+ if (tag !== 88) {
4640
4677
  break;
4641
4678
  }
4642
4679
  message.numPublishers = reader.uint32();
4643
4680
  continue;
4644
4681
  case 10:
4645
- if (tag != 80) {
4682
+ if (tag !== 80) {
4646
4683
  break;
4647
4684
  }
4648
4685
  message.activeRecording = reader.bool();
4649
4686
  continue;
4650
4687
  }
4651
- if ((tag & 7) == 4 || tag == 0) {
4688
+ if ((tag & 7) === 4 || tag === 0) {
4652
4689
  break;
4653
4690
  }
4654
4691
  reader.skipType(tag & 7);
@@ -4734,19 +4771,19 @@ const Codec = {
4734
4771
  const tag = reader.uint32();
4735
4772
  switch (tag >>> 3) {
4736
4773
  case 1:
4737
- if (tag != 10) {
4774
+ if (tag !== 10) {
4738
4775
  break;
4739
4776
  }
4740
4777
  message.mime = reader.string();
4741
4778
  continue;
4742
4779
  case 2:
4743
- if (tag != 18) {
4780
+ if (tag !== 18) {
4744
4781
  break;
4745
4782
  }
4746
4783
  message.fmtpLine = reader.string();
4747
4784
  continue;
4748
4785
  }
4749
- if ((tag & 7) == 4 || tag == 0) {
4786
+ if ((tag & 7) === 4 || tag === 0) {
4750
4787
  break;
4751
4788
  }
4752
4789
  reader.skipType(tag & 7);
@@ -4823,29 +4860,29 @@ const ParticipantPermission = {
4823
4860
  const tag = reader.uint32();
4824
4861
  switch (tag >>> 3) {
4825
4862
  case 1:
4826
- if (tag != 8) {
4863
+ if (tag !== 8) {
4827
4864
  break;
4828
4865
  }
4829
4866
  message.canSubscribe = reader.bool();
4830
4867
  continue;
4831
4868
  case 2:
4832
- if (tag != 16) {
4869
+ if (tag !== 16) {
4833
4870
  break;
4834
4871
  }
4835
4872
  message.canPublish = reader.bool();
4836
4873
  continue;
4837
4874
  case 3:
4838
- if (tag != 24) {
4875
+ if (tag !== 24) {
4839
4876
  break;
4840
4877
  }
4841
4878
  message.canPublishData = reader.bool();
4842
4879
  continue;
4843
4880
  case 9:
4844
- if (tag == 72) {
4881
+ if (tag === 72) {
4845
4882
  message.canPublishSources.push(reader.int32());
4846
4883
  continue;
4847
4884
  }
4848
- if (tag == 74) {
4885
+ if (tag === 74) {
4849
4886
  const end2 = reader.uint32() + reader.pos;
4850
4887
  while (reader.pos < end2) {
4851
4888
  message.canPublishSources.push(reader.int32());
@@ -4854,25 +4891,25 @@ const ParticipantPermission = {
4854
4891
  }
4855
4892
  break;
4856
4893
  case 7:
4857
- if (tag != 56) {
4894
+ if (tag !== 56) {
4858
4895
  break;
4859
4896
  }
4860
4897
  message.hidden = reader.bool();
4861
4898
  continue;
4862
4899
  case 8:
4863
- if (tag != 64) {
4900
+ if (tag !== 64) {
4864
4901
  break;
4865
4902
  }
4866
4903
  message.recorder = reader.bool();
4867
4904
  continue;
4868
4905
  case 10:
4869
- if (tag != 80) {
4906
+ if (tag !== 80) {
4870
4907
  break;
4871
4908
  }
4872
4909
  message.canUpdateMetadata = reader.bool();
4873
4910
  continue;
4874
4911
  }
4875
- if ((tag & 7) == 4 || tag == 0) {
4912
+ if ((tag & 7) === 4 || tag === 0) {
4876
4913
  break;
4877
4914
  }
4878
4915
  reader.skipType(tag & 7);
@@ -4982,73 +5019,73 @@ const ParticipantInfo = {
4982
5019
  const tag = reader.uint32();
4983
5020
  switch (tag >>> 3) {
4984
5021
  case 1:
4985
- if (tag != 10) {
5022
+ if (tag !== 10) {
4986
5023
  break;
4987
5024
  }
4988
5025
  message.sid = reader.string();
4989
5026
  continue;
4990
5027
  case 2:
4991
- if (tag != 18) {
5028
+ if (tag !== 18) {
4992
5029
  break;
4993
5030
  }
4994
5031
  message.identity = reader.string();
4995
5032
  continue;
4996
5033
  case 3:
4997
- if (tag != 24) {
5034
+ if (tag !== 24) {
4998
5035
  break;
4999
5036
  }
5000
5037
  message.state = reader.int32();
5001
5038
  continue;
5002
5039
  case 4:
5003
- if (tag != 34) {
5040
+ if (tag !== 34) {
5004
5041
  break;
5005
5042
  }
5006
5043
  message.tracks.push(TrackInfo.decode(reader, reader.uint32()));
5007
5044
  continue;
5008
5045
  case 5:
5009
- if (tag != 42) {
5046
+ if (tag !== 42) {
5010
5047
  break;
5011
5048
  }
5012
5049
  message.metadata = reader.string();
5013
5050
  continue;
5014
5051
  case 6:
5015
- if (tag != 48) {
5052
+ if (tag !== 48) {
5016
5053
  break;
5017
5054
  }
5018
5055
  message.joinedAt = longToNumber$1(reader.int64());
5019
5056
  continue;
5020
5057
  case 9:
5021
- if (tag != 74) {
5058
+ if (tag !== 74) {
5022
5059
  break;
5023
5060
  }
5024
5061
  message.name = reader.string();
5025
5062
  continue;
5026
5063
  case 10:
5027
- if (tag != 80) {
5064
+ if (tag !== 80) {
5028
5065
  break;
5029
5066
  }
5030
5067
  message.version = reader.uint32();
5031
5068
  continue;
5032
5069
  case 11:
5033
- if (tag != 90) {
5070
+ if (tag !== 90) {
5034
5071
  break;
5035
5072
  }
5036
5073
  message.permission = ParticipantPermission.decode(reader, reader.uint32());
5037
5074
  continue;
5038
5075
  case 12:
5039
- if (tag != 98) {
5076
+ if (tag !== 98) {
5040
5077
  break;
5041
5078
  }
5042
5079
  message.region = reader.string();
5043
5080
  continue;
5044
5081
  case 13:
5045
- if (tag != 104) {
5082
+ if (tag !== 104) {
5046
5083
  break;
5047
5084
  }
5048
5085
  message.isPublisher = reader.bool();
5049
5086
  continue;
5050
5087
  }
5051
- if ((tag & 7) == 4 || tag == 0) {
5088
+ if ((tag & 7) === 4 || tag === 0) {
5052
5089
  break;
5053
5090
  }
5054
5091
  reader.skipType(tag & 7);
@@ -5142,31 +5179,31 @@ const SimulcastCodecInfo = {
5142
5179
  const tag = reader.uint32();
5143
5180
  switch (tag >>> 3) {
5144
5181
  case 1:
5145
- if (tag != 10) {
5182
+ if (tag !== 10) {
5146
5183
  break;
5147
5184
  }
5148
5185
  message.mimeType = reader.string();
5149
5186
  continue;
5150
5187
  case 2:
5151
- if (tag != 18) {
5188
+ if (tag !== 18) {
5152
5189
  break;
5153
5190
  }
5154
5191
  message.mid = reader.string();
5155
5192
  continue;
5156
5193
  case 3:
5157
- if (tag != 26) {
5194
+ if (tag !== 26) {
5158
5195
  break;
5159
5196
  }
5160
5197
  message.cid = reader.string();
5161
5198
  continue;
5162
5199
  case 4:
5163
- if (tag != 34) {
5200
+ if (tag !== 34) {
5164
5201
  break;
5165
5202
  }
5166
5203
  message.layers.push(VideoLayer.decode(reader, reader.uint32()));
5167
5204
  continue;
5168
5205
  }
5169
- if ((tag & 7) == 4 || tag == 0) {
5206
+ if ((tag & 7) === 4 || tag === 0) {
5170
5207
  break;
5171
5208
  }
5172
5209
  reader.skipType(tag & 7);
@@ -5287,103 +5324,103 @@ const TrackInfo = {
5287
5324
  const tag = reader.uint32();
5288
5325
  switch (tag >>> 3) {
5289
5326
  case 1:
5290
- if (tag != 10) {
5327
+ if (tag !== 10) {
5291
5328
  break;
5292
5329
  }
5293
5330
  message.sid = reader.string();
5294
5331
  continue;
5295
5332
  case 2:
5296
- if (tag != 16) {
5333
+ if (tag !== 16) {
5297
5334
  break;
5298
5335
  }
5299
5336
  message.type = reader.int32();
5300
5337
  continue;
5301
5338
  case 3:
5302
- if (tag != 26) {
5339
+ if (tag !== 26) {
5303
5340
  break;
5304
5341
  }
5305
5342
  message.name = reader.string();
5306
5343
  continue;
5307
5344
  case 4:
5308
- if (tag != 32) {
5345
+ if (tag !== 32) {
5309
5346
  break;
5310
5347
  }
5311
5348
  message.muted = reader.bool();
5312
5349
  continue;
5313
5350
  case 5:
5314
- if (tag != 40) {
5351
+ if (tag !== 40) {
5315
5352
  break;
5316
5353
  }
5317
5354
  message.width = reader.uint32();
5318
5355
  continue;
5319
5356
  case 6:
5320
- if (tag != 48) {
5357
+ if (tag !== 48) {
5321
5358
  break;
5322
5359
  }
5323
5360
  message.height = reader.uint32();
5324
5361
  continue;
5325
5362
  case 7:
5326
- if (tag != 56) {
5363
+ if (tag !== 56) {
5327
5364
  break;
5328
5365
  }
5329
5366
  message.simulcast = reader.bool();
5330
5367
  continue;
5331
5368
  case 8:
5332
- if (tag != 64) {
5369
+ if (tag !== 64) {
5333
5370
  break;
5334
5371
  }
5335
5372
  message.disableDtx = reader.bool();
5336
5373
  continue;
5337
5374
  case 9:
5338
- if (tag != 72) {
5375
+ if (tag !== 72) {
5339
5376
  break;
5340
5377
  }
5341
5378
  message.source = reader.int32();
5342
5379
  continue;
5343
5380
  case 10:
5344
- if (tag != 82) {
5381
+ if (tag !== 82) {
5345
5382
  break;
5346
5383
  }
5347
5384
  message.layers.push(VideoLayer.decode(reader, reader.uint32()));
5348
5385
  continue;
5349
5386
  case 11:
5350
- if (tag != 90) {
5387
+ if (tag !== 90) {
5351
5388
  break;
5352
5389
  }
5353
5390
  message.mimeType = reader.string();
5354
5391
  continue;
5355
5392
  case 12:
5356
- if (tag != 98) {
5393
+ if (tag !== 98) {
5357
5394
  break;
5358
5395
  }
5359
5396
  message.mid = reader.string();
5360
5397
  continue;
5361
5398
  case 13:
5362
- if (tag != 106) {
5399
+ if (tag !== 106) {
5363
5400
  break;
5364
5401
  }
5365
5402
  message.codecs.push(SimulcastCodecInfo.decode(reader, reader.uint32()));
5366
5403
  continue;
5367
5404
  case 14:
5368
- if (tag != 112) {
5405
+ if (tag !== 112) {
5369
5406
  break;
5370
5407
  }
5371
5408
  message.stereo = reader.bool();
5372
5409
  continue;
5373
5410
  case 15:
5374
- if (tag != 120) {
5411
+ if (tag !== 120) {
5375
5412
  break;
5376
5413
  }
5377
5414
  message.disableRed = reader.bool();
5378
5415
  continue;
5379
5416
  case 16:
5380
- if (tag != 128) {
5417
+ if (tag !== 128) {
5381
5418
  break;
5382
5419
  }
5383
5420
  message.encryption = reader.int32();
5384
5421
  continue;
5385
5422
  }
5386
- if ((tag & 7) == 4 || tag == 0) {
5423
+ if ((tag & 7) === 4 || tag === 0) {
5387
5424
  break;
5388
5425
  }
5389
5426
  reader.skipType(tag & 7);
@@ -5500,37 +5537,37 @@ const VideoLayer = {
5500
5537
  const tag = reader.uint32();
5501
5538
  switch (tag >>> 3) {
5502
5539
  case 1:
5503
- if (tag != 8) {
5540
+ if (tag !== 8) {
5504
5541
  break;
5505
5542
  }
5506
5543
  message.quality = reader.int32();
5507
5544
  continue;
5508
5545
  case 2:
5509
- if (tag != 16) {
5546
+ if (tag !== 16) {
5510
5547
  break;
5511
5548
  }
5512
5549
  message.width = reader.uint32();
5513
5550
  continue;
5514
5551
  case 3:
5515
- if (tag != 24) {
5552
+ if (tag !== 24) {
5516
5553
  break;
5517
5554
  }
5518
5555
  message.height = reader.uint32();
5519
5556
  continue;
5520
5557
  case 4:
5521
- if (tag != 32) {
5558
+ if (tag !== 32) {
5522
5559
  break;
5523
5560
  }
5524
5561
  message.bitrate = reader.uint32();
5525
5562
  continue;
5526
5563
  case 5:
5527
- if (tag != 40) {
5564
+ if (tag !== 40) {
5528
5565
  break;
5529
5566
  }
5530
5567
  message.ssrc = reader.uint32();
5531
5568
  continue;
5532
5569
  }
5533
- if ((tag & 7) == 4 || tag == 0) {
5570
+ if ((tag & 7) === 4 || tag === 0) {
5534
5571
  break;
5535
5572
  }
5536
5573
  reader.skipType(tag & 7);
@@ -5600,13 +5637,13 @@ const DataPacket = {
5600
5637
  const tag = reader.uint32();
5601
5638
  switch (tag >>> 3) {
5602
5639
  case 1:
5603
- if (tag != 8) {
5640
+ if (tag !== 8) {
5604
5641
  break;
5605
5642
  }
5606
5643
  message.kind = reader.int32();
5607
5644
  continue;
5608
5645
  case 2:
5609
- if (tag != 18) {
5646
+ if (tag !== 18) {
5610
5647
  break;
5611
5648
  }
5612
5649
  message.value = {
@@ -5615,7 +5652,7 @@ const DataPacket = {
5615
5652
  };
5616
5653
  continue;
5617
5654
  case 3:
5618
- if (tag != 26) {
5655
+ if (tag !== 26) {
5619
5656
  break;
5620
5657
  }
5621
5658
  message.value = {
@@ -5624,7 +5661,7 @@ const DataPacket = {
5624
5661
  };
5625
5662
  continue;
5626
5663
  }
5627
- if ((tag & 7) == 4 || tag == 0) {
5664
+ if ((tag & 7) === 4 || tag === 0) {
5628
5665
  break;
5629
5666
  }
5630
5667
  reader.skipType(tag & 7);
@@ -5694,13 +5731,13 @@ const ActiveSpeakerUpdate = {
5694
5731
  const tag = reader.uint32();
5695
5732
  switch (tag >>> 3) {
5696
5733
  case 1:
5697
- if (tag != 10) {
5734
+ if (tag !== 10) {
5698
5735
  break;
5699
5736
  }
5700
5737
  message.speakers.push(SpeakerInfo.decode(reader, reader.uint32()));
5701
5738
  continue;
5702
5739
  }
5703
- if ((tag & 7) == 4 || tag == 0) {
5740
+ if ((tag & 7) === 4 || tag === 0) {
5704
5741
  break;
5705
5742
  }
5706
5743
  reader.skipType(tag & 7);
@@ -5760,25 +5797,25 @@ const SpeakerInfo = {
5760
5797
  const tag = reader.uint32();
5761
5798
  switch (tag >>> 3) {
5762
5799
  case 1:
5763
- if (tag != 10) {
5800
+ if (tag !== 10) {
5764
5801
  break;
5765
5802
  }
5766
5803
  message.sid = reader.string();
5767
5804
  continue;
5768
5805
  case 2:
5769
- if (tag != 21) {
5806
+ if (tag !== 21) {
5770
5807
  break;
5771
5808
  }
5772
5809
  message.level = reader.float();
5773
5810
  continue;
5774
5811
  case 3:
5775
- if (tag != 24) {
5812
+ if (tag !== 24) {
5776
5813
  break;
5777
5814
  }
5778
5815
  message.active = reader.bool();
5779
5816
  continue;
5780
5817
  }
5781
- if ((tag & 7) == 4 || tag == 0) {
5818
+ if ((tag & 7) === 4 || tag === 0) {
5782
5819
  break;
5783
5820
  }
5784
5821
  reader.skipType(tag & 7);
@@ -5844,31 +5881,31 @@ const UserPacket = {
5844
5881
  const tag = reader.uint32();
5845
5882
  switch (tag >>> 3) {
5846
5883
  case 1:
5847
- if (tag != 10) {
5884
+ if (tag !== 10) {
5848
5885
  break;
5849
5886
  }
5850
5887
  message.participantSid = reader.string();
5851
5888
  continue;
5852
5889
  case 2:
5853
- if (tag != 18) {
5890
+ if (tag !== 18) {
5854
5891
  break;
5855
5892
  }
5856
5893
  message.payload = reader.bytes();
5857
5894
  continue;
5858
5895
  case 3:
5859
- if (tag != 26) {
5896
+ if (tag !== 26) {
5860
5897
  break;
5861
5898
  }
5862
5899
  message.destinationSids.push(reader.string());
5863
5900
  continue;
5864
5901
  case 4:
5865
- if (tag != 34) {
5902
+ if (tag !== 34) {
5866
5903
  break;
5867
5904
  }
5868
5905
  message.topic = reader.string();
5869
5906
  continue;
5870
5907
  }
5871
- if ((tag & 7) == 4 || tag == 0) {
5908
+ if ((tag & 7) === 4 || tag === 0) {
5872
5909
  break;
5873
5910
  }
5874
5911
  reader.skipType(tag & 7);
@@ -5878,7 +5915,7 @@ const UserPacket = {
5878
5915
  fromJSON(object) {
5879
5916
  return {
5880
5917
  participantSid: isSet$1(object.participantSid) ? String(object.participantSid) : "",
5881
- payload: isSet$1(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(),
5918
+ payload: isSet$1(object.payload) ? bytesFromBase64$1(object.payload) : new Uint8Array(),
5882
5919
  destinationSids: Array.isArray(object === null || object === void 0 ? void 0 : object.destinationSids) ? object.destinationSids.map(e => String(e)) : [],
5883
5920
  topic: isSet$1(object.topic) ? String(object.topic) : undefined
5884
5921
  };
@@ -5886,7 +5923,7 @@ const UserPacket = {
5886
5923
  toJSON(message) {
5887
5924
  const obj = {};
5888
5925
  message.participantSid !== undefined && (obj.participantSid = message.participantSid);
5889
- message.payload !== undefined && (obj.payload = base64FromBytes(message.payload !== undefined ? message.payload : new Uint8Array()));
5926
+ message.payload !== undefined && (obj.payload = base64FromBytes$1(message.payload !== undefined ? message.payload : new Uint8Array()));
5890
5927
  if (message.destinationSids) {
5891
5928
  obj.destinationSids = message.destinationSids.map(e => e);
5892
5929
  } else {
@@ -5933,19 +5970,19 @@ const ParticipantTracks = {
5933
5970
  const tag = reader.uint32();
5934
5971
  switch (tag >>> 3) {
5935
5972
  case 1:
5936
- if (tag != 10) {
5973
+ if (tag !== 10) {
5937
5974
  break;
5938
5975
  }
5939
5976
  message.participantSid = reader.string();
5940
5977
  continue;
5941
5978
  case 2:
5942
- if (tag != 18) {
5979
+ if (tag !== 18) {
5943
5980
  break;
5944
5981
  }
5945
5982
  message.trackSids.push(reader.string());
5946
5983
  continue;
5947
5984
  }
5948
- if ((tag & 7) == 4 || tag == 0) {
5985
+ if ((tag & 7) === 4 || tag === 0) {
5949
5986
  break;
5950
5987
  }
5951
5988
  reader.skipType(tag & 7);
@@ -6020,43 +6057,43 @@ const ServerInfo = {
6020
6057
  const tag = reader.uint32();
6021
6058
  switch (tag >>> 3) {
6022
6059
  case 1:
6023
- if (tag != 8) {
6060
+ if (tag !== 8) {
6024
6061
  break;
6025
6062
  }
6026
6063
  message.edition = reader.int32();
6027
6064
  continue;
6028
6065
  case 2:
6029
- if (tag != 18) {
6066
+ if (tag !== 18) {
6030
6067
  break;
6031
6068
  }
6032
6069
  message.version = reader.string();
6033
6070
  continue;
6034
6071
  case 3:
6035
- if (tag != 24) {
6072
+ if (tag !== 24) {
6036
6073
  break;
6037
6074
  }
6038
6075
  message.protocol = reader.int32();
6039
6076
  continue;
6040
6077
  case 4:
6041
- if (tag != 34) {
6078
+ if (tag !== 34) {
6042
6079
  break;
6043
6080
  }
6044
6081
  message.region = reader.string();
6045
6082
  continue;
6046
6083
  case 5:
6047
- if (tag != 42) {
6084
+ if (tag !== 42) {
6048
6085
  break;
6049
6086
  }
6050
6087
  message.nodeId = reader.string();
6051
6088
  continue;
6052
6089
  case 6:
6053
- if (tag != 50) {
6090
+ if (tag !== 50) {
6054
6091
  break;
6055
6092
  }
6056
6093
  message.debugInfo = reader.string();
6057
6094
  continue;
6058
6095
  }
6059
- if ((tag & 7) == 4 || tag == 0) {
6096
+ if ((tag & 7) === 4 || tag === 0) {
6060
6097
  break;
6061
6098
  }
6062
6099
  reader.skipType(tag & 7);
@@ -6155,67 +6192,67 @@ const ClientInfo = {
6155
6192
  const tag = reader.uint32();
6156
6193
  switch (tag >>> 3) {
6157
6194
  case 1:
6158
- if (tag != 8) {
6195
+ if (tag !== 8) {
6159
6196
  break;
6160
6197
  }
6161
6198
  message.sdk = reader.int32();
6162
6199
  continue;
6163
6200
  case 2:
6164
- if (tag != 18) {
6201
+ if (tag !== 18) {
6165
6202
  break;
6166
6203
  }
6167
6204
  message.version = reader.string();
6168
6205
  continue;
6169
6206
  case 3:
6170
- if (tag != 24) {
6207
+ if (tag !== 24) {
6171
6208
  break;
6172
6209
  }
6173
6210
  message.protocol = reader.int32();
6174
6211
  continue;
6175
6212
  case 4:
6176
- if (tag != 34) {
6213
+ if (tag !== 34) {
6177
6214
  break;
6178
6215
  }
6179
6216
  message.os = reader.string();
6180
6217
  continue;
6181
6218
  case 5:
6182
- if (tag != 42) {
6219
+ if (tag !== 42) {
6183
6220
  break;
6184
6221
  }
6185
6222
  message.osVersion = reader.string();
6186
6223
  continue;
6187
6224
  case 6:
6188
- if (tag != 50) {
6225
+ if (tag !== 50) {
6189
6226
  break;
6190
6227
  }
6191
6228
  message.deviceModel = reader.string();
6192
6229
  continue;
6193
6230
  case 7:
6194
- if (tag != 58) {
6231
+ if (tag !== 58) {
6195
6232
  break;
6196
6233
  }
6197
6234
  message.browser = reader.string();
6198
6235
  continue;
6199
6236
  case 8:
6200
- if (tag != 66) {
6237
+ if (tag !== 66) {
6201
6238
  break;
6202
6239
  }
6203
6240
  message.browserVersion = reader.string();
6204
6241
  continue;
6205
6242
  case 9:
6206
- if (tag != 74) {
6243
+ if (tag !== 74) {
6207
6244
  break;
6208
6245
  }
6209
6246
  message.address = reader.string();
6210
6247
  continue;
6211
6248
  case 10:
6212
- if (tag != 82) {
6249
+ if (tag !== 82) {
6213
6250
  break;
6214
6251
  }
6215
6252
  message.network = reader.string();
6216
6253
  continue;
6217
6254
  }
6218
- if ((tag & 7) == 4 || tag == 0) {
6255
+ if ((tag & 7) === 4 || tag === 0) {
6219
6256
  break;
6220
6257
  }
6221
6258
  reader.skipType(tag & 7);
@@ -6306,37 +6343,37 @@ const ClientConfiguration = {
6306
6343
  const tag = reader.uint32();
6307
6344
  switch (tag >>> 3) {
6308
6345
  case 1:
6309
- if (tag != 10) {
6346
+ if (tag !== 10) {
6310
6347
  break;
6311
6348
  }
6312
6349
  message.video = VideoConfiguration.decode(reader, reader.uint32());
6313
6350
  continue;
6314
6351
  case 2:
6315
- if (tag != 18) {
6352
+ if (tag !== 18) {
6316
6353
  break;
6317
6354
  }
6318
6355
  message.screen = VideoConfiguration.decode(reader, reader.uint32());
6319
6356
  continue;
6320
6357
  case 3:
6321
- if (tag != 24) {
6358
+ if (tag !== 24) {
6322
6359
  break;
6323
6360
  }
6324
6361
  message.resumeConnection = reader.int32();
6325
6362
  continue;
6326
6363
  case 4:
6327
- if (tag != 34) {
6364
+ if (tag !== 34) {
6328
6365
  break;
6329
6366
  }
6330
6367
  message.disabledCodecs = DisabledCodecs.decode(reader, reader.uint32());
6331
6368
  continue;
6332
6369
  case 5:
6333
- if (tag != 40) {
6370
+ if (tag !== 40) {
6334
6371
  break;
6335
6372
  }
6336
6373
  message.forceRelay = reader.int32();
6337
6374
  continue;
6338
6375
  }
6339
- if ((tag & 7) == 4 || tag == 0) {
6376
+ if ((tag & 7) === 4 || tag === 0) {
6340
6377
  break;
6341
6378
  }
6342
6379
  reader.skipType(tag & 7);
@@ -6396,13 +6433,13 @@ const VideoConfiguration = {
6396
6433
  const tag = reader.uint32();
6397
6434
  switch (tag >>> 3) {
6398
6435
  case 1:
6399
- if (tag != 8) {
6436
+ if (tag !== 8) {
6400
6437
  break;
6401
6438
  }
6402
6439
  message.hardwareEncoder = reader.int32();
6403
6440
  continue;
6404
6441
  }
6405
- if ((tag & 7) == 4 || tag == 0) {
6442
+ if ((tag & 7) === 4 || tag === 0) {
6406
6443
  break;
6407
6444
  }
6408
6445
  reader.skipType(tag & 7);
@@ -6431,7 +6468,8 @@ const VideoConfiguration = {
6431
6468
  };
6432
6469
  function createBaseDisabledCodecs() {
6433
6470
  return {
6434
- codecs: []
6471
+ codecs: [],
6472
+ publish: []
6435
6473
  };
6436
6474
  }
6437
6475
  const DisabledCodecs = {
@@ -6440,6 +6478,9 @@ const DisabledCodecs = {
6440
6478
  for (const v of message.codecs) {
6441
6479
  Codec.encode(v, writer.uint32(10).fork()).ldelim();
6442
6480
  }
6481
+ for (const v of message.publish) {
6482
+ Codec.encode(v, writer.uint32(18).fork()).ldelim();
6483
+ }
6443
6484
  return writer;
6444
6485
  },
6445
6486
  decode(input, length) {
@@ -6450,13 +6491,19 @@ const DisabledCodecs = {
6450
6491
  const tag = reader.uint32();
6451
6492
  switch (tag >>> 3) {
6452
6493
  case 1:
6453
- if (tag != 10) {
6494
+ if (tag !== 10) {
6454
6495
  break;
6455
6496
  }
6456
6497
  message.codecs.push(Codec.decode(reader, reader.uint32()));
6457
6498
  continue;
6499
+ case 2:
6500
+ if (tag !== 18) {
6501
+ break;
6502
+ }
6503
+ message.publish.push(Codec.decode(reader, reader.uint32()));
6504
+ continue;
6458
6505
  }
6459
- if ((tag & 7) == 4 || tag == 0) {
6506
+ if ((tag & 7) === 4 || tag === 0) {
6460
6507
  break;
6461
6508
  }
6462
6509
  reader.skipType(tag & 7);
@@ -6465,7 +6512,8 @@ const DisabledCodecs = {
6465
6512
  },
6466
6513
  fromJSON(object) {
6467
6514
  return {
6468
- codecs: Array.isArray(object === null || object === void 0 ? void 0 : object.codecs) ? object.codecs.map(e => Codec.fromJSON(e)) : []
6515
+ codecs: Array.isArray(object === null || object === void 0 ? void 0 : object.codecs) ? object.codecs.map(e => Codec.fromJSON(e)) : [],
6516
+ publish: Array.isArray(object === null || object === void 0 ? void 0 : object.publish) ? object.publish.map(e => Codec.fromJSON(e)) : []
6469
6517
  };
6470
6518
  },
6471
6519
  toJSON(message) {
@@ -6475,15 +6523,21 @@ const DisabledCodecs = {
6475
6523
  } else {
6476
6524
  obj.codecs = [];
6477
6525
  }
6526
+ if (message.publish) {
6527
+ obj.publish = message.publish.map(e => e ? Codec.toJSON(e) : undefined);
6528
+ } else {
6529
+ obj.publish = [];
6530
+ }
6478
6531
  return obj;
6479
6532
  },
6480
6533
  create(base) {
6481
6534
  return DisabledCodecs.fromPartial(base !== null && base !== void 0 ? base : {});
6482
6535
  },
6483
6536
  fromPartial(object) {
6484
- var _a;
6537
+ var _a, _b;
6485
6538
  const message = createBaseDisabledCodecs();
6486
6539
  message.codecs = ((_a = object.codecs) === null || _a === void 0 ? void 0 : _a.map(e => Codec.fromPartial(e))) || [];
6540
+ message.publish = ((_b = object.publish) === null || _b === void 0 ? void 0 : _b.map(e => Codec.fromPartial(e))) || [];
6487
6541
  return message;
6488
6542
  }
6489
6543
  };
@@ -6502,7 +6556,7 @@ var tsProtoGlobalThis$1 = (() => {
6502
6556
  }
6503
6557
  throw "Unable to locate global object";
6504
6558
  })();
6505
- function bytesFromBase64(b64) {
6559
+ function bytesFromBase64$1(b64) {
6506
6560
  if (tsProtoGlobalThis$1.Buffer) {
6507
6561
  return Uint8Array.from(tsProtoGlobalThis$1.Buffer.from(b64, "base64"));
6508
6562
  } else {
@@ -6514,7 +6568,7 @@ function bytesFromBase64(b64) {
6514
6568
  return arr;
6515
6569
  }
6516
6570
  }
6517
- function base64FromBytes(arr) {
6571
+ function base64FromBytes$1(arr) {
6518
6572
  if (tsProtoGlobalThis$1.Buffer) {
6519
6573
  return tsProtoGlobalThis$1.Buffer.from(arr).toString("base64");
6520
6574
  } else {
@@ -6567,6 +6621,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6567
6621
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6568
6622
  PERFORMANCE OF THIS SOFTWARE.
6569
6623
  ***************************************************************************** */
6624
+ /* global Reflect, Promise */
6625
+
6570
6626
 
6571
6627
  function __awaiter(thisArg, _arguments, P, generator) {
6572
6628
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -6986,6 +7042,7 @@ var eventsExports = events.exports;
6986
7042
  * that can be found in the LICENSE file in the root of the source
6987
7043
  * tree.
6988
7044
  */
7045
+ /* eslint-env node */
6989
7046
 
6990
7047
  let logDisabled_ = true;
6991
7048
  let deprecationWarnings_ = true;
@@ -7232,6 +7289,7 @@ function filterStats(result, track, outbound) {
7232
7289
  * that can be found in the LICENSE file in the root of the source
7233
7290
  * tree.
7234
7291
  */
7292
+ /* eslint-env node */
7235
7293
  const logging = log;
7236
7294
  function shimGetUserMedia$2(window, browserDetails) {
7237
7295
  const navigator = window && window.navigator;
@@ -7411,6 +7469,7 @@ function shimGetUserMedia$2(window, browserDetails) {
7411
7469
  * that can be found in the LICENSE file in the root of the source
7412
7470
  * tree.
7413
7471
  */
7472
+ /* eslint-env node */
7414
7473
 
7415
7474
  function shimGetDisplayMedia$1(window, getSourceId) {
7416
7475
  if (window.navigator.mediaDevices && 'getDisplayMedia' in window.navigator.mediaDevices) {
@@ -7455,6 +7514,7 @@ function shimGetDisplayMedia$1(window, getSourceId) {
7455
7514
  * that can be found in the LICENSE file in the root of the source
7456
7515
  * tree.
7457
7516
  */
7517
+ /* eslint-env node */
7458
7518
  function shimMediaStream(window) {
7459
7519
  window.MediaStream = window.MediaStream || window.webkitMediaStream;
7460
7520
  }
@@ -8080,6 +8140,7 @@ var chromeShim = /*#__PURE__*/Object.freeze({
8080
8140
  * that can be found in the LICENSE file in the root of the source
8081
8141
  * tree.
8082
8142
  */
8143
+ /* eslint-env node */
8083
8144
  function shimGetUserMedia$1(window, browserDetails) {
8084
8145
  const navigator = window && window.navigator;
8085
8146
  const MediaStreamTrack = window && window.MediaStreamTrack;
@@ -8134,6 +8195,7 @@ function shimGetUserMedia$1(window, browserDetails) {
8134
8195
  * that can be found in the LICENSE file in the root of the source
8135
8196
  * tree.
8136
8197
  */
8198
+ /* eslint-env node */
8137
8199
 
8138
8200
  function shimGetDisplayMedia(window, preferredMediaSource) {
8139
8201
  if (window.navigator.mediaDevices && 'getDisplayMedia' in window.navigator.mediaDevices) {
@@ -8168,6 +8230,7 @@ function shimGetDisplayMedia(window, preferredMediaSource) {
8168
8230
  * that can be found in the LICENSE file in the root of the source
8169
8231
  * tree.
8170
8232
  */
8233
+ /* eslint-env node */
8171
8234
  function shimOnTrack(window) {
8172
8235
  if (typeof window === 'object' && window.RTCTrackEvent && 'receiver' in window.RTCTrackEvent.prototype && !('transceiver' in window.RTCTrackEvent.prototype)) {
8173
8236
  Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
@@ -9533,6 +9596,7 @@ var sdp = /*#__PURE__*/_mergeNamespaces({
9533
9596
  * that can be found in the LICENSE file in the root of the source
9534
9597
  * tree.
9535
9598
  */
9599
+ /* eslint-env node */
9536
9600
  function shimRTCIceCandidate(window) {
9537
9601
  // foundation is arbitrarily chosen as an indicator for full support for
9538
9602
  // https://w3c.github.io/webrtc-pc/#rtcicecandidate-interface
@@ -10086,6 +10150,8 @@ function adapterFactory() {
10086
10150
  * that can be found in the LICENSE file in the root of the source
10087
10151
  * tree.
10088
10152
  */
10153
+ /* eslint-env node */
10154
+
10089
10155
  adapterFactory({
10090
10156
  window: typeof window === 'undefined' ? undefined : window
10091
10157
  });
@@ -10256,7 +10322,7 @@ const SignalRequest = {
10256
10322
  const tag = reader.uint32();
10257
10323
  switch (tag >>> 3) {
10258
10324
  case 1:
10259
- if (tag != 10) {
10325
+ if (tag !== 10) {
10260
10326
  break;
10261
10327
  }
10262
10328
  message.message = {
@@ -10265,7 +10331,7 @@ const SignalRequest = {
10265
10331
  };
10266
10332
  continue;
10267
10333
  case 2:
10268
- if (tag != 18) {
10334
+ if (tag !== 18) {
10269
10335
  break;
10270
10336
  }
10271
10337
  message.message = {
@@ -10274,7 +10340,7 @@ const SignalRequest = {
10274
10340
  };
10275
10341
  continue;
10276
10342
  case 3:
10277
- if (tag != 26) {
10343
+ if (tag !== 26) {
10278
10344
  break;
10279
10345
  }
10280
10346
  message.message = {
@@ -10283,7 +10349,7 @@ const SignalRequest = {
10283
10349
  };
10284
10350
  continue;
10285
10351
  case 4:
10286
- if (tag != 34) {
10352
+ if (tag !== 34) {
10287
10353
  break;
10288
10354
  }
10289
10355
  message.message = {
@@ -10292,7 +10358,7 @@ const SignalRequest = {
10292
10358
  };
10293
10359
  continue;
10294
10360
  case 5:
10295
- if (tag != 42) {
10361
+ if (tag !== 42) {
10296
10362
  break;
10297
10363
  }
10298
10364
  message.message = {
@@ -10301,7 +10367,7 @@ const SignalRequest = {
10301
10367
  };
10302
10368
  continue;
10303
10369
  case 6:
10304
- if (tag != 50) {
10370
+ if (tag !== 50) {
10305
10371
  break;
10306
10372
  }
10307
10373
  message.message = {
@@ -10310,7 +10376,7 @@ const SignalRequest = {
10310
10376
  };
10311
10377
  continue;
10312
10378
  case 7:
10313
- if (tag != 58) {
10379
+ if (tag !== 58) {
10314
10380
  break;
10315
10381
  }
10316
10382
  message.message = {
@@ -10319,7 +10385,7 @@ const SignalRequest = {
10319
10385
  };
10320
10386
  continue;
10321
10387
  case 8:
10322
- if (tag != 66) {
10388
+ if (tag !== 66) {
10323
10389
  break;
10324
10390
  }
10325
10391
  message.message = {
@@ -10328,7 +10394,7 @@ const SignalRequest = {
10328
10394
  };
10329
10395
  continue;
10330
10396
  case 10:
10331
- if (tag != 82) {
10397
+ if (tag !== 82) {
10332
10398
  break;
10333
10399
  }
10334
10400
  message.message = {
@@ -10337,7 +10403,7 @@ const SignalRequest = {
10337
10403
  };
10338
10404
  continue;
10339
10405
  case 11:
10340
- if (tag != 90) {
10406
+ if (tag !== 90) {
10341
10407
  break;
10342
10408
  }
10343
10409
  message.message = {
@@ -10346,7 +10412,7 @@ const SignalRequest = {
10346
10412
  };
10347
10413
  continue;
10348
10414
  case 12:
10349
- if (tag != 98) {
10415
+ if (tag !== 98) {
10350
10416
  break;
10351
10417
  }
10352
10418
  message.message = {
@@ -10355,7 +10421,7 @@ const SignalRequest = {
10355
10421
  };
10356
10422
  continue;
10357
10423
  case 13:
10358
- if (tag != 106) {
10424
+ if (tag !== 106) {
10359
10425
  break;
10360
10426
  }
10361
10427
  message.message = {
@@ -10364,7 +10430,7 @@ const SignalRequest = {
10364
10430
  };
10365
10431
  continue;
10366
10432
  case 14:
10367
- if (tag != 112) {
10433
+ if (tag !== 112) {
10368
10434
  break;
10369
10435
  }
10370
10436
  message.message = {
@@ -10373,7 +10439,7 @@ const SignalRequest = {
10373
10439
  };
10374
10440
  continue;
10375
10441
  case 15:
10376
- if (tag != 122) {
10442
+ if (tag !== 122) {
10377
10443
  break;
10378
10444
  }
10379
10445
  message.message = {
@@ -10382,7 +10448,7 @@ const SignalRequest = {
10382
10448
  };
10383
10449
  continue;
10384
10450
  case 16:
10385
- if (tag != 130) {
10451
+ if (tag !== 130) {
10386
10452
  break;
10387
10453
  }
10388
10454
  message.message = {
@@ -10391,7 +10457,7 @@ const SignalRequest = {
10391
10457
  };
10392
10458
  continue;
10393
10459
  }
10394
- if ((tag & 7) == 4 || tag == 0) {
10460
+ if ((tag & 7) === 4 || tag === 0) {
10395
10461
  break;
10396
10462
  }
10397
10463
  reader.skipType(tag & 7);
@@ -10634,6 +10700,9 @@ const SignalResponse = {
10634
10700
  case "pongResp":
10635
10701
  Pong.encode(message.message.pongResp, writer.uint32(162).fork()).ldelim();
10636
10702
  break;
10703
+ case "subscriptionResponse":
10704
+ SubscriptionResponse.encode(message.message.subscriptionResponse, writer.uint32(170).fork()).ldelim();
10705
+ break;
10637
10706
  }
10638
10707
  return writer;
10639
10708
  },
@@ -10645,7 +10714,7 @@ const SignalResponse = {
10645
10714
  const tag = reader.uint32();
10646
10715
  switch (tag >>> 3) {
10647
10716
  case 1:
10648
- if (tag != 10) {
10717
+ if (tag !== 10) {
10649
10718
  break;
10650
10719
  }
10651
10720
  message.message = {
@@ -10654,7 +10723,7 @@ const SignalResponse = {
10654
10723
  };
10655
10724
  continue;
10656
10725
  case 2:
10657
- if (tag != 18) {
10726
+ if (tag !== 18) {
10658
10727
  break;
10659
10728
  }
10660
10729
  message.message = {
@@ -10663,7 +10732,7 @@ const SignalResponse = {
10663
10732
  };
10664
10733
  continue;
10665
10734
  case 3:
10666
- if (tag != 26) {
10735
+ if (tag !== 26) {
10667
10736
  break;
10668
10737
  }
10669
10738
  message.message = {
@@ -10672,7 +10741,7 @@ const SignalResponse = {
10672
10741
  };
10673
10742
  continue;
10674
10743
  case 4:
10675
- if (tag != 34) {
10744
+ if (tag !== 34) {
10676
10745
  break;
10677
10746
  }
10678
10747
  message.message = {
@@ -10681,7 +10750,7 @@ const SignalResponse = {
10681
10750
  };
10682
10751
  continue;
10683
10752
  case 5:
10684
- if (tag != 42) {
10753
+ if (tag !== 42) {
10685
10754
  break;
10686
10755
  }
10687
10756
  message.message = {
@@ -10690,7 +10759,7 @@ const SignalResponse = {
10690
10759
  };
10691
10760
  continue;
10692
10761
  case 6:
10693
- if (tag != 50) {
10762
+ if (tag !== 50) {
10694
10763
  break;
10695
10764
  }
10696
10765
  message.message = {
@@ -10699,7 +10768,7 @@ const SignalResponse = {
10699
10768
  };
10700
10769
  continue;
10701
10770
  case 8:
10702
- if (tag != 66) {
10771
+ if (tag !== 66) {
10703
10772
  break;
10704
10773
  }
10705
10774
  message.message = {
@@ -10708,7 +10777,7 @@ const SignalResponse = {
10708
10777
  };
10709
10778
  continue;
10710
10779
  case 9:
10711
- if (tag != 74) {
10780
+ if (tag !== 74) {
10712
10781
  break;
10713
10782
  }
10714
10783
  message.message = {
@@ -10717,7 +10786,7 @@ const SignalResponse = {
10717
10786
  };
10718
10787
  continue;
10719
10788
  case 10:
10720
- if (tag != 82) {
10789
+ if (tag !== 82) {
10721
10790
  break;
10722
10791
  }
10723
10792
  message.message = {
@@ -10726,7 +10795,7 @@ const SignalResponse = {
10726
10795
  };
10727
10796
  continue;
10728
10797
  case 11:
10729
- if (tag != 90) {
10798
+ if (tag !== 90) {
10730
10799
  break;
10731
10800
  }
10732
10801
  message.message = {
@@ -10735,7 +10804,7 @@ const SignalResponse = {
10735
10804
  };
10736
10805
  continue;
10737
10806
  case 12:
10738
- if (tag != 98) {
10807
+ if (tag !== 98) {
10739
10808
  break;
10740
10809
  }
10741
10810
  message.message = {
@@ -10744,7 +10813,7 @@ const SignalResponse = {
10744
10813
  };
10745
10814
  continue;
10746
10815
  case 13:
10747
- if (tag != 106) {
10816
+ if (tag !== 106) {
10748
10817
  break;
10749
10818
  }
10750
10819
  message.message = {
@@ -10753,7 +10822,7 @@ const SignalResponse = {
10753
10822
  };
10754
10823
  continue;
10755
10824
  case 14:
10756
- if (tag != 114) {
10825
+ if (tag !== 114) {
10757
10826
  break;
10758
10827
  }
10759
10828
  message.message = {
@@ -10762,7 +10831,7 @@ const SignalResponse = {
10762
10831
  };
10763
10832
  continue;
10764
10833
  case 15:
10765
- if (tag != 122) {
10834
+ if (tag !== 122) {
10766
10835
  break;
10767
10836
  }
10768
10837
  message.message = {
@@ -10771,7 +10840,7 @@ const SignalResponse = {
10771
10840
  };
10772
10841
  continue;
10773
10842
  case 16:
10774
- if (tag != 130) {
10843
+ if (tag !== 130) {
10775
10844
  break;
10776
10845
  }
10777
10846
  message.message = {
@@ -10780,7 +10849,7 @@ const SignalResponse = {
10780
10849
  };
10781
10850
  continue;
10782
10851
  case 17:
10783
- if (tag != 138) {
10852
+ if (tag !== 138) {
10784
10853
  break;
10785
10854
  }
10786
10855
  message.message = {
@@ -10789,7 +10858,7 @@ const SignalResponse = {
10789
10858
  };
10790
10859
  continue;
10791
10860
  case 18:
10792
- if (tag != 144) {
10861
+ if (tag !== 144) {
10793
10862
  break;
10794
10863
  }
10795
10864
  message.message = {
@@ -10798,7 +10867,7 @@ const SignalResponse = {
10798
10867
  };
10799
10868
  continue;
10800
10869
  case 19:
10801
- if (tag != 154) {
10870
+ if (tag !== 154) {
10802
10871
  break;
10803
10872
  }
10804
10873
  message.message = {
@@ -10807,7 +10876,7 @@ const SignalResponse = {
10807
10876
  };
10808
10877
  continue;
10809
10878
  case 20:
10810
- if (tag != 162) {
10879
+ if (tag !== 162) {
10811
10880
  break;
10812
10881
  }
10813
10882
  message.message = {
@@ -10815,8 +10884,17 @@ const SignalResponse = {
10815
10884
  pongResp: Pong.decode(reader, reader.uint32())
10816
10885
  };
10817
10886
  continue;
10887
+ case 21:
10888
+ if (tag !== 170) {
10889
+ break;
10890
+ }
10891
+ message.message = {
10892
+ $case: "subscriptionResponse",
10893
+ subscriptionResponse: SubscriptionResponse.decode(reader, reader.uint32())
10894
+ };
10895
+ continue;
10818
10896
  }
10819
- if ((tag & 7) == 4 || tag == 0) {
10897
+ if ((tag & 7) === 4 || tag === 0) {
10820
10898
  break;
10821
10899
  }
10822
10900
  reader.skipType(tag & 7);
@@ -10882,11 +10960,14 @@ const SignalResponse = {
10882
10960
  } : isSet(object.pongResp) ? {
10883
10961
  $case: "pongResp",
10884
10962
  pongResp: Pong.fromJSON(object.pongResp)
10963
+ } : isSet(object.subscriptionResponse) ? {
10964
+ $case: "subscriptionResponse",
10965
+ subscriptionResponse: SubscriptionResponse.fromJSON(object.subscriptionResponse)
10885
10966
  } : undefined
10886
10967
  };
10887
10968
  },
10888
10969
  toJSON(message) {
10889
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30;
10970
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33;
10890
10971
  const obj = {};
10891
10972
  ((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "join" && (obj.join = ((_b = message.message) === null || _b === void 0 ? void 0 : _b.join) ? JoinResponse.toJSON((_c = message.message) === null || _c === void 0 ? void 0 : _c.join) : undefined);
10892
10973
  ((_d = message.message) === null || _d === void 0 ? void 0 : _d.$case) === "answer" && (obj.answer = ((_e = message.message) === null || _e === void 0 ? void 0 : _e.answer) ? SessionDescription.toJSON((_f = message.message) === null || _f === void 0 ? void 0 : _f.answer) : undefined);
@@ -10907,13 +10988,14 @@ const SignalResponse = {
10907
10988
  ((_23 = message.message) === null || _23 === void 0 ? void 0 : _23.$case) === "pong" && (obj.pong = Math.round((_24 = message.message) === null || _24 === void 0 ? void 0 : _24.pong));
10908
10989
  ((_25 = message.message) === null || _25 === void 0 ? void 0 : _25.$case) === "reconnect" && (obj.reconnect = ((_26 = message.message) === null || _26 === void 0 ? void 0 : _26.reconnect) ? ReconnectResponse.toJSON((_27 = message.message) === null || _27 === void 0 ? void 0 : _27.reconnect) : undefined);
10909
10990
  ((_28 = message.message) === null || _28 === void 0 ? void 0 : _28.$case) === "pongResp" && (obj.pongResp = ((_29 = message.message) === null || _29 === void 0 ? void 0 : _29.pongResp) ? Pong.toJSON((_30 = message.message) === null || _30 === void 0 ? void 0 : _30.pongResp) : undefined);
10991
+ ((_31 = message.message) === null || _31 === void 0 ? void 0 : _31.$case) === "subscriptionResponse" && (obj.subscriptionResponse = ((_32 = message.message) === null || _32 === void 0 ? void 0 : _32.subscriptionResponse) ? SubscriptionResponse.toJSON((_33 = message.message) === null || _33 === void 0 ? void 0 : _33.subscriptionResponse) : undefined);
10910
10992
  return obj;
10911
10993
  },
10912
10994
  create(base) {
10913
10995
  return SignalResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10914
10996
  },
10915
10997
  fromPartial(object) {
10916
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32;
10998
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35;
10917
10999
  const message = createBaseSignalResponse();
10918
11000
  if (((_a = object.message) === null || _a === void 0 ? void 0 : _a.$case) === "join" && ((_b = object.message) === null || _b === void 0 ? void 0 : _b.join) !== undefined && ((_c = object.message) === null || _c === void 0 ? void 0 : _c.join) !== null) {
10919
11001
  message.message = {
@@ -11029,6 +11111,12 @@ const SignalResponse = {
11029
11111
  pongResp: Pong.fromPartial(object.message.pongResp)
11030
11112
  };
11031
11113
  }
11114
+ if (((_33 = object.message) === null || _33 === void 0 ? void 0 : _33.$case) === "subscriptionResponse" && ((_34 = object.message) === null || _34 === void 0 ? void 0 : _34.subscriptionResponse) !== undefined && ((_35 = object.message) === null || _35 === void 0 ? void 0 : _35.subscriptionResponse) !== null) {
11115
+ message.message = {
11116
+ $case: "subscriptionResponse",
11117
+ subscriptionResponse: SubscriptionResponse.fromPartial(object.message.subscriptionResponse)
11118
+ };
11119
+ }
11032
11120
  return message;
11033
11121
  }
11034
11122
  };
@@ -11061,25 +11149,25 @@ const SimulcastCodec = {
11061
11149
  const tag = reader.uint32();
11062
11150
  switch (tag >>> 3) {
11063
11151
  case 1:
11064
- if (tag != 10) {
11152
+ if (tag !== 10) {
11065
11153
  break;
11066
11154
  }
11067
11155
  message.codec = reader.string();
11068
11156
  continue;
11069
11157
  case 2:
11070
- if (tag != 18) {
11158
+ if (tag !== 18) {
11071
11159
  break;
11072
11160
  }
11073
11161
  message.cid = reader.string();
11074
11162
  continue;
11075
11163
  case 3:
11076
- if (tag != 24) {
11164
+ if (tag !== 24) {
11077
11165
  break;
11078
11166
  }
11079
11167
  message.enableSimulcastLayers = reader.bool();
11080
11168
  continue;
11081
11169
  }
11082
- if ((tag & 7) == 4 || tag == 0) {
11170
+ if ((tag & 7) === 4 || tag === 0) {
11083
11171
  break;
11084
11172
  }
11085
11173
  reader.skipType(tag & 7);
@@ -11185,91 +11273,91 @@ const AddTrackRequest = {
11185
11273
  const tag = reader.uint32();
11186
11274
  switch (tag >>> 3) {
11187
11275
  case 1:
11188
- if (tag != 10) {
11276
+ if (tag !== 10) {
11189
11277
  break;
11190
11278
  }
11191
11279
  message.cid = reader.string();
11192
11280
  continue;
11193
11281
  case 2:
11194
- if (tag != 18) {
11282
+ if (tag !== 18) {
11195
11283
  break;
11196
11284
  }
11197
11285
  message.name = reader.string();
11198
11286
  continue;
11199
11287
  case 3:
11200
- if (tag != 24) {
11288
+ if (tag !== 24) {
11201
11289
  break;
11202
11290
  }
11203
11291
  message.type = reader.int32();
11204
11292
  continue;
11205
11293
  case 4:
11206
- if (tag != 32) {
11294
+ if (tag !== 32) {
11207
11295
  break;
11208
11296
  }
11209
11297
  message.width = reader.uint32();
11210
11298
  continue;
11211
11299
  case 5:
11212
- if (tag != 40) {
11300
+ if (tag !== 40) {
11213
11301
  break;
11214
11302
  }
11215
11303
  message.height = reader.uint32();
11216
11304
  continue;
11217
11305
  case 6:
11218
- if (tag != 48) {
11306
+ if (tag !== 48) {
11219
11307
  break;
11220
11308
  }
11221
11309
  message.muted = reader.bool();
11222
11310
  continue;
11223
11311
  case 7:
11224
- if (tag != 56) {
11312
+ if (tag !== 56) {
11225
11313
  break;
11226
11314
  }
11227
11315
  message.disableDtx = reader.bool();
11228
11316
  continue;
11229
11317
  case 8:
11230
- if (tag != 64) {
11318
+ if (tag !== 64) {
11231
11319
  break;
11232
11320
  }
11233
11321
  message.source = reader.int32();
11234
11322
  continue;
11235
11323
  case 9:
11236
- if (tag != 74) {
11324
+ if (tag !== 74) {
11237
11325
  break;
11238
11326
  }
11239
11327
  message.layers.push(VideoLayer.decode(reader, reader.uint32()));
11240
11328
  continue;
11241
11329
  case 10:
11242
- if (tag != 82) {
11330
+ if (tag !== 82) {
11243
11331
  break;
11244
11332
  }
11245
11333
  message.simulcastCodecs.push(SimulcastCodec.decode(reader, reader.uint32()));
11246
11334
  continue;
11247
11335
  case 11:
11248
- if (tag != 90) {
11336
+ if (tag !== 90) {
11249
11337
  break;
11250
11338
  }
11251
11339
  message.sid = reader.string();
11252
11340
  continue;
11253
11341
  case 12:
11254
- if (tag != 96) {
11342
+ if (tag !== 96) {
11255
11343
  break;
11256
11344
  }
11257
11345
  message.stereo = reader.bool();
11258
11346
  continue;
11259
11347
  case 13:
11260
- if (tag != 104) {
11348
+ if (tag !== 104) {
11261
11349
  break;
11262
11350
  }
11263
11351
  message.disableRed = reader.bool();
11264
11352
  continue;
11265
11353
  case 14:
11266
- if (tag != 112) {
11354
+ if (tag !== 112) {
11267
11355
  break;
11268
11356
  }
11269
11357
  message.encryption = reader.int32();
11270
11358
  continue;
11271
11359
  }
11272
- if ((tag & 7) == 4 || tag == 0) {
11360
+ if ((tag & 7) === 4 || tag === 0) {
11273
11361
  break;
11274
11362
  }
11275
11363
  reader.skipType(tag & 7);
@@ -11368,19 +11456,19 @@ const TrickleRequest = {
11368
11456
  const tag = reader.uint32();
11369
11457
  switch (tag >>> 3) {
11370
11458
  case 1:
11371
- if (tag != 10) {
11459
+ if (tag !== 10) {
11372
11460
  break;
11373
11461
  }
11374
11462
  message.candidateInit = reader.string();
11375
11463
  continue;
11376
11464
  case 2:
11377
- if (tag != 16) {
11465
+ if (tag !== 16) {
11378
11466
  break;
11379
11467
  }
11380
11468
  message.target = reader.int32();
11381
11469
  continue;
11382
11470
  }
11383
- if ((tag & 7) == 4 || tag == 0) {
11471
+ if ((tag & 7) === 4 || tag === 0) {
11384
11472
  break;
11385
11473
  }
11386
11474
  reader.skipType(tag & 7);
@@ -11435,19 +11523,19 @@ const MuteTrackRequest = {
11435
11523
  const tag = reader.uint32();
11436
11524
  switch (tag >>> 3) {
11437
11525
  case 1:
11438
- if (tag != 10) {
11526
+ if (tag !== 10) {
11439
11527
  break;
11440
11528
  }
11441
11529
  message.sid = reader.string();
11442
11530
  continue;
11443
11531
  case 2:
11444
- if (tag != 16) {
11532
+ if (tag !== 16) {
11445
11533
  break;
11446
11534
  }
11447
11535
  message.muted = reader.bool();
11448
11536
  continue;
11449
11537
  }
11450
- if ((tag & 7) == 4 || tag == 0) {
11538
+ if ((tag & 7) === 4 || tag === 0) {
11451
11539
  break;
11452
11540
  }
11453
11541
  reader.skipType(tag & 7);
@@ -11490,7 +11578,8 @@ function createBaseJoinResponse() {
11490
11578
  serverRegion: "",
11491
11579
  pingTimeout: 0,
11492
11580
  pingInterval: 0,
11493
- serverInfo: undefined
11581
+ serverInfo: undefined,
11582
+ sifTrailer: new Uint8Array()
11494
11583
  };
11495
11584
  }
11496
11585
  const JoinResponse = {
@@ -11532,6 +11621,9 @@ const JoinResponse = {
11532
11621
  if (message.serverInfo !== undefined) {
11533
11622
  ServerInfo.encode(message.serverInfo, writer.uint32(98).fork()).ldelim();
11534
11623
  }
11624
+ if (message.sifTrailer.length !== 0) {
11625
+ writer.uint32(106).bytes(message.sifTrailer);
11626
+ }
11535
11627
  return writer;
11536
11628
  },
11537
11629
  decode(input, length) {
@@ -11542,79 +11634,85 @@ const JoinResponse = {
11542
11634
  const tag = reader.uint32();
11543
11635
  switch (tag >>> 3) {
11544
11636
  case 1:
11545
- if (tag != 10) {
11637
+ if (tag !== 10) {
11546
11638
  break;
11547
11639
  }
11548
11640
  message.room = Room$1.decode(reader, reader.uint32());
11549
11641
  continue;
11550
11642
  case 2:
11551
- if (tag != 18) {
11643
+ if (tag !== 18) {
11552
11644
  break;
11553
11645
  }
11554
11646
  message.participant = ParticipantInfo.decode(reader, reader.uint32());
11555
11647
  continue;
11556
11648
  case 3:
11557
- if (tag != 26) {
11649
+ if (tag !== 26) {
11558
11650
  break;
11559
11651
  }
11560
11652
  message.otherParticipants.push(ParticipantInfo.decode(reader, reader.uint32()));
11561
11653
  continue;
11562
11654
  case 4:
11563
- if (tag != 34) {
11655
+ if (tag !== 34) {
11564
11656
  break;
11565
11657
  }
11566
11658
  message.serverVersion = reader.string();
11567
11659
  continue;
11568
11660
  case 5:
11569
- if (tag != 42) {
11661
+ if (tag !== 42) {
11570
11662
  break;
11571
11663
  }
11572
11664
  message.iceServers.push(ICEServer.decode(reader, reader.uint32()));
11573
11665
  continue;
11574
11666
  case 6:
11575
- if (tag != 48) {
11667
+ if (tag !== 48) {
11576
11668
  break;
11577
11669
  }
11578
11670
  message.subscriberPrimary = reader.bool();
11579
11671
  continue;
11580
11672
  case 7:
11581
- if (tag != 58) {
11673
+ if (tag !== 58) {
11582
11674
  break;
11583
11675
  }
11584
11676
  message.alternativeUrl = reader.string();
11585
11677
  continue;
11586
11678
  case 8:
11587
- if (tag != 66) {
11679
+ if (tag !== 66) {
11588
11680
  break;
11589
11681
  }
11590
11682
  message.clientConfiguration = ClientConfiguration.decode(reader, reader.uint32());
11591
11683
  continue;
11592
11684
  case 9:
11593
- if (tag != 74) {
11685
+ if (tag !== 74) {
11594
11686
  break;
11595
11687
  }
11596
11688
  message.serverRegion = reader.string();
11597
11689
  continue;
11598
11690
  case 10:
11599
- if (tag != 80) {
11691
+ if (tag !== 80) {
11600
11692
  break;
11601
11693
  }
11602
11694
  message.pingTimeout = reader.int32();
11603
11695
  continue;
11604
11696
  case 11:
11605
- if (tag != 88) {
11697
+ if (tag !== 88) {
11606
11698
  break;
11607
11699
  }
11608
11700
  message.pingInterval = reader.int32();
11609
11701
  continue;
11610
11702
  case 12:
11611
- if (tag != 98) {
11703
+ if (tag !== 98) {
11612
11704
  break;
11613
11705
  }
11614
11706
  message.serverInfo = ServerInfo.decode(reader, reader.uint32());
11615
11707
  continue;
11708
+ case 13:
11709
+ if (tag !== 106) {
11710
+ break;
11711
+ }
11712
+ message.sifTrailer = reader.bytes();
11713
+ continue;
11616
11714
  }
11617
- if ((tag & 7) == 4 || tag == 0) {
11715
+ if ((tag & 7) === 4 || tag === 0) {
11618
11716
  break;
11619
11717
  }
11620
11718
  reader.skipType(tag & 7);
@@ -11634,7 +11732,8 @@ const JoinResponse = {
11634
11732
  serverRegion: isSet(object.serverRegion) ? String(object.serverRegion) : "",
11635
11733
  pingTimeout: isSet(object.pingTimeout) ? Number(object.pingTimeout) : 0,
11636
11734
  pingInterval: isSet(object.pingInterval) ? Number(object.pingInterval) : 0,
11637
- serverInfo: isSet(object.serverInfo) ? ServerInfo.fromJSON(object.serverInfo) : undefined
11735
+ serverInfo: isSet(object.serverInfo) ? ServerInfo.fromJSON(object.serverInfo) : undefined,
11736
+ sifTrailer: isSet(object.sifTrailer) ? bytesFromBase64(object.sifTrailer) : new Uint8Array()
11638
11737
  };
11639
11738
  },
11640
11739
  toJSON(message) {
@@ -11659,13 +11758,14 @@ const JoinResponse = {
11659
11758
  message.pingTimeout !== undefined && (obj.pingTimeout = Math.round(message.pingTimeout));
11660
11759
  message.pingInterval !== undefined && (obj.pingInterval = Math.round(message.pingInterval));
11661
11760
  message.serverInfo !== undefined && (obj.serverInfo = message.serverInfo ? ServerInfo.toJSON(message.serverInfo) : undefined);
11761
+ message.sifTrailer !== undefined && (obj.sifTrailer = base64FromBytes(message.sifTrailer !== undefined ? message.sifTrailer : new Uint8Array()));
11662
11762
  return obj;
11663
11763
  },
11664
11764
  create(base) {
11665
11765
  return JoinResponse.fromPartial(base !== null && base !== void 0 ? base : {});
11666
11766
  },
11667
11767
  fromPartial(object) {
11668
- var _a, _b, _c, _d, _e, _f, _g, _h;
11768
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
11669
11769
  const message = createBaseJoinResponse();
11670
11770
  message.room = object.room !== undefined && object.room !== null ? Room$1.fromPartial(object.room) : undefined;
11671
11771
  message.participant = object.participant !== undefined && object.participant !== null ? ParticipantInfo.fromPartial(object.participant) : undefined;
@@ -11679,6 +11779,7 @@ const JoinResponse = {
11679
11779
  message.pingTimeout = (_g = object.pingTimeout) !== null && _g !== void 0 ? _g : 0;
11680
11780
  message.pingInterval = (_h = object.pingInterval) !== null && _h !== void 0 ? _h : 0;
11681
11781
  message.serverInfo = object.serverInfo !== undefined && object.serverInfo !== null ? ServerInfo.fromPartial(object.serverInfo) : undefined;
11782
+ message.sifTrailer = (_j = object.sifTrailer) !== null && _j !== void 0 ? _j : new Uint8Array();
11682
11783
  return message;
11683
11784
  }
11684
11785
  };
@@ -11707,19 +11808,19 @@ const ReconnectResponse = {
11707
11808
  const tag = reader.uint32();
11708
11809
  switch (tag >>> 3) {
11709
11810
  case 1:
11710
- if (tag != 10) {
11811
+ if (tag !== 10) {
11711
11812
  break;
11712
11813
  }
11713
11814
  message.iceServers.push(ICEServer.decode(reader, reader.uint32()));
11714
11815
  continue;
11715
11816
  case 2:
11716
- if (tag != 18) {
11817
+ if (tag !== 18) {
11717
11818
  break;
11718
11819
  }
11719
11820
  message.clientConfiguration = ClientConfiguration.decode(reader, reader.uint32());
11720
11821
  continue;
11721
11822
  }
11722
- if ((tag & 7) == 4 || tag == 0) {
11823
+ if ((tag & 7) === 4 || tag === 0) {
11723
11824
  break;
11724
11825
  }
11725
11826
  reader.skipType(tag & 7);
@@ -11778,19 +11879,19 @@ const TrackPublishedResponse = {
11778
11879
  const tag = reader.uint32();
11779
11880
  switch (tag >>> 3) {
11780
11881
  case 1:
11781
- if (tag != 10) {
11882
+ if (tag !== 10) {
11782
11883
  break;
11783
11884
  }
11784
11885
  message.cid = reader.string();
11785
11886
  continue;
11786
11887
  case 2:
11787
- if (tag != 18) {
11888
+ if (tag !== 18) {
11788
11889
  break;
11789
11890
  }
11790
11891
  message.track = TrackInfo.decode(reader, reader.uint32());
11791
11892
  continue;
11792
11893
  }
11793
- if ((tag & 7) == 4 || tag == 0) {
11894
+ if ((tag & 7) === 4 || tag === 0) {
11794
11895
  break;
11795
11896
  }
11796
11897
  reader.skipType(tag & 7);
@@ -11841,13 +11942,13 @@ const TrackUnpublishedResponse = {
11841
11942
  const tag = reader.uint32();
11842
11943
  switch (tag >>> 3) {
11843
11944
  case 1:
11844
- if (tag != 10) {
11945
+ if (tag !== 10) {
11845
11946
  break;
11846
11947
  }
11847
11948
  message.trackSid = reader.string();
11848
11949
  continue;
11849
11950
  }
11850
- if ((tag & 7) == 4 || tag == 0) {
11951
+ if ((tag & 7) === 4 || tag === 0) {
11851
11952
  break;
11852
11953
  }
11853
11954
  reader.skipType(tag & 7);
@@ -11899,19 +12000,19 @@ const SessionDescription = {
11899
12000
  const tag = reader.uint32();
11900
12001
  switch (tag >>> 3) {
11901
12002
  case 1:
11902
- if (tag != 10) {
12003
+ if (tag !== 10) {
11903
12004
  break;
11904
12005
  }
11905
12006
  message.type = reader.string();
11906
12007
  continue;
11907
12008
  case 2:
11908
- if (tag != 18) {
12009
+ if (tag !== 18) {
11909
12010
  break;
11910
12011
  }
11911
12012
  message.sdp = reader.string();
11912
12013
  continue;
11913
12014
  }
11914
- if ((tag & 7) == 4 || tag == 0) {
12015
+ if ((tag & 7) === 4 || tag === 0) {
11915
12016
  break;
11916
12017
  }
11917
12018
  reader.skipType(tag & 7);
@@ -11962,13 +12063,13 @@ const ParticipantUpdate = {
11962
12063
  const tag = reader.uint32();
11963
12064
  switch (tag >>> 3) {
11964
12065
  case 1:
11965
- if (tag != 10) {
12066
+ if (tag !== 10) {
11966
12067
  break;
11967
12068
  }
11968
12069
  message.participants.push(ParticipantInfo.decode(reader, reader.uint32()));
11969
12070
  continue;
11970
12071
  }
11971
- if ((tag & 7) == 4 || tag == 0) {
12072
+ if ((tag & 7) === 4 || tag === 0) {
11972
12073
  break;
11973
12074
  }
11974
12075
  reader.skipType(tag & 7);
@@ -12028,25 +12129,25 @@ const UpdateSubscription = {
12028
12129
  const tag = reader.uint32();
12029
12130
  switch (tag >>> 3) {
12030
12131
  case 1:
12031
- if (tag != 10) {
12132
+ if (tag !== 10) {
12032
12133
  break;
12033
12134
  }
12034
12135
  message.trackSids.push(reader.string());
12035
12136
  continue;
12036
12137
  case 2:
12037
- if (tag != 16) {
12138
+ if (tag !== 16) {
12038
12139
  break;
12039
12140
  }
12040
12141
  message.subscribe = reader.bool();
12041
12142
  continue;
12042
12143
  case 3:
12043
- if (tag != 26) {
12144
+ if (tag !== 26) {
12044
12145
  break;
12045
12146
  }
12046
12147
  message.participantTracks.push(ParticipantTracks.decode(reader, reader.uint32()));
12047
12148
  continue;
12048
12149
  }
12049
- if ((tag & 7) == 4 || tag == 0) {
12150
+ if ((tag & 7) === 4 || tag === 0) {
12050
12151
  break;
12051
12152
  }
12052
12153
  reader.skipType(tag & 7);
@@ -12132,49 +12233,49 @@ const UpdateTrackSettings = {
12132
12233
  const tag = reader.uint32();
12133
12234
  switch (tag >>> 3) {
12134
12235
  case 1:
12135
- if (tag != 10) {
12236
+ if (tag !== 10) {
12136
12237
  break;
12137
12238
  }
12138
12239
  message.trackSids.push(reader.string());
12139
12240
  continue;
12140
12241
  case 3:
12141
- if (tag != 24) {
12242
+ if (tag !== 24) {
12142
12243
  break;
12143
12244
  }
12144
12245
  message.disabled = reader.bool();
12145
12246
  continue;
12146
12247
  case 4:
12147
- if (tag != 32) {
12248
+ if (tag !== 32) {
12148
12249
  break;
12149
12250
  }
12150
12251
  message.quality = reader.int32();
12151
12252
  continue;
12152
12253
  case 5:
12153
- if (tag != 40) {
12254
+ if (tag !== 40) {
12154
12255
  break;
12155
12256
  }
12156
12257
  message.width = reader.uint32();
12157
12258
  continue;
12158
12259
  case 6:
12159
- if (tag != 48) {
12260
+ if (tag !== 48) {
12160
12261
  break;
12161
12262
  }
12162
12263
  message.height = reader.uint32();
12163
12264
  continue;
12164
12265
  case 7:
12165
- if (tag != 56) {
12266
+ if (tag !== 56) {
12166
12267
  break;
12167
12268
  }
12168
12269
  message.fps = reader.uint32();
12169
12270
  continue;
12170
12271
  case 8:
12171
- if (tag != 64) {
12272
+ if (tag !== 64) {
12172
12273
  break;
12173
12274
  }
12174
12275
  message.priority = reader.uint32();
12175
12276
  continue;
12176
12277
  }
12177
- if ((tag & 7) == 4 || tag == 0) {
12278
+ if ((tag & 7) === 4 || tag === 0) {
12178
12279
  break;
12179
12280
  }
12180
12281
  reader.skipType(tag & 7);
@@ -12248,19 +12349,19 @@ const LeaveRequest = {
12248
12349
  const tag = reader.uint32();
12249
12350
  switch (tag >>> 3) {
12250
12351
  case 1:
12251
- if (tag != 8) {
12352
+ if (tag !== 8) {
12252
12353
  break;
12253
12354
  }
12254
12355
  message.canReconnect = reader.bool();
12255
12356
  continue;
12256
12357
  case 2:
12257
- if (tag != 16) {
12358
+ if (tag !== 16) {
12258
12359
  break;
12259
12360
  }
12260
12361
  message.reason = reader.int32();
12261
12362
  continue;
12262
12363
  }
12263
- if ((tag & 7) == 4 || tag == 0) {
12364
+ if ((tag & 7) === 4 || tag === 0) {
12264
12365
  break;
12265
12366
  }
12266
12367
  reader.skipType(tag & 7);
@@ -12315,19 +12416,19 @@ const UpdateVideoLayers = {
12315
12416
  const tag = reader.uint32();
12316
12417
  switch (tag >>> 3) {
12317
12418
  case 1:
12318
- if (tag != 10) {
12419
+ if (tag !== 10) {
12319
12420
  break;
12320
12421
  }
12321
12422
  message.trackSid = reader.string();
12322
12423
  continue;
12323
12424
  case 2:
12324
- if (tag != 18) {
12425
+ if (tag !== 18) {
12325
12426
  break;
12326
12427
  }
12327
12428
  message.layers.push(VideoLayer.decode(reader, reader.uint32()));
12328
12429
  continue;
12329
12430
  }
12330
- if ((tag & 7) == 4 || tag == 0) {
12431
+ if ((tag & 7) === 4 || tag === 0) {
12331
12432
  break;
12332
12433
  }
12333
12434
  reader.skipType(tag & 7);
@@ -12386,19 +12487,19 @@ const UpdateParticipantMetadata = {
12386
12487
  const tag = reader.uint32();
12387
12488
  switch (tag >>> 3) {
12388
12489
  case 1:
12389
- if (tag != 10) {
12490
+ if (tag !== 10) {
12390
12491
  break;
12391
12492
  }
12392
12493
  message.metadata = reader.string();
12393
12494
  continue;
12394
12495
  case 2:
12395
- if (tag != 18) {
12496
+ if (tag !== 18) {
12396
12497
  break;
12397
12498
  }
12398
12499
  message.name = reader.string();
12399
12500
  continue;
12400
12501
  }
12401
- if ((tag & 7) == 4 || tag == 0) {
12502
+ if ((tag & 7) === 4 || tag === 0) {
12402
12503
  break;
12403
12504
  }
12404
12505
  reader.skipType(tag & 7);
@@ -12457,25 +12558,25 @@ const ICEServer = {
12457
12558
  const tag = reader.uint32();
12458
12559
  switch (tag >>> 3) {
12459
12560
  case 1:
12460
- if (tag != 10) {
12561
+ if (tag !== 10) {
12461
12562
  break;
12462
12563
  }
12463
12564
  message.urls.push(reader.string());
12464
12565
  continue;
12465
12566
  case 2:
12466
- if (tag != 18) {
12567
+ if (tag !== 18) {
12467
12568
  break;
12468
12569
  }
12469
12570
  message.username = reader.string();
12470
12571
  continue;
12471
12572
  case 3:
12472
- if (tag != 26) {
12573
+ if (tag !== 26) {
12473
12574
  break;
12474
12575
  }
12475
12576
  message.credential = reader.string();
12476
12577
  continue;
12477
12578
  }
12478
- if ((tag & 7) == 4 || tag == 0) {
12579
+ if ((tag & 7) === 4 || tag === 0) {
12479
12580
  break;
12480
12581
  }
12481
12582
  reader.skipType(tag & 7);
@@ -12533,13 +12634,13 @@ const SpeakersChanged = {
12533
12634
  const tag = reader.uint32();
12534
12635
  switch (tag >>> 3) {
12535
12636
  case 1:
12536
- if (tag != 10) {
12637
+ if (tag !== 10) {
12537
12638
  break;
12538
12639
  }
12539
12640
  message.speakers.push(SpeakerInfo.decode(reader, reader.uint32()));
12540
12641
  continue;
12541
12642
  }
12542
- if ((tag & 7) == 4 || tag == 0) {
12643
+ if ((tag & 7) === 4 || tag === 0) {
12543
12644
  break;
12544
12645
  }
12545
12646
  reader.skipType(tag & 7);
@@ -12591,13 +12692,13 @@ const RoomUpdate = {
12591
12692
  const tag = reader.uint32();
12592
12693
  switch (tag >>> 3) {
12593
12694
  case 1:
12594
- if (tag != 10) {
12695
+ if (tag !== 10) {
12595
12696
  break;
12596
12697
  }
12597
12698
  message.room = Room$1.decode(reader, reader.uint32());
12598
12699
  continue;
12599
12700
  }
12600
- if ((tag & 7) == 4 || tag == 0) {
12701
+ if ((tag & 7) === 4 || tag === 0) {
12601
12702
  break;
12602
12703
  }
12603
12704
  reader.skipType(tag & 7);
@@ -12652,25 +12753,25 @@ const ConnectionQualityInfo = {
12652
12753
  const tag = reader.uint32();
12653
12754
  switch (tag >>> 3) {
12654
12755
  case 1:
12655
- if (tag != 10) {
12756
+ if (tag !== 10) {
12656
12757
  break;
12657
12758
  }
12658
12759
  message.participantSid = reader.string();
12659
12760
  continue;
12660
12761
  case 2:
12661
- if (tag != 16) {
12762
+ if (tag !== 16) {
12662
12763
  break;
12663
12764
  }
12664
12765
  message.quality = reader.int32();
12665
12766
  continue;
12666
12767
  case 3:
12667
- if (tag != 29) {
12768
+ if (tag !== 29) {
12668
12769
  break;
12669
12770
  }
12670
12771
  message.score = reader.float();
12671
12772
  continue;
12672
12773
  }
12673
- if ((tag & 7) == 4 || tag == 0) {
12774
+ if ((tag & 7) === 4 || tag === 0) {
12674
12775
  break;
12675
12776
  }
12676
12777
  reader.skipType(tag & 7);
@@ -12724,13 +12825,13 @@ const ConnectionQualityUpdate = {
12724
12825
  const tag = reader.uint32();
12725
12826
  switch (tag >>> 3) {
12726
12827
  case 1:
12727
- if (tag != 10) {
12828
+ if (tag !== 10) {
12728
12829
  break;
12729
12830
  }
12730
12831
  message.updates.push(ConnectionQualityInfo.decode(reader, reader.uint32()));
12731
12832
  continue;
12732
12833
  }
12733
- if ((tag & 7) == 4 || tag == 0) {
12834
+ if ((tag & 7) === 4 || tag === 0) {
12734
12835
  break;
12735
12836
  }
12736
12837
  reader.skipType(tag & 7);
@@ -12790,25 +12891,25 @@ const StreamStateInfo = {
12790
12891
  const tag = reader.uint32();
12791
12892
  switch (tag >>> 3) {
12792
12893
  case 1:
12793
- if (tag != 10) {
12894
+ if (tag !== 10) {
12794
12895
  break;
12795
12896
  }
12796
12897
  message.participantSid = reader.string();
12797
12898
  continue;
12798
12899
  case 2:
12799
- if (tag != 18) {
12900
+ if (tag !== 18) {
12800
12901
  break;
12801
12902
  }
12802
12903
  message.trackSid = reader.string();
12803
12904
  continue;
12804
12905
  case 3:
12805
- if (tag != 24) {
12906
+ if (tag !== 24) {
12806
12907
  break;
12807
12908
  }
12808
12909
  message.state = reader.int32();
12809
12910
  continue;
12810
12911
  }
12811
- if ((tag & 7) == 4 || tag == 0) {
12912
+ if ((tag & 7) === 4 || tag === 0) {
12812
12913
  break;
12813
12914
  }
12814
12915
  reader.skipType(tag & 7);
@@ -12862,13 +12963,13 @@ const StreamStateUpdate = {
12862
12963
  const tag = reader.uint32();
12863
12964
  switch (tag >>> 3) {
12864
12965
  case 1:
12865
- if (tag != 10) {
12966
+ if (tag !== 10) {
12866
12967
  break;
12867
12968
  }
12868
12969
  message.streamStates.push(StreamStateInfo.decode(reader, reader.uint32()));
12869
12970
  continue;
12870
12971
  }
12871
- if ((tag & 7) == 4 || tag == 0) {
12972
+ if ((tag & 7) === 4 || tag === 0) {
12872
12973
  break;
12873
12974
  }
12874
12975
  reader.skipType(tag & 7);
@@ -12924,19 +13025,19 @@ const SubscribedQuality = {
12924
13025
  const tag = reader.uint32();
12925
13026
  switch (tag >>> 3) {
12926
13027
  case 1:
12927
- if (tag != 8) {
13028
+ if (tag !== 8) {
12928
13029
  break;
12929
13030
  }
12930
13031
  message.quality = reader.int32();
12931
13032
  continue;
12932
13033
  case 2:
12933
- if (tag != 16) {
13034
+ if (tag !== 16) {
12934
13035
  break;
12935
13036
  }
12936
13037
  message.enabled = reader.bool();
12937
13038
  continue;
12938
13039
  }
12939
- if ((tag & 7) == 4 || tag == 0) {
13040
+ if ((tag & 7) === 4 || tag === 0) {
12940
13041
  break;
12941
13042
  }
12942
13043
  reader.skipType(tag & 7);
@@ -12991,19 +13092,19 @@ const SubscribedCodec = {
12991
13092
  const tag = reader.uint32();
12992
13093
  switch (tag >>> 3) {
12993
13094
  case 1:
12994
- if (tag != 10) {
13095
+ if (tag !== 10) {
12995
13096
  break;
12996
13097
  }
12997
13098
  message.codec = reader.string();
12998
13099
  continue;
12999
13100
  case 2:
13000
- if (tag != 18) {
13101
+ if (tag !== 18) {
13001
13102
  break;
13002
13103
  }
13003
13104
  message.qualities.push(SubscribedQuality.decode(reader, reader.uint32()));
13004
13105
  continue;
13005
13106
  }
13006
- if ((tag & 7) == 4 || tag == 0) {
13107
+ if ((tag & 7) === 4 || tag === 0) {
13007
13108
  break;
13008
13109
  }
13009
13110
  reader.skipType(tag & 7);
@@ -13066,25 +13167,25 @@ const SubscribedQualityUpdate = {
13066
13167
  const tag = reader.uint32();
13067
13168
  switch (tag >>> 3) {
13068
13169
  case 1:
13069
- if (tag != 10) {
13170
+ if (tag !== 10) {
13070
13171
  break;
13071
13172
  }
13072
13173
  message.trackSid = reader.string();
13073
13174
  continue;
13074
13175
  case 2:
13075
- if (tag != 18) {
13176
+ if (tag !== 18) {
13076
13177
  break;
13077
13178
  }
13078
13179
  message.subscribedQualities.push(SubscribedQuality.decode(reader, reader.uint32()));
13079
13180
  continue;
13080
13181
  case 3:
13081
- if (tag != 26) {
13182
+ if (tag !== 26) {
13082
13183
  break;
13083
13184
  }
13084
13185
  message.subscribedCodecs.push(SubscribedCodec.decode(reader, reader.uint32()));
13085
13186
  continue;
13086
13187
  }
13087
- if ((tag & 7) == 4 || tag == 0) {
13188
+ if ((tag & 7) === 4 || tag === 0) {
13088
13189
  break;
13089
13190
  }
13090
13191
  reader.skipType(tag & 7);
@@ -13158,31 +13259,31 @@ const TrackPermission = {
13158
13259
  const tag = reader.uint32();
13159
13260
  switch (tag >>> 3) {
13160
13261
  case 1:
13161
- if (tag != 10) {
13262
+ if (tag !== 10) {
13162
13263
  break;
13163
13264
  }
13164
13265
  message.participantSid = reader.string();
13165
13266
  continue;
13166
13267
  case 2:
13167
- if (tag != 16) {
13268
+ if (tag !== 16) {
13168
13269
  break;
13169
13270
  }
13170
13271
  message.allTracks = reader.bool();
13171
13272
  continue;
13172
13273
  case 3:
13173
- if (tag != 26) {
13274
+ if (tag !== 26) {
13174
13275
  break;
13175
13276
  }
13176
13277
  message.trackSids.push(reader.string());
13177
13278
  continue;
13178
13279
  case 4:
13179
- if (tag != 34) {
13280
+ if (tag !== 34) {
13180
13281
  break;
13181
13282
  }
13182
13283
  message.participantIdentity = reader.string();
13183
13284
  continue;
13184
13285
  }
13185
- if ((tag & 7) == 4 || tag == 0) {
13286
+ if ((tag & 7) === 4 || tag === 0) {
13186
13287
  break;
13187
13288
  }
13188
13289
  reader.skipType(tag & 7);
@@ -13247,19 +13348,19 @@ const SubscriptionPermission = {
13247
13348
  const tag = reader.uint32();
13248
13349
  switch (tag >>> 3) {
13249
13350
  case 1:
13250
- if (tag != 8) {
13351
+ if (tag !== 8) {
13251
13352
  break;
13252
13353
  }
13253
13354
  message.allParticipants = reader.bool();
13254
13355
  continue;
13255
13356
  case 2:
13256
- if (tag != 18) {
13357
+ if (tag !== 18) {
13257
13358
  break;
13258
13359
  }
13259
13360
  message.trackPermissions.push(TrackPermission.decode(reader, reader.uint32()));
13260
13361
  continue;
13261
13362
  }
13262
- if ((tag & 7) == 4 || tag == 0) {
13363
+ if ((tag & 7) === 4 || tag === 0) {
13263
13364
  break;
13264
13365
  }
13265
13366
  reader.skipType(tag & 7);
@@ -13322,25 +13423,25 @@ const SubscriptionPermissionUpdate = {
13322
13423
  const tag = reader.uint32();
13323
13424
  switch (tag >>> 3) {
13324
13425
  case 1:
13325
- if (tag != 10) {
13426
+ if (tag !== 10) {
13326
13427
  break;
13327
13428
  }
13328
13429
  message.participantSid = reader.string();
13329
13430
  continue;
13330
13431
  case 2:
13331
- if (tag != 18) {
13432
+ if (tag !== 18) {
13332
13433
  break;
13333
13434
  }
13334
13435
  message.trackSid = reader.string();
13335
13436
  continue;
13336
13437
  case 3:
13337
- if (tag != 24) {
13438
+ if (tag !== 24) {
13338
13439
  break;
13339
13440
  }
13340
13441
  message.allowed = reader.bool();
13341
13442
  continue;
13342
13443
  }
13343
- if ((tag & 7) == 4 || tag == 0) {
13444
+ if ((tag & 7) === 4 || tag === 0) {
13344
13445
  break;
13345
13446
  }
13346
13447
  reader.skipType(tag & 7);
@@ -13410,37 +13511,37 @@ const SyncState = {
13410
13511
  const tag = reader.uint32();
13411
13512
  switch (tag >>> 3) {
13412
13513
  case 1:
13413
- if (tag != 10) {
13514
+ if (tag !== 10) {
13414
13515
  break;
13415
13516
  }
13416
13517
  message.answer = SessionDescription.decode(reader, reader.uint32());
13417
13518
  continue;
13418
13519
  case 2:
13419
- if (tag != 18) {
13520
+ if (tag !== 18) {
13420
13521
  break;
13421
13522
  }
13422
13523
  message.subscription = UpdateSubscription.decode(reader, reader.uint32());
13423
13524
  continue;
13424
13525
  case 3:
13425
- if (tag != 26) {
13526
+ if (tag !== 26) {
13426
13527
  break;
13427
13528
  }
13428
13529
  message.publishTracks.push(TrackPublishedResponse.decode(reader, reader.uint32()));
13429
13530
  continue;
13430
13531
  case 4:
13431
- if (tag != 34) {
13532
+ if (tag !== 34) {
13432
13533
  break;
13433
13534
  }
13434
13535
  message.dataChannels.push(DataChannelInfo.decode(reader, reader.uint32()));
13435
13536
  continue;
13436
13537
  case 5:
13437
- if (tag != 42) {
13538
+ if (tag !== 42) {
13438
13539
  break;
13439
13540
  }
13440
13541
  message.offer = SessionDescription.decode(reader, reader.uint32());
13441
13542
  continue;
13442
13543
  }
13443
- if ((tag & 7) == 4 || tag == 0) {
13544
+ if ((tag & 7) === 4 || tag === 0) {
13444
13545
  break;
13445
13546
  }
13446
13547
  reader.skipType(tag & 7);
@@ -13516,25 +13617,25 @@ const DataChannelInfo = {
13516
13617
  const tag = reader.uint32();
13517
13618
  switch (tag >>> 3) {
13518
13619
  case 1:
13519
- if (tag != 10) {
13620
+ if (tag !== 10) {
13520
13621
  break;
13521
13622
  }
13522
13623
  message.label = reader.string();
13523
13624
  continue;
13524
13625
  case 2:
13525
- if (tag != 16) {
13626
+ if (tag !== 16) {
13526
13627
  break;
13527
13628
  }
13528
13629
  message.id = reader.uint32();
13529
13630
  continue;
13530
13631
  case 3:
13531
- if (tag != 24) {
13632
+ if (tag !== 24) {
13532
13633
  break;
13533
13634
  }
13534
13635
  message.target = reader.int32();
13535
13636
  continue;
13536
13637
  }
13537
- if ((tag & 7) == 4 || tag == 0) {
13638
+ if ((tag & 7) === 4 || tag === 0) {
13538
13639
  break;
13539
13640
  }
13540
13641
  reader.skipType(tag & 7);
@@ -13606,7 +13707,7 @@ const SimulateScenario = {
13606
13707
  const tag = reader.uint32();
13607
13708
  switch (tag >>> 3) {
13608
13709
  case 1:
13609
- if (tag != 8) {
13710
+ if (tag !== 8) {
13610
13711
  break;
13611
13712
  }
13612
13713
  message.scenario = {
@@ -13615,7 +13716,7 @@ const SimulateScenario = {
13615
13716
  };
13616
13717
  continue;
13617
13718
  case 2:
13618
- if (tag != 16) {
13719
+ if (tag !== 16) {
13619
13720
  break;
13620
13721
  }
13621
13722
  message.scenario = {
@@ -13624,7 +13725,7 @@ const SimulateScenario = {
13624
13725
  };
13625
13726
  continue;
13626
13727
  case 3:
13627
- if (tag != 24) {
13728
+ if (tag !== 24) {
13628
13729
  break;
13629
13730
  }
13630
13731
  message.scenario = {
@@ -13633,7 +13734,7 @@ const SimulateScenario = {
13633
13734
  };
13634
13735
  continue;
13635
13736
  case 4:
13636
- if (tag != 32) {
13737
+ if (tag !== 32) {
13637
13738
  break;
13638
13739
  }
13639
13740
  message.scenario = {
@@ -13642,7 +13743,7 @@ const SimulateScenario = {
13642
13743
  };
13643
13744
  continue;
13644
13745
  case 5:
13645
- if (tag != 40) {
13746
+ if (tag !== 40) {
13646
13747
  break;
13647
13748
  }
13648
13749
  message.scenario = {
@@ -13651,7 +13752,7 @@ const SimulateScenario = {
13651
13752
  };
13652
13753
  continue;
13653
13754
  case 6:
13654
- if (tag != 48) {
13755
+ if (tag !== 48) {
13655
13756
  break;
13656
13757
  }
13657
13758
  message.scenario = {
@@ -13660,7 +13761,7 @@ const SimulateScenario = {
13660
13761
  };
13661
13762
  continue;
13662
13763
  }
13663
- if ((tag & 7) == 4 || tag == 0) {
13764
+ if ((tag & 7) === 4 || tag === 0) {
13664
13765
  break;
13665
13766
  }
13666
13767
  reader.skipType(tag & 7);
@@ -13771,19 +13872,19 @@ const Ping = {
13771
13872
  const tag = reader.uint32();
13772
13873
  switch (tag >>> 3) {
13773
13874
  case 1:
13774
- if (tag != 8) {
13875
+ if (tag !== 8) {
13775
13876
  break;
13776
13877
  }
13777
13878
  message.timestamp = longToNumber(reader.int64());
13778
13879
  continue;
13779
13880
  case 2:
13780
- if (tag != 16) {
13881
+ if (tag !== 16) {
13781
13882
  break;
13782
13883
  }
13783
13884
  message.rtt = longToNumber(reader.int64());
13784
13885
  continue;
13785
13886
  }
13786
- if ((tag & 7) == 4 || tag == 0) {
13887
+ if ((tag & 7) === 4 || tag === 0) {
13787
13888
  break;
13788
13889
  }
13789
13890
  reader.skipType(tag & 7);
@@ -13838,19 +13939,19 @@ const Pong = {
13838
13939
  const tag = reader.uint32();
13839
13940
  switch (tag >>> 3) {
13840
13941
  case 1:
13841
- if (tag != 8) {
13942
+ if (tag !== 8) {
13842
13943
  break;
13843
13944
  }
13844
13945
  message.lastPingTimestamp = longToNumber(reader.int64());
13845
13946
  continue;
13846
13947
  case 2:
13847
- if (tag != 16) {
13948
+ if (tag !== 16) {
13848
13949
  break;
13849
13950
  }
13850
13951
  message.timestamp = longToNumber(reader.int64());
13851
13952
  continue;
13852
13953
  }
13853
- if ((tag & 7) == 4 || tag == 0) {
13954
+ if ((tag & 7) === 4 || tag === 0) {
13854
13955
  break;
13855
13956
  }
13856
13957
  reader.skipType(tag & 7);
@@ -13880,6 +13981,73 @@ const Pong = {
13880
13981
  return message;
13881
13982
  }
13882
13983
  };
13984
+ function createBaseSubscriptionResponse() {
13985
+ return {
13986
+ trackSid: "",
13987
+ err: 0
13988
+ };
13989
+ }
13990
+ const SubscriptionResponse = {
13991
+ encode(message) {
13992
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
13993
+ if (message.trackSid !== "") {
13994
+ writer.uint32(10).string(message.trackSid);
13995
+ }
13996
+ if (message.err !== 0) {
13997
+ writer.uint32(16).int32(message.err);
13998
+ }
13999
+ return writer;
14000
+ },
14001
+ decode(input, length) {
14002
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
14003
+ let end = length === undefined ? reader.len : reader.pos + length;
14004
+ const message = createBaseSubscriptionResponse();
14005
+ while (reader.pos < end) {
14006
+ const tag = reader.uint32();
14007
+ switch (tag >>> 3) {
14008
+ case 1:
14009
+ if (tag !== 10) {
14010
+ break;
14011
+ }
14012
+ message.trackSid = reader.string();
14013
+ continue;
14014
+ case 2:
14015
+ if (tag !== 16) {
14016
+ break;
14017
+ }
14018
+ message.err = reader.int32();
14019
+ continue;
14020
+ }
14021
+ if ((tag & 7) === 4 || tag === 0) {
14022
+ break;
14023
+ }
14024
+ reader.skipType(tag & 7);
14025
+ }
14026
+ return message;
14027
+ },
14028
+ fromJSON(object) {
14029
+ return {
14030
+ trackSid: isSet(object.trackSid) ? String(object.trackSid) : "",
14031
+ err: isSet(object.err) ? subscriptionErrorFromJSON(object.err) : 0
14032
+ };
14033
+ },
14034
+ toJSON(message) {
14035
+ const obj = {};
14036
+ message.trackSid !== undefined && (obj.trackSid = message.trackSid);
14037
+ message.err !== undefined && (obj.err = subscriptionErrorToJSON(message.err));
14038
+ return obj;
14039
+ },
14040
+ create(base) {
14041
+ return SubscriptionResponse.fromPartial(base !== null && base !== void 0 ? base : {});
14042
+ },
14043
+ fromPartial(object) {
14044
+ var _a, _b;
14045
+ const message = createBaseSubscriptionResponse();
14046
+ message.trackSid = (_a = object.trackSid) !== null && _a !== void 0 ? _a : "";
14047
+ message.err = (_b = object.err) !== null && _b !== void 0 ? _b : 0;
14048
+ return message;
14049
+ }
14050
+ };
13883
14051
  var tsProtoGlobalThis = (() => {
13884
14052
  if (typeof globalThis !== "undefined") {
13885
14053
  return globalThis;
@@ -13895,6 +14063,29 @@ var tsProtoGlobalThis = (() => {
13895
14063
  }
13896
14064
  throw "Unable to locate global object";
13897
14065
  })();
14066
+ function bytesFromBase64(b64) {
14067
+ if (tsProtoGlobalThis.Buffer) {
14068
+ return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64"));
14069
+ } else {
14070
+ const bin = tsProtoGlobalThis.atob(b64);
14071
+ const arr = new Uint8Array(bin.length);
14072
+ for (let i = 0; i < bin.length; ++i) {
14073
+ arr[i] = bin.charCodeAt(i);
14074
+ }
14075
+ return arr;
14076
+ }
14077
+ }
14078
+ function base64FromBytes(arr) {
14079
+ if (tsProtoGlobalThis.Buffer) {
14080
+ return tsProtoGlobalThis.Buffer.from(arr).toString("base64");
14081
+ } else {
14082
+ const bin = [];
14083
+ arr.forEach(byte => {
14084
+ bin.push(String.fromCharCode(byte));
14085
+ });
14086
+ return tsProtoGlobalThis.btoa(bin.join(""));
14087
+ }
14088
+ }
13898
14089
  function longToNumber(long) {
13899
14090
  if (long.gt(Number.MAX_SAFE_INTEGER)) {
13900
14091
  throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
@@ -14010,7 +14201,7 @@ let browserDetails;
14010
14201
  */
14011
14202
  function getBrowser(userAgent) {
14012
14203
  let force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
14013
- if (userAgent === undefined && (typeof document !== 'undefined' || typeof navigator === 'undefined')) {
14204
+ if (typeof userAgent === 'undefined' && typeof navigator === 'undefined') {
14014
14205
  return;
14015
14206
  }
14016
14207
  const ua = (userAgent !== null && userAgent !== void 0 ? userAgent : navigator.userAgent).toLowerCase();
@@ -14060,7 +14251,7 @@ function getMatch(exp, ua) {
14060
14251
  return match && match.length >= id && match[id] || '';
14061
14252
  }
14062
14253
 
14063
- var version$1 = "1.9.6";
14254
+ var version$1 = "1.10.0";
14064
14255
 
14065
14256
  const version = version$1;
14066
14257
  const protocolVersion = 9;
@@ -14610,7 +14801,7 @@ class SignalClient {
14610
14801
  const params = createConnectionParams(token, clientInfo, opts);
14611
14802
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
14612
14803
  const abortHandler = () => __awaiter(this, void 0, void 0, function* () {
14613
- yield this.close();
14804
+ this.close();
14614
14805
  reject(new ConnectionError('room connection has been cancelled (signal)'));
14615
14806
  });
14616
14807
  if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
@@ -14956,6 +15147,10 @@ class SignalClient {
14956
15147
  if (this.onLocalTrackUnpublished) {
14957
15148
  this.onLocalTrackUnpublished(msg.trackUnpublished);
14958
15149
  }
15150
+ } else if (msg.$case === 'subscriptionResponse') {
15151
+ if (this.onSubscriptionError) {
15152
+ this.onSubscriptionError(msg.subscriptionResponse);
15153
+ }
14959
15154
  } else if (msg.$case === 'pong') {
14960
15155
  this.resetPingTimeout();
14961
15156
  } else if (msg.$case === 'pongResp') {
@@ -16812,6 +17007,10 @@ var TrackEvent;
16812
17007
  * Fires on RemoteTrackPublication
16813
17008
  */
16814
17009
  TrackEvent["SubscriptionStatusChanged"] = "subscriptionStatusChanged";
17010
+ /**
17011
+ * Fires on RemoteTrackPublication
17012
+ */
17013
+ TrackEvent["SubscriptionFailed"] = "subscriptionFailed";
16815
17014
  })(TrackEvent || (TrackEvent = {}));
16816
17015
 
16817
17016
  const BACKGROUND_REACTION_DELAY = 5000;
@@ -16893,7 +17092,7 @@ class Track extends eventsExports.EventEmitter {
16893
17092
  // even if we believe it's already attached to the element, it's possible
16894
17093
  // the element's srcObject was set to something else out of band.
16895
17094
  // we'll want to re-attach it in that case
16896
- attachToElement(this._mediaStreamTrack, element);
17095
+ attachToElement(this.mediaStreamTrack, element);
16897
17096
  // handle auto playback failures
16898
17097
  const allMediaStreamTracks = element.srcObject.getTracks();
16899
17098
  if (allMediaStreamTracks.some(tr => tr.kind === 'audio')) {
@@ -16922,7 +17121,7 @@ class Track extends eventsExports.EventEmitter {
16922
17121
  try {
16923
17122
  // detach from a single element
16924
17123
  if (element) {
16925
- detachTrack(this._mediaStreamTrack, element);
17124
+ detachTrack(this.mediaStreamTrack, element);
16926
17125
  const idx = this.attachedElements.indexOf(element);
16927
17126
  if (idx >= 0) {
16928
17127
  this.attachedElements.splice(idx, 1);
@@ -16933,7 +17132,7 @@ class Track extends eventsExports.EventEmitter {
16933
17132
  }
16934
17133
  const detached = [];
16935
17134
  this.attachedElements.forEach(elm => {
16936
- detachTrack(this._mediaStreamTrack, elm);
17135
+ detachTrack(this.mediaStreamTrack, elm);
16937
17136
  detached.push(elm);
16938
17137
  this.recycleElement(elm);
16939
17138
  this.emit(TrackEvent.ElementDetached, elm);
@@ -18233,6 +18432,7 @@ class LocalTrack extends Track {
18233
18432
  constructor(mediaTrack, kind, constraints) {
18234
18433
  let userProvidedTrack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
18235
18434
  super(mediaTrack, kind);
18435
+ this.isSettingUpProcessor = false;
18236
18436
  this._isUpstreamPaused = false;
18237
18437
  this.handleEnded = () => {
18238
18438
  if (this.isInBackground) {
@@ -18272,6 +18472,10 @@ class LocalTrack extends Track {
18272
18472
  get isUserProvided() {
18273
18473
  return this.providedByUser;
18274
18474
  }
18475
+ get mediaStreamTrack() {
18476
+ var _a, _b;
18477
+ return (_b = (_a = this.processor) === null || _a === void 0 ? void 0 : _a.processedTrack) !== null && _b !== void 0 ? _b : this._mediaStreamTrack;
18478
+ }
18275
18479
  waitForDimensions() {
18276
18480
  let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultDimensionsTimeout;
18277
18481
  return __awaiter(this, void 0, void 0, function* () {
@@ -18349,6 +18553,9 @@ class LocalTrack extends Track {
18349
18553
  });
18350
18554
  this.mediaStream = new MediaStream([track]);
18351
18555
  this.providedByUser = userProvidedTrack;
18556
+ if (this.processor) {
18557
+ yield this.stopProcessor();
18558
+ }
18352
18559
  return this;
18353
18560
  });
18354
18561
  }
@@ -18369,7 +18576,7 @@ class LocalTrack extends Track {
18369
18576
  }
18370
18577
  // detach
18371
18578
  this.attachedElements.forEach(el => {
18372
- detachTrack(this._mediaStreamTrack, el);
18579
+ detachTrack(this.mediaStreamTrack, el);
18373
18580
  });
18374
18581
  this._mediaStreamTrack.removeEventListener('ended', this.handleEnded);
18375
18582
  // on Safari, the old audio track must be stopped before attempting to acquire
@@ -18387,11 +18594,16 @@ class LocalTrack extends Track {
18387
18594
  }
18388
18595
  this._mediaStreamTrack = newTrack;
18389
18596
  yield this.resumeUpstream();
18390
- this.attachedElements.forEach(el => {
18391
- attachToElement(newTrack, el);
18392
- });
18393
18597
  this.mediaStream = mediaStream;
18394
18598
  this.constraints = constraints;
18599
+ if (this.processor) {
18600
+ const processor = this.processor;
18601
+ yield this.setProcessor(processor);
18602
+ } else {
18603
+ this.attachedElements.forEach(el => {
18604
+ attachToElement(this._mediaStreamTrack, el);
18605
+ });
18606
+ }
18395
18607
  this.emit(TrackEvent.Restarted, this);
18396
18608
  return this;
18397
18609
  });
@@ -18425,6 +18637,18 @@ class LocalTrack extends Track {
18425
18637
  }
18426
18638
  });
18427
18639
  }
18640
+ stop() {
18641
+ var _a;
18642
+ super.stop();
18643
+ (_a = this.processor) === null || _a === void 0 ? void 0 : _a.destroy();
18644
+ this.processor = undefined;
18645
+ }
18646
+ /**
18647
+ * pauses publishing to the server without disabling the local MediaStreamTrack
18648
+ * this is used to display a user's own video locally while pausing publishing to
18649
+ * the server.
18650
+ * this API is unsupported on Safari < 12 due to a bug
18651
+ **/
18428
18652
  pauseUpstream() {
18429
18653
  return __awaiter(this, void 0, void 0, function* () {
18430
18654
  const unlock = yield this.pauseUpstreamLock.lock();
@@ -18438,8 +18662,12 @@ class LocalTrack extends Track {
18438
18662
  }
18439
18663
  this._isUpstreamPaused = true;
18440
18664
  this.emit(TrackEvent.UpstreamPaused, this);
18441
- const emptyTrack = this.kind === Track.Kind.Audio ? getEmptyAudioStreamTrack() : getEmptyVideoStreamTrack();
18442
- yield this.sender.replaceTrack(emptyTrack);
18665
+ const browser = getBrowser();
18666
+ if ((browser === null || browser === void 0 ? void 0 : browser.name) === 'Safari' && compareVersions(browser.version, '12.0') < 0) {
18667
+ // https://bugs.webkit.org/show_bug.cgi?id=184911
18668
+ throw new DeviceUnsupportedError('pauseUpstream is not supported on Safari < 12.');
18669
+ }
18670
+ yield this.sender.replaceTrack(null);
18443
18671
  } finally {
18444
18672
  unlock();
18445
18673
  }
@@ -18464,6 +18692,78 @@ class LocalTrack extends Track {
18464
18692
  }
18465
18693
  });
18466
18694
  }
18695
+ /**
18696
+ * Sets a processor on this track.
18697
+ * See https://github.com/livekit/track-processors-js for example usage
18698
+ *
18699
+ * @experimental
18700
+ *
18701
+ * @param processor
18702
+ * @param showProcessedStreamLocally
18703
+ * @returns
18704
+ */
18705
+ setProcessor(processor) {
18706
+ let showProcessedStreamLocally = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
18707
+ var _a, _b;
18708
+ return __awaiter(this, void 0, void 0, function* () {
18709
+ if (this.isSettingUpProcessor) {
18710
+ livekitLogger.warn('already trying to set up a processor');
18711
+ return;
18712
+ }
18713
+ livekitLogger.debug('setting up processor');
18714
+ this.isSettingUpProcessor = true;
18715
+ if (this.processor) {
18716
+ yield this.stopProcessor();
18717
+ }
18718
+ if (this.kind === 'unknown') {
18719
+ throw TypeError('cannot set processor on track of unknown kind');
18720
+ }
18721
+ this.processorElement = (_a = this.processorElement) !== null && _a !== void 0 ? _a : document.createElement(this.kind);
18722
+ this.processorElement.muted = true;
18723
+ attachToElement(this._mediaStreamTrack, this.processorElement);
18724
+ this.processorElement.play().catch(e => livekitLogger.error(e));
18725
+ const processorOptions = {
18726
+ kind: this.kind,
18727
+ track: this._mediaStreamTrack,
18728
+ element: this.processorElement
18729
+ };
18730
+ yield processor.init(processorOptions);
18731
+ this.processor = processor;
18732
+ if (this.processor.processedTrack) {
18733
+ for (const el of this.attachedElements) {
18734
+ if (el !== this.processorElement && showProcessedStreamLocally) {
18735
+ detachTrack(this._mediaStreamTrack, el);
18736
+ attachToElement(this.processor.processedTrack, el);
18737
+ }
18738
+ }
18739
+ yield (_b = this.sender) === null || _b === void 0 ? void 0 : _b.replaceTrack(this.processor.processedTrack);
18740
+ }
18741
+ this.isSettingUpProcessor = false;
18742
+ });
18743
+ }
18744
+ getProcessor() {
18745
+ return this.processor;
18746
+ }
18747
+ /**
18748
+ * Stops the track processor
18749
+ * See https://github.com/livekit/track-processors-js for example usage
18750
+ *
18751
+ * @experimental
18752
+ * @returns
18753
+ */
18754
+ stopProcessor() {
18755
+ var _a, _b;
18756
+ return __awaiter(this, void 0, void 0, function* () {
18757
+ if (!this.processor) return;
18758
+ livekitLogger.debug('stopping processor');
18759
+ (_a = this.processor.processedTrack) === null || _a === void 0 ? void 0 : _a.stop();
18760
+ yield this.processor.destroy();
18761
+ this.processor = undefined;
18762
+ (_b = this.processorElement) === null || _b === void 0 ? void 0 : _b.remove();
18763
+ this.processorElement = undefined;
18764
+ yield this.restart();
18765
+ });
18766
+ }
18467
18767
  }
18468
18768
 
18469
18769
  class LocalAudioTrack extends LocalTrack {
@@ -18629,67 +18929,366 @@ class LocalAudioTrack extends LocalTrack {
18629
18929
  }
18630
18930
  }
18631
18931
 
18632
- const refreshSubscribedCodecAfterNewCodec = 5000;
18633
- class LocalVideoTrack extends LocalTrack {
18634
- /**
18635
- *
18636
- * @param mediaTrack
18637
- * @param constraints MediaTrackConstraints that are being used when restarting or reacquiring tracks
18638
- * @param userProvidedTrack Signals to the SDK whether or not the mediaTrack should be managed (i.e. released and reacquired) internally by the SDK
18639
- */
18640
- constructor(mediaTrack, constraints) {
18641
- let userProvidedTrack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
18642
- super(mediaTrack, Track.Kind.Video, constraints, userProvidedTrack);
18643
- /* @internal */
18644
- this.simulcastCodecs = new Map();
18645
- this.monitorSender = () => __awaiter(this, void 0, void 0, function* () {
18646
- if (!this.sender) {
18647
- this._currentBitrate = 0;
18648
- return;
18649
- }
18650
- let stats;
18651
- try {
18652
- stats = yield this.getSenderStats();
18653
- } catch (e) {
18654
- livekitLogger.error('could not get audio sender stats', {
18655
- error: e
18656
- });
18657
- return;
18658
- }
18659
- const statsMap = new Map(stats.map(s => [s.rid, s]));
18660
- if (this.prevStats) {
18661
- let totalBitrate = 0;
18662
- statsMap.forEach((s, key) => {
18663
- var _a;
18664
- const prev = (_a = this.prevStats) === null || _a === void 0 ? void 0 : _a.get(key);
18665
- totalBitrate += computeBitrate(s, prev);
18666
- });
18667
- this._currentBitrate = totalBitrate;
18668
- }
18669
- this.prevStats = statsMap;
18670
- });
18671
- this.senderLock = new Mutex();
18672
- }
18673
- get isSimulcast() {
18674
- if (this.sender && this.sender.getParameters().encodings.length > 1) {
18675
- return true;
18676
- }
18677
- return false;
18932
+ /** @internal */
18933
+ function mediaTrackToLocalTrack(mediaStreamTrack, constraints) {
18934
+ switch (mediaStreamTrack.kind) {
18935
+ case 'audio':
18936
+ return new LocalAudioTrack(mediaStreamTrack, constraints, false);
18937
+ case 'video':
18938
+ return new LocalVideoTrack(mediaStreamTrack, constraints, false);
18939
+ default:
18940
+ throw new TrackInvalidError("unsupported track type: ".concat(mediaStreamTrack.kind));
18678
18941
  }
18679
- /* @internal */
18680
- startMonitor(signalClient) {
18942
+ }
18943
+ /* @internal */
18944
+ const presets169 = Object.values(VideoPresets);
18945
+ /* @internal */
18946
+ const presets43 = Object.values(VideoPresets43);
18947
+ /* @internal */
18948
+ const presetsScreenShare = Object.values(ScreenSharePresets);
18949
+ /* @internal */
18950
+ const defaultSimulcastPresets169 = [VideoPresets.h180, VideoPresets.h360];
18951
+ /* @internal */
18952
+ const defaultSimulcastPresets43 = [VideoPresets43.h180, VideoPresets43.h360];
18953
+ /* @internal */
18954
+ const computeDefaultScreenShareSimulcastPresets = fromPreset => {
18955
+ const layers = [{
18956
+ scaleResolutionDownBy: 2,
18957
+ fps: 3
18958
+ }];
18959
+ return layers.map(t => {
18681
18960
  var _a;
18682
- this.signalClient = signalClient;
18683
- if (!isWeb()) {
18684
- return;
18685
- }
18686
- // save original encodings
18687
- // TODO : merge simulcast tracks stats
18688
- const params = (_a = this.sender) === null || _a === void 0 ? void 0 : _a.getParameters();
18689
- if (params) {
18690
- this.encodings = params.encodings;
18691
- }
18692
- if (this.monitorInterval) {
18961
+ return new VideoPreset(Math.floor(fromPreset.width / t.scaleResolutionDownBy), Math.floor(fromPreset.height / t.scaleResolutionDownBy), Math.max(150000, Math.floor(fromPreset.encoding.maxBitrate / (Math.pow(t.scaleResolutionDownBy, 2) * (((_a = fromPreset.encoding.maxFramerate) !== null && _a !== void 0 ? _a : 30) / t.fps)))), t.fps, fromPreset.encoding.priority);
18962
+ });
18963
+ };
18964
+ // /**
18965
+ // *
18966
+ // * @internal
18967
+ // * @experimental
18968
+ // */
18969
+ // const computeDefaultMultiCodecSimulcastEncodings = (width: number, height: number) => {
18970
+ // // use vp8 as a default
18971
+ // const vp8 = determineAppropriateEncoding(false, width, height);
18972
+ // const vp9 = { ...vp8, maxBitrate: vp8.maxBitrate * 0.9 };
18973
+ // const h264 = { ...vp8, maxBitrate: vp8.maxBitrate * 1.1 };
18974
+ // const av1 = { ...vp8, maxBitrate: vp8.maxBitrate * 0.7 };
18975
+ // return {
18976
+ // vp8,
18977
+ // vp9,
18978
+ // h264,
18979
+ // av1,
18980
+ // };
18981
+ // };
18982
+ const videoRids = ['q', 'h', 'f'];
18983
+ /* @internal */
18984
+ function computeVideoEncodings(isScreenShare, width, height, options) {
18985
+ var _a, _b;
18986
+ let videoEncoding = options === null || options === void 0 ? void 0 : options.videoEncoding;
18987
+ if (isScreenShare) {
18988
+ videoEncoding = options === null || options === void 0 ? void 0 : options.screenShareEncoding;
18989
+ }
18990
+ const useSimulcast = options === null || options === void 0 ? void 0 : options.simulcast;
18991
+ const scalabilityMode = options === null || options === void 0 ? void 0 : options.scalabilityMode;
18992
+ const videoCodec = options === null || options === void 0 ? void 0 : options.videoCodec;
18993
+ if (!videoEncoding && !useSimulcast && !scalabilityMode || !width || !height) {
18994
+ // when we aren't simulcasting or svc, will need to return a single encoding without
18995
+ // capping bandwidth. we always require a encoding for dynacast
18996
+ return [{}];
18997
+ }
18998
+ if (!videoEncoding) {
18999
+ // find the right encoding based on width/height
19000
+ videoEncoding = determineAppropriateEncoding(isScreenShare, width, height, videoCodec);
19001
+ livekitLogger.debug('using video encoding', videoEncoding);
19002
+ }
19003
+ const original = new VideoPreset(width, height, videoEncoding.maxBitrate, videoEncoding.maxFramerate);
19004
+ if (scalabilityMode && isSVCCodec(videoCodec)) {
19005
+ livekitLogger.debug("using svc with scalabilityMode ".concat(scalabilityMode));
19006
+ const encodings = [];
19007
+ // svc use first encoding as the original, so we sort encoding from high to low
19008
+ switch (scalabilityMode) {
19009
+ case 'L3T3':
19010
+ case 'L3T3_KEY':
19011
+ encodings.push({
19012
+ rid: videoRids[2],
19013
+ maxBitrate: videoEncoding.maxBitrate,
19014
+ /* @ts-ignore */
19015
+ maxFramerate: original.encoding.maxFramerate,
19016
+ /* @ts-ignore */
19017
+ scalabilityMode: scalabilityMode
19018
+ });
19019
+ livekitLogger.debug('encodings', encodings);
19020
+ return encodings;
19021
+ default:
19022
+ // TODO : support other scalability modes
19023
+ throw new Error("unsupported scalabilityMode: ".concat(scalabilityMode));
19024
+ }
19025
+ }
19026
+ if (!useSimulcast) {
19027
+ return [videoEncoding];
19028
+ }
19029
+ let presets = [];
19030
+ if (isScreenShare) {
19031
+ presets = (_a = sortPresets(options === null || options === void 0 ? void 0 : options.screenShareSimulcastLayers)) !== null && _a !== void 0 ? _a : defaultSimulcastLayers(isScreenShare, original);
19032
+ } else {
19033
+ presets = (_b = sortPresets(options === null || options === void 0 ? void 0 : options.videoSimulcastLayers)) !== null && _b !== void 0 ? _b : defaultSimulcastLayers(isScreenShare, original);
19034
+ }
19035
+ let midPreset;
19036
+ if (presets.length > 0) {
19037
+ const lowPreset = presets[0];
19038
+ if (presets.length > 1) {
19039
+ [, midPreset] = presets;
19040
+ }
19041
+ // NOTE:
19042
+ // 1. Ordering of these encodings is important. Chrome seems
19043
+ // to use the index into encodings to decide which layer
19044
+ // to disable when CPU constrained.
19045
+ // So encodings should be ordered in increasing spatial
19046
+ // resolution order.
19047
+ // 2. ion-sfu translates rids into layers. So, all encodings
19048
+ // should have the base layer `q` and then more added
19049
+ // based on other conditions.
19050
+ const size = Math.max(width, height);
19051
+ if (size >= 960 && midPreset) {
19052
+ return encodingsFromPresets(width, height, [lowPreset, midPreset, original]);
19053
+ }
19054
+ if (size >= 480) {
19055
+ return encodingsFromPresets(width, height, [lowPreset, original]);
19056
+ }
19057
+ }
19058
+ return encodingsFromPresets(width, height, [original]);
19059
+ }
19060
+ function computeTrackBackupEncodings(track, videoCodec, opts) {
19061
+ var _a, _b, _c, _d;
19062
+ if (!opts.backupCodec || opts.backupCodec.codec === opts.videoCodec) {
19063
+ // backup codec publishing is disabled
19064
+ return;
19065
+ }
19066
+ if (videoCodec !== opts.backupCodec.codec) {
19067
+ livekitLogger.warn('requested a different codec than specified as backup', {
19068
+ serverRequested: videoCodec,
19069
+ backup: opts.backupCodec.codec
19070
+ });
19071
+ }
19072
+ opts.videoCodec = videoCodec;
19073
+ // use backup encoding setting as videoEncoding for backup codec publishing
19074
+ opts.videoEncoding = opts.backupCodec.encoding;
19075
+ const settings = track.mediaStreamTrack.getSettings();
19076
+ const width = (_a = settings.width) !== null && _a !== void 0 ? _a : (_b = track.dimensions) === null || _b === void 0 ? void 0 : _b.width;
19077
+ const height = (_c = settings.height) !== null && _c !== void 0 ? _c : (_d = track.dimensions) === null || _d === void 0 ? void 0 : _d.height;
19078
+ const encodings = computeVideoEncodings(track.source === Track.Source.ScreenShare, width, height, opts);
19079
+ return encodings;
19080
+ }
19081
+ /* @internal */
19082
+ function determineAppropriateEncoding(isScreenShare, width, height, codec) {
19083
+ const presets = presetsForResolution(isScreenShare, width, height);
19084
+ let {
19085
+ encoding
19086
+ } = presets[0];
19087
+ // handle portrait by swapping dimensions
19088
+ const size = Math.max(width, height);
19089
+ for (let i = 0; i < presets.length; i += 1) {
19090
+ const preset = presets[i];
19091
+ encoding = preset.encoding;
19092
+ if (preset.width >= size) {
19093
+ break;
19094
+ }
19095
+ }
19096
+ // presets are based on the assumption of vp8 as a codec
19097
+ // for other codecs we adjust the maxBitrate if no specific videoEncoding has been provided
19098
+ // TODO make the bitrate multipliers configurable per codec
19099
+ if (codec) {
19100
+ switch (codec) {
19101
+ case 'av1':
19102
+ encoding = Object.assign({}, encoding);
19103
+ encoding.maxBitrate = encoding.maxBitrate * 0.7;
19104
+ break;
19105
+ case 'vp9':
19106
+ encoding = Object.assign({}, encoding);
19107
+ encoding.maxBitrate = encoding.maxBitrate * 0.85;
19108
+ break;
19109
+ }
19110
+ }
19111
+ return encoding;
19112
+ }
19113
+ /* @internal */
19114
+ function presetsForResolution(isScreenShare, width, height) {
19115
+ if (isScreenShare) {
19116
+ return presetsScreenShare;
19117
+ }
19118
+ const aspect = width > height ? width / height : height / width;
19119
+ if (Math.abs(aspect - 16.0 / 9) < Math.abs(aspect - 4.0 / 3)) {
19120
+ return presets169;
19121
+ }
19122
+ return presets43;
19123
+ }
19124
+ /* @internal */
19125
+ function defaultSimulcastLayers(isScreenShare, original) {
19126
+ if (isScreenShare) {
19127
+ return computeDefaultScreenShareSimulcastPresets(original);
19128
+ }
19129
+ const {
19130
+ width,
19131
+ height
19132
+ } = original;
19133
+ const aspect = width > height ? width / height : height / width;
19134
+ if (Math.abs(aspect - 16.0 / 9) < Math.abs(aspect - 4.0 / 3)) {
19135
+ return defaultSimulcastPresets169;
19136
+ }
19137
+ return defaultSimulcastPresets43;
19138
+ }
19139
+ // presets should be ordered by low, medium, high
19140
+ function encodingsFromPresets(width, height, presets) {
19141
+ const encodings = [];
19142
+ presets.forEach((preset, idx) => {
19143
+ if (idx >= videoRids.length) {
19144
+ return;
19145
+ }
19146
+ const size = Math.min(width, height);
19147
+ const rid = videoRids[idx];
19148
+ const encoding = {
19149
+ rid,
19150
+ scaleResolutionDownBy: Math.max(1, size / Math.min(preset.width, preset.height)),
19151
+ maxBitrate: preset.encoding.maxBitrate
19152
+ };
19153
+ if (preset.encoding.maxFramerate) {
19154
+ encoding.maxFramerate = preset.encoding.maxFramerate;
19155
+ }
19156
+ if (preset.encoding.priority) {
19157
+ encoding.priority = preset.encoding.priority;
19158
+ encoding.networkPriority = preset.encoding.priority;
19159
+ }
19160
+ encodings.push(encoding);
19161
+ });
19162
+ // RN ios simulcast requires all same framerates.
19163
+ if (isReactNative() && getReactNativeOs() === 'ios') {
19164
+ let topFramerate = undefined;
19165
+ encodings.forEach(encoding => {
19166
+ if (!topFramerate) {
19167
+ topFramerate = encoding.maxFramerate;
19168
+ } else if (encoding.maxFramerate && encoding.maxFramerate > topFramerate) {
19169
+ topFramerate = encoding.maxFramerate;
19170
+ }
19171
+ });
19172
+ let notifyOnce = true;
19173
+ encodings.forEach(encoding => {
19174
+ var _a;
19175
+ if (encoding.maxFramerate != topFramerate) {
19176
+ if (notifyOnce) {
19177
+ notifyOnce = false;
19178
+ livekitLogger.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.");
19179
+ }
19180
+ livekitLogger.info("Setting framerate of encoding \"".concat((_a = encoding.rid) !== null && _a !== void 0 ? _a : '', "\" to ").concat(topFramerate));
19181
+ encoding.maxFramerate = topFramerate;
19182
+ }
19183
+ });
19184
+ }
19185
+ return encodings;
19186
+ }
19187
+ /** @internal */
19188
+ function sortPresets(presets) {
19189
+ if (!presets) return;
19190
+ return presets.sort((a, b) => {
19191
+ const {
19192
+ encoding: aEnc
19193
+ } = a;
19194
+ const {
19195
+ encoding: bEnc
19196
+ } = b;
19197
+ if (aEnc.maxBitrate > bEnc.maxBitrate) {
19198
+ return 1;
19199
+ }
19200
+ if (aEnc.maxBitrate < bEnc.maxBitrate) return -1;
19201
+ if (aEnc.maxBitrate === bEnc.maxBitrate && aEnc.maxFramerate && bEnc.maxFramerate) {
19202
+ return aEnc.maxFramerate > bEnc.maxFramerate ? 1 : -1;
19203
+ }
19204
+ return 0;
19205
+ });
19206
+ }
19207
+ /** @internal */
19208
+ class ScalabilityMode {
19209
+ constructor(scalabilityMode) {
19210
+ const results = scalabilityMode.match(/^L(\d)T(\d)(h|_KEY|_KEY_SHIFT){0,1}$/);
19211
+ if (!results) {
19212
+ throw new Error('invalid scalability mode');
19213
+ }
19214
+ this.spatial = parseInt(results[1]);
19215
+ this.temporal = parseInt(results[2]);
19216
+ if (results.length > 3) {
19217
+ switch (results[3]) {
19218
+ case 'h':
19219
+ case '_KEY':
19220
+ case '_KEY_SHIFT':
19221
+ this.suffix = results[3];
19222
+ }
19223
+ }
19224
+ }
19225
+ toString() {
19226
+ var _a;
19227
+ return "L".concat(this.spatial, "T").concat(this.temporal).concat((_a = this.suffix) !== null && _a !== void 0 ? _a : '');
19228
+ }
19229
+ }
19230
+
19231
+ const refreshSubscribedCodecAfterNewCodec = 5000;
19232
+ class LocalVideoTrack extends LocalTrack {
19233
+ /**
19234
+ *
19235
+ * @param mediaTrack
19236
+ * @param constraints MediaTrackConstraints that are being used when restarting or reacquiring tracks
19237
+ * @param userProvidedTrack Signals to the SDK whether or not the mediaTrack should be managed (i.e. released and reacquired) internally by the SDK
19238
+ */
19239
+ constructor(mediaTrack, constraints) {
19240
+ let userProvidedTrack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
19241
+ super(mediaTrack, Track.Kind.Video, constraints, userProvidedTrack);
19242
+ /* @internal */
19243
+ this.simulcastCodecs = new Map();
19244
+ this.monitorSender = () => __awaiter(this, void 0, void 0, function* () {
19245
+ if (!this.sender) {
19246
+ this._currentBitrate = 0;
19247
+ return;
19248
+ }
19249
+ let stats;
19250
+ try {
19251
+ stats = yield this.getSenderStats();
19252
+ } catch (e) {
19253
+ livekitLogger.error('could not get audio sender stats', {
19254
+ error: e
19255
+ });
19256
+ return;
19257
+ }
19258
+ const statsMap = new Map(stats.map(s => [s.rid, s]));
19259
+ if (this.prevStats) {
19260
+ let totalBitrate = 0;
19261
+ statsMap.forEach((s, key) => {
19262
+ var _a;
19263
+ const prev = (_a = this.prevStats) === null || _a === void 0 ? void 0 : _a.get(key);
19264
+ totalBitrate += computeBitrate(s, prev);
19265
+ });
19266
+ this._currentBitrate = totalBitrate;
19267
+ }
19268
+ this.prevStats = statsMap;
19269
+ });
19270
+ this.senderLock = new Mutex();
19271
+ }
19272
+ get isSimulcast() {
19273
+ if (this.sender && this.sender.getParameters().encodings.length > 1) {
19274
+ return true;
19275
+ }
19276
+ return false;
19277
+ }
19278
+ /* @internal */
19279
+ startMonitor(signalClient) {
19280
+ var _a;
19281
+ this.signalClient = signalClient;
19282
+ if (!isWeb()) {
19283
+ return;
19284
+ }
19285
+ // save original encodings
19286
+ // TODO : merge simulcast tracks stats
19287
+ const params = (_a = this.sender) === null || _a === void 0 ? void 0 : _a.getParameters();
19288
+ if (params) {
19289
+ this.encodings = params.encodings;
19290
+ }
19291
+ if (this.monitorInterval) {
18693
19292
  return;
18694
19293
  }
18695
19294
  this.monitorInterval = setInterval(() => {
@@ -18870,30 +19469,26 @@ class LocalVideoTrack extends LocalTrack {
18870
19469
  this.subscribedCodecs = codecs;
18871
19470
  const newCodecs = [];
18872
19471
  try {
18873
- for (_a = true, codecs_1 = __asyncValues(codecs); codecs_1_1 = yield codecs_1.next(), _b = codecs_1_1.done, !_b;) {
19472
+ for (_a = true, codecs_1 = __asyncValues(codecs); codecs_1_1 = yield codecs_1.next(), _b = codecs_1_1.done, !_b; _a = true) {
18874
19473
  _d = codecs_1_1.value;
18875
19474
  _a = false;
18876
- try {
18877
- const codec = _d;
18878
- if (!this.codec || this.codec === codec.codec) {
18879
- yield this.setPublishingLayers(codec.qualities);
18880
- } else {
18881
- const simulcastCodecInfo = this.simulcastCodecs.get(codec.codec);
18882
- livekitLogger.debug("try setPublishingCodec for ".concat(codec.codec), simulcastCodecInfo);
18883
- if (!simulcastCodecInfo || !simulcastCodecInfo.sender) {
18884
- for (const q of codec.qualities) {
18885
- if (q.enabled) {
18886
- newCodecs.push(codec.codec);
18887
- break;
18888
- }
19475
+ const codec = _d;
19476
+ if (!this.codec || this.codec === codec.codec) {
19477
+ yield this.setPublishingLayers(codec.qualities);
19478
+ } else {
19479
+ const simulcastCodecInfo = this.simulcastCodecs.get(codec.codec);
19480
+ livekitLogger.debug("try setPublishingCodec for ".concat(codec.codec), simulcastCodecInfo);
19481
+ if (!simulcastCodecInfo || !simulcastCodecInfo.sender) {
19482
+ for (const q of codec.qualities) {
19483
+ if (q.enabled) {
19484
+ newCodecs.push(codec.codec);
19485
+ break;
18889
19486
  }
18890
- } else if (simulcastCodecInfo.encodings) {
18891
- livekitLogger.debug("try setPublishingLayersForSender ".concat(codec.codec));
18892
- yield setPublishingLayersForSender(simulcastCodecInfo.sender, simulcastCodecInfo.encodings, codec.qualities, this.senderLock);
18893
19487
  }
19488
+ } else if (simulcastCodecInfo.encodings) {
19489
+ livekitLogger.debug("try setPublishingLayersForSender ".concat(codec.codec));
19490
+ yield setPublishingLayersForSender(simulcastCodecInfo.sender, simulcastCodecInfo.encodings, codec.qualities, this.senderLock);
18894
19491
  }
18895
- } finally {
18896
- _a = true;
18897
19492
  }
18898
19493
  }
18899
19494
  } catch (e_1_1) {
@@ -18959,40 +19554,81 @@ function setPublishingLayersForSender(sender, senderEncodings, qualities, sender
18959
19554
  return;
18960
19555
  }
18961
19556
  let hasChanged = false;
18962
- encodings.forEach((encoding, idx) => {
18963
- var _a;
18964
- let rid = (_a = encoding.rid) !== null && _a !== void 0 ? _a : '';
18965
- if (rid === '') {
18966
- rid = 'q';
18967
- }
18968
- const quality = videoQualityForRid(rid);
18969
- const subscribedQuality = qualities.find(q => q.quality === quality);
18970
- if (!subscribedQuality) {
18971
- return;
18972
- }
18973
- if (encoding.active !== subscribedQuality.enabled) {
19557
+ /* @ts-ignore */
19558
+ if (encodings.length === 1 && encodings[0].scalabilityMode) {
19559
+ // svc dynacast encodings
19560
+ const encoding = encodings[0];
19561
+ /* @ts-ignore */
19562
+ // const mode = new ScalabilityMode(encoding.scalabilityMode);
19563
+ let maxQuality = VideoQuality.OFF;
19564
+ qualities.forEach(q => {
19565
+ if (q.enabled && (maxQuality === VideoQuality.OFF || q.quality > maxQuality)) {
19566
+ maxQuality = q.quality;
19567
+ }
19568
+ });
19569
+ if (maxQuality === VideoQuality.OFF) {
19570
+ if (encoding.active) {
19571
+ encoding.active = false;
19572
+ hasChanged = true;
19573
+ }
19574
+ } else if (!encoding.active /* || mode.spatial !== maxQuality + 1*/) {
18974
19575
  hasChanged = true;
18975
- encoding.active = subscribedQuality.enabled;
18976
- livekitLogger.debug("setting layer ".concat(subscribedQuality.quality, " to ").concat(encoding.active ? 'enabled' : 'disabled'));
18977
- // FireFox does not support setting encoding.active to false, so we
18978
- // have a workaround of lowering its bitrate and resolution to the min.
18979
- if (isFireFox()) {
18980
- if (subscribedQuality.enabled) {
18981
- encoding.scaleResolutionDownBy = senderEncodings[idx].scaleResolutionDownBy;
18982
- encoding.maxBitrate = senderEncodings[idx].maxBitrate;
18983
- /* @ts-ignore */
18984
- encoding.maxFrameRate = senderEncodings[idx].maxFrameRate;
18985
- } else {
18986
- encoding.scaleResolutionDownBy = 4;
18987
- encoding.maxBitrate = 10;
18988
- /* @ts-ignore */
18989
- encoding.maxFrameRate = 2;
19576
+ encoding.active = true;
19577
+ /* disable closable spatial layer as it has video blur/frozen issue with current server/client
19578
+ 1. chrome 113: when switching to up layer with scalability Mode change, it will generate a
19579
+ low resolution frame and recover very quickly, but noticable
19580
+ 2. livekit sfu: additional pli request cause video frozen for a few frames, also noticable
19581
+ @ts-ignore
19582
+ const originalMode = new ScalabilityMode(senderEncodings[0].scalabilityMode)
19583
+ mode.spatial = maxQuality + 1;
19584
+ mode.suffix = originalMode.suffix;
19585
+ if (mode.spatial === 1) {
19586
+ // no suffix for L1Tx
19587
+ mode.suffix = undefined;
19588
+ }
19589
+ @ts-ignore
19590
+ encoding.scalabilityMode = mode.toString();
19591
+ encoding.scaleResolutionDownBy = 2 ** (2 - maxQuality);
19592
+ */
19593
+ }
19594
+ } else {
19595
+ // simulcast dynacast encodings
19596
+ encodings.forEach((encoding, idx) => {
19597
+ var _a;
19598
+ let rid = (_a = encoding.rid) !== null && _a !== void 0 ? _a : '';
19599
+ if (rid === '') {
19600
+ rid = 'q';
19601
+ }
19602
+ const quality = videoQualityForRid(rid);
19603
+ const subscribedQuality = qualities.find(q => q.quality === quality);
19604
+ if (!subscribedQuality) {
19605
+ return;
19606
+ }
19607
+ if (encoding.active !== subscribedQuality.enabled) {
19608
+ hasChanged = true;
19609
+ encoding.active = subscribedQuality.enabled;
19610
+ livekitLogger.debug("setting layer ".concat(subscribedQuality.quality, " to ").concat(encoding.active ? 'enabled' : 'disabled'));
19611
+ // FireFox does not support setting encoding.active to false, so we
19612
+ // have a workaround of lowering its bitrate and resolution to the min.
19613
+ if (isFireFox()) {
19614
+ if (subscribedQuality.enabled) {
19615
+ encoding.scaleResolutionDownBy = senderEncodings[idx].scaleResolutionDownBy;
19616
+ encoding.maxBitrate = senderEncodings[idx].maxBitrate;
19617
+ /* @ts-ignore */
19618
+ encoding.maxFrameRate = senderEncodings[idx].maxFrameRate;
19619
+ } else {
19620
+ encoding.scaleResolutionDownBy = 4;
19621
+ encoding.maxBitrate = 10;
19622
+ /* @ts-ignore */
19623
+ encoding.maxFrameRate = 2;
19624
+ }
18990
19625
  }
18991
19626
  }
18992
- }
18993
- });
19627
+ });
19628
+ }
18994
19629
  if (hasChanged) {
18995
19630
  params.encodings = encodings;
19631
+ livekitLogger.debug("setting encodings", params.encodings);
18996
19632
  yield sender.setParameters(params);
18997
19633
  }
18998
19634
  } finally {
@@ -19023,6 +19659,23 @@ function videoLayersFromEncodings(width, height, encodings) {
19023
19659
  ssrc: 0
19024
19660
  }];
19025
19661
  }
19662
+ /* @ts-ignore */
19663
+ if (encodings.length === 1 && encodings[0].scalabilityMode) {
19664
+ // svc layers
19665
+ /* @ts-ignore */
19666
+ const sm = new ScalabilityMode(encodings[0].scalabilityMode);
19667
+ const layers = [];
19668
+ for (let i = 0; i < sm.spatial; i += 1) {
19669
+ layers.push({
19670
+ quality: VideoQuality.HIGH - i,
19671
+ width: width / Math.pow(2, i),
19672
+ height: height / Math.pow(2, i),
19673
+ bitrate: encodings[0].maxBitrate ? encodings[0].maxBitrate / Math.pow(3, i) : 0,
19674
+ ssrc: 0
19675
+ });
19676
+ }
19677
+ return layers;
19678
+ }
19026
19679
  return encodings.map(encoding => {
19027
19680
  var _a, _b, _c;
19028
19681
  const scale = (_a = encoding.scaleResolutionDownBy) !== null && _a !== void 0 ? _a : 1;
@@ -20111,6 +20764,10 @@ class RemoteTrackPublication extends TrackPublication {
20111
20764
  this.emitSubscriptionUpdateIfChanged(prevStatus);
20112
20765
  }
20113
20766
  /** @internal */
20767
+ setSubscriptionError(error) {
20768
+ this.emit(TrackEvent.SubscriptionFailed, error);
20769
+ }
20770
+ /** @internal */
20114
20771
  updateInfo(info) {
20115
20772
  super.updateInfo(info);
20116
20773
  const prevMetadataMuted = this.metadataMuted;
@@ -20201,491 +20858,239 @@ class RemoteParticipant extends Participant {
20201
20858
  publication.on(TrackEvent.SubscriptionPermissionChanged, status => {
20202
20859
  this.emit(ParticipantEvent.TrackSubscriptionPermissionChanged, publication, status);
20203
20860
  });
20204
- publication.on(TrackEvent.SubscriptionStatusChanged, status => {
20205
- this.emit(ParticipantEvent.TrackSubscriptionStatusChanged, publication, status);
20206
- });
20207
- publication.on(TrackEvent.Subscribed, track => {
20208
- this.emit(ParticipantEvent.TrackSubscribed, track, publication);
20209
- });
20210
- publication.on(TrackEvent.Unsubscribed, previousTrack => {
20211
- this.emit(ParticipantEvent.TrackUnsubscribed, previousTrack, publication);
20212
- });
20213
- }
20214
- getTrack(source) {
20215
- const track = super.getTrack(source);
20216
- if (track) {
20217
- return track;
20218
- }
20219
- }
20220
- getTrackByName(name) {
20221
- const track = super.getTrackByName(name);
20222
- if (track) {
20223
- return track;
20224
- }
20225
- }
20226
- /**
20227
- * sets the volume on the participant's microphone track
20228
- * if no track exists the volume will be applied when the microphone track is added
20229
- */
20230
- setVolume(volume) {
20231
- this.volume = volume;
20232
- const audioPublication = this.getTrack(Track.Source.Microphone);
20233
- if (audioPublication && audioPublication.track) {
20234
- audioPublication.track.setVolume(volume);
20235
- }
20236
- }
20237
- /**
20238
- * gets the volume on the participant's microphone track
20239
- */
20240
- getVolume() {
20241
- const audioPublication = this.getTrack(Track.Source.Microphone);
20242
- if (audioPublication && audioPublication.track) {
20243
- return audioPublication.track.getVolume();
20244
- }
20245
- return this.volume;
20246
- }
20247
- /** @internal */
20248
- addSubscribedMediaTrack(mediaTrack, sid, mediaStream, receiver, adaptiveStreamSettings, triesLeft) {
20249
- // find the track publication
20250
- // it's possible for the media track to arrive before participant info
20251
- let publication = this.getTrackPublication(sid);
20252
- // it's also possible that the browser didn't honor our original track id
20253
- // FireFox would use its own local uuid instead of server track id
20254
- if (!publication) {
20255
- if (!sid.startsWith('TR')) {
20256
- // find the first track that matches type
20257
- this.tracks.forEach(p => {
20258
- if (!publication && mediaTrack.kind === p.kind.toString()) {
20259
- publication = p;
20260
- }
20261
- });
20262
- }
20263
- }
20264
- // when we couldn't locate the track, it's possible that the metadata hasn't
20265
- // yet arrived. Wait a bit longer for it to arrive, or fire an error
20266
- if (!publication) {
20267
- if (triesLeft === 0) {
20268
- livekitLogger.error('could not find published track', {
20269
- participant: this.sid,
20270
- trackSid: sid
20271
- });
20272
- this.emit(ParticipantEvent.TrackSubscriptionFailed, sid);
20273
- return;
20274
- }
20275
- if (triesLeft === undefined) triesLeft = 20;
20276
- setTimeout(() => {
20277
- this.addSubscribedMediaTrack(mediaTrack, sid, mediaStream, receiver, adaptiveStreamSettings, triesLeft - 1);
20278
- }, 150);
20279
- return;
20280
- }
20281
- if (mediaTrack.readyState === 'ended') {
20282
- livekitLogger.error('unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()', {
20283
- participant: this.sid,
20284
- trackSid: sid
20285
- });
20286
- this.emit(ParticipantEvent.TrackSubscriptionFailed, sid);
20287
- return;
20288
- }
20289
- const isVideo = mediaTrack.kind === 'video';
20290
- let track;
20291
- if (isVideo) {
20292
- track = new RemoteVideoTrack(mediaTrack, sid, receiver, adaptiveStreamSettings);
20293
- } else {
20294
- track = new RemoteAudioTrack(mediaTrack, sid, receiver, this.audioContext, this.audioOutput);
20295
- }
20296
- // set track info
20297
- track.source = publication.source;
20298
- // keep publication's muted status
20299
- track.isMuted = publication.isMuted;
20300
- track.setMediaStream(mediaStream);
20301
- track.start();
20302
- publication.setTrack(track);
20303
- // set participant volume on new microphone tracks
20304
- if (this.volume !== undefined && track instanceof RemoteAudioTrack && track.source === Track.Source.Microphone) {
20305
- track.setVolume(this.volume);
20306
- }
20307
- return publication;
20308
- }
20309
- /** @internal */
20310
- get hasMetadata() {
20311
- return !!this.participantInfo;
20312
- }
20313
- getTrackPublication(sid) {
20314
- return this.tracks.get(sid);
20315
- }
20316
- /** @internal */
20317
- updateInfo(info) {
20318
- if (!super.updateInfo(info)) {
20319
- return false;
20320
- }
20321
- // we are getting a list of all available tracks, reconcile in here
20322
- // and send out events for changes
20323
- // reconcile track publications, publish events only if metadata is already there
20324
- // i.e. changes since the local participant has joined
20325
- const validTracks = new Map();
20326
- const newTracks = new Map();
20327
- info.tracks.forEach(ti => {
20328
- var _a;
20329
- let publication = this.getTrackPublication(ti.sid);
20330
- if (!publication) {
20331
- // new publication
20332
- const kind = Track.kindFromProto(ti.type);
20333
- if (!kind) {
20334
- return;
20335
- }
20336
- publication = new RemoteTrackPublication(kind, ti, (_a = this.signalClient.connectOptions) === null || _a === void 0 ? void 0 : _a.autoSubscribe);
20337
- publication.updateInfo(ti);
20338
- newTracks.set(ti.sid, publication);
20339
- const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => publishedTrack.source === (publication === null || publication === void 0 ? void 0 : publication.source));
20340
- if (existingTrackOfSource && publication.source !== Track.Source.Unknown) {
20341
- livekitLogger.debug("received a second track publication for ".concat(this.identity, " with the same source: ").concat(publication.source), {
20342
- oldTrack: existingTrackOfSource,
20343
- newTrack: publication,
20344
- participant: this,
20345
- participantInfo: info
20346
- });
20347
- }
20348
- this.addTrackPublication(publication);
20349
- } else {
20350
- publication.updateInfo(ti);
20351
- }
20352
- validTracks.set(ti.sid, publication);
20353
- });
20354
- // detect removed tracks
20355
- this.tracks.forEach(publication => {
20356
- if (!validTracks.has(publication.trackSid)) {
20357
- livekitLogger.trace('detected removed track on remote participant, unpublishing', {
20358
- publication,
20359
- participantSid: this.sid
20360
- });
20361
- this.unpublishTrack(publication.trackSid, true);
20362
- }
20861
+ publication.on(TrackEvent.SubscriptionStatusChanged, status => {
20862
+ this.emit(ParticipantEvent.TrackSubscriptionStatusChanged, publication, status);
20363
20863
  });
20364
- // always emit events for new publications, Room will not forward them unless it's ready
20365
- newTracks.forEach(publication => {
20366
- this.emit(ParticipantEvent.TrackPublished, publication);
20864
+ publication.on(TrackEvent.Subscribed, track => {
20865
+ this.emit(ParticipantEvent.TrackSubscribed, track, publication);
20866
+ });
20867
+ publication.on(TrackEvent.Unsubscribed, previousTrack => {
20868
+ this.emit(ParticipantEvent.TrackUnsubscribed, previousTrack, publication);
20869
+ });
20870
+ publication.on(TrackEvent.SubscriptionFailed, error => {
20871
+ this.emit(ParticipantEvent.TrackSubscriptionFailed, publication.trackSid, error);
20367
20872
  });
20368
- return true;
20369
20873
  }
20370
- /** @internal */
20371
- unpublishTrack(sid, sendUnpublish) {
20372
- const publication = this.tracks.get(sid);
20373
- if (!publication) {
20374
- return;
20375
- }
20376
- // also send unsubscribe, if track is actively subscribed
20377
- const {
20378
- track
20379
- } = publication;
20874
+ getTrack(source) {
20875
+ const track = super.getTrack(source);
20380
20876
  if (track) {
20381
- track.stop();
20382
- publication.setTrack(undefined);
20383
- }
20384
- // remove track from maps only after unsubscribed has been fired
20385
- this.tracks.delete(sid);
20386
- // remove from the right type map
20387
- switch (publication.kind) {
20388
- case Track.Kind.Audio:
20389
- this.audioTracks.delete(sid);
20390
- break;
20391
- case Track.Kind.Video:
20392
- this.videoTracks.delete(sid);
20393
- break;
20877
+ return track;
20394
20878
  }
20395
- if (sendUnpublish) {
20396
- this.emit(ParticipantEvent.TrackUnpublished, publication);
20879
+ }
20880
+ getTrackByName(name) {
20881
+ const track = super.getTrackByName(name);
20882
+ if (track) {
20883
+ return track;
20397
20884
  }
20398
20885
  }
20399
20886
  /**
20400
- * @internal
20887
+ * sets the volume on the participant's microphone track
20888
+ * if no track exists the volume will be applied when the microphone track is added
20401
20889
  */
20402
- setAudioContext(ctx) {
20403
- this.audioContext = ctx;
20404
- this.audioTracks.forEach(track => track.track instanceof RemoteAudioTrack && track.track.setAudioContext(ctx));
20890
+ setVolume(volume) {
20891
+ this.volume = volume;
20892
+ const audioPublication = this.getTrack(Track.Source.Microphone);
20893
+ if (audioPublication && audioPublication.track) {
20894
+ audioPublication.track.setVolume(volume);
20895
+ }
20405
20896
  }
20406
20897
  /**
20407
- * @internal
20898
+ * gets the volume on the participant's microphone track
20408
20899
  */
20409
- setAudioOutput(output) {
20410
- return __awaiter(this, void 0, void 0, function* () {
20411
- this.audioOutput = output;
20412
- const promises = [];
20413
- this.audioTracks.forEach(pub => {
20414
- var _a;
20415
- if (pub.track instanceof RemoteAudioTrack) {
20416
- promises.push(pub.track.setSinkId((_a = output.deviceId) !== null && _a !== void 0 ? _a : 'default'));
20417
- }
20418
- });
20419
- yield Promise.all(promises);
20420
- });
20900
+ getVolume() {
20901
+ const audioPublication = this.getTrack(Track.Source.Microphone);
20902
+ if (audioPublication && audioPublication.track) {
20903
+ return audioPublication.track.getVolume();
20904
+ }
20905
+ return this.volume;
20421
20906
  }
20422
20907
  /** @internal */
20423
- emit(event) {
20424
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
20425
- args[_key - 1] = arguments[_key];
20908
+ addSubscribedMediaTrack(mediaTrack, sid, mediaStream, receiver, adaptiveStreamSettings, triesLeft) {
20909
+ // find the track publication
20910
+ // it's possible for the media track to arrive before participant info
20911
+ let publication = this.getTrackPublication(sid);
20912
+ // it's also possible that the browser didn't honor our original track id
20913
+ // FireFox would use its own local uuid instead of server track id
20914
+ if (!publication) {
20915
+ if (!sid.startsWith('TR')) {
20916
+ // find the first track that matches type
20917
+ this.tracks.forEach(p => {
20918
+ if (!publication && mediaTrack.kind === p.kind.toString()) {
20919
+ publication = p;
20920
+ }
20921
+ });
20922
+ }
20426
20923
  }
20427
- livekitLogger.trace('participant event', {
20428
- participant: this.sid,
20429
- event,
20430
- args
20431
- });
20432
- return super.emit(event, ...args);
20433
- }
20434
- }
20435
-
20436
- /** @internal */
20437
- function mediaTrackToLocalTrack(mediaStreamTrack, constraints) {
20438
- switch (mediaStreamTrack.kind) {
20439
- case 'audio':
20440
- return new LocalAudioTrack(mediaStreamTrack, constraints, false);
20441
- case 'video':
20442
- return new LocalVideoTrack(mediaStreamTrack, constraints, false);
20443
- default:
20444
- throw new TrackInvalidError("unsupported track type: ".concat(mediaStreamTrack.kind));
20445
- }
20446
- }
20447
- /* @internal */
20448
- const presets169 = Object.values(VideoPresets);
20449
- /* @internal */
20450
- const presets43 = Object.values(VideoPresets43);
20451
- /* @internal */
20452
- const presetsScreenShare = Object.values(ScreenSharePresets);
20453
- /* @internal */
20454
- const defaultSimulcastPresets169 = [VideoPresets.h180, VideoPresets.h360];
20455
- /* @internal */
20456
- const defaultSimulcastPresets43 = [VideoPresets43.h180, VideoPresets43.h360];
20457
- /* @internal */
20458
- const computeDefaultScreenShareSimulcastPresets = fromPreset => {
20459
- const layers = [{
20460
- scaleResolutionDownBy: 2,
20461
- fps: 3
20462
- }];
20463
- return layers.map(t => {
20464
- var _a;
20465
- return new VideoPreset(Math.floor(fromPreset.width / t.scaleResolutionDownBy), Math.floor(fromPreset.height / t.scaleResolutionDownBy), Math.max(150000, Math.floor(fromPreset.encoding.maxBitrate / (Math.pow(t.scaleResolutionDownBy, 2) * (((_a = fromPreset.encoding.maxFramerate) !== null && _a !== void 0 ? _a : 30) / t.fps)))), t.fps, fromPreset.encoding.priority);
20466
- });
20467
- };
20468
- // /**
20469
- // *
20470
- // * @internal
20471
- // * @experimental
20472
- // */
20473
- // const computeDefaultMultiCodecSimulcastEncodings = (width: number, height: number) => {
20474
- // // use vp8 as a default
20475
- // const vp8 = determineAppropriateEncoding(false, width, height);
20476
- // const vp9 = { ...vp8, maxBitrate: vp8.maxBitrate * 0.9 };
20477
- // const h264 = { ...vp8, maxBitrate: vp8.maxBitrate * 1.1 };
20478
- // const av1 = { ...vp8, maxBitrate: vp8.maxBitrate * 0.7 };
20479
- // return {
20480
- // vp8,
20481
- // vp9,
20482
- // h264,
20483
- // av1,
20484
- // };
20485
- // };
20486
- const videoRids = ['q', 'h', 'f'];
20487
- /* @internal */
20488
- function computeVideoEncodings(isScreenShare, width, height, options) {
20489
- var _a, _b;
20490
- let videoEncoding = options === null || options === void 0 ? void 0 : options.videoEncoding;
20491
- if (isScreenShare) {
20492
- videoEncoding = options === null || options === void 0 ? void 0 : options.screenShareEncoding;
20493
- }
20494
- const useSimulcast = options === null || options === void 0 ? void 0 : options.simulcast;
20495
- const scalabilityMode = options === null || options === void 0 ? void 0 : options.scalabilityMode;
20496
- const videoCodec = options === null || options === void 0 ? void 0 : options.videoCodec;
20497
- if (!videoEncoding && !useSimulcast && !scalabilityMode || !width || !height) {
20498
- // when we aren't simulcasting or svc, will need to return a single encoding without
20499
- // capping bandwidth. we always require a encoding for dynacast
20500
- return [{}];
20501
- }
20502
- if (!videoEncoding) {
20503
- // find the right encoding based on width/height
20504
- videoEncoding = determineAppropriateEncoding(isScreenShare, width, height, videoCodec);
20505
- livekitLogger.debug('using video encoding', videoEncoding);
20506
- }
20507
- const original = new VideoPreset(width, height, videoEncoding.maxBitrate, videoEncoding.maxFramerate);
20508
- if (scalabilityMode && isSVCCodec(videoCodec)) {
20509
- livekitLogger.debug("using svc with scalabilityMode ".concat(scalabilityMode));
20510
- const encodings = [];
20511
- // svc use first encoding as the original, so we sort encoding from high to low
20512
- switch (scalabilityMode) {
20513
- case 'L3T3':
20514
- for (let i = 0; i < 3; i += 1) {
20515
- encodings.push({
20516
- rid: videoRids[2 - i],
20517
- scaleResolutionDownBy: Math.pow(2, i),
20518
- maxBitrate: videoEncoding.maxBitrate / Math.pow(3, i),
20519
- /* @ts-ignore */
20520
- maxFramerate: original.encoding.maxFramerate,
20521
- /* @ts-ignore */
20522
- scalabilityMode: 'L3T3'
20523
- });
20524
- }
20525
- livekitLogger.debug('encodings', encodings);
20526
- return encodings;
20527
- default:
20528
- // TODO : support other scalability modes
20529
- throw new Error("unsupported scalabilityMode: ".concat(scalabilityMode));
20924
+ // when we couldn't locate the track, it's possible that the metadata hasn't
20925
+ // yet arrived. Wait a bit longer for it to arrive, or fire an error
20926
+ if (!publication) {
20927
+ if (triesLeft === 0) {
20928
+ livekitLogger.error('could not find published track', {
20929
+ participant: this.sid,
20930
+ trackSid: sid
20931
+ });
20932
+ this.emit(ParticipantEvent.TrackSubscriptionFailed, sid);
20933
+ return;
20934
+ }
20935
+ if (triesLeft === undefined) triesLeft = 20;
20936
+ setTimeout(() => {
20937
+ this.addSubscribedMediaTrack(mediaTrack, sid, mediaStream, receiver, adaptiveStreamSettings, triesLeft - 1);
20938
+ }, 150);
20939
+ return;
20530
20940
  }
20531
- }
20532
- if (!useSimulcast) {
20533
- return [videoEncoding];
20534
- }
20535
- let presets = [];
20536
- if (isScreenShare) {
20537
- presets = (_a = sortPresets(options === null || options === void 0 ? void 0 : options.screenShareSimulcastLayers)) !== null && _a !== void 0 ? _a : defaultSimulcastLayers(isScreenShare, original);
20538
- } else {
20539
- presets = (_b = sortPresets(options === null || options === void 0 ? void 0 : options.videoSimulcastLayers)) !== null && _b !== void 0 ? _b : defaultSimulcastLayers(isScreenShare, original);
20540
- }
20541
- let midPreset;
20542
- if (presets.length > 0) {
20543
- const lowPreset = presets[0];
20544
- if (presets.length > 1) {
20545
- [, midPreset] = presets;
20941
+ if (mediaTrack.readyState === 'ended') {
20942
+ livekitLogger.error('unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()', {
20943
+ participant: this.sid,
20944
+ trackSid: sid
20945
+ });
20946
+ this.emit(ParticipantEvent.TrackSubscriptionFailed, sid);
20947
+ return;
20546
20948
  }
20547
- // NOTE:
20548
- // 1. Ordering of these encodings is important. Chrome seems
20549
- // to use the index into encodings to decide which layer
20550
- // to disable when CPU constrained.
20551
- // So encodings should be ordered in increasing spatial
20552
- // resolution order.
20553
- // 2. ion-sfu translates rids into layers. So, all encodings
20554
- // should have the base layer `q` and then more added
20555
- // based on other conditions.
20556
- const size = Math.max(width, height);
20557
- if (size >= 960 && midPreset) {
20558
- return encodingsFromPresets(width, height, [lowPreset, midPreset, original]);
20949
+ const isVideo = mediaTrack.kind === 'video';
20950
+ let track;
20951
+ if (isVideo) {
20952
+ track = new RemoteVideoTrack(mediaTrack, sid, receiver, adaptiveStreamSettings);
20953
+ } else {
20954
+ track = new RemoteAudioTrack(mediaTrack, sid, receiver, this.audioContext, this.audioOutput);
20559
20955
  }
20560
- if (size >= 480) {
20561
- return encodingsFromPresets(width, height, [lowPreset, original]);
20956
+ // set track info
20957
+ track.source = publication.source;
20958
+ // keep publication's muted status
20959
+ track.isMuted = publication.isMuted;
20960
+ track.setMediaStream(mediaStream);
20961
+ track.start();
20962
+ publication.setTrack(track);
20963
+ // set participant volume on new microphone tracks
20964
+ if (this.volume !== undefined && track instanceof RemoteAudioTrack && track.source === Track.Source.Microphone) {
20965
+ track.setVolume(this.volume);
20562
20966
  }
20967
+ return publication;
20563
20968
  }
20564
- return encodingsFromPresets(width, height, [original]);
20565
- }
20566
- function computeTrackBackupEncodings(track, videoCodec, opts) {
20567
- var _a, _b, _c, _d;
20568
- if (!opts.backupCodec || opts.backupCodec.codec === opts.videoCodec) {
20569
- // backup codec publishing is disabled
20570
- return;
20969
+ /** @internal */
20970
+ get hasMetadata() {
20971
+ return !!this.participantInfo;
20571
20972
  }
20572
- if (videoCodec !== opts.backupCodec.codec) {
20573
- livekitLogger.warn('requested a different codec than specified as backup', {
20574
- serverRequested: videoCodec,
20575
- backup: opts.backupCodec.codec
20576
- });
20973
+ getTrackPublication(sid) {
20974
+ return this.tracks.get(sid);
20577
20975
  }
20578
- opts.videoCodec = videoCodec;
20579
- // use backup encoding setting as videoEncoding for backup codec publishing
20580
- opts.videoEncoding = opts.backupCodec.encoding;
20581
- const settings = track.mediaStreamTrack.getSettings();
20582
- const width = (_a = settings.width) !== null && _a !== void 0 ? _a : (_b = track.dimensions) === null || _b === void 0 ? void 0 : _b.width;
20583
- const height = (_c = settings.height) !== null && _c !== void 0 ? _c : (_d = track.dimensions) === null || _d === void 0 ? void 0 : _d.height;
20584
- const encodings = computeVideoEncodings(track.source === Track.Source.ScreenShare, width, height, opts);
20585
- return encodings;
20586
- }
20587
- /* @internal */
20588
- function determineAppropriateEncoding(isScreenShare, width, height, codec) {
20589
- const presets = presetsForResolution(isScreenShare, width, height);
20590
- let {
20591
- encoding
20592
- } = presets[0];
20593
- // handle portrait by swapping dimensions
20594
- const size = Math.max(width, height);
20595
- for (let i = 0; i < presets.length; i += 1) {
20596
- const preset = presets[i];
20597
- encoding = preset.encoding;
20598
- if (preset.width >= size) {
20599
- break;
20976
+ /** @internal */
20977
+ updateInfo(info) {
20978
+ if (!super.updateInfo(info)) {
20979
+ return false;
20600
20980
  }
20981
+ // we are getting a list of all available tracks, reconcile in here
20982
+ // and send out events for changes
20983
+ // reconcile track publications, publish events only if metadata is already there
20984
+ // i.e. changes since the local participant has joined
20985
+ const validTracks = new Map();
20986
+ const newTracks = new Map();
20987
+ info.tracks.forEach(ti => {
20988
+ var _a;
20989
+ let publication = this.getTrackPublication(ti.sid);
20990
+ if (!publication) {
20991
+ // new publication
20992
+ const kind = Track.kindFromProto(ti.type);
20993
+ if (!kind) {
20994
+ return;
20995
+ }
20996
+ publication = new RemoteTrackPublication(kind, ti, (_a = this.signalClient.connectOptions) === null || _a === void 0 ? void 0 : _a.autoSubscribe);
20997
+ publication.updateInfo(ti);
20998
+ newTracks.set(ti.sid, publication);
20999
+ const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => publishedTrack.source === (publication === null || publication === void 0 ? void 0 : publication.source));
21000
+ if (existingTrackOfSource && publication.source !== Track.Source.Unknown) {
21001
+ livekitLogger.debug("received a second track publication for ".concat(this.identity, " with the same source: ").concat(publication.source), {
21002
+ oldTrack: existingTrackOfSource,
21003
+ newTrack: publication,
21004
+ participant: this,
21005
+ participantInfo: info
21006
+ });
21007
+ }
21008
+ this.addTrackPublication(publication);
21009
+ } else {
21010
+ publication.updateInfo(ti);
21011
+ }
21012
+ validTracks.set(ti.sid, publication);
21013
+ });
21014
+ // detect removed tracks
21015
+ this.tracks.forEach(publication => {
21016
+ if (!validTracks.has(publication.trackSid)) {
21017
+ livekitLogger.trace('detected removed track on remote participant, unpublishing', {
21018
+ publication,
21019
+ participantSid: this.sid
21020
+ });
21021
+ this.unpublishTrack(publication.trackSid, true);
21022
+ }
21023
+ });
21024
+ // always emit events for new publications, Room will not forward them unless it's ready
21025
+ newTracks.forEach(publication => {
21026
+ this.emit(ParticipantEvent.TrackPublished, publication);
21027
+ });
21028
+ return true;
20601
21029
  }
20602
- // presets are based on the assumption of vp8 as a codec
20603
- // for other codecs we adjust the maxBitrate if no specific videoEncoding has been provided
20604
- // TODO make the bitrate multipliers configurable per codec
20605
- if (codec) {
20606
- switch (codec) {
20607
- case 'av1':
20608
- encoding = Object.assign({}, encoding);
20609
- encoding.maxBitrate = encoding.maxBitrate * 0.7;
21030
+ /** @internal */
21031
+ unpublishTrack(sid, sendUnpublish) {
21032
+ const publication = this.tracks.get(sid);
21033
+ if (!publication) {
21034
+ return;
21035
+ }
21036
+ // also send unsubscribe, if track is actively subscribed
21037
+ const {
21038
+ track
21039
+ } = publication;
21040
+ if (track) {
21041
+ track.stop();
21042
+ publication.setTrack(undefined);
21043
+ }
21044
+ // remove track from maps only after unsubscribed has been fired
21045
+ this.tracks.delete(sid);
21046
+ // remove from the right type map
21047
+ switch (publication.kind) {
21048
+ case Track.Kind.Audio:
21049
+ this.audioTracks.delete(sid);
20610
21050
  break;
20611
- case 'vp9':
20612
- encoding = Object.assign({}, encoding);
20613
- encoding.maxBitrate = encoding.maxBitrate * 0.85;
21051
+ case Track.Kind.Video:
21052
+ this.videoTracks.delete(sid);
20614
21053
  break;
20615
21054
  }
21055
+ if (sendUnpublish) {
21056
+ this.emit(ParticipantEvent.TrackUnpublished, publication);
21057
+ }
20616
21058
  }
20617
- return encoding;
20618
- }
20619
- /* @internal */
20620
- function presetsForResolution(isScreenShare, width, height) {
20621
- if (isScreenShare) {
20622
- return presetsScreenShare;
20623
- }
20624
- const aspect = width > height ? width / height : height / width;
20625
- if (Math.abs(aspect - 16.0 / 9) < Math.abs(aspect - 4.0 / 3)) {
20626
- return presets169;
20627
- }
20628
- return presets43;
20629
- }
20630
- /* @internal */
20631
- function defaultSimulcastLayers(isScreenShare, original) {
20632
- if (isScreenShare) {
20633
- return computeDefaultScreenShareSimulcastPresets(original);
21059
+ /**
21060
+ * @internal
21061
+ */
21062
+ setAudioContext(ctx) {
21063
+ this.audioContext = ctx;
21064
+ this.audioTracks.forEach(track => track.track instanceof RemoteAudioTrack && track.track.setAudioContext(ctx));
20634
21065
  }
20635
- const {
20636
- width,
20637
- height
20638
- } = original;
20639
- const aspect = width > height ? width / height : height / width;
20640
- if (Math.abs(aspect - 16.0 / 9) < Math.abs(aspect - 4.0 / 3)) {
20641
- return defaultSimulcastPresets169;
21066
+ /**
21067
+ * @internal
21068
+ */
21069
+ setAudioOutput(output) {
21070
+ return __awaiter(this, void 0, void 0, function* () {
21071
+ this.audioOutput = output;
21072
+ const promises = [];
21073
+ this.audioTracks.forEach(pub => {
21074
+ var _a;
21075
+ if (pub.track instanceof RemoteAudioTrack) {
21076
+ promises.push(pub.track.setSinkId((_a = output.deviceId) !== null && _a !== void 0 ? _a : 'default'));
21077
+ }
21078
+ });
21079
+ yield Promise.all(promises);
21080
+ });
20642
21081
  }
20643
- return defaultSimulcastPresets43;
20644
- }
20645
- // presets should be ordered by low, medium, high
20646
- function encodingsFromPresets(width, height, presets) {
20647
- const encodings = [];
20648
- presets.forEach((preset, idx) => {
20649
- if (idx >= videoRids.length) {
20650
- return;
20651
- }
20652
- const size = Math.min(width, height);
20653
- const rid = videoRids[idx];
20654
- const encoding = {
20655
- rid,
20656
- scaleResolutionDownBy: Math.max(1, size / Math.min(preset.width, preset.height)),
20657
- maxBitrate: preset.encoding.maxBitrate
20658
- };
20659
- if (preset.encoding.maxFramerate) {
20660
- encoding.maxFramerate = preset.encoding.maxFramerate;
20661
- }
20662
- if (preset.encoding.priority) {
20663
- encoding.priority = preset.encoding.priority;
20664
- encoding.networkPriority = preset.encoding.priority;
20665
- }
20666
- encodings.push(encoding);
20667
- });
20668
- return encodings;
20669
- }
20670
- /** @internal */
20671
- function sortPresets(presets) {
20672
- if (!presets) return;
20673
- return presets.sort((a, b) => {
20674
- const {
20675
- encoding: aEnc
20676
- } = a;
20677
- const {
20678
- encoding: bEnc
20679
- } = b;
20680
- if (aEnc.maxBitrate > bEnc.maxBitrate) {
20681
- return 1;
20682
- }
20683
- if (aEnc.maxBitrate < bEnc.maxBitrate) return -1;
20684
- if (aEnc.maxBitrate === bEnc.maxBitrate && aEnc.maxFramerate && bEnc.maxFramerate) {
20685
- return aEnc.maxFramerate > bEnc.maxFramerate ? 1 : -1;
21082
+ /** @internal */
21083
+ emit(event) {
21084
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
21085
+ args[_key - 1] = arguments[_key];
20686
21086
  }
20687
- return 0;
20688
- });
21087
+ livekitLogger.trace('participant event', {
21088
+ participant: this.sid,
21089
+ event,
21090
+ args
21091
+ });
21092
+ return super.emit(event, ...args);
21093
+ }
20689
21094
  }
20690
21095
 
20691
21096
  class LocalParticipant extends Participant {
@@ -20763,17 +21168,13 @@ class LocalParticipant extends Participant {
20763
21168
  }
20764
21169
  const newCodecs = yield pub.videoTrack.setPublishingCodecs(update.subscribedCodecs);
20765
21170
  try {
20766
- for (var _f = true, newCodecs_1 = __asyncValues(newCodecs), newCodecs_1_1; newCodecs_1_1 = yield newCodecs_1.next(), _a = newCodecs_1_1.done, !_a;) {
21171
+ for (var _f = true, newCodecs_1 = __asyncValues(newCodecs), newCodecs_1_1; newCodecs_1_1 = yield newCodecs_1.next(), _a = newCodecs_1_1.done, !_a; _f = true) {
20767
21172
  _c = newCodecs_1_1.value;
20768
21173
  _f = false;
20769
- try {
20770
- const codec = _c;
20771
- if (isBackupCodec(codec)) {
20772
- livekitLogger.debug("publish ".concat(codec, " for ").concat(pub.videoTrack.sid));
20773
- yield this.publishAdditionalCodecForTrack(pub.videoTrack, codec, pub.options);
20774
- }
20775
- } finally {
20776
- _f = true;
21174
+ const codec = _c;
21175
+ if (isBackupCodec(codec)) {
21176
+ livekitLogger.debug("publish ".concat(codec, " for ").concat(pub.videoTrack.sid));
21177
+ yield this.publishAdditionalCodecForTrack(pub.videoTrack, codec, pub.options);
20777
21178
  }
20778
21179
  }
20779
21180
  } catch (e_1_1) {
@@ -21221,7 +21622,7 @@ class LocalParticipant extends Participant {
21221
21622
  });
21222
21623
  }
21223
21624
  publish(track, opts, options, isStereo) {
21224
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
21625
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
21225
21626
  return __awaiter(this, void 0, void 0, function* () {
21226
21627
  const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => track instanceof LocalTrack && publishedTrack.source === track.source);
21227
21628
  if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
@@ -21298,8 +21699,8 @@ class LocalParticipant extends Participant {
21298
21699
  // for svc codecs, disable simulcast and use vp8 for backup codec
21299
21700
  if (track instanceof LocalVideoTrack) {
21300
21701
  if (isSVCCodec(opts.videoCodec)) {
21301
- // set scalabilityMode to 'L3T3' by default
21302
- opts.scalabilityMode = (_e = opts.scalabilityMode) !== null && _e !== void 0 ? _e : 'L3T3';
21702
+ // set scalabilityMode to 'L3T3_KEY' by default
21703
+ opts.scalabilityMode = (_e = opts.scalabilityMode) !== null && _e !== void 0 ? _e : 'L3T3_KEY';
21303
21704
  }
21304
21705
  // set up backup
21305
21706
  if (opts.videoCodec && opts.backupCodec && opts.videoCodec !== opts.backupCodec.codec) {
@@ -21315,15 +21716,23 @@ class LocalParticipant extends Participant {
21315
21716
  cid: '',
21316
21717
  enableSimulcastLayers: true
21317
21718
  }];
21719
+ } else if (opts.videoCodec) {
21720
+ // pass codec info to sfu so it can prefer codec for the client which don't support
21721
+ // setCodecPreferences
21722
+ req.simulcastCodecs = [{
21723
+ codec: opts.videoCodec,
21724
+ cid: track.mediaStreamTrack.id,
21725
+ enableSimulcastLayers: (_f = opts.simulcast) !== null && _f !== void 0 ? _f : false
21726
+ }];
21318
21727
  }
21319
21728
  }
21320
21729
  encodings = computeVideoEncodings(track.source === Track.Source.ScreenShare, dims.width, dims.height, opts);
21321
- req.layers = videoLayersFromEncodings(req.width, req.height, simEncodings !== null && simEncodings !== void 0 ? simEncodings : encodings);
21730
+ req.layers = videoLayersFromEncodings(req.width, req.height, encodings);
21322
21731
  } else if (track.kind === Track.Kind.Audio) {
21323
21732
  encodings = [{
21324
- maxBitrate: (_g = (_f = opts.audioPreset) === null || _f === void 0 ? void 0 : _f.maxBitrate) !== null && _g !== void 0 ? _g : opts.audioBitrate,
21325
- priority: (_j = (_h = opts.audioPreset) === null || _h === void 0 ? void 0 : _h.priority) !== null && _j !== void 0 ? _j : 'high',
21326
- networkPriority: (_l = (_k = opts.audioPreset) === null || _k === void 0 ? void 0 : _k.priority) !== null && _l !== void 0 ? _l : 'high'
21733
+ maxBitrate: (_h = (_g = opts.audioPreset) === null || _g === void 0 ? void 0 : _g.maxBitrate) !== null && _h !== void 0 ? _h : opts.audioBitrate,
21734
+ priority: (_k = (_j = opts.audioPreset) === null || _j === void 0 ? void 0 : _j.priority) !== null && _k !== void 0 ? _k : 'high',
21735
+ networkPriority: (_m = (_l = opts.audioPreset) === null || _l === void 0 ? void 0 : _l.priority) !== null && _m !== void 0 ? _m : 'high'
21327
21736
  }];
21328
21737
  }
21329
21738
  if (!this.engine || this.engine.isClosed) {
@@ -21365,7 +21774,7 @@ class LocalParticipant extends Participant {
21365
21774
  });
21366
21775
  // store RTPSender
21367
21776
  track.sender = yield this.engine.createSender(track, opts, encodings);
21368
- if (track.codec && isSVCCodec(track.codec) && encodings && ((_m = encodings[0]) === null || _m === void 0 ? void 0 : _m.maxBitrate)) {
21777
+ if (track.codec && isSVCCodec(track.codec) && encodings && ((_o = encodings[0]) === null || _o === void 0 ? void 0 : _o.maxBitrate)) {
21369
21778
  this.engine.publisher.setTrackCodecBitrate(req.cid, track.codec, encodings[0].maxBitrate / 1000);
21370
21779
  }
21371
21780
  this.engine.negotiate();
@@ -21470,6 +21879,16 @@ class LocalParticipant extends Participant {
21470
21879
  track.sender = undefined;
21471
21880
  if (this.engine.publisher && this.engine.publisher.pc.connectionState !== 'closed' && trackSender) {
21472
21881
  try {
21882
+ for (const transceiver of this.engine.publisher.pc.getTransceivers()) {
21883
+ // if sender is not currently sending (after replaceTrack(null))
21884
+ // removeTrack would have no effect.
21885
+ // to ensure we end up successfully removing the track, manually set
21886
+ // the transceiver to inactive
21887
+ if (transceiver.sender === trackSender) {
21888
+ transceiver.direction = 'inactive';
21889
+ negotiationNeeded = true;
21890
+ }
21891
+ }
21473
21892
  if (this.engine.removeTrack(trackSender)) {
21474
21893
  negotiationNeeded = true;
21475
21894
  }
@@ -22079,6 +22498,17 @@ class Room extends eventsExports.EventEmitter {
22079
22498
  }
22080
22499
  pub.setAllowed(update.allowed);
22081
22500
  };
22501
+ this.handleSubscriptionError = update => {
22502
+ const participant = Array.from(this.participants.values()).find(p => p.tracks.has(update.trackSid));
22503
+ if (!participant) {
22504
+ return;
22505
+ }
22506
+ const pub = participant.getTrackPublication(update.trackSid);
22507
+ if (!pub) {
22508
+ return;
22509
+ }
22510
+ pub.setSubscriptionError(update.err);
22511
+ };
22082
22512
  this.handleDataPacket = (userPacket, kind) => {
22083
22513
  // find the participant
22084
22514
  const participant = this.participants.get(userPacket.participantSid);
@@ -22212,6 +22642,7 @@ class Room extends eventsExports.EventEmitter {
22212
22642
  this.engine.client.onStreamStateUpdate = this.handleStreamStateUpdate;
22213
22643
  this.engine.client.onSubscriptionPermissionUpdate = this.handleSubscriptionPermissionUpdate;
22214
22644
  this.engine.client.onConnectionQuality = this.handleConnectionQualityUpdate;
22645
+ this.engine.client.onSubscriptionError = this.handleSubscriptionError;
22215
22646
  this.engine.on(EngineEvent.MediaTrackAdded, (mediaTrack, stream, receiver) => {
22216
22647
  this.onTrackAdded(mediaTrack, stream, receiver);
22217
22648
  }).on(EngineEvent.Disconnected, reason => {
@@ -22676,6 +23107,8 @@ class Room extends eventsExports.EventEmitter {
22676
23107
  this.emitWhenConnected(RoomEvent.ParticipantPermissionsChanged, prevPermissions, participant);
22677
23108
  }).on(ParticipantEvent.TrackSubscriptionStatusChanged, (pub, status) => {
22678
23109
  this.emitWhenConnected(RoomEvent.TrackSubscriptionStatusChanged, pub, status, participant);
23110
+ }).on(ParticipantEvent.TrackSubscriptionFailed, (trackSid, error) => {
23111
+ this.emit(RoomEvent.TrackSubscriptionFailed, trackSid, participant, error);
22679
23112
  }).on(ParticipantEvent.TrackSubscriptionPermissionChanged, (pub, status) => {
22680
23113
  this.emitWhenConnected(RoomEvent.TrackSubscriptionPermissionChanged, pub, status, participant);
22681
23114
  });