Этот репозиторий содержит Flutter плагины для платформы ОС Аврора.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

55 lines
1.5 KiB

/**
* SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru>
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <embedder_texture/embedder_texture_plugin.h>
#include <flutter/method-channel.h>
#include <flutter/platform-methods.h>
void EmbedderTexturePlugin::RegisterWithRegistrar(PluginRegistrar &registrar)
{
TextureRegistrar *plugin = registrar.GetRegisterTexture();
m_cameraPixelBuffer = new CameraPixelBuffer(plugin);
registrar.RegisterMethodChannel("embedder_texture",
MethodCodecType::Standard,
[this, plugin](const MethodCall &call) { this->onMethodCall(call, plugin); });
}
void EmbedderTexturePlugin::onMethodCall(const MethodCall &call, TextureRegistrar *plugin) {
const auto &method = call.GetMethod();
if (method == "create") {
onCreate(call, plugin);
return;
}
if (method == "remove") {
onRemove(call, plugin);
return;
}
unimplemented(call);
}
void EmbedderTexturePlugin::onCreate(const MethodCall &call, TextureRegistrar *plugin)
{
auto textureId = m_cameraPixelBuffer->Register();
call.SendSuccessResponse(textureId);
}
void EmbedderTexturePlugin::onRemove(const MethodCall &call, TextureRegistrar *plugin)
{
auto textureId = call.GetArgument<Encodable::Int>("textureId");
m_cameraPixelBuffer->Unregister();
call.SendSuccessResponse(true);
}
void EmbedderTexturePlugin::unimplemented(const MethodCall &call)
{
call.SendSuccessResponse(nullptr);
}