@spatialwalk/avatarkit-rtc 1.0.0-beta.8 → 1.0.0-beta.9
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 +2 -571
- package/dist/assets/animation-worker-DOGeTjF0.js.map +1 -0
- package/dist/core/AvatarPlayer.d.ts +8 -3
- package/dist/core/AvatarPlayer.d.ts.map +1 -1
- package/dist/core/RTCProvider.d.ts +12 -5
- package/dist/core/RTCProvider.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index10.js +86 -47
- package/dist/index10.js.map +1 -1
- package/dist/index11.js +14 -104
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +390 -14
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +137 -349
- package/dist/index13.js.map +1 -1
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +1 -1
- package/dist/index2.js +38 -17
- package/dist/index2.js.map +1 -1
- package/dist/index3.js +141 -42
- package/dist/index3.js.map +1 -1
- package/dist/index4.js +101 -70
- package/dist/index4.js.map +1 -1
- package/dist/index5.js +6 -2
- package/dist/index5.js.map +1 -1
- package/dist/index6.js +73 -18
- package/dist/index6.js.map +1 -1
- package/dist/index8.js +5 -2
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +65 -164
- package/dist/index9.js.map +1 -1
- package/dist/providers/agora/AgoraProvider.d.ts.map +1 -1
- package/dist/providers/agora/types.d.ts.map +1 -1
- package/dist/providers/base/BaseProvider.d.ts +9 -13
- package/dist/providers/base/BaseProvider.d.ts.map +1 -1
- package/dist/providers/livekit/LiveKitProvider.d.ts +4 -2
- package/dist/providers/livekit/LiveKitProvider.d.ts.map +1 -1
- package/dist/providers/livekit/animation-worker.d.ts.map +1 -1
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +12 -3
- package/dist/assets/animation-worker-CdhDm7lL.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RTCConnectionConfig } from '../types';
|
|
1
|
+
import { RTCConnectionConfig, RTCPrepareConnectionConfig } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* RTC Provider interface.
|
|
4
4
|
*
|
|
@@ -17,12 +17,19 @@ import { RTCConnectionConfig } from '../types';
|
|
|
17
17
|
* }
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
+
export type RTCProviderEventHandler = (...args: unknown[]) => void;
|
|
20
21
|
export interface RTCProvider {
|
|
21
22
|
/**
|
|
22
23
|
* Provider name identifier (e.g., 'livekit', 'agora').
|
|
23
24
|
* Used for logging and debugging.
|
|
24
25
|
*/
|
|
25
26
|
readonly name: string;
|
|
27
|
+
/**
|
|
28
|
+
* Pre-warm a future connection if the provider supports it.
|
|
29
|
+
* This should not establish a full RTC session or change connection state,
|
|
30
|
+
* but may warm DNS/TLS caches or select an edge region.
|
|
31
|
+
*/
|
|
32
|
+
prepareConnection?(config: RTCPrepareConnectionConfig): Promise<void>;
|
|
26
33
|
/**
|
|
27
34
|
* Connect to RTC server.
|
|
28
35
|
* @param config - Connection configuration containing server URL and credentials
|
|
@@ -41,9 +48,9 @@ export interface RTCProvider {
|
|
|
41
48
|
getConnectionState(): string;
|
|
42
49
|
/**
|
|
43
50
|
* Publish local audio track (microphone) to the RTC server.
|
|
44
|
-
* @param track - MediaStreamTrack from getUserMedia
|
|
51
|
+
* @param track - Optional MediaStreamTrack from getUserMedia; when omitted the provider may create a microphone track
|
|
45
52
|
*/
|
|
46
|
-
publishAudioTrack(track
|
|
53
|
+
publishAudioTrack(track?: MediaStreamTrack): Promise<void>;
|
|
47
54
|
/**
|
|
48
55
|
* Unpublish audio track from the RTC server.
|
|
49
56
|
*/
|
|
@@ -53,13 +60,13 @@ export interface RTCProvider {
|
|
|
53
60
|
* @param event - Event name
|
|
54
61
|
* @param handler - Event handler function
|
|
55
62
|
*/
|
|
56
|
-
on(event: string, handler:
|
|
63
|
+
on(event: string, handler: RTCProviderEventHandler): void;
|
|
57
64
|
/**
|
|
58
65
|
* Remove event listener.
|
|
59
66
|
* @param event - Event name
|
|
60
67
|
* @param handler - Event handler function
|
|
61
68
|
*/
|
|
62
|
-
off(event: string, handler:
|
|
69
|
+
off(event: string, handler: RTCProviderEventHandler): void;
|
|
63
70
|
/**
|
|
64
71
|
* Get the native RTC client object.
|
|
65
72
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RTCProvider.d.ts","sourceRoot":"","sources":["../../src/core/RTCProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"RTCProvider.d.ts","sourceRoot":"","sources":["../../src/core/RTCProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAGhF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAEnE,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,iBAAiB,CAAC,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;;OAGG;IACH,kBAAkB,IAAI,MAAM,CAAC;IA4B7B;;;OAGG;IACH,iBAAiB,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D;;OAEG;IACH,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC;;;;OAIG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAE1D;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAE3D;;;;;;;OAOG;IACH,eAAe,IAAI,OAAO,CAAC;CAC5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
export { AvatarPlayer } from './core';
|
|
10
10
|
export type { AvatarPlayerOptions } from './core';
|
|
11
11
|
export { LiveKitProvider, AgoraProvider } from './providers';
|
|
12
|
-
export type { AgoraProviderOptions, LiveKitRoom, AgoraClient } from './providers';
|
|
13
|
-
export { ConnectionState, isLiveKitConfig, isAgoraConfig } from './types';
|
|
14
|
-
export type { RTCConnectionConfig, LiveKitConnectionConfig, AgoraConnectionConfig, } from './types';
|
|
12
|
+
export type { AgoraProviderOptions, LiveKitRoom, AgoraClient, } from './providers';
|
|
13
|
+
export { ConnectionState, isLiveKitConfig, isLiveKitPrepareConfig, isAgoraConfig, } from './types';
|
|
14
|
+
export type { RTCConnectionConfig, RTCPrepareConnectionConfig, LiveKitConnectionConfig, LiveKitPrepareConnectionConfig, AgoraConnectionConfig, } from './types';
|
|
15
15
|
export type { LogLevel } from './utils';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,YAAY,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,YAAY,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,8BAA8B,EAC9B,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { AvatarPlayer } from "./index2.js";
|
|
2
2
|
import { LiveKitProvider } from "./index3.js";
|
|
3
3
|
import { AgoraProvider } from "./index4.js";
|
|
4
|
-
import { ConnectionState, isAgoraConfig, isLiveKitConfig } from "./index5.js";
|
|
4
|
+
import { ConnectionState, isAgoraConfig, isLiveKitConfig, isLiveKitPrepareConfig } from "./index5.js";
|
|
5
5
|
export {
|
|
6
6
|
AgoraProvider,
|
|
7
7
|
AvatarPlayer,
|
|
8
8
|
ConnectionState,
|
|
9
9
|
LiveKitProvider,
|
|
10
10
|
isAgoraConfig,
|
|
11
|
-
isLiveKitConfig
|
|
11
|
+
isLiveKitConfig,
|
|
12
|
+
isLiveKitPrepareConfig
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index10.js
CHANGED
|
@@ -1,75 +1,114 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { createAnimationReceiverTransform } from "./index14.js";
|
|
4
5
|
import { logger } from "./index7.js";
|
|
5
|
-
|
|
6
|
+
import WorkerWrapper from "./index15.js";
|
|
7
|
+
const DEFAULT_TRANSITION_START_FRAMES = 8;
|
|
8
|
+
const DEFAULT_TRANSITION_END_FRAMES = 12;
|
|
9
|
+
class VP8Extractor {
|
|
6
10
|
constructor() {
|
|
7
11
|
/** @internal */
|
|
8
|
-
__publicField(this, "
|
|
12
|
+
__publicField(this, "callbacks", null);
|
|
9
13
|
/** @internal */
|
|
10
|
-
__publicField(this, "
|
|
14
|
+
__publicField(this, "receiver", null);
|
|
15
|
+
/** @internal */
|
|
16
|
+
__publicField(this, "transform", null);
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
19
|
+
* Initialize the extractor with a receiver and callbacks.
|
|
20
|
+
* @param receiver - RTCRtpReceiver to extract data from
|
|
21
|
+
* @param callbacks - Callbacks to receive extracted data
|
|
22
|
+
* @internal
|
|
16
23
|
*/
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
24
|
+
async initialize(receiver, callbacks) {
|
|
25
|
+
if (this.receiver || this.transform) {
|
|
26
|
+
throw new Error("VP8Extractor already initialized");
|
|
20
27
|
}
|
|
21
|
-
this.
|
|
28
|
+
this.receiver = receiver;
|
|
29
|
+
this.callbacks = callbacks;
|
|
30
|
+
if (receiver.transform) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const worker = new WorkerWrapper();
|
|
34
|
+
const onEvent = (evt) => {
|
|
35
|
+
this.handleTransformEvent(evt);
|
|
36
|
+
};
|
|
37
|
+
this.transform = createAnimationReceiverTransform(worker, onEvent);
|
|
38
|
+
receiver.transform = this.transform;
|
|
22
39
|
}
|
|
23
40
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
26
|
-
* @param handler - Event handler
|
|
41
|
+
* Handle events from the animation transform.
|
|
42
|
+
* @internal
|
|
27
43
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
44
|
+
handleTransformEvent(evt) {
|
|
45
|
+
if (!this.callbacks) return;
|
|
46
|
+
if (evt.type === "metadata") {
|
|
47
|
+
this.callbacks.onStreamStats({
|
|
48
|
+
framesPerSec: evt.framesPerSec,
|
|
49
|
+
totalFrames: evt.totalFrames ?? 0,
|
|
50
|
+
framesSent: evt.framesSent ?? 0,
|
|
51
|
+
framesLost: evt.framesLost ?? 0,
|
|
52
|
+
framesRecovered: evt.framesRecovered ?? 0,
|
|
53
|
+
framesDropped: evt.framesDropped ?? 0,
|
|
54
|
+
framesOutOfOrder: evt.framesOutOfOrder ?? 0,
|
|
55
|
+
framesDuplicate: evt.framesDuplicate ?? 0,
|
|
56
|
+
lastRenderedSeq: evt.lastRenderedSeq ?? -1
|
|
57
|
+
});
|
|
58
|
+
} else if (evt.type === "transition") {
|
|
59
|
+
this.callbacks.onTransition(
|
|
60
|
+
evt.protobufData,
|
|
61
|
+
DEFAULT_TRANSITION_START_FRAMES
|
|
62
|
+
);
|
|
63
|
+
} else if (evt.type === "transitionEnd") {
|
|
64
|
+
this.callbacks.onTransitionEnd(
|
|
65
|
+
evt.protobufData,
|
|
66
|
+
DEFAULT_TRANSITION_END_FRAMES
|
|
67
|
+
);
|
|
68
|
+
} else if (evt.type === "animation") {
|
|
69
|
+
if (!evt.isIdle) {
|
|
70
|
+
this.callbacks.onAnimationData(evt.protobufData, {
|
|
71
|
+
frameSeq: evt.frameSeq,
|
|
72
|
+
isStart: evt.isStart,
|
|
73
|
+
isEnd: evt.isEnd,
|
|
74
|
+
isIdle: evt.isIdle,
|
|
75
|
+
isRecovered: evt.isRecovered
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
} else if (evt.type === "idleStart") {
|
|
79
|
+
this.callbacks.onIdleStart();
|
|
80
|
+
} else if (evt.type === "error") {
|
|
81
|
+
logger.error("VP8Extractor", "Error:", evt.error);
|
|
32
82
|
}
|
|
33
83
|
}
|
|
34
84
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @param
|
|
37
|
-
* @
|
|
85
|
+
* Check if this extractor is connected to the given receiver.
|
|
86
|
+
* @param receiver - RTCRtpReceiver to check
|
|
87
|
+
* @returns true if connected to this receiver
|
|
38
88
|
* @internal
|
|
39
89
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (handlers) {
|
|
43
|
-
handlers.forEach((handler) => {
|
|
44
|
-
try {
|
|
45
|
-
handler(...args);
|
|
46
|
-
} catch (error) {
|
|
47
|
-
logger.error(this.name, `Error in event handler for ${event}:`, error);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
90
|
+
isConnectedTo(receiver) {
|
|
91
|
+
return this.receiver === receiver;
|
|
51
92
|
}
|
|
52
93
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
94
|
+
* Get the receiver this extractor is connected to.
|
|
95
|
+
* @returns The connected RTCRtpReceiver or null
|
|
55
96
|
* @internal
|
|
56
97
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.emit("connection-state-changed", state);
|
|
69
|
-
}
|
|
98
|
+
getReceiver() {
|
|
99
|
+
return this.receiver;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Dispose the extractor and release resources.
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
dispose() {
|
|
106
|
+
this.receiver = null;
|
|
107
|
+
this.transform = null;
|
|
108
|
+
this.callbacks = null;
|
|
70
109
|
}
|
|
71
110
|
}
|
|
72
111
|
export {
|
|
73
|
-
|
|
112
|
+
VP8Extractor
|
|
74
113
|
};
|
|
75
114
|
//# sourceMappingURL=index10.js.map
|
package/dist/index10.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index10.js","sources":["../src/providers/
|
|
1
|
+
{"version":3,"file":"index10.js","sources":["../src/providers/livekit/VP8Extractor.ts"],"sourcesContent":["/**\n * VP8 Data Extractor for LiveKit.\n *\n * Extracts animation data from VP8 video tracks using RTCRtpScriptTransform.\n *\n * @internal\n * @packageDocumentation\n */\n\nimport type { AnimationTrackCallbacks } from '../../core/types';\nimport type { AnimationTransformEvent } from './types';\nimport { createAnimationReceiverTransform } from './animation-transform';\nimport { logger } from '../../utils';\n\n// Import worker with inline - this bundles the worker code as a blob URL\nimport AnimationWorker from './animation-worker.ts?worker&inline';\n\n// Default transition frame counts (used when protocol doesn't specify)\nconst DEFAULT_TRANSITION_START_FRAMES = 8;\nconst DEFAULT_TRANSITION_END_FRAMES = 12;\n\n/**\n * VP8Extractor - Extracts animation data from VP8 video tracks.\n *\n * Uses RTCRtpScriptTransform and a Web Worker to parse VP8 frames\n * and extract embedded animation data.\n *\n * @internal\n */\nexport class VP8Extractor {\n /** @internal */\n private callbacks: AnimationTrackCallbacks | null = null;\n /** @internal */\n private receiver: RTCRtpReceiver | null = null;\n /** @internal */\n private transform: RTCRtpScriptTransform | null = null;\n\n /**\n * Initialize the extractor with a receiver and callbacks.\n * @param receiver - RTCRtpReceiver to extract data from\n * @param callbacks - Callbacks to receive extracted data\n * @internal\n */\n async initialize(\n receiver: RTCRtpReceiver,\n callbacks: AnimationTrackCallbacks,\n ): Promise<void> {\n if (this.receiver || this.transform) {\n throw new Error('VP8Extractor already initialized');\n }\n\n this.receiver = receiver;\n this.callbacks = callbacks;\n\n // Check if transform is already set\n if (receiver.transform) {\n return;\n }\n\n // Create worker and transform\n const worker = new AnimationWorker();\n const onEvent = (evt: AnimationTransformEvent) => {\n this.handleTransformEvent(evt);\n };\n\n this.transform = createAnimationReceiverTransform(worker, onEvent);\n receiver.transform = this.transform;\n }\n\n /**\n * Handle events from the animation transform.\n * @internal\n */\n private handleTransformEvent(evt: AnimationTransformEvent): void {\n if (!this.callbacks) return;\n\n if (evt.type === 'metadata') {\n this.callbacks.onStreamStats({\n framesPerSec: evt.framesPerSec,\n totalFrames: evt.totalFrames ?? 0,\n framesSent: evt.framesSent ?? 0,\n framesLost: evt.framesLost ?? 0,\n framesRecovered: evt.framesRecovered ?? 0,\n framesDropped: evt.framesDropped ?? 0,\n framesOutOfOrder: evt.framesOutOfOrder ?? 0,\n framesDuplicate: evt.framesDuplicate ?? 0,\n lastRenderedSeq: evt.lastRenderedSeq ?? -1,\n });\n } else if (evt.type === 'transition') {\n this.callbacks.onTransition(\n evt.protobufData,\n DEFAULT_TRANSITION_START_FRAMES,\n );\n } else if (evt.type === 'transitionEnd') {\n this.callbacks.onTransitionEnd(\n evt.protobufData,\n DEFAULT_TRANSITION_END_FRAMES,\n );\n } else if (evt.type === 'animation') {\n if (!evt.isIdle) {\n this.callbacks.onAnimationData(evt.protobufData, {\n frameSeq: evt.frameSeq,\n isStart: evt.isStart,\n isEnd: evt.isEnd,\n isIdle: evt.isIdle,\n isRecovered: evt.isRecovered,\n });\n }\n } else if (evt.type === 'idleStart') {\n this.callbacks.onIdleStart();\n } else if (evt.type === 'error') {\n logger.error('VP8Extractor', 'Error:', evt.error);\n }\n }\n\n /**\n * Check if this extractor is connected to the given receiver.\n * @param receiver - RTCRtpReceiver to check\n * @returns true if connected to this receiver\n * @internal\n */\n isConnectedTo(receiver: RTCRtpReceiver): boolean {\n return this.receiver === receiver;\n }\n\n /**\n * Get the receiver this extractor is connected to.\n * @returns The connected RTCRtpReceiver or null\n * @internal\n */\n getReceiver(): RTCRtpReceiver | null {\n return this.receiver;\n }\n\n /**\n * Dispose the extractor and release resources.\n * @internal\n */\n dispose(): void {\n this.receiver = null;\n this.transform = null;\n this.callbacks = null;\n }\n}\n"],"names":["AnimationWorker"],"mappings":";;;;;;AAkBA,MAAM,kCAAkC;AACxC,MAAM,gCAAgC;AAU/B,MAAM,aAAa;AAAA,EAAnB;AAEG;AAAA,qCAA4C;AAE5C;AAAA,oCAAkC;AAElC;AAAA,qCAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlD,MAAM,WACJ,UACA,WACe;AACf,QAAI,KAAK,YAAY,KAAK,WAAW;AACnC,YAAM,IAAI,MAAM,kCAAkC;AAAA,IACpD;AAEA,SAAK,WAAW;AAChB,SAAK,YAAY;AAGjB,QAAI,SAAS,WAAW;AACtB;AAAA,IACF;AAGA,UAAM,SAAS,IAAIA,cAAA;AACnB,UAAM,UAAU,CAAC,QAAiC;AAChD,WAAK,qBAAqB,GAAG;AAAA,IAC/B;AAEA,SAAK,YAAY,iCAAiC,QAAQ,OAAO;AACjE,aAAS,YAAY,KAAK;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,qBAAqB,KAAoC;AAC/D,QAAI,CAAC,KAAK,UAAW;AAErB,QAAI,IAAI,SAAS,YAAY;AAC3B,WAAK,UAAU,cAAc;AAAA,QAC3B,cAAc,IAAI;AAAA,QAClB,aAAa,IAAI,eAAe;AAAA,QAChC,YAAY,IAAI,cAAc;AAAA,QAC9B,YAAY,IAAI,cAAc;AAAA,QAC9B,iBAAiB,IAAI,mBAAmB;AAAA,QACxC,eAAe,IAAI,iBAAiB;AAAA,QACpC,kBAAkB,IAAI,oBAAoB;AAAA,QAC1C,iBAAiB,IAAI,mBAAmB;AAAA,QACxC,iBAAiB,IAAI,mBAAmB;AAAA,MAAA,CACzC;AAAA,IACH,WAAW,IAAI,SAAS,cAAc;AACpC,WAAK,UAAU;AAAA,QACb,IAAI;AAAA,QACJ;AAAA,MAAA;AAAA,IAEJ,WAAW,IAAI,SAAS,iBAAiB;AACvC,WAAK,UAAU;AAAA,QACb,IAAI;AAAA,QACJ;AAAA,MAAA;AAAA,IAEJ,WAAW,IAAI,SAAS,aAAa;AACnC,UAAI,CAAC,IAAI,QAAQ;AACf,aAAK,UAAU,gBAAgB,IAAI,cAAc;AAAA,UAC/C,UAAU,IAAI;AAAA,UACd,SAAS,IAAI;AAAA,UACb,OAAO,IAAI;AAAA,UACX,QAAQ,IAAI;AAAA,UACZ,aAAa,IAAI;AAAA,QAAA,CAClB;AAAA,MACH;AAAA,IACF,WAAW,IAAI,SAAS,aAAa;AACnC,WAAK,UAAU,YAAA;AAAA,IACjB,WAAW,IAAI,SAAS,SAAS;AAC/B,aAAO,MAAM,gBAAgB,UAAU,IAAI,KAAK;AAAA,IAClD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cAAc,UAAmC;AAC/C,WAAO,KAAK,aAAa;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,cAAqC;AACnC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAgB;AACd,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,YAAY;AAAA,EACnB;AACF;"}
|
package/dist/index11.js
CHANGED
|
@@ -1,108 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
__publicField(this, "callbacks", null);
|
|
13
|
-
/** @internal */
|
|
14
|
-
__publicField(this, "receiver", null);
|
|
15
|
-
/** @internal */
|
|
16
|
-
__publicField(this, "transform", null);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Initialize the extractor with a receiver and callbacks.
|
|
20
|
-
* @param receiver - RTCRtpReceiver to extract data from
|
|
21
|
-
* @param callbacks - Callbacks to receive extracted data
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
async initialize(receiver, callbacks) {
|
|
25
|
-
if (this.receiver || this.transform) {
|
|
26
|
-
throw new Error("VP8Extractor already initialized");
|
|
27
|
-
}
|
|
28
|
-
this.receiver = receiver;
|
|
29
|
-
this.callbacks = callbacks;
|
|
30
|
-
if (receiver.transform) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const worker = new WorkerWrapper();
|
|
34
|
-
const onEvent = (evt) => {
|
|
35
|
-
this.handleTransformEvent(evt);
|
|
36
|
-
};
|
|
37
|
-
this.transform = createAnimationReceiverTransform(worker, onEvent);
|
|
38
|
-
receiver.transform = this.transform;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Handle events from the animation transform.
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
handleTransformEvent(evt) {
|
|
45
|
-
if (!this.callbacks) return;
|
|
46
|
-
if (evt.type === "metadata") {
|
|
47
|
-
this.callbacks.onStreamStats({
|
|
48
|
-
framesPerSec: evt.framesPerSec,
|
|
49
|
-
totalFrames: evt.totalFrames ?? 0,
|
|
50
|
-
framesSent: evt.framesSent ?? 0,
|
|
51
|
-
framesLost: evt.framesLost ?? 0,
|
|
52
|
-
framesRecovered: evt.framesRecovered ?? 0,
|
|
53
|
-
framesDropped: evt.framesDropped ?? 0,
|
|
54
|
-
framesOutOfOrder: evt.framesOutOfOrder ?? 0,
|
|
55
|
-
framesDuplicate: evt.framesDuplicate ?? 0,
|
|
56
|
-
lastRenderedSeq: evt.lastRenderedSeq ?? -1
|
|
57
|
-
});
|
|
58
|
-
} else if (evt.type === "transition") {
|
|
59
|
-
this.callbacks.onTransition(evt.protobufData, DEFAULT_TRANSITION_START_FRAMES);
|
|
60
|
-
} else if (evt.type === "transitionEnd") {
|
|
61
|
-
this.callbacks.onTransitionEnd(evt.protobufData, DEFAULT_TRANSITION_END_FRAMES);
|
|
62
|
-
} else if (evt.type === "animation") {
|
|
63
|
-
if (!evt.isIdle) {
|
|
64
|
-
this.callbacks.onAnimationData(evt.protobufData, {
|
|
65
|
-
frameSeq: evt.frameSeq,
|
|
66
|
-
isStart: evt.isStart,
|
|
67
|
-
isEnd: evt.isEnd,
|
|
68
|
-
isIdle: evt.isIdle,
|
|
69
|
-
isRecovered: evt.isRecovered
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
} else if (evt.type === "idleStart") {
|
|
73
|
-
this.callbacks.onIdleStart();
|
|
74
|
-
} else if (evt.type === "error") {
|
|
75
|
-
logger.error("VP8Extractor", "Error:", evt.error);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Check if this extractor is connected to the given receiver.
|
|
80
|
-
* @param receiver - RTCRtpReceiver to check
|
|
81
|
-
* @returns true if connected to this receiver
|
|
82
|
-
* @internal
|
|
83
|
-
*/
|
|
84
|
-
isConnectedTo(receiver) {
|
|
85
|
-
return this.receiver === receiver;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Get the receiver this extractor is connected to.
|
|
89
|
-
* @returns The connected RTCRtpReceiver or null
|
|
90
|
-
* @internal
|
|
91
|
-
*/
|
|
92
|
-
getReceiver() {
|
|
93
|
-
return this.receiver;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Dispose the extractor and release resources.
|
|
97
|
-
* @internal
|
|
98
|
-
*/
|
|
99
|
-
dispose() {
|
|
100
|
-
this.receiver = null;
|
|
101
|
-
this.transform = null;
|
|
102
|
-
this.callbacks = null;
|
|
103
|
-
}
|
|
1
|
+
function supportsScriptTransform() {
|
|
2
|
+
return typeof RTCRtpScriptTransform !== "undefined";
|
|
3
|
+
}
|
|
4
|
+
function supportsEncodedStreams() {
|
|
5
|
+
var _a;
|
|
6
|
+
return typeof ((_a = RTCRtpSender == null ? void 0 : RTCRtpSender.prototype) == null ? void 0 : _a.createEncodedStreams) === "function";
|
|
7
|
+
}
|
|
8
|
+
function getInsertableStreamsMethod() {
|
|
9
|
+
if (supportsScriptTransform()) return "scriptTransform";
|
|
10
|
+
if (supportsEncodedStreams()) return "encodedStreams";
|
|
11
|
+
return null;
|
|
104
12
|
}
|
|
105
13
|
export {
|
|
106
|
-
|
|
14
|
+
getInsertableStreamsMethod,
|
|
15
|
+
supportsEncodedStreams,
|
|
16
|
+
supportsScriptTransform
|
|
107
17
|
};
|
|
108
18
|
//# sourceMappingURL=index11.js.map
|
package/dist/index11.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index11.js","sources":["../src/providers/livekit/
|
|
1
|
+
{"version":3,"file":"index11.js","sources":["../src/providers/livekit/utils.ts"],"sourcesContent":["/**\n * Insertable Streams utilities.\n *\n * Note: Audio tracks no longer embed metadata - animation data is now sent via a separate video track.\n * These utilities are kept for potential future use and backwards compatibility.\n *\n * @internal\n * @packageDocumentation\n */\n\n/**\n * Check if browser supports RTCRtpScriptTransform (the modern Insertable Streams API).\n * @returns true if RTCRtpScriptTransform is available\n * @internal\n */\nexport function supportsScriptTransform(): boolean {\n return typeof RTCRtpScriptTransform !== 'undefined';\n}\n\n/**\n * Check if browser supports createEncodedStreams (older Insertable Streams API).\n * @returns true if createEncodedStreams is available\n * @internal\n */\nexport function supportsEncodedStreams(): boolean {\n // This is deprecated but still works in some browsers\n // @ts-expect-error - experimental API\n return typeof RTCRtpSender?.prototype?.createEncodedStreams === 'function';\n}\n\n/**\n * Insertable Streams method type.\n * @internal\n */\nexport type InsertableStreamsMethod =\n | 'scriptTransform'\n | 'encodedStreams'\n | null;\n\n/**\n * Get supported Insertable Streams method.\n * @returns The supported method or null if none available\n * @internal\n */\nexport function getInsertableStreamsMethod(): InsertableStreamsMethod {\n if (supportsScriptTransform()) return 'scriptTransform';\n if (supportsEncodedStreams()) return 'encodedStreams';\n return null;\n}\n"],"names":[],"mappings":"AAeO,SAAS,0BAAmC;AACjD,SAAO,OAAO,0BAA0B;AAC1C;AAOO,SAAS,yBAAkC;AAT3C;AAYL,SAAO,SAAO,kDAAc,cAAd,mBAAyB,0BAAyB;AAClE;AAgBO,SAAS,6BAAsD;AACpE,MAAI,wBAAA,EAA2B,QAAO;AACtC,MAAI,uBAAA,EAA0B,QAAO;AACrC,SAAO;AACT;"}
|