@stinkycomputing/sesame-api-client 1.4.1-alpha.9 → 1.4.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -32,19 +32,21 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  CodecType: () => CodecType,
34
34
  CommandList: () => CommandList,
35
+ ConnectionState: () => ConnectionState,
35
36
  EaseKind: () => EaseKind,
36
37
  Event: () => Event,
38
+ FrameHeader: () => FrameHeader,
39
+ FrameType: () => FrameType,
37
40
  JobsApi: () => JobsApi,
38
41
  Message: () => Message,
39
- PacketType: () => PacketType,
40
42
  RPCClient: () => RPCClient,
41
43
  RecorderApi: () => RecorderApi,
42
44
  Request: () => Request,
43
45
  Response: () => Response,
44
- SesameBinaryProtocol: () => SesameBinaryProtocol,
45
46
  SesameClient: () => SesameClient,
46
47
  SesameConnection: () => SesameConnection,
47
48
  StatusApi: () => StatusApi,
49
+ WireProtocol: () => WireProtocol,
48
50
  getLogger: () => getLogger,
49
51
  log: () => log,
50
52
  sesame: () => sesame,
@@ -13359,15 +13361,22 @@ var sesame = $root.sesame = (() => {
13359
13361
  }
13360
13362
  TransportEvent.prototype.sourceId = "";
13361
13363
  TransportEvent.prototype.userId = "";
13364
+ TransportEvent.prototype.uri = "";
13362
13365
  TransportEvent.prototype.state = 0;
13363
13366
  TransportEvent.prototype.durationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13364
13367
  TransportEvent.prototype.positionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13365
13368
  TransportEvent.prototype.materialPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13369
+ TransportEvent.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13370
+ TransportEvent.prototype.speed = 0;
13366
13371
  TransportEvent.prototype.userPlaylistId = "";
13367
13372
  TransportEvent.prototype.playlistIndex = 0;
13368
13373
  TransportEvent.prototype.playlistLength = 0;
13369
13374
  TransportEvent.prototype.clipId = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
13370
13375
  TransportEvent.prototype.clipPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13376
+ TransportEvent.prototype.clipDurationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13377
+ TransportEvent.prototype.preroll = 0;
13378
+ TransportEvent.prototype.postroll = 0;
13379
+ TransportEvent.prototype.metadata = "";
13371
13380
  TransportEvent.create = function create(properties) {
13372
13381
  return new TransportEvent(properties);
13373
13382
  };
@@ -13384,51 +13393,86 @@ var sesame = $root.sesame = (() => {
13384
13393
  /* id 2, wireType 2 =*/
13385
13394
  18
13386
13395
  ).string(message.userId);
13396
+ if (message.uri != null && Object.hasOwnProperty.call(message, "uri"))
13397
+ writer.uint32(
13398
+ /* id 3, wireType 2 =*/
13399
+ 26
13400
+ ).string(message.uri);
13387
13401
  if (message.state != null && Object.hasOwnProperty.call(message, "state"))
13388
13402
  writer.uint32(
13389
- /* id 3, wireType 0 =*/
13390
- 24
13403
+ /* id 4, wireType 0 =*/
13404
+ 32
13391
13405
  ).int32(message.state);
13392
13406
  if (message.durationUs != null && Object.hasOwnProperty.call(message, "durationUs"))
13393
13407
  writer.uint32(
13394
- /* id 4, wireType 0 =*/
13395
- 32
13408
+ /* id 5, wireType 0 =*/
13409
+ 40
13396
13410
  ).int64(message.durationUs);
13397
13411
  if (message.positionUs != null && Object.hasOwnProperty.call(message, "positionUs"))
13398
13412
  writer.uint32(
13399
- /* id 5, wireType 0 =*/
13400
- 40
13413
+ /* id 6, wireType 0 =*/
13414
+ 48
13401
13415
  ).int64(message.positionUs);
13402
13416
  if (message.materialPositionUs != null && Object.hasOwnProperty.call(message, "materialPositionUs"))
13403
13417
  writer.uint32(
13404
- /* id 6, wireType 0 =*/
13405
- 48
13418
+ /* id 7, wireType 0 =*/
13419
+ 56
13406
13420
  ).int64(message.materialPositionUs);
13421
+ if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
13422
+ writer.uint32(
13423
+ /* id 8, wireType 0 =*/
13424
+ 64
13425
+ ).int64(message.userTimeMs);
13426
+ if (message.speed != null && Object.hasOwnProperty.call(message, "speed"))
13427
+ writer.uint32(
13428
+ /* id 9, wireType 5 =*/
13429
+ 77
13430
+ ).float(message.speed);
13407
13431
  if (message.userPlaylistId != null && Object.hasOwnProperty.call(message, "userPlaylistId"))
13408
13432
  writer.uint32(
13409
- /* id 7, wireType 2 =*/
13410
- 58
13433
+ /* id 10, wireType 2 =*/
13434
+ 82
13411
13435
  ).string(message.userPlaylistId);
13412
13436
  if (message.playlistIndex != null && Object.hasOwnProperty.call(message, "playlistIndex"))
13413
13437
  writer.uint32(
13414
- /* id 8, wireType 0 =*/
13415
- 64
13438
+ /* id 11, wireType 0 =*/
13439
+ 88
13416
13440
  ).uint32(message.playlistIndex);
13417
13441
  if (message.playlistLength != null && Object.hasOwnProperty.call(message, "playlistLength"))
13418
13442
  writer.uint32(
13419
- /* id 9, wireType 0 =*/
13420
- 72
13443
+ /* id 12, wireType 0 =*/
13444
+ 96
13421
13445
  ).uint32(message.playlistLength);
13422
13446
  if (message.clipId != null && Object.hasOwnProperty.call(message, "clipId"))
13423
13447
  writer.uint32(
13424
- /* id 10, wireType 0 =*/
13425
- 80
13448
+ /* id 13, wireType 0 =*/
13449
+ 104
13426
13450
  ).uint64(message.clipId);
13427
13451
  if (message.clipPositionUs != null && Object.hasOwnProperty.call(message, "clipPositionUs"))
13428
13452
  writer.uint32(
13429
- /* id 11, wireType 0 =*/
13430
- 88
13453
+ /* id 14, wireType 0 =*/
13454
+ 112
13431
13455
  ).int64(message.clipPositionUs);
13456
+ if (message.clipDurationUs != null && Object.hasOwnProperty.call(message, "clipDurationUs"))
13457
+ writer.uint32(
13458
+ /* id 15, wireType 0 =*/
13459
+ 120
13460
+ ).int64(message.clipDurationUs);
13461
+ if (message.preroll != null && Object.hasOwnProperty.call(message, "preroll"))
13462
+ writer.uint32(
13463
+ /* id 16, wireType 0 =*/
13464
+ 128
13465
+ ).uint32(message.preroll);
13466
+ if (message.postroll != null && Object.hasOwnProperty.call(message, "postroll"))
13467
+ writer.uint32(
13468
+ /* id 17, wireType 0 =*/
13469
+ 136
13470
+ ).uint32(message.postroll);
13471
+ if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata"))
13472
+ writer.uint32(
13473
+ /* id 18, wireType 2 =*/
13474
+ 146
13475
+ ).string(message.metadata);
13432
13476
  return writer;
13433
13477
  };
13434
13478
  TransportEvent.encodeDelimited = function encodeDelimited(message, writer) {
@@ -13452,41 +13496,69 @@ var sesame = $root.sesame = (() => {
13452
13496
  break;
13453
13497
  }
13454
13498
  case 3: {
13455
- message.state = reader.int32();
13499
+ message.uri = reader.string();
13456
13500
  break;
13457
13501
  }
13458
13502
  case 4: {
13459
- message.durationUs = reader.int64();
13503
+ message.state = reader.int32();
13460
13504
  break;
13461
13505
  }
13462
13506
  case 5: {
13463
- message.positionUs = reader.int64();
13507
+ message.durationUs = reader.int64();
13464
13508
  break;
13465
13509
  }
13466
13510
  case 6: {
13467
- message.materialPositionUs = reader.int64();
13511
+ message.positionUs = reader.int64();
13468
13512
  break;
13469
13513
  }
13470
13514
  case 7: {
13471
- message.userPlaylistId = reader.string();
13515
+ message.materialPositionUs = reader.int64();
13472
13516
  break;
13473
13517
  }
13474
13518
  case 8: {
13475
- message.playlistIndex = reader.uint32();
13519
+ message.userTimeMs = reader.int64();
13476
13520
  break;
13477
13521
  }
13478
13522
  case 9: {
13479
- message.playlistLength = reader.uint32();
13523
+ message.speed = reader.float();
13480
13524
  break;
13481
13525
  }
13482
13526
  case 10: {
13483
- message.clipId = reader.uint64();
13527
+ message.userPlaylistId = reader.string();
13484
13528
  break;
13485
13529
  }
13486
13530
  case 11: {
13531
+ message.playlistIndex = reader.uint32();
13532
+ break;
13533
+ }
13534
+ case 12: {
13535
+ message.playlistLength = reader.uint32();
13536
+ break;
13537
+ }
13538
+ case 13: {
13539
+ message.clipId = reader.uint64();
13540
+ break;
13541
+ }
13542
+ case 14: {
13487
13543
  message.clipPositionUs = reader.int64();
13488
13544
  break;
13489
13545
  }
13546
+ case 15: {
13547
+ message.clipDurationUs = reader.int64();
13548
+ break;
13549
+ }
13550
+ case 16: {
13551
+ message.preroll = reader.uint32();
13552
+ break;
13553
+ }
13554
+ case 17: {
13555
+ message.postroll = reader.uint32();
13556
+ break;
13557
+ }
13558
+ case 18: {
13559
+ message.metadata = reader.string();
13560
+ break;
13561
+ }
13490
13562
  default:
13491
13563
  reader.skipType(tag & 7);
13492
13564
  break;
@@ -13510,6 +13582,10 @@ var sesame = $root.sesame = (() => {
13510
13582
  if (!$util.isString(message.userId))
13511
13583
  return "userId: string expected";
13512
13584
  }
13585
+ if (message.uri != null && message.hasOwnProperty("uri")) {
13586
+ if (!$util.isString(message.uri))
13587
+ return "uri: string expected";
13588
+ }
13513
13589
  if (message.state != null && message.hasOwnProperty("state"))
13514
13590
  switch (message.state) {
13515
13591
  default:
@@ -13533,6 +13609,14 @@ var sesame = $root.sesame = (() => {
13533
13609
  if (!$util.isInteger(message.materialPositionUs) && !(message.materialPositionUs && $util.isInteger(message.materialPositionUs.low) && $util.isInteger(message.materialPositionUs.high)))
13534
13610
  return "materialPositionUs: integer|Long expected";
13535
13611
  }
13612
+ if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
13613
+ if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
13614
+ return "userTimeMs: integer|Long expected";
13615
+ }
13616
+ if (message.speed != null && message.hasOwnProperty("speed")) {
13617
+ if (typeof message.speed !== "number")
13618
+ return "speed: number expected";
13619
+ }
13536
13620
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId")) {
13537
13621
  if (!$util.isString(message.userPlaylistId))
13538
13622
  return "userPlaylistId: string expected";
@@ -13553,6 +13637,22 @@ var sesame = $root.sesame = (() => {
13553
13637
  if (!$util.isInteger(message.clipPositionUs) && !(message.clipPositionUs && $util.isInteger(message.clipPositionUs.low) && $util.isInteger(message.clipPositionUs.high)))
13554
13638
  return "clipPositionUs: integer|Long expected";
13555
13639
  }
13640
+ if (message.clipDurationUs != null && message.hasOwnProperty("clipDurationUs")) {
13641
+ if (!$util.isInteger(message.clipDurationUs) && !(message.clipDurationUs && $util.isInteger(message.clipDurationUs.low) && $util.isInteger(message.clipDurationUs.high)))
13642
+ return "clipDurationUs: integer|Long expected";
13643
+ }
13644
+ if (message.preroll != null && message.hasOwnProperty("preroll")) {
13645
+ if (!$util.isInteger(message.preroll))
13646
+ return "preroll: integer expected";
13647
+ }
13648
+ if (message.postroll != null && message.hasOwnProperty("postroll")) {
13649
+ if (!$util.isInteger(message.postroll))
13650
+ return "postroll: integer expected";
13651
+ }
13652
+ if (message.metadata != null && message.hasOwnProperty("metadata")) {
13653
+ if (!$util.isString(message.metadata))
13654
+ return "metadata: string expected";
13655
+ }
13556
13656
  return null;
13557
13657
  };
13558
13658
  TransportEvent.fromObject = function fromObject(object) {
@@ -13563,6 +13663,8 @@ var sesame = $root.sesame = (() => {
13563
13663
  message.sourceId = String(object.sourceId);
13564
13664
  if (object.userId != null)
13565
13665
  message.userId = String(object.userId);
13666
+ if (object.uri != null)
13667
+ message.uri = String(object.uri);
13566
13668
  switch (object.state) {
13567
13669
  default:
13568
13670
  if (typeof object.state === "number") {
@@ -13621,6 +13723,18 @@ var sesame = $root.sesame = (() => {
13621
13723
  else if (typeof object.materialPositionUs === "object")
13622
13724
  message.materialPositionUs = new $util.LongBits(object.materialPositionUs.low >>> 0, object.materialPositionUs.high >>> 0).toNumber();
13623
13725
  }
13726
+ if (object.userTimeMs != null) {
13727
+ if ($util.Long)
13728
+ (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
13729
+ else if (typeof object.userTimeMs === "string")
13730
+ message.userTimeMs = parseInt(object.userTimeMs, 10);
13731
+ else if (typeof object.userTimeMs === "number")
13732
+ message.userTimeMs = object.userTimeMs;
13733
+ else if (typeof object.userTimeMs === "object")
13734
+ message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
13735
+ }
13736
+ if (object.speed != null)
13737
+ message.speed = Number(object.speed);
13624
13738
  if (object.userPlaylistId != null)
13625
13739
  message.userPlaylistId = String(object.userPlaylistId);
13626
13740
  if (object.playlistIndex != null)
@@ -13647,6 +13761,22 @@ var sesame = $root.sesame = (() => {
13647
13761
  else if (typeof object.clipPositionUs === "object")
13648
13762
  message.clipPositionUs = new $util.LongBits(object.clipPositionUs.low >>> 0, object.clipPositionUs.high >>> 0).toNumber();
13649
13763
  }
13764
+ if (object.clipDurationUs != null) {
13765
+ if ($util.Long)
13766
+ (message.clipDurationUs = $util.Long.fromValue(object.clipDurationUs)).unsigned = false;
13767
+ else if (typeof object.clipDurationUs === "string")
13768
+ message.clipDurationUs = parseInt(object.clipDurationUs, 10);
13769
+ else if (typeof object.clipDurationUs === "number")
13770
+ message.clipDurationUs = object.clipDurationUs;
13771
+ else if (typeof object.clipDurationUs === "object")
13772
+ message.clipDurationUs = new $util.LongBits(object.clipDurationUs.low >>> 0, object.clipDurationUs.high >>> 0).toNumber();
13773
+ }
13774
+ if (object.preroll != null)
13775
+ message.preroll = object.preroll >>> 0;
13776
+ if (object.postroll != null)
13777
+ message.postroll = object.postroll >>> 0;
13778
+ if (object.metadata != null)
13779
+ message.metadata = String(object.metadata);
13650
13780
  return message;
13651
13781
  };
13652
13782
  TransportEvent.toObject = function toObject(message, options) {
@@ -13656,6 +13786,7 @@ var sesame = $root.sesame = (() => {
13656
13786
  if (options.defaults) {
13657
13787
  object.sourceId = "";
13658
13788
  object.userId = "";
13789
+ object.uri = "";
13659
13790
  object.state = options.enums === String ? "SOURCE_TRANSPORT_STATE_STOPPED" : 0;
13660
13791
  if ($util.Long) {
13661
13792
  let long = new $util.Long(0, 0, false);
@@ -13672,6 +13803,12 @@ var sesame = $root.sesame = (() => {
13672
13803
  object.materialPositionUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13673
13804
  } else
13674
13805
  object.materialPositionUs = options.longs === String ? "0" : 0;
13806
+ if ($util.Long) {
13807
+ let long = new $util.Long(0, 0, false);
13808
+ object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13809
+ } else
13810
+ object.userTimeMs = options.longs === String ? "0" : 0;
13811
+ object.speed = 0;
13675
13812
  object.userPlaylistId = "";
13676
13813
  object.playlistIndex = 0;
13677
13814
  object.playlistLength = 0;
@@ -13685,11 +13822,21 @@ var sesame = $root.sesame = (() => {
13685
13822
  object.clipPositionUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13686
13823
  } else
13687
13824
  object.clipPositionUs = options.longs === String ? "0" : 0;
13825
+ if ($util.Long) {
13826
+ let long = new $util.Long(0, 0, false);
13827
+ object.clipDurationUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13828
+ } else
13829
+ object.clipDurationUs = options.longs === String ? "0" : 0;
13830
+ object.preroll = 0;
13831
+ object.postroll = 0;
13832
+ object.metadata = "";
13688
13833
  }
13689
13834
  if (message.sourceId != null && message.hasOwnProperty("sourceId"))
13690
13835
  object.sourceId = message.sourceId;
13691
13836
  if (message.userId != null && message.hasOwnProperty("userId"))
13692
13837
  object.userId = message.userId;
13838
+ if (message.uri != null && message.hasOwnProperty("uri"))
13839
+ object.uri = message.uri;
13693
13840
  if (message.state != null && message.hasOwnProperty("state"))
13694
13841
  object.state = options.enums === String ? $root.sesame.v1.sources.SourceTransportState[message.state] === void 0 ? message.state : $root.sesame.v1.sources.SourceTransportState[message.state] : message.state;
13695
13842
  if (message.durationUs != null && message.hasOwnProperty("durationUs"))
@@ -13707,6 +13854,13 @@ var sesame = $root.sesame = (() => {
13707
13854
  object.materialPositionUs = options.longs === String ? String(message.materialPositionUs) : message.materialPositionUs;
13708
13855
  else
13709
13856
  object.materialPositionUs = options.longs === String ? $util.Long.prototype.toString.call(message.materialPositionUs) : options.longs === Number ? new $util.LongBits(message.materialPositionUs.low >>> 0, message.materialPositionUs.high >>> 0).toNumber() : message.materialPositionUs;
13857
+ if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
13858
+ if (typeof message.userTimeMs === "number")
13859
+ object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
13860
+ else
13861
+ object.userTimeMs = options.longs === String ? $util.Long.prototype.toString.call(message.userTimeMs) : options.longs === Number ? new $util.LongBits(message.userTimeMs.low >>> 0, message.userTimeMs.high >>> 0).toNumber() : message.userTimeMs;
13862
+ if (message.speed != null && message.hasOwnProperty("speed"))
13863
+ object.speed = options.json && !isFinite(message.speed) ? String(message.speed) : message.speed;
13710
13864
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId"))
13711
13865
  object.userPlaylistId = message.userPlaylistId;
13712
13866
  if (message.playlistIndex != null && message.hasOwnProperty("playlistIndex"))
@@ -13723,6 +13877,17 @@ var sesame = $root.sesame = (() => {
13723
13877
  object.clipPositionUs = options.longs === String ? String(message.clipPositionUs) : message.clipPositionUs;
13724
13878
  else
13725
13879
  object.clipPositionUs = options.longs === String ? $util.Long.prototype.toString.call(message.clipPositionUs) : options.longs === Number ? new $util.LongBits(message.clipPositionUs.low >>> 0, message.clipPositionUs.high >>> 0).toNumber() : message.clipPositionUs;
13880
+ if (message.clipDurationUs != null && message.hasOwnProperty("clipDurationUs"))
13881
+ if (typeof message.clipDurationUs === "number")
13882
+ object.clipDurationUs = options.longs === String ? String(message.clipDurationUs) : message.clipDurationUs;
13883
+ else
13884
+ object.clipDurationUs = options.longs === String ? $util.Long.prototype.toString.call(message.clipDurationUs) : options.longs === Number ? new $util.LongBits(message.clipDurationUs.low >>> 0, message.clipDurationUs.high >>> 0).toNumber() : message.clipDurationUs;
13885
+ if (message.preroll != null && message.hasOwnProperty("preroll"))
13886
+ object.preroll = message.preroll;
13887
+ if (message.postroll != null && message.hasOwnProperty("postroll"))
13888
+ object.postroll = message.postroll;
13889
+ if (message.metadata != null && message.hasOwnProperty("metadata"))
13890
+ object.metadata = message.metadata;
13726
13891
  return object;
13727
13892
  };
13728
13893
  TransportEvent.prototype.toJSON = function toJSON() {
@@ -21109,108 +21274,710 @@ var sesame = $root.sesame = (() => {
21109
21274
  }();
21110
21275
  return rpc;
21111
21276
  }();
21112
- return v1;
21113
- }();
21114
- return sesame2;
21115
- })();
21116
-
21117
- // src/command-list.ts
21118
- var CommandList = class {
21119
- constructor() {
21120
- this.cl = new sesame.v1.commands.CommandList();
21121
- this.cl.commandList = [];
21122
- }
21123
- add(item, timeOffsetMs, transaction) {
21124
- item.timeOffsetUs = (timeOffsetMs || 0) * 1e3;
21125
- if (transaction) {
21126
- item.transactionDeps = transaction?.dependencies || [];
21127
- item.transactionId = transaction.transactionId;
21128
- }
21129
- this.cl.commandList.push(item);
21130
- return item;
21131
- }
21132
- applyTransaction(transaction) {
21133
- this.cl.commandList.forEach((item) => {
21134
- if (transaction.transactionId !== void 0) {
21135
- item.transactionId = transaction.transactionId;
21136
- }
21137
- if (transaction.dependencies !== void 0) {
21138
- item.transactionDeps = item.transactionDeps ? item.transactionDeps.concat(transaction.dependencies) : transaction.dependencies;
21139
- }
21140
- });
21141
- }
21142
- getLength() {
21143
- return this.cl.commandList.length;
21144
- }
21145
- filterCreatedAndDestroyedSources() {
21146
- const created = /* @__PURE__ */ new Map();
21147
- const createdAndRemoved = [];
21148
- for (let i = 0; i < this.cl.commandList.length; i++) {
21149
- if (this.cl.commandList[i].addSource) {
21150
- created.set(this.cl.commandList[i].addSource.id, this.cl.commandList[i]);
21151
- } else if (this.cl.commandList[i].removeSource) {
21152
- const id = this.cl.commandList[i].removeSource.id;
21153
- if (created.has(id)) {
21154
- createdAndRemoved.push({ add: created.get(id), del: this.cl.commandList[i] });
21277
+ v1.wire = function() {
21278
+ const wire = {};
21279
+ wire.FrameType = function() {
21280
+ const valuesById = {}, values = Object.create(valuesById);
21281
+ values[valuesById[0] = "FRAME_TYPE_UNSPECIFIED"] = 0;
21282
+ values[valuesById[1] = "FRAME_TYPE_RPC"] = 1;
21283
+ values[valuesById[2] = "FRAME_TYPE_VIDEO"] = 2;
21284
+ values[valuesById[3] = "FRAME_TYPE_AUDIO"] = 3;
21285
+ values[valuesById[4] = "FRAME_TYPE_MUXED"] = 4;
21286
+ values[valuesById[5] = "FRAME_TYPE_DECODER_DATA"] = 5;
21287
+ values[valuesById[6] = "FRAME_TYPE_DATA"] = 6;
21288
+ return values;
21289
+ }();
21290
+ wire.CodecType = function() {
21291
+ const valuesById = {}, values = Object.create(valuesById);
21292
+ values[valuesById[0] = "CODEC_TYPE_UNSPECIFIED"] = 0;
21293
+ values[valuesById[1] = "CODEC_TYPE_VIDEO_VP8"] = 1;
21294
+ values[valuesById[2] = "CODEC_TYPE_VIDEO_VP9"] = 2;
21295
+ values[valuesById[3] = "CODEC_TYPE_VIDEO_AVC"] = 3;
21296
+ values[valuesById[4] = "CODEC_TYPE_VIDEO_HEVC"] = 4;
21297
+ values[valuesById[5] = "CODEC_TYPE_VIDEO_AV1"] = 5;
21298
+ values[valuesById[64] = "CODEC_TYPE_AUDIO_OPUS"] = 64;
21299
+ values[valuesById[65] = "CODEC_TYPE_AUDIO_AAC"] = 65;
21300
+ values[valuesById[66] = "CODEC_TYPE_AUDIO_PCM"] = 66;
21301
+ return values;
21302
+ }();
21303
+ wire.MediaCodecData = function() {
21304
+ function MediaCodecData2(properties) {
21305
+ if (properties) {
21306
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
21307
+ if (properties[keys[i]] != null)
21308
+ this[keys[i]] = properties[keys[i]];
21309
+ }
21155
21310
  }
21156
- }
21157
- }
21158
- createdAndRemoved.forEach((item) => {
21159
- this.cl.commandList.splice(this.cl.commandList.indexOf(item.add), 1);
21160
- this.cl.commandList.splice(this.cl.commandList.indexOf(item.del), 1);
21161
- });
21162
- }
21163
- getCommandListMsg() {
21164
- return this.cl;
21165
- }
21166
- callback(event, data, timeOffsetMs) {
21167
- let item = new sesame.v1.commands.CommandListItem();
21168
- item.callback = { event, data };
21169
- return this.add(item, timeOffsetMs);
21170
- }
21171
- compositorAdd(id, width, height, multisample, timeOffsetMs) {
21172
- let item = new sesame.v1.commands.CommandListItem();
21173
- item.addCompositor = { id, multisample, width, height };
21174
- return this.add(item, timeOffsetMs);
21175
- }
21176
- compositorRemove(id, timeOffsetMs) {
21177
- let item = new sesame.v1.commands.CommandListItem();
21178
- item.removeCompositor = { id };
21179
- return this.add(item, timeOffsetMs);
21180
- }
21181
- compositorClear(id, timeOffsetMs) {
21182
- let item = new sesame.v1.commands.CommandListItem();
21183
- item.clearCompositor = { id };
21184
- return this.add(item, timeOffsetMs);
21185
- }
21186
- sourceAdd(id, cfg, timeOffsetMs) {
21187
- let item = new sesame.v1.commands.CommandListItem();
21188
- item.addSource = { id, config: cfg };
21189
- return this.add(item, timeOffsetMs);
21190
- }
21191
- sourceRemove(id, timeOffsetMs) {
21192
- let item = new sesame.v1.commands.CommandListItem();
21193
- item.removeSource = { id };
21194
- return this.add(item, timeOffsetMs);
21195
- }
21196
- nodeAdd(id, cfg, timeOffsetMs) {
21197
- let item = new sesame.v1.commands.CommandListItem();
21198
- item.addNode = {
21199
- compositorId: cfg.compositorId,
21200
- nodeId: id,
21201
- parentAddress: cfg.parentAddress || "",
21202
- nodeType: cfg.nodeType
21203
- };
21204
- return this.add(item, timeOffsetMs);
21205
- }
21206
- nodeRemove(compositorId, address, timeOffsetMs) {
21207
- let item = new sesame.v1.commands.CommandListItem();
21208
- item.removeNode = { compositorId, address };
21209
- return this.add(item, timeOffsetMs);
21210
- }
21211
- propertySet(propertyDomain, addr, prop, val, timeOffsetMs) {
21212
- let item = new sesame.v1.commands.CommandListItem();
21213
- item.setProperty = {
21311
+ MediaCodecData2.prototype.codecType = 0;
21312
+ MediaCodecData2.prototype.sampleRate = 0;
21313
+ MediaCodecData2.prototype.timebaseNum = 0;
21314
+ MediaCodecData2.prototype.timebaseDen = 0;
21315
+ MediaCodecData2.prototype.codecProfile = 0;
21316
+ MediaCodecData2.prototype.codecLevel = 0;
21317
+ MediaCodecData2.prototype.width = 0;
21318
+ MediaCodecData2.prototype.height = 0;
21319
+ MediaCodecData2.prototype.channels = 0;
21320
+ MediaCodecData2.prototype.bitDepth = 0;
21321
+ MediaCodecData2.create = function create(properties) {
21322
+ return new MediaCodecData2(properties);
21323
+ };
21324
+ MediaCodecData2.encode = function encode(message, writer) {
21325
+ if (!writer)
21326
+ writer = $Writer.create();
21327
+ if (message.codecType != null && Object.hasOwnProperty.call(message, "codecType"))
21328
+ writer.uint32(
21329
+ /* id 1, wireType 0 =*/
21330
+ 8
21331
+ ).int32(message.codecType);
21332
+ if (message.sampleRate != null && Object.hasOwnProperty.call(message, "sampleRate"))
21333
+ writer.uint32(
21334
+ /* id 2, wireType 0 =*/
21335
+ 16
21336
+ ).uint32(message.sampleRate);
21337
+ if (message.timebaseNum != null && Object.hasOwnProperty.call(message, "timebaseNum"))
21338
+ writer.uint32(
21339
+ /* id 3, wireType 0 =*/
21340
+ 24
21341
+ ).uint32(message.timebaseNum);
21342
+ if (message.timebaseDen != null && Object.hasOwnProperty.call(message, "timebaseDen"))
21343
+ writer.uint32(
21344
+ /* id 4, wireType 0 =*/
21345
+ 32
21346
+ ).uint32(message.timebaseDen);
21347
+ if (message.codecProfile != null && Object.hasOwnProperty.call(message, "codecProfile"))
21348
+ writer.uint32(
21349
+ /* id 5, wireType 0 =*/
21350
+ 40
21351
+ ).uint32(message.codecProfile);
21352
+ if (message.codecLevel != null && Object.hasOwnProperty.call(message, "codecLevel"))
21353
+ writer.uint32(
21354
+ /* id 6, wireType 0 =*/
21355
+ 48
21356
+ ).uint32(message.codecLevel);
21357
+ if (message.width != null && Object.hasOwnProperty.call(message, "width"))
21358
+ writer.uint32(
21359
+ /* id 7, wireType 0 =*/
21360
+ 56
21361
+ ).uint32(message.width);
21362
+ if (message.height != null && Object.hasOwnProperty.call(message, "height"))
21363
+ writer.uint32(
21364
+ /* id 8, wireType 0 =*/
21365
+ 64
21366
+ ).uint32(message.height);
21367
+ if (message.channels != null && Object.hasOwnProperty.call(message, "channels"))
21368
+ writer.uint32(
21369
+ /* id 9, wireType 0 =*/
21370
+ 72
21371
+ ).uint32(message.channels);
21372
+ if (message.bitDepth != null && Object.hasOwnProperty.call(message, "bitDepth"))
21373
+ writer.uint32(
21374
+ /* id 10, wireType 0 =*/
21375
+ 80
21376
+ ).uint32(message.bitDepth);
21377
+ return writer;
21378
+ };
21379
+ MediaCodecData2.encodeDelimited = function encodeDelimited(message, writer) {
21380
+ return this.encode(message, writer).ldelim();
21381
+ };
21382
+ MediaCodecData2.decode = function decode(reader, length, error) {
21383
+ if (!(reader instanceof $Reader))
21384
+ reader = $Reader.create(reader);
21385
+ let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.sesame.v1.wire.MediaCodecData();
21386
+ while (reader.pos < end) {
21387
+ let tag = reader.uint32();
21388
+ if (tag === error)
21389
+ break;
21390
+ switch (tag >>> 3) {
21391
+ case 1: {
21392
+ message.codecType = reader.int32();
21393
+ break;
21394
+ }
21395
+ case 2: {
21396
+ message.sampleRate = reader.uint32();
21397
+ break;
21398
+ }
21399
+ case 3: {
21400
+ message.timebaseNum = reader.uint32();
21401
+ break;
21402
+ }
21403
+ case 4: {
21404
+ message.timebaseDen = reader.uint32();
21405
+ break;
21406
+ }
21407
+ case 5: {
21408
+ message.codecProfile = reader.uint32();
21409
+ break;
21410
+ }
21411
+ case 6: {
21412
+ message.codecLevel = reader.uint32();
21413
+ break;
21414
+ }
21415
+ case 7: {
21416
+ message.width = reader.uint32();
21417
+ break;
21418
+ }
21419
+ case 8: {
21420
+ message.height = reader.uint32();
21421
+ break;
21422
+ }
21423
+ case 9: {
21424
+ message.channels = reader.uint32();
21425
+ break;
21426
+ }
21427
+ case 10: {
21428
+ message.bitDepth = reader.uint32();
21429
+ break;
21430
+ }
21431
+ default:
21432
+ reader.skipType(tag & 7);
21433
+ break;
21434
+ }
21435
+ }
21436
+ return message;
21437
+ };
21438
+ MediaCodecData2.decodeDelimited = function decodeDelimited(reader) {
21439
+ if (!(reader instanceof $Reader))
21440
+ reader = new $Reader(reader);
21441
+ return this.decode(reader, reader.uint32());
21442
+ };
21443
+ MediaCodecData2.verify = function verify(message) {
21444
+ if (typeof message !== "object" || message === null)
21445
+ return "object expected";
21446
+ if (message.codecType != null && message.hasOwnProperty("codecType"))
21447
+ switch (message.codecType) {
21448
+ default:
21449
+ return "codecType: enum value expected";
21450
+ case 0:
21451
+ case 1:
21452
+ case 2:
21453
+ case 3:
21454
+ case 4:
21455
+ case 5:
21456
+ case 64:
21457
+ case 65:
21458
+ case 66:
21459
+ break;
21460
+ }
21461
+ if (message.sampleRate != null && message.hasOwnProperty("sampleRate")) {
21462
+ if (!$util.isInteger(message.sampleRate))
21463
+ return "sampleRate: integer expected";
21464
+ }
21465
+ if (message.timebaseNum != null && message.hasOwnProperty("timebaseNum")) {
21466
+ if (!$util.isInteger(message.timebaseNum))
21467
+ return "timebaseNum: integer expected";
21468
+ }
21469
+ if (message.timebaseDen != null && message.hasOwnProperty("timebaseDen")) {
21470
+ if (!$util.isInteger(message.timebaseDen))
21471
+ return "timebaseDen: integer expected";
21472
+ }
21473
+ if (message.codecProfile != null && message.hasOwnProperty("codecProfile")) {
21474
+ if (!$util.isInteger(message.codecProfile))
21475
+ return "codecProfile: integer expected";
21476
+ }
21477
+ if (message.codecLevel != null && message.hasOwnProperty("codecLevel")) {
21478
+ if (!$util.isInteger(message.codecLevel))
21479
+ return "codecLevel: integer expected";
21480
+ }
21481
+ if (message.width != null && message.hasOwnProperty("width")) {
21482
+ if (!$util.isInteger(message.width))
21483
+ return "width: integer expected";
21484
+ }
21485
+ if (message.height != null && message.hasOwnProperty("height")) {
21486
+ if (!$util.isInteger(message.height))
21487
+ return "height: integer expected";
21488
+ }
21489
+ if (message.channels != null && message.hasOwnProperty("channels")) {
21490
+ if (!$util.isInteger(message.channels))
21491
+ return "channels: integer expected";
21492
+ }
21493
+ if (message.bitDepth != null && message.hasOwnProperty("bitDepth")) {
21494
+ if (!$util.isInteger(message.bitDepth))
21495
+ return "bitDepth: integer expected";
21496
+ }
21497
+ return null;
21498
+ };
21499
+ MediaCodecData2.fromObject = function fromObject(object) {
21500
+ if (object instanceof $root.sesame.v1.wire.MediaCodecData)
21501
+ return object;
21502
+ let message = new $root.sesame.v1.wire.MediaCodecData();
21503
+ switch (object.codecType) {
21504
+ default:
21505
+ if (typeof object.codecType === "number") {
21506
+ message.codecType = object.codecType;
21507
+ break;
21508
+ }
21509
+ break;
21510
+ case "CODEC_TYPE_UNSPECIFIED":
21511
+ case 0:
21512
+ message.codecType = 0;
21513
+ break;
21514
+ case "CODEC_TYPE_VIDEO_VP8":
21515
+ case 1:
21516
+ message.codecType = 1;
21517
+ break;
21518
+ case "CODEC_TYPE_VIDEO_VP9":
21519
+ case 2:
21520
+ message.codecType = 2;
21521
+ break;
21522
+ case "CODEC_TYPE_VIDEO_AVC":
21523
+ case 3:
21524
+ message.codecType = 3;
21525
+ break;
21526
+ case "CODEC_TYPE_VIDEO_HEVC":
21527
+ case 4:
21528
+ message.codecType = 4;
21529
+ break;
21530
+ case "CODEC_TYPE_VIDEO_AV1":
21531
+ case 5:
21532
+ message.codecType = 5;
21533
+ break;
21534
+ case "CODEC_TYPE_AUDIO_OPUS":
21535
+ case 64:
21536
+ message.codecType = 64;
21537
+ break;
21538
+ case "CODEC_TYPE_AUDIO_AAC":
21539
+ case 65:
21540
+ message.codecType = 65;
21541
+ break;
21542
+ case "CODEC_TYPE_AUDIO_PCM":
21543
+ case 66:
21544
+ message.codecType = 66;
21545
+ break;
21546
+ }
21547
+ if (object.sampleRate != null)
21548
+ message.sampleRate = object.sampleRate >>> 0;
21549
+ if (object.timebaseNum != null)
21550
+ message.timebaseNum = object.timebaseNum >>> 0;
21551
+ if (object.timebaseDen != null)
21552
+ message.timebaseDen = object.timebaseDen >>> 0;
21553
+ if (object.codecProfile != null)
21554
+ message.codecProfile = object.codecProfile >>> 0;
21555
+ if (object.codecLevel != null)
21556
+ message.codecLevel = object.codecLevel >>> 0;
21557
+ if (object.width != null)
21558
+ message.width = object.width >>> 0;
21559
+ if (object.height != null)
21560
+ message.height = object.height >>> 0;
21561
+ if (object.channels != null)
21562
+ message.channels = object.channels >>> 0;
21563
+ if (object.bitDepth != null)
21564
+ message.bitDepth = object.bitDepth >>> 0;
21565
+ return message;
21566
+ };
21567
+ MediaCodecData2.toObject = function toObject(message, options) {
21568
+ if (!options)
21569
+ options = {};
21570
+ let object = {};
21571
+ if (options.defaults) {
21572
+ object.codecType = options.enums === String ? "CODEC_TYPE_UNSPECIFIED" : 0;
21573
+ object.sampleRate = 0;
21574
+ object.timebaseNum = 0;
21575
+ object.timebaseDen = 0;
21576
+ object.codecProfile = 0;
21577
+ object.codecLevel = 0;
21578
+ object.width = 0;
21579
+ object.height = 0;
21580
+ object.channels = 0;
21581
+ object.bitDepth = 0;
21582
+ }
21583
+ if (message.codecType != null && message.hasOwnProperty("codecType"))
21584
+ object.codecType = options.enums === String ? $root.sesame.v1.wire.CodecType[message.codecType] === void 0 ? message.codecType : $root.sesame.v1.wire.CodecType[message.codecType] : message.codecType;
21585
+ if (message.sampleRate != null && message.hasOwnProperty("sampleRate"))
21586
+ object.sampleRate = message.sampleRate;
21587
+ if (message.timebaseNum != null && message.hasOwnProperty("timebaseNum"))
21588
+ object.timebaseNum = message.timebaseNum;
21589
+ if (message.timebaseDen != null && message.hasOwnProperty("timebaseDen"))
21590
+ object.timebaseDen = message.timebaseDen;
21591
+ if (message.codecProfile != null && message.hasOwnProperty("codecProfile"))
21592
+ object.codecProfile = message.codecProfile;
21593
+ if (message.codecLevel != null && message.hasOwnProperty("codecLevel"))
21594
+ object.codecLevel = message.codecLevel;
21595
+ if (message.width != null && message.hasOwnProperty("width"))
21596
+ object.width = message.width;
21597
+ if (message.height != null && message.hasOwnProperty("height"))
21598
+ object.height = message.height;
21599
+ if (message.channels != null && message.hasOwnProperty("channels"))
21600
+ object.channels = message.channels;
21601
+ if (message.bitDepth != null && message.hasOwnProperty("bitDepth"))
21602
+ object.bitDepth = message.bitDepth;
21603
+ return object;
21604
+ };
21605
+ MediaCodecData2.prototype.toJSON = function toJSON() {
21606
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
21607
+ };
21608
+ MediaCodecData2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
21609
+ if (typeUrlPrefix === void 0) {
21610
+ typeUrlPrefix = "type.googleapis.com";
21611
+ }
21612
+ return typeUrlPrefix + "/sesame.v1.wire.MediaCodecData";
21613
+ };
21614
+ return MediaCodecData2;
21615
+ }();
21616
+ wire.FrameHeader = function() {
21617
+ function FrameHeader2(properties) {
21618
+ if (properties) {
21619
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
21620
+ if (properties[keys[i]] != null)
21621
+ this[keys[i]] = properties[keys[i]];
21622
+ }
21623
+ }
21624
+ FrameHeader2.prototype.type = 0;
21625
+ FrameHeader2.prototype.pts = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
21626
+ FrameHeader2.prototype.id = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
21627
+ FrameHeader2.prototype.keyframe = false;
21628
+ FrameHeader2.prototype.codecData = null;
21629
+ FrameHeader2.prototype.routingMetadata = "";
21630
+ FrameHeader2.create = function create(properties) {
21631
+ return new FrameHeader2(properties);
21632
+ };
21633
+ FrameHeader2.encode = function encode(message, writer) {
21634
+ if (!writer)
21635
+ writer = $Writer.create();
21636
+ if (message.type != null && Object.hasOwnProperty.call(message, "type"))
21637
+ writer.uint32(
21638
+ /* id 1, wireType 0 =*/
21639
+ 8
21640
+ ).int32(message.type);
21641
+ if (message.pts != null && Object.hasOwnProperty.call(message, "pts"))
21642
+ writer.uint32(
21643
+ /* id 2, wireType 0 =*/
21644
+ 16
21645
+ ).uint64(message.pts);
21646
+ if (message.id != null && Object.hasOwnProperty.call(message, "id"))
21647
+ writer.uint32(
21648
+ /* id 3, wireType 0 =*/
21649
+ 24
21650
+ ).uint64(message.id);
21651
+ if (message.keyframe != null && Object.hasOwnProperty.call(message, "keyframe"))
21652
+ writer.uint32(
21653
+ /* id 4, wireType 0 =*/
21654
+ 32
21655
+ ).bool(message.keyframe);
21656
+ if (message.codecData != null && Object.hasOwnProperty.call(message, "codecData"))
21657
+ $root.sesame.v1.wire.MediaCodecData.encode(message.codecData, writer.uint32(
21658
+ /* id 5, wireType 2 =*/
21659
+ 42
21660
+ ).fork()).ldelim();
21661
+ if (message.routingMetadata != null && Object.hasOwnProperty.call(message, "routingMetadata"))
21662
+ writer.uint32(
21663
+ /* id 6, wireType 2 =*/
21664
+ 50
21665
+ ).string(message.routingMetadata);
21666
+ return writer;
21667
+ };
21668
+ FrameHeader2.encodeDelimited = function encodeDelimited(message, writer) {
21669
+ return this.encode(message, writer).ldelim();
21670
+ };
21671
+ FrameHeader2.decode = function decode(reader, length, error) {
21672
+ if (!(reader instanceof $Reader))
21673
+ reader = $Reader.create(reader);
21674
+ let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.sesame.v1.wire.FrameHeader();
21675
+ while (reader.pos < end) {
21676
+ let tag = reader.uint32();
21677
+ if (tag === error)
21678
+ break;
21679
+ switch (tag >>> 3) {
21680
+ case 1: {
21681
+ message.type = reader.int32();
21682
+ break;
21683
+ }
21684
+ case 2: {
21685
+ message.pts = reader.uint64();
21686
+ break;
21687
+ }
21688
+ case 3: {
21689
+ message.id = reader.uint64();
21690
+ break;
21691
+ }
21692
+ case 4: {
21693
+ message.keyframe = reader.bool();
21694
+ break;
21695
+ }
21696
+ case 5: {
21697
+ message.codecData = $root.sesame.v1.wire.MediaCodecData.decode(reader, reader.uint32());
21698
+ break;
21699
+ }
21700
+ case 6: {
21701
+ message.routingMetadata = reader.string();
21702
+ break;
21703
+ }
21704
+ default:
21705
+ reader.skipType(tag & 7);
21706
+ break;
21707
+ }
21708
+ }
21709
+ return message;
21710
+ };
21711
+ FrameHeader2.decodeDelimited = function decodeDelimited(reader) {
21712
+ if (!(reader instanceof $Reader))
21713
+ reader = new $Reader(reader);
21714
+ return this.decode(reader, reader.uint32());
21715
+ };
21716
+ FrameHeader2.verify = function verify(message) {
21717
+ if (typeof message !== "object" || message === null)
21718
+ return "object expected";
21719
+ if (message.type != null && message.hasOwnProperty("type"))
21720
+ switch (message.type) {
21721
+ default:
21722
+ return "type: enum value expected";
21723
+ case 0:
21724
+ case 1:
21725
+ case 2:
21726
+ case 3:
21727
+ case 4:
21728
+ case 5:
21729
+ case 6:
21730
+ break;
21731
+ }
21732
+ if (message.pts != null && message.hasOwnProperty("pts")) {
21733
+ if (!$util.isInteger(message.pts) && !(message.pts && $util.isInteger(message.pts.low) && $util.isInteger(message.pts.high)))
21734
+ return "pts: integer|Long expected";
21735
+ }
21736
+ if (message.id != null && message.hasOwnProperty("id")) {
21737
+ if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high)))
21738
+ return "id: integer|Long expected";
21739
+ }
21740
+ if (message.keyframe != null && message.hasOwnProperty("keyframe")) {
21741
+ if (typeof message.keyframe !== "boolean")
21742
+ return "keyframe: boolean expected";
21743
+ }
21744
+ if (message.codecData != null && message.hasOwnProperty("codecData")) {
21745
+ let error = $root.sesame.v1.wire.MediaCodecData.verify(message.codecData);
21746
+ if (error)
21747
+ return "codecData." + error;
21748
+ }
21749
+ if (message.routingMetadata != null && message.hasOwnProperty("routingMetadata")) {
21750
+ if (!$util.isString(message.routingMetadata))
21751
+ return "routingMetadata: string expected";
21752
+ }
21753
+ return null;
21754
+ };
21755
+ FrameHeader2.fromObject = function fromObject(object) {
21756
+ if (object instanceof $root.sesame.v1.wire.FrameHeader)
21757
+ return object;
21758
+ let message = new $root.sesame.v1.wire.FrameHeader();
21759
+ switch (object.type) {
21760
+ default:
21761
+ if (typeof object.type === "number") {
21762
+ message.type = object.type;
21763
+ break;
21764
+ }
21765
+ break;
21766
+ case "FRAME_TYPE_UNSPECIFIED":
21767
+ case 0:
21768
+ message.type = 0;
21769
+ break;
21770
+ case "FRAME_TYPE_RPC":
21771
+ case 1:
21772
+ message.type = 1;
21773
+ break;
21774
+ case "FRAME_TYPE_VIDEO":
21775
+ case 2:
21776
+ message.type = 2;
21777
+ break;
21778
+ case "FRAME_TYPE_AUDIO":
21779
+ case 3:
21780
+ message.type = 3;
21781
+ break;
21782
+ case "FRAME_TYPE_MUXED":
21783
+ case 4:
21784
+ message.type = 4;
21785
+ break;
21786
+ case "FRAME_TYPE_DECODER_DATA":
21787
+ case 5:
21788
+ message.type = 5;
21789
+ break;
21790
+ case "FRAME_TYPE_DATA":
21791
+ case 6:
21792
+ message.type = 6;
21793
+ break;
21794
+ }
21795
+ if (object.pts != null) {
21796
+ if ($util.Long)
21797
+ (message.pts = $util.Long.fromValue(object.pts)).unsigned = true;
21798
+ else if (typeof object.pts === "string")
21799
+ message.pts = parseInt(object.pts, 10);
21800
+ else if (typeof object.pts === "number")
21801
+ message.pts = object.pts;
21802
+ else if (typeof object.pts === "object")
21803
+ message.pts = new $util.LongBits(object.pts.low >>> 0, object.pts.high >>> 0).toNumber(true);
21804
+ }
21805
+ if (object.id != null) {
21806
+ if ($util.Long)
21807
+ (message.id = $util.Long.fromValue(object.id)).unsigned = true;
21808
+ else if (typeof object.id === "string")
21809
+ message.id = parseInt(object.id, 10);
21810
+ else if (typeof object.id === "number")
21811
+ message.id = object.id;
21812
+ else if (typeof object.id === "object")
21813
+ message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber(true);
21814
+ }
21815
+ if (object.keyframe != null)
21816
+ message.keyframe = Boolean(object.keyframe);
21817
+ if (object.codecData != null) {
21818
+ if (typeof object.codecData !== "object")
21819
+ throw TypeError(".sesame.v1.wire.FrameHeader.codecData: object expected");
21820
+ message.codecData = $root.sesame.v1.wire.MediaCodecData.fromObject(object.codecData);
21821
+ }
21822
+ if (object.routingMetadata != null)
21823
+ message.routingMetadata = String(object.routingMetadata);
21824
+ return message;
21825
+ };
21826
+ FrameHeader2.toObject = function toObject(message, options) {
21827
+ if (!options)
21828
+ options = {};
21829
+ let object = {};
21830
+ if (options.defaults) {
21831
+ object.type = options.enums === String ? "FRAME_TYPE_UNSPECIFIED" : 0;
21832
+ if ($util.Long) {
21833
+ let long = new $util.Long(0, 0, true);
21834
+ object.pts = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
21835
+ } else
21836
+ object.pts = options.longs === String ? "0" : 0;
21837
+ if ($util.Long) {
21838
+ let long = new $util.Long(0, 0, true);
21839
+ object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
21840
+ } else
21841
+ object.id = options.longs === String ? "0" : 0;
21842
+ object.keyframe = false;
21843
+ object.codecData = null;
21844
+ object.routingMetadata = "";
21845
+ }
21846
+ if (message.type != null && message.hasOwnProperty("type"))
21847
+ object.type = options.enums === String ? $root.sesame.v1.wire.FrameType[message.type] === void 0 ? message.type : $root.sesame.v1.wire.FrameType[message.type] : message.type;
21848
+ if (message.pts != null && message.hasOwnProperty("pts"))
21849
+ if (typeof message.pts === "number")
21850
+ object.pts = options.longs === String ? String(message.pts) : message.pts;
21851
+ else
21852
+ object.pts = options.longs === String ? $util.Long.prototype.toString.call(message.pts) : options.longs === Number ? new $util.LongBits(message.pts.low >>> 0, message.pts.high >>> 0).toNumber(true) : message.pts;
21853
+ if (message.id != null && message.hasOwnProperty("id"))
21854
+ if (typeof message.id === "number")
21855
+ object.id = options.longs === String ? String(message.id) : message.id;
21856
+ else
21857
+ object.id = options.longs === String ? $util.Long.prototype.toString.call(message.id) : options.longs === Number ? new $util.LongBits(message.id.low >>> 0, message.id.high >>> 0).toNumber(true) : message.id;
21858
+ if (message.keyframe != null && message.hasOwnProperty("keyframe"))
21859
+ object.keyframe = message.keyframe;
21860
+ if (message.codecData != null && message.hasOwnProperty("codecData"))
21861
+ object.codecData = $root.sesame.v1.wire.MediaCodecData.toObject(message.codecData, options);
21862
+ if (message.routingMetadata != null && message.hasOwnProperty("routingMetadata"))
21863
+ object.routingMetadata = message.routingMetadata;
21864
+ return object;
21865
+ };
21866
+ FrameHeader2.prototype.toJSON = function toJSON() {
21867
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
21868
+ };
21869
+ FrameHeader2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
21870
+ if (typeUrlPrefix === void 0) {
21871
+ typeUrlPrefix = "type.googleapis.com";
21872
+ }
21873
+ return typeUrlPrefix + "/sesame.v1.wire.FrameHeader";
21874
+ };
21875
+ return FrameHeader2;
21876
+ }();
21877
+ return wire;
21878
+ }();
21879
+ return v1;
21880
+ }();
21881
+ return sesame2;
21882
+ })();
21883
+
21884
+ // src/command-list.ts
21885
+ var CommandList = class {
21886
+ constructor() {
21887
+ this.cl = new sesame.v1.commands.CommandList();
21888
+ this.cl.commandList = [];
21889
+ }
21890
+ add(item, timeOffsetMs, transaction) {
21891
+ item.timeOffsetUs = (timeOffsetMs || 0) * 1e3;
21892
+ if (transaction) {
21893
+ item.transactionDeps = transaction?.dependencies || [];
21894
+ item.transactionId = transaction.transactionId;
21895
+ }
21896
+ this.cl.commandList.push(item);
21897
+ return item;
21898
+ }
21899
+ applyTransaction(transaction) {
21900
+ this.cl.commandList.forEach((item) => {
21901
+ if (transaction.transactionId !== void 0) {
21902
+ item.transactionId = transaction.transactionId;
21903
+ }
21904
+ if (transaction.dependencies !== void 0) {
21905
+ item.transactionDeps = item.transactionDeps ? item.transactionDeps.concat(transaction.dependencies) : transaction.dependencies;
21906
+ }
21907
+ });
21908
+ }
21909
+ getLength() {
21910
+ return this.cl.commandList.length;
21911
+ }
21912
+ filterCreatedAndDestroyedSources() {
21913
+ const created = /* @__PURE__ */ new Map();
21914
+ const createdAndRemoved = [];
21915
+ for (let i = 0; i < this.cl.commandList.length; i++) {
21916
+ if (this.cl.commandList[i].addSource) {
21917
+ created.set(this.cl.commandList[i].addSource.id, this.cl.commandList[i]);
21918
+ } else if (this.cl.commandList[i].removeSource) {
21919
+ const id = this.cl.commandList[i].removeSource.id;
21920
+ if (created.has(id)) {
21921
+ createdAndRemoved.push({ add: created.get(id), del: this.cl.commandList[i] });
21922
+ }
21923
+ }
21924
+ }
21925
+ createdAndRemoved.forEach((item) => {
21926
+ this.cl.commandList.splice(this.cl.commandList.indexOf(item.add), 1);
21927
+ this.cl.commandList.splice(this.cl.commandList.indexOf(item.del), 1);
21928
+ });
21929
+ }
21930
+ getCommandListMsg() {
21931
+ return this.cl;
21932
+ }
21933
+ callback(event, data, timeOffsetMs) {
21934
+ let item = new sesame.v1.commands.CommandListItem();
21935
+ item.callback = { event, data };
21936
+ return this.add(item, timeOffsetMs);
21937
+ }
21938
+ compositorAdd(id, width, height, multisample, timeOffsetMs) {
21939
+ let item = new sesame.v1.commands.CommandListItem();
21940
+ item.addCompositor = { id, multisample, width, height };
21941
+ return this.add(item, timeOffsetMs);
21942
+ }
21943
+ compositorRemove(id, timeOffsetMs) {
21944
+ let item = new sesame.v1.commands.CommandListItem();
21945
+ item.removeCompositor = { id };
21946
+ return this.add(item, timeOffsetMs);
21947
+ }
21948
+ compositorClear(id, timeOffsetMs) {
21949
+ let item = new sesame.v1.commands.CommandListItem();
21950
+ item.clearCompositor = { id };
21951
+ return this.add(item, timeOffsetMs);
21952
+ }
21953
+ sourceAdd(id, cfg, timeOffsetMs) {
21954
+ let item = new sesame.v1.commands.CommandListItem();
21955
+ item.addSource = { id, config: cfg };
21956
+ return this.add(item, timeOffsetMs);
21957
+ }
21958
+ sourceRemove(id, timeOffsetMs) {
21959
+ let item = new sesame.v1.commands.CommandListItem();
21960
+ item.removeSource = { id };
21961
+ return this.add(item, timeOffsetMs);
21962
+ }
21963
+ nodeAdd(id, cfg, timeOffsetMs) {
21964
+ let item = new sesame.v1.commands.CommandListItem();
21965
+ item.addNode = {
21966
+ compositorId: cfg.compositorId,
21967
+ nodeId: id,
21968
+ parentAddress: cfg.parentAddress || "",
21969
+ nodeType: cfg.nodeType
21970
+ };
21971
+ return this.add(item, timeOffsetMs);
21972
+ }
21973
+ nodeRemove(compositorId, address, timeOffsetMs) {
21974
+ let item = new sesame.v1.commands.CommandListItem();
21975
+ item.removeNode = { compositorId, address };
21976
+ return this.add(item, timeOffsetMs);
21977
+ }
21978
+ propertySet(propertyDomain, addr, prop, val, timeOffsetMs) {
21979
+ let item = new sesame.v1.commands.CommandListItem();
21980
+ item.setProperty = {
21214
21981
  address: addr,
21215
21982
  property: prop,
21216
21983
  domain: propertyDomain,
@@ -21548,7 +22315,8 @@ var RPCClient = class extends import_events.EventEmitter {
21548
22315
  eventHandler(event) {
21549
22316
  const topic = event.topic ?? 0;
21550
22317
  if (topic === sesame.v1.common.EventTopic.EVENT_TOPIC_UNSPECIFIED) {
21551
- throw new Error(`Unknown event topic: ${event.topic}`);
22318
+ log.warn(`Ignoring event with unspecified topic: ${event.topic}`);
22319
+ return;
21552
22320
  }
21553
22321
  const type = this.eventTypes[topic];
21554
22322
  let payload;
@@ -21574,255 +22342,58 @@ var RPCClient = class extends import_events.EventEmitter {
21574
22342
  // src/sesame-connection.ts
21575
22343
  var import_events2 = require("events");
21576
22344
 
21577
- // src/sesame-binary-protocol.ts
21578
- var PROTOCOL_MAGIC = 1297302867;
21579
- var PROTOCOL_VERSION = 1;
21580
- var HEADER_DATA_SIZE = 32;
21581
- var HEADER_CODEC_DATA_SIZE = 24;
21582
- var HEADER_METADATA_SIZE = 64;
21583
- var FLAG_HAS_CODEC_DATA = 1 << 0;
21584
- var FLAG_HAS_METADATA = 1 << 1;
21585
- var FLAG_IS_KEYFRAME = 1 << 2;
21586
- var PacketType = /* @__PURE__ */ ((PacketType2) => {
21587
- PacketType2[PacketType2["VIDEO_FRAME"] = 1] = "VIDEO_FRAME";
21588
- PacketType2[PacketType2["AUDIO_FRAME"] = 2] = "AUDIO_FRAME";
21589
- PacketType2[PacketType2["RPC"] = 3] = "RPC";
21590
- PacketType2[PacketType2["MUXED_DATA"] = 4] = "MUXED_DATA";
21591
- PacketType2[PacketType2["DECODER_DATA"] = 5] = "DECODER_DATA";
21592
- return PacketType2;
21593
- })(PacketType || {});
21594
- var CodecType = /* @__PURE__ */ ((CodecType2) => {
21595
- CodecType2[CodecType2["VIDEO_VP8"] = 1] = "VIDEO_VP8";
21596
- CodecType2[CodecType2["VIDEO_VP9"] = 2] = "VIDEO_VP9";
21597
- CodecType2[CodecType2["VIDEO_AVC"] = 3] = "VIDEO_AVC";
21598
- CodecType2[CodecType2["VIDEO_HEVC"] = 4] = "VIDEO_HEVC";
21599
- CodecType2[CodecType2["VIDEO_AV1"] = 5] = "VIDEO_AV1";
21600
- CodecType2[CodecType2["AUDIO_OPUS"] = 64] = "AUDIO_OPUS";
21601
- CodecType2[CodecType2["AUDIO_AAC"] = 65] = "AUDIO_AAC";
21602
- CodecType2[CodecType2["AUDIO_PCM"] = 66] = "AUDIO_PCM";
21603
- return CodecType2;
21604
- })(CodecType || {});
21605
- var SesameBinaryProtocol = class {
22345
+ // src/sesame-wire-protocol.ts
22346
+ var FrameType = sesame.v1.wire.FrameType;
22347
+ var FrameHeader = sesame.v1.wire.FrameHeader;
22348
+ var MediaCodecData = sesame.v1.wire.MediaCodecData;
22349
+ var CodecType = sesame.v1.wire.CodecType;
22350
+ var PREFIX_SIZE = 4;
22351
+ var WireProtocol = class {
21606
22352
  /**
21607
- * Initialize a header data structure with proper defaults
22353
+ * Serialize a wire frame: 4-byte LE header_size + protobuf FrameHeader + payload.
21608
22354
  */
21609
- static initHeader(type, flags, pts, id) {
21610
- return {
21611
- magic: PROTOCOL_MAGIC,
21612
- version: PROTOCOL_VERSION,
21613
- header_size: this.calculateHeaderSize(flags),
21614
- type,
21615
- flags,
21616
- pts,
21617
- id,
21618
- reserved: 0
21619
- // Always zero reserved fields
21620
- };
21621
- }
21622
- /**
21623
- * Calculate the total header size based on flags
21624
- */
21625
- static calculateHeaderSize(flags) {
21626
- let size = HEADER_DATA_SIZE;
21627
- if (flags & FLAG_HAS_METADATA) {
21628
- size += HEADER_METADATA_SIZE;
21629
- }
21630
- if (flags & FLAG_HAS_CODEC_DATA) {
21631
- size += HEADER_CODEC_DATA_SIZE;
22355
+ static serialize(header, payload) {
22356
+ const headerBytes = sesame.v1.wire.FrameHeader.encode(header).finish();
22357
+ const headerSize = headerBytes.length;
22358
+ const payloadSize = payload ? payload.length : 0;
22359
+ const total = PREFIX_SIZE + headerSize + payloadSize;
22360
+ const buffer = new Uint8Array(total);
22361
+ const view = new DataView(buffer.buffer);
22362
+ view.setUint32(0, headerSize, true);
22363
+ buffer.set(headerBytes, PREFIX_SIZE);
22364
+ if (payload && payloadSize > 0) {
22365
+ buffer.set(payload, PREFIX_SIZE + headerSize);
21632
22366
  }
21633
- return size;
22367
+ return buffer;
21634
22368
  }
21635
22369
  /**
21636
- * Validate a header structure
22370
+ * Parse an incoming wire frame.
21637
22371
  */
21638
- static validateHeader(header, totalSize) {
21639
- if (header.magic !== PROTOCOL_MAGIC) {
21640
- return false;
22372
+ static parse(data) {
22373
+ const result = { valid: false, header: null, payload: null };
22374
+ if (!data || data.length < PREFIX_SIZE) return result;
22375
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
22376
+ const headerSize = view.getUint32(0, true);
22377
+ if (data.length < PREFIX_SIZE + headerSize) return result;
22378
+ try {
22379
+ const headerBytes = data.subarray(PREFIX_SIZE, PREFIX_SIZE + headerSize);
22380
+ result.header = sesame.v1.wire.FrameHeader.decode(headerBytes);
22381
+ result.payload = data.subarray(PREFIX_SIZE + headerSize);
22382
+ result.valid = true;
22383
+ } catch {
21641
22384
  }
21642
- if (header.version !== PROTOCOL_VERSION) {
21643
- return false;
21644
- }
21645
- const expectedHeaderSize = this.calculateHeaderSize(header.flags);
21646
- if (header.header_size !== expectedHeaderSize) {
21647
- return false;
21648
- }
21649
- if (totalSize < header.header_size) {
21650
- return false;
21651
- }
21652
- return true;
21653
- }
21654
- /**
21655
- * Serialize data into a Uint8Array buffer
21656
- */
21657
- static serialize(header, metadata = null, codecData = null, payload = null) {
21658
- const includeMetadata = metadata !== null && header.flags & FLAG_HAS_METADATA;
21659
- const includeCodec = codecData !== null && header.flags & FLAG_HAS_CODEC_DATA;
21660
- let totalSize = HEADER_DATA_SIZE;
21661
- if (includeMetadata) totalSize += HEADER_METADATA_SIZE;
21662
- if (includeCodec) totalSize += HEADER_CODEC_DATA_SIZE;
21663
- if (payload) totalSize += payload.length;
21664
- header.header_size = totalSize - (payload ? payload.length : 0);
21665
- const buffer = new ArrayBuffer(totalSize);
21666
- const view = new DataView(buffer);
21667
- let offset = 0;
21668
- view.setUint32(offset, header.magic, true);
21669
- offset += 4;
21670
- view.setUint32(offset, header.flags, true);
21671
- offset += 4;
21672
- view.setBigUint64(offset, header.pts, true);
21673
- offset += 8;
21674
- view.setBigUint64(offset, header.id, true);
21675
- offset += 8;
21676
- view.setUint16(offset, header.version, true);
21677
- offset += 2;
21678
- view.setUint16(offset, header.header_size, true);
21679
- offset += 2;
21680
- view.setUint16(offset, header.type, true);
21681
- offset += 2;
21682
- view.setUint16(offset, header.reserved, true);
21683
- offset += 2;
21684
- if (includeMetadata && metadata) {
21685
- const metadataBytes = this.stringToFixedBytes(metadata.metadata, 64);
21686
- new Uint8Array(buffer, offset, 64).set(metadataBytes);
21687
- offset += 64;
21688
- }
21689
- if (includeCodec && codecData) {
21690
- view.setUint32(offset, codecData.sample_rate, true);
21691
- offset += 4;
21692
- view.setUint32(offset, codecData.timebase_num, true);
21693
- offset += 4;
21694
- view.setUint32(offset, codecData.timebase_den, true);
21695
- offset += 4;
21696
- view.setUint16(offset, codecData.codec_profile, true);
21697
- offset += 2;
21698
- view.setUint16(offset, codecData.codec_level, true);
21699
- offset += 2;
21700
- view.setUint16(offset, codecData.width, true);
21701
- offset += 2;
21702
- view.setUint16(offset, codecData.height, true);
21703
- offset += 2;
21704
- view.setUint8(offset, codecData.codec_type);
21705
- offset += 1;
21706
- view.setUint8(offset, codecData.channels);
21707
- offset += 1;
21708
- view.setUint8(offset, codecData.bit_depth);
21709
- offset += 1;
21710
- view.setUint8(offset, codecData.reserved);
21711
- offset += 1;
21712
- }
21713
- if (payload && payload.length > 0) {
21714
- new Uint8Array(buffer, offset).set(payload);
21715
- }
21716
- return new Uint8Array(buffer);
21717
- }
21718
- /**
21719
- * Parse incoming binary data
21720
- */
21721
- static parseData(data) {
21722
- const result = {
21723
- valid: false,
21724
- header: null,
21725
- metadata: null,
21726
- codec_data: null,
21727
- payload: null,
21728
- payload_size: 0
21729
- };
21730
- if (!data || data.length < 36) {
21731
- return result;
21732
- }
21733
- const view = new DataView(data.buffer, data.byteOffset);
21734
- let offset = 0;
21735
- const header = {
21736
- magic: view.getUint32(offset, true),
21737
- flags: view.getUint32(offset + 4, true),
21738
- pts: view.getBigUint64(offset + 8, true),
21739
- id: view.getBigUint64(offset + 16, true),
21740
- version: view.getUint16(offset + 24, true),
21741
- header_size: view.getUint16(offset + 26, true),
21742
- type: view.getUint16(offset + 28, true),
21743
- reserved: view.getUint16(offset + 30, true)
21744
- };
21745
- offset += HEADER_DATA_SIZE;
21746
- if (!this.validateHeader(header, data.length)) {
21747
- return result;
21748
- }
21749
- result.header = header;
21750
- if (header.flags & FLAG_HAS_METADATA) {
21751
- if (data.length < offset + HEADER_METADATA_SIZE) {
21752
- return result;
21753
- }
21754
- const metadataBytes = data.slice(offset, offset + HEADER_METADATA_SIZE);
21755
- const metadataStr = this.fixedBytesToString(metadataBytes);
21756
- result.metadata = { metadata: metadataStr };
21757
- offset += HEADER_METADATA_SIZE;
21758
- }
21759
- if (header.flags & FLAG_HAS_CODEC_DATA) {
21760
- if (data.length < offset + HEADER_CODEC_DATA_SIZE) {
21761
- return result;
21762
- }
21763
- result.codec_data = {
21764
- sample_rate: view.getUint32(offset, true),
21765
- timebase_num: view.getUint32(offset + 4, true),
21766
- timebase_den: view.getUint32(offset + 8, true),
21767
- codec_profile: view.getUint16(offset + 12, true),
21768
- codec_level: view.getUint16(offset + 14, true),
21769
- width: view.getUint16(offset + 16, true),
21770
- height: view.getUint16(offset + 18, true),
21771
- codec_type: view.getUint8(offset + 20),
21772
- channels: view.getUint8(offset + 21),
21773
- bit_depth: view.getUint8(offset + 22),
21774
- reserved: view.getUint8(offset + 23)
21775
- };
21776
- offset += HEADER_CODEC_DATA_SIZE;
21777
- }
21778
- if (offset < data.length) {
21779
- result.payload = data.slice(offset);
21780
- result.payload_size = result.payload.length;
21781
- } else {
21782
- result.payload = new Uint8Array(0);
21783
- result.payload_size = 0;
21784
- }
21785
- result.valid = true;
21786
22385
  return result;
21787
22386
  }
21788
- /**
21789
- * Helper: Convert string to fixed-size byte array (null-terminated)
21790
- */
21791
- static stringToFixedBytes(str, size) {
21792
- const bytes = new Uint8Array(size);
21793
- let encoded;
21794
- if (typeof TextEncoder !== "undefined") {
21795
- const encoder = new TextEncoder();
21796
- encoded = encoder.encode(str);
21797
- } else {
21798
- encoded = new Uint8Array(Buffer.from(str, "utf8"));
21799
- }
21800
- const copyLen = Math.min(encoded.length, size - 1);
21801
- bytes.set(encoded.slice(0, copyLen));
21802
- bytes[copyLen] = 0;
21803
- return bytes;
21804
- }
21805
- /**
21806
- * Helper: Convert fixed-size byte array to string (null-terminated)
21807
- */
21808
- static fixedBytesToString(bytes) {
21809
- let len = bytes.length;
21810
- for (let i = 0; i < bytes.length; i++) {
21811
- if (bytes[i] === 0) {
21812
- len = i;
21813
- break;
21814
- }
21815
- }
21816
- if (typeof TextDecoder !== "undefined") {
21817
- const decoder = new TextDecoder();
21818
- return decoder.decode(bytes.slice(0, len));
21819
- } else {
21820
- return Buffer.from(bytes.slice(0, len)).toString("utf8");
21821
- }
21822
- }
21823
22387
  };
21824
22388
 
21825
22389
  // src/sesame-connection.ts
22390
+ var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
22391
+ ConnectionState2["Disconnected"] = "disconnected";
22392
+ ConnectionState2["Connecting"] = "connecting";
22393
+ ConnectionState2["Connected"] = "connected";
22394
+ ConnectionState2["Reconnecting"] = "reconnecting";
22395
+ return ConnectionState2;
22396
+ })(ConnectionState || {});
21826
22397
  function waitForEvent(emitter, eventName) {
21827
22398
  return new Promise((resolve) => {
21828
22399
  emitter.once(eventName, resolve);
@@ -21835,6 +22406,7 @@ var SesameConnection = class extends import_events2.EventEmitter {
21835
22406
  this.numRetries = 0;
21836
22407
  this.url = "";
21837
22408
  this.autoReconnect = true;
22409
+ this._state = "disconnected" /* Disconnected */;
21838
22410
  /* Bound listeners so we can removeEventListener later */
21839
22411
  this.boundMessageHandler = (event) => this.messageHandler(event);
21840
22412
  this.boundOpenHandler = () => this.openHandler();
@@ -21842,38 +22414,68 @@ var SesameConnection = class extends import_events2.EventEmitter {
21842
22414
  this.boundErrorHandler = (event) => this.errorHandler(event);
21843
22415
  this.openHandler = () => {
21844
22416
  this.numRetries = 0;
22417
+ this.setState("connected" /* Connected */);
21845
22418
  this.emit("open");
21846
22419
  };
21847
22420
  this.messageHandler = (event) => {
21848
22421
  if (event.data instanceof ArrayBuffer) {
21849
- const parsed = SesameBinaryProtocol.parseData(new Uint8Array(event.data));
21850
- if (!parsed.valid) this.emit("error", new Error("Invalid packet received"));
21851
- if (parsed.header?.type == 1 /* VIDEO_FRAME */) {
21852
- this.emit("video-packet", event.data);
21853
- } else if (parsed.header?.type == 2 /* AUDIO_FRAME */) {
21854
- this.emit("audio-packet", event.data);
21855
- } else if (parsed.header?.type == 3 /* RPC */) {
22422
+ const parsed = WireProtocol.parse(new Uint8Array(event.data));
22423
+ if (!parsed.valid) {
22424
+ this.emit("error", new Error("Invalid packet received"));
22425
+ return;
22426
+ }
22427
+ const frameType = parsed.header?.type;
22428
+ if (frameType === FrameType.FRAME_TYPE_RPC) {
21856
22429
  this.emit("rpc", parsed.payload);
22430
+ } else {
22431
+ this.emit("media-packet", parsed);
21857
22432
  }
21858
22433
  }
21859
22434
  };
21860
22435
  this.url = options.url;
21861
22436
  this.autoReconnect = options.autoReconnect;
21862
- if (options.autoConnect) this.connect().catch(() => log.debug("failed connect"));
22437
+ if (options.autoConnect) this.connect().catch(() => {
22438
+ });
22439
+ }
22440
+ get state() {
22441
+ return this._state;
22442
+ }
22443
+ setState(newState) {
22444
+ if (this._state === newState) return;
22445
+ const prev = this._state;
22446
+ this._state = newState;
22447
+ switch (newState) {
22448
+ case "connected" /* Connected */:
22449
+ log.info("Connected to Sesame");
22450
+ break;
22451
+ case "reconnecting" /* Reconnecting */:
22452
+ if (prev === "connected" /* Connected */) {
22453
+ log.warn("Lost connection to Sesame, will try reconnect..");
22454
+ } else {
22455
+ log.warn("Failed to connect to Sesame, will try reconnect..");
22456
+ }
22457
+ break;
22458
+ case "disconnected" /* Disconnected */:
22459
+ log.info("Disconnected from Sesame");
22460
+ break;
22461
+ }
22462
+ this.emit("state", newState, prev);
21863
22463
  }
21864
22464
  isConnected() {
21865
22465
  return this.socket !== void 0 && this.socket.readyState === WebSocket.OPEN;
21866
22466
  }
21867
22467
  async send(data) {
21868
22468
  if (!this.isConnected()) throw new Error("Not connected");
21869
- const header = SesameBinaryProtocol.initHeader(3 /* RPC */, 0, BigInt(0), BigInt(0));
21870
- const data_to_send = SesameBinaryProtocol.serialize(header, null, null, data);
21871
- if (!data_to_send) throw new Error("Failed to serialize data");
21872
- this.socket.send(data_to_send);
22469
+ const header = { type: sesame.v1.wire.FrameType.FRAME_TYPE_RPC };
22470
+ const frame = WireProtocol.serialize(header, data);
22471
+ this.socket.send(frame);
21873
22472
  return Promise.resolve();
21874
22473
  }
21875
22474
  async connect() {
21876
22475
  this.active = true;
22476
+ if (this._state === "disconnected" /* Disconnected */) {
22477
+ this.setState("connecting" /* Connecting */);
22478
+ }
21877
22479
  this.socket = new WebSocket(this.url);
21878
22480
  this.socket.addEventListener("message", this.boundMessageHandler);
21879
22481
  this.socket.addEventListener("open", this.boundOpenHandler);
@@ -21896,6 +22498,7 @@ var SesameConnection = class extends import_events2.EventEmitter {
21896
22498
  async disconnect() {
21897
22499
  this.active = false;
21898
22500
  if (!this.socket) {
22501
+ this.setState("disconnected" /* Disconnected */);
21899
22502
  return;
21900
22503
  }
21901
22504
  const sock = this.socket;
@@ -21913,7 +22516,8 @@ var SesameConnection = class extends import_events2.EventEmitter {
21913
22516
  }
21914
22517
  retryHandler() {
21915
22518
  if (this.active && this.autoReconnect) {
21916
- this.connect().catch((err) => log.error("Retry failed", err));
22519
+ this.connect().catch(() => {
22520
+ });
21917
22521
  }
21918
22522
  }
21919
22523
  closeHandler() {
@@ -21923,13 +22527,17 @@ var SesameConnection = class extends import_events2.EventEmitter {
21923
22527
  }
21924
22528
  this.socket = void 0;
21925
22529
  if (this.active) {
21926
- try {
22530
+ if (this.autoReconnect) {
22531
+ this.setState("reconnecting" /* Reconnecting */);
21927
22532
  setTimeout(() => {
21928
22533
  this.retryHandler();
21929
22534
  }, defaultBackoff(++this.numRetries));
21930
- } catch (err) {
21931
- log.error("Connection error", err);
22535
+ } else {
22536
+ this.active = false;
22537
+ this.setState("disconnected" /* Disconnected */);
21932
22538
  }
22539
+ } else {
22540
+ this.setState("disconnected" /* Disconnected */);
21933
22541
  }
21934
22542
  }
21935
22543
  errorHandler(error) {
@@ -21955,9 +22563,6 @@ var StatusApi = class {
21955
22563
  async getIODevices() {
21956
22564
  return this.rpc.service.requestIODeviceList(new sesame.v1.common.Empty());
21957
22565
  }
21958
- async requestKeyframe(outputId) {
21959
- await this.rpc.service.requestKeyframe({ id: outputId });
21960
- }
21961
22566
  };
21962
22567
 
21963
22568
  // src/recorder-api.ts
@@ -22106,10 +22711,7 @@ var SesameClient = class extends import_events3.EventEmitter {
22106
22711
  constructor(portOrUrl) {
22107
22712
  super();
22108
22713
  this.subscriptions = [];
22109
- this.errorIsLogged = false;
22110
- this.onVideoPacket = () => {
22111
- };
22112
- this.onAudioPacket = () => {
22714
+ this.onMediaPacket = () => {
22113
22715
  };
22114
22716
  this.onCallbackMessage = () => {
22115
22717
  };
@@ -22120,10 +22722,6 @@ var SesameClient = class extends import_events3.EventEmitter {
22120
22722
  autoReconnect: true
22121
22723
  });
22122
22724
  this.conn.on("error", () => {
22123
- if (!this.errorIsLogged) {
22124
- log.warn("Could not connect to Sesame Engine, will keep trying..");
22125
- this.errorIsLogged = true;
22126
- }
22127
22725
  });
22128
22726
  let events = {
22129
22727
  [sesame.v1.common.EventTopic.EVENT_TOPIC_ERROR]: sesame.v1.status.Event,
@@ -22148,18 +22746,18 @@ var SesameClient = class extends import_events3.EventEmitter {
22148
22746
  }
22149
22747
  });
22150
22748
  this.rpc.on("error", (err) => {
22151
- log.error(`RPC error: ${err.message}`);
22749
+ if (this.isConnected()) {
22750
+ log.error(`RPC error: ${err.message}`);
22751
+ }
22152
22752
  });
22153
22753
  this.conn.on("open", async () => {
22154
22754
  this.sendSubscriptions();
22155
- this.errorIsLogged = false;
22156
22755
  this.emit("connected");
22157
22756
  });
22158
22757
  this.conn.on("close", () => {
22159
22758
  this.emit("disconnected");
22160
22759
  });
22161
- this.conn.on("video-packet", (data) => this.onVideoPacket(this.videoSubscriptionId, data));
22162
- this.conn.on("audio-packet", (data) => this.onAudioPacket(this.videoSubscriptionId, data));
22760
+ this.conn.on("media-packet", (frame) => this.onMediaPacket(this.mediaSubscriptionId, frame));
22163
22761
  this.subscriptions = [];
22164
22762
  }
22165
22763
  isConnected() {
@@ -22169,14 +22767,14 @@ var SesameClient = class extends import_events3.EventEmitter {
22169
22767
  if (!this.isConnected()) return;
22170
22768
  const eventTopics = this.subscriptions.map((subscription) => subscription.topic);
22171
22769
  const channels = [];
22172
- if (this.videoSubscriptionId) channels.push(`video/${this.videoSubscriptionId}`);
22770
+ if (this.mediaSubscriptionId) channels.push(`media-stream/${this.mediaSubscriptionId}`);
22173
22771
  let subs = { eventTopics, channels };
22174
22772
  this.rpc.service.updateSubscriptions(subs).catch((err) => {
22175
22773
  log.error(`Failed to update subscriptions: ${err.message}`);
22176
22774
  });
22177
22775
  }
22178
- addVideoSubscription(id) {
22179
- this.videoSubscriptionId = id;
22776
+ addMediaSubscription(id) {
22777
+ this.mediaSubscriptionId = id;
22180
22778
  this.sendSubscriptions();
22181
22779
  }
22182
22780
  addSubscription(topic, callback) {
@@ -22195,6 +22793,9 @@ var SesameClient = class extends import_events3.EventEmitter {
22195
22793
  getService() {
22196
22794
  return this.rpc;
22197
22795
  }
22796
+ async requestKeyframe(outputId) {
22797
+ await this.rpc.service.requestKeyframe({ id: outputId });
22798
+ }
22198
22799
  async execute(cl) {
22199
22800
  cl.filterCreatedAndDestroyedSources();
22200
22801
  if (cl.getCommandListMsg().commandList.length > 0) {
@@ -22215,19 +22816,21 @@ var Event = sesame.v1.rpc.Event;
22215
22816
  0 && (module.exports = {
22216
22817
  CodecType,
22217
22818
  CommandList,
22819
+ ConnectionState,
22218
22820
  EaseKind,
22219
22821
  Event,
22822
+ FrameHeader,
22823
+ FrameType,
22220
22824
  JobsApi,
22221
22825
  Message,
22222
- PacketType,
22223
22826
  RPCClient,
22224
22827
  RecorderApi,
22225
22828
  Request,
22226
22829
  Response,
22227
- SesameBinaryProtocol,
22228
22830
  SesameClient,
22229
22831
  SesameConnection,
22230
22832
  StatusApi,
22833
+ WireProtocol,
22231
22834
  getLogger,
22232
22835
  log,
22233
22836
  sesame,