opus-codec-worker 0.0.7 → 0.0.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/actions/actions.d.ts +54 -0
- package/actions/index.d.ts +1 -0
- package/package.json +2 -2
- package/worker.js +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface IWorkerRequest<Data, Response> {
|
|
2
|
+
data: Data;
|
|
3
|
+
_response?: RequestResponse<Response>;
|
|
4
|
+
transfer?: ArrayBuffer[];
|
|
5
|
+
requestId: RequestId;
|
|
6
|
+
}
|
|
7
|
+
export type RequestResponse<T> = {
|
|
8
|
+
requestId: RequestId;
|
|
9
|
+
value: T;
|
|
10
|
+
} | {
|
|
11
|
+
requestId: RequestId;
|
|
12
|
+
failures: string[];
|
|
13
|
+
};
|
|
14
|
+
export type RequestId = ReturnType<typeof getRequestId>;
|
|
15
|
+
export interface ICreateEncoderOptions {
|
|
16
|
+
sampleRate: number;
|
|
17
|
+
channels: number;
|
|
18
|
+
application: number;
|
|
19
|
+
outBufferLength: number;
|
|
20
|
+
pcmBufferLength: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ICreateEncoder extends IWorkerRequest<ICreateEncoderOptions, number> {
|
|
23
|
+
type: RequestType.CreateEncoder;
|
|
24
|
+
}
|
|
25
|
+
export interface IDestroyEncoderOptions {
|
|
26
|
+
encoder: number;
|
|
27
|
+
}
|
|
28
|
+
export interface IDestroyEncoder extends IWorkerRequest<number, number> {
|
|
29
|
+
type: RequestType.DestroyEncoder;
|
|
30
|
+
}
|
|
31
|
+
export declare function destroyEncoder(encoder: number): IDestroyEncoder;
|
|
32
|
+
export declare enum RequestType {
|
|
33
|
+
CreateEncoder = 0,
|
|
34
|
+
EncodeFloat = 1,
|
|
35
|
+
DestroyEncoder = 2
|
|
36
|
+
}
|
|
37
|
+
export interface IEncodeFloatResult {
|
|
38
|
+
encoded: ArrayBuffer | null;
|
|
39
|
+
}
|
|
40
|
+
export interface IEncodeFloat extends IWorkerRequest<IEncodeFloatOptions, IEncodeFloatResult> {
|
|
41
|
+
type: RequestType.EncodeFloat;
|
|
42
|
+
}
|
|
43
|
+
export interface IEncodeFloatOptions {
|
|
44
|
+
pcm: Float32Array;
|
|
45
|
+
encoder: number;
|
|
46
|
+
frameSize: number;
|
|
47
|
+
maxDataBytes: number;
|
|
48
|
+
}
|
|
49
|
+
export type RequestResponseType<T> = T extends IWorkerRequest<unknown, infer R> ? R : never;
|
|
50
|
+
export type WorkerRequest = IEncodeFloat | ICreateEncoder | IDestroyEncoder;
|
|
51
|
+
declare function getRequestId(): string;
|
|
52
|
+
export declare function createEncoder(data: ICreateEncoderOptions): ICreateEncoder;
|
|
53
|
+
export declare function encodeFloat(data: IEncodeFloatOptions): IEncodeFloat;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as default from './actions';
|
package/package.json
CHANGED
package/worker.js
CHANGED
|
@@ -2333,7 +2333,7 @@ const actions_1 = __webpack_require__(/*! ../actions/actions */ "./actions/actio
|
|
|
2333
2333
|
const native_1 = __importDefault(__webpack_require__(/*! opus-codec/native */ "./node_modules/opus-codec/native/index.js"));
|
|
2334
2334
|
const runtime_1 = __webpack_require__(/*! opus-codec/runtime */ "./node_modules/opus-codec/runtime/index.js");
|
|
2335
2335
|
const pendingRuntime = (0, native_1.default)({
|
|
2336
|
-
|
|
2336
|
+
locateFile: () => '/opus/index.wasm',
|
|
2337
2337
|
});
|
|
2338
2338
|
let nextEncoderId = 0;
|
|
2339
2339
|
const encoders = new Map();
|