@stinkycomputing/sesame-api-client 1.4.1-alpha.9 → 1.4.1-beta.1
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/README.md +59 -137
- package/dist/index.browser.mjs +706 -274
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.cjs +710 -276
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +706 -274
- package/dist/index.mjs.map +4 -4
- package/dist/proto/api.d.ts +305 -0
- package/dist/proto/api.js +922 -0
- package/dist/rpc-client.d.ts.map +1 -1
- package/dist/sesame-api-client.d.ts +5 -6
- package/dist/sesame-api-client.d.ts.map +1 -1
- package/dist/sesame-connection.d.ts +11 -2
- package/dist/sesame-connection.d.ts.map +1 -1
- package/dist/sesame-wire-protocol.d.ts +29 -0
- package/dist/sesame-wire-protocol.d.ts.map +1 -0
- package/dist/status-api.d.ts +0 -1
- package/dist/status-api.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -32,19 +32,21 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
CodecType: () => CodecType,
|
|
34
34
|
CommandList: () => CommandList,
|
|
35
|
+
ConnectionState: () => ConnectionState,
|
|
35
36
|
EaseKind: () => EaseKind,
|
|
36
37
|
Event: () => Event,
|
|
38
|
+
FrameHeader: () => FrameHeader,
|
|
39
|
+
FrameType: () => FrameType,
|
|
37
40
|
JobsApi: () => JobsApi,
|
|
38
41
|
Message: () => Message,
|
|
39
|
-
PacketType: () => PacketType,
|
|
40
42
|
RPCClient: () => RPCClient,
|
|
41
43
|
RecorderApi: () => RecorderApi,
|
|
42
44
|
Request: () => Request,
|
|
43
45
|
Response: () => Response,
|
|
44
|
-
SesameBinaryProtocol: () => SesameBinaryProtocol,
|
|
45
46
|
SesameClient: () => SesameClient,
|
|
46
47
|
SesameConnection: () => SesameConnection,
|
|
47
48
|
StatusApi: () => StatusApi,
|
|
49
|
+
WireProtocol: () => WireProtocol,
|
|
48
50
|
getLogger: () => getLogger,
|
|
49
51
|
log: () => log,
|
|
50
52
|
sesame: () => sesame,
|
|
@@ -21109,6 +21111,602 @@ var sesame = $root.sesame = (() => {
|
|
|
21109
21111
|
}();
|
|
21110
21112
|
return rpc;
|
|
21111
21113
|
}();
|
|
21114
|
+
v1.wire = function() {
|
|
21115
|
+
const wire = {};
|
|
21116
|
+
wire.FrameType = function() {
|
|
21117
|
+
const valuesById = {}, values = Object.create(valuesById);
|
|
21118
|
+
values[valuesById[0] = "FRAME_TYPE_UNSPECIFIED"] = 0;
|
|
21119
|
+
values[valuesById[1] = "FRAME_TYPE_RPC"] = 1;
|
|
21120
|
+
values[valuesById[2] = "FRAME_TYPE_VIDEO"] = 2;
|
|
21121
|
+
values[valuesById[3] = "FRAME_TYPE_AUDIO"] = 3;
|
|
21122
|
+
values[valuesById[4] = "FRAME_TYPE_MUXED"] = 4;
|
|
21123
|
+
values[valuesById[5] = "FRAME_TYPE_DECODER_DATA"] = 5;
|
|
21124
|
+
return values;
|
|
21125
|
+
}();
|
|
21126
|
+
wire.CodecType = function() {
|
|
21127
|
+
const valuesById = {}, values = Object.create(valuesById);
|
|
21128
|
+
values[valuesById[0] = "CODEC_TYPE_UNSPECIFIED"] = 0;
|
|
21129
|
+
values[valuesById[1] = "CODEC_TYPE_VIDEO_VP8"] = 1;
|
|
21130
|
+
values[valuesById[2] = "CODEC_TYPE_VIDEO_VP9"] = 2;
|
|
21131
|
+
values[valuesById[3] = "CODEC_TYPE_VIDEO_AVC"] = 3;
|
|
21132
|
+
values[valuesById[4] = "CODEC_TYPE_VIDEO_HEVC"] = 4;
|
|
21133
|
+
values[valuesById[5] = "CODEC_TYPE_VIDEO_AV1"] = 5;
|
|
21134
|
+
values[valuesById[64] = "CODEC_TYPE_AUDIO_OPUS"] = 64;
|
|
21135
|
+
values[valuesById[65] = "CODEC_TYPE_AUDIO_AAC"] = 65;
|
|
21136
|
+
values[valuesById[66] = "CODEC_TYPE_AUDIO_PCM"] = 66;
|
|
21137
|
+
return values;
|
|
21138
|
+
}();
|
|
21139
|
+
wire.MediaCodecData = function() {
|
|
21140
|
+
function MediaCodecData2(properties) {
|
|
21141
|
+
if (properties) {
|
|
21142
|
+
for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
21143
|
+
if (properties[keys[i]] != null)
|
|
21144
|
+
this[keys[i]] = properties[keys[i]];
|
|
21145
|
+
}
|
|
21146
|
+
}
|
|
21147
|
+
MediaCodecData2.prototype.codecType = 0;
|
|
21148
|
+
MediaCodecData2.prototype.sampleRate = 0;
|
|
21149
|
+
MediaCodecData2.prototype.timebaseNum = 0;
|
|
21150
|
+
MediaCodecData2.prototype.timebaseDen = 0;
|
|
21151
|
+
MediaCodecData2.prototype.codecProfile = 0;
|
|
21152
|
+
MediaCodecData2.prototype.codecLevel = 0;
|
|
21153
|
+
MediaCodecData2.prototype.width = 0;
|
|
21154
|
+
MediaCodecData2.prototype.height = 0;
|
|
21155
|
+
MediaCodecData2.prototype.channels = 0;
|
|
21156
|
+
MediaCodecData2.prototype.bitDepth = 0;
|
|
21157
|
+
MediaCodecData2.create = function create(properties) {
|
|
21158
|
+
return new MediaCodecData2(properties);
|
|
21159
|
+
};
|
|
21160
|
+
MediaCodecData2.encode = function encode(message, writer) {
|
|
21161
|
+
if (!writer)
|
|
21162
|
+
writer = $Writer.create();
|
|
21163
|
+
if (message.codecType != null && Object.hasOwnProperty.call(message, "codecType"))
|
|
21164
|
+
writer.uint32(
|
|
21165
|
+
/* id 1, wireType 0 =*/
|
|
21166
|
+
8
|
|
21167
|
+
).int32(message.codecType);
|
|
21168
|
+
if (message.sampleRate != null && Object.hasOwnProperty.call(message, "sampleRate"))
|
|
21169
|
+
writer.uint32(
|
|
21170
|
+
/* id 2, wireType 0 =*/
|
|
21171
|
+
16
|
|
21172
|
+
).uint32(message.sampleRate);
|
|
21173
|
+
if (message.timebaseNum != null && Object.hasOwnProperty.call(message, "timebaseNum"))
|
|
21174
|
+
writer.uint32(
|
|
21175
|
+
/* id 3, wireType 0 =*/
|
|
21176
|
+
24
|
|
21177
|
+
).uint32(message.timebaseNum);
|
|
21178
|
+
if (message.timebaseDen != null && Object.hasOwnProperty.call(message, "timebaseDen"))
|
|
21179
|
+
writer.uint32(
|
|
21180
|
+
/* id 4, wireType 0 =*/
|
|
21181
|
+
32
|
|
21182
|
+
).uint32(message.timebaseDen);
|
|
21183
|
+
if (message.codecProfile != null && Object.hasOwnProperty.call(message, "codecProfile"))
|
|
21184
|
+
writer.uint32(
|
|
21185
|
+
/* id 5, wireType 0 =*/
|
|
21186
|
+
40
|
|
21187
|
+
).uint32(message.codecProfile);
|
|
21188
|
+
if (message.codecLevel != null && Object.hasOwnProperty.call(message, "codecLevel"))
|
|
21189
|
+
writer.uint32(
|
|
21190
|
+
/* id 6, wireType 0 =*/
|
|
21191
|
+
48
|
|
21192
|
+
).uint32(message.codecLevel);
|
|
21193
|
+
if (message.width != null && Object.hasOwnProperty.call(message, "width"))
|
|
21194
|
+
writer.uint32(
|
|
21195
|
+
/* id 7, wireType 0 =*/
|
|
21196
|
+
56
|
|
21197
|
+
).uint32(message.width);
|
|
21198
|
+
if (message.height != null && Object.hasOwnProperty.call(message, "height"))
|
|
21199
|
+
writer.uint32(
|
|
21200
|
+
/* id 8, wireType 0 =*/
|
|
21201
|
+
64
|
|
21202
|
+
).uint32(message.height);
|
|
21203
|
+
if (message.channels != null && Object.hasOwnProperty.call(message, "channels"))
|
|
21204
|
+
writer.uint32(
|
|
21205
|
+
/* id 9, wireType 0 =*/
|
|
21206
|
+
72
|
|
21207
|
+
).uint32(message.channels);
|
|
21208
|
+
if (message.bitDepth != null && Object.hasOwnProperty.call(message, "bitDepth"))
|
|
21209
|
+
writer.uint32(
|
|
21210
|
+
/* id 10, wireType 0 =*/
|
|
21211
|
+
80
|
|
21212
|
+
).uint32(message.bitDepth);
|
|
21213
|
+
return writer;
|
|
21214
|
+
};
|
|
21215
|
+
MediaCodecData2.encodeDelimited = function encodeDelimited(message, writer) {
|
|
21216
|
+
return this.encode(message, writer).ldelim();
|
|
21217
|
+
};
|
|
21218
|
+
MediaCodecData2.decode = function decode(reader, length, error) {
|
|
21219
|
+
if (!(reader instanceof $Reader))
|
|
21220
|
+
reader = $Reader.create(reader);
|
|
21221
|
+
let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.sesame.v1.wire.MediaCodecData();
|
|
21222
|
+
while (reader.pos < end) {
|
|
21223
|
+
let tag = reader.uint32();
|
|
21224
|
+
if (tag === error)
|
|
21225
|
+
break;
|
|
21226
|
+
switch (tag >>> 3) {
|
|
21227
|
+
case 1: {
|
|
21228
|
+
message.codecType = reader.int32();
|
|
21229
|
+
break;
|
|
21230
|
+
}
|
|
21231
|
+
case 2: {
|
|
21232
|
+
message.sampleRate = reader.uint32();
|
|
21233
|
+
break;
|
|
21234
|
+
}
|
|
21235
|
+
case 3: {
|
|
21236
|
+
message.timebaseNum = reader.uint32();
|
|
21237
|
+
break;
|
|
21238
|
+
}
|
|
21239
|
+
case 4: {
|
|
21240
|
+
message.timebaseDen = reader.uint32();
|
|
21241
|
+
break;
|
|
21242
|
+
}
|
|
21243
|
+
case 5: {
|
|
21244
|
+
message.codecProfile = reader.uint32();
|
|
21245
|
+
break;
|
|
21246
|
+
}
|
|
21247
|
+
case 6: {
|
|
21248
|
+
message.codecLevel = reader.uint32();
|
|
21249
|
+
break;
|
|
21250
|
+
}
|
|
21251
|
+
case 7: {
|
|
21252
|
+
message.width = reader.uint32();
|
|
21253
|
+
break;
|
|
21254
|
+
}
|
|
21255
|
+
case 8: {
|
|
21256
|
+
message.height = reader.uint32();
|
|
21257
|
+
break;
|
|
21258
|
+
}
|
|
21259
|
+
case 9: {
|
|
21260
|
+
message.channels = reader.uint32();
|
|
21261
|
+
break;
|
|
21262
|
+
}
|
|
21263
|
+
case 10: {
|
|
21264
|
+
message.bitDepth = reader.uint32();
|
|
21265
|
+
break;
|
|
21266
|
+
}
|
|
21267
|
+
default:
|
|
21268
|
+
reader.skipType(tag & 7);
|
|
21269
|
+
break;
|
|
21270
|
+
}
|
|
21271
|
+
}
|
|
21272
|
+
return message;
|
|
21273
|
+
};
|
|
21274
|
+
MediaCodecData2.decodeDelimited = function decodeDelimited(reader) {
|
|
21275
|
+
if (!(reader instanceof $Reader))
|
|
21276
|
+
reader = new $Reader(reader);
|
|
21277
|
+
return this.decode(reader, reader.uint32());
|
|
21278
|
+
};
|
|
21279
|
+
MediaCodecData2.verify = function verify(message) {
|
|
21280
|
+
if (typeof message !== "object" || message === null)
|
|
21281
|
+
return "object expected";
|
|
21282
|
+
if (message.codecType != null && message.hasOwnProperty("codecType"))
|
|
21283
|
+
switch (message.codecType) {
|
|
21284
|
+
default:
|
|
21285
|
+
return "codecType: enum value expected";
|
|
21286
|
+
case 0:
|
|
21287
|
+
case 1:
|
|
21288
|
+
case 2:
|
|
21289
|
+
case 3:
|
|
21290
|
+
case 4:
|
|
21291
|
+
case 5:
|
|
21292
|
+
case 64:
|
|
21293
|
+
case 65:
|
|
21294
|
+
case 66:
|
|
21295
|
+
break;
|
|
21296
|
+
}
|
|
21297
|
+
if (message.sampleRate != null && message.hasOwnProperty("sampleRate")) {
|
|
21298
|
+
if (!$util.isInteger(message.sampleRate))
|
|
21299
|
+
return "sampleRate: integer expected";
|
|
21300
|
+
}
|
|
21301
|
+
if (message.timebaseNum != null && message.hasOwnProperty("timebaseNum")) {
|
|
21302
|
+
if (!$util.isInteger(message.timebaseNum))
|
|
21303
|
+
return "timebaseNum: integer expected";
|
|
21304
|
+
}
|
|
21305
|
+
if (message.timebaseDen != null && message.hasOwnProperty("timebaseDen")) {
|
|
21306
|
+
if (!$util.isInteger(message.timebaseDen))
|
|
21307
|
+
return "timebaseDen: integer expected";
|
|
21308
|
+
}
|
|
21309
|
+
if (message.codecProfile != null && message.hasOwnProperty("codecProfile")) {
|
|
21310
|
+
if (!$util.isInteger(message.codecProfile))
|
|
21311
|
+
return "codecProfile: integer expected";
|
|
21312
|
+
}
|
|
21313
|
+
if (message.codecLevel != null && message.hasOwnProperty("codecLevel")) {
|
|
21314
|
+
if (!$util.isInteger(message.codecLevel))
|
|
21315
|
+
return "codecLevel: integer expected";
|
|
21316
|
+
}
|
|
21317
|
+
if (message.width != null && message.hasOwnProperty("width")) {
|
|
21318
|
+
if (!$util.isInteger(message.width))
|
|
21319
|
+
return "width: integer expected";
|
|
21320
|
+
}
|
|
21321
|
+
if (message.height != null && message.hasOwnProperty("height")) {
|
|
21322
|
+
if (!$util.isInteger(message.height))
|
|
21323
|
+
return "height: integer expected";
|
|
21324
|
+
}
|
|
21325
|
+
if (message.channels != null && message.hasOwnProperty("channels")) {
|
|
21326
|
+
if (!$util.isInteger(message.channels))
|
|
21327
|
+
return "channels: integer expected";
|
|
21328
|
+
}
|
|
21329
|
+
if (message.bitDepth != null && message.hasOwnProperty("bitDepth")) {
|
|
21330
|
+
if (!$util.isInteger(message.bitDepth))
|
|
21331
|
+
return "bitDepth: integer expected";
|
|
21332
|
+
}
|
|
21333
|
+
return null;
|
|
21334
|
+
};
|
|
21335
|
+
MediaCodecData2.fromObject = function fromObject(object) {
|
|
21336
|
+
if (object instanceof $root.sesame.v1.wire.MediaCodecData)
|
|
21337
|
+
return object;
|
|
21338
|
+
let message = new $root.sesame.v1.wire.MediaCodecData();
|
|
21339
|
+
switch (object.codecType) {
|
|
21340
|
+
default:
|
|
21341
|
+
if (typeof object.codecType === "number") {
|
|
21342
|
+
message.codecType = object.codecType;
|
|
21343
|
+
break;
|
|
21344
|
+
}
|
|
21345
|
+
break;
|
|
21346
|
+
case "CODEC_TYPE_UNSPECIFIED":
|
|
21347
|
+
case 0:
|
|
21348
|
+
message.codecType = 0;
|
|
21349
|
+
break;
|
|
21350
|
+
case "CODEC_TYPE_VIDEO_VP8":
|
|
21351
|
+
case 1:
|
|
21352
|
+
message.codecType = 1;
|
|
21353
|
+
break;
|
|
21354
|
+
case "CODEC_TYPE_VIDEO_VP9":
|
|
21355
|
+
case 2:
|
|
21356
|
+
message.codecType = 2;
|
|
21357
|
+
break;
|
|
21358
|
+
case "CODEC_TYPE_VIDEO_AVC":
|
|
21359
|
+
case 3:
|
|
21360
|
+
message.codecType = 3;
|
|
21361
|
+
break;
|
|
21362
|
+
case "CODEC_TYPE_VIDEO_HEVC":
|
|
21363
|
+
case 4:
|
|
21364
|
+
message.codecType = 4;
|
|
21365
|
+
break;
|
|
21366
|
+
case "CODEC_TYPE_VIDEO_AV1":
|
|
21367
|
+
case 5:
|
|
21368
|
+
message.codecType = 5;
|
|
21369
|
+
break;
|
|
21370
|
+
case "CODEC_TYPE_AUDIO_OPUS":
|
|
21371
|
+
case 64:
|
|
21372
|
+
message.codecType = 64;
|
|
21373
|
+
break;
|
|
21374
|
+
case "CODEC_TYPE_AUDIO_AAC":
|
|
21375
|
+
case 65:
|
|
21376
|
+
message.codecType = 65;
|
|
21377
|
+
break;
|
|
21378
|
+
case "CODEC_TYPE_AUDIO_PCM":
|
|
21379
|
+
case 66:
|
|
21380
|
+
message.codecType = 66;
|
|
21381
|
+
break;
|
|
21382
|
+
}
|
|
21383
|
+
if (object.sampleRate != null)
|
|
21384
|
+
message.sampleRate = object.sampleRate >>> 0;
|
|
21385
|
+
if (object.timebaseNum != null)
|
|
21386
|
+
message.timebaseNum = object.timebaseNum >>> 0;
|
|
21387
|
+
if (object.timebaseDen != null)
|
|
21388
|
+
message.timebaseDen = object.timebaseDen >>> 0;
|
|
21389
|
+
if (object.codecProfile != null)
|
|
21390
|
+
message.codecProfile = object.codecProfile >>> 0;
|
|
21391
|
+
if (object.codecLevel != null)
|
|
21392
|
+
message.codecLevel = object.codecLevel >>> 0;
|
|
21393
|
+
if (object.width != null)
|
|
21394
|
+
message.width = object.width >>> 0;
|
|
21395
|
+
if (object.height != null)
|
|
21396
|
+
message.height = object.height >>> 0;
|
|
21397
|
+
if (object.channels != null)
|
|
21398
|
+
message.channels = object.channels >>> 0;
|
|
21399
|
+
if (object.bitDepth != null)
|
|
21400
|
+
message.bitDepth = object.bitDepth >>> 0;
|
|
21401
|
+
return message;
|
|
21402
|
+
};
|
|
21403
|
+
MediaCodecData2.toObject = function toObject(message, options) {
|
|
21404
|
+
if (!options)
|
|
21405
|
+
options = {};
|
|
21406
|
+
let object = {};
|
|
21407
|
+
if (options.defaults) {
|
|
21408
|
+
object.codecType = options.enums === String ? "CODEC_TYPE_UNSPECIFIED" : 0;
|
|
21409
|
+
object.sampleRate = 0;
|
|
21410
|
+
object.timebaseNum = 0;
|
|
21411
|
+
object.timebaseDen = 0;
|
|
21412
|
+
object.codecProfile = 0;
|
|
21413
|
+
object.codecLevel = 0;
|
|
21414
|
+
object.width = 0;
|
|
21415
|
+
object.height = 0;
|
|
21416
|
+
object.channels = 0;
|
|
21417
|
+
object.bitDepth = 0;
|
|
21418
|
+
}
|
|
21419
|
+
if (message.codecType != null && message.hasOwnProperty("codecType"))
|
|
21420
|
+
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;
|
|
21421
|
+
if (message.sampleRate != null && message.hasOwnProperty("sampleRate"))
|
|
21422
|
+
object.sampleRate = message.sampleRate;
|
|
21423
|
+
if (message.timebaseNum != null && message.hasOwnProperty("timebaseNum"))
|
|
21424
|
+
object.timebaseNum = message.timebaseNum;
|
|
21425
|
+
if (message.timebaseDen != null && message.hasOwnProperty("timebaseDen"))
|
|
21426
|
+
object.timebaseDen = message.timebaseDen;
|
|
21427
|
+
if (message.codecProfile != null && message.hasOwnProperty("codecProfile"))
|
|
21428
|
+
object.codecProfile = message.codecProfile;
|
|
21429
|
+
if (message.codecLevel != null && message.hasOwnProperty("codecLevel"))
|
|
21430
|
+
object.codecLevel = message.codecLevel;
|
|
21431
|
+
if (message.width != null && message.hasOwnProperty("width"))
|
|
21432
|
+
object.width = message.width;
|
|
21433
|
+
if (message.height != null && message.hasOwnProperty("height"))
|
|
21434
|
+
object.height = message.height;
|
|
21435
|
+
if (message.channels != null && message.hasOwnProperty("channels"))
|
|
21436
|
+
object.channels = message.channels;
|
|
21437
|
+
if (message.bitDepth != null && message.hasOwnProperty("bitDepth"))
|
|
21438
|
+
object.bitDepth = message.bitDepth;
|
|
21439
|
+
return object;
|
|
21440
|
+
};
|
|
21441
|
+
MediaCodecData2.prototype.toJSON = function toJSON() {
|
|
21442
|
+
return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
|
|
21443
|
+
};
|
|
21444
|
+
MediaCodecData2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
|
21445
|
+
if (typeUrlPrefix === void 0) {
|
|
21446
|
+
typeUrlPrefix = "type.googleapis.com";
|
|
21447
|
+
}
|
|
21448
|
+
return typeUrlPrefix + "/sesame.v1.wire.MediaCodecData";
|
|
21449
|
+
};
|
|
21450
|
+
return MediaCodecData2;
|
|
21451
|
+
}();
|
|
21452
|
+
wire.FrameHeader = function() {
|
|
21453
|
+
function FrameHeader2(properties) {
|
|
21454
|
+
if (properties) {
|
|
21455
|
+
for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
21456
|
+
if (properties[keys[i]] != null)
|
|
21457
|
+
this[keys[i]] = properties[keys[i]];
|
|
21458
|
+
}
|
|
21459
|
+
}
|
|
21460
|
+
FrameHeader2.prototype.type = 0;
|
|
21461
|
+
FrameHeader2.prototype.pts = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
|
|
21462
|
+
FrameHeader2.prototype.id = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
|
|
21463
|
+
FrameHeader2.prototype.keyframe = false;
|
|
21464
|
+
FrameHeader2.prototype.codecData = null;
|
|
21465
|
+
FrameHeader2.prototype.routingMetadata = "";
|
|
21466
|
+
FrameHeader2.create = function create(properties) {
|
|
21467
|
+
return new FrameHeader2(properties);
|
|
21468
|
+
};
|
|
21469
|
+
FrameHeader2.encode = function encode(message, writer) {
|
|
21470
|
+
if (!writer)
|
|
21471
|
+
writer = $Writer.create();
|
|
21472
|
+
if (message.type != null && Object.hasOwnProperty.call(message, "type"))
|
|
21473
|
+
writer.uint32(
|
|
21474
|
+
/* id 1, wireType 0 =*/
|
|
21475
|
+
8
|
|
21476
|
+
).int32(message.type);
|
|
21477
|
+
if (message.pts != null && Object.hasOwnProperty.call(message, "pts"))
|
|
21478
|
+
writer.uint32(
|
|
21479
|
+
/* id 2, wireType 0 =*/
|
|
21480
|
+
16
|
|
21481
|
+
).uint64(message.pts);
|
|
21482
|
+
if (message.id != null && Object.hasOwnProperty.call(message, "id"))
|
|
21483
|
+
writer.uint32(
|
|
21484
|
+
/* id 3, wireType 0 =*/
|
|
21485
|
+
24
|
|
21486
|
+
).uint64(message.id);
|
|
21487
|
+
if (message.keyframe != null && Object.hasOwnProperty.call(message, "keyframe"))
|
|
21488
|
+
writer.uint32(
|
|
21489
|
+
/* id 4, wireType 0 =*/
|
|
21490
|
+
32
|
|
21491
|
+
).bool(message.keyframe);
|
|
21492
|
+
if (message.codecData != null && Object.hasOwnProperty.call(message, "codecData"))
|
|
21493
|
+
$root.sesame.v1.wire.MediaCodecData.encode(message.codecData, writer.uint32(
|
|
21494
|
+
/* id 5, wireType 2 =*/
|
|
21495
|
+
42
|
|
21496
|
+
).fork()).ldelim();
|
|
21497
|
+
if (message.routingMetadata != null && Object.hasOwnProperty.call(message, "routingMetadata"))
|
|
21498
|
+
writer.uint32(
|
|
21499
|
+
/* id 6, wireType 2 =*/
|
|
21500
|
+
50
|
|
21501
|
+
).string(message.routingMetadata);
|
|
21502
|
+
return writer;
|
|
21503
|
+
};
|
|
21504
|
+
FrameHeader2.encodeDelimited = function encodeDelimited(message, writer) {
|
|
21505
|
+
return this.encode(message, writer).ldelim();
|
|
21506
|
+
};
|
|
21507
|
+
FrameHeader2.decode = function decode(reader, length, error) {
|
|
21508
|
+
if (!(reader instanceof $Reader))
|
|
21509
|
+
reader = $Reader.create(reader);
|
|
21510
|
+
let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.sesame.v1.wire.FrameHeader();
|
|
21511
|
+
while (reader.pos < end) {
|
|
21512
|
+
let tag = reader.uint32();
|
|
21513
|
+
if (tag === error)
|
|
21514
|
+
break;
|
|
21515
|
+
switch (tag >>> 3) {
|
|
21516
|
+
case 1: {
|
|
21517
|
+
message.type = reader.int32();
|
|
21518
|
+
break;
|
|
21519
|
+
}
|
|
21520
|
+
case 2: {
|
|
21521
|
+
message.pts = reader.uint64();
|
|
21522
|
+
break;
|
|
21523
|
+
}
|
|
21524
|
+
case 3: {
|
|
21525
|
+
message.id = reader.uint64();
|
|
21526
|
+
break;
|
|
21527
|
+
}
|
|
21528
|
+
case 4: {
|
|
21529
|
+
message.keyframe = reader.bool();
|
|
21530
|
+
break;
|
|
21531
|
+
}
|
|
21532
|
+
case 5: {
|
|
21533
|
+
message.codecData = $root.sesame.v1.wire.MediaCodecData.decode(reader, reader.uint32());
|
|
21534
|
+
break;
|
|
21535
|
+
}
|
|
21536
|
+
case 6: {
|
|
21537
|
+
message.routingMetadata = reader.string();
|
|
21538
|
+
break;
|
|
21539
|
+
}
|
|
21540
|
+
default:
|
|
21541
|
+
reader.skipType(tag & 7);
|
|
21542
|
+
break;
|
|
21543
|
+
}
|
|
21544
|
+
}
|
|
21545
|
+
return message;
|
|
21546
|
+
};
|
|
21547
|
+
FrameHeader2.decodeDelimited = function decodeDelimited(reader) {
|
|
21548
|
+
if (!(reader instanceof $Reader))
|
|
21549
|
+
reader = new $Reader(reader);
|
|
21550
|
+
return this.decode(reader, reader.uint32());
|
|
21551
|
+
};
|
|
21552
|
+
FrameHeader2.verify = function verify(message) {
|
|
21553
|
+
if (typeof message !== "object" || message === null)
|
|
21554
|
+
return "object expected";
|
|
21555
|
+
if (message.type != null && message.hasOwnProperty("type"))
|
|
21556
|
+
switch (message.type) {
|
|
21557
|
+
default:
|
|
21558
|
+
return "type: enum value expected";
|
|
21559
|
+
case 0:
|
|
21560
|
+
case 1:
|
|
21561
|
+
case 2:
|
|
21562
|
+
case 3:
|
|
21563
|
+
case 4:
|
|
21564
|
+
case 5:
|
|
21565
|
+
break;
|
|
21566
|
+
}
|
|
21567
|
+
if (message.pts != null && message.hasOwnProperty("pts")) {
|
|
21568
|
+
if (!$util.isInteger(message.pts) && !(message.pts && $util.isInteger(message.pts.low) && $util.isInteger(message.pts.high)))
|
|
21569
|
+
return "pts: integer|Long expected";
|
|
21570
|
+
}
|
|
21571
|
+
if (message.id != null && message.hasOwnProperty("id")) {
|
|
21572
|
+
if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high)))
|
|
21573
|
+
return "id: integer|Long expected";
|
|
21574
|
+
}
|
|
21575
|
+
if (message.keyframe != null && message.hasOwnProperty("keyframe")) {
|
|
21576
|
+
if (typeof message.keyframe !== "boolean")
|
|
21577
|
+
return "keyframe: boolean expected";
|
|
21578
|
+
}
|
|
21579
|
+
if (message.codecData != null && message.hasOwnProperty("codecData")) {
|
|
21580
|
+
let error = $root.sesame.v1.wire.MediaCodecData.verify(message.codecData);
|
|
21581
|
+
if (error)
|
|
21582
|
+
return "codecData." + error;
|
|
21583
|
+
}
|
|
21584
|
+
if (message.routingMetadata != null && message.hasOwnProperty("routingMetadata")) {
|
|
21585
|
+
if (!$util.isString(message.routingMetadata))
|
|
21586
|
+
return "routingMetadata: string expected";
|
|
21587
|
+
}
|
|
21588
|
+
return null;
|
|
21589
|
+
};
|
|
21590
|
+
FrameHeader2.fromObject = function fromObject(object) {
|
|
21591
|
+
if (object instanceof $root.sesame.v1.wire.FrameHeader)
|
|
21592
|
+
return object;
|
|
21593
|
+
let message = new $root.sesame.v1.wire.FrameHeader();
|
|
21594
|
+
switch (object.type) {
|
|
21595
|
+
default:
|
|
21596
|
+
if (typeof object.type === "number") {
|
|
21597
|
+
message.type = object.type;
|
|
21598
|
+
break;
|
|
21599
|
+
}
|
|
21600
|
+
break;
|
|
21601
|
+
case "FRAME_TYPE_UNSPECIFIED":
|
|
21602
|
+
case 0:
|
|
21603
|
+
message.type = 0;
|
|
21604
|
+
break;
|
|
21605
|
+
case "FRAME_TYPE_RPC":
|
|
21606
|
+
case 1:
|
|
21607
|
+
message.type = 1;
|
|
21608
|
+
break;
|
|
21609
|
+
case "FRAME_TYPE_VIDEO":
|
|
21610
|
+
case 2:
|
|
21611
|
+
message.type = 2;
|
|
21612
|
+
break;
|
|
21613
|
+
case "FRAME_TYPE_AUDIO":
|
|
21614
|
+
case 3:
|
|
21615
|
+
message.type = 3;
|
|
21616
|
+
break;
|
|
21617
|
+
case "FRAME_TYPE_MUXED":
|
|
21618
|
+
case 4:
|
|
21619
|
+
message.type = 4;
|
|
21620
|
+
break;
|
|
21621
|
+
case "FRAME_TYPE_DECODER_DATA":
|
|
21622
|
+
case 5:
|
|
21623
|
+
message.type = 5;
|
|
21624
|
+
break;
|
|
21625
|
+
}
|
|
21626
|
+
if (object.pts != null) {
|
|
21627
|
+
if ($util.Long)
|
|
21628
|
+
(message.pts = $util.Long.fromValue(object.pts)).unsigned = true;
|
|
21629
|
+
else if (typeof object.pts === "string")
|
|
21630
|
+
message.pts = parseInt(object.pts, 10);
|
|
21631
|
+
else if (typeof object.pts === "number")
|
|
21632
|
+
message.pts = object.pts;
|
|
21633
|
+
else if (typeof object.pts === "object")
|
|
21634
|
+
message.pts = new $util.LongBits(object.pts.low >>> 0, object.pts.high >>> 0).toNumber(true);
|
|
21635
|
+
}
|
|
21636
|
+
if (object.id != null) {
|
|
21637
|
+
if ($util.Long)
|
|
21638
|
+
(message.id = $util.Long.fromValue(object.id)).unsigned = true;
|
|
21639
|
+
else if (typeof object.id === "string")
|
|
21640
|
+
message.id = parseInt(object.id, 10);
|
|
21641
|
+
else if (typeof object.id === "number")
|
|
21642
|
+
message.id = object.id;
|
|
21643
|
+
else if (typeof object.id === "object")
|
|
21644
|
+
message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber(true);
|
|
21645
|
+
}
|
|
21646
|
+
if (object.keyframe != null)
|
|
21647
|
+
message.keyframe = Boolean(object.keyframe);
|
|
21648
|
+
if (object.codecData != null) {
|
|
21649
|
+
if (typeof object.codecData !== "object")
|
|
21650
|
+
throw TypeError(".sesame.v1.wire.FrameHeader.codecData: object expected");
|
|
21651
|
+
message.codecData = $root.sesame.v1.wire.MediaCodecData.fromObject(object.codecData);
|
|
21652
|
+
}
|
|
21653
|
+
if (object.routingMetadata != null)
|
|
21654
|
+
message.routingMetadata = String(object.routingMetadata);
|
|
21655
|
+
return message;
|
|
21656
|
+
};
|
|
21657
|
+
FrameHeader2.toObject = function toObject(message, options) {
|
|
21658
|
+
if (!options)
|
|
21659
|
+
options = {};
|
|
21660
|
+
let object = {};
|
|
21661
|
+
if (options.defaults) {
|
|
21662
|
+
object.type = options.enums === String ? "FRAME_TYPE_UNSPECIFIED" : 0;
|
|
21663
|
+
if ($util.Long) {
|
|
21664
|
+
let long = new $util.Long(0, 0, true);
|
|
21665
|
+
object.pts = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
|
|
21666
|
+
} else
|
|
21667
|
+
object.pts = options.longs === String ? "0" : 0;
|
|
21668
|
+
if ($util.Long) {
|
|
21669
|
+
let long = new $util.Long(0, 0, true);
|
|
21670
|
+
object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
|
|
21671
|
+
} else
|
|
21672
|
+
object.id = options.longs === String ? "0" : 0;
|
|
21673
|
+
object.keyframe = false;
|
|
21674
|
+
object.codecData = null;
|
|
21675
|
+
object.routingMetadata = "";
|
|
21676
|
+
}
|
|
21677
|
+
if (message.type != null && message.hasOwnProperty("type"))
|
|
21678
|
+
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;
|
|
21679
|
+
if (message.pts != null && message.hasOwnProperty("pts"))
|
|
21680
|
+
if (typeof message.pts === "number")
|
|
21681
|
+
object.pts = options.longs === String ? String(message.pts) : message.pts;
|
|
21682
|
+
else
|
|
21683
|
+
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;
|
|
21684
|
+
if (message.id != null && message.hasOwnProperty("id"))
|
|
21685
|
+
if (typeof message.id === "number")
|
|
21686
|
+
object.id = options.longs === String ? String(message.id) : message.id;
|
|
21687
|
+
else
|
|
21688
|
+
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;
|
|
21689
|
+
if (message.keyframe != null && message.hasOwnProperty("keyframe"))
|
|
21690
|
+
object.keyframe = message.keyframe;
|
|
21691
|
+
if (message.codecData != null && message.hasOwnProperty("codecData"))
|
|
21692
|
+
object.codecData = $root.sesame.v1.wire.MediaCodecData.toObject(message.codecData, options);
|
|
21693
|
+
if (message.routingMetadata != null && message.hasOwnProperty("routingMetadata"))
|
|
21694
|
+
object.routingMetadata = message.routingMetadata;
|
|
21695
|
+
return object;
|
|
21696
|
+
};
|
|
21697
|
+
FrameHeader2.prototype.toJSON = function toJSON() {
|
|
21698
|
+
return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
|
|
21699
|
+
};
|
|
21700
|
+
FrameHeader2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
|
21701
|
+
if (typeUrlPrefix === void 0) {
|
|
21702
|
+
typeUrlPrefix = "type.googleapis.com";
|
|
21703
|
+
}
|
|
21704
|
+
return typeUrlPrefix + "/sesame.v1.wire.FrameHeader";
|
|
21705
|
+
};
|
|
21706
|
+
return FrameHeader2;
|
|
21707
|
+
}();
|
|
21708
|
+
return wire;
|
|
21709
|
+
}();
|
|
21112
21710
|
return v1;
|
|
21113
21711
|
}();
|
|
21114
21712
|
return sesame2;
|
|
@@ -21548,7 +22146,8 @@ var RPCClient = class extends import_events.EventEmitter {
|
|
|
21548
22146
|
eventHandler(event) {
|
|
21549
22147
|
const topic = event.topic ?? 0;
|
|
21550
22148
|
if (topic === sesame.v1.common.EventTopic.EVENT_TOPIC_UNSPECIFIED) {
|
|
21551
|
-
|
|
22149
|
+
log.warn(`Ignoring event with unspecified topic: ${event.topic}`);
|
|
22150
|
+
return;
|
|
21552
22151
|
}
|
|
21553
22152
|
const type = this.eventTypes[topic];
|
|
21554
22153
|
let payload;
|
|
@@ -21574,255 +22173,58 @@ var RPCClient = class extends import_events.EventEmitter {
|
|
|
21574
22173
|
// src/sesame-connection.ts
|
|
21575
22174
|
var import_events2 = require("events");
|
|
21576
22175
|
|
|
21577
|
-
// src/sesame-
|
|
21578
|
-
var
|
|
21579
|
-
var
|
|
21580
|
-
var
|
|
21581
|
-
var
|
|
21582
|
-
var
|
|
21583
|
-
var
|
|
21584
|
-
var FLAG_HAS_METADATA = 1 << 1;
|
|
21585
|
-
var FLAG_IS_KEYFRAME = 1 << 2;
|
|
21586
|
-
var PacketType = /* @__PURE__ */ ((PacketType2) => {
|
|
21587
|
-
PacketType2[PacketType2["VIDEO_FRAME"] = 1] = "VIDEO_FRAME";
|
|
21588
|
-
PacketType2[PacketType2["AUDIO_FRAME"] = 2] = "AUDIO_FRAME";
|
|
21589
|
-
PacketType2[PacketType2["RPC"] = 3] = "RPC";
|
|
21590
|
-
PacketType2[PacketType2["MUXED_DATA"] = 4] = "MUXED_DATA";
|
|
21591
|
-
PacketType2[PacketType2["DECODER_DATA"] = 5] = "DECODER_DATA";
|
|
21592
|
-
return PacketType2;
|
|
21593
|
-
})(PacketType || {});
|
|
21594
|
-
var CodecType = /* @__PURE__ */ ((CodecType2) => {
|
|
21595
|
-
CodecType2[CodecType2["VIDEO_VP8"] = 1] = "VIDEO_VP8";
|
|
21596
|
-
CodecType2[CodecType2["VIDEO_VP9"] = 2] = "VIDEO_VP9";
|
|
21597
|
-
CodecType2[CodecType2["VIDEO_AVC"] = 3] = "VIDEO_AVC";
|
|
21598
|
-
CodecType2[CodecType2["VIDEO_HEVC"] = 4] = "VIDEO_HEVC";
|
|
21599
|
-
CodecType2[CodecType2["VIDEO_AV1"] = 5] = "VIDEO_AV1";
|
|
21600
|
-
CodecType2[CodecType2["AUDIO_OPUS"] = 64] = "AUDIO_OPUS";
|
|
21601
|
-
CodecType2[CodecType2["AUDIO_AAC"] = 65] = "AUDIO_AAC";
|
|
21602
|
-
CodecType2[CodecType2["AUDIO_PCM"] = 66] = "AUDIO_PCM";
|
|
21603
|
-
return CodecType2;
|
|
21604
|
-
})(CodecType || {});
|
|
21605
|
-
var SesameBinaryProtocol = class {
|
|
21606
|
-
/**
|
|
21607
|
-
* Initialize a header data structure with proper defaults
|
|
21608
|
-
*/
|
|
21609
|
-
static initHeader(type, flags, pts, id) {
|
|
21610
|
-
return {
|
|
21611
|
-
magic: PROTOCOL_MAGIC,
|
|
21612
|
-
version: PROTOCOL_VERSION,
|
|
21613
|
-
header_size: this.calculateHeaderSize(flags),
|
|
21614
|
-
type,
|
|
21615
|
-
flags,
|
|
21616
|
-
pts,
|
|
21617
|
-
id,
|
|
21618
|
-
reserved: 0
|
|
21619
|
-
// Always zero reserved fields
|
|
21620
|
-
};
|
|
21621
|
-
}
|
|
21622
|
-
/**
|
|
21623
|
-
* Calculate the total header size based on flags
|
|
21624
|
-
*/
|
|
21625
|
-
static calculateHeaderSize(flags) {
|
|
21626
|
-
let size = HEADER_DATA_SIZE;
|
|
21627
|
-
if (flags & FLAG_HAS_METADATA) {
|
|
21628
|
-
size += HEADER_METADATA_SIZE;
|
|
21629
|
-
}
|
|
21630
|
-
if (flags & FLAG_HAS_CODEC_DATA) {
|
|
21631
|
-
size += HEADER_CODEC_DATA_SIZE;
|
|
21632
|
-
}
|
|
21633
|
-
return size;
|
|
21634
|
-
}
|
|
21635
|
-
/**
|
|
21636
|
-
* Validate a header structure
|
|
21637
|
-
*/
|
|
21638
|
-
static validateHeader(header, totalSize) {
|
|
21639
|
-
if (header.magic !== PROTOCOL_MAGIC) {
|
|
21640
|
-
return false;
|
|
21641
|
-
}
|
|
21642
|
-
if (header.version !== PROTOCOL_VERSION) {
|
|
21643
|
-
return false;
|
|
21644
|
-
}
|
|
21645
|
-
const expectedHeaderSize = this.calculateHeaderSize(header.flags);
|
|
21646
|
-
if (header.header_size !== expectedHeaderSize) {
|
|
21647
|
-
return false;
|
|
21648
|
-
}
|
|
21649
|
-
if (totalSize < header.header_size) {
|
|
21650
|
-
return false;
|
|
21651
|
-
}
|
|
21652
|
-
return true;
|
|
21653
|
-
}
|
|
22176
|
+
// src/sesame-wire-protocol.ts
|
|
22177
|
+
var FrameType = sesame.v1.wire.FrameType;
|
|
22178
|
+
var FrameHeader = sesame.v1.wire.FrameHeader;
|
|
22179
|
+
var MediaCodecData = sesame.v1.wire.MediaCodecData;
|
|
22180
|
+
var CodecType = sesame.v1.wire.CodecType;
|
|
22181
|
+
var PREFIX_SIZE = 4;
|
|
22182
|
+
var WireProtocol = class {
|
|
21654
22183
|
/**
|
|
21655
|
-
* Serialize
|
|
22184
|
+
* Serialize a wire frame: 4-byte LE header_size + protobuf FrameHeader + payload.
|
|
21656
22185
|
*/
|
|
21657
|
-
static serialize(header,
|
|
21658
|
-
const
|
|
21659
|
-
const
|
|
21660
|
-
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21664
|
-
|
|
21665
|
-
|
|
21666
|
-
|
|
21667
|
-
|
|
21668
|
-
view.setUint32(offset, header.magic, true);
|
|
21669
|
-
offset += 4;
|
|
21670
|
-
view.setUint32(offset, header.flags, true);
|
|
21671
|
-
offset += 4;
|
|
21672
|
-
view.setBigUint64(offset, header.pts, true);
|
|
21673
|
-
offset += 8;
|
|
21674
|
-
view.setBigUint64(offset, header.id, true);
|
|
21675
|
-
offset += 8;
|
|
21676
|
-
view.setUint16(offset, header.version, true);
|
|
21677
|
-
offset += 2;
|
|
21678
|
-
view.setUint16(offset, header.header_size, true);
|
|
21679
|
-
offset += 2;
|
|
21680
|
-
view.setUint16(offset, header.type, true);
|
|
21681
|
-
offset += 2;
|
|
21682
|
-
view.setUint16(offset, header.reserved, true);
|
|
21683
|
-
offset += 2;
|
|
21684
|
-
if (includeMetadata && metadata) {
|
|
21685
|
-
const metadataBytes = this.stringToFixedBytes(metadata.metadata, 64);
|
|
21686
|
-
new Uint8Array(buffer, offset, 64).set(metadataBytes);
|
|
21687
|
-
offset += 64;
|
|
22186
|
+
static serialize(header, payload) {
|
|
22187
|
+
const headerBytes = sesame.v1.wire.FrameHeader.encode(header).finish();
|
|
22188
|
+
const headerSize = headerBytes.length;
|
|
22189
|
+
const payloadSize = payload ? payload.length : 0;
|
|
22190
|
+
const total = PREFIX_SIZE + headerSize + payloadSize;
|
|
22191
|
+
const buffer = new Uint8Array(total);
|
|
22192
|
+
const view = new DataView(buffer.buffer);
|
|
22193
|
+
view.setUint32(0, headerSize, true);
|
|
22194
|
+
buffer.set(headerBytes, PREFIX_SIZE);
|
|
22195
|
+
if (payload && payloadSize > 0) {
|
|
22196
|
+
buffer.set(payload, PREFIX_SIZE + headerSize);
|
|
21688
22197
|
}
|
|
21689
|
-
|
|
21690
|
-
view.setUint32(offset, codecData.sample_rate, true);
|
|
21691
|
-
offset += 4;
|
|
21692
|
-
view.setUint32(offset, codecData.timebase_num, true);
|
|
21693
|
-
offset += 4;
|
|
21694
|
-
view.setUint32(offset, codecData.timebase_den, true);
|
|
21695
|
-
offset += 4;
|
|
21696
|
-
view.setUint16(offset, codecData.codec_profile, true);
|
|
21697
|
-
offset += 2;
|
|
21698
|
-
view.setUint16(offset, codecData.codec_level, true);
|
|
21699
|
-
offset += 2;
|
|
21700
|
-
view.setUint16(offset, codecData.width, true);
|
|
21701
|
-
offset += 2;
|
|
21702
|
-
view.setUint16(offset, codecData.height, true);
|
|
21703
|
-
offset += 2;
|
|
21704
|
-
view.setUint8(offset, codecData.codec_type);
|
|
21705
|
-
offset += 1;
|
|
21706
|
-
view.setUint8(offset, codecData.channels);
|
|
21707
|
-
offset += 1;
|
|
21708
|
-
view.setUint8(offset, codecData.bit_depth);
|
|
21709
|
-
offset += 1;
|
|
21710
|
-
view.setUint8(offset, codecData.reserved);
|
|
21711
|
-
offset += 1;
|
|
21712
|
-
}
|
|
21713
|
-
if (payload && payload.length > 0) {
|
|
21714
|
-
new Uint8Array(buffer, offset).set(payload);
|
|
21715
|
-
}
|
|
21716
|
-
return new Uint8Array(buffer);
|
|
22198
|
+
return buffer;
|
|
21717
22199
|
}
|
|
21718
22200
|
/**
|
|
21719
|
-
* Parse incoming
|
|
22201
|
+
* Parse an incoming wire frame.
|
|
21720
22202
|
*/
|
|
21721
|
-
static
|
|
21722
|
-
const result = {
|
|
21723
|
-
|
|
21724
|
-
|
|
21725
|
-
|
|
21726
|
-
|
|
21727
|
-
|
|
21728
|
-
|
|
21729
|
-
|
|
21730
|
-
|
|
21731
|
-
|
|
21732
|
-
}
|
|
21733
|
-
const view = new DataView(data.buffer, data.byteOffset);
|
|
21734
|
-
let offset = 0;
|
|
21735
|
-
const header = {
|
|
21736
|
-
magic: view.getUint32(offset, true),
|
|
21737
|
-
flags: view.getUint32(offset + 4, true),
|
|
21738
|
-
pts: view.getBigUint64(offset + 8, true),
|
|
21739
|
-
id: view.getBigUint64(offset + 16, true),
|
|
21740
|
-
version: view.getUint16(offset + 24, true),
|
|
21741
|
-
header_size: view.getUint16(offset + 26, true),
|
|
21742
|
-
type: view.getUint16(offset + 28, true),
|
|
21743
|
-
reserved: view.getUint16(offset + 30, true)
|
|
21744
|
-
};
|
|
21745
|
-
offset += HEADER_DATA_SIZE;
|
|
21746
|
-
if (!this.validateHeader(header, data.length)) {
|
|
21747
|
-
return result;
|
|
21748
|
-
}
|
|
21749
|
-
result.header = header;
|
|
21750
|
-
if (header.flags & FLAG_HAS_METADATA) {
|
|
21751
|
-
if (data.length < offset + HEADER_METADATA_SIZE) {
|
|
21752
|
-
return result;
|
|
21753
|
-
}
|
|
21754
|
-
const metadataBytes = data.slice(offset, offset + HEADER_METADATA_SIZE);
|
|
21755
|
-
const metadataStr = this.fixedBytesToString(metadataBytes);
|
|
21756
|
-
result.metadata = { metadata: metadataStr };
|
|
21757
|
-
offset += HEADER_METADATA_SIZE;
|
|
22203
|
+
static parse(data) {
|
|
22204
|
+
const result = { valid: false, header: null, payload: null };
|
|
22205
|
+
if (!data || data.length < PREFIX_SIZE) return result;
|
|
22206
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
22207
|
+
const headerSize = view.getUint32(0, true);
|
|
22208
|
+
if (data.length < PREFIX_SIZE + headerSize) return result;
|
|
22209
|
+
try {
|
|
22210
|
+
const headerBytes = data.subarray(PREFIX_SIZE, PREFIX_SIZE + headerSize);
|
|
22211
|
+
result.header = sesame.v1.wire.FrameHeader.decode(headerBytes);
|
|
22212
|
+
result.payload = data.subarray(PREFIX_SIZE + headerSize);
|
|
22213
|
+
result.valid = true;
|
|
22214
|
+
} catch {
|
|
21758
22215
|
}
|
|
21759
|
-
if (header.flags & FLAG_HAS_CODEC_DATA) {
|
|
21760
|
-
if (data.length < offset + HEADER_CODEC_DATA_SIZE) {
|
|
21761
|
-
return result;
|
|
21762
|
-
}
|
|
21763
|
-
result.codec_data = {
|
|
21764
|
-
sample_rate: view.getUint32(offset, true),
|
|
21765
|
-
timebase_num: view.getUint32(offset + 4, true),
|
|
21766
|
-
timebase_den: view.getUint32(offset + 8, true),
|
|
21767
|
-
codec_profile: view.getUint16(offset + 12, true),
|
|
21768
|
-
codec_level: view.getUint16(offset + 14, true),
|
|
21769
|
-
width: view.getUint16(offset + 16, true),
|
|
21770
|
-
height: view.getUint16(offset + 18, true),
|
|
21771
|
-
codec_type: view.getUint8(offset + 20),
|
|
21772
|
-
channels: view.getUint8(offset + 21),
|
|
21773
|
-
bit_depth: view.getUint8(offset + 22),
|
|
21774
|
-
reserved: view.getUint8(offset + 23)
|
|
21775
|
-
};
|
|
21776
|
-
offset += HEADER_CODEC_DATA_SIZE;
|
|
21777
|
-
}
|
|
21778
|
-
if (offset < data.length) {
|
|
21779
|
-
result.payload = data.slice(offset);
|
|
21780
|
-
result.payload_size = result.payload.length;
|
|
21781
|
-
} else {
|
|
21782
|
-
result.payload = new Uint8Array(0);
|
|
21783
|
-
result.payload_size = 0;
|
|
21784
|
-
}
|
|
21785
|
-
result.valid = true;
|
|
21786
22216
|
return result;
|
|
21787
22217
|
}
|
|
21788
|
-
/**
|
|
21789
|
-
* Helper: Convert string to fixed-size byte array (null-terminated)
|
|
21790
|
-
*/
|
|
21791
|
-
static stringToFixedBytes(str, size) {
|
|
21792
|
-
const bytes = new Uint8Array(size);
|
|
21793
|
-
let encoded;
|
|
21794
|
-
if (typeof TextEncoder !== "undefined") {
|
|
21795
|
-
const encoder = new TextEncoder();
|
|
21796
|
-
encoded = encoder.encode(str);
|
|
21797
|
-
} else {
|
|
21798
|
-
encoded = new Uint8Array(Buffer.from(str, "utf8"));
|
|
21799
|
-
}
|
|
21800
|
-
const copyLen = Math.min(encoded.length, size - 1);
|
|
21801
|
-
bytes.set(encoded.slice(0, copyLen));
|
|
21802
|
-
bytes[copyLen] = 0;
|
|
21803
|
-
return bytes;
|
|
21804
|
-
}
|
|
21805
|
-
/**
|
|
21806
|
-
* Helper: Convert fixed-size byte array to string (null-terminated)
|
|
21807
|
-
*/
|
|
21808
|
-
static fixedBytesToString(bytes) {
|
|
21809
|
-
let len = bytes.length;
|
|
21810
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
21811
|
-
if (bytes[i] === 0) {
|
|
21812
|
-
len = i;
|
|
21813
|
-
break;
|
|
21814
|
-
}
|
|
21815
|
-
}
|
|
21816
|
-
if (typeof TextDecoder !== "undefined") {
|
|
21817
|
-
const decoder = new TextDecoder();
|
|
21818
|
-
return decoder.decode(bytes.slice(0, len));
|
|
21819
|
-
} else {
|
|
21820
|
-
return Buffer.from(bytes.slice(0, len)).toString("utf8");
|
|
21821
|
-
}
|
|
21822
|
-
}
|
|
21823
22218
|
};
|
|
21824
22219
|
|
|
21825
22220
|
// src/sesame-connection.ts
|
|
22221
|
+
var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
|
|
22222
|
+
ConnectionState2["Disconnected"] = "disconnected";
|
|
22223
|
+
ConnectionState2["Connecting"] = "connecting";
|
|
22224
|
+
ConnectionState2["Connected"] = "connected";
|
|
22225
|
+
ConnectionState2["Reconnecting"] = "reconnecting";
|
|
22226
|
+
return ConnectionState2;
|
|
22227
|
+
})(ConnectionState || {});
|
|
21826
22228
|
function waitForEvent(emitter, eventName) {
|
|
21827
22229
|
return new Promise((resolve) => {
|
|
21828
22230
|
emitter.once(eventName, resolve);
|
|
@@ -21835,6 +22237,7 @@ var SesameConnection = class extends import_events2.EventEmitter {
|
|
|
21835
22237
|
this.numRetries = 0;
|
|
21836
22238
|
this.url = "";
|
|
21837
22239
|
this.autoReconnect = true;
|
|
22240
|
+
this._state = "disconnected" /* Disconnected */;
|
|
21838
22241
|
/* Bound listeners so we can removeEventListener later */
|
|
21839
22242
|
this.boundMessageHandler = (event) => this.messageHandler(event);
|
|
21840
22243
|
this.boundOpenHandler = () => this.openHandler();
|
|
@@ -21842,38 +22245,68 @@ var SesameConnection = class extends import_events2.EventEmitter {
|
|
|
21842
22245
|
this.boundErrorHandler = (event) => this.errorHandler(event);
|
|
21843
22246
|
this.openHandler = () => {
|
|
21844
22247
|
this.numRetries = 0;
|
|
22248
|
+
this.setState("connected" /* Connected */);
|
|
21845
22249
|
this.emit("open");
|
|
21846
22250
|
};
|
|
21847
22251
|
this.messageHandler = (event) => {
|
|
21848
22252
|
if (event.data instanceof ArrayBuffer) {
|
|
21849
|
-
const parsed =
|
|
21850
|
-
if (!parsed.valid)
|
|
21851
|
-
|
|
21852
|
-
|
|
21853
|
-
}
|
|
21854
|
-
|
|
21855
|
-
|
|
22253
|
+
const parsed = WireProtocol.parse(new Uint8Array(event.data));
|
|
22254
|
+
if (!parsed.valid) {
|
|
22255
|
+
this.emit("error", new Error("Invalid packet received"));
|
|
22256
|
+
return;
|
|
22257
|
+
}
|
|
22258
|
+
const frameType = parsed.header?.type;
|
|
22259
|
+
if (frameType === FrameType.FRAME_TYPE_RPC) {
|
|
21856
22260
|
this.emit("rpc", parsed.payload);
|
|
22261
|
+
} else {
|
|
22262
|
+
this.emit("media-packet", parsed);
|
|
21857
22263
|
}
|
|
21858
22264
|
}
|
|
21859
22265
|
};
|
|
21860
22266
|
this.url = options.url;
|
|
21861
22267
|
this.autoReconnect = options.autoReconnect;
|
|
21862
|
-
if (options.autoConnect) this.connect().catch(() =>
|
|
22268
|
+
if (options.autoConnect) this.connect().catch(() => {
|
|
22269
|
+
});
|
|
22270
|
+
}
|
|
22271
|
+
get state() {
|
|
22272
|
+
return this._state;
|
|
22273
|
+
}
|
|
22274
|
+
setState(newState) {
|
|
22275
|
+
if (this._state === newState) return;
|
|
22276
|
+
const prev = this._state;
|
|
22277
|
+
this._state = newState;
|
|
22278
|
+
switch (newState) {
|
|
22279
|
+
case "connected" /* Connected */:
|
|
22280
|
+
log.info("Connected to Sesame");
|
|
22281
|
+
break;
|
|
22282
|
+
case "reconnecting" /* Reconnecting */:
|
|
22283
|
+
if (prev === "connected" /* Connected */) {
|
|
22284
|
+
log.warn("Lost connection to Sesame, will try reconnect..");
|
|
22285
|
+
} else {
|
|
22286
|
+
log.warn("Failed to connect to Sesame, will try reconnect..");
|
|
22287
|
+
}
|
|
22288
|
+
break;
|
|
22289
|
+
case "disconnected" /* Disconnected */:
|
|
22290
|
+
log.info("Disconnected from Sesame");
|
|
22291
|
+
break;
|
|
22292
|
+
}
|
|
22293
|
+
this.emit("state", newState, prev);
|
|
21863
22294
|
}
|
|
21864
22295
|
isConnected() {
|
|
21865
22296
|
return this.socket !== void 0 && this.socket.readyState === WebSocket.OPEN;
|
|
21866
22297
|
}
|
|
21867
22298
|
async send(data) {
|
|
21868
22299
|
if (!this.isConnected()) throw new Error("Not connected");
|
|
21869
|
-
const header =
|
|
21870
|
-
const
|
|
21871
|
-
|
|
21872
|
-
this.socket.send(data_to_send);
|
|
22300
|
+
const header = { type: sesame.v1.wire.FrameType.FRAME_TYPE_RPC };
|
|
22301
|
+
const frame = WireProtocol.serialize(header, data);
|
|
22302
|
+
this.socket.send(frame);
|
|
21873
22303
|
return Promise.resolve();
|
|
21874
22304
|
}
|
|
21875
22305
|
async connect() {
|
|
21876
22306
|
this.active = true;
|
|
22307
|
+
if (this._state === "disconnected" /* Disconnected */) {
|
|
22308
|
+
this.setState("connecting" /* Connecting */);
|
|
22309
|
+
}
|
|
21877
22310
|
this.socket = new WebSocket(this.url);
|
|
21878
22311
|
this.socket.addEventListener("message", this.boundMessageHandler);
|
|
21879
22312
|
this.socket.addEventListener("open", this.boundOpenHandler);
|
|
@@ -21896,6 +22329,7 @@ var SesameConnection = class extends import_events2.EventEmitter {
|
|
|
21896
22329
|
async disconnect() {
|
|
21897
22330
|
this.active = false;
|
|
21898
22331
|
if (!this.socket) {
|
|
22332
|
+
this.setState("disconnected" /* Disconnected */);
|
|
21899
22333
|
return;
|
|
21900
22334
|
}
|
|
21901
22335
|
const sock = this.socket;
|
|
@@ -21913,7 +22347,8 @@ var SesameConnection = class extends import_events2.EventEmitter {
|
|
|
21913
22347
|
}
|
|
21914
22348
|
retryHandler() {
|
|
21915
22349
|
if (this.active && this.autoReconnect) {
|
|
21916
|
-
this.connect().catch((
|
|
22350
|
+
this.connect().catch(() => {
|
|
22351
|
+
});
|
|
21917
22352
|
}
|
|
21918
22353
|
}
|
|
21919
22354
|
closeHandler() {
|
|
@@ -21923,13 +22358,17 @@ var SesameConnection = class extends import_events2.EventEmitter {
|
|
|
21923
22358
|
}
|
|
21924
22359
|
this.socket = void 0;
|
|
21925
22360
|
if (this.active) {
|
|
21926
|
-
|
|
22361
|
+
if (this.autoReconnect) {
|
|
22362
|
+
this.setState("reconnecting" /* Reconnecting */);
|
|
21927
22363
|
setTimeout(() => {
|
|
21928
22364
|
this.retryHandler();
|
|
21929
22365
|
}, defaultBackoff(++this.numRetries));
|
|
21930
|
-
}
|
|
21931
|
-
|
|
22366
|
+
} else {
|
|
22367
|
+
this.active = false;
|
|
22368
|
+
this.setState("disconnected" /* Disconnected */);
|
|
21932
22369
|
}
|
|
22370
|
+
} else {
|
|
22371
|
+
this.setState("disconnected" /* Disconnected */);
|
|
21933
22372
|
}
|
|
21934
22373
|
}
|
|
21935
22374
|
errorHandler(error) {
|
|
@@ -21955,9 +22394,6 @@ var StatusApi = class {
|
|
|
21955
22394
|
async getIODevices() {
|
|
21956
22395
|
return this.rpc.service.requestIODeviceList(new sesame.v1.common.Empty());
|
|
21957
22396
|
}
|
|
21958
|
-
async requestKeyframe(outputId) {
|
|
21959
|
-
await this.rpc.service.requestKeyframe({ id: outputId });
|
|
21960
|
-
}
|
|
21961
22397
|
};
|
|
21962
22398
|
|
|
21963
22399
|
// src/recorder-api.ts
|
|
@@ -22106,10 +22542,7 @@ var SesameClient = class extends import_events3.EventEmitter {
|
|
|
22106
22542
|
constructor(portOrUrl) {
|
|
22107
22543
|
super();
|
|
22108
22544
|
this.subscriptions = [];
|
|
22109
|
-
this.
|
|
22110
|
-
this.onVideoPacket = () => {
|
|
22111
|
-
};
|
|
22112
|
-
this.onAudioPacket = () => {
|
|
22545
|
+
this.onMediaPacket = () => {
|
|
22113
22546
|
};
|
|
22114
22547
|
this.onCallbackMessage = () => {
|
|
22115
22548
|
};
|
|
@@ -22120,10 +22553,6 @@ var SesameClient = class extends import_events3.EventEmitter {
|
|
|
22120
22553
|
autoReconnect: true
|
|
22121
22554
|
});
|
|
22122
22555
|
this.conn.on("error", () => {
|
|
22123
|
-
if (!this.errorIsLogged) {
|
|
22124
|
-
log.warn("Could not connect to Sesame Engine, will keep trying..");
|
|
22125
|
-
this.errorIsLogged = true;
|
|
22126
|
-
}
|
|
22127
22556
|
});
|
|
22128
22557
|
let events = {
|
|
22129
22558
|
[sesame.v1.common.EventTopic.EVENT_TOPIC_ERROR]: sesame.v1.status.Event,
|
|
@@ -22148,18 +22577,18 @@ var SesameClient = class extends import_events3.EventEmitter {
|
|
|
22148
22577
|
}
|
|
22149
22578
|
});
|
|
22150
22579
|
this.rpc.on("error", (err) => {
|
|
22151
|
-
|
|
22580
|
+
if (this.isConnected()) {
|
|
22581
|
+
log.error(`RPC error: ${err.message}`);
|
|
22582
|
+
}
|
|
22152
22583
|
});
|
|
22153
22584
|
this.conn.on("open", async () => {
|
|
22154
22585
|
this.sendSubscriptions();
|
|
22155
|
-
this.errorIsLogged = false;
|
|
22156
22586
|
this.emit("connected");
|
|
22157
22587
|
});
|
|
22158
22588
|
this.conn.on("close", () => {
|
|
22159
22589
|
this.emit("disconnected");
|
|
22160
22590
|
});
|
|
22161
|
-
this.conn.on("
|
|
22162
|
-
this.conn.on("audio-packet", (data) => this.onAudioPacket(this.videoSubscriptionId, data));
|
|
22591
|
+
this.conn.on("media-packet", (frame) => this.onMediaPacket(this.mediaSubscriptionId, frame));
|
|
22163
22592
|
this.subscriptions = [];
|
|
22164
22593
|
}
|
|
22165
22594
|
isConnected() {
|
|
@@ -22169,14 +22598,14 @@ var SesameClient = class extends import_events3.EventEmitter {
|
|
|
22169
22598
|
if (!this.isConnected()) return;
|
|
22170
22599
|
const eventTopics = this.subscriptions.map((subscription) => subscription.topic);
|
|
22171
22600
|
const channels = [];
|
|
22172
|
-
if (this.
|
|
22601
|
+
if (this.mediaSubscriptionId) channels.push(`media-stream/${this.mediaSubscriptionId}`);
|
|
22173
22602
|
let subs = { eventTopics, channels };
|
|
22174
22603
|
this.rpc.service.updateSubscriptions(subs).catch((err) => {
|
|
22175
22604
|
log.error(`Failed to update subscriptions: ${err.message}`);
|
|
22176
22605
|
});
|
|
22177
22606
|
}
|
|
22178
|
-
|
|
22179
|
-
this.
|
|
22607
|
+
addMediaSubscription(id) {
|
|
22608
|
+
this.mediaSubscriptionId = id;
|
|
22180
22609
|
this.sendSubscriptions();
|
|
22181
22610
|
}
|
|
22182
22611
|
addSubscription(topic, callback) {
|
|
@@ -22195,6 +22624,9 @@ var SesameClient = class extends import_events3.EventEmitter {
|
|
|
22195
22624
|
getService() {
|
|
22196
22625
|
return this.rpc;
|
|
22197
22626
|
}
|
|
22627
|
+
async requestKeyframe(outputId) {
|
|
22628
|
+
await this.rpc.service.requestKeyframe({ id: outputId });
|
|
22629
|
+
}
|
|
22198
22630
|
async execute(cl) {
|
|
22199
22631
|
cl.filterCreatedAndDestroyedSources();
|
|
22200
22632
|
if (cl.getCommandListMsg().commandList.length > 0) {
|
|
@@ -22215,19 +22647,21 @@ var Event = sesame.v1.rpc.Event;
|
|
|
22215
22647
|
0 && (module.exports = {
|
|
22216
22648
|
CodecType,
|
|
22217
22649
|
CommandList,
|
|
22650
|
+
ConnectionState,
|
|
22218
22651
|
EaseKind,
|
|
22219
22652
|
Event,
|
|
22653
|
+
FrameHeader,
|
|
22654
|
+
FrameType,
|
|
22220
22655
|
JobsApi,
|
|
22221
22656
|
Message,
|
|
22222
|
-
PacketType,
|
|
22223
22657
|
RPCClient,
|
|
22224
22658
|
RecorderApi,
|
|
22225
22659
|
Request,
|
|
22226
22660
|
Response,
|
|
22227
|
-
SesameBinaryProtocol,
|
|
22228
22661
|
SesameClient,
|
|
22229
22662
|
SesameConnection,
|
|
22230
22663
|
StatusApi,
|
|
22664
|
+
WireProtocol,
|
|
22231
22665
|
getLogger,
|
|
22232
22666
|
log,
|
|
22233
22667
|
sesame,
|