@ikonai/sdk 1.0.72 → 1.0.74
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/assets/{audio-playback-worker-CC2FKp8X.js → audio-playback-worker-DLkTvKgj.js} +394 -511
- package/assets/{protocol-worker-DCLZvHGe.js → protocol-worker-BfR3vj38.js} +52 -52
- package/assets/{video-capture-worker-CzOnKSIv.js → video-capture-worker-ZDlmU6Ta.js} +153 -153
- package/assets/{video-playback-worker-BTMuFG90.js → video-playback-worker-BMnMLk3U.js} +203 -203
- package/assets/viseme-worker-BOyyqInI.js +831 -0
- package/client/ikon-client-config.d.ts +6 -0
- package/client/ikon-client.d.ts +22 -0
- package/index.d.ts +2 -1
- package/index.js +2771 -2540
- package/media/ikon-audio-playback.d.ts +0 -57
- package/media/index.d.ts +1 -0
- package/media/viseme-tracker.d.ts +53 -0
- package/package.json +1 -1
- package/utils/connect-timeline.d.ts +4 -0
- package/utils/log-sender.d.ts +1 -0
- package/utils/query-params.d.ts +9 -0
- package/webrtc/index.d.ts +1 -1
- package/webrtc/webrtc-config.d.ts +2 -0
- package/webrtc/webrtc-connection.d.ts +1 -0
- package/webrtc/webrtc-signaling.d.ts +16 -0
- package/worker/audio-playback-worker.d.ts +0 -10
- package/worker/viseme-worker.d.ts +24 -0
|
@@ -76,11 +76,6 @@ export declare class IkonAudioPlayback {
|
|
|
76
76
|
private readonly fallbackQueues;
|
|
77
77
|
private readonly activeStreams;
|
|
78
78
|
private mediaSessionConfig;
|
|
79
|
-
private readonly streamShapeSets;
|
|
80
|
-
private readonly currentShapeSetValues;
|
|
81
|
-
private readonly visemeBuffers;
|
|
82
|
-
private visemeDelayMs;
|
|
83
|
-
private readonly _visemeResult;
|
|
84
79
|
constructor(client: IkonClient, config?: IkonAudioPlaybackConfig);
|
|
85
80
|
/**
|
|
86
81
|
* Set Media Session metadata for OS-level media controls (lock screen, notifications).
|
|
@@ -136,58 +131,6 @@ export declare class IkonAudioPlayback {
|
|
|
136
131
|
* Dispose of resources. After calling this, the instance should not be reused.
|
|
137
132
|
*/
|
|
138
133
|
dispose(): void;
|
|
139
|
-
/**
|
|
140
|
-
* Get the shape set declarations for a stream.
|
|
141
|
-
* Shape sets are declared at stream begin and contain metadata about the
|
|
142
|
-
* shape values that will be included in audio frames.
|
|
143
|
-
*
|
|
144
|
-
* @param streamId - The stream ID to get shape sets for
|
|
145
|
-
* @returns Array of shape set declarations, or null if stream not found
|
|
146
|
-
*/
|
|
147
|
-
getShapeSets(streamId: string): {
|
|
148
|
-
SetId: number;
|
|
149
|
-
Name: string;
|
|
150
|
-
ShapeNames: string[];
|
|
151
|
-
}[] | null;
|
|
152
|
-
/**
|
|
153
|
-
* Get the current shape set values for a named shape set on a stream.
|
|
154
|
-
* Values are updated with each audio frame and represent the latest
|
|
155
|
-
* analysis results (e.g., viseme data).
|
|
156
|
-
*
|
|
157
|
-
* @param streamId - The stream ID to get values for
|
|
158
|
-
* @param setName - The name of the shape set (e.g., "Viseme")
|
|
159
|
-
* @returns Array of float values, or null if not found
|
|
160
|
-
*/
|
|
161
|
-
getShapeSetValues(streamId: string, setName: string): number[] | null;
|
|
162
|
-
/**
|
|
163
|
-
* Get the current shape set values by set ID for a stream.
|
|
164
|
-
*
|
|
165
|
-
* @param streamId - The stream ID to get values for
|
|
166
|
-
* @param setId - The numeric ID of the shape set
|
|
167
|
-
* @returns Array of float values, or null if not found
|
|
168
|
-
*/
|
|
169
|
-
getShapeSetValuesById(streamId: string, setId: number): number[] | null;
|
|
170
|
-
/**
|
|
171
|
-
* Get all current shape set values for a stream.
|
|
172
|
-
*
|
|
173
|
-
* @param streamId - The stream ID to get values for
|
|
174
|
-
* @returns Map of set ID to values, or null if stream not found
|
|
175
|
-
*/
|
|
176
|
-
getAllShapeSetValues(streamId: string): Map<number, number[]> | null;
|
|
177
|
-
/**
|
|
178
|
-
* Get current viseme values from any active stream.
|
|
179
|
-
* Uses sample-based timing for precise synchronization with audio playback.
|
|
180
|
-
* Interpolates between viseme keyframes for smooth animation.
|
|
181
|
-
*
|
|
182
|
-
* @returns Object with mouthOpenY (0-1) and mouthForm (-1 to +1), or null if no viseme data
|
|
183
|
-
*/
|
|
184
|
-
getCurrentVisemeValues(): {
|
|
185
|
-
mouthOpenY: number;
|
|
186
|
-
mouthForm: number;
|
|
187
|
-
} | null;
|
|
188
|
-
setVisemeDelayMs(delayMs: number): void;
|
|
189
|
-
getVisemeDelayMs(): number;
|
|
190
|
-
private processShapeSetValues;
|
|
191
134
|
private resolveDiagnosticsConfig;
|
|
192
135
|
private resolveBackgroundConfig;
|
|
193
136
|
private ensureAudioGraph;
|
package/media/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { IkonAudioPlayback } from './ikon-audio-playback';
|
|
|
4
4
|
export type { IkonAudioPlaybackConfig } from './ikon-audio-playback';
|
|
5
5
|
export { IkonVideoPlayback } from './ikon-video-playback';
|
|
6
6
|
export type { IkonVideoPlaybackConfig } from './ikon-video-playback';
|
|
7
|
+
export { VisemeTracker } from './viseme-tracker';
|
|
7
8
|
export { isSharedArrayBufferSupported, isAudioWorkletSupported } from './capabilities';
|
|
8
9
|
export { IkonMediaCapture } from './ikon-media-capture';
|
|
9
10
|
export type { IkonMediaCaptureConfig } from './ikon-media-capture';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AudioShapeSet } from '../../../../shared/protocol/src/index.ts';
|
|
2
|
+
import { IkonClient } from '../client/ikon-client';
|
|
3
|
+
/**
|
|
4
|
+
* Time-synchronized lip-sync / shape-set receiver.
|
|
5
|
+
*
|
|
6
|
+
* Server audio analyzers (viseme, sentiment, etc.) declare their shape sets on
|
|
7
|
+
* {@link AudioStreamBegin} and stream per-frame values as {@link AudioShapeFrame}
|
|
8
|
+
* messages. Those messages ride the same GROUP_AUDIO stream as audio, but carry no
|
|
9
|
+
* PCM — so consuming them needs none of the audio playback machinery (decoder,
|
|
10
|
+
* AudioContext, worklet). This tracker parses them in a dedicated lightweight
|
|
11
|
+
* worker and exposes interpolated values via {@link getCurrentVisemeValues},
|
|
12
|
+
* driven by a plain wall clock. It works identically whether audio is delivered
|
|
13
|
+
* over WebRTC RTP tracks or the SDK's own playback pipeline.
|
|
14
|
+
*/
|
|
15
|
+
export declare class VisemeTracker {
|
|
16
|
+
private readonly client;
|
|
17
|
+
private worker;
|
|
18
|
+
private protocolPort;
|
|
19
|
+
private readonly streamShapeSets;
|
|
20
|
+
private readonly currentShapeSetValues;
|
|
21
|
+
private readonly visemeBuffers;
|
|
22
|
+
private visemeDelayMs;
|
|
23
|
+
private readonly _visemeResult;
|
|
24
|
+
constructor(client: IkonClient);
|
|
25
|
+
/**
|
|
26
|
+
* Starts the viseme worker and subscribes to the GROUP_AUDIO protocol stream.
|
|
27
|
+
* Idempotent; safe to call once audio is known to be in use.
|
|
28
|
+
*/
|
|
29
|
+
enable(): void;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
getShapeSets(streamId: string): AudioShapeSet[] | null;
|
|
32
|
+
/**
|
|
33
|
+
* Get the latest values for a named shape set on a stream (e.g. "Viseme").
|
|
34
|
+
*/
|
|
35
|
+
getShapeSetValues(streamId: string, setName: string): number[] | null;
|
|
36
|
+
getShapeSetValuesById(streamId: string, setId: number): number[] | null;
|
|
37
|
+
getAllShapeSetValues(streamId: string): Map<number, number[]> | null;
|
|
38
|
+
/**
|
|
39
|
+
* Get current viseme values from any active stream.
|
|
40
|
+
* Uses sample-based timing for precise synchronization with audio playback.
|
|
41
|
+
* Interpolates between viseme keyframes for smooth animation.
|
|
42
|
+
*
|
|
43
|
+
* @returns Object with mouthOpenY (0-1) and mouthForm (-1 to +1), or null if no viseme data
|
|
44
|
+
*/
|
|
45
|
+
getCurrentVisemeValues(): {
|
|
46
|
+
mouthOpenY: number;
|
|
47
|
+
mouthForm: number;
|
|
48
|
+
} | null;
|
|
49
|
+
setVisemeDelayMs(delayMs: number): void;
|
|
50
|
+
getVisemeDelayMs(): number;
|
|
51
|
+
private onWorkerMessage;
|
|
52
|
+
private processShapeSetValues;
|
|
53
|
+
}
|
package/package.json
CHANGED
package/utils/log-sender.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function startLogSender(backendUrl: string, authToken: string, sessionId?: string, channelInstanceId?: string): void;
|
|
2
|
+
export declare function sendAnalyticsEvent(eventName: string, parameters: Record<string, string>): void;
|
|
2
3
|
export declare function stopLogSender(): void;
|
package/utils/query-params.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* - ikon-audio Force audio on (true) or off (false)
|
|
18
18
|
* - ikon-video Force video on (true) or off (false)
|
|
19
19
|
* - ikon-webrtc Force WebRTC on (true) or off (false)
|
|
20
|
+
* - ikon-ice-transport Force the WebRTC ICE transport policy: "relay" (TURN-only, useful for testing the relay path) or "all" (default)
|
|
20
21
|
* - ikon-inspect Enable element inspection overlay (true)
|
|
21
22
|
* - ikon-retry Enable retry loops in auth/channel connect (default true; set false to fail fast)
|
|
22
23
|
* - ikon-api Route backend API calls through same-origin /ikon/api (default true on deployed apps; false to force direct calls to api.{env}.ikon.live; always off in local dev)
|
|
@@ -33,6 +34,7 @@ export declare const IKON_PARAM_GIT_BRANCH = "ikon-git-branch";
|
|
|
33
34
|
export declare const IKON_PARAM_AUDIO = "ikon-audio";
|
|
34
35
|
export declare const IKON_PARAM_VIDEO = "ikon-video";
|
|
35
36
|
export declare const IKON_PARAM_WEBRTC = "ikon-webrtc";
|
|
37
|
+
export declare const IKON_PARAM_ICE_TRANSPORT = "ikon-ice-transport";
|
|
36
38
|
export declare const IKON_PARAM_INSPECT = "ikon-inspect";
|
|
37
39
|
export declare const IKON_PARAM_DEBUG_OVERLAY = "ikon-debug-overlay";
|
|
38
40
|
export declare const IKON_PARAM_AUTH = "ikon-auth";
|
|
@@ -52,6 +54,13 @@ export declare function getServerUrlParam(): string | null;
|
|
|
52
54
|
export declare function getAudioParam(): boolean | null;
|
|
53
55
|
export declare function getVideoParam(): boolean | null;
|
|
54
56
|
export declare function getWebRtcParam(): boolean | null;
|
|
57
|
+
/**
|
|
58
|
+
* Force the WebRTC ICE transport policy. `relay` makes the browser gather only
|
|
59
|
+
* TURN relay candidates (no host/srflx), forcing media through the TURN server —
|
|
60
|
+
* useful for verifying the relay path works. `all` is the browser default.
|
|
61
|
+
* Returns null when unset or unrecognized.
|
|
62
|
+
*/
|
|
63
|
+
export declare function getIceTransportPolicyParam(): RTCIceTransportPolicy | null;
|
|
55
64
|
export declare function getInspectParam(): boolean;
|
|
56
65
|
/**
|
|
57
66
|
* On-screen debug overlay toggle. Distinct from `ikon-debug` (verbose logging / devtools):
|
package/webrtc/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { WebRTCConnection, type WebRTCConnectionConfig, type WebRTCConnectionState } from './webrtc-connection';
|
|
2
2
|
export { WebRTCSignaling, type WebRTCSignalingConfig } from './webrtc-signaling';
|
|
3
|
-
export { WEBRTC_AUDIO_CODEC, WEBRTC_AUDIO_SAMPLE_RATE, WEBRTC_AUDIO_CHANNELS, WEBRTC_AUDIO_BITRATE, WEBRTC_AUDIO_JITTER_BUFFER_TARGET_MS, WEBRTC_VIDEO_CODEC, WEBRTC_VIDEO_MAX_BITRATE, WEBRTC_VIDEO_MAX_FRAMERATE, WEBRTC_MAX_AUDIO_TRACKS, WEBRTC_MAX_VIDEO_TRACKS, WEBRTC_BUNDLE_POLICY, WEBRTC_RTCP_MUX_POLICY, WEBRTC_DATA_CHANNEL_LABEL, WEBRTC_DATA_CHANNEL_ORDERED, WEBRTC_DATA_CHANNEL_MAX_RETRANSMITS, } from './webrtc-config';
|
|
3
|
+
export { WEBRTC_AUDIO_CODEC, WEBRTC_AUDIO_SAMPLE_RATE, WEBRTC_AUDIO_CHANNELS, WEBRTC_AUDIO_BITRATE, WEBRTC_AUDIO_JITTER_BUFFER_TARGET_MS, WEBRTC_VIDEO_CODEC, WEBRTC_VIDEO_MAX_BITRATE, WEBRTC_VIDEO_MAX_FRAMERATE, WEBRTC_MAX_AUDIO_TRACKS, WEBRTC_MAX_VIDEO_TRACKS, WEBRTC_BUNDLE_POLICY, WEBRTC_RTCP_MUX_POLICY, WEBRTC_DATA_CHANNEL_LABEL, WEBRTC_DATA_CHANNEL_ORDERED, WEBRTC_DATA_CHANNEL_MAX_RETRANSMITS, WEBRTC_CONNECT_TIMEOUT_MS, } from './webrtc-config';
|
|
@@ -9,6 +9,8 @@ export declare const WEBRTC_VIDEO_MAX_FRAMERATE = 30;
|
|
|
9
9
|
export declare const WEBRTC_VIDEO_PLAYOUT_DELAY_HINT_S = 0.05;
|
|
10
10
|
export declare const WEBRTC_BUNDLE_POLICY: RTCBundlePolicy;
|
|
11
11
|
export declare const WEBRTC_RTCP_MUX_POLICY: RTCRtcpMuxPolicy;
|
|
12
|
+
export declare const WEBRTC_ICE_SERVERS_REQUEST_TIMEOUT_MS = 5000;
|
|
13
|
+
export declare const WEBRTC_CONNECT_TIMEOUT_MS = 8000;
|
|
12
14
|
export declare const WEBRTC_MAX_AUDIO_TRACKS = 16;
|
|
13
15
|
export declare const WEBRTC_MAX_VIDEO_TRACKS = 16;
|
|
14
16
|
export declare const WEBRTC_DATA_CHANNEL_LABEL = "ikon-data";
|
|
@@ -4,6 +4,7 @@ export interface WebRTCConnectionConfig {
|
|
|
4
4
|
useVideoTrack: boolean;
|
|
5
5
|
useDataChannel: boolean;
|
|
6
6
|
iceServers?: RTCIceServer[];
|
|
7
|
+
iceTransportPolicy?: RTCIceTransportPolicy;
|
|
7
8
|
onIceCandidate?: (candidate: RTCIceCandidate | null) => void;
|
|
8
9
|
onStateChange?: (state: WebRTCConnectionState) => void;
|
|
9
10
|
onDataChannelMessage?: (data: ArrayBuffer) => void;
|
|
@@ -8,6 +8,7 @@ export interface WebRTCSignalingConfig {
|
|
|
8
8
|
useVideoTrack: boolean;
|
|
9
9
|
useDataChannel: boolean;
|
|
10
10
|
iceServers?: RTCIceServer[];
|
|
11
|
+
iceTransportPolicy?: RTCIceTransportPolicy;
|
|
11
12
|
onStateChange?: (state: WebRTCConnectionState) => void;
|
|
12
13
|
onDataChannelMessage?: (data: ArrayBuffer) => void;
|
|
13
14
|
onDataChannelOpen?: () => void;
|
|
@@ -23,12 +24,19 @@ export declare class WebRTCSignaling {
|
|
|
23
24
|
private isConnecting;
|
|
24
25
|
private audioTrackCount;
|
|
25
26
|
private videoTrackCount;
|
|
27
|
+
private iceServersResolve;
|
|
26
28
|
constructor(config: WebRTCSignalingConfig);
|
|
27
29
|
get state(): WebRTCConnectionState;
|
|
28
30
|
get peerConnection(): RTCPeerConnection | null;
|
|
29
31
|
get isDataChannelOpen(): boolean;
|
|
30
32
|
connect(sendMessage: (message: ProtocolMessage) => void): Promise<void>;
|
|
31
33
|
handleProtocolMessage(message: ProtocolMessage | Uint8Array): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Tell the server we are abandoning WebRTC so it drops the peer immediately
|
|
36
|
+
* and resumes protocol-channel media, rather than waiting for its liveness
|
|
37
|
+
* timeout. Must be called before disconnect() (which clears the sender).
|
|
38
|
+
*/
|
|
39
|
+
notifyServerClose(): void;
|
|
32
40
|
disconnect(): void;
|
|
33
41
|
sendDataChannelMessage(data: ArrayBuffer): void;
|
|
34
42
|
private audioCaptureStream;
|
|
@@ -60,6 +68,14 @@ export declare class WebRTCSignaling {
|
|
|
60
68
|
stopCapture(): Promise<void>;
|
|
61
69
|
private applyEncodingParams;
|
|
62
70
|
private sendOffer;
|
|
71
|
+
/**
|
|
72
|
+
* Ask the server for the current TURN/STUN servers (with freshly minted TURN
|
|
73
|
+
* credentials) and wait for the response before building the peer connection.
|
|
74
|
+
* Falls back to any app-configured servers if the server doesn't answer in
|
|
75
|
+
* time, so a missing or older server never hangs the connection.
|
|
76
|
+
*/
|
|
77
|
+
private requestIceServers;
|
|
78
|
+
private handleIceServersResponse;
|
|
63
79
|
private handleAnswer;
|
|
64
80
|
private parseVideoCodecFromSdp;
|
|
65
81
|
private handleLocalIceCandidate;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AudioShapeSet, AudioShapeSetValues } from '../../../../shared/protocol/src/index.ts';
|
|
2
1
|
export type AudioPlaybackWorkerTransport = 'sab' | 'pcm';
|
|
3
2
|
export type AudioPlaybackWorkerConfigureMessage = {
|
|
4
3
|
type: 'configure';
|
|
@@ -26,7 +25,6 @@ export type AudioPlaybackWorkerOut = {
|
|
|
26
25
|
type: 'streamBegin';
|
|
27
26
|
streamId: string;
|
|
28
27
|
sharedArrayBuffer?: SharedArrayBuffer;
|
|
29
|
-
shapeSets?: AudioShapeSet[];
|
|
30
28
|
} | {
|
|
31
29
|
type: 'streamEnd';
|
|
32
30
|
streamId: string;
|
|
@@ -51,12 +49,4 @@ export type AudioPlaybackWorkerOut = {
|
|
|
51
49
|
isFirst: boolean;
|
|
52
50
|
isLast: boolean;
|
|
53
51
|
jitterMs: number;
|
|
54
|
-
} | {
|
|
55
|
-
type: 'shapeFrame';
|
|
56
|
-
streamId: string;
|
|
57
|
-
epoch: number;
|
|
58
|
-
sequence: number;
|
|
59
|
-
timestampInterleavedSamples: number;
|
|
60
|
-
frameSizeInterleavedSamples: number;
|
|
61
|
-
shapeSetValues: AudioShapeSetValues[];
|
|
62
52
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AudioShapeSet, AudioShapeSetValues } from '../../../../shared/protocol/src/index.ts';
|
|
2
|
+
export type VisemeWorkerAttachProtocolPortMessage = {
|
|
3
|
+
type: 'attachProtocolPort';
|
|
4
|
+
port: MessagePort;
|
|
5
|
+
};
|
|
6
|
+
export type VisemeWorkerDisposeMessage = {
|
|
7
|
+
type: 'dispose';
|
|
8
|
+
};
|
|
9
|
+
export type VisemeWorkerIn = VisemeWorkerAttachProtocolPortMessage | VisemeWorkerDisposeMessage;
|
|
10
|
+
export type VisemeWorkerOut = {
|
|
11
|
+
type: 'streamBegin';
|
|
12
|
+
streamId: string;
|
|
13
|
+
shapeSets: AudioShapeSet[];
|
|
14
|
+
} | {
|
|
15
|
+
type: 'streamEnd';
|
|
16
|
+
streamId: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'shapeFrame';
|
|
19
|
+
streamId: string;
|
|
20
|
+
epoch: number;
|
|
21
|
+
timestampInterleavedSamples: number;
|
|
22
|
+
frameSizeInterleavedSamples: number;
|
|
23
|
+
shapeSetValues: AudioShapeSetValues[];
|
|
24
|
+
};
|