-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathRNFFilamentRecorder.cpp
More file actions
57 lines (48 loc) · 2.27 KB
/
Copy pathRNFFilamentRecorder.cpp
File metadata and controls
57 lines (48 loc) · 2.27 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
56
57
//
// Created by Marc Rousavy on 02.05.24.
//
#include "RNFFilamentRecorder.h"
#include "RNFLogger.h"
#include <jsi/jsi.h>
namespace margelo {
using namespace facebook;
FilamentRecorder::FilamentRecorder(std::shared_ptr<nitro::Dispatcher> renderThreadDispatcher, int width, int height, int fps,
double bitRate)
: HybridObject("FilamentRecorder"), _renderThreadDispatcher(renderThreadDispatcher), _width(width), _height(height), _fps(fps),
_bitRate(bitRate), _listenerManager(ListenerManager<ReadyForMoreDataCallback>::create()) {
Logger::log(TAG, "Creating %zu x %zu @ %zu FPS (%f bps) FilamentRecorder...", width, height, fps, bitRate);
}
FilamentRecorder::~FilamentRecorder() {
Logger::log(TAG, "Destroying FilamentRecorder...");
}
void FilamentRecorder::loadHybridMethods() {
HybridObject::loadHybridMethods();
registerHybrids(this, [](nitro::Prototype& proto) {
proto.registerHybridGetter("width", &FilamentRecorder::getWidth);
proto.registerHybridGetter("height", &FilamentRecorder::getHeight);
proto.registerHybridGetter("fps", &FilamentRecorder::getFps);
proto.registerHybridGetter("bitRate", &FilamentRecorder::getBitRate);
proto.registerHybridGetter("outputFile", &FilamentRecorder::getOutputFile);
proto.registerHybridGetter("isRecording", &FilamentRecorder::getIsRecording);
proto.registerHybridMethod("startRecording", &FilamentRecorder::startRecording);
proto.registerHybridMethod("stopRecording", &FilamentRecorder::stopRecording);
proto.registerHybridMethod("renderFrame", &FilamentRecorder::renderFrame);
// TODO: nitro
// proto.registerHybridMethod("addOnReadyForMoreDataListener", &FilamentRecorder::addOnReadyForMoreDataListener);
});
}
std::shared_ptr<Listener> FilamentRecorder::addOnReadyForMoreDataListener(const ReadyForMoreDataCallback& callback) {
return _listenerManager->add(callback);
}
bool FilamentRecorder::onReadyForMoreData() {
// notify all JS listeners
bool shouldContinueNext = _listenerManager->getHasListeners();
_listenerManager->forEach([&shouldContinueNext](const ReadyForMoreDataCallback& callback) {
bool result = callback();
if (!result) {
shouldContinueNext = false;
}
});
return shouldContinueNext;
}
} // namespace margelo