forked from udarrr/opencv4nodejs-prebuilt-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoWriter.cc
101 lines (85 loc) · 2.68 KB
/
VideoWriter.cc
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "opencv_modules.h"
#ifdef HAVE_IO
#include "VideoWriter.h"
#include "VideoWriterBindings.h"
Nan::Persistent<v8::FunctionTemplate> VideoWriter::constructor;
NAN_MODULE_INIT(VideoWriter::Init) {
v8::Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(VideoWriter::New);
constructor.Reset(ctor);
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(FF::newString("VideoWriter"));
Nan::SetMethod(ctor, "fourcc", Fourcc);
Nan::SetPrototypeMethod(ctor, "write", Write);
Nan::SetPrototypeMethod(ctor, "writeAsync", WriteAsync);
Nan::SetPrototypeMethod(ctor, "get", Get);
Nan::SetPrototypeMethod(ctor, "getAsync", GetAsync);
Nan::SetPrototypeMethod(ctor, "set", Set);
Nan::SetPrototypeMethod(ctor, "setAsync", SetAsync);
Nan::SetPrototypeMethod(ctor, "release", Release);
Nan::Set(target,FF::newString("VideoWriter"), FF::getFunction(ctor));
};
NAN_METHOD(VideoWriter::New) {
FF::TryCatch tryCatch("VideoWriter::New");
FF_ASSERT_CONSTRUCT_CALL();
VideoWriterBindings::NewWorker worker;
if (worker.applyUnwrappers(info)) {
return tryCatch.reThrow();
}
VideoWriter* self = new VideoWriter();
self->self.open(worker.fileName, worker.fourccCode, worker.fps, (cv::Size)worker.frameSize, worker.isColor);
self->Wrap(info.Holder());
info.GetReturnValue().Set(info.Holder());
}
NAN_METHOD(VideoWriter::Release) {
Nan::ObjectWrap::Unwrap<VideoWriter>(info.This())->self.release();
}
NAN_METHOD(VideoWriter::Get) {
FF::executeSyncBinding(
std::make_shared<VideoWriterBindings::GetWorker>(VideoWriter::unwrapSelf(info)),
"VideoWriter::Get",
info
);
}
NAN_METHOD(VideoWriter::GetAsync) {
FF::executeAsyncBinding(
std::make_shared<VideoWriterBindings::GetWorker>(VideoWriter::unwrapSelf(info)),
"VideoWriter::GetAsync",
info
);
}
NAN_METHOD(VideoWriter::Set) {
FF::executeSyncBinding(
std::make_shared<VideoWriterBindings::SetWorker>(VideoWriter::unwrapSelf(info)),
"VideoCaptureVideoWriter::Set",
info
);
}
NAN_METHOD(VideoWriter::SetAsync) {
FF::executeAsyncBinding(
std::make_shared<VideoWriterBindings::SetWorker>(VideoWriter::unwrapSelf(info)),
"VideoWriter::SetAsync",
info
);
}
NAN_METHOD(VideoWriter::Fourcc) {
FF::executeSyncBinding(
std::make_shared<VideoWriterBindings::FourccWorker>(),
"VideoWriter::Fourcc",
info
);
}
NAN_METHOD(VideoWriter::Write) {
FF::executeSyncBinding(
std::make_shared<VideoWriterBindings::WriteWorker>(VideoWriter::unwrapSelf(info)),
"VideoWriter::Write",
info
);
}
NAN_METHOD(VideoWriter::WriteAsync) {
FF::executeAsyncBinding(
std::make_shared<VideoWriterBindings::WriteWorker>(VideoWriter::unwrapSelf(info)),
"VideoWriter::WriteAsync",
info
);
}
#endif