@decartai/sdk 0.0.13 → 0.0.15
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/realtime/client.js
CHANGED
|
@@ -40,7 +40,9 @@ const createRealTimeClient = (opts) => {
|
|
|
40
40
|
console.error("WebRTC error:", error);
|
|
41
41
|
eventEmitter.emit("error", createWebrtcError(error));
|
|
42
42
|
},
|
|
43
|
-
customizeOffer: options.customizeOffer
|
|
43
|
+
customizeOffer: options.customizeOffer,
|
|
44
|
+
vp8MinBitrate: 200,
|
|
45
|
+
vp8StartBitrate: 600
|
|
44
46
|
});
|
|
45
47
|
await webrtcManager.connect(stream);
|
|
46
48
|
const methods = realtimeMethods(webrtcManager);
|
|
@@ -11,7 +11,7 @@ var WebRTCConnection = class {
|
|
|
11
11
|
constructor(callbacks = {}) {
|
|
12
12
|
this.callbacks = callbacks;
|
|
13
13
|
}
|
|
14
|
-
async connect(url, localStream, timeout =
|
|
14
|
+
async connect(url, localStream, timeout = 35e3, integration) {
|
|
15
15
|
const deadline = Date.now() + timeout;
|
|
16
16
|
this.localStream = localStream;
|
|
17
17
|
const userAgent = encodeURIComponent(buildUserAgent(integration));
|
|
@@ -69,6 +69,7 @@ var WebRTCConnection = class {
|
|
|
69
69
|
case "ready": {
|
|
70
70
|
await this.applyCodecPreference("video/VP8");
|
|
71
71
|
const offer = await this.pc.createOffer();
|
|
72
|
+
this.modifyVP8Bitrate(offer);
|
|
72
73
|
await this.callbacks.customizeOffer?.(offer);
|
|
73
74
|
await this.pc.setLocalDescription(offer);
|
|
74
75
|
this.send({
|
|
@@ -187,6 +188,43 @@ var WebRTCConnection = class {
|
|
|
187
188
|
}
|
|
188
189
|
await videoTransceiver.setCodecPreferences(orderedCodecs);
|
|
189
190
|
}
|
|
191
|
+
modifyVP8Bitrate(offer) {
|
|
192
|
+
if (!offer.sdp) return;
|
|
193
|
+
const minBitrateInKbps = this.callbacks.vp8MinBitrate;
|
|
194
|
+
const startBitrateInKbps = this.callbacks.vp8StartBitrate;
|
|
195
|
+
if (minBitrateInKbps === 0 && startBitrateInKbps === 0) return;
|
|
196
|
+
const bitrateParams = `x-google-min-bitrate=${minBitrateInKbps};x-google-start-bitrate=${startBitrateInKbps}`;
|
|
197
|
+
const sdpLines = offer.sdp.split("\r\n");
|
|
198
|
+
const modifiedLines = [];
|
|
199
|
+
for (let i = 0; i < sdpLines.length; i++) {
|
|
200
|
+
if (sdpLines[i].includes("VP8/90000")) {
|
|
201
|
+
const match = sdpLines[i].match(/a=rtpmap:(\d+) VP8/);
|
|
202
|
+
if (match) {
|
|
203
|
+
const payloadType = match[1];
|
|
204
|
+
let fmtpIndex = -1;
|
|
205
|
+
let insertAfterIndex = i;
|
|
206
|
+
for (let j = i + 1; j < sdpLines.length && sdpLines[j].startsWith("a="); j++) {
|
|
207
|
+
if (sdpLines[j].startsWith(`a=fmtp:${payloadType}`)) {
|
|
208
|
+
fmtpIndex = j;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
if (sdpLines[j].startsWith(`a=rtcp-fb:${payloadType}`)) insertAfterIndex = j;
|
|
212
|
+
if (sdpLines[j].startsWith("a=rtpmap:")) break;
|
|
213
|
+
}
|
|
214
|
+
if (fmtpIndex !== -1) {
|
|
215
|
+
if (!sdpLines[fmtpIndex].includes("x-google-min-bitrate")) sdpLines[fmtpIndex] += `;${bitrateParams}`;
|
|
216
|
+
} else {
|
|
217
|
+
for (let k = i; k <= insertAfterIndex; k++) modifiedLines.push(sdpLines[k]);
|
|
218
|
+
modifiedLines.push(`a=fmtp:${payloadType} ${bitrateParams}`);
|
|
219
|
+
i = insertAfterIndex;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
modifiedLines.push(sdpLines[i]);
|
|
225
|
+
}
|
|
226
|
+
offer.sdp = modifiedLines.join("\r\n");
|
|
227
|
+
}
|
|
190
228
|
};
|
|
191
229
|
|
|
192
230
|
//#endregion
|
|
@@ -19,7 +19,9 @@ var WebRTCManager = class {
|
|
|
19
19
|
onRemoteStream: config.onRemoteStream,
|
|
20
20
|
onStateChange: config.onConnectionStateChange,
|
|
21
21
|
onError: config.onError,
|
|
22
|
-
customizeOffer: config.customizeOffer
|
|
22
|
+
customizeOffer: config.customizeOffer,
|
|
23
|
+
vp8MinBitrate: config.vp8MinBitrate,
|
|
24
|
+
vp8StartBitrate: config.vp8StartBitrate
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
async connect(localStream) {
|
package/dist/shared/model.d.ts
CHANGED
|
@@ -47,10 +47,7 @@ declare const modelInputSchemas: {
|
|
|
47
47
|
prompt: z.ZodString;
|
|
48
48
|
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL]>;
|
|
49
49
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
50
|
-
resolution: z.ZodDefault<z.ZodOptional<z.
|
|
51
|
-
"720p": "720p";
|
|
52
|
-
"480p": "480p";
|
|
53
|
-
}>>>;
|
|
50
|
+
resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
|
|
54
51
|
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
55
52
|
num_inference_steps: z.ZodOptional<z.ZodNumber>;
|
|
56
53
|
}, z.core.$strip>;
|
package/dist/shared/model.js
CHANGED
|
@@ -45,36 +45,36 @@ const proResolutionSchema = () => {
|
|
|
45
45
|
*/
|
|
46
46
|
const motionResolutionSchema = z.literal("720p").default("720p").optional().describe("The resolution to use for the generation");
|
|
47
47
|
/**
|
|
48
|
-
* Resolution schema for lucy-pro-v2v (supports 720p
|
|
48
|
+
* Resolution schema for lucy-pro-v2v (supports 720p).
|
|
49
49
|
*/
|
|
50
|
-
const proV2vResolutionSchema = z.
|
|
50
|
+
const proV2vResolutionSchema = z.literal("720p").optional().describe("The resolution to use for the generation").default("720p");
|
|
51
51
|
const modelInputSchemas = {
|
|
52
52
|
"lucy-pro-t2v": z.object({
|
|
53
|
-
prompt: z.string().describe("The prompt to use for the generation"),
|
|
53
|
+
prompt: z.string().min(1).max(1e3).describe("The prompt to use for the generation"),
|
|
54
54
|
seed: z.number().optional().describe("The seed to use for the generation"),
|
|
55
55
|
resolution: proResolutionSchema(),
|
|
56
56
|
orientation: z.string().optional().describe("The orientation to use for the generation")
|
|
57
57
|
}),
|
|
58
58
|
"lucy-pro-t2i": z.object({
|
|
59
|
-
prompt: z.string().describe("The prompt to use for the generation"),
|
|
59
|
+
prompt: z.string().min(1).max(1e3).describe("The prompt to use for the generation"),
|
|
60
60
|
seed: z.number().optional().describe("The seed to use for the generation"),
|
|
61
61
|
resolution: proResolutionSchema(),
|
|
62
62
|
orientation: z.string().optional().describe("The orientation to use for the generation")
|
|
63
63
|
}),
|
|
64
64
|
"lucy-pro-i2v": z.object({
|
|
65
|
-
prompt: z.string().describe("The prompt to use for the generation"),
|
|
65
|
+
prompt: z.string().min(1).max(1e3).describe("The prompt to use for the generation"),
|
|
66
66
|
data: fileInputSchema.describe("The image data to use for generation (File, Blob, ReadableStream, URL, or string URL)"),
|
|
67
67
|
seed: z.number().optional().describe("The seed to use for the generation"),
|
|
68
68
|
resolution: proResolutionSchema()
|
|
69
69
|
}),
|
|
70
70
|
"lucy-dev-i2v": z.object({
|
|
71
|
-
prompt: z.string().describe("The prompt to use for the generation"),
|
|
71
|
+
prompt: z.string().min(1).max(1e3).describe("The prompt to use for the generation"),
|
|
72
72
|
data: fileInputSchema.describe("The image data to use for generation (File, Blob, ReadableStream, URL, or string URL)"),
|
|
73
73
|
seed: z.number().optional().describe("The seed to use for the generation"),
|
|
74
74
|
resolution: devResolutionSchema
|
|
75
75
|
}),
|
|
76
76
|
"lucy-pro-v2v": z.object({
|
|
77
|
-
prompt: z.string().describe("The prompt to use for the generation"),
|
|
77
|
+
prompt: z.string().min(1).max(1e3).describe("The prompt to use for the generation"),
|
|
78
78
|
data: fileInputSchema.describe("The video data to use for generation (File, Blob, ReadableStream, URL, or string URL)"),
|
|
79
79
|
seed: z.number().optional().describe("The seed to use for the generation"),
|
|
80
80
|
resolution: proV2vResolutionSchema,
|
|
@@ -82,21 +82,21 @@ const modelInputSchemas = {
|
|
|
82
82
|
num_inference_steps: z.number().optional().describe("The number of inference steps")
|
|
83
83
|
}),
|
|
84
84
|
"lucy-dev-v2v": z.object({
|
|
85
|
-
prompt: z.string().describe("The prompt to use for the generation"),
|
|
85
|
+
prompt: z.string().min(1).max(1e3).describe("The prompt to use for the generation"),
|
|
86
86
|
data: fileInputSchema.describe("The video data to use for generation (File, Blob, ReadableStream, URL, or string URL)"),
|
|
87
87
|
seed: z.number().optional().describe("The seed to use for the generation"),
|
|
88
88
|
resolution: devResolutionSchema,
|
|
89
89
|
enhance_prompt: z.boolean().optional().describe("Whether to enhance the prompt")
|
|
90
90
|
}),
|
|
91
91
|
"lucy-pro-flf2v": z.object({
|
|
92
|
-
prompt: z.string().describe("The prompt to use for the generation"),
|
|
92
|
+
prompt: z.string().min(1).max(1e3).describe("The prompt to use for the generation"),
|
|
93
93
|
start: fileInputSchema.describe("The start frame image (File, Blob, ReadableStream, URL, or string URL)"),
|
|
94
94
|
end: fileInputSchema.describe("The end frame image (File, Blob, ReadableStream, URL, or string URL)"),
|
|
95
95
|
seed: z.number().optional().describe("The seed to use for the generation"),
|
|
96
96
|
resolution: proResolutionSchema()
|
|
97
97
|
}),
|
|
98
98
|
"lucy-pro-i2i": z.object({
|
|
99
|
-
prompt: z.string().describe("The prompt to use for the generation"),
|
|
99
|
+
prompt: z.string().min(1).max(1e3).describe("The prompt to use for the generation"),
|
|
100
100
|
data: fileInputSchema.describe("The image data to use for generation (File, Blob, ReadableStream, URL, or string URL)"),
|
|
101
101
|
seed: z.number().optional().describe("The seed to use for the generation"),
|
|
102
102
|
resolution: proResolutionSchema(),
|
package/dist/version.js
CHANGED