@roboflow/inference-sdk 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +156 -139
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/webrtc.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
var q = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var j = (r, e, t) => e in r ? q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var u = (r, e, t) => j(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var O;
|
|
5
|
-
const
|
|
5
|
+
const K = typeof process < "u" && ((O = process.env) != null && O.RF_API_BASE_URL) ? process.env.RF_API_BASE_URL : "https://api.roboflow.com", V = [
|
|
6
6
|
"https://serverless.roboflow.com",
|
|
7
7
|
"https://serverless.roboflow.one"
|
|
8
8
|
];
|
|
9
|
-
class
|
|
9
|
+
class k {
|
|
10
10
|
/**
|
|
11
11
|
* @private
|
|
12
12
|
* Use InferenceHTTPClient.init() instead
|
|
13
13
|
*/
|
|
14
|
-
constructor(e, t = "https://serverless.roboflow.com", n =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
constructor(e, t = "https://serverless.roboflow.com", n = K) {
|
|
15
|
+
u(this, "apiKey");
|
|
16
|
+
u(this, "serverUrl");
|
|
17
|
+
u(this, "apiBaseUrl");
|
|
18
18
|
this.apiKey = e, this.serverUrl = t, this.apiBaseUrl = n;
|
|
19
19
|
}
|
|
20
20
|
static init({ apiKey: e, serverUrl: t, apiBaseUrl: n }) {
|
|
21
21
|
if (!e)
|
|
22
22
|
throw new Error("apiKey is required");
|
|
23
|
-
return new
|
|
23
|
+
return new k(e, t, n);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Initialize a WebRTC worker pipeline
|
|
@@ -62,21 +62,21 @@ class E {
|
|
|
62
62
|
if (i && f)
|
|
63
63
|
throw new Error("Provide either workflowSpec OR (workspaceName + workflowId), not both");
|
|
64
64
|
const {
|
|
65
|
-
imageInputName:
|
|
66
|
-
streamOutputNames:
|
|
67
|
-
dataOutputNames:
|
|
65
|
+
imageInputName: l = "image",
|
|
66
|
+
streamOutputNames: s = [],
|
|
67
|
+
dataOutputNames: c = [],
|
|
68
68
|
threadPoolWorkers: y = 4,
|
|
69
69
|
workflowsParameters: S = {},
|
|
70
|
-
iceServers:
|
|
71
|
-
processingTimeout:
|
|
72
|
-
requestedPlan:
|
|
70
|
+
iceServers: h,
|
|
71
|
+
processingTimeout: d,
|
|
72
|
+
requestedPlan: p,
|
|
73
73
|
requestedRegion: C,
|
|
74
|
-
realtimeProcessing:
|
|
75
|
-
rtspUrl:
|
|
74
|
+
realtimeProcessing: R = !0,
|
|
75
|
+
rtspUrl: b,
|
|
76
76
|
extraPayload: _
|
|
77
77
|
} = o, w = {
|
|
78
78
|
type: "WorkflowConfiguration",
|
|
79
|
-
image_input_name:
|
|
79
|
+
image_input_name: l,
|
|
80
80
|
workflows_parameters: S,
|
|
81
81
|
workflows_thread_pool_workers: y,
|
|
82
82
|
cancel_thread_pool_tasks_on_exit: !0,
|
|
@@ -86,24 +86,24 @@ class E {
|
|
|
86
86
|
const m = {
|
|
87
87
|
workflow_configuration: w,
|
|
88
88
|
api_key: this.apiKey,
|
|
89
|
-
webrtc_realtime_processing:
|
|
89
|
+
webrtc_realtime_processing: R,
|
|
90
90
|
webrtc_offer: {
|
|
91
91
|
sdp: e.sdp,
|
|
92
92
|
type: e.type
|
|
93
93
|
},
|
|
94
|
-
webrtc_config:
|
|
95
|
-
stream_output:
|
|
96
|
-
data_output:
|
|
94
|
+
webrtc_config: h ? { iceServers: h } : null,
|
|
95
|
+
stream_output: s,
|
|
96
|
+
data_output: c
|
|
97
97
|
};
|
|
98
|
-
|
|
98
|
+
d !== void 0 && (m.processing_timeout = d), p !== void 0 && (m.requested_plan = p), C !== void 0 && (m.requested_region = C), b && (m.rtsp_url = b), _ && Object.assign(m, _);
|
|
99
99
|
const v = await fetch(`${this.serverUrl}/initialise_webrtc_worker`, {
|
|
100
100
|
method: "POST",
|
|
101
101
|
headers: { "Content-Type": "application/json" },
|
|
102
102
|
body: JSON.stringify(m)
|
|
103
103
|
});
|
|
104
104
|
if (!v.ok) {
|
|
105
|
-
const
|
|
106
|
-
throw new Error(`initialise_webrtc_worker failed (${v.status}): ${
|
|
105
|
+
const T = await v.text().catch(() => "");
|
|
106
|
+
throw new Error(`initialise_webrtc_worker failed (${v.status}): ${T}`);
|
|
107
107
|
}
|
|
108
108
|
return await v.json();
|
|
109
109
|
}
|
|
@@ -167,7 +167,7 @@ class E {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
const
|
|
170
|
+
const oe = {
|
|
171
171
|
/**
|
|
172
172
|
* Create a connector that uses API key directly
|
|
173
173
|
*
|
|
@@ -191,7 +191,7 @@ const ie = {
|
|
|
191
191
|
typeof window < "u" && console.warn(
|
|
192
192
|
"[Security Warning] Using API key directly in browser will expose it. Use connectors.withProxyUrl() for production. See: https://docs.roboflow.com/api-reference/authentication#securing-your-api-key"
|
|
193
193
|
);
|
|
194
|
-
const a =
|
|
194
|
+
const a = k.init({ apiKey: r, serverUrl: t, apiBaseUrl: n });
|
|
195
195
|
return {
|
|
196
196
|
connectWrtc: async (o, i) => (console.debug("wrtcParams", i), await a.initializeWebrtcWorker({
|
|
197
197
|
offer: o,
|
|
@@ -335,20 +335,20 @@ async function $(r = { video: !0 }) {
|
|
|
335
335
|
function D(r) {
|
|
336
336
|
r && (r.getTracks().forEach((e) => e.stop()), console.log("[RFStreams] Stream stopped"));
|
|
337
337
|
}
|
|
338
|
-
const
|
|
338
|
+
const se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
339
339
|
__proto__: null,
|
|
340
340
|
stopStream: D,
|
|
341
341
|
useCamera: $
|
|
342
342
|
}, Symbol.toStringTag, { value: "Module" })), F = 49152, M = 262144, z = 10;
|
|
343
|
-
function
|
|
343
|
+
function G(r) {
|
|
344
344
|
return new Promise((e) => setTimeout(e, r));
|
|
345
345
|
}
|
|
346
|
-
class
|
|
346
|
+
class A {
|
|
347
347
|
constructor(e, t) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
348
|
+
u(this, "file");
|
|
349
|
+
u(this, "channel");
|
|
350
|
+
u(this, "totalChunks");
|
|
351
|
+
u(this, "cancelled", !1);
|
|
352
352
|
this.file = e, this.channel = t, this.totalChunks = Math.ceil(e.size / F);
|
|
353
353
|
}
|
|
354
354
|
/**
|
|
@@ -369,20 +369,20 @@ class N {
|
|
|
369
369
|
throw new Error("Upload cancelled");
|
|
370
370
|
if (this.channel.readyState !== "open")
|
|
371
371
|
throw new Error("Video upload interrupted");
|
|
372
|
-
const a = n * F, o = Math.min(a + F, t), i = this.file.slice(a, o), f = new Uint8Array(await i.arrayBuffer()),
|
|
373
|
-
for (
|
|
372
|
+
const a = n * F, o = Math.min(a + F, t), i = this.file.slice(a, o), f = new Uint8Array(await i.arrayBuffer()), l = new ArrayBuffer(8 + f.length), s = new DataView(l);
|
|
373
|
+
for (s.setUint32(0, n, !0), s.setUint32(4, this.totalChunks, !0), new Uint8Array(l, 8).set(f); this.channel.bufferedAmount > M; ) {
|
|
374
374
|
if (this.channel.readyState !== "open")
|
|
375
375
|
throw new Error("Video upload interrupted");
|
|
376
|
-
await
|
|
376
|
+
await G(z);
|
|
377
377
|
}
|
|
378
|
-
this.channel.send(
|
|
378
|
+
this.channel.send(l), e && e(o, t);
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
const
|
|
383
|
-
class
|
|
382
|
+
const H = 12;
|
|
383
|
+
class N {
|
|
384
384
|
constructor() {
|
|
385
|
-
|
|
385
|
+
u(this, "pendingFrames", /* @__PURE__ */ new Map());
|
|
386
386
|
}
|
|
387
387
|
/**
|
|
388
388
|
* Process an incoming chunk and return the complete message if all chunks received
|
|
@@ -396,11 +396,11 @@ class A {
|
|
|
396
396
|
});
|
|
397
397
|
const o = this.pendingFrames.get(e);
|
|
398
398
|
if (o.chunks.set(t, a), o.chunks.size === n) {
|
|
399
|
-
const i = Array.from(o.chunks.values()).reduce((
|
|
400
|
-
let
|
|
401
|
-
for (let
|
|
402
|
-
const
|
|
403
|
-
f.set(
|
|
399
|
+
const i = Array.from(o.chunks.values()).reduce((s, c) => s + c.length, 0), f = new Uint8Array(i);
|
|
400
|
+
let l = 0;
|
|
401
|
+
for (let s = 0; s < n; s++) {
|
|
402
|
+
const c = o.chunks.get(s);
|
|
403
|
+
f.set(c, l), l += c.length;
|
|
404
404
|
}
|
|
405
405
|
return this.pendingFrames.delete(e), f;
|
|
406
406
|
}
|
|
@@ -414,10 +414,25 @@ class A {
|
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
function x(r) {
|
|
417
|
-
const e = new DataView(r), t = e.getUint32(0, !0), n = e.getUint32(4, !0), a = e.getUint32(8, !0), o = new Uint8Array(r,
|
|
417
|
+
const e = new DataView(r), t = e.getUint32(0, !0), n = e.getUint32(4, !0), a = e.getUint32(8, !0), o = new Uint8Array(r, H);
|
|
418
418
|
return { frameId: t, chunkIndex: n, totalChunks: a, payload: o };
|
|
419
419
|
}
|
|
420
|
-
async function
|
|
420
|
+
async function J(r) {
|
|
421
|
+
const e = new DecompressionStream("gzip"), t = e.writable.getWriter();
|
|
422
|
+
t.write(r), t.close();
|
|
423
|
+
const n = e.readable.getReader(), a = [];
|
|
424
|
+
for (; ; ) {
|
|
425
|
+
const { done: l, value: s } = await n.read();
|
|
426
|
+
if (l) break;
|
|
427
|
+
a.push(s);
|
|
428
|
+
}
|
|
429
|
+
const o = a.reduce((l, s) => l + s.length, 0), i = new Uint8Array(o);
|
|
430
|
+
let f = 0;
|
|
431
|
+
for (const l of a)
|
|
432
|
+
i.set(l, f), f += l.length;
|
|
433
|
+
return i;
|
|
434
|
+
}
|
|
435
|
+
async function Z(r, e = 6e3) {
|
|
421
436
|
if (r.iceGatheringState === "complete") return;
|
|
422
437
|
let t = !1;
|
|
423
438
|
const n = (a) => {
|
|
@@ -442,52 +457,52 @@ async function G(r, e = 6e3) {
|
|
|
442
457
|
r.removeEventListener("icecandidate", n);
|
|
443
458
|
}
|
|
444
459
|
}
|
|
445
|
-
function
|
|
460
|
+
function Q(r) {
|
|
446
461
|
return new Promise((e) => {
|
|
447
462
|
r.addEventListener("track", (t) => {
|
|
448
463
|
t.streams && t.streams[0] && e(t.streams[0]);
|
|
449
464
|
});
|
|
450
465
|
});
|
|
451
466
|
}
|
|
452
|
-
const
|
|
467
|
+
const X = [
|
|
453
468
|
{ urls: ["stun:stun.l.google.com:19302"] }
|
|
454
469
|
];
|
|
455
|
-
async function
|
|
470
|
+
async function Y(r, e, t, n, a) {
|
|
456
471
|
if ([!!r, !!e, !!n].filter(Boolean).length !== 1)
|
|
457
472
|
throw new Error("Exactly one of localStream, file, or rtspUrl must be provided");
|
|
458
|
-
const
|
|
459
|
-
iceServers:
|
|
473
|
+
const s = t ?? X, c = new RTCPeerConnection({
|
|
474
|
+
iceServers: s
|
|
460
475
|
});
|
|
461
|
-
a != null && a.onPeerConnectionCreated && await a.onPeerConnectionCreated(
|
|
476
|
+
a != null && a.onPeerConnectionCreated && await a.onPeerConnectionCreated(c);
|
|
462
477
|
try {
|
|
463
|
-
|
|
464
|
-
} catch (
|
|
465
|
-
console.warn("[RFWebRTC] Could not add transceiver:",
|
|
478
|
+
c.addTransceiver("video", { direction: "recvonly" });
|
|
479
|
+
} catch (p) {
|
|
480
|
+
console.warn("[RFWebRTC] Could not add transceiver:", p);
|
|
466
481
|
}
|
|
467
482
|
if (r)
|
|
468
|
-
for (const
|
|
469
|
-
const C =
|
|
470
|
-
a != null && a.onTrackAdded && await a.onTrackAdded(
|
|
483
|
+
for (const p of r.getVideoTracks()) {
|
|
484
|
+
const C = c.addTrack(p, r);
|
|
485
|
+
a != null && a.onTrackAdded && await a.onTrackAdded(p, C, c);
|
|
471
486
|
}
|
|
472
|
-
const y =
|
|
487
|
+
const y = Q(c), S = c.createDataChannel("inference", {
|
|
473
488
|
ordered: !0
|
|
474
489
|
});
|
|
475
|
-
let
|
|
476
|
-
e && (
|
|
477
|
-
let
|
|
490
|
+
let h;
|
|
491
|
+
e && (h = c.createDataChannel("video_upload"));
|
|
492
|
+
let d = await c.createOffer();
|
|
478
493
|
if (a != null && a.onOfferCreated) {
|
|
479
|
-
const
|
|
480
|
-
|
|
494
|
+
const p = await a.onOfferCreated(d);
|
|
495
|
+
p && (d = p);
|
|
481
496
|
}
|
|
482
|
-
return await
|
|
483
|
-
pc:
|
|
484
|
-
offer:
|
|
497
|
+
return await c.setLocalDescription(d), await Z(c), {
|
|
498
|
+
pc: c,
|
|
499
|
+
offer: c.localDescription,
|
|
485
500
|
remoteStreamPromise: y,
|
|
486
501
|
dataChannel: S,
|
|
487
|
-
uploadChannel:
|
|
502
|
+
uploadChannel: h
|
|
488
503
|
};
|
|
489
504
|
}
|
|
490
|
-
async function
|
|
505
|
+
async function ee(r) {
|
|
491
506
|
const e = r.getSenders().find((n) => n.track && n.track.kind === "video");
|
|
492
507
|
if (!e) return;
|
|
493
508
|
const t = e.getParameters();
|
|
@@ -498,7 +513,7 @@ async function Y(r) {
|
|
|
498
513
|
console.warn("[RFWebRTC] Failed to set encoding parameters:", n);
|
|
499
514
|
}
|
|
500
515
|
}
|
|
501
|
-
function
|
|
516
|
+
function te(r, e = 3e4) {
|
|
502
517
|
return new Promise((t, n) => {
|
|
503
518
|
if (r.readyState === "open") {
|
|
504
519
|
t();
|
|
@@ -521,46 +536,48 @@ class B {
|
|
|
521
536
|
* The underlying RTCPeerConnection.
|
|
522
537
|
* Exposed for advanced use cases like getting stats or accessing senders.
|
|
523
538
|
*/
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
539
|
+
u(this, "peerConnection");
|
|
540
|
+
u(this, "_localStream");
|
|
541
|
+
u(this, "remoteStreamPromise");
|
|
542
|
+
u(this, "pipelineId");
|
|
543
|
+
u(this, "apiKey");
|
|
529
544
|
/**
|
|
530
545
|
* The data channel used for receiving inference results.
|
|
531
546
|
* Exposed for advanced use cases.
|
|
532
547
|
*/
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
548
|
+
u(this, "dataChannel");
|
|
549
|
+
u(this, "reassembler");
|
|
550
|
+
u(this, "ackPacingEnabled");
|
|
536
551
|
/**
|
|
537
552
|
* The data channel used for uploading video files (only available in file upload mode).
|
|
538
553
|
* Exposed for advanced use cases.
|
|
539
554
|
*/
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
this.peerConnection = e, this._localStream = i == null ? void 0 : i.localStream, this.remoteStreamPromise = t, this.pipelineId = n, this.apiKey = a, this.dataChannel = o, this.reassembler = new
|
|
555
|
+
u(this, "uploadChannel");
|
|
556
|
+
u(this, "uploader");
|
|
557
|
+
u(this, "onComplete");
|
|
558
|
+
this.peerConnection = e, this._localStream = i == null ? void 0 : i.localStream, this.remoteStreamPromise = t, this.pipelineId = n, this.apiKey = a, this.dataChannel = o, this.reassembler = new N(), this.ackPacingEnabled = (i == null ? void 0 : i.ackPacingEnabled) === !0, this.uploadChannel = i == null ? void 0 : i.uploadChannel, this.onComplete = i == null ? void 0 : i.onComplete, this.dataChannel.binaryType = "arraybuffer";
|
|
544
559
|
const f = i == null ? void 0 : i.onData;
|
|
545
|
-
f && (this.dataChannel.addEventListener("message", (
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
560
|
+
f && (this.dataChannel.addEventListener("message", (l) => {
|
|
561
|
+
(async () => {
|
|
562
|
+
try {
|
|
563
|
+
if (l.data instanceof ArrayBuffer) {
|
|
564
|
+
const { frameId: s, chunkIndex: c, totalChunks: y, payload: S } = x(l.data), h = this.reassembler.processChunk(s, c, y, S);
|
|
565
|
+
if (h) {
|
|
566
|
+
let d;
|
|
567
|
+
h[0] === 31 && h[1] === 139 ? d = await J(h) : d = h;
|
|
568
|
+
const C = new TextDecoder("utf-8").decode(d), R = JSON.parse(C);
|
|
569
|
+
await Promise.resolve(f(R)), this.maybeSendAck(s);
|
|
570
|
+
}
|
|
571
|
+
} else {
|
|
572
|
+
const s = JSON.parse(l.data);
|
|
573
|
+
f(s);
|
|
554
574
|
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
f(c);
|
|
575
|
+
} catch (s) {
|
|
576
|
+
console.error("[RFWebRTC] Failed to parse data channel message:", s);
|
|
558
577
|
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}), this.dataChannel.addEventListener("error", (d) => {
|
|
563
|
-
console.error("[RFWebRTC] Data channel error:", d);
|
|
578
|
+
})();
|
|
579
|
+
}), this.dataChannel.addEventListener("error", (l) => {
|
|
580
|
+
console.error("[RFWebRTC] Data channel error:", l);
|
|
564
581
|
})), this.dataChannel.addEventListener("close", () => {
|
|
565
582
|
this.reassembler.clear(), this.onComplete && this.onComplete();
|
|
566
583
|
});
|
|
@@ -622,7 +639,7 @@ class B {
|
|
|
622
639
|
async cleanup() {
|
|
623
640
|
if (this.uploader && this.uploader.cancel(), this.reassembler.clear(), this.pipelineId && this.apiKey)
|
|
624
641
|
try {
|
|
625
|
-
await
|
|
642
|
+
await k.init({ apiKey: this.apiKey }).terminatePipeline({ pipelineId: this.pipelineId });
|
|
626
643
|
} catch (e) {
|
|
627
644
|
console.warn("[RFWebRTC] Failed to terminate pipeline:", e);
|
|
628
645
|
}
|
|
@@ -646,7 +663,7 @@ class B {
|
|
|
646
663
|
async startUpload(e, t) {
|
|
647
664
|
if (!this.uploadChannel)
|
|
648
665
|
throw new Error("No upload channel available. This connection was not created for file uploads.");
|
|
649
|
-
await
|
|
666
|
+
await te(this.uploadChannel), this.uploader = new A(e, this.uploadChannel), await this.uploader.upload(t);
|
|
650
667
|
}
|
|
651
668
|
/**
|
|
652
669
|
* Cancel any ongoing file upload
|
|
@@ -716,65 +733,65 @@ async function U({
|
|
|
716
733
|
onComplete: o,
|
|
717
734
|
onFileUploadProgress: i,
|
|
718
735
|
options: f = {},
|
|
719
|
-
hooks:
|
|
736
|
+
hooks: l
|
|
720
737
|
}) {
|
|
721
738
|
var L;
|
|
722
739
|
if (!t || typeof t.connectWrtc != "function")
|
|
723
740
|
throw new Error("connector must have a connectWrtc method");
|
|
724
|
-
const
|
|
725
|
-
let
|
|
726
|
-
if ((!
|
|
741
|
+
const s = !!e, c = !s && r instanceof File, y = !s && !c && r ? r : void 0, S = c ? r : void 0;
|
|
742
|
+
let h = n.iceServers;
|
|
743
|
+
if ((!h || h.length === 0) && t.getIceServers)
|
|
727
744
|
try {
|
|
728
745
|
const g = await t.getIceServers();
|
|
729
|
-
g && g.length > 0 && (
|
|
746
|
+
g && g.length > 0 && (h = g);
|
|
730
747
|
} catch (g) {
|
|
731
748
|
console.warn("[RFWebRTC] Failed to fetch TURN config, using defaults:", g);
|
|
732
749
|
}
|
|
733
|
-
const { pc:
|
|
750
|
+
const { pc: d, offer: p, remoteStreamPromise: C, dataChannel: R, uploadChannel: b } = await Y(
|
|
734
751
|
y,
|
|
735
752
|
S,
|
|
736
|
-
|
|
753
|
+
h,
|
|
737
754
|
e,
|
|
738
|
-
|
|
755
|
+
l
|
|
739
756
|
), _ = {
|
|
740
757
|
...n,
|
|
741
|
-
iceServers:
|
|
742
|
-
realtimeProcessing: n.realtimeProcessing ?? !
|
|
758
|
+
iceServers: h,
|
|
759
|
+
realtimeProcessing: n.realtimeProcessing ?? !c,
|
|
743
760
|
rtspUrl: e
|
|
744
761
|
}, w = await t.connectWrtc(
|
|
745
|
-
{ sdp:
|
|
762
|
+
{ sdp: p.sdp, type: p.type },
|
|
746
763
|
_
|
|
747
764
|
), m = { sdp: w.sdp, type: w.type };
|
|
748
765
|
if (!(m != null && m.sdp) || !(m != null && m.type))
|
|
749
766
|
throw console.error("[RFWebRTC] Invalid answer from server:", w), new Error("connector.connectWrtc must return answer with sdp and type");
|
|
750
767
|
const v = ((L = w == null ? void 0 : w.context) == null ? void 0 : L.pipeline_id) || null;
|
|
751
|
-
await
|
|
752
|
-
const
|
|
753
|
-
|
|
768
|
+
await d.setRemoteDescription(m), await new Promise((g, I) => {
|
|
769
|
+
const E = () => {
|
|
770
|
+
d.connectionState === "connected" ? (d.removeEventListener("connectionstatechange", E), g()) : d.connectionState === "failed" && (d.removeEventListener("connectionstatechange", E), I(new Error("WebRTC connection failed")));
|
|
754
771
|
};
|
|
755
|
-
|
|
756
|
-
|
|
772
|
+
d.addEventListener("connectionstatechange", E), E(), setTimeout(() => {
|
|
773
|
+
d.removeEventListener("connectionstatechange", E), I(new Error("WebRTC connection timeout after 30s"));
|
|
757
774
|
}, 3e4);
|
|
758
|
-
}), y && f.disableInputStreamDownscaling !== !1 && await
|
|
759
|
-
const P = t._apiKey || null,
|
|
760
|
-
|
|
775
|
+
}), y && f.disableInputStreamDownscaling !== !1 && await ee(d);
|
|
776
|
+
const P = t._apiKey || null, T = _.realtimeProcessing === !1, W = new B(
|
|
777
|
+
d,
|
|
761
778
|
C,
|
|
762
779
|
v,
|
|
763
780
|
P,
|
|
764
|
-
|
|
781
|
+
R,
|
|
765
782
|
{
|
|
766
783
|
localStream: y,
|
|
767
|
-
uploadChannel:
|
|
784
|
+
uploadChannel: b,
|
|
768
785
|
onData: a,
|
|
769
786
|
onComplete: o,
|
|
770
|
-
ackPacingEnabled:
|
|
787
|
+
ackPacingEnabled: T
|
|
771
788
|
}
|
|
772
789
|
);
|
|
773
|
-
return S &&
|
|
790
|
+
return S && b && W.startUpload(S, i).catch((g) => {
|
|
774
791
|
console.error("[RFWebRTC] Upload error:", g);
|
|
775
792
|
}), W;
|
|
776
793
|
}
|
|
777
|
-
async function
|
|
794
|
+
async function re({
|
|
778
795
|
source: r,
|
|
779
796
|
connector: e,
|
|
780
797
|
wrtcParams: t,
|
|
@@ -793,7 +810,7 @@ async function te({
|
|
|
793
810
|
hooks: o
|
|
794
811
|
});
|
|
795
812
|
}
|
|
796
|
-
async function
|
|
813
|
+
async function ne({
|
|
797
814
|
file: r,
|
|
798
815
|
connector: e,
|
|
799
816
|
wrtcParams: t,
|
|
@@ -815,7 +832,7 @@ async function re({
|
|
|
815
832
|
hooks: i
|
|
816
833
|
});
|
|
817
834
|
}
|
|
818
|
-
async function
|
|
835
|
+
async function ae({
|
|
819
836
|
rtspUrl: r,
|
|
820
837
|
connector: e,
|
|
821
838
|
wrtcParams: t,
|
|
@@ -832,20 +849,20 @@ async function ne({
|
|
|
832
849
|
hooks: a
|
|
833
850
|
});
|
|
834
851
|
}
|
|
835
|
-
const
|
|
852
|
+
const ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
836
853
|
__proto__: null,
|
|
837
|
-
ChunkReassembler:
|
|
838
|
-
FileUploader:
|
|
854
|
+
ChunkReassembler: N,
|
|
855
|
+
FileUploader: A,
|
|
839
856
|
RFWebRTCConnection: B,
|
|
840
857
|
parseBinaryHeader: x,
|
|
841
|
-
useRtspStream:
|
|
842
|
-
useStream:
|
|
843
|
-
useVideoFile:
|
|
858
|
+
useRtspStream: ae,
|
|
859
|
+
useStream: re,
|
|
860
|
+
useVideoFile: ne
|
|
844
861
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
845
862
|
export {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
863
|
+
k as InferenceHTTPClient,
|
|
864
|
+
oe as connectors,
|
|
865
|
+
se as streams,
|
|
866
|
+
ce as webrtc
|
|
850
867
|
};
|
|
851
868
|
//# sourceMappingURL=index.es.js.map
|