@decartai/sdk 0.1.1 → 0.1.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.
|
@@ -50,6 +50,10 @@ declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
|
|
|
50
50
|
"720p": "720p";
|
|
51
51
|
"1080p": "1080p";
|
|
52
52
|
}>>;
|
|
53
|
+
preferredVideoCodec: z.ZodOptional<z.ZodEnum<{
|
|
54
|
+
h264: "h264";
|
|
55
|
+
vp9: "vp9";
|
|
56
|
+
}>>;
|
|
53
57
|
}, z.core.$strip>;
|
|
54
58
|
type RealTimeClientConnectOptions = Omit<z.infer<typeof realTimeClientConnectOptionsSchema>, "model"> & {
|
|
55
59
|
model: ModelDefinition | CustomModelDefinition;
|
package/dist/realtime/client.js
CHANGED
|
@@ -21,7 +21,8 @@ const realTimeClientConnectOptionsSchema = z.object({
|
|
|
21
21
|
initialState: realTimeClientInitialStateSchema.optional(),
|
|
22
22
|
queryParams: z.record(z.string(), z.string()).optional(),
|
|
23
23
|
mirror: z.union([z.literal("auto"), z.boolean()]).optional(),
|
|
24
|
-
resolution: z.enum(["720p", "1080p"]).optional()
|
|
24
|
+
resolution: z.enum(["720p", "1080p"]).optional(),
|
|
25
|
+
preferredVideoCodec: z.enum(["h264", "vp9"]).optional()
|
|
25
26
|
});
|
|
26
27
|
const createRealTimeClient = (opts) => {
|
|
27
28
|
const { baseUrl, apiKey, integration } = opts;
|
|
@@ -29,7 +30,7 @@ const createRealTimeClient = (opts) => {
|
|
|
29
30
|
const connect = async (stream, options) => {
|
|
30
31
|
const parsedOptions = realTimeClientConnectOptionsSchema.safeParse(options);
|
|
31
32
|
if (!parsedOptions.success) throw parsedOptions.error;
|
|
32
|
-
const { onRemoteStream, onConnectionChange, onQueuePosition, initialState, resolution } = parsedOptions.data;
|
|
33
|
+
const { onRemoteStream, onConnectionChange, onQueuePosition, initialState, resolution, preferredVideoCodec } = parsedOptions.data;
|
|
33
34
|
const mirror = parsedOptions.data.mirror ?? false;
|
|
34
35
|
let inputStream = stream ?? new MediaStream();
|
|
35
36
|
let mirroredStream;
|
|
@@ -63,6 +64,7 @@ const createRealTimeClient = (opts) => {
|
|
|
63
64
|
onStats: (stats) => emitOrBuffer("stats", stats)
|
|
64
65
|
});
|
|
65
66
|
const safariCodec = isDesktopSafari() ? "vp8" : void 0;
|
|
67
|
+
const publishCodec = safariCodec ?? preferredVideoCodec;
|
|
66
68
|
session = new StreamSession({
|
|
67
69
|
url: `${url}?${new URLSearchParams({
|
|
68
70
|
...safariCodec ? { livekit_server_codec: safariCodec } : {},
|
|
@@ -78,7 +80,7 @@ const createRealTimeClient = (opts) => {
|
|
|
78
80
|
initialImageRef,
|
|
79
81
|
initialPrompt,
|
|
80
82
|
logger,
|
|
81
|
-
videoCodec:
|
|
83
|
+
videoCodec: publishCodec
|
|
82
84
|
});
|
|
83
85
|
let sessionId = null;
|
|
84
86
|
let subscribeToken = null;
|
|
@@ -4,15 +4,16 @@ import mitt from "mitt";
|
|
|
4
4
|
import { Room, RoomEvent, Track, TrackEvent } from "livekit-client";
|
|
5
5
|
//#region src/realtime/media-channel.ts
|
|
6
6
|
function getDefaultVideoPublishOptions(videoCodec) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
maxFramerate: REALTIME_CONFIG.livekit.defaultPublishFps
|
|
10
|
-
};
|
|
7
|
+
const resolvedCodec = videoCodec ?? REALTIME_CONFIG.livekit.defaultVideoCodec;
|
|
8
|
+
const maxBitrate = resolvedCodec === "vp9" ? REALTIME_CONFIG.livekit.vp9MaxVideoBitrateBps : REALTIME_CONFIG.livekit.defaultMaxVideoBitrateBps;
|
|
11
9
|
return {
|
|
12
10
|
source: Track.Source.Camera,
|
|
13
|
-
videoCodec:
|
|
14
|
-
simulcast:
|
|
15
|
-
videoEncoding
|
|
11
|
+
videoCodec: resolvedCodec,
|
|
12
|
+
simulcast: resolvedCodec !== "vp9",
|
|
13
|
+
videoEncoding: {
|
|
14
|
+
maxBitrate,
|
|
15
|
+
maxFramerate: REALTIME_CONFIG.livekit.defaultPublishFps
|
|
16
|
+
}
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
var MediaChannel = class {
|