Recorder Class

Description

Recorder 实现了对当前渲染环境的屏幕录制功能。

当前Recorder 只在 Android(4.3 或更新)和 iOS的OpenGL ES 2.0 环境下工作。

由于依赖于OpenGLES,本类的所有函数(除requestPermissions以外,包括析构函数)都必须在单个包含OpenGLES上下文的线程中调用。

Unity Only Unity中如果使用Multi-threaded rendering功能,则脚本线程将与渲染线程分离,无法在渲染线程上调用updateFrame。因此,如果需要使用屏幕录制功能,应禁用Multi-threaded rendering功能。

Android使用时需要在AndroidManifest.xml中加入android.permission.RECORD_AUDIO权限声明。

iOS使用时需要在Info.plist中加入NSMicrophoneUsageDescription权限声明。

isAvailable

只在Android 4.3以上或iOS平台下返回true。

C

bool easyar_Recorder_isAvailable(void)

C++17

static bool isAvailable()

C++03

static bool isAvailable()

Java

public static boolean isAvailable()

Kotlin

companion object fun isAvailable(): Boolean

Objective-C

+ (bool)isAvailable

Swift

public static func isAvailable() -> Bool

C#

public static bool isAvailable()

requestPermissions

请求录屏所需的系统权限。你可以选择使用这个函数或自己调用系统函数申请权限。只在Android和iOS平台上有效,其他平台上的行为为直接调用回调通知权限已授权。应在UI线程调用该函数。

C

void easyar_Recorder_requestPermissions(easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback)

C++17

static void requestPermissions(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(PermissionStatus, std::string)>> permissionCallback)

C++03

static void requestPermissions(CallbackScheduler * callbackScheduler, OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback)

Java

public static void requestPermissions(@Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromPermissionStatusAndString permissionCallback)

Kotlin

companion object fun requestPermissions(callbackScheduler: CallbackScheduler, permissionCallback: FunctorOfVoidFromPermissionStatusAndString?): Unit

Objective-C

+ (void)requestPermissions:(easyar_CallbackScheduler *)callbackScheduler permissionCallback:(void (^)(easyar_PermissionStatus status, NSString * value))permissionCallback

Swift

public static func requestPermissions(_ callbackScheduler: CallbackScheduler, _ permissionCallback: ((PermissionStatus, String) -> Void)?) -> Void

C#

public static void requestPermissions(CallbackScheduler callbackScheduler, Optional<Action<PermissionStatus, string>> permissionCallback)

create

创建并初始化录屏功能。statusCallback回调中会通知一些状态变化和对应的日志。

C

void easyar_Recorder_create(easyar_RecorderConfiguration * config, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromRecordStatusAndString statusCallback, easyar_Recorder * * Return)

C++17

static std::shared_ptr<Recorder> create(std::shared_ptr<RecorderConfiguration> config, std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(RecordStatus, std::string)>> statusCallback)

C++03

static void create(RecorderConfiguration * config, CallbackScheduler * callbackScheduler, OptionalOfFunctorOfVoidFromRecordStatusAndString statusCallback, Recorder * * Return)

Java

public static @Nonnull Recorder create(@Nonnull RecorderConfiguration config, @Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromRecordStatusAndString statusCallback)

Kotlin

companion object fun create(config: RecorderConfiguration, callbackScheduler: CallbackScheduler, statusCallback: FunctorOfVoidFromRecordStatusAndString?): Recorder

Objective-C

+ (easyar_Recorder *)create:(easyar_RecorderConfiguration *)config callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler statusCallback:(void (^)(easyar_RecordStatus status, NSString * value))statusCallback

Swift

public static func create(_ config: RecorderConfiguration, _ callbackScheduler: CallbackScheduler, _ statusCallback: ((RecordStatus, String) -> Void)?) -> Recorder

C#

public static Recorder create(RecorderConfiguration config, CallbackScheduler callbackScheduler, Optional<Action<RecordStatus, string>> statusCallback)

start

开始录屏。

C

void easyar_Recorder_start(easyar_Recorder * This)

C++17

void start()

C++03

void start()

Java

public void start()

Kotlin

fun start(): Unit

Objective-C

- (void)start

Swift

public func start() -> Void

C#

public virtual void start()

updateFrame

使用texture录制一帧数据。

C

void easyar_Recorder_updateFrame(easyar_Recorder * This, easyar_TextureId * texture, int width, int height)

C++17

void updateFrame(std::shared_ptr<TextureId> texture, int width, int height)

C++03

void updateFrame(TextureId * texture, int width, int height)

Java

public void updateFrame(@Nonnull TextureId texture, int width, int height)

Kotlin

fun updateFrame(texture: TextureId, width: Int, height: Int): Unit

Objective-C

- (void)updateFrame:(easyar_TextureId *)texture width:(int)width height:(int)height

Swift

public func updateFrame(_ texture: TextureId, _ width: Int32, _ height: Int32) -> Void

C#

public virtual void updateFrame(TextureId texture, int width, int height)

stop

停止录屏。在调用stop之后,会等待文件写入结束并返回录制是否成功的结果。

C

bool easyar_Recorder_stop(easyar_Recorder * This)

C++17

bool stop()

C++03

bool stop()

Java

public boolean stop()

Kotlin

fun stop(): Boolean

Objective-C

- (bool)stop

Swift

public func stop() -> Bool

C#

public virtual bool stop()