Repository navigation
Expand file tree
/
Copy pathbinding.cpp
More file actions
55 lines (42 loc) · 1.64 KB
/
Copy pathbinding.cpp
File metadata and controls
55 lines (42 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <napi.h>
#include "env_state.h"
#include "frame.h"
#include "audio.h"
#include "encoder.h"
#include "decoder.h"
#include "image_decoder.h"
#include "async_encoder.h"
#include "async_decoder.h"
#include "capability_probe.h"
// Forward declaration
void InitUtil(Napi::Env env, Napi::Object exports);
std::atomic<bool> nwc_env_teardown{false};
Napi::Object Init(Napi::Env env, Napi::Object exports) {
// One hook with static-lifetime state; per-instance hooks dangled after
// GC and corrupted node's cleanup queue at exit
env.AddCleanupHook([](std::atomic<bool>* flag) { flag->store(true); },
&nwc_env_teardown);
// Initialize frame classes
VideoFrameNative::Init(env, exports);
// Initialize audio classes
AudioDataNative::Init(env, exports);
AudioDecoderNative::Init(env, exports);
AudioEncoderNative::Init(env, exports);
// Initialize video encoder/decoder (sync versions)
VideoEncoderNative::Init(env, exports);
VideoDecoderNative::Init(env, exports);
// Initialize async video encoder/decoder (non-blocking versions)
VideoEncoderAsync::Init(env, exports);
VideoDecoderAsync::Init(env, exports);
// Initialize image decoder
ImageDecoderNative::Init(env, exports);
// Initialize capability probe for isConfigSupported
CapabilityProbe::Init(env, exports);
// Add factory functions
exports.Set("createVideoFrame", Napi::Function::New(env, CreateVideoFrame));
exports.Set("createAudioData", Napi::Function::New(env, CreateAudioData));
// Initialize utilities
InitUtil(env, exports);
return exports;
}
NODE_API_MODULE(webcodecs_node, Init)