Created
February 24, 2022 12:41
-
-
Save ozcanzaferayan/7a00bd09a085b00775a54df61ce0ae57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#import <jsi/jsi.h> | |
#import <CoreMedia/CMSampleBuffer.h> | |
#import "Frame.h" | |
using namespace facebook; | |
class JSI_EXPORT FrameHostObject: public jsi::HostObject { | |
public: | |
explicit FrameHostObject(Frame* frame): frame(frame) {} | |
public: | |
// By overriding the get and getPropertyNames functions, | |
// properties can be used as JS object property. | |
// For example, when frame.height is requested, | |
// the get method here is called by setting the name property "height" below. | |
jsi::Value get(jsi::Runtime&, const jsi::PropNameID& name) override; | |
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& rt) override; | |
void close(); | |
public: | |
// We cannot access directly to frame object | |
// Because this is C++ object and JS doesn't know how to interact with this object. | |
// Instead we use the get methods above. | |
Frame* frame; | |
private: | |
void assertIsFrameStrong(jsi::Runtime& runtime, const std::string& accessedPropName); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment