@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.
@@ -13699,15 +13699,22 @@ var sesame = $root.sesame = (() => {
13699
13699
  }
13700
13700
  TransportEvent.prototype.sourceId = "";
13701
13701
  TransportEvent.prototype.userId = "";
13702
+ TransportEvent.prototype.uri = "";
13702
13703
  TransportEvent.prototype.state = 0;
13703
13704
  TransportEvent.prototype.durationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13704
13705
  TransportEvent.prototype.positionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13705
13706
  TransportEvent.prototype.materialPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13707
+ TransportEvent.prototype.userTimeMs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13708
+ TransportEvent.prototype.speed = 0;
13706
13709
  TransportEvent.prototype.userPlaylistId = "";
13707
13710
  TransportEvent.prototype.playlistIndex = 0;
13708
13711
  TransportEvent.prototype.playlistLength = 0;
13709
13712
  TransportEvent.prototype.clipId = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
13710
13713
  TransportEvent.prototype.clipPositionUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13714
+ TransportEvent.prototype.clipDurationUs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
13715
+ TransportEvent.prototype.preroll = 0;
13716
+ TransportEvent.prototype.postroll = 0;
13717
+ TransportEvent.prototype.metadata = "";
13711
13718
  TransportEvent.create = function create(properties) {
13712
13719
  return new TransportEvent(properties);
13713
13720
  };
@@ -13724,51 +13731,86 @@ var sesame = $root.sesame = (() => {
13724
13731
  /* id 2, wireType 2 =*/
13725
13732
  18
13726
13733
  ).string(message.userId);
13734
+ if (message.uri != null && Object.hasOwnProperty.call(message, "uri"))
13735
+ writer.uint32(
13736
+ /* id 3, wireType 2 =*/
13737
+ 26
13738
+ ).string(message.uri);
13727
13739
  if (message.state != null && Object.hasOwnProperty.call(message, "state"))
13728
13740
  writer.uint32(
13729
- /* id 3, wireType 0 =*/
13730
- 24
13741
+ /* id 4, wireType 0 =*/
13742
+ 32
13731
13743
  ).int32(message.state);
13732
13744
  if (message.durationUs != null && Object.hasOwnProperty.call(message, "durationUs"))
13733
13745
  writer.uint32(
13734
- /* id 4, wireType 0 =*/
13735
- 32
13746
+ /* id 5, wireType 0 =*/
13747
+ 40
13736
13748
  ).int64(message.durationUs);
13737
13749
  if (message.positionUs != null && Object.hasOwnProperty.call(message, "positionUs"))
13738
13750
  writer.uint32(
13739
- /* id 5, wireType 0 =*/
13740
- 40
13751
+ /* id 6, wireType 0 =*/
13752
+ 48
13741
13753
  ).int64(message.positionUs);
13742
13754
  if (message.materialPositionUs != null && Object.hasOwnProperty.call(message, "materialPositionUs"))
13743
13755
  writer.uint32(
13744
- /* id 6, wireType 0 =*/
13745
- 48
13756
+ /* id 7, wireType 0 =*/
13757
+ 56
13746
13758
  ).int64(message.materialPositionUs);
13759
+ if (message.userTimeMs != null && Object.hasOwnProperty.call(message, "userTimeMs"))
13760
+ writer.uint32(
13761
+ /* id 8, wireType 0 =*/
13762
+ 64
13763
+ ).int64(message.userTimeMs);
13764
+ if (message.speed != null && Object.hasOwnProperty.call(message, "speed"))
13765
+ writer.uint32(
13766
+ /* id 9, wireType 5 =*/
13767
+ 77
13768
+ ).float(message.speed);
13747
13769
  if (message.userPlaylistId != null && Object.hasOwnProperty.call(message, "userPlaylistId"))
13748
13770
  writer.uint32(
13749
- /* id 7, wireType 2 =*/
13750
- 58
13771
+ /* id 10, wireType 2 =*/
13772
+ 82
13751
13773
  ).string(message.userPlaylistId);
13752
13774
  if (message.playlistIndex != null && Object.hasOwnProperty.call(message, "playlistIndex"))
13753
13775
  writer.uint32(
13754
- /* id 8, wireType 0 =*/
13755
- 64
13776
+ /* id 11, wireType 0 =*/
13777
+ 88
13756
13778
  ).uint32(message.playlistIndex);
13757
13779
  if (message.playlistLength != null && Object.hasOwnProperty.call(message, "playlistLength"))
13758
13780
  writer.uint32(
13759
- /* id 9, wireType 0 =*/
13760
- 72
13781
+ /* id 12, wireType 0 =*/
13782
+ 96
13761
13783
  ).uint32(message.playlistLength);
13762
13784
  if (message.clipId != null && Object.hasOwnProperty.call(message, "clipId"))
13763
13785
  writer.uint32(
13764
- /* id 10, wireType 0 =*/
13765
- 80
13786
+ /* id 13, wireType 0 =*/
13787
+ 104
13766
13788
  ).uint64(message.clipId);
13767
13789
  if (message.clipPositionUs != null && Object.hasOwnProperty.call(message, "clipPositionUs"))
13768
13790
  writer.uint32(
13769
- /* id 11, wireType 0 =*/
13770
- 88
13791
+ /* id 14, wireType 0 =*/
13792
+ 112
13771
13793
  ).int64(message.clipPositionUs);
13794
+ if (message.clipDurationUs != null && Object.hasOwnProperty.call(message, "clipDurationUs"))
13795
+ writer.uint32(
13796
+ /* id 15, wireType 0 =*/
13797
+ 120
13798
+ ).int64(message.clipDurationUs);
13799
+ if (message.preroll != null && Object.hasOwnProperty.call(message, "preroll"))
13800
+ writer.uint32(
13801
+ /* id 16, wireType 0 =*/
13802
+ 128
13803
+ ).uint32(message.preroll);
13804
+ if (message.postroll != null && Object.hasOwnProperty.call(message, "postroll"))
13805
+ writer.uint32(
13806
+ /* id 17, wireType 0 =*/
13807
+ 136
13808
+ ).uint32(message.postroll);
13809
+ if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata"))
13810
+ writer.uint32(
13811
+ /* id 18, wireType 2 =*/
13812
+ 146
13813
+ ).string(message.metadata);
13772
13814
  return writer;
13773
13815
  };
13774
13816
  TransportEvent.encodeDelimited = function encodeDelimited(message, writer) {
@@ -13792,41 +13834,69 @@ var sesame = $root.sesame = (() => {
13792
13834
  break;
13793
13835
  }
13794
13836
  case 3: {
13795
- message.state = reader.int32();
13837
+ message.uri = reader.string();
13796
13838
  break;
13797
13839
  }
13798
13840
  case 4: {
13799
- message.durationUs = reader.int64();
13841
+ message.state = reader.int32();
13800
13842
  break;
13801
13843
  }
13802
13844
  case 5: {
13803
- message.positionUs = reader.int64();
13845
+ message.durationUs = reader.int64();
13804
13846
  break;
13805
13847
  }
13806
13848
  case 6: {
13807
- message.materialPositionUs = reader.int64();
13849
+ message.positionUs = reader.int64();
13808
13850
  break;
13809
13851
  }
13810
13852
  case 7: {
13811
- message.userPlaylistId = reader.string();
13853
+ message.materialPositionUs = reader.int64();
13812
13854
  break;
13813
13855
  }
13814
13856
  case 8: {
13815
- message.playlistIndex = reader.uint32();
13857
+ message.userTimeMs = reader.int64();
13816
13858
  break;
13817
13859
  }
13818
13860
  case 9: {
13819
- message.playlistLength = reader.uint32();
13861
+ message.speed = reader.float();
13820
13862
  break;
13821
13863
  }
13822
13864
  case 10: {
13823
- message.clipId = reader.uint64();
13865
+ message.userPlaylistId = reader.string();
13824
13866
  break;
13825
13867
  }
13826
13868
  case 11: {
13869
+ message.playlistIndex = reader.uint32();
13870
+ break;
13871
+ }
13872
+ case 12: {
13873
+ message.playlistLength = reader.uint32();
13874
+ break;
13875
+ }
13876
+ case 13: {
13877
+ message.clipId = reader.uint64();
13878
+ break;
13879
+ }
13880
+ case 14: {
13827
13881
  message.clipPositionUs = reader.int64();
13828
13882
  break;
13829
13883
  }
13884
+ case 15: {
13885
+ message.clipDurationUs = reader.int64();
13886
+ break;
13887
+ }
13888
+ case 16: {
13889
+ message.preroll = reader.uint32();
13890
+ break;
13891
+ }
13892
+ case 17: {
13893
+ message.postroll = reader.uint32();
13894
+ break;
13895
+ }
13896
+ case 18: {
13897
+ message.metadata = reader.string();
13898
+ break;
13899
+ }
13830
13900
  default:
13831
13901
  reader.skipType(tag & 7);
13832
13902
  break;
@@ -13850,6 +13920,10 @@ var sesame = $root.sesame = (() => {
13850
13920
  if (!$util.isString(message.userId))
13851
13921
  return "userId: string expected";
13852
13922
  }
13923
+ if (message.uri != null && message.hasOwnProperty("uri")) {
13924
+ if (!$util.isString(message.uri))
13925
+ return "uri: string expected";
13926
+ }
13853
13927
  if (message.state != null && message.hasOwnProperty("state"))
13854
13928
  switch (message.state) {
13855
13929
  default:
@@ -13873,6 +13947,14 @@ var sesame = $root.sesame = (() => {
13873
13947
  if (!$util.isInteger(message.materialPositionUs) && !(message.materialPositionUs && $util.isInteger(message.materialPositionUs.low) && $util.isInteger(message.materialPositionUs.high)))
13874
13948
  return "materialPositionUs: integer|Long expected";
13875
13949
  }
13950
+ if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs")) {
13951
+ if (!$util.isInteger(message.userTimeMs) && !(message.userTimeMs && $util.isInteger(message.userTimeMs.low) && $util.isInteger(message.userTimeMs.high)))
13952
+ return "userTimeMs: integer|Long expected";
13953
+ }
13954
+ if (message.speed != null && message.hasOwnProperty("speed")) {
13955
+ if (typeof message.speed !== "number")
13956
+ return "speed: number expected";
13957
+ }
13876
13958
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId")) {
13877
13959
  if (!$util.isString(message.userPlaylistId))
13878
13960
  return "userPlaylistId: string expected";
@@ -13893,6 +13975,22 @@ var sesame = $root.sesame = (() => {
13893
13975
  if (!$util.isInteger(message.clipPositionUs) && !(message.clipPositionUs && $util.isInteger(message.clipPositionUs.low) && $util.isInteger(message.clipPositionUs.high)))
13894
13976
  return "clipPositionUs: integer|Long expected";
13895
13977
  }
13978
+ if (message.clipDurationUs != null && message.hasOwnProperty("clipDurationUs")) {
13979
+ if (!$util.isInteger(message.clipDurationUs) && !(message.clipDurationUs && $util.isInteger(message.clipDurationUs.low) && $util.isInteger(message.clipDurationUs.high)))
13980
+ return "clipDurationUs: integer|Long expected";
13981
+ }
13982
+ if (message.preroll != null && message.hasOwnProperty("preroll")) {
13983
+ if (!$util.isInteger(message.preroll))
13984
+ return "preroll: integer expected";
13985
+ }
13986
+ if (message.postroll != null && message.hasOwnProperty("postroll")) {
13987
+ if (!$util.isInteger(message.postroll))
13988
+ return "postroll: integer expected";
13989
+ }
13990
+ if (message.metadata != null && message.hasOwnProperty("metadata")) {
13991
+ if (!$util.isString(message.metadata))
13992
+ return "metadata: string expected";
13993
+ }
13896
13994
  return null;
13897
13995
  };
13898
13996
  TransportEvent.fromObject = function fromObject(object) {
@@ -13903,6 +14001,8 @@ var sesame = $root.sesame = (() => {
13903
14001
  message.sourceId = String(object.sourceId);
13904
14002
  if (object.userId != null)
13905
14003
  message.userId = String(object.userId);
14004
+ if (object.uri != null)
14005
+ message.uri = String(object.uri);
13906
14006
  switch (object.state) {
13907
14007
  default:
13908
14008
  if (typeof object.state === "number") {
@@ -13961,6 +14061,18 @@ var sesame = $root.sesame = (() => {
13961
14061
  else if (typeof object.materialPositionUs === "object")
13962
14062
  message.materialPositionUs = new $util.LongBits(object.materialPositionUs.low >>> 0, object.materialPositionUs.high >>> 0).toNumber();
13963
14063
  }
14064
+ if (object.userTimeMs != null) {
14065
+ if ($util.Long)
14066
+ (message.userTimeMs = $util.Long.fromValue(object.userTimeMs)).unsigned = false;
14067
+ else if (typeof object.userTimeMs === "string")
14068
+ message.userTimeMs = parseInt(object.userTimeMs, 10);
14069
+ else if (typeof object.userTimeMs === "number")
14070
+ message.userTimeMs = object.userTimeMs;
14071
+ else if (typeof object.userTimeMs === "object")
14072
+ message.userTimeMs = new $util.LongBits(object.userTimeMs.low >>> 0, object.userTimeMs.high >>> 0).toNumber();
14073
+ }
14074
+ if (object.speed != null)
14075
+ message.speed = Number(object.speed);
13964
14076
  if (object.userPlaylistId != null)
13965
14077
  message.userPlaylistId = String(object.userPlaylistId);
13966
14078
  if (object.playlistIndex != null)
@@ -13987,6 +14099,22 @@ var sesame = $root.sesame = (() => {
13987
14099
  else if (typeof object.clipPositionUs === "object")
13988
14100
  message.clipPositionUs = new $util.LongBits(object.clipPositionUs.low >>> 0, object.clipPositionUs.high >>> 0).toNumber();
13989
14101
  }
14102
+ if (object.clipDurationUs != null) {
14103
+ if ($util.Long)
14104
+ (message.clipDurationUs = $util.Long.fromValue(object.clipDurationUs)).unsigned = false;
14105
+ else if (typeof object.clipDurationUs === "string")
14106
+ message.clipDurationUs = parseInt(object.clipDurationUs, 10);
14107
+ else if (typeof object.clipDurationUs === "number")
14108
+ message.clipDurationUs = object.clipDurationUs;
14109
+ else if (typeof object.clipDurationUs === "object")
14110
+ message.clipDurationUs = new $util.LongBits(object.clipDurationUs.low >>> 0, object.clipDurationUs.high >>> 0).toNumber();
14111
+ }
14112
+ if (object.preroll != null)
14113
+ message.preroll = object.preroll >>> 0;
14114
+ if (object.postroll != null)
14115
+ message.postroll = object.postroll >>> 0;
14116
+ if (object.metadata != null)
14117
+ message.metadata = String(object.metadata);
13990
14118
  return message;
13991
14119
  };
13992
14120
  TransportEvent.toObject = function toObject(message, options) {
@@ -13996,6 +14124,7 @@ var sesame = $root.sesame = (() => {
13996
14124
  if (options.defaults) {
13997
14125
  object.sourceId = "";
13998
14126
  object.userId = "";
14127
+ object.uri = "";
13999
14128
  object.state = options.enums === String ? "SOURCE_TRANSPORT_STATE_STOPPED" : 0;
14000
14129
  if ($util.Long) {
14001
14130
  let long = new $util.Long(0, 0, false);
@@ -14012,6 +14141,12 @@ var sesame = $root.sesame = (() => {
14012
14141
  object.materialPositionUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
14013
14142
  } else
14014
14143
  object.materialPositionUs = options.longs === String ? "0" : 0;
14144
+ if ($util.Long) {
14145
+ let long = new $util.Long(0, 0, false);
14146
+ object.userTimeMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
14147
+ } else
14148
+ object.userTimeMs = options.longs === String ? "0" : 0;
14149
+ object.speed = 0;
14015
14150
  object.userPlaylistId = "";
14016
14151
  object.playlistIndex = 0;
14017
14152
  object.playlistLength = 0;
@@ -14025,11 +14160,21 @@ var sesame = $root.sesame = (() => {
14025
14160
  object.clipPositionUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
14026
14161
  } else
14027
14162
  object.clipPositionUs = options.longs === String ? "0" : 0;
14163
+ if ($util.Long) {
14164
+ let long = new $util.Long(0, 0, false);
14165
+ object.clipDurationUs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
14166
+ } else
14167
+ object.clipDurationUs = options.longs === String ? "0" : 0;
14168
+ object.preroll = 0;
14169
+ object.postroll = 0;
14170
+ object.metadata = "";
14028
14171
  }
14029
14172
  if (message.sourceId != null && message.hasOwnProperty("sourceId"))
14030
14173
  object.sourceId = message.sourceId;
14031
14174
  if (message.userId != null && message.hasOwnProperty("userId"))
14032
14175
  object.userId = message.userId;
14176
+ if (message.uri != null && message.hasOwnProperty("uri"))
14177
+ object.uri = message.uri;
14033
14178
  if (message.state != null && message.hasOwnProperty("state"))
14034
14179
  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;
14035
14180
  if (message.durationUs != null && message.hasOwnProperty("durationUs"))
@@ -14047,6 +14192,13 @@ var sesame = $root.sesame = (() => {
14047
14192
  object.materialPositionUs = options.longs === String ? String(message.materialPositionUs) : message.materialPositionUs;
14048
14193
  else
14049
14194
  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;
14195
+ if (message.userTimeMs != null && message.hasOwnProperty("userTimeMs"))
14196
+ if (typeof message.userTimeMs === "number")
14197
+ object.userTimeMs = options.longs === String ? String(message.userTimeMs) : message.userTimeMs;
14198
+ else
14199
+ 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;
14200
+ if (message.speed != null && message.hasOwnProperty("speed"))
14201
+ object.speed = options.json && !isFinite(message.speed) ? String(message.speed) : message.speed;
14050
14202
  if (message.userPlaylistId != null && message.hasOwnProperty("userPlaylistId"))
14051
14203
  object.userPlaylistId = message.userPlaylistId;
14052
14204
  if (message.playlistIndex != null && message.hasOwnProperty("playlistIndex"))
@@ -14063,6 +14215,17 @@ var sesame = $root.sesame = (() => {
14063
14215
  object.clipPositionUs = options.longs === String ? String(message.clipPositionUs) : message.clipPositionUs;
14064
14216
  else
14065
14217
  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;
14218
+ if (message.clipDurationUs != null && message.hasOwnProperty("clipDurationUs"))
14219
+ if (typeof message.clipDurationUs === "number")
14220
+ object.clipDurationUs = options.longs === String ? String(message.clipDurationUs) : message.clipDurationUs;
14221
+ else
14222
+ 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;
14223
+ if (message.preroll != null && message.hasOwnProperty("preroll"))
14224
+ object.preroll = message.preroll;
14225
+ if (message.postroll != null && message.hasOwnProperty("postroll"))
14226
+ object.postroll = message.postroll;
14227
+ if (message.metadata != null && message.hasOwnProperty("metadata"))
14228
+ object.metadata = message.metadata;
14066
14229
  return object;
14067
14230
  };
14068
14231
  TransportEvent.prototype.toJSON = function toJSON() {
@@ -21449,108 +21612,710 @@ var sesame = $root.sesame = (() => {
21449
21612
  }();
21450
21613
  return rpc;
21451
21614
  }();
21452
- return v1;
21453
- }();
21454
- return sesame2;
21455
- })();
21456
-
21457
- // src/command-list.ts
21458
- var CommandList = class {
21459
- constructor() {
21460
- this.cl = new sesame.v1.commands.CommandList();
21461
- this.cl.commandList = [];
21462
- }
21463
- add(item, timeOffsetMs, transaction) {
21464
- item.timeOffsetUs = (timeOffsetMs || 0) * 1e3;
21465
- if (transaction) {
21466
- item.transactionDeps = transaction?.dependencies || [];
21467
- item.transactionId = transaction.transactionId;
21468
- }
21469
- this.cl.commandList.push(item);
21470
- return item;
21471
- }
21472
- applyTransaction(transaction) {
21473
- this.cl.commandList.forEach((item) => {
21474
- if (transaction.transactionId !== void 0) {
21475
- item.transactionId = transaction.transactionId;
21476
- }
21477
- if (transaction.dependencies !== void 0) {
21478
- item.transactionDeps = item.transactionDeps ? item.transactionDeps.concat(transaction.dependencies) : transaction.dependencies;
21479
- }
21480
- });
21481
- }
21482
- getLength() {
21483
- return this.cl.commandList.length;
21484
- }
21485
- filterCreatedAndDestroyedSources() {
21486
- const created = /* @__PURE__ */ new Map();
21487
- const createdAndRemoved = [];
21488
- for (let i = 0; i < this.cl.commandList.length; i++) {
21489
- if (this.cl.commandList[i].addSource) {
21490
- created.set(this.cl.commandList[i].addSource.id, this.cl.commandList[i]);
21491
- } else if (this.cl.commandList[i].removeSource) {
21492
- const id = this.cl.commandList[i].removeSource.id;
21493
- if (created.has(id)) {
21494
- createdAndRemoved.push({ add: created.get(id), del: this.cl.commandList[i] });
21615
+ v1.wire = function() {
21616
+ const wire = {};
21617
+ wire.FrameType = function() {
21618
+ const valuesById = {}, values = Object.create(valuesById);
21619
+ values[valuesById[0] = "FRAME_TYPE_UNSPECIFIED"] = 0;
21620
+ values[valuesById[1] = "FRAME_TYPE_RPC"] = 1;
21621
+ values[valuesById[2] = "FRAME_TYPE_VIDEO"] = 2;
21622
+ values[valuesById[3] = "FRAME_TYPE_AUDIO"] = 3;
21623
+ values[valuesById[4] = "FRAME_TYPE_MUXED"] = 4;
21624
+ values[valuesById[5] = "FRAME_TYPE_DECODER_DATA"] = 5;
21625
+ values[valuesById[6] = "FRAME_TYPE_DATA"] = 6;
21626
+ return values;
21627
+ }();
21628
+ wire.CodecType = function() {
21629
+ const valuesById = {}, values = Object.create(valuesById);
21630
+ values[valuesById[0] = "CODEC_TYPE_UNSPECIFIED"] = 0;
21631
+ values[valuesById[1] = "CODEC_TYPE_VIDEO_VP8"] = 1;
21632
+ values[valuesById[2] = "CODEC_TYPE_VIDEO_VP9"] = 2;
21633
+ values[valuesById[3] = "CODEC_TYPE_VIDEO_AVC"] = 3;
21634
+ values[valuesById[4] = "CODEC_TYPE_VIDEO_HEVC"] = 4;
21635
+ values[valuesById[5] = "CODEC_TYPE_VIDEO_AV1"] = 5;
21636
+ values[valuesById[64] = "CODEC_TYPE_AUDIO_OPUS"] = 64;
21637
+ values[valuesById[65] = "CODEC_TYPE_AUDIO_AAC"] = 65;
21638
+ values[valuesById[66] = "CODEC_TYPE_AUDIO_PCM"] = 66;
21639
+ return values;
21640
+ }();
21641
+ wire.MediaCodecData = function() {
21642
+ function MediaCodecData2(properties) {
21643
+ if (properties) {
21644
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
21645
+ if (properties[keys[i]] != null)
21646
+ this[keys[i]] = properties[keys[i]];
21647
+ }
21495
21648
  }
21496
- }
21497
- }
21498
- createdAndRemoved.forEach((item) => {
21499
- this.cl.commandList.splice(this.cl.commandList.indexOf(item.add), 1);
21500
- this.cl.commandList.splice(this.cl.commandList.indexOf(item.del), 1);
21501
- });
21502
- }
21503
- getCommandListMsg() {
21504
- return this.cl;
21505
- }
21506
- callback(event, data, timeOffsetMs) {
21507
- let item = new sesame.v1.commands.CommandListItem();
21508
- item.callback = { event, data };
21509
- return this.add(item, timeOffsetMs);
21510
- }
21511
- compositorAdd(id, width, height, multisample, timeOffsetMs) {
21512
- let item = new sesame.v1.commands.CommandListItem();
21513
- item.addCompositor = { id, multisample, width, height };
21514
- return this.add(item, timeOffsetMs);
21515
- }
21516
- compositorRemove(id, timeOffsetMs) {
21517
- let item = new sesame.v1.commands.CommandListItem();
21518
- item.removeCompositor = { id };
21519
- return this.add(item, timeOffsetMs);
21520
- }
21521
- compositorClear(id, timeOffsetMs) {
21522
- let item = new sesame.v1.commands.CommandListItem();
21523
- item.clearCompositor = { id };
21524
- return this.add(item, timeOffsetMs);
21525
- }
21526
- sourceAdd(id, cfg, timeOffsetMs) {
21527
- let item = new sesame.v1.commands.CommandListItem();
21528
- item.addSource = { id, config: cfg };
21529
- return this.add(item, timeOffsetMs);
21530
- }
21531
- sourceRemove(id, timeOffsetMs) {
21532
- let item = new sesame.v1.commands.CommandListItem();
21533
- item.removeSource = { id };
21534
- return this.add(item, timeOffsetMs);
21535
- }
21536
- nodeAdd(id, cfg, timeOffsetMs) {
21537
- let item = new sesame.v1.commands.CommandListItem();
21538
- item.addNode = {
21539
- compositorId: cfg.compositorId,
21540
- nodeId: id,
21541
- parentAddress: cfg.parentAddress || "",
21542
- nodeType: cfg.nodeType
21543
- };
21544
- return this.add(item, timeOffsetMs);
21545
- }
21546
- nodeRemove(compositorId, address, timeOffsetMs) {
21547
- let item = new sesame.v1.commands.CommandListItem();
21548
- item.removeNode = { compositorId, address };
21549
- return this.add(item, timeOffsetMs);
21550
- }
21551
- propertySet(propertyDomain, addr, prop, val, timeOffsetMs) {
21552
- let item = new sesame.v1.commands.CommandListItem();
21553
- item.setProperty = {
21649
+ MediaCodecData2.prototype.codecType = 0;
21650
+ MediaCodecData2.prototype.sampleRate = 0;
21651
+ MediaCodecData2.prototype.timebaseNum = 0;
21652
+ MediaCodecData2.prototype.timebaseDen = 0;
21653
+ MediaCodecData2.prototype.codecProfile = 0;
21654
+ MediaCodecData2.prototype.codecLevel = 0;
21655
+ MediaCodecData2.prototype.width = 0;
21656
+ MediaCodecData2.prototype.height = 0;
21657
+ MediaCodecData2.prototype.channels = 0;
21658
+ MediaCodecData2.prototype.bitDepth = 0;
21659
+ MediaCodecData2.create = function create(properties) {
21660
+ return new MediaCodecData2(properties);
21661
+ };
21662
+ MediaCodecData2.encode = function encode(message, writer) {
21663
+ if (!writer)
21664
+ writer = $Writer.create();
21665
+ if (message.codecType != null && Object.hasOwnProperty.call(message, "codecType"))
21666
+ writer.uint32(
21667
+ /* id 1, wireType 0 =*/
21668
+ 8
21669
+ ).int32(message.codecType);
21670
+ if (message.sampleRate != null && Object.hasOwnProperty.call(message, "sampleRate"))
21671
+ writer.uint32(
21672
+ /* id 2, wireType 0 =*/
21673
+ 16
21674
+ ).uint32(message.sampleRate);
21675
+ if (message.timebaseNum != null && Object.hasOwnProperty.call(message, "timebaseNum"))
21676
+ writer.uint32(
21677
+ /* id 3, wireType 0 =*/
21678
+ 24
21679
+ ).uint32(message.timebaseNum);
21680
+ if (message.timebaseDen != null && Object.hasOwnProperty.call(message, "timebaseDen"))
21681
+ writer.uint32(
21682
+ /* id 4, wireType 0 =*/
21683
+ 32
21684
+ ).uint32(message.timebaseDen);
21685
+ if (message.codecProfile != null && Object.hasOwnProperty.call(message, "codecProfile"))
21686
+ writer.uint32(
21687
+ /* id 5, wireType 0 =*/
21688
+ 40
21689
+ ).uint32(message.codecProfile);
21690
+ if (message.codecLevel != null && Object.hasOwnProperty.call(message, "codecLevel"))
21691
+ writer.uint32(
21692
+ /* id 6, wireType 0 =*/
21693
+ 48
21694
+ ).uint32(message.codecLevel);
21695
+ if (message.width != null && Object.hasOwnProperty.call(message, "width"))
21696
+ writer.uint32(
21697
+ /* id 7, wireType 0 =*/
21698
+ 56
21699
+ ).uint32(message.width);
21700
+ if (message.height != null && Object.hasOwnProperty.call(message, "height"))
21701
+ writer.uint32(
21702
+ /* id 8, wireType 0 =*/
21703
+ 64
21704
+ ).uint32(message.height);
21705
+ if (message.channels != null && Object.hasOwnProperty.call(message, "channels"))
21706
+ writer.uint32(
21707
+ /* id 9, wireType 0 =*/
21708
+ 72
21709
+ ).uint32(message.channels);
21710
+ if (message.bitDepth != null && Object.hasOwnProperty.call(message, "bitDepth"))
21711
+ writer.uint32(
21712
+ /* id 10, wireType 0 =*/
21713
+ 80
21714
+ ).uint32(message.bitDepth);
21715
+ return writer;
21716
+ };
21717
+ MediaCodecData2.encodeDelimited = function encodeDelimited(message, writer) {
21718
+ return this.encode(message, writer).ldelim();
21719
+ };
21720
+ MediaCodecData2.decode = function decode(reader, length, error) {
21721
+ if (!(reader instanceof $Reader))
21722
+ reader = $Reader.create(reader);
21723
+ let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.sesame.v1.wire.MediaCodecData();
21724
+ while (reader.pos < end) {
21725
+ let tag = reader.uint32();
21726
+ if (tag === error)
21727
+ break;
21728
+ switch (tag >>> 3) {
21729
+ case 1: {
21730
+ message.codecType = reader.int32();
21731
+ break;
21732
+ }
21733
+ case 2: {
21734
+ message.sampleRate = reader.uint32();
21735
+ break;
21736
+ }
21737
+ case 3: {
21738
+ message.timebaseNum = reader.uint32();
21739
+ break;
21740
+ }
21741
+ case 4: {
21742
+ message.timebaseDen = reader.uint32();
21743
+ break;
21744
+ }
21745
+ case 5: {
21746
+ message.codecProfile = reader.uint32();
21747
+ break;
21748
+ }
21749
+ case 6: {
21750
+ message.codecLevel = reader.uint32();
21751
+ break;
21752
+ }
21753
+ case 7: {
21754
+ message.width = reader.uint32();
21755
+ break;
21756
+ }
21757
+ case 8: {
21758
+ message.height = reader.uint32();
21759
+ break;
21760
+ }
21761
+ case 9: {
21762
+ message.channels = reader.uint32();
21763
+ break;
21764
+ }
21765
+ case 10: {
21766
+ message.bitDepth = reader.uint32();
21767
+ break;
21768
+ }
21769
+ default:
21770
+ reader.skipType(tag & 7);
21771
+ break;
21772
+ }
21773
+ }
21774
+ return message;
21775
+ };
21776
+ MediaCodecData2.decodeDelimited = function decodeDelimited(reader) {
21777
+ if (!(reader instanceof $Reader))
21778
+ reader = new $Reader(reader);
21779
+ return this.decode(reader, reader.uint32());
21780
+ };
21781
+ MediaCodecData2.verify = function verify(message) {
21782
+ if (typeof message !== "object" || message === null)
21783
+ return "object expected";
21784
+ if (message.codecType != null && message.hasOwnProperty("codecType"))
21785
+ switch (message.codecType) {
21786
+ default:
21787
+ return "codecType: enum value expected";
21788
+ case 0:
21789
+ case 1:
21790
+ case 2:
21791
+ case 3:
21792
+ case 4:
21793
+ case 5:
21794
+ case 64:
21795
+ case 65:
21796
+ case 66:
21797
+ break;
21798
+ }
21799
+ if (message.sampleRate != null && message.hasOwnProperty("sampleRate")) {
21800
+ if (!$util.isInteger(message.sampleRate))
21801
+ return "sampleRate: integer expected";
21802
+ }
21803
+ if (message.timebaseNum != null && message.hasOwnProperty("timebaseNum")) {
21804
+ if (!$util.isInteger(message.timebaseNum))
21805
+ return "timebaseNum: integer expected";
21806
+ }
21807
+ if (message.timebaseDen != null && message.hasOwnProperty("timebaseDen")) {
21808
+ if (!$util.isInteger(message.timebaseDen))
21809
+ return "timebaseDen: integer expected";
21810
+ }
21811
+ if (message.codecProfile != null && message.hasOwnProperty("codecProfile")) {
21812
+ if (!$util.isInteger(message.codecProfile))
21813
+ return "codecProfile: integer expected";
21814
+ }
21815
+ if (message.codecLevel != null && message.hasOwnProperty("codecLevel")) {
21816
+ if (!$util.isInteger(message.codecLevel))
21817
+ return "codecLevel: integer expected";
21818
+ }
21819
+ if (message.width != null && message.hasOwnProperty("width")) {
21820
+ if (!$util.isInteger(message.width))
21821
+ return "width: integer expected";
21822
+ }
21823
+ if (message.height != null && message.hasOwnProperty("height")) {
21824
+ if (!$util.isInteger(message.height))
21825
+ return "height: integer expected";
21826
+ }
21827
+ if (message.channels != null && message.hasOwnProperty("channels")) {
21828
+ if (!$util.isInteger(message.channels))
21829
+ return "channels: integer expected";
21830
+ }
21831
+ if (message.bitDepth != null && message.hasOwnProperty("bitDepth")) {
21832
+ if (!$util.isInteger(message.bitDepth))
21833
+ return "bitDepth: integer expected";
21834
+ }
21835
+ return null;
21836
+ };
21837
+ MediaCodecData2.fromObject = function fromObject(object) {
21838
+ if (object instanceof $root.sesame.v1.wire.MediaCodecData)
21839
+ return object;
21840
+ let message = new $root.sesame.v1.wire.MediaCodecData();
21841
+ switch (object.codecType) {
21842
+ default:
21843
+ if (typeof object.codecType === "number") {
21844
+ message.codecType = object.codecType;
21845
+ break;
21846
+ }
21847
+ break;
21848
+ case "CODEC_TYPE_UNSPECIFIED":
21849
+ case 0:
21850
+ message.codecType = 0;
21851
+ break;
21852
+ case "CODEC_TYPE_VIDEO_VP8":
21853
+ case 1:
21854
+ message.codecType = 1;
21855
+ break;
21856
+ case "CODEC_TYPE_VIDEO_VP9":
21857
+ case 2:
21858
+ message.codecType = 2;
21859
+ break;
21860
+ case "CODEC_TYPE_VIDEO_AVC":
21861
+ case 3:
21862
+ message.codecType = 3;
21863
+ break;
21864
+ case "CODEC_TYPE_VIDEO_HEVC":
21865
+ case 4:
21866
+ message.codecType = 4;
21867
+ break;
21868
+ case "CODEC_TYPE_VIDEO_AV1":
21869
+ case 5:
21870
+ message.codecType = 5;
21871
+ break;
21872
+ case "CODEC_TYPE_AUDIO_OPUS":
21873
+ case 64:
21874
+ message.codecType = 64;
21875
+ break;
21876
+ case "CODEC_TYPE_AUDIO_AAC":
21877
+ case 65:
21878
+ message.codecType = 65;
21879
+ break;
21880
+ case "CODEC_TYPE_AUDIO_PCM":
21881
+ case 66:
21882
+ message.codecType = 66;
21883
+ break;
21884
+ }
21885
+ if (object.sampleRate != null)
21886
+ message.sampleRate = object.sampleRate >>> 0;
21887
+ if (object.timebaseNum != null)
21888
+ message.timebaseNum = object.timebaseNum >>> 0;
21889
+ if (object.timebaseDen != null)
21890
+ message.timebaseDen = object.timebaseDen >>> 0;
21891
+ if (object.codecProfile != null)
21892
+ message.codecProfile = object.codecProfile >>> 0;
21893
+ if (object.codecLevel != null)
21894
+ message.codecLevel = object.codecLevel >>> 0;
21895
+ if (object.width != null)
21896
+ message.width = object.width >>> 0;
21897
+ if (object.height != null)
21898
+ message.height = object.height >>> 0;
21899
+ if (object.channels != null)
21900
+ message.channels = object.channels >>> 0;
21901
+ if (object.bitDepth != null)
21902
+ message.bitDepth = object.bitDepth >>> 0;
21903
+ return message;
21904
+ };
21905
+ MediaCodecData2.toObject = function toObject(message, options) {
21906
+ if (!options)
21907
+ options = {};
21908
+ let object = {};
21909
+ if (options.defaults) {
21910
+ object.codecType = options.enums === String ? "CODEC_TYPE_UNSPECIFIED" : 0;
21911
+ object.sampleRate = 0;
21912
+ object.timebaseNum = 0;
21913
+ object.timebaseDen = 0;
21914
+ object.codecProfile = 0;
21915
+ object.codecLevel = 0;
21916
+ object.width = 0;
21917
+ object.height = 0;
21918
+ object.channels = 0;
21919
+ object.bitDepth = 0;
21920
+ }
21921
+ if (message.codecType != null && message.hasOwnProperty("codecType"))
21922
+ 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;
21923
+ if (message.sampleRate != null && message.hasOwnProperty("sampleRate"))
21924
+ object.sampleRate = message.sampleRate;
21925
+ if (message.timebaseNum != null && message.hasOwnProperty("timebaseNum"))
21926
+ object.timebaseNum = message.timebaseNum;
21927
+ if (message.timebaseDen != null && message.hasOwnProperty("timebaseDen"))
21928
+ object.timebaseDen = message.timebaseDen;
21929
+ if (message.codecProfile != null && message.hasOwnProperty("codecProfile"))
21930
+ object.codecProfile = message.codecProfile;
21931
+ if (message.codecLevel != null && message.hasOwnProperty("codecLevel"))
21932
+ object.codecLevel = message.codecLevel;
21933
+ if (message.width != null && message.hasOwnProperty("width"))
21934
+ object.width = message.width;
21935
+ if (message.height != null && message.hasOwnProperty("height"))
21936
+ object.height = message.height;
21937
+ if (message.channels != null && message.hasOwnProperty("channels"))
21938
+ object.channels = message.channels;
21939
+ if (message.bitDepth != null && message.hasOwnProperty("bitDepth"))
21940
+ object.bitDepth = message.bitDepth;
21941
+ return object;
21942
+ };
21943
+ MediaCodecData2.prototype.toJSON = function toJSON() {
21944
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
21945
+ };
21946
+ MediaCodecData2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
21947
+ if (typeUrlPrefix === void 0) {
21948
+ typeUrlPrefix = "type.googleapis.com";
21949
+ }
21950
+ return typeUrlPrefix + "/sesame.v1.wire.MediaCodecData";
21951
+ };
21952
+ return MediaCodecData2;
21953
+ }();
21954
+ wire.FrameHeader = function() {
21955
+ function FrameHeader2(properties) {
21956
+ if (properties) {
21957
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
21958
+ if (properties[keys[i]] != null)
21959
+ this[keys[i]] = properties[keys[i]];
21960
+ }
21961
+ }
21962
+ FrameHeader2.prototype.type = 0;
21963
+ FrameHeader2.prototype.pts = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
21964
+ FrameHeader2.prototype.id = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
21965
+ FrameHeader2.prototype.keyframe = false;
21966
+ FrameHeader2.prototype.codecData = null;
21967
+ FrameHeader2.prototype.routingMetadata = "";
21968
+ FrameHeader2.create = function create(properties) {
21969
+ return new FrameHeader2(properties);
21970
+ };
21971
+ FrameHeader2.encode = function encode(message, writer) {
21972
+ if (!writer)
21973
+ writer = $Writer.create();
21974
+ if (message.type != null && Object.hasOwnProperty.call(message, "type"))
21975
+ writer.uint32(
21976
+ /* id 1, wireType 0 =*/
21977
+ 8
21978
+ ).int32(message.type);
21979
+ if (message.pts != null && Object.hasOwnProperty.call(message, "pts"))
21980
+ writer.uint32(
21981
+ /* id 2, wireType 0 =*/
21982
+ 16
21983
+ ).uint64(message.pts);
21984
+ if (message.id != null && Object.hasOwnProperty.call(message, "id"))
21985
+ writer.uint32(
21986
+ /* id 3, wireType 0 =*/
21987
+ 24
21988
+ ).uint64(message.id);
21989
+ if (message.keyframe != null && Object.hasOwnProperty.call(message, "keyframe"))
21990
+ writer.uint32(
21991
+ /* id 4, wireType 0 =*/
21992
+ 32
21993
+ ).bool(message.keyframe);
21994
+ if (message.codecData != null && Object.hasOwnProperty.call(message, "codecData"))
21995
+ $root.sesame.v1.wire.MediaCodecData.encode(message.codecData, writer.uint32(
21996
+ /* id 5, wireType 2 =*/
21997
+ 42
21998
+ ).fork()).ldelim();
21999
+ if (message.routingMetadata != null && Object.hasOwnProperty.call(message, "routingMetadata"))
22000
+ writer.uint32(
22001
+ /* id 6, wireType 2 =*/
22002
+ 50
22003
+ ).string(message.routingMetadata);
22004
+ return writer;
22005
+ };
22006
+ FrameHeader2.encodeDelimited = function encodeDelimited(message, writer) {
22007
+ return this.encode(message, writer).ldelim();
22008
+ };
22009
+ FrameHeader2.decode = function decode(reader, length, error) {
22010
+ if (!(reader instanceof $Reader))
22011
+ reader = $Reader.create(reader);
22012
+ let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.sesame.v1.wire.FrameHeader();
22013
+ while (reader.pos < end) {
22014
+ let tag = reader.uint32();
22015
+ if (tag === error)
22016
+ break;
22017
+ switch (tag >>> 3) {
22018
+ case 1: {
22019
+ message.type = reader.int32();
22020
+ break;
22021
+ }
22022
+ case 2: {
22023
+ message.pts = reader.uint64();
22024
+ break;
22025
+ }
22026
+ case 3: {
22027
+ message.id = reader.uint64();
22028
+ break;
22029
+ }
22030
+ case 4: {
22031
+ message.keyframe = reader.bool();
22032
+ break;
22033
+ }
22034
+ case 5: {
22035
+ message.codecData = $root.sesame.v1.wire.MediaCodecData.decode(reader, reader.uint32());
22036
+ break;
22037
+ }
22038
+ case 6: {
22039
+ message.routingMetadata = reader.string();
22040
+ break;
22041
+ }
22042
+ default:
22043
+ reader.skipType(tag & 7);
22044
+ break;
22045
+ }
22046
+ }
22047
+ return message;
22048
+ };
22049
+ FrameHeader2.decodeDelimited = function decodeDelimited(reader) {
22050
+ if (!(reader instanceof $Reader))
22051
+ reader = new $Reader(reader);
22052
+ return this.decode(reader, reader.uint32());
22053
+ };
22054
+ FrameHeader2.verify = function verify(message) {
22055
+ if (typeof message !== "object" || message === null)
22056
+ return "object expected";
22057
+ if (message.type != null && message.hasOwnProperty("type"))
22058
+ switch (message.type) {
22059
+ default:
22060
+ return "type: enum value expected";
22061
+ case 0:
22062
+ case 1:
22063
+ case 2:
22064
+ case 3:
22065
+ case 4:
22066
+ case 5:
22067
+ case 6:
22068
+ break;
22069
+ }
22070
+ if (message.pts != null && message.hasOwnProperty("pts")) {
22071
+ if (!$util.isInteger(message.pts) && !(message.pts && $util.isInteger(message.pts.low) && $util.isInteger(message.pts.high)))
22072
+ return "pts: integer|Long expected";
22073
+ }
22074
+ if (message.id != null && message.hasOwnProperty("id")) {
22075
+ if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high)))
22076
+ return "id: integer|Long expected";
22077
+ }
22078
+ if (message.keyframe != null && message.hasOwnProperty("keyframe")) {
22079
+ if (typeof message.keyframe !== "boolean")
22080
+ return "keyframe: boolean expected";
22081
+ }
22082
+ if (message.codecData != null && message.hasOwnProperty("codecData")) {
22083
+ let error = $root.sesame.v1.wire.MediaCodecData.verify(message.codecData);
22084
+ if (error)
22085
+ return "codecData." + error;
22086
+ }
22087
+ if (message.routingMetadata != null && message.hasOwnProperty("routingMetadata")) {
22088
+ if (!$util.isString(message.routingMetadata))
22089
+ return "routingMetadata: string expected";
22090
+ }
22091
+ return null;
22092
+ };
22093
+ FrameHeader2.fromObject = function fromObject(object) {
22094
+ if (object instanceof $root.sesame.v1.wire.FrameHeader)
22095
+ return object;
22096
+ let message = new $root.sesame.v1.wire.FrameHeader();
22097
+ switch (object.type) {
22098
+ default:
22099
+ if (typeof object.type === "number") {
22100
+ message.type = object.type;
22101
+ break;
22102
+ }
22103
+ break;
22104
+ case "FRAME_TYPE_UNSPECIFIED":
22105
+ case 0:
22106
+ message.type = 0;
22107
+ break;
22108
+ case "FRAME_TYPE_RPC":
22109
+ case 1:
22110
+ message.type = 1;
22111
+ break;
22112
+ case "FRAME_TYPE_VIDEO":
22113
+ case 2:
22114
+ message.type = 2;
22115
+ break;
22116
+ case "FRAME_TYPE_AUDIO":
22117
+ case 3:
22118
+ message.type = 3;
22119
+ break;
22120
+ case "FRAME_TYPE_MUXED":
22121
+ case 4:
22122
+ message.type = 4;
22123
+ break;
22124
+ case "FRAME_TYPE_DECODER_DATA":
22125
+ case 5:
22126
+ message.type = 5;
22127
+ break;
22128
+ case "FRAME_TYPE_DATA":
22129
+ case 6:
22130
+ message.type = 6;
22131
+ break;
22132
+ }
22133
+ if (object.pts != null) {
22134
+ if ($util.Long)
22135
+ (message.pts = $util.Long.fromValue(object.pts)).unsigned = true;
22136
+ else if (typeof object.pts === "string")
22137
+ message.pts = parseInt(object.pts, 10);
22138
+ else if (typeof object.pts === "number")
22139
+ message.pts = object.pts;
22140
+ else if (typeof object.pts === "object")
22141
+ message.pts = new $util.LongBits(object.pts.low >>> 0, object.pts.high >>> 0).toNumber(true);
22142
+ }
22143
+ if (object.id != null) {
22144
+ if ($util.Long)
22145
+ (message.id = $util.Long.fromValue(object.id)).unsigned = true;
22146
+ else if (typeof object.id === "string")
22147
+ message.id = parseInt(object.id, 10);
22148
+ else if (typeof object.id === "number")
22149
+ message.id = object.id;
22150
+ else if (typeof object.id === "object")
22151
+ message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber(true);
22152
+ }
22153
+ if (object.keyframe != null)
22154
+ message.keyframe = Boolean(object.keyframe);
22155
+ if (object.codecData != null) {
22156
+ if (typeof object.codecData !== "object")
22157
+ throw TypeError(".sesame.v1.wire.FrameHeader.codecData: object expected");
22158
+ message.codecData = $root.sesame.v1.wire.MediaCodecData.fromObject(object.codecData);
22159
+ }
22160
+ if (object.routingMetadata != null)
22161
+ message.routingMetadata = String(object.routingMetadata);
22162
+ return message;
22163
+ };
22164
+ FrameHeader2.toObject = function toObject(message, options) {
22165
+ if (!options)
22166
+ options = {};
22167
+ let object = {};
22168
+ if (options.defaults) {
22169
+ object.type = options.enums === String ? "FRAME_TYPE_UNSPECIFIED" : 0;
22170
+ if ($util.Long) {
22171
+ let long = new $util.Long(0, 0, true);
22172
+ object.pts = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
22173
+ } else
22174
+ object.pts = options.longs === String ? "0" : 0;
22175
+ if ($util.Long) {
22176
+ let long = new $util.Long(0, 0, true);
22177
+ object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
22178
+ } else
22179
+ object.id = options.longs === String ? "0" : 0;
22180
+ object.keyframe = false;
22181
+ object.codecData = null;
22182
+ object.routingMetadata = "";
22183
+ }
22184
+ if (message.type != null && message.hasOwnProperty("type"))
22185
+ 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;
22186
+ if (message.pts != null && message.hasOwnProperty("pts"))
22187
+ if (typeof message.pts === "number")
22188
+ object.pts = options.longs === String ? String(message.pts) : message.pts;
22189
+ else
22190
+ 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;
22191
+ if (message.id != null && message.hasOwnProperty("id"))
22192
+ if (typeof message.id === "number")
22193
+ object.id = options.longs === String ? String(message.id) : message.id;
22194
+ else
22195
+ 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;
22196
+ if (message.keyframe != null && message.hasOwnProperty("keyframe"))
22197
+ object.keyframe = message.keyframe;
22198
+ if (message.codecData != null && message.hasOwnProperty("codecData"))
22199
+ object.codecData = $root.sesame.v1.wire.MediaCodecData.toObject(message.codecData, options);
22200
+ if (message.routingMetadata != null && message.hasOwnProperty("routingMetadata"))
22201
+ object.routingMetadata = message.routingMetadata;
22202
+ return object;
22203
+ };
22204
+ FrameHeader2.prototype.toJSON = function toJSON() {
22205
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
22206
+ };
22207
+ FrameHeader2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
22208
+ if (typeUrlPrefix === void 0) {
22209
+ typeUrlPrefix = "type.googleapis.com";
22210
+ }
22211
+ return typeUrlPrefix + "/sesame.v1.wire.FrameHeader";
22212
+ };
22213
+ return FrameHeader2;
22214
+ }();
22215
+ return wire;
22216
+ }();
22217
+ return v1;
22218
+ }();
22219
+ return sesame2;
22220
+ })();
22221
+
22222
+ // src/command-list.ts
22223
+ var CommandList = class {
22224
+ constructor() {
22225
+ this.cl = new sesame.v1.commands.CommandList();
22226
+ this.cl.commandList = [];
22227
+ }
22228
+ add(item, timeOffsetMs, transaction) {
22229
+ item.timeOffsetUs = (timeOffsetMs || 0) * 1e3;
22230
+ if (transaction) {
22231
+ item.transactionDeps = transaction?.dependencies || [];
22232
+ item.transactionId = transaction.transactionId;
22233
+ }
22234
+ this.cl.commandList.push(item);
22235
+ return item;
22236
+ }
22237
+ applyTransaction(transaction) {
22238
+ this.cl.commandList.forEach((item) => {
22239
+ if (transaction.transactionId !== void 0) {
22240
+ item.transactionId = transaction.transactionId;
22241
+ }
22242
+ if (transaction.dependencies !== void 0) {
22243
+ item.transactionDeps = item.transactionDeps ? item.transactionDeps.concat(transaction.dependencies) : transaction.dependencies;
22244
+ }
22245
+ });
22246
+ }
22247
+ getLength() {
22248
+ return this.cl.commandList.length;
22249
+ }
22250
+ filterCreatedAndDestroyedSources() {
22251
+ const created = /* @__PURE__ */ new Map();
22252
+ const createdAndRemoved = [];
22253
+ for (let i = 0; i < this.cl.commandList.length; i++) {
22254
+ if (this.cl.commandList[i].addSource) {
22255
+ created.set(this.cl.commandList[i].addSource.id, this.cl.commandList[i]);
22256
+ } else if (this.cl.commandList[i].removeSource) {
22257
+ const id = this.cl.commandList[i].removeSource.id;
22258
+ if (created.has(id)) {
22259
+ createdAndRemoved.push({ add: created.get(id), del: this.cl.commandList[i] });
22260
+ }
22261
+ }
22262
+ }
22263
+ createdAndRemoved.forEach((item) => {
22264
+ this.cl.commandList.splice(this.cl.commandList.indexOf(item.add), 1);
22265
+ this.cl.commandList.splice(this.cl.commandList.indexOf(item.del), 1);
22266
+ });
22267
+ }
22268
+ getCommandListMsg() {
22269
+ return this.cl;
22270
+ }
22271
+ callback(event, data, timeOffsetMs) {
22272
+ let item = new sesame.v1.commands.CommandListItem();
22273
+ item.callback = { event, data };
22274
+ return this.add(item, timeOffsetMs);
22275
+ }
22276
+ compositorAdd(id, width, height, multisample, timeOffsetMs) {
22277
+ let item = new sesame.v1.commands.CommandListItem();
22278
+ item.addCompositor = { id, multisample, width, height };
22279
+ return this.add(item, timeOffsetMs);
22280
+ }
22281
+ compositorRemove(id, timeOffsetMs) {
22282
+ let item = new sesame.v1.commands.CommandListItem();
22283
+ item.removeCompositor = { id };
22284
+ return this.add(item, timeOffsetMs);
22285
+ }
22286
+ compositorClear(id, timeOffsetMs) {
22287
+ let item = new sesame.v1.commands.CommandListItem();
22288
+ item.clearCompositor = { id };
22289
+ return this.add(item, timeOffsetMs);
22290
+ }
22291
+ sourceAdd(id, cfg, timeOffsetMs) {
22292
+ let item = new sesame.v1.commands.CommandListItem();
22293
+ item.addSource = { id, config: cfg };
22294
+ return this.add(item, timeOffsetMs);
22295
+ }
22296
+ sourceRemove(id, timeOffsetMs) {
22297
+ let item = new sesame.v1.commands.CommandListItem();
22298
+ item.removeSource = { id };
22299
+ return this.add(item, timeOffsetMs);
22300
+ }
22301
+ nodeAdd(id, cfg, timeOffsetMs) {
22302
+ let item = new sesame.v1.commands.CommandListItem();
22303
+ item.addNode = {
22304
+ compositorId: cfg.compositorId,
22305
+ nodeId: id,
22306
+ parentAddress: cfg.parentAddress || "",
22307
+ nodeType: cfg.nodeType
22308
+ };
22309
+ return this.add(item, timeOffsetMs);
22310
+ }
22311
+ nodeRemove(compositorId, address, timeOffsetMs) {
22312
+ let item = new sesame.v1.commands.CommandListItem();
22313
+ item.removeNode = { compositorId, address };
22314
+ return this.add(item, timeOffsetMs);
22315
+ }
22316
+ propertySet(propertyDomain, addr, prop, val, timeOffsetMs) {
22317
+ let item = new sesame.v1.commands.CommandListItem();
22318
+ item.setProperty = {
21554
22319
  address: addr,
21555
22320
  property: prop,
21556
22321
  domain: propertyDomain,
@@ -21888,7 +22653,8 @@ var RPCClient = class extends import_events.EventEmitter {
21888
22653
  eventHandler(event) {
21889
22654
  const topic = event.topic ?? 0;
21890
22655
  if (topic === sesame.v1.common.EventTopic.EVENT_TOPIC_UNSPECIFIED) {
21891
- throw new Error(`Unknown event topic: ${event.topic}`);
22656
+ log.warn(`Ignoring event with unspecified topic: ${event.topic}`);
22657
+ return;
21892
22658
  }
21893
22659
  const type = this.eventTypes[topic];
21894
22660
  let payload;
@@ -21914,255 +22680,58 @@ var RPCClient = class extends import_events.EventEmitter {
21914
22680
  // src/sesame-connection.ts
21915
22681
  var import_events2 = __toESM(require_events());
21916
22682
 
21917
- // src/sesame-binary-protocol.ts
21918
- var PROTOCOL_MAGIC = 1297302867;
21919
- var PROTOCOL_VERSION = 1;
21920
- var HEADER_DATA_SIZE = 32;
21921
- var HEADER_CODEC_DATA_SIZE = 24;
21922
- var HEADER_METADATA_SIZE = 64;
21923
- var FLAG_HAS_CODEC_DATA = 1 << 0;
21924
- var FLAG_HAS_METADATA = 1 << 1;
21925
- var FLAG_IS_KEYFRAME = 1 << 2;
21926
- var PacketType = /* @__PURE__ */ ((PacketType2) => {
21927
- PacketType2[PacketType2["VIDEO_FRAME"] = 1] = "VIDEO_FRAME";
21928
- PacketType2[PacketType2["AUDIO_FRAME"] = 2] = "AUDIO_FRAME";
21929
- PacketType2[PacketType2["RPC"] = 3] = "RPC";
21930
- PacketType2[PacketType2["MUXED_DATA"] = 4] = "MUXED_DATA";
21931
- PacketType2[PacketType2["DECODER_DATA"] = 5] = "DECODER_DATA";
21932
- return PacketType2;
21933
- })(PacketType || {});
21934
- var CodecType = /* @__PURE__ */ ((CodecType2) => {
21935
- CodecType2[CodecType2["VIDEO_VP8"] = 1] = "VIDEO_VP8";
21936
- CodecType2[CodecType2["VIDEO_VP9"] = 2] = "VIDEO_VP9";
21937
- CodecType2[CodecType2["VIDEO_AVC"] = 3] = "VIDEO_AVC";
21938
- CodecType2[CodecType2["VIDEO_HEVC"] = 4] = "VIDEO_HEVC";
21939
- CodecType2[CodecType2["VIDEO_AV1"] = 5] = "VIDEO_AV1";
21940
- CodecType2[CodecType2["AUDIO_OPUS"] = 64] = "AUDIO_OPUS";
21941
- CodecType2[CodecType2["AUDIO_AAC"] = 65] = "AUDIO_AAC";
21942
- CodecType2[CodecType2["AUDIO_PCM"] = 66] = "AUDIO_PCM";
21943
- return CodecType2;
21944
- })(CodecType || {});
21945
- var SesameBinaryProtocol = class {
22683
+ // src/sesame-wire-protocol.ts
22684
+ var FrameType = sesame.v1.wire.FrameType;
22685
+ var FrameHeader = sesame.v1.wire.FrameHeader;
22686
+ var MediaCodecData = sesame.v1.wire.MediaCodecData;
22687
+ var CodecType = sesame.v1.wire.CodecType;
22688
+ var PREFIX_SIZE = 4;
22689
+ var WireProtocol = class {
21946
22690
  /**
21947
- * Initialize a header data structure with proper defaults
22691
+ * Serialize a wire frame: 4-byte LE header_size + protobuf FrameHeader + payload.
21948
22692
  */
21949
- static initHeader(type, flags, pts, id) {
21950
- return {
21951
- magic: PROTOCOL_MAGIC,
21952
- version: PROTOCOL_VERSION,
21953
- header_size: this.calculateHeaderSize(flags),
21954
- type,
21955
- flags,
21956
- pts,
21957
- id,
21958
- reserved: 0
21959
- // Always zero reserved fields
21960
- };
21961
- }
21962
- /**
21963
- * Calculate the total header size based on flags
21964
- */
21965
- static calculateHeaderSize(flags) {
21966
- let size = HEADER_DATA_SIZE;
21967
- if (flags & FLAG_HAS_METADATA) {
21968
- size += HEADER_METADATA_SIZE;
21969
- }
21970
- if (flags & FLAG_HAS_CODEC_DATA) {
21971
- size += HEADER_CODEC_DATA_SIZE;
22693
+ static serialize(header, payload) {
22694
+ const headerBytes = sesame.v1.wire.FrameHeader.encode(header).finish();
22695
+ const headerSize = headerBytes.length;
22696
+ const payloadSize = payload ? payload.length : 0;
22697
+ const total = PREFIX_SIZE + headerSize + payloadSize;
22698
+ const buffer = new Uint8Array(total);
22699
+ const view = new DataView(buffer.buffer);
22700
+ view.setUint32(0, headerSize, true);
22701
+ buffer.set(headerBytes, PREFIX_SIZE);
22702
+ if (payload && payloadSize > 0) {
22703
+ buffer.set(payload, PREFIX_SIZE + headerSize);
21972
22704
  }
21973
- return size;
22705
+ return buffer;
21974
22706
  }
21975
22707
  /**
21976
- * Validate a header structure
22708
+ * Parse an incoming wire frame.
21977
22709
  */
21978
- static validateHeader(header, totalSize) {
21979
- if (header.magic !== PROTOCOL_MAGIC) {
21980
- return false;
22710
+ static parse(data) {
22711
+ const result = { valid: false, header: null, payload: null };
22712
+ if (!data || data.length < PREFIX_SIZE) return result;
22713
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
22714
+ const headerSize = view.getUint32(0, true);
22715
+ if (data.length < PREFIX_SIZE + headerSize) return result;
22716
+ try {
22717
+ const headerBytes = data.subarray(PREFIX_SIZE, PREFIX_SIZE + headerSize);
22718
+ result.header = sesame.v1.wire.FrameHeader.decode(headerBytes);
22719
+ result.payload = data.subarray(PREFIX_SIZE + headerSize);
22720
+ result.valid = true;
22721
+ } catch {
21981
22722
  }
21982
- if (header.version !== PROTOCOL_VERSION) {
21983
- return false;
21984
- }
21985
- const expectedHeaderSize = this.calculateHeaderSize(header.flags);
21986
- if (header.header_size !== expectedHeaderSize) {
21987
- return false;
21988
- }
21989
- if (totalSize < header.header_size) {
21990
- return false;
21991
- }
21992
- return true;
21993
- }
21994
- /**
21995
- * Serialize data into a Uint8Array buffer
21996
- */
21997
- static serialize(header, metadata = null, codecData = null, payload = null) {
21998
- const includeMetadata = metadata !== null && header.flags & FLAG_HAS_METADATA;
21999
- const includeCodec = codecData !== null && header.flags & FLAG_HAS_CODEC_DATA;
22000
- let totalSize = HEADER_DATA_SIZE;
22001
- if (includeMetadata) totalSize += HEADER_METADATA_SIZE;
22002
- if (includeCodec) totalSize += HEADER_CODEC_DATA_SIZE;
22003
- if (payload) totalSize += payload.length;
22004
- header.header_size = totalSize - (payload ? payload.length : 0);
22005
- const buffer = new ArrayBuffer(totalSize);
22006
- const view = new DataView(buffer);
22007
- let offset = 0;
22008
- view.setUint32(offset, header.magic, true);
22009
- offset += 4;
22010
- view.setUint32(offset, header.flags, true);
22011
- offset += 4;
22012
- view.setBigUint64(offset, header.pts, true);
22013
- offset += 8;
22014
- view.setBigUint64(offset, header.id, true);
22015
- offset += 8;
22016
- view.setUint16(offset, header.version, true);
22017
- offset += 2;
22018
- view.setUint16(offset, header.header_size, true);
22019
- offset += 2;
22020
- view.setUint16(offset, header.type, true);
22021
- offset += 2;
22022
- view.setUint16(offset, header.reserved, true);
22023
- offset += 2;
22024
- if (includeMetadata && metadata) {
22025
- const metadataBytes = this.stringToFixedBytes(metadata.metadata, 64);
22026
- new Uint8Array(buffer, offset, 64).set(metadataBytes);
22027
- offset += 64;
22028
- }
22029
- if (includeCodec && codecData) {
22030
- view.setUint32(offset, codecData.sample_rate, true);
22031
- offset += 4;
22032
- view.setUint32(offset, codecData.timebase_num, true);
22033
- offset += 4;
22034
- view.setUint32(offset, codecData.timebase_den, true);
22035
- offset += 4;
22036
- view.setUint16(offset, codecData.codec_profile, true);
22037
- offset += 2;
22038
- view.setUint16(offset, codecData.codec_level, true);
22039
- offset += 2;
22040
- view.setUint16(offset, codecData.width, true);
22041
- offset += 2;
22042
- view.setUint16(offset, codecData.height, true);
22043
- offset += 2;
22044
- view.setUint8(offset, codecData.codec_type);
22045
- offset += 1;
22046
- view.setUint8(offset, codecData.channels);
22047
- offset += 1;
22048
- view.setUint8(offset, codecData.bit_depth);
22049
- offset += 1;
22050
- view.setUint8(offset, codecData.reserved);
22051
- offset += 1;
22052
- }
22053
- if (payload && payload.length > 0) {
22054
- new Uint8Array(buffer, offset).set(payload);
22055
- }
22056
- return new Uint8Array(buffer);
22057
- }
22058
- /**
22059
- * Parse incoming binary data
22060
- */
22061
- static parseData(data) {
22062
- const result = {
22063
- valid: false,
22064
- header: null,
22065
- metadata: null,
22066
- codec_data: null,
22067
- payload: null,
22068
- payload_size: 0
22069
- };
22070
- if (!data || data.length < 36) {
22071
- return result;
22072
- }
22073
- const view = new DataView(data.buffer, data.byteOffset);
22074
- let offset = 0;
22075
- const header = {
22076
- magic: view.getUint32(offset, true),
22077
- flags: view.getUint32(offset + 4, true),
22078
- pts: view.getBigUint64(offset + 8, true),
22079
- id: view.getBigUint64(offset + 16, true),
22080
- version: view.getUint16(offset + 24, true),
22081
- header_size: view.getUint16(offset + 26, true),
22082
- type: view.getUint16(offset + 28, true),
22083
- reserved: view.getUint16(offset + 30, true)
22084
- };
22085
- offset += HEADER_DATA_SIZE;
22086
- if (!this.validateHeader(header, data.length)) {
22087
- return result;
22088
- }
22089
- result.header = header;
22090
- if (header.flags & FLAG_HAS_METADATA) {
22091
- if (data.length < offset + HEADER_METADATA_SIZE) {
22092
- return result;
22093
- }
22094
- const metadataBytes = data.slice(offset, offset + HEADER_METADATA_SIZE);
22095
- const metadataStr = this.fixedBytesToString(metadataBytes);
22096
- result.metadata = { metadata: metadataStr };
22097
- offset += HEADER_METADATA_SIZE;
22098
- }
22099
- if (header.flags & FLAG_HAS_CODEC_DATA) {
22100
- if (data.length < offset + HEADER_CODEC_DATA_SIZE) {
22101
- return result;
22102
- }
22103
- result.codec_data = {
22104
- sample_rate: view.getUint32(offset, true),
22105
- timebase_num: view.getUint32(offset + 4, true),
22106
- timebase_den: view.getUint32(offset + 8, true),
22107
- codec_profile: view.getUint16(offset + 12, true),
22108
- codec_level: view.getUint16(offset + 14, true),
22109
- width: view.getUint16(offset + 16, true),
22110
- height: view.getUint16(offset + 18, true),
22111
- codec_type: view.getUint8(offset + 20),
22112
- channels: view.getUint8(offset + 21),
22113
- bit_depth: view.getUint8(offset + 22),
22114
- reserved: view.getUint8(offset + 23)
22115
- };
22116
- offset += HEADER_CODEC_DATA_SIZE;
22117
- }
22118
- if (offset < data.length) {
22119
- result.payload = data.slice(offset);
22120
- result.payload_size = result.payload.length;
22121
- } else {
22122
- result.payload = new Uint8Array(0);
22123
- result.payload_size = 0;
22124
- }
22125
- result.valid = true;
22126
22723
  return result;
22127
22724
  }
22128
- /**
22129
- * Helper: Convert string to fixed-size byte array (null-terminated)
22130
- */
22131
- static stringToFixedBytes(str, size) {
22132
- const bytes = new Uint8Array(size);
22133
- let encoded;
22134
- if (typeof TextEncoder !== "undefined") {
22135
- const encoder = new TextEncoder();
22136
- encoded = encoder.encode(str);
22137
- } else {
22138
- encoded = new Uint8Array(Buffer.from(str, "utf8"));
22139
- }
22140
- const copyLen = Math.min(encoded.length, size - 1);
22141
- bytes.set(encoded.slice(0, copyLen));
22142
- bytes[copyLen] = 0;
22143
- return bytes;
22144
- }
22145
- /**
22146
- * Helper: Convert fixed-size byte array to string (null-terminated)
22147
- */
22148
- static fixedBytesToString(bytes) {
22149
- let len = bytes.length;
22150
- for (let i = 0; i < bytes.length; i++) {
22151
- if (bytes[i] === 0) {
22152
- len = i;
22153
- break;
22154
- }
22155
- }
22156
- if (typeof TextDecoder !== "undefined") {
22157
- const decoder = new TextDecoder();
22158
- return decoder.decode(bytes.slice(0, len));
22159
- } else {
22160
- return Buffer.from(bytes.slice(0, len)).toString("utf8");
22161
- }
22162
- }
22163
22725
  };
22164
22726
 
22165
22727
  // src/sesame-connection.ts
22728
+ var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
22729
+ ConnectionState2["Disconnected"] = "disconnected";
22730
+ ConnectionState2["Connecting"] = "connecting";
22731
+ ConnectionState2["Connected"] = "connected";
22732
+ ConnectionState2["Reconnecting"] = "reconnecting";
22733
+ return ConnectionState2;
22734
+ })(ConnectionState || {});
22166
22735
  function waitForEvent(emitter, eventName) {
22167
22736
  return new Promise((resolve) => {
22168
22737
  emitter.once(eventName, resolve);
@@ -22175,6 +22744,7 @@ var SesameConnection = class extends import_events2.EventEmitter {
22175
22744
  this.numRetries = 0;
22176
22745
  this.url = "";
22177
22746
  this.autoReconnect = true;
22747
+ this._state = "disconnected" /* Disconnected */;
22178
22748
  /* Bound listeners so we can removeEventListener later */
22179
22749
  this.boundMessageHandler = (event) => this.messageHandler(event);
22180
22750
  this.boundOpenHandler = () => this.openHandler();
@@ -22182,38 +22752,68 @@ var SesameConnection = class extends import_events2.EventEmitter {
22182
22752
  this.boundErrorHandler = (event) => this.errorHandler(event);
22183
22753
  this.openHandler = () => {
22184
22754
  this.numRetries = 0;
22755
+ this.setState("connected" /* Connected */);
22185
22756
  this.emit("open");
22186
22757
  };
22187
22758
  this.messageHandler = (event) => {
22188
22759
  if (event.data instanceof ArrayBuffer) {
22189
- const parsed = SesameBinaryProtocol.parseData(new Uint8Array(event.data));
22190
- if (!parsed.valid) this.emit("error", new Error("Invalid packet received"));
22191
- if (parsed.header?.type == 1 /* VIDEO_FRAME */) {
22192
- this.emit("video-packet", event.data);
22193
- } else if (parsed.header?.type == 2 /* AUDIO_FRAME */) {
22194
- this.emit("audio-packet", event.data);
22195
- } else if (parsed.header?.type == 3 /* RPC */) {
22760
+ const parsed = WireProtocol.parse(new Uint8Array(event.data));
22761
+ if (!parsed.valid) {
22762
+ this.emit("error", new Error("Invalid packet received"));
22763
+ return;
22764
+ }
22765
+ const frameType = parsed.header?.type;
22766
+ if (frameType === FrameType.FRAME_TYPE_RPC) {
22196
22767
  this.emit("rpc", parsed.payload);
22768
+ } else {
22769
+ this.emit("media-packet", parsed);
22197
22770
  }
22198
22771
  }
22199
22772
  };
22200
22773
  this.url = options.url;
22201
22774
  this.autoReconnect = options.autoReconnect;
22202
- if (options.autoConnect) this.connect().catch(() => log.debug("failed connect"));
22775
+ if (options.autoConnect) this.connect().catch(() => {
22776
+ });
22777
+ }
22778
+ get state() {
22779
+ return this._state;
22780
+ }
22781
+ setState(newState) {
22782
+ if (this._state === newState) return;
22783
+ const prev = this._state;
22784
+ this._state = newState;
22785
+ switch (newState) {
22786
+ case "connected" /* Connected */:
22787
+ log.info("Connected to Sesame");
22788
+ break;
22789
+ case "reconnecting" /* Reconnecting */:
22790
+ if (prev === "connected" /* Connected */) {
22791
+ log.warn("Lost connection to Sesame, will try reconnect..");
22792
+ } else {
22793
+ log.warn("Failed to connect to Sesame, will try reconnect..");
22794
+ }
22795
+ break;
22796
+ case "disconnected" /* Disconnected */:
22797
+ log.info("Disconnected from Sesame");
22798
+ break;
22799
+ }
22800
+ this.emit("state", newState, prev);
22203
22801
  }
22204
22802
  isConnected() {
22205
22803
  return this.socket !== void 0 && this.socket.readyState === WebSocket.OPEN;
22206
22804
  }
22207
22805
  async send(data) {
22208
22806
  if (!this.isConnected()) throw new Error("Not connected");
22209
- const header = SesameBinaryProtocol.initHeader(3 /* RPC */, 0, BigInt(0), BigInt(0));
22210
- const data_to_send = SesameBinaryProtocol.serialize(header, null, null, data);
22211
- if (!data_to_send) throw new Error("Failed to serialize data");
22212
- this.socket.send(data_to_send);
22807
+ const header = { type: sesame.v1.wire.FrameType.FRAME_TYPE_RPC };
22808
+ const frame = WireProtocol.serialize(header, data);
22809
+ this.socket.send(frame);
22213
22810
  return Promise.resolve();
22214
22811
  }
22215
22812
  async connect() {
22216
22813
  this.active = true;
22814
+ if (this._state === "disconnected" /* Disconnected */) {
22815
+ this.setState("connecting" /* Connecting */);
22816
+ }
22217
22817
  this.socket = new WebSocket(this.url);
22218
22818
  this.socket.addEventListener("message", this.boundMessageHandler);
22219
22819
  this.socket.addEventListener("open", this.boundOpenHandler);
@@ -22236,6 +22836,7 @@ var SesameConnection = class extends import_events2.EventEmitter {
22236
22836
  async disconnect() {
22237
22837
  this.active = false;
22238
22838
  if (!this.socket) {
22839
+ this.setState("disconnected" /* Disconnected */);
22239
22840
  return;
22240
22841
  }
22241
22842
  const sock = this.socket;
@@ -22253,7 +22854,8 @@ var SesameConnection = class extends import_events2.EventEmitter {
22253
22854
  }
22254
22855
  retryHandler() {
22255
22856
  if (this.active && this.autoReconnect) {
22256
- this.connect().catch((err) => log.error("Retry failed", err));
22857
+ this.connect().catch(() => {
22858
+ });
22257
22859
  }
22258
22860
  }
22259
22861
  closeHandler() {
@@ -22263,13 +22865,17 @@ var SesameConnection = class extends import_events2.EventEmitter {
22263
22865
  }
22264
22866
  this.socket = void 0;
22265
22867
  if (this.active) {
22266
- try {
22868
+ if (this.autoReconnect) {
22869
+ this.setState("reconnecting" /* Reconnecting */);
22267
22870
  setTimeout(() => {
22268
22871
  this.retryHandler();
22269
22872
  }, defaultBackoff(++this.numRetries));
22270
- } catch (err) {
22271
- log.error("Connection error", err);
22873
+ } else {
22874
+ this.active = false;
22875
+ this.setState("disconnected" /* Disconnected */);
22272
22876
  }
22877
+ } else {
22878
+ this.setState("disconnected" /* Disconnected */);
22273
22879
  }
22274
22880
  }
22275
22881
  errorHandler(error) {
@@ -22295,9 +22901,6 @@ var StatusApi = class {
22295
22901
  async getIODevices() {
22296
22902
  return this.rpc.service.requestIODeviceList(new sesame.v1.common.Empty());
22297
22903
  }
22298
- async requestKeyframe(outputId) {
22299
- await this.rpc.service.requestKeyframe({ id: outputId });
22300
- }
22301
22904
  };
22302
22905
 
22303
22906
  // src/recorder-api.ts
@@ -22446,10 +23049,7 @@ var SesameClient = class extends import_events3.EventEmitter {
22446
23049
  constructor(portOrUrl) {
22447
23050
  super();
22448
23051
  this.subscriptions = [];
22449
- this.errorIsLogged = false;
22450
- this.onVideoPacket = () => {
22451
- };
22452
- this.onAudioPacket = () => {
23052
+ this.onMediaPacket = () => {
22453
23053
  };
22454
23054
  this.onCallbackMessage = () => {
22455
23055
  };
@@ -22460,10 +23060,6 @@ var SesameClient = class extends import_events3.EventEmitter {
22460
23060
  autoReconnect: true
22461
23061
  });
22462
23062
  this.conn.on("error", () => {
22463
- if (!this.errorIsLogged) {
22464
- log.warn("Could not connect to Sesame Engine, will keep trying..");
22465
- this.errorIsLogged = true;
22466
- }
22467
23063
  });
22468
23064
  let events = {
22469
23065
  [sesame.v1.common.EventTopic.EVENT_TOPIC_ERROR]: sesame.v1.status.Event,
@@ -22488,18 +23084,18 @@ var SesameClient = class extends import_events3.EventEmitter {
22488
23084
  }
22489
23085
  });
22490
23086
  this.rpc.on("error", (err) => {
22491
- log.error(`RPC error: ${err.message}`);
23087
+ if (this.isConnected()) {
23088
+ log.error(`RPC error: ${err.message}`);
23089
+ }
22492
23090
  });
22493
23091
  this.conn.on("open", async () => {
22494
23092
  this.sendSubscriptions();
22495
- this.errorIsLogged = false;
22496
23093
  this.emit("connected");
22497
23094
  });
22498
23095
  this.conn.on("close", () => {
22499
23096
  this.emit("disconnected");
22500
23097
  });
22501
- this.conn.on("video-packet", (data) => this.onVideoPacket(this.videoSubscriptionId, data));
22502
- this.conn.on("audio-packet", (data) => this.onAudioPacket(this.videoSubscriptionId, data));
23098
+ this.conn.on("media-packet", (frame) => this.onMediaPacket(this.mediaSubscriptionId, frame));
22503
23099
  this.subscriptions = [];
22504
23100
  }
22505
23101
  isConnected() {
@@ -22509,14 +23105,14 @@ var SesameClient = class extends import_events3.EventEmitter {
22509
23105
  if (!this.isConnected()) return;
22510
23106
  const eventTopics = this.subscriptions.map((subscription) => subscription.topic);
22511
23107
  const channels = [];
22512
- if (this.videoSubscriptionId) channels.push(`video/${this.videoSubscriptionId}`);
23108
+ if (this.mediaSubscriptionId) channels.push(`media-stream/${this.mediaSubscriptionId}`);
22513
23109
  let subs = { eventTopics, channels };
22514
23110
  this.rpc.service.updateSubscriptions(subs).catch((err) => {
22515
23111
  log.error(`Failed to update subscriptions: ${err.message}`);
22516
23112
  });
22517
23113
  }
22518
- addVideoSubscription(id) {
22519
- this.videoSubscriptionId = id;
23114
+ addMediaSubscription(id) {
23115
+ this.mediaSubscriptionId = id;
22520
23116
  this.sendSubscriptions();
22521
23117
  }
22522
23118
  addSubscription(topic, callback) {
@@ -22535,6 +23131,9 @@ var SesameClient = class extends import_events3.EventEmitter {
22535
23131
  getService() {
22536
23132
  return this.rpc;
22537
23133
  }
23134
+ async requestKeyframe(outputId) {
23135
+ await this.rpc.service.requestKeyframe({ id: outputId });
23136
+ }
22538
23137
  async execute(cl) {
22539
23138
  cl.filterCreatedAndDestroyedSources();
22540
23139
  if (cl.getCommandListMsg().commandList.length > 0) {
@@ -22554,19 +23153,21 @@ var Event = sesame.v1.rpc.Event;
22554
23153
  export {
22555
23154
  CodecType,
22556
23155
  CommandList,
23156
+ ConnectionState,
22557
23157
  EaseKind,
22558
23158
  Event,
23159
+ FrameHeader,
23160
+ FrameType,
22559
23161
  JobsApi,
22560
23162
  Message,
22561
- PacketType,
22562
23163
  RPCClient,
22563
23164
  RecorderApi,
22564
23165
  Request,
22565
23166
  Response,
22566
- SesameBinaryProtocol,
22567
23167
  SesameClient,
22568
23168
  SesameConnection,
22569
23169
  StatusApi,
23170
+ WireProtocol,
22570
23171
  getLogger,
22571
23172
  log,
22572
23173
  sesame,