Skip to content

Instantly share code, notes, and snippets.

@ozcanzaferayan
Created February 24, 2022 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozcanzaferayan/7a00bd09a085b00775a54df61ce0ae57 to your computer and use it in GitHub Desktop.
Save ozcanzaferayan/7a00bd09a085b00775a54df61ce0ae57 to your computer and use it in GitHub Desktop.
#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