@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.mjs CHANGED
@@ -13304,15 +13304,22 @@ var sesame = $root.sesame = (() => {
13304
13304
  }
13305
13305
  TransportEvent.prototype.sourceId = "";
13306
13306
  TransportEvent.prototype.userId = "";
13307
+ TransportEvent.prototype.uri = "";
13307
13308
  TransportEvent.prototype.state = 0;
13308
13309
  TransportEvent.prototype.durationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13309
13310
  TransportEvent.prototype.positionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13310
13311
  TransportEvent.prototype.materialPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13312
+ TransportEvent.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13313
+ TransportEvent.prototype.speed = 0;
13311
13314
  TransportEvent.prototype.userPlaylistId = "";
13312
13315
  TransportEvent.prototype.playlistIndex = 0;
13313
13316
  TransportEvent.prototype.playlistLength = 0;
13314
13317
  TransportEvent.prototype.clipId = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
13315
13318
  TransportEvent.prototype.clipPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13319
+ TransportEvent.prototype.clipDurationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13320
+ TransportEvent.prototype.preroll = 0;
13321
+ TransportEvent.prototype.postroll = 0;
13322
+ TransportEvent.prototype.metadata = "";
13316
13323
  TransportEvent.create = function create(properties) {
13317
13324
  return new TransportEvent(properties);
13318
13325
  };
@@ -13329,51 +13336,86 @@ var sesame = $root.sesame = (() => {
13329
13336
  /* id 2, wireType 2 =*/
13330
13337
  18
13331
13338
  ).string(message.userId);
13339
+ if (message.uri != null && Object.hasOwnProperty.call(message, "uri"))
13340
+ writer.uint32(
13341
+ /* id 3, wireType 2 =*/
13342
+ 26
13343
+ ).string(message.uri);
13332
13344
  if (message.state != null && Object.hasOwnProperty.call(message, "state"))
13333
13345
  writer.uint32(
13334
- /* id 3, wireType 0 =*/
13335
- 24
13346
+ /* id 4, wireType 0 =*/
13347
+ 32
13336
13348
  ).int32(message.state);
13337
13349
  if (message.durationUs != null && Object.hasOwnProperty.call(message, "durationUs"))
13338
13350
  writer.uint32(
13339
- /* id 4, wireType 0 =*/
13340
- 32
13351
+ /* id 5, wireType 0 =*/
13352
+ 40
13341
13353
  ).int64(message.durationUs);
13342
13354
  if (message.positionUs != null && Object.hasOwnProperty.call(message, "positionUs"))
13343
13355
  writer.uint32(
13344
- /* id 5, wireType 0 =*/
13345
- 40
13356
+ /* id 6, wireType 0 =*/
13357
+ 48
13346
13358
  ).int64(message.positionUs);
13347
13359
  if (message.materialPositionUs != null && Object.hasOwnProperty.call(message, "materialPositionUs"))
13348
13360
  writer.uint32(
13349
- /* id 6, wireType 0 =*/
13350
- 48
13361
+ /* id 7, wireType 0 =*/
13362
+ 56
13351
13363
  ).int64(message.materialPositionUs);
13364
+ if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
13365
+ writer.uint32(
13366
+ /* id 8, wireType 0 =*/
13367
+ 64
13368
+ ).int64(message.userTimeMs);
13369
+ if (message.speed != null && Object.hasOwnProperty.call(message, "speed"))
13370
+ writer.uint32(
13371
+ /* id 9, wireType 5 =*/
13372
+ 77
13373
+ ).float(message.speed);
13352
13374
  if (message.userPlaylistId != null && Object.hasOwnProperty.call(message, "userPlaylistId"))
13353
13375
  writer.uint32(
13354
- /* id 7, wireType 2 =*/
13355
- 58
13376
+ /* id 10, wireType 2 =*/
13377
+ 82
13356
13378
  ).string(message.userPlaylistId);
13357
13379
  if (message.playlistIndex != null && Object.hasOwnProperty.call(message, "playlistIndex"))
13358
13380
  writer.uint32(
13359
- /* id 8, wireType 0 =*/
13360
- 64
13381
+ /* id 11, wireType 0 =*/
13382
+ 88
13361
13383
  ).uint32(message.playlistIndex);
13362
13384
  if (message.playlistLength != null && Object.hasOwnProperty.call(message, "playlistLength"))
13363
13385
  writer.uint32(
13364
- /* id 9, wireType 0 =*/
13365
- 72
13386
+ /* id 12, wireType 0 =*/
13387
+ 96
13366
13388
  ).uint32(message.playlistLength);
13367
13389
  if (message.clipId != null && Object.hasOwnProperty.call(message, "clipId"))
13368
13390
  writer.uint32(
13369
- /* id 10, wireType 0 =*/
13370
- 80
13391
+ /* id 13, wireType 0 =*/
13392
+ 104
13371
13393
  ).uint64(message.clipId);
13372
13394
  if (message.clipPositionUs != null && Object.hasOwnProperty.call(message, "clipPositionUs"))
13373
13395
  writer.uint32(
13374
- /* id 11, wireType 0 =*/
13375
- 88
13396
+ /* id 14, wireType 0 =*/
13397
+ 112
13376
13398
  ).int64(message.clipPositionUs);
13399
+ if (message.clipDurationUs != null && Object.hasOwnProperty.call(message, "clipDurationUs"))
13400
+ writer.uint32(
13401
+ /* id 15, wireType 0 =*/
13402
+ 120
13403
+ ).int64(message.clipDurationUs);
13404
+ if (message.preroll != null && Object.hasOwnProperty.call(message, "preroll"))
13405
+ writer.uint32(
13406
+ /* id 16, wireType 0 =*/
13407
+ 128
13408
+ ).uint32(message.preroll);
13409
+ if (message.postroll != null && Object.hasOwnProperty.call(message, "postroll"))
13410
+ writer.uint32(
13411
+ /* id 17, wireType 0 =*/
13412
+ 136
13413
+ ).uint32(message.postroll);
13414
+ if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata"))
13415
+ writer.uint32(
13416
+ /* id 18, wireType 2 =*/
13417
+ 146
13418
+ ).string(message.metadata);
13377
13419
  return writer;
13378
13420
  };
13379
13421
  TransportEvent.encodeDelimited = function encodeDelimited(message, writer) {
@@ -13397,41 +13439,69 @@ var sesame = $root.sesame = (() => {
13397
13439
  break;
13398
13440
  }
13399
13441
  case 3: {
13400
- message.state = reader.int32();
13442
+ message.uri = reader.string();
13401
13443
  break;
13402
13444
  }
13403
13445
  case 4: {
13404
- message.durationUs = reader.int64();
13446
+ message.state = reader.int32();
13405
13447
  break;
13406
13448
  }
13407
13449
  case 5: {
13408
- message.positionUs = reader.int64();
13450
+ message.durationUs = reader.int64();
13409
13451
  break;
13410
13452
  }
13411
13453
  case 6: {
13412
- message.materialPositionUs = reader.int64();
13454
+ message.positionUs = reader.int64();
13413
13455
  break;
13414
13456
  }
13415
13457
  case 7: {
13416
- message.userPlaylistId = reader.string();
13458
+ message.materialPositionUs = reader.int64();
13417
13459
  break;
13418
13460
  }
13419
13461
  case 8: {
13420
- message.playlistIndex = reader.uint32();
13462
+ message.userTimeMs = reader.int64();
13421
13463
  break;
13422
13464
  }
13423
13465
  case 9: {
13424
- message.playlistLength = reader.uint32();
13466
+ message.speed = reader.float();
13425
13467
  break;
13426
13468
  }
13427
13469
  case 10: {
13428
- message.clipId = reader.uint64();
13470
+ message.userPlaylistId = reader.string();
13429
13471
  break;
13430
13472
  }
13431
13473
  case 11: {
13474
+ message.playlistIndex = reader.uint32();
13475
+ break;
13476
+ }
13477
+ case 12: {
13478
+ message.playlistLength = reader.uint32();
13479
+ break;
13480
+ }
13481
+ case 13: {
13482
+ message.clipId = reader.uint64();
13483
+ break;
13484
+ }
13485
+ case 14: {
13432
13486
  message.clipPositionUs = reader.int64();
13433
13487
  break;
13434
13488
  }
13489
+ case 15: {
13490
+ message.clipDurationUs = reader.int64();
13491
+ break;
13492
+ }
13493
+ case 16: {
13494
+ message.preroll = reader.uint32();
13495
+ break;
13496
+ }
13497
+ case 17: {
13498
+ message.postroll = reader.uint32();
13499
+ break;
13500
+ }
13501
+ case 18: {
13502
+ message.metadata = reader.string();
13503
+ break;
13504
+ }
13435
13505
  default:
13436
13506
  reader.skipType(tag & 7);
13437
13507
  break;
@@ -13455,6 +13525,10 @@ var sesame = $root.sesame = (() => {
13455
13525
  if (!$util.isString(message.userId))
13456
13526
  return "userId: string expected";
13457
13527
  }
13528
+ if (message.uri != null && message.hasOwnProperty("uri")) {
13529
+ if (!$util.isString(message.uri))
13530
+ return "uri: string expected";
13531
+ }
13458
13532
  if (message.state != null && message.hasOwnProperty("state"))
13459
13533
  switch (message.state) {
13460
13534
  default:
@@ -13478,6 +13552,14 @@ var sesame = $root.sesame = (() => {
13478
13552
  if (!$util.isInteger(message.materialPositionUs) && !(message.materialPositionUs && $util.isInteger(message.materialPositionUs.low) && $util.isInteger(message.materialPositionUs.high)))
13479
13553
  return "materialPositionUs: integer|Long expected";
13480
13554
  }
13555
+ if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
13556
+ if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
13557
+ return "userTimeMs: integer|Long expected";
13558
+ }
13559
+ if (message.speed != null && message.hasOwnProperty("speed")) {
13560
+ if (typeof message.speed !== "number")
13561
+ return "speed: number expected";
13562
+ }
13481
13563
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId")) {
13482
13564
  if (!$util.isString(message.userPlaylistId))
13483
13565
  return "userPlaylistId: string expected";
@@ -13498,6 +13580,22 @@ var sesame = $root.sesame = (() => {
13498
13580
  if (!$util.isInteger(message.clipPositionUs) && !(message.clipPositionUs && $util.isInteger(message.clipPositionUs.low) && $util.isInteger(message.clipPositionUs.high)))
13499
13581
  return "clipPositionUs: integer|Long expected";
13500
13582
  }
13583
+ if (message.clipDurationUs != null && message.hasOwnProperty("clipDurationUs")) {
13584
+ if (!$util.isInteger(message.clipDurationUs) && !(message.clipDurationUs && $util.isInteger(message.clipDurationUs.low) && $util.isInteger(message.clipDurationUs.high)))
13585
+ return "clipDurationUs: integer|Long expected";
13586
+ }
13587
+ if (message.preroll != null && message.hasOwnProperty("preroll")) {
13588
+ if (!$util.isInteger(message.preroll))
13589
+ return "preroll: integer expected";
13590
+ }
13591
+ if (message.postroll != null && message.hasOwnProperty("postroll")) {
13592
+ if (!$util.isInteger(message.postroll))
13593
+ return "postroll: integer expected";
13594
+ }
13595
+ if (message.metadata != null && message.hasOwnProperty("metadata")) {
13596
+ if (!$util.isString(message.metadata))
13597
+ return "metadata: string expected";
13598
+ }
13501
13599
  return null;
13502
13600
  };
13503
13601
  TransportEvent.fromObject = function fromObject(object) {
@@ -13508,6 +13606,8 @@ var sesame = $root.sesame = (() => {
13508
13606
  message.sourceId = String(object.sourceId);
13509
13607
  if (object.userId != null)
13510
13608
  message.userId = String(object.userId);
13609
+ if (object.uri != null)
13610
+ message.uri = String(object.uri);
13511
13611
  switch (object.state) {
13512
13612
  default:
13513
13613
  if (typeof object.state === "number") {
@@ -13566,6 +13666,18 @@ var sesame = $root.sesame = (() => {
13566
13666
  else if (typeof object.materialPositionUs === "object")
13567
13667
  message.materialPositionUs = new $util.LongBits(object.materialPositionUs.low >>> 0, object.materialPositionUs.high >>> 0).toNumber();
13568
13668
  }
13669
+ if (object.userTimeMs != null) {
13670
+ if ($util.Long)
13671
+ (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
13672
+ else if (typeof object.userTimeMs === "string")
13673
+ message.userTimeMs = parseInt(object.userTimeMs, 10);
13674
+ else if (typeof object.userTimeMs === "number")
13675
+ message.userTimeMs = object.userTimeMs;
13676
+ else if (typeof object.userTimeMs === "object")
13677
+ message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
13678
+ }
13679
+ if (object.speed != null)
13680
+ message.speed = Number(object.speed);
13569
13681
  if (object.userPlaylistId != null)
13570
13682
  message.userPlaylistId = String(object.userPlaylistId);
13571
13683
  if (object.playlistIndex != null)
@@ -13592,6 +13704,22 @@ var sesame = $root.sesame = (() => {
13592
13704
  else if (typeof object.clipPositionUs === "object")
13593
13705
  message.clipPositionUs = new $util.LongBits(object.clipPositionUs.low >>> 0, object.clipPositionUs.high >>> 0).toNumber();
13594
13706
  }
13707
+ if (object.clipDurationUs != null) {
13708
+ if ($util.Long)
13709
+ (message.clipDurationUs = $util.Long.fromValue(object.clipDurationUs)).unsigned = false;
13710
+ else if (typeof object.clipDurationUs === "string")
13711
+ message.clipDurationUs = parseInt(object.clipDurationUs, 10);
13712
+ else if (typeof object.clipDurationUs === "number")
13713
+ message.clipDurationUs = object.clipDurationUs;
13714
+ else if (typeof object.clipDurationUs === "object")
13715
+ message.clipDurationUs = new $util.LongBits(object.clipDurationUs.low >>> 0, object.clipDurationUs.high >>> 0).toNumber();
13716
+ }
13717
+ if (object.preroll != null)
13718
+ message.preroll = object.preroll >>> 0;
13719
+ if (object.postroll != null)
13720
+ message.postroll = object.postroll >>> 0;
13721
+ if (object.metadata != null)
13722
+ message.metadata = String(object.metadata);
13595
13723
  return message;
13596
13724
  };
13597
13725
  TransportEvent.toObject = function toObject(message, options) {
@@ -13601,6 +13729,7 @@ var sesame = $root.sesame = (() => {
13601
13729
  if (options.defaults) {
13602
13730
  object.sourceId = "";
13603
13731
  object.userId = "";
13732
+ object.uri = "";
13604
13733
  object.state = options.enums === String ? "SOURCE_TRANSPORT_STATE_STOPPED" : 0;
13605
13734
  if ($util.Long) {
13606
13735
  let long = new $util.Long(0, 0, false);
@@ -13617,6 +13746,12 @@ var sesame = $root.sesame = (() => {
13617
13746
  object.materialPositionUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13618
13747
  } else
13619
13748
  object.materialPositionUs = options.longs === String ? "0" : 0;
13749
+ if ($util.Long) {
13750
+ let long = new $util.Long(0, 0, false);
13751
+ object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13752
+ } else
13753
+ object.userTimeMs = options.longs === String ? "0" : 0;
13754
+ object.speed = 0;
13620
13755
  object.userPlaylistId = "";
13621
13756
  object.playlistIndex = 0;
13622
13757
  object.playlistLength = 0;
@@ -13630,11 +13765,21 @@ var sesame = $root.sesame = (() => {
13630
13765
  object.clipPositionUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13631
13766
  } else
13632
13767
  object.clipPositionUs = options.longs === String ? "0" : 0;
13768
+ if ($util.Long) {
13769
+ let long = new $util.Long(0, 0, false);
13770
+ object.clipDurationUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
13771
+ } else
13772
+ object.clipDurationUs = options.longs === String ? "0" : 0;
13773
+ object.preroll = 0;
13774
+ object.postroll = 0;
13775
+ object.metadata = "";
13633
13776
  }
13634
13777
  if (message.sourceId != null && message.hasOwnProperty("sourceId"))
13635
13778
  object.sourceId = message.sourceId;
13636
13779
  if (message.userId != null && message.hasOwnProperty("userId"))
13637
13780
  object.userId = message.userId;
13781
+ if (message.uri != null && message.hasOwnProperty("uri"))
13782
+ object.uri = message.uri;
13638
13783
  if (message.state != null && message.hasOwnProperty("state"))
13639
13784
  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;
13640
13785
  if (message.durationUs != null && message.hasOwnProperty("durationUs"))
@@ -13652,6 +13797,13 @@ var sesame = $root.sesame = (() => {
13652
13797
  object.materialPositionUs = options.longs === String ? String(message.materialPositionUs) : message.materialPositionUs;
13653
13798
  else
13654
13799
  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;
13800
+ if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
13801
+ if (typeof message.userTimeMs === "number")
13802
+ object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
13803
+ else
13804
+ 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;
13805
+ if (message.speed != null && message.hasOwnProperty("speed"))
13806
+ object.speed = options.json && !isFinite(message.speed) ? String(message.speed) : message.speed;
13655
13807
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId"))
13656
13808
  object.userPlaylistId = message.userPlaylistId;
13657
13809
  if (message.playlistIndex != null && message.hasOwnProperty("playlistIndex"))
@@ -13668,6 +13820,17 @@ var sesame = $root.sesame = (() => {
13668
13820
  object.clipPositionUs = options.longs === String ? String(message.clipPositionUs) : message.clipPositionUs;
13669
13821
  else
13670
13822
  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;
13823
+ if (message.clipDurationUs != null && message.hasOwnProperty("clipDurationUs"))
13824
+ if (typeof message.clipDurationUs === "number")
13825
+ object.clipDurationUs = options.longs === String ? String(message.clipDurationUs) : message.clipDurationUs;
13826
+ else
13827
+ 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;
13828
+ if (message.preroll != null && message.hasOwnProperty("preroll"))
13829
+ object.preroll = message.preroll;
13830
+ if (message.postroll != null && message.hasOwnProperty("postroll"))
13831
+ object.postroll = message.postroll;
13832
+ if (message.metadata != null && message.hasOwnProperty("metadata"))
13833
+ object.metadata = message.metadata;
13671
13834
  return object;
13672
13835
  };
13673
13836
  TransportEvent.prototype.toJSON = function toJSON() {
@@ -21054,108 +21217,710 @@ var sesame = $root.sesame = (() => {
21054
21217
  }();
21055
21218
  return rpc;
21056
21219
  }();
21057
- return v1;
21058
- }();
21059
- return sesame2;
21060
- })();
21061
-
21062
- // src/command-list.ts
21063
- var CommandList = class {
21064
- constructor() {
21065
- this.cl = new sesame.v1.commands.CommandList();
21066
- this.cl.commandList = [];
21067
- }
21068
- add(item, timeOffsetMs, transaction) {
21069
- item.timeOffsetUs = (timeOffsetMs || 0) * 1e3;
21070
- if (transaction) {
21071
- item.transactionDeps = transaction?.dependencies || [];
21072
- item.transactionId = transaction.transactionId;
21073
- }
21074
- this.cl.commandList.push(item);
21075
- return item;
21076
- }
21077
- applyTransaction(transaction) {
21078
- this.cl.commandList.forEach((item) => {
21079
- if (transaction.transactionId !== void 0) {
21080
- item.transactionId = transaction.transactionId;
21081
- }
21082
- if (transaction.dependencies !== void 0) {
21083
- item.transactionDeps = item.transactionDeps ? item.transactionDeps.concat(transaction.dependencies) : transaction.dependencies;
21084
- }
21085
- });
21086
- }
21087
- getLength() {
21088
- return this.cl.commandList.length;
21089
- }
21090
- filterCreatedAndDestroyedSources() {
21091
- const created = /* @__PURE__ */ new Map();
21092
- const createdAndRemoved = [];
21093
- for (let i = 0; i < this.cl.commandList.length; i++) {
21094
- if (this.cl.commandList[i].addSource) {
21095
- created.set(this.cl.commandList[i].addSource.id, this.cl.commandList[i]);
21096
- } else if (this.cl.commandList[i].removeSource) {
21097
- const id = this.cl.commandList[i].removeSource.id;
21098
- if (created.has(id)) {
21099
- createdAndRemoved.push({ add: created.get(id), del: this.cl.commandList[i] });
21220
+ v1.wire = function() {
21221
+ const wire = {};
21222
+ wire.FrameType = function() {
21223
+ const valuesById = {}, values = Object.create(valuesById);
21224
+ values[valuesById[0] = "FRAME_TYPE_UNSPECIFIED"] = 0;
21225
+ values[valuesById[1] = "FRAME_TYPE_RPC"] = 1;
21226
+ values[valuesById[2] = "FRAME_TYPE_VIDEO"] = 2;
21227
+ values[valuesById[3] = "FRAME_TYPE_AUDIO"] = 3;
21228
+ values[valuesById[4] = "FRAME_TYPE_MUXED"] = 4;
21229
+ values[valuesById[5] = "FRAME_TYPE_DECODER_DATA"] = 5;
21230
+ values[valuesById[6] = "FRAME_TYPE_DATA"] = 6;
21231
+ return values;
21232
+ }();
21233
+ wire.CodecType = function() {
21234
+ const valuesById = {}, values = Object.create(valuesById);
21235
+ values[valuesById[0] = "CODEC_TYPE_UNSPECIFIED"] = 0;
21236
+ values[valuesById[1] = "CODEC_TYPE_VIDEO_VP8"] = 1;
21237
+ values[valuesById[2] = "CODEC_TYPE_VIDEO_VP9"] = 2;
21238
+ values[valuesById[3] = "CODEC_TYPE_VIDEO_AVC"] = 3;
21239
+ values[valuesById[4] = "CODEC_TYPE_VIDEO_HEVC"] = 4;
21240
+ values[valuesById[5] = "CODEC_TYPE_VIDEO_AV1"] = 5;
21241
+ values[valuesById[64] = "CODEC_TYPE_AUDIO_OPUS"] = 64;
21242
+ values[valuesById[65] = "CODEC_TYPE_AUDIO_AAC"] = 65;
21243
+ values[valuesById[66] = "CODEC_TYPE_AUDIO_PCM"] = 66;
21244
+ return values;
21245
+ }();
21246
+ wire.MediaCodecData = function() {
21247
+ function MediaCodecData2(properties) {
21248
+ if (properties) {
21249
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
21250
+ if (properties[keys[i]] != null)
21251
+ this[keys[i]] = properties[keys[i]];
21252
+ }
21100
21253
  }
21101
- }
21102
- }
21103
- createdAndRemoved.forEach((item) => {
21104
- this.cl.commandList.splice(this.cl.commandList.indexOf(item.add), 1);
21105
- this.cl.commandList.splice(this.cl.commandList.indexOf(item.del), 1);
21106
- });
21107
- }
21108
- getCommandListMsg() {
21109
- return this.cl;
21110
- }
21111
- callback(event, data, timeOffsetMs) {
21112
- let item = new sesame.v1.commands.CommandListItem();
21113
- item.callback = { event, data };
21114
- return this.add(item, timeOffsetMs);
21115
- }
21116
- compositorAdd(id, width, height, multisample, timeOffsetMs) {
21117
- let item = new sesame.v1.commands.CommandListItem();
21118
- item.addCompositor = { id, multisample, width, height };
21119
- return this.add(item, timeOffsetMs);
21120
- }
21121
- compositorRemove(id, timeOffsetMs) {
21122
- let item = new sesame.v1.commands.CommandListItem();
21123
- item.removeCompositor = { id };
21124
- return this.add(item, timeOffsetMs);
21125
- }
21126
- compositorClear(id, timeOffsetMs) {
21127
- let item = new sesame.v1.commands.CommandListItem();
21128
- item.clearCompositor = { id };
21129
- return this.add(item, timeOffsetMs);
21130
- }
21131
- sourceAdd(id, cfg, timeOffsetMs) {
21132
- let item = new sesame.v1.commands.CommandListItem();
21133
- item.addSource = { id, config: cfg };
21134
- return this.add(item, timeOffsetMs);
21135
- }
21136
- sourceRemove(id, timeOffsetMs) {
21137
- let item = new sesame.v1.commands.CommandListItem();
21138
- item.removeSource = { id };
21139
- return this.add(item, timeOffsetMs);
21140
- }
21141
- nodeAdd(id, cfg, timeOffsetMs) {
21142
- let item = new sesame.v1.commands.CommandListItem();
21143
- item.addNode = {
21144
- compositorId: cfg.compositorId,
21145
- nodeId: id,
21146
- parentAddress: cfg.parentAddress || "",
21147
- nodeType: cfg.nodeType
21148
- };
21149
- return this.add(item, timeOffsetMs);
21150
- }
21151
- nodeRemove(compositorId, address, timeOffsetMs) {
21152
- let item = new sesame.v1.commands.CommandListItem();
21153
- item.removeNode = { compositorId, address };
21154
- return this.add(item, timeOffsetMs);
21155
- }
21156
- propertySet(propertyDomain, addr, prop, val, timeOffsetMs) {
21157
- let item = new sesame.v1.commands.CommandListItem();
21158
- item.setProperty = {
21254
+ MediaCodecData2.prototype.codecType = 0;
21255
+ MediaCodecData2.prototype.sampleRate = 0;
21256
+ MediaCodecData2.prototype.timebaseNum = 0;
21257
+ MediaCodecData2.prototype.timebaseDen = 0;
21258
+ MediaCodecData2.prototype.codecProfile = 0;
21259
+ MediaCodecData2.prototype.codecLevel = 0;
21260
+ MediaCodecData2.prototype.width = 0;
21261
+ MediaCodecData2.prototype.height = 0;
21262
+ MediaCodecData2.prototype.channels = 0;
21263
+ MediaCodecData2.prototype.bitDepth = 0;
21264
+ MediaCodecData2.create = function create(properties) {
21265
+ return new MediaCodecData2(properties);
21266
+ };
21267
+ MediaCodecData2.encode = function encode(message, writer) {
21268
+ if (!writer)
21269
+ writer = $Writer.create();
21270
+ if (message.codecType != null && Object.hasOwnProperty.call(message, "codecType"))
21271
+ writer.uint32(
21272
+ /* id 1, wireType 0 =*/
21273
+ 8
21274
+ ).int32(message.codecType);
21275
+ if (message.sampleRate != null && Object.hasOwnProperty.call(message, "sampleRate"))
21276
+ writer.uint32(
21277
+ /* id 2, wireType 0 =*/
21278
+ 16
21279
+ ).uint32(message.sampleRate);
21280
+ if (message.timebaseNum != null && Object.hasOwnProperty.call(message, "timebaseNum"))
21281
+ writer.uint32(
21282
+ /* id 3, wireType 0 =*/
21283
+ 24
21284
+ ).uint32(message.timebaseNum);
21285
+ if (message.timebaseDen != null && Object.hasOwnProperty.call(message, "timebaseDen"))
21286
+ writer.uint32(
21287
+ /* id 4, wireType 0 =*/
21288
+ 32
21289
+ ).uint32(message.timebaseDen);
21290
+ if (message.codecProfile != null && Object.hasOwnProperty.call(message, "codecProfile"))
21291
+ writer.uint32(
21292
+ /* id 5, wireType 0 =*/
21293
+ 40
21294
+ ).uint32(message.codecProfile);
21295
+ if (message.codecLevel != null && Object.hasOwnProperty.call(message, "codecLevel"))
21296
+ writer.uint32(
21297
+ /* id 6, wireType 0 =*/
21298
+ 48
21299
+ ).uint32(message.codecLevel);
21300
+ if (message.width != null && Object.hasOwnProperty.call(message, "width"))
21301
+ writer.uint32(
21302
+ /* id 7, wireType 0 =*/
21303
+ 56
21304
+ ).uint32(message.width);
21305
+ if (message.height != null && Object.hasOwnProperty.call(message, "height"))
21306
+ writer.uint32(
21307
+ /* id 8, wireType 0 =*/
21308
+ 64
21309
+ ).uint32(message.height);
21310
+ if (message.channels != null && Object.hasOwnProperty.call(message, "channels"))
21311
+ writer.uint32(
21312
+ /* id 9, wireType 0 =*/
21313
+ 72
21314
+ ).uint32(message.channels);
21315
+ if (message.bitDepth != null && Object.hasOwnProperty.call(message, "bitDepth"))
21316
+ writer.uint32(
21317
+ /* id 10, wireType 0 =*/
21318
+ 80
21319
+ ).uint32(message.bitDepth);
21320
+ return writer;
21321
+ };
21322
+ MediaCodecData2.encodeDelimited = function encodeDelimited(message, writer) {
21323
+ return this.encode(message, writer).ldelim();
21324
+ };
21325
+ MediaCodecData2.decode = function decode(reader, length, error) {
21326
+ if (!(reader instanceof $Reader))
21327
+ reader = $Reader.create(reader);
21328
+ let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.sesame.v1.wire.MediaCodecData();
21329
+ while (reader.pos < end) {
21330
+ let tag = reader.uint32();
21331
+ if (tag === error)
21332
+ break;
21333
+ switch (tag >>> 3) {
21334
+ case 1: {
21335
+ message.codecType = reader.int32();
21336
+ break;
21337
+ }
21338
+ case 2: {
21339
+ message.sampleRate = reader.uint32();
21340
+ break;
21341
+ }
21342
+ case 3: {
21343
+ message.timebaseNum = reader.uint32();
21344
+ break;
21345
+ }
21346
+ case 4: {
21347
+ message.timebaseDen = reader.uint32();
21348
+ break;
21349
+ }
21350
+ case 5: {
21351
+ message.codecProfile = reader.uint32();
21352
+ break;
21353
+ }
21354
+ case 6: {
21355
+ message.codecLevel = reader.uint32();
21356
+ break;
21357
+ }
21358
+ case 7: {
21359
+ message.width = reader.uint32();
21360
+ break;
21361
+ }
21362
+ case 8: {
21363
+ message.height = reader.uint32();
21364
+ break;
21365
+ }
21366
+ case 9: {
21367
+ message.channels = reader.uint32();
21368
+ break;
21369
+ }
21370
+ case 10: {
21371
+ message.bitDepth = reader.uint32();
21372
+ break;
21373
+ }
21374
+ default:
21375
+ reader.skipType(tag & 7);
21376
+ break;
21377
+ }
21378
+ }
21379
+ return message;
21380
+ };
21381
+ MediaCodecData2.decodeDelimited = function decodeDelimited(reader) {
21382
+ if (!(reader instanceof $Reader))
21383
+ reader = new $Reader(reader);
21384
+ return this.decode(reader, reader.uint32());
21385
+ };
21386
+ MediaCodecData2.verify = function verify(message) {
21387
+ if (typeof message !== "object" || message === null)
21388
+ return "object expected";
21389
+ if (message.codecType != null && message.hasOwnProperty("codecType"))
21390
+ switch (message.codecType) {
21391
+ default:
21392
+ return "codecType: enum value expected";
21393
+ case 0:
21394
+ case 1:
21395
+ case 2:
21396
+ case 3:
21397
+ case 4:
21398
+ case 5:
21399
+ case 64:
21400
+ case 65:
21401
+ case 66:
21402
+ break;
21403
+ }
21404
+ if (message.sampleRate != null && message.hasOwnProperty("sampleRate")) {
21405
+ if (!$util.isInteger(message.sampleRate))
21406
+ return "sampleRate: integer expected";
21407
+ }
21408
+ if (message.timebaseNum != null && message.hasOwnProperty("timebaseNum")) {
21409
+ if (!$util.isInteger(message.timebaseNum))
21410
+ return "timebaseNum: integer expected";
21411
+ }
21412
+ if (message.timebaseDen != null && message.hasOwnProperty("timebaseDen")) {
21413
+ if (!$util.isInteger(message.timebaseDen))
21414
+ return "timebaseDen: integer expected";
21415
+ }
21416
+ if (message.codecProfile != null && message.hasOwnProperty("codecProfile")) {
21417
+ if (!$util.isInteger(message.codecProfile))
21418
+ return "codecProfile: integer expected";
21419
+ }
21420
+ if (message.codecLevel != null && message.hasOwnProperty("codecLevel")) {
21421
+ if (!$util.isInteger(message.codecLevel))
21422
+ return "codecLevel: integer expected";
21423
+ }
21424
+ if (message.width != null && message.hasOwnProperty("width")) {
21425
+ if (!$util.isInteger(message.width))
21426
+ return "width: integer expected";
21427
+ }
21428
+ if (message.height != null && message.hasOwnProperty("height")) {
21429
+ if (!$util.isInteger(message.height))
21430
+ return "height: integer expected";
21431
+ }
21432
+ if (message.channels != null && message.hasOwnProperty("channels")) {
21433
+ if (!$util.isInteger(message.channels))
21434
+ return "channels: integer expected";
21435
+ }
21436
+ if (message.bitDepth != null && message.hasOwnProperty("bitDepth")) {
21437
+ if (!$util.isInteger(message.bitDepth))
21438
+ return "bitDepth: integer expected";
21439
+ }
21440
+ return null;
21441
+ };
21442
+ MediaCodecData2.fromObject = function fromObject(object) {
21443
+ if (object instanceof $root.sesame.v1.wire.MediaCodecData)
21444
+ return object;
21445
+ let message = new $root.sesame.v1.wire.MediaCodecData();
21446
+ switch (object.codecType) {
21447
+ default:
21448
+ if (typeof object.codecType === "number") {
21449
+ message.codecType = object.codecType;
21450
+ break;
21451
+ }
21452
+ break;
21453
+ case "CODEC_TYPE_UNSPECIFIED":
21454
+ case 0:
21455
+ message.codecType = 0;
21456
+ break;
21457
+ case "CODEC_TYPE_VIDEO_VP8":
21458
+ case 1:
21459
+ message.codecType = 1;
21460
+ break;
21461
+ case "CODEC_TYPE_VIDEO_VP9":
21462
+ case 2:
21463
+ message.codecType = 2;
21464
+ break;
21465
+ case "CODEC_TYPE_VIDEO_AVC":
21466
+ case 3:
21467
+ message.codecType = 3;
21468
+ break;
21469
+ case "CODEC_TYPE_VIDEO_HEVC":
21470
+ case 4:
21471
+ message.codecType = 4;
21472
+ break;
21473
+ case "CODEC_TYPE_VIDEO_AV1":
21474
+ case 5:
21475
+ message.codecType = 5;
21476
+ break;
21477
+ case "CODEC_TYPE_AUDIO_OPUS":
21478
+ case 64:
21479
+ message.codecType = 64;
21480
+ break;
21481
+ case "CODEC_TYPE_AUDIO_AAC":
21482
+ case 65:
21483
+ message.codecType = 65;
21484
+ break;
21485
+ case "CODEC_TYPE_AUDIO_PCM":
21486
+ case 66:
21487
+ message.codecType = 66;
21488
+ break;
21489
+ }
21490
+ if (object.sampleRate != null)
21491
+ message.sampleRate = object.sampleRate >>> 0;
21492
+ if (object.timebaseNum != null)
21493
+ message.timebaseNum = object.timebaseNum >>> 0;
21494
+ if (object.timebaseDen != null)
21495
+ message.timebaseDen = object.timebaseDen >>> 0;
21496
+ if (object.codecProfile != null)
21497
+ message.codecProfile = object.codecProfile >>> 0;
21498
+ if (object.codecLevel != null)
21499
+ message.codecLevel = object.codecLevel >>> 0;
21500
+ if (object.width != null)
21501
+ message.width = object.width >>> 0;
21502
+ if (object.height != null)
21503
+ message.height = object.height >>> 0;
21504
+ if (object.channels != null)
21505
+ message.channels = object.channels >>> 0;
21506
+ if (object.bitDepth != null)
21507
+ message.bitDepth = object.bitDepth >>> 0;
21508
+ return message;
21509
+ };
21510
+ MediaCodecData2.toObject = function toObject(message, options) {
21511
+ if (!options)
21512
+ options = {};
21513
+ let object = {};
21514
+ if (options.defaults) {
21515
+ object.codecType = options.enums === String ? "CODEC_TYPE_UNSPECIFIED" : 0;
21516
+ object.sampleRate = 0;
21517
+ object.timebaseNum = 0;
21518
+ object.timebaseDen = 0;
21519
+ object.codecProfile = 0;
21520
+ object.codecLevel = 0;
21521
+ object.width = 0;
21522
+ object.height = 0;
21523
+ object.channels = 0;
21524
+ object.bitDepth = 0;
21525
+ }
21526
+ if (message.codecType != null && message.hasOwnProperty("codecType"))
21527
+ 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;
21528
+ if (message.sampleRate != null && message.hasOwnProperty("sampleRate"))
21529
+ object.sampleRate = message.sampleRate;
21530
+ if (message.timebaseNum != null && message.hasOwnProperty("timebaseNum"))
21531
+ object.timebaseNum = message.timebaseNum;
21532
+ if (message.timebaseDen != null && message.hasOwnProperty("timebaseDen"))
21533
+ object.timebaseDen = message.timebaseDen;
21534
+ if (message.codecProfile != null && message.hasOwnProperty("codecProfile"))
21535
+ object.codecProfile = message.codecProfile;
21536
+ if (message.codecLevel != null && message.hasOwnProperty("codecLevel"))
21537
+ object.codecLevel = message.codecLevel;
21538
+ if (message.width != null && message.hasOwnProperty("width"))
21539
+ object.width = message.width;
21540
+ if (message.height != null && message.hasOwnProperty("height"))
21541
+ object.height = message.height;
21542
+ if (message.channels != null && message.hasOwnProperty("channels"))
21543
+ object.channels = message.channels;
21544
+ if (message.bitDepth != null && message.hasOwnProperty("bitDepth"))
21545
+ object.bitDepth = message.bitDepth;
21546
+ return object;
21547
+ };
21548
+ MediaCodecData2.prototype.toJSON = function toJSON() {
21549
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
21550
+ };
21551
+ MediaCodecData2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
21552
+ if (typeUrlPrefix === void 0) {
21553
+ typeUrlPrefix = "type.googleapis.com";
21554
+ }
21555
+ return typeUrlPrefix + "/sesame.v1.wire.MediaCodecData";
21556
+ };
21557
+ return MediaCodecData2;
21558
+ }();
21559
+ wire.FrameHeader = function() {
21560
+ function FrameHeader2(properties) {
21561
+ if (properties) {
21562
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
21563
+ if (properties[keys[i]] != null)
21564
+ this[keys[i]] = properties[keys[i]];
21565
+ }
21566
+ }
21567
+ FrameHeader2.prototype.type = 0;
21568
+ FrameHeader2.prototype.pts = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
21569
+ FrameHeader2.prototype.id = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
21570
+ FrameHeader2.prototype.keyframe = false;
21571
+ FrameHeader2.prototype.codecData = null;
21572
+ FrameHeader2.prototype.routingMetadata = "";
21573
+ FrameHeader2.create = function create(properties) {
21574
+ return new FrameHeader2(properties);
21575
+ };
21576
+ FrameHeader2.encode = function encode(message, writer) {
21577
+ if (!writer)
21578
+ writer = $Writer.create();
21579
+ if (message.type != null && Object.hasOwnProperty.call(message, "type"))
21580
+ writer.uint32(
21581
+ /* id 1, wireType 0 =*/
21582
+ 8
21583
+ ).int32(message.type);
21584
+ if (message.pts != null && Object.hasOwnProperty.call(message, "pts"))
21585
+ writer.uint32(
21586
+ /* id 2, wireType 0 =*/
21587
+ 16
21588
+ ).uint64(message.pts);
21589
+ if (message.id != null && Object.hasOwnProperty.call(message, "id"))
21590
+ writer.uint32(
21591
+ /* id 3, wireType 0 =*/
21592
+ 24
21593
+ ).uint64(message.id);
21594
+ if (message.keyframe != null && Object.hasOwnProperty.call(message, "keyframe"))
21595
+ writer.uint32(
21596
+ /* id 4, wireType 0 =*/
21597
+ 32
21598
+ ).bool(message.keyframe);
21599
+ if (message.codecData != null && Object.hasOwnProperty.call(message, "codecData"))
21600
+ $root.sesame.v1.wire.MediaCodecData.encode(message.codecData, writer.uint32(
21601
+ /* id 5, wireType 2 =*/
21602
+ 42
21603
+ ).fork()).ldelim();
21604
+ if (message.routingMetadata != null && Object.hasOwnProperty.call(message, "routingMetadata"))
21605
+ writer.uint32(
21606
+ /* id 6, wireType 2 =*/
21607
+ 50
21608
+ ).string(message.routingMetadata);
21609
+ return writer;
21610
+ };
21611
+ FrameHeader2.encodeDelimited = function encodeDelimited(message, writer) {
21612
+ return this.encode(message, writer).ldelim();
21613
+ };
21614
+ FrameHeader2.decode = function decode(reader, length, error) {
21615
+ if (!(reader instanceof $Reader))
21616
+ reader = $Reader.create(reader);
21617
+ let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.sesame.v1.wire.FrameHeader();
21618
+ while (reader.pos < end) {
21619
+ let tag = reader.uint32();
21620
+ if (tag === error)
21621
+ break;
21622
+ switch (tag >>> 3) {
21623
+ case 1: {
21624
+ message.type = reader.int32();
21625
+ break;
21626
+ }
21627
+ case 2: {
21628
+ message.pts = reader.uint64();
21629
+ break;
21630
+ }
21631
+ case 3: {
21632
+ message.id = reader.uint64();
21633
+ break;
21634
+ }
21635
+ case 4: {
21636
+ message.keyframe = reader.bool();
21637
+ break;
21638
+ }
21639
+ case 5: {
21640
+ message.codecData = $root.sesame.v1.wire.MediaCodecData.decode(reader, reader.uint32());
21641
+ break;
21642
+ }
21643
+ case 6: {
21644
+ message.routingMetadata = reader.string();
21645
+ break;
21646
+ }
21647
+ default:
21648
+ reader.skipType(tag & 7);
21649
+ break;
21650
+ }
21651
+ }
21652
+ return message;
21653
+ };
21654
+ FrameHeader2.decodeDelimited = function decodeDelimited(reader) {
21655
+ if (!(reader instanceof $Reader))
21656
+ reader = new $Reader(reader);
21657
+ return this.decode(reader, reader.uint32());
21658
+ };
21659
+ FrameHeader2.verify = function verify(message) {
21660
+ if (typeof message !== "object" || message === null)
21661
+ return "object expected";
21662
+ if (message.type != null && message.hasOwnProperty("type"))
21663
+ switch (message.type) {
21664
+ default:
21665
+ return "type: enum value expected";
21666
+ case 0:
21667
+ case 1:
21668
+ case 2:
21669
+ case 3:
21670
+ case 4:
21671
+ case 5:
21672
+ case 6:
21673
+ break;
21674
+ }
21675
+ if (message.pts != null && message.hasOwnProperty("pts")) {
21676
+ if (!$util.isInteger(message.pts) && !(message.pts && $util.isInteger(message.pts.low) && $util.isInteger(message.pts.high)))
21677
+ return "pts: integer|Long expected";
21678
+ }
21679
+ if (message.id != null && message.hasOwnProperty("id")) {
21680
+ if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high)))
21681
+ return "id: integer|Long expected";
21682
+ }
21683
+ if (message.keyframe != null && message.hasOwnProperty("keyframe")) {
21684
+ if (typeof message.keyframe !== "boolean")
21685
+ return "keyframe: boolean expected";
21686
+ }
21687
+ if (message.codecData != null && message.hasOwnProperty("codecData")) {
21688
+ let error = $root.sesame.v1.wire.MediaCodecData.verify(message.codecData);
21689
+ if (error)
21690
+ return "codecData." + error;
21691
+ }
21692
+ if (message.routingMetadata != null && message.hasOwnProperty("routingMetadata")) {
21693
+ if (!$util.isString(message.routingMetadata))
21694
+ return "routingMetadata: string expected";
21695
+ }
21696
+ return null;
21697
+ };
21698
+ FrameHeader2.fromObject = function fromObject(object) {
21699
+ if (object instanceof $root.sesame.v1.wire.FrameHeader)
21700
+ return object;
21701
+ let message = new $root.sesame.v1.wire.FrameHeader();
21702
+ switch (object.type) {
21703
+ default:
21704
+ if (typeof object.type === "number") {
21705
+ message.type = object.type;
21706
+ break;
21707
+ }
21708
+ break;
21709
+ case "FRAME_TYPE_UNSPECIFIED":
21710
+ case 0:
21711
+ message.type = 0;
21712
+ break;
21713
+ case "FRAME_TYPE_RPC":
21714
+ case 1:
21715
+ message.type = 1;
21716
+ break;
21717
+ case "FRAME_TYPE_VIDEO":
21718
+ case 2:
21719
+ message.type = 2;
21720
+ break;
21721
+ case "FRAME_TYPE_AUDIO":
21722
+ case 3:
21723
+ message.type = 3;
21724
+ break;
21725
+ case "FRAME_TYPE_MUXED":
21726
+ case 4:
21727
+ message.type = 4;
21728
+ break;
21729
+ case "FRAME_TYPE_DECODER_DATA":
21730
+ case 5:
21731
+ message.type = 5;
21732
+ break;
21733
+ case "FRAME_TYPE_DATA":
21734
+ case 6:
21735
+ message.type = 6;
21736
+ break;
21737
+ }
21738
+ if (object.pts != null) {
21739
+ if ($util.Long)
21740
+ (message.pts = $util.Long.fromValue(object.pts)).unsigned = true;
21741
+ else if (typeof object.pts === "string")
21742
+ message.pts = parseInt(object.pts, 10);
21743
+ else if (typeof object.pts === "number")
21744
+ message.pts = object.pts;
21745
+ else if (typeof object.pts === "object")
21746
+ message.pts = new $util.LongBits(object.pts.low >>> 0, object.pts.high >>> 0).toNumber(true);
21747
+ }
21748
+ if (object.id != null) {
21749
+ if ($util.Long)
21750
+ (message.id = $util.Long.fromValue(object.id)).unsigned = true;
21751
+ else if (typeof object.id === "string")
21752
+ message.id = parseInt(object.id, 10);
21753
+ else if (typeof object.id === "number")
21754
+ message.id = object.id;
21755
+ else if (typeof object.id === "object")
21756
+ message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber(true);
21757
+ }
21758
+ if (object.keyframe != null)
21759
+ message.keyframe = Boolean(object.keyframe);
21760
+ if (object.codecData != null) {
21761
+ if (typeof object.codecData !== "object")
21762
+ throw TypeError(".sesame.v1.wire.FrameHeader.codecData: object expected");
21763
+ message.codecData = $root.sesame.v1.wire.MediaCodecData.fromObject(object.codecData);
21764
+ }
21765
+ if (object.routingMetadata != null)
21766
+ message.routingMetadata = String(object.routingMetadata);
21767
+ return message;
21768
+ };
21769
+ FrameHeader2.toObject = function toObject(message, options) {
21770
+ if (!options)
21771
+ options = {};
21772
+ let object = {};
21773
+ if (options.defaults) {
21774
+ object.type = options.enums === String ? "FRAME_TYPE_UNSPECIFIED" : 0;
21775
+ if ($util.Long) {
21776
+ let long = new $util.Long(0, 0, true);
21777
+ object.pts = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
21778
+ } else
21779
+ object.pts = options.longs === String ? "0" : 0;
21780
+ if ($util.Long) {
21781
+ let long = new $util.Long(0, 0, true);
21782
+ object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
21783
+ } else
21784
+ object.id = options.longs === String ? "0" : 0;
21785
+ object.keyframe = false;
21786
+ object.codecData = null;
21787
+ object.routingMetadata = "";
21788
+ }
21789
+ if (message.type != null && message.hasOwnProperty("type"))
21790
+ 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;
21791
+ if (message.pts != null && message.hasOwnProperty("pts"))
21792
+ if (typeof message.pts === "number")
21793
+ object.pts = options.longs === String ? String(message.pts) : message.pts;
21794
+ else
21795
+ 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;
21796
+ if (message.id != null && message.hasOwnProperty("id"))
21797
+ if (typeof message.id === "number")
21798
+ object.id = options.longs === String ? String(message.id) : message.id;
21799
+ else
21800
+ 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;
21801
+ if (message.keyframe != null && message.hasOwnProperty("keyframe"))
21802
+ object.keyframe = message.keyframe;
21803
+ if (message.codecData != null && message.hasOwnProperty("codecData"))
21804
+ object.codecData = $root.sesame.v1.wire.MediaCodecData.toObject(message.codecData, options);
21805
+ if (message.routingMetadata != null && message.hasOwnProperty("routingMetadata"))
21806
+ object.routingMetadata = message.routingMetadata;
21807
+ return object;
21808
+ };
21809
+ FrameHeader2.prototype.toJSON = function toJSON() {
21810
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
21811
+ };
21812
+ FrameHeader2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
21813
+ if (typeUrlPrefix === void 0) {
21814
+ typeUrlPrefix = "type.googleapis.com";
21815
+ }
21816
+ return typeUrlPrefix + "/sesame.v1.wire.FrameHeader";
21817
+ };
21818
+ return FrameHeader2;
21819
+ }();
21820
+ return wire;
21821
+ }();
21822
+ return v1;
21823
+ }();
21824
+ return sesame2;
21825
+ })();
21826
+
21827
+ // src/command-list.ts
21828
+ var CommandList = class {
21829
+ constructor() {
21830
+ this.cl = new sesame.v1.commands.CommandList();
21831
+ this.cl.commandList = [];
21832
+ }
21833
+ add(item, timeOffsetMs, transaction) {
21834
+ item.timeOffsetUs = (timeOffsetMs || 0) * 1e3;
21835
+ if (transaction) {
21836
+ item.transactionDeps = transaction?.dependencies || [];
21837
+ item.transactionId = transaction.transactionId;
21838
+ }
21839
+ this.cl.commandList.push(item);
21840
+ return item;
21841
+ }
21842
+ applyTransaction(transaction) {
21843
+ this.cl.commandList.forEach((item) => {
21844
+ if (transaction.transactionId !== void 0) {
21845
+ item.transactionId = transaction.transactionId;
21846
+ }
21847
+ if (transaction.dependencies !== void 0) {
21848
+ item.transactionDeps = item.transactionDeps ? item.transactionDeps.concat(transaction.dependencies) : transaction.dependencies;
21849
+ }
21850
+ });
21851
+ }
21852
+ getLength() {
21853
+ return this.cl.commandList.length;
21854
+ }
21855
+ filterCreatedAndDestroyedSources() {
21856
+ const created = /* @__PURE__ */ new Map();
21857
+ const createdAndRemoved = [];
21858
+ for (let i = 0; i < this.cl.commandList.length; i++) {
21859
+ if (this.cl.commandList[i].addSource) {
21860
+ created.set(this.cl.commandList[i].addSource.id, this.cl.commandList[i]);
21861
+ } else if (this.cl.commandList[i].removeSource) {
21862
+ const id = this.cl.commandList[i].removeSource.id;
21863
+ if (created.has(id)) {
21864
+ createdAndRemoved.push({ add: created.get(id), del: this.cl.commandList[i] });
21865
+ }
21866
+ }
21867
+ }
21868
+ createdAndRemoved.forEach((item) => {
21869
+ this.cl.commandList.splice(this.cl.commandList.indexOf(item.add), 1);
21870
+ this.cl.commandList.splice(this.cl.commandList.indexOf(item.del), 1);
21871
+ });
21872
+ }
21873
+ getCommandListMsg() {
21874
+ return this.cl;
21875
+ }
21876
+ callback(event, data, timeOffsetMs) {
21877
+ let item = new sesame.v1.commands.CommandListItem();
21878
+ item.callback = { event, data };
21879
+ return this.add(item, timeOffsetMs);
21880
+ }
21881
+ compositorAdd(id, width, height, multisample, timeOffsetMs) {
21882
+ let item = new sesame.v1.commands.CommandListItem();
21883
+ item.addCompositor = { id, multisample, width, height };
21884
+ return this.add(item, timeOffsetMs);
21885
+ }
21886
+ compositorRemove(id, timeOffsetMs) {
21887
+ let item = new sesame.v1.commands.CommandListItem();
21888
+ item.removeCompositor = { id };
21889
+ return this.add(item, timeOffsetMs);
21890
+ }
21891
+ compositorClear(id, timeOffsetMs) {
21892
+ let item = new sesame.v1.commands.CommandListItem();
21893
+ item.clearCompositor = { id };
21894
+ return this.add(item, timeOffsetMs);
21895
+ }
21896
+ sourceAdd(id, cfg, timeOffsetMs) {
21897
+ let item = new sesame.v1.commands.CommandListItem();
21898
+ item.addSource = { id, config: cfg };
21899
+ return this.add(item, timeOffsetMs);
21900
+ }
21901
+ sourceRemove(id, timeOffsetMs) {
21902
+ let item = new sesame.v1.commands.CommandListItem();
21903
+ item.removeSource = { id };
21904
+ return this.add(item, timeOffsetMs);
21905
+ }
21906
+ nodeAdd(id, cfg, timeOffsetMs) {
21907
+ let item = new sesame.v1.commands.CommandListItem();
21908
+ item.addNode = {
21909
+ compositorId: cfg.compositorId,
21910
+ nodeId: id,
21911
+ parentAddress: cfg.parentAddress || "",
21912
+ nodeType: cfg.nodeType
21913
+ };
21914
+ return this.add(item, timeOffsetMs);
21915
+ }
21916
+ nodeRemove(compositorId, address, timeOffsetMs) {
21917
+ let item = new sesame.v1.commands.CommandListItem();
21918
+ item.removeNode = { compositorId, address };
21919
+ return this.add(item, timeOffsetMs);
21920
+ }
21921
+ propertySet(propertyDomain, addr, prop, val, timeOffsetMs) {
21922
+ let item = new sesame.v1.commands.CommandListItem();
21923
+ item.setProperty = {
21159
21924
  address: addr,
21160
21925
  property: prop,
21161
21926
  domain: propertyDomain,
@@ -21493,7 +22258,8 @@ var RPCClient = class extends EventEmitter {
21493
22258
  eventHandler(event) {
21494
22259
  const topic = event.topic ?? 0;
21495
22260
  if (topic === sesame.v1.common.EventTopic.EVENT_TOPIC_UNSPECIFIED) {
21496
- throw new Error(`Unknown event topic: ${event.topic}`);
22261
+ log.warn(`Ignoring event with unspecified topic: ${event.topic}`);
22262
+ return;
21497
22263
  }
21498
22264
  const type = this.eventTypes[topic];
21499
22265
  let payload;
@@ -21519,255 +22285,58 @@ var RPCClient = class extends EventEmitter {
21519
22285
  // src/sesame-connection.ts
21520
22286
  import { EventEmitter as EventEmitter2 } from "events";
21521
22287
 
21522
- // src/sesame-binary-protocol.ts
21523
- var PROTOCOL_MAGIC = 1297302867;
21524
- var PROTOCOL_VERSION = 1;
21525
- var HEADER_DATA_SIZE = 32;
21526
- var HEADER_CODEC_DATA_SIZE = 24;
21527
- var HEADER_METADATA_SIZE = 64;
21528
- var FLAG_HAS_CODEC_DATA = 1 << 0;
21529
- var FLAG_HAS_METADATA = 1 << 1;
21530
- var FLAG_IS_KEYFRAME = 1 << 2;
21531
- var PacketType = /* @__PURE__ */ ((PacketType2) => {
21532
- PacketType2[PacketType2["VIDEO_FRAME"] = 1] = "VIDEO_FRAME";
21533
- PacketType2[PacketType2["AUDIO_FRAME"] = 2] = "AUDIO_FRAME";
21534
- PacketType2[PacketType2["RPC"] = 3] = "RPC";
21535
- PacketType2[PacketType2["MUXED_DATA"] = 4] = "MUXED_DATA";
21536
- PacketType2[PacketType2["DECODER_DATA"] = 5] = "DECODER_DATA";
21537
- return PacketType2;
21538
- })(PacketType || {});
21539
- var CodecType = /* @__PURE__ */ ((CodecType2) => {
21540
- CodecType2[CodecType2["VIDEO_VP8"] = 1] = "VIDEO_VP8";
21541
- CodecType2[CodecType2["VIDEO_VP9"] = 2] = "VIDEO_VP9";
21542
- CodecType2[CodecType2["VIDEO_AVC"] = 3] = "VIDEO_AVC";
21543
- CodecType2[CodecType2["VIDEO_HEVC"] = 4] = "VIDEO_HEVC";
21544
- CodecType2[CodecType2["VIDEO_AV1"] = 5] = "VIDEO_AV1";
21545
- CodecType2[CodecType2["AUDIO_OPUS"] = 64] = "AUDIO_OPUS";
21546
- CodecType2[CodecType2["AUDIO_AAC"] = 65] = "AUDIO_AAC";
21547
- CodecType2[CodecType2["AUDIO_PCM"] = 66] = "AUDIO_PCM";
21548
- return CodecType2;
21549
- })(CodecType || {});
21550
- var SesameBinaryProtocol = class {
22288
+ // src/sesame-wire-protocol.ts
22289
+ var FrameType = sesame.v1.wire.FrameType;
22290
+ var FrameHeader = sesame.v1.wire.FrameHeader;
22291
+ var MediaCodecData = sesame.v1.wire.MediaCodecData;
22292
+ var CodecType = sesame.v1.wire.CodecType;
22293
+ var PREFIX_SIZE = 4;
22294
+ var WireProtocol = class {
21551
22295
  /**
21552
- * Initialize a header data structure with proper defaults
22296
+ * Serialize a wire frame: 4-byte LE header_size + protobuf FrameHeader + payload.
21553
22297
  */
21554
- static initHeader(type, flags, pts, id) {
21555
- return {
21556
- magic: PROTOCOL_MAGIC,
21557
- version: PROTOCOL_VERSION,
21558
- header_size: this.calculateHeaderSize(flags),
21559
- type,
21560
- flags,
21561
- pts,
21562
- id,
21563
- reserved: 0
21564
- // Always zero reserved fields
21565
- };
21566
- }
21567
- /**
21568
- * Calculate the total header size based on flags
21569
- */
21570
- static calculateHeaderSize(flags) {
21571
- let size = HEADER_DATA_SIZE;
21572
- if (flags & FLAG_HAS_METADATA) {
21573
- size += HEADER_METADATA_SIZE;
21574
- }
21575
- if (flags & FLAG_HAS_CODEC_DATA) {
21576
- size += HEADER_CODEC_DATA_SIZE;
22298
+ static serialize(header, payload) {
22299
+ const headerBytes = sesame.v1.wire.FrameHeader.encode(header).finish();
22300
+ const headerSize = headerBytes.length;
22301
+ const payloadSize = payload ? payload.length : 0;
22302
+ const total = PREFIX_SIZE + headerSize + payloadSize;
22303
+ const buffer = new Uint8Array(total);
22304
+ const view = new DataView(buffer.buffer);
22305
+ view.setUint32(0, headerSize, true);
22306
+ buffer.set(headerBytes, PREFIX_SIZE);
22307
+ if (payload && payloadSize > 0) {
22308
+ buffer.set(payload, PREFIX_SIZE + headerSize);
21577
22309
  }
21578
- return size;
22310
+ return buffer;
21579
22311
  }
21580
22312
  /**
21581
- * Validate a header structure
22313
+ * Parse an incoming wire frame.
21582
22314
  */
21583
- static validateHeader(header, totalSize) {
21584
- if (header.magic !== PROTOCOL_MAGIC) {
21585
- return false;
22315
+ static parse(data) {
22316
+ const result = { valid: false, header: null, payload: null };
22317
+ if (!data || data.length < PREFIX_SIZE) return result;
22318
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
22319
+ const headerSize = view.getUint32(0, true);
22320
+ if (data.length < PREFIX_SIZE + headerSize) return result;
22321
+ try {
22322
+ const headerBytes = data.subarray(PREFIX_SIZE, PREFIX_SIZE + headerSize);
22323
+ result.header = sesame.v1.wire.FrameHeader.decode(headerBytes);
22324
+ result.payload = data.subarray(PREFIX_SIZE + headerSize);
22325
+ result.valid = true;
22326
+ } catch {
21586
22327
  }
21587
- if (header.version !== PROTOCOL_VERSION) {
21588
- return false;
21589
- }
21590
- const expectedHeaderSize = this.calculateHeaderSize(header.flags);
21591
- if (header.header_size !== expectedHeaderSize) {
21592
- return false;
21593
- }
21594
- if (totalSize < header.header_size) {
21595
- return false;
21596
- }
21597
- return true;
21598
- }
21599
- /**
21600
- * Serialize data into a Uint8Array buffer
21601
- */
21602
- static serialize(header, metadata = null, codecData = null, payload = null) {
21603
- const includeMetadata = metadata !== null && header.flags & FLAG_HAS_METADATA;
21604
- const includeCodec = codecData !== null && header.flags & FLAG_HAS_CODEC_DATA;
21605
- let totalSize = HEADER_DATA_SIZE;
21606
- if (includeMetadata) totalSize += HEADER_METADATA_SIZE;
21607
- if (includeCodec) totalSize += HEADER_CODEC_DATA_SIZE;
21608
- if (payload) totalSize += payload.length;
21609
- header.header_size = totalSize - (payload ? payload.length : 0);
21610
- const buffer = new ArrayBuffer(totalSize);
21611
- const view = new DataView(buffer);
21612
- let offset = 0;
21613
- view.setUint32(offset, header.magic, true);
21614
- offset += 4;
21615
- view.setUint32(offset, header.flags, true);
21616
- offset += 4;
21617
- view.setBigUint64(offset, header.pts, true);
21618
- offset += 8;
21619
- view.setBigUint64(offset, header.id, true);
21620
- offset += 8;
21621
- view.setUint16(offset, header.version, true);
21622
- offset += 2;
21623
- view.setUint16(offset, header.header_size, true);
21624
- offset += 2;
21625
- view.setUint16(offset, header.type, true);
21626
- offset += 2;
21627
- view.setUint16(offset, header.reserved, true);
21628
- offset += 2;
21629
- if (includeMetadata && metadata) {
21630
- const metadataBytes = this.stringToFixedBytes(metadata.metadata, 64);
21631
- new Uint8Array(buffer, offset, 64).set(metadataBytes);
21632
- offset += 64;
21633
- }
21634
- if (includeCodec && codecData) {
21635
- view.setUint32(offset, codecData.sample_rate, true);
21636
- offset += 4;
21637
- view.setUint32(offset, codecData.timebase_num, true);
21638
- offset += 4;
21639
- view.setUint32(offset, codecData.timebase_den, true);
21640
- offset += 4;
21641
- view.setUint16(offset, codecData.codec_profile, true);
21642
- offset += 2;
21643
- view.setUint16(offset, codecData.codec_level, true);
21644
- offset += 2;
21645
- view.setUint16(offset, codecData.width, true);
21646
- offset += 2;
21647
- view.setUint16(offset, codecData.height, true);
21648
- offset += 2;
21649
- view.setUint8(offset, codecData.codec_type);
21650
- offset += 1;
21651
- view.setUint8(offset, codecData.channels);
21652
- offset += 1;
21653
- view.setUint8(offset, codecData.bit_depth);
21654
- offset += 1;
21655
- view.setUint8(offset, codecData.reserved);
21656
- offset += 1;
21657
- }
21658
- if (payload && payload.length > 0) {
21659
- new Uint8Array(buffer, offset).set(payload);
21660
- }
21661
- return new Uint8Array(buffer);
21662
- }
21663
- /**
21664
- * Parse incoming binary data
21665
- */
21666
- static parseData(data) {
21667
- const result = {
21668
- valid: false,
21669
- header: null,
21670
- metadata: null,
21671
- codec_data: null,
21672
- payload: null,
21673
- payload_size: 0
21674
- };
21675
- if (!data || data.length < 36) {
21676
- return result;
21677
- }
21678
- const view = new DataView(data.buffer, data.byteOffset);
21679
- let offset = 0;
21680
- const header = {
21681
- magic: view.getUint32(offset, true),
21682
- flags: view.getUint32(offset + 4, true),
21683
- pts: view.getBigUint64(offset + 8, true),
21684
- id: view.getBigUint64(offset + 16, true),
21685
- version: view.getUint16(offset + 24, true),
21686
- header_size: view.getUint16(offset + 26, true),
21687
- type: view.getUint16(offset + 28, true),
21688
- reserved: view.getUint16(offset + 30, true)
21689
- };
21690
- offset += HEADER_DATA_SIZE;
21691
- if (!this.validateHeader(header, data.length)) {
21692
- return result;
21693
- }
21694
- result.header = header;
21695
- if (header.flags & FLAG_HAS_METADATA) {
21696
- if (data.length < offset + HEADER_METADATA_SIZE) {
21697
- return result;
21698
- }
21699
- const metadataBytes = data.slice(offset, offset + HEADER_METADATA_SIZE);
21700
- const metadataStr = this.fixedBytesToString(metadataBytes);
21701
- result.metadata = { metadata: metadataStr };
21702
- offset += HEADER_METADATA_SIZE;
21703
- }
21704
- if (header.flags & FLAG_HAS_CODEC_DATA) {
21705
- if (data.length < offset + HEADER_CODEC_DATA_SIZE) {
21706
- return result;
21707
- }
21708
- result.codec_data = {
21709
- sample_rate: view.getUint32(offset, true),
21710
- timebase_num: view.getUint32(offset + 4, true),
21711
- timebase_den: view.getUint32(offset + 8, true),
21712
- codec_profile: view.getUint16(offset + 12, true),
21713
- codec_level: view.getUint16(offset + 14, true),
21714
- width: view.getUint16(offset + 16, true),
21715
- height: view.getUint16(offset + 18, true),
21716
- codec_type: view.getUint8(offset + 20),
21717
- channels: view.getUint8(offset + 21),
21718
- bit_depth: view.getUint8(offset + 22),
21719
- reserved: view.getUint8(offset + 23)
21720
- };
21721
- offset += HEADER_CODEC_DATA_SIZE;
21722
- }
21723
- if (offset < data.length) {
21724
- result.payload = data.slice(offset);
21725
- result.payload_size = result.payload.length;
21726
- } else {
21727
- result.payload = new Uint8Array(0);
21728
- result.payload_size = 0;
21729
- }
21730
- result.valid = true;
21731
22328
  return result;
21732
22329
  }
21733
- /**
21734
- * Helper: Convert string to fixed-size byte array (null-terminated)
21735
- */
21736
- static stringToFixedBytes(str, size) {
21737
- const bytes = new Uint8Array(size);
21738
- let encoded;
21739
- if (typeof TextEncoder !== "undefined") {
21740
- const encoder = new TextEncoder();
21741
- encoded = encoder.encode(str);
21742
- } else {
21743
- encoded = new Uint8Array(Buffer.from(str, "utf8"));
21744
- }
21745
- const copyLen = Math.min(encoded.length, size - 1);
21746
- bytes.set(encoded.slice(0, copyLen));
21747
- bytes[copyLen] = 0;
21748
- return bytes;
21749
- }
21750
- /**
21751
- * Helper: Convert fixed-size byte array to string (null-terminated)
21752
- */
21753
- static fixedBytesToString(bytes) {
21754
- let len = bytes.length;
21755
- for (let i = 0; i < bytes.length; i++) {
21756
- if (bytes[i] === 0) {
21757
- len = i;
21758
- break;
21759
- }
21760
- }
21761
- if (typeof TextDecoder !== "undefined") {
21762
- const decoder = new TextDecoder();
21763
- return decoder.decode(bytes.slice(0, len));
21764
- } else {
21765
- return Buffer.from(bytes.slice(0, len)).toString("utf8");
21766
- }
21767
- }
21768
22330
  };
21769
22331
 
21770
22332
  // src/sesame-connection.ts
22333
+ var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
22334
+ ConnectionState2["Disconnected"] = "disconnected";
22335
+ ConnectionState2["Connecting"] = "connecting";
22336
+ ConnectionState2["Connected"] = "connected";
22337
+ ConnectionState2["Reconnecting"] = "reconnecting";
22338
+ return ConnectionState2;
22339
+ })(ConnectionState || {});
21771
22340
  function waitForEvent(emitter, eventName) {
21772
22341
  return new Promise((resolve) => {
21773
22342
  emitter.once(eventName, resolve);
@@ -21780,6 +22349,7 @@ var SesameConnection = class extends EventEmitter2 {
21780
22349
  this.numRetries = 0;
21781
22350
  this.url = "";
21782
22351
  this.autoReconnect = true;
22352
+ this._state = "disconnected" /* Disconnected */;
21783
22353
  /* Bound listeners so we can removeEventListener later */
21784
22354
  this.boundMessageHandler = (event) => this.messageHandler(event);
21785
22355
  this.boundOpenHandler = () => this.openHandler();
@@ -21787,38 +22357,68 @@ var SesameConnection = class extends EventEmitter2 {
21787
22357
  this.boundErrorHandler = (event) => this.errorHandler(event);
21788
22358
  this.openHandler = () => {
21789
22359
  this.numRetries = 0;
22360
+ this.setState("connected" /* Connected */);
21790
22361
  this.emit("open");
21791
22362
  };
21792
22363
  this.messageHandler = (event) => {
21793
22364
  if (event.data instanceof ArrayBuffer) {
21794
- const parsed = SesameBinaryProtocol.parseData(new Uint8Array(event.data));
21795
- if (!parsed.valid) this.emit("error", new Error("Invalid packet received"));
21796
- if (parsed.header?.type == 1 /* VIDEO_FRAME */) {
21797
- this.emit("video-packet", event.data);
21798
- } else if (parsed.header?.type == 2 /* AUDIO_FRAME */) {
21799
- this.emit("audio-packet", event.data);
21800
- } else if (parsed.header?.type == 3 /* RPC */) {
22365
+ const parsed = WireProtocol.parse(new Uint8Array(event.data));
22366
+ if (!parsed.valid) {
22367
+ this.emit("error", new Error("Invalid packet received"));
22368
+ return;
22369
+ }
22370
+ const frameType = parsed.header?.type;
22371
+ if (frameType === FrameType.FRAME_TYPE_RPC) {
21801
22372
  this.emit("rpc", parsed.payload);
22373
+ } else {
22374
+ this.emit("media-packet", parsed);
21802
22375
  }
21803
22376
  }
21804
22377
  };
21805
22378
  this.url = options.url;
21806
22379
  this.autoReconnect = options.autoReconnect;
21807
- if (options.autoConnect) this.connect().catch(() => log.debug("failed connect"));
22380
+ if (options.autoConnect) this.connect().catch(() => {
22381
+ });
22382
+ }
22383
+ get state() {
22384
+ return this._state;
22385
+ }
22386
+ setState(newState) {
22387
+ if (this._state === newState) return;
22388
+ const prev = this._state;
22389
+ this._state = newState;
22390
+ switch (newState) {
22391
+ case "connected" /* Connected */:
22392
+ log.info("Connected to Sesame");
22393
+ break;
22394
+ case "reconnecting" /* Reconnecting */:
22395
+ if (prev === "connected" /* Connected */) {
22396
+ log.warn("Lost connection to Sesame, will try reconnect..");
22397
+ } else {
22398
+ log.warn("Failed to connect to Sesame, will try reconnect..");
22399
+ }
22400
+ break;
22401
+ case "disconnected" /* Disconnected */:
22402
+ log.info("Disconnected from Sesame");
22403
+ break;
22404
+ }
22405
+ this.emit("state", newState, prev);
21808
22406
  }
21809
22407
  isConnected() {
21810
22408
  return this.socket !== void 0 && this.socket.readyState === WebSocket.OPEN;
21811
22409
  }
21812
22410
  async send(data) {
21813
22411
  if (!this.isConnected()) throw new Error("Not connected");
21814
- const header = SesameBinaryProtocol.initHeader(3 /* RPC */, 0, BigInt(0), BigInt(0));
21815
- const data_to_send = SesameBinaryProtocol.serialize(header, null, null, data);
21816
- if (!data_to_send) throw new Error("Failed to serialize data");
21817
- this.socket.send(data_to_send);
22412
+ const header = { type: sesame.v1.wire.FrameType.FRAME_TYPE_RPC };
22413
+ const frame = WireProtocol.serialize(header, data);
22414
+ this.socket.send(frame);
21818
22415
  return Promise.resolve();
21819
22416
  }
21820
22417
  async connect() {
21821
22418
  this.active = true;
22419
+ if (this._state === "disconnected" /* Disconnected */) {
22420
+ this.setState("connecting" /* Connecting */);
22421
+ }
21822
22422
  this.socket = new WebSocket(this.url);
21823
22423
  this.socket.addEventListener("message", this.boundMessageHandler);
21824
22424
  this.socket.addEventListener("open", this.boundOpenHandler);
@@ -21841,6 +22441,7 @@ var SesameConnection = class extends EventEmitter2 {
21841
22441
  async disconnect() {
21842
22442
  this.active = false;
21843
22443
  if (!this.socket) {
22444
+ this.setState("disconnected" /* Disconnected */);
21844
22445
  return;
21845
22446
  }
21846
22447
  const sock = this.socket;
@@ -21858,7 +22459,8 @@ var SesameConnection = class extends EventEmitter2 {
21858
22459
  }
21859
22460
  retryHandler() {
21860
22461
  if (this.active && this.autoReconnect) {
21861
- this.connect().catch((err) => log.error("Retry failed", err));
22462
+ this.connect().catch(() => {
22463
+ });
21862
22464
  }
21863
22465
  }
21864
22466
  closeHandler() {
@@ -21868,13 +22470,17 @@ var SesameConnection = class extends EventEmitter2 {
21868
22470
  }
21869
22471
  this.socket = void 0;
21870
22472
  if (this.active) {
21871
- try {
22473
+ if (this.autoReconnect) {
22474
+ this.setState("reconnecting" /* Reconnecting */);
21872
22475
  setTimeout(() => {
21873
22476
  this.retryHandler();
21874
22477
  }, defaultBackoff(++this.numRetries));
21875
- } catch (err) {
21876
- log.error("Connection error", err);
22478
+ } else {
22479
+ this.active = false;
22480
+ this.setState("disconnected" /* Disconnected */);
21877
22481
  }
22482
+ } else {
22483
+ this.setState("disconnected" /* Disconnected */);
21878
22484
  }
21879
22485
  }
21880
22486
  errorHandler(error) {
@@ -21900,9 +22506,6 @@ var StatusApi = class {
21900
22506
  async getIODevices() {
21901
22507
  return this.rpc.service.requestIODeviceList(new sesame.v1.common.Empty());
21902
22508
  }
21903
- async requestKeyframe(outputId) {
21904
- await this.rpc.service.requestKeyframe({ id: outputId });
21905
- }
21906
22509
  };
21907
22510
 
21908
22511
  // src/recorder-api.ts
@@ -22051,10 +22654,7 @@ var SesameClient = class extends EventEmitter3 {
22051
22654
  constructor(portOrUrl) {
22052
22655
  super();
22053
22656
  this.subscriptions = [];
22054
- this.errorIsLogged = false;
22055
- this.onVideoPacket = () => {
22056
- };
22057
- this.onAudioPacket = () => {
22657
+ this.onMediaPacket = () => {
22058
22658
  };
22059
22659
  this.onCallbackMessage = () => {
22060
22660
  };
@@ -22065,10 +22665,6 @@ var SesameClient = class extends EventEmitter3 {
22065
22665
  autoReconnect: true
22066
22666
  });
22067
22667
  this.conn.on("error", () => {
22068
- if (!this.errorIsLogged) {
22069
- log.warn("Could not connect to Sesame Engine, will keep trying..");
22070
- this.errorIsLogged = true;
22071
- }
22072
22668
  });
22073
22669
  let events = {
22074
22670
  [sesame.v1.common.EventTopic.EVENT_TOPIC_ERROR]: sesame.v1.status.Event,
@@ -22093,18 +22689,18 @@ var SesameClient = class extends EventEmitter3 {
22093
22689
  }
22094
22690
  });
22095
22691
  this.rpc.on("error", (err) => {
22096
- log.error(`RPC error: ${err.message}`);
22692
+ if (this.isConnected()) {
22693
+ log.error(`RPC error: ${err.message}`);
22694
+ }
22097
22695
  });
22098
22696
  this.conn.on("open", async () => {
22099
22697
  this.sendSubscriptions();
22100
- this.errorIsLogged = false;
22101
22698
  this.emit("connected");
22102
22699
  });
22103
22700
  this.conn.on("close", () => {
22104
22701
  this.emit("disconnected");
22105
22702
  });
22106
- this.conn.on("video-packet", (data) => this.onVideoPacket(this.videoSubscriptionId, data));
22107
- this.conn.on("audio-packet", (data) => this.onAudioPacket(this.videoSubscriptionId, data));
22703
+ this.conn.on("media-packet", (frame) => this.onMediaPacket(this.mediaSubscriptionId, frame));
22108
22704
  this.subscriptions = [];
22109
22705
  }
22110
22706
  isConnected() {
@@ -22114,14 +22710,14 @@ var SesameClient = class extends EventEmitter3 {
22114
22710
  if (!this.isConnected()) return;
22115
22711
  const eventTopics = this.subscriptions.map((subscription) => subscription.topic);
22116
22712
  const channels = [];
22117
- if (this.videoSubscriptionId) channels.push(`video/${this.videoSubscriptionId}`);
22713
+ if (this.mediaSubscriptionId) channels.push(`media-stream/${this.mediaSubscriptionId}`);
22118
22714
  let subs = { eventTopics, channels };
22119
22715
  this.rpc.service.updateSubscriptions(subs).catch((err) => {
22120
22716
  log.error(`Failed to update subscriptions: ${err.message}`);
22121
22717
  });
22122
22718
  }
22123
- addVideoSubscription(id) {
22124
- this.videoSubscriptionId = id;
22719
+ addMediaSubscription(id) {
22720
+ this.mediaSubscriptionId = id;
22125
22721
  this.sendSubscriptions();
22126
22722
  }
22127
22723
  addSubscription(topic, callback) {
@@ -22140,6 +22736,9 @@ var SesameClient = class extends EventEmitter3 {
22140
22736
  getService() {
22141
22737
  return this.rpc;
22142
22738
  }
22739
+ async requestKeyframe(outputId) {
22740
+ await this.rpc.service.requestKeyframe({ id: outputId });
22741
+ }
22143
22742
  async execute(cl) {
22144
22743
  cl.filterCreatedAndDestroyedSources();
22145
22744
  if (cl.getCommandListMsg().commandList.length > 0) {
@@ -22159,19 +22758,21 @@ var Event = sesame.v1.rpc.Event;
22159
22758
  export {
22160
22759
  CodecType,
22161
22760
  CommandList,
22761
+ ConnectionState,
22162
22762
  EaseKind,
22163
22763
  Event,
22764
+ FrameHeader,
22765
+ FrameType,
22164
22766
  JobsApi,
22165
22767
  Message,
22166
- PacketType,
22167
22768
  RPCClient,
22168
22769
  RecorderApi,
22169
22770
  Request,
22170
22771
  Response,
22171
- SesameBinaryProtocol,
22172
22772
  SesameClient,
22173
22773
  SesameConnection,
22174
22774
  StatusApi,
22775
+ WireProtocol,
22175
22776
  getLogger,
22176
22777
  log,
22177
22778
  sesame,