-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Rewrite Android C++ part (VisionCameraProxy
+ JFrame
)
#1661
Changes from 8 commits
0611b73
4a82509
def0921
8efb1cc
ce0cc91
c288545
456571f
8b11200
cdfb713
ca4bf22
f8aec55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,25 +11,25 @@ | |
#include <string> | ||
#include <mutex> | ||
|
||
#include "java-bindings/JImageProxy.h" | ||
#include "java-bindings/JFrame.h" | ||
|
||
namespace vision { | ||
|
||
using namespace facebook; | ||
|
||
class JSI_EXPORT FrameHostObject : public jsi::HostObject { | ||
public: | ||
explicit FrameHostObject(jni::alias_ref<JImageProxy::javaobject> image); | ||
explicit FrameHostObject(const jni::alias_ref<JFrame::javaobject>& frame); | ||
public: | ||
~FrameHostObject(); | ||
|
||
public: | ||
public: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) override; | ||
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override; | ||
|
||
public: | ||
jni::global_ref<JImageProxy> frame; | ||
public: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
jni::global_ref<JFrame> frame; | ||
|
||
private: | ||
private: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
static auto constexpr TAG = "VisionCamera"; | ||
|
||
size_t _refCount; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// Created by Marc Rousavy on 21.07.23. | ||
// | ||
|
||
#include "FrameProcessorPluginHostObject.h" | ||
#include <vector> | ||
#include "FrameHostObject.h" | ||
#include "JSIJNIConversion.h" | ||
|
||
namespace vision { | ||
|
||
using namespace facebook; | ||
|
||
std::vector<jsi::PropNameID> FrameProcessorPluginHostObject::getPropertyNames(jsi::Runtime& runtime) { | ||
std::vector<jsi::PropNameID> result; | ||
result.push_back(jsi::PropNameID::forUtf8(runtime, std::string("call"))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
return result; | ||
} | ||
|
||
jsi::Value FrameProcessorPluginHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& propName) { | ||
auto name = propName.utf8(runtime); | ||
|
||
if (name == "call") { | ||
return jsi::Function::createFromHostFunction(runtime, | ||
jsi::PropNameID::forUtf8(runtime, "call"), | ||
2, | ||
[=](jsi::Runtime &runtime, | ||
const jsi::Value &thisValue, | ||
const jsi::Value *arguments, | ||
size_t count) -> jsi::Value { | ||
// Frame is first argument | ||
auto frameHostObject = arguments[0].asObject(runtime).asHostObject<FrameHostObject>(runtime); | ||
auto frame = frameHostObject->frame; | ||
|
||
// Options are second argument (possibly undefined) | ||
local_ref<react::ReadableNativeMap::javaobject> options = nullptr; | ||
if (count > 1) { | ||
options = JSIJNIConversion::convertJSIObjectToJNIMap(runtime, arguments[1].asObject(runtime)); | ||
} | ||
|
||
// Call actual plugin | ||
auto result = _plugin->callback(frame, options); | ||
|
||
// Convert result value to jsi::Value (possibly undefined) | ||
return JSIJNIConversion::convertJNIObjectToJSIValue(runtime, result); | ||
}); | ||
} | ||
|
||
return jsi::Value::undefined(); | ||
} | ||
|
||
} // namespace vision | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// Created by Marc Rousavy on 21.07.23. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <jsi/jsi.h> | ||
#include "java-bindings/JFrameProcessorPlugin.h" | ||
#include <memory> | ||
#include <ReactCommon/CallInvoker.h> | ||
#include <fbjni/fbjni.h> | ||
|
||
namespace vision { | ||
|
||
using namespace facebook; | ||
|
||
class FrameProcessorPluginHostObject: public jsi::HostObject { | ||
public: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
explicit FrameProcessorPluginHostObject(jni::alias_ref<JFrameProcessorPlugin::javaobject> plugin): | ||
_plugin(make_global(plugin)) { } | ||
~FrameProcessorPluginHostObject() { } | ||
|
||
public: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
jsi::Value get(jsi::Runtime& runtime, const jsi::PropNameID& name) override; | ||
|
||
private: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
jni::global_ref<JFrameProcessorPlugin::javaobject> _plugin; | ||
}; | ||
|
||
} // namespace vision | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
public: should be indented +1 space inside class FrameHostObject [whitespace/indent] [3]