@awangxcode/qiro-baileys 7.0.0-rc25.6 → 7.0.0-rc26.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.
- package/LICENSE +15 -0
- package/README.md +1445 -1041
- package/WAProto/WAProto.proto +4 -0
- package/WAProto/index.d.ts +4067 -243
- package/WAProto/index.js +74957 -43330
- package/assets/branding/qiro-logo.svg +24 -0
- package/assets/branding/qiro-mark.png +0 -0
- package/assets/branding/qiro-mark.svg +34 -0
- package/assets/branding/qiro-social-preview.png +0 -0
- package/lib/Defaults/index.d.ts +16 -1
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +43 -10
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Extensions/advanced.d.ts +1 -1
- package/lib/Extensions/experimental.d.ts +1 -3
- package/lib/Extensions/experimental.d.ts.map +1 -1
- package/lib/Extensions/experimental.js +0 -2
- package/lib/Extensions/experimental.js.map +1 -1
- package/lib/MessageBuilder/index.d.ts +5 -5
- package/lib/MessageBuilder/index.d.ts.map +1 -1
- package/lib/MessageBuilder/index.js +12 -3
- package/lib/MessageBuilder/index.js.map +1 -1
- package/lib/Signal/Group/group-session-builder.d.ts +3 -3
- package/lib/Signal/Group/group-session-builder.js +4 -4
- package/lib/Signal/Group/group_cipher.d.ts +2 -2
- package/lib/Signal/Group/group_cipher.js +4 -4
- package/lib/Signal/Group/index.d.ts +11 -11
- package/lib/Signal/Group/index.js +11 -11
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
- package/lib/Signal/Group/sender-key-message.d.ts +1 -1
- package/lib/Signal/Group/sender-key-message.js +1 -1
- package/lib/Signal/Group/sender-key-record.d.ts +1 -1
- package/lib/Signal/Group/sender-key-record.js +2 -2
- package/lib/Signal/Group/sender-key-state.d.ts +2 -2
- package/lib/Signal/Group/sender-key-state.js +2 -2
- package/lib/Signal/libsignal.d.ts +3 -3
- package/lib/Signal/libsignal.js +6 -6
- package/lib/Signal/lid-mapping.d.ts +2 -2
- package/lib/Signal/lid-mapping.js +4 -4
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/Client/index.d.ts +2 -2
- package/lib/Socket/Client/index.js +2 -2
- package/lib/Socket/Client/types.d.ts +1 -1
- package/lib/Socket/Client/websocket.d.ts +1 -1
- package/lib/Socket/Client/websocket.js +2 -2
- package/lib/Socket/business.d.ts +347 -65
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/business.js +5 -5
- package/lib/Socket/chats.d.ts +129 -16
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +293 -18
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +332 -50
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/communities.js +5 -5
- package/lib/Socket/groups.d.ts +133 -27
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +4 -4
- package/lib/Socket/index.d.ts +366 -84
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +8 -5
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +324 -41
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +81 -30
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +340 -44
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +171 -35
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/mex.d.ts +1 -1
- package/lib/Socket/mex.js +1 -1
- package/lib/Socket/newsletter.d.ts +324 -39
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +345 -5
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +24 -11
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +89 -36
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.js +4 -0
- package/lib/Store/make-in-memory-store.d.ts +63 -0
- package/lib/Store/make-in-memory-store.js +397 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +79 -0
- package/lib/Store/object-repository.d.ts +11 -0
- package/lib/Store/object-repository.js +24 -0
- package/lib/Types/Auth.d.ts +2 -2
- package/lib/Types/Chat.d.ts +19 -6
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Chat.js.map +1 -1
- package/lib/Types/Events.d.ts +9 -9
- package/lib/Types/GroupMetadata.d.ts +2 -2
- package/lib/Types/Message.d.ts +70 -6
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js +11 -0
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/Mex.d.ts +68 -39
- package/lib/Types/Mex.d.ts.map +1 -1
- package/lib/Types/Mex.js +66 -0
- package/lib/Types/Mex.js.map +1 -1
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +1 -1
- package/lib/Types/Socket.d.ts +50 -5
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/Socket.js +1 -1
- package/lib/Types/State.d.ts +1 -1
- package/lib/Types/USync.d.ts +2 -2
- package/lib/Types/USync.js +1 -1
- package/lib/Types/index.d.ts +14 -14
- package/lib/Types/index.js +12 -12
- package/lib/Utils/audio-sticker.d.ts +14 -0
- package/lib/Utils/audio-sticker.js +172 -0
- package/lib/Utils/auth-store.d.ts +30 -0
- package/lib/Utils/auth-store.js +77 -0
- package/lib/Utils/auth-utils.d.ts +2 -2
- package/lib/Utils/auth-utils.js +4 -4
- package/lib/Utils/browser-utils.d.ts +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +3 -3
- package/lib/Utils/chat-theme.d.ts +34 -0
- package/lib/Utils/chat-theme.js +336 -0
- package/lib/Utils/chat-utils.d.ts +3 -3
- package/lib/Utils/chat-utils.js +9 -9
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +3 -3
- package/lib/Utils/companion-reg-client-utils.js +1 -1
- package/lib/Utils/crypto.d.ts +1 -1
- package/lib/Utils/crypto.js +1 -1
- package/lib/Utils/decode-wa-message.d.ts +18 -4
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +57 -2
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +4 -3
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +7 -8
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +5 -4
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +13 -22
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/group-metadata-cache.d.ts +4 -0
- package/lib/Utils/group-metadata-cache.js +25 -0
- package/lib/Utils/history.d.ts +1 -1
- package/lib/Utils/history.js +6 -6
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/html-app.d.ts +19 -0
- package/lib/Utils/html-app.js +96 -0
- package/lib/Utils/html-multiplayer.d.ts +10 -0
- package/lib/Utils/html-multiplayer.js +94 -0
- package/lib/Utils/identity-change-handler.d.ts +2 -2
- package/lib/Utils/identity-change-handler.js +2 -2
- package/lib/Utils/index.d.ts +46 -21
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +48 -21
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview-metadata.d.ts +47 -0
- package/lib/Utils/link-preview-metadata.js +88 -0
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/message-retry-manager.d.ts +1 -1
- package/lib/Utils/messages-media.d.ts +35 -6
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +69 -22
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +45 -5
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +123 -32
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/modern-messages.d.ts +150 -0
- package/lib/Utils/modern-messages.js +496 -0
- package/lib/Utils/native-flow.d.ts +11 -0
- package/lib/Utils/native-flow.js +116 -0
- package/lib/Utils/newsletter-status.d.ts +158 -0
- package/lib/Utils/newsletter-status.js +651 -0
- package/lib/Utils/noise-handler.d.ts +3 -3
- package/lib/Utils/noise-handler.js +3 -3
- package/lib/Utils/offline-node-processor.d.ts +1 -1
- package/lib/Utils/optional-media.d.ts +3 -0
- package/lib/Utils/optional-media.js +46 -0
- package/lib/Utils/payment-messages.d.ts +38 -0
- package/lib/Utils/payment-messages.js +160 -0
- package/lib/Utils/pre-key-manager.d.ts +2 -2
- package/lib/Utils/process-message.d.ts +13 -2
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +87 -7
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/reporting-utils.d.ts +2 -2
- package/lib/Utils/reporting-utils.js +1 -1
- package/lib/Utils/scheduled-message.d.ts +51 -0
- package/lib/Utils/scheduled-message.js +113 -0
- package/lib/Utils/sender-key-memory.d.ts +19 -0
- package/lib/Utils/sender-key-memory.js +51 -0
- package/lib/Utils/signal.d.ts +4 -4
- package/lib/Utils/signal.js +4 -4
- package/lib/Utils/stanza-ack.d.ts +1 -1
- package/lib/Utils/status-stickers.d.ts +127 -0
- package/lib/Utils/status-stickers.js +261 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -2
- package/lib/Utils/sync-action-utils.js +1 -1
- package/lib/Utils/tc-token-utils.d.ts +2 -2
- package/lib/Utils/tc-token-utils.js +1 -1
- package/lib/Utils/ttl-cache.d.ts +29 -0
- package/lib/Utils/ttl-cache.js +121 -0
- package/lib/Utils/use-mongo-auth-state.d.ts +22 -0
- package/lib/Utils/use-mongo-auth-state.js +68 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -1
- package/lib/Utils/use-multi-file-auth-state.js +28 -15
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
- package/lib/Utils/use-mysql-auth-state.d.ts +20 -0
- package/lib/Utils/use-mysql-auth-state.js +80 -0
- package/lib/Utils/use-nekodb-auth.d.ts +19 -0
- package/lib/Utils/use-nekodb-auth.js +111 -0
- package/lib/Utils/use-postgres-auth-state.d.ts +20 -0
- package/lib/Utils/use-postgres-auth-state.js +80 -0
- package/lib/Utils/use-redis-auth-state.d.ts +20 -0
- package/lib/Utils/use-redis-auth-state.js +90 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.js +109 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
- package/lib/Utils/use-sqlite-auth-state.js +121 -0
- package/lib/Utils/username.d.ts +12 -0
- package/lib/Utils/username.js +59 -0
- package/lib/Utils/validate-connection.d.ts +2 -2
- package/lib/Utils/validate-connection.js +5 -5
- package/lib/Utils/voice-recognition.d.ts +53 -0
- package/lib/Utils/voice-recognition.js +219 -0
- package/lib/VoIP/audio-feeder.d.ts +24 -0
- package/lib/VoIP/audio-feeder.js +276 -0
- package/lib/VoIP/index.d.ts +93 -0
- package/lib/VoIP/index.js +998 -0
- package/lib/VoIP/relay-transport.d.ts +5 -0
- package/lib/VoIP/relay-transport.js +824 -0
- package/lib/VoIP/signaling.d.ts +11 -0
- package/lib/VoIP/signaling.js +1099 -0
- package/lib/VoIP/types.d.ts +2 -0
- package/lib/VoIP/types.js +12 -0
- package/lib/VoIP/video-feeder.d.ts +24 -0
- package/lib/VoIP/video-feeder.js +276 -0
- package/lib/VoIP/wasm-engine.d.ts +26 -0
- package/lib/VoIP/wasm-engine.js +1318 -0
- package/lib/VoIP/worker-bootstrap.js +1022 -0
- package/lib/WABinary/decode.d.ts +1 -1
- package/lib/WABinary/decode.js +2 -2
- package/lib/WABinary/encode.d.ts +1 -1
- package/lib/WABinary/encode.js +2 -2
- package/lib/WABinary/generic-utils.d.ts +3 -1
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +3 -1
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WABinary/index.d.ts +5 -5
- package/lib/WABinary/index.js +5 -5
- package/lib/WABinary/jid-utils.d.ts +2 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -1
- package/lib/WABinary/jid-utils.js +3 -1
- package/lib/WABinary/jid-utils.js.map +1 -1
- package/lib/WABinary/types.d.ts +1 -1
- package/lib/WABinary/types.js +1 -1
- package/lib/WAM/BinaryInfo.d.ts +1 -1
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAM/encode.js +2 -2
- package/lib/WAM/index.d.ts +3 -3
- package/lib/WAM/index.js +3 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +2 -2
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/index.d.ts +5 -5
- package/lib/WAUSync/Protocols/index.js +5 -5
- package/lib/WAUSync/USyncQuery.d.ts +3 -3
- package/lib/WAUSync/USyncQuery.js +5 -5
- package/lib/WAUSync/index.d.ts +3 -3
- package/lib/WAUSync/index.js +3 -3
- package/lib/extensions/awang-MessageBuilder.js +1 -1
- package/lib/index.d.ts +14 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -11
- package/lib/index.js.map +1 -1
- package/package.json +78 -31
- package/MIGRASI-QIRO-BAILEYS-RC25.md +0 -102
- package/QIRO-BAILEYS-RC25.md +0 -168
- package/THIRD_PARTY_NOTICES.md +0 -49
- /package/{engine-requirements.js → config/engine-requirements.js} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const VIDEO_FORMAT_I420: number;
|
|
2
|
+
export declare class VideoFeeder {
|
|
3
|
+
constructor(width: number, height: number, fps: number, onFrame: (frame: Buffer, width: number, height: number, fps: number) => void, source?: string | null, hooks?: {
|
|
4
|
+
onTrackStart?: (track: string) => void;
|
|
5
|
+
onTrackEnd?: (track: string) => void;
|
|
6
|
+
onIdle?: () => void;
|
|
7
|
+
ffmpegPath?: string;
|
|
8
|
+
});
|
|
9
|
+
readonly queuedFrames: number;
|
|
10
|
+
readonly playlistLength: number;
|
|
11
|
+
readonly currentTrack: string | null;
|
|
12
|
+
readonly idle: boolean;
|
|
13
|
+
underflowFrames: number;
|
|
14
|
+
framesEmitted: number;
|
|
15
|
+
tracksPlayed: number;
|
|
16
|
+
rebuffers: number;
|
|
17
|
+
ffmpegPath: string;
|
|
18
|
+
enqueue(source: string | string[]): number;
|
|
19
|
+
clearPlaylist(): void;
|
|
20
|
+
skip(): boolean;
|
|
21
|
+
start(playlist?: string[]): void;
|
|
22
|
+
stop(): void;
|
|
23
|
+
}
|
|
24
|
+
export default VideoFeeder;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
const PREBUFFER_FRAMES = 3;
|
|
3
|
+
const MAX_QUEUED_FRAMES = 90;
|
|
4
|
+
const RESUME_QUEUE_FRAMES = 30;
|
|
5
|
+
const RESYNC_AFTER_MS = 400;
|
|
6
|
+
export const VIDEO_FORMAT_I420 = 1;
|
|
7
|
+
export class VideoFeeder {
|
|
8
|
+
constructor(width, height, fps, onFrame, source = null, hooks = {}) {
|
|
9
|
+
this.width = Math.max(2, Math.floor((Math.trunc(Number(width)) || 640) / 2) * 2);
|
|
10
|
+
this.height = Math.max(2, Math.floor((Math.trunc(Number(height)) || 480) / 2) * 2);
|
|
11
|
+
this.fps = fps;
|
|
12
|
+
this.onFrame = onFrame;
|
|
13
|
+
this.source = source;
|
|
14
|
+
this.onTrackStart = hooks.onTrackStart ?? (() => {});
|
|
15
|
+
this.onTrackEnd = hooks.onTrackEnd ?? (() => {});
|
|
16
|
+
this.onIdle = hooks.onIdle ?? (() => {});
|
|
17
|
+
this.ffmpegPath = hooks.ffmpegPath || process.env.FFMPEG_PATH || 'ffmpeg';
|
|
18
|
+
this.underflowFrames = 0;
|
|
19
|
+
this.framesEmitted = 0;
|
|
20
|
+
this.tracksPlayed = 0;
|
|
21
|
+
this.rebuffers = 0;
|
|
22
|
+
this._proc = null;
|
|
23
|
+
this._playlist = [];
|
|
24
|
+
this._current = null;
|
|
25
|
+
this._sourceEnded = false;
|
|
26
|
+
this._idle = false;
|
|
27
|
+
this._pendingParts = [];
|
|
28
|
+
this._pendingBytes = 0;
|
|
29
|
+
this._queue = [];
|
|
30
|
+
this._emitTimer = null;
|
|
31
|
+
this._startedAtMs = 0;
|
|
32
|
+
this._emitIndex = 0;
|
|
33
|
+
this._buffering = true;
|
|
34
|
+
this._running = false;
|
|
35
|
+
this._lastFrame = null;
|
|
36
|
+
this._frameBytes = Math.floor(this.width * this.height * 3 / 2);
|
|
37
|
+
this._frameIntervalMs = 1000 / this.fps;
|
|
38
|
+
}
|
|
39
|
+
get queuedFrames() {
|
|
40
|
+
return this._queue.length;
|
|
41
|
+
}
|
|
42
|
+
get playlistLength() {
|
|
43
|
+
return this._playlist.length;
|
|
44
|
+
}
|
|
45
|
+
get currentTrack() {
|
|
46
|
+
return this._current;
|
|
47
|
+
}
|
|
48
|
+
get idle() {
|
|
49
|
+
return this._idle;
|
|
50
|
+
}
|
|
51
|
+
enqueue(source) {
|
|
52
|
+
const tracks = Array.isArray(source) ? source : [source];
|
|
53
|
+
for (const track of tracks) {
|
|
54
|
+
if (track) {
|
|
55
|
+
this._playlist.push(track);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (this._running && !this._proc) {
|
|
59
|
+
this._advance();
|
|
60
|
+
}
|
|
61
|
+
return this._playlist.length;
|
|
62
|
+
}
|
|
63
|
+
clearPlaylist() {
|
|
64
|
+
this._playlist = [];
|
|
65
|
+
}
|
|
66
|
+
skip() {
|
|
67
|
+
if (!this._proc) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
this._stopSource();
|
|
71
|
+
this._advance();
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
start(playlist) {
|
|
75
|
+
if (this._running) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this._running = true;
|
|
79
|
+
this._idle = false;
|
|
80
|
+
this._buffering = true;
|
|
81
|
+
this._emitIndex = 0;
|
|
82
|
+
this._startedAtMs = 0;
|
|
83
|
+
const initial = playlist ?? (this.source ? [this.source] : []);
|
|
84
|
+
this._playlist = Array.isArray(initial) ? [...initial] : [initial];
|
|
85
|
+
this._advance();
|
|
86
|
+
this._schedule();
|
|
87
|
+
}
|
|
88
|
+
stop() {
|
|
89
|
+
this._running = false;
|
|
90
|
+
if (this._emitTimer) {
|
|
91
|
+
clearTimeout(this._emitTimer);
|
|
92
|
+
this._emitTimer = null;
|
|
93
|
+
}
|
|
94
|
+
this._stopSource();
|
|
95
|
+
this._playlist = [];
|
|
96
|
+
this._current = null;
|
|
97
|
+
this._pendingParts = [];
|
|
98
|
+
this._pendingBytes = 0;
|
|
99
|
+
this._queue = [];
|
|
100
|
+
this._lastFrame = null;
|
|
101
|
+
this._buffering = true;
|
|
102
|
+
}
|
|
103
|
+
_stopSource() {
|
|
104
|
+
const proc = this._proc;
|
|
105
|
+
this._proc = null;
|
|
106
|
+
if (proc) {
|
|
107
|
+
proc.stdout?.removeAllListeners('data');
|
|
108
|
+
proc.removeAllListeners('exit');
|
|
109
|
+
try {
|
|
110
|
+
proc.kill?.('SIGTERM');
|
|
111
|
+
}
|
|
112
|
+
catch {}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_advance() {
|
|
116
|
+
const next = this._playlist.shift();
|
|
117
|
+
if (!next) {
|
|
118
|
+
this._current = null;
|
|
119
|
+
if (!this._idle) {
|
|
120
|
+
this._idle = true;
|
|
121
|
+
this.onIdle();
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this._idle = false;
|
|
126
|
+
this._current = next;
|
|
127
|
+
this._sourceEnded = false;
|
|
128
|
+
this._buffering = true;
|
|
129
|
+
this._spawn(next);
|
|
130
|
+
this.tracksPlayed += 1;
|
|
131
|
+
this.onTrackStart(next);
|
|
132
|
+
}
|
|
133
|
+
_spawn(source) {
|
|
134
|
+
const proc = spawn(this.ffmpegPath, [
|
|
135
|
+
'-hide_banner',
|
|
136
|
+
'-loglevel', 'error',
|
|
137
|
+
'-thread_queue_size', '512',
|
|
138
|
+
...this._resolveInputArgs(source),
|
|
139
|
+
'-vf', `scale=${this.width}:${this.height}:force_original_aspect_ratio=decrease,pad=${this.width}:${this.height}:(ow-iw)/2:(oh-ih)/2,fps=${this.fps}`,
|
|
140
|
+
'-pix_fmt', 'yuv420p',
|
|
141
|
+
'-f', 'rawvideo',
|
|
142
|
+
'-an',
|
|
143
|
+
'pipe:1'
|
|
144
|
+
]);
|
|
145
|
+
this._proc = proc;
|
|
146
|
+
proc.stdout.on('data', chunk => this._absorb(chunk));
|
|
147
|
+
proc.stderr.on('data', chunk => {
|
|
148
|
+
process.stderr.write(`[VideoFeeder] ${chunk.toString().trim()}\n`);
|
|
149
|
+
});
|
|
150
|
+
proc.on('error', err => {
|
|
151
|
+
if (this._proc !== proc) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
process.stderr.write(`[VideoFeeder] ffmpeg error: ${err?.message || err}\n`);
|
|
155
|
+
this._proc = null;
|
|
156
|
+
this._sourceEnded = true;
|
|
157
|
+
});
|
|
158
|
+
proc.on('exit', code => {
|
|
159
|
+
if (this._proc !== proc) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (code !== 0 && code !== null) {
|
|
163
|
+
process.stderr.write(`[VideoFeeder] ffmpeg exited with code=${code}\n`);
|
|
164
|
+
}
|
|
165
|
+
this._proc = null;
|
|
166
|
+
this._sourceEnded = true;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
_resolveInputArgs(source = this.source) {
|
|
170
|
+
if (!source || source === 'black') {
|
|
171
|
+
return ['-re', '-f', 'lavfi', '-i', `color=c=black:s=${this.width}x${this.height}:r=${this.fps}`];
|
|
172
|
+
}
|
|
173
|
+
if (source.startsWith('lavfi:')) {
|
|
174
|
+
return ['-re', '-f', 'lavfi', '-i', source.slice('lavfi:'.length)];
|
|
175
|
+
}
|
|
176
|
+
if (/\.(jpe?g|png|webp|bmp|gif)$/i.test(source)) {
|
|
177
|
+
return ['-re', '-loop', '1', '-i', source];
|
|
178
|
+
}
|
|
179
|
+
return ['-re', '-i', source];
|
|
180
|
+
}
|
|
181
|
+
_absorb(chunk) {
|
|
182
|
+
this._pendingParts.push(chunk);
|
|
183
|
+
this._pendingBytes += chunk.length;
|
|
184
|
+
while (this._pendingBytes >= this._frameBytes) {
|
|
185
|
+
if (this._queue.length >= MAX_QUEUED_FRAMES) {
|
|
186
|
+
this._proc?.stdout.pause();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this._queue.push(this._takeFrame());
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
_takeFrame() {
|
|
193
|
+
const frame = this._pendingParts.length === 1 && this._pendingParts[0].length === this._frameBytes
|
|
194
|
+
? this._pendingParts.shift()
|
|
195
|
+
: this._takeFromParts();
|
|
196
|
+
this._pendingBytes -= this._frameBytes;
|
|
197
|
+
return frame;
|
|
198
|
+
}
|
|
199
|
+
_takeFromParts() {
|
|
200
|
+
const frame = Buffer.allocUnsafe(this._frameBytes);
|
|
201
|
+
let filled = 0;
|
|
202
|
+
while (filled < this._frameBytes) {
|
|
203
|
+
const part = this._pendingParts[0];
|
|
204
|
+
const take = Math.min(part.length, this._frameBytes - filled);
|
|
205
|
+
part.copy(frame, filled, 0, take);
|
|
206
|
+
filled += take;
|
|
207
|
+
if (take === part.length) {
|
|
208
|
+
this._pendingParts.shift();
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
this._pendingParts[0] = part.subarray(take);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return frame;
|
|
215
|
+
}
|
|
216
|
+
_schedule() {
|
|
217
|
+
if (!this._running) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (this._startedAtMs === 0) {
|
|
221
|
+
this._startedAtMs = Date.now();
|
|
222
|
+
}
|
|
223
|
+
const target = this._startedAtMs + this._emitIndex * this._frameIntervalMs;
|
|
224
|
+
const now = Date.now();
|
|
225
|
+
if (now - target > RESYNC_AFTER_MS) {
|
|
226
|
+
this._startedAtMs = now - this._emitIndex * this._frameIntervalMs;
|
|
227
|
+
}
|
|
228
|
+
this._emitTimer = setTimeout(() => {
|
|
229
|
+
this._emitTimer = null;
|
|
230
|
+
this._tick();
|
|
231
|
+
}, Math.max(0, target - now));
|
|
232
|
+
}
|
|
233
|
+
_tick() {
|
|
234
|
+
if (!this._running && !this._proc) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (this._sourceEnded && !this._queue.length && !this._pendingBytes) {
|
|
238
|
+
this._sourceEnded = false;
|
|
239
|
+
const finished = this._current;
|
|
240
|
+
this._current = null;
|
|
241
|
+
this.onTrackEnd(finished);
|
|
242
|
+
this._advance();
|
|
243
|
+
}
|
|
244
|
+
if (this._buffering) {
|
|
245
|
+
if (this._queue.length < PREBUFFER_FRAMES && this._proc) {
|
|
246
|
+
this._startedAtMs = 0;
|
|
247
|
+
this._emitIndex = 0;
|
|
248
|
+
this._schedule();
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this._buffering = false;
|
|
252
|
+
}
|
|
253
|
+
const frame = this._queue.shift();
|
|
254
|
+
if (frame) {
|
|
255
|
+
this._lastFrame = frame;
|
|
256
|
+
this.onFrame(frame, this.width, this.height, this.fps);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
this.underflowFrames += 1;
|
|
260
|
+
if (this._lastFrame) {
|
|
261
|
+
this.onFrame(this._lastFrame, this.width, this.height, this.fps);
|
|
262
|
+
}
|
|
263
|
+
if (this._proc) {
|
|
264
|
+
this.rebuffers += 1;
|
|
265
|
+
this._buffering = true;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
this.framesEmitted += 1;
|
|
269
|
+
this._emitIndex += 1;
|
|
270
|
+
if (this._proc?.stdout.isPaused() && this._queue.length <= RESUME_QUEUE_FRAMES) {
|
|
271
|
+
this._proc.stdout.resume();
|
|
272
|
+
}
|
|
273
|
+
this._schedule();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
export default VideoFeeder;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare class WasmEngine {
|
|
2
|
+
constructor(config?: {
|
|
3
|
+
wasmPath?: string;
|
|
4
|
+
wasmBinary?: Uint8Array | Buffer;
|
|
5
|
+
resourcesPath?: string;
|
|
6
|
+
storageDir?: string;
|
|
7
|
+
loaderCode?: string;
|
|
8
|
+
workerModulesCode?: string;
|
|
9
|
+
enableLogs?: boolean;
|
|
10
|
+
options?: Record<string, unknown>;
|
|
11
|
+
callbacks?: Record<string, unknown>;
|
|
12
|
+
});
|
|
13
|
+
initialize(): Promise<void>;
|
|
14
|
+
isInitialized(): boolean;
|
|
15
|
+
initVoipStack(selfPnJid: string, selfJid: string, selfLidJid: string): void;
|
|
16
|
+
waitForVoipStackReady(): Promise<void>;
|
|
17
|
+
startGroupCall(options: Record<string, unknown>): unknown;
|
|
18
|
+
joinOngoingCall(options: Record<string, unknown>): unknown;
|
|
19
|
+
acceptCall(isMicEnabled?: boolean, isCameraEnabled?: boolean): unknown;
|
|
20
|
+
sendVideoFrame(frame: Uint8Array, width: number, height: number, fps: number, format?: number, orientation?: number, useDesktopCapture?: boolean): boolean;
|
|
21
|
+
startScreenShare(): unknown;
|
|
22
|
+
stopScreenShare(): unknown;
|
|
23
|
+
releaseVideoFrameBuffer(): void;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|
|
26
|
+
export default WasmEngine;
|