MCPcopy Create free account
hub / github.com/BabitMF/bmf / stopAlgorithm

Method stopAlgorithm

bmf_lite/ohos/entry/src/main/cpp/render/plugin_render.cpp:457–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457napi_value PluginRender::stopAlgorithm(napi_env env, napi_callback_info info) {
458 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "PluginRender",
459 "stopAlgorithm");
460 napi_value thisArg;
461 if (napi_get_cb_info(env, info, nullptr, nullptr, &thisArg, nullptr) !=
462 napi_ok) {
463 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginRender",
464 "createCamera: napi_get_cb_info fail");
465 return nullptr;
466 }
467 /* // 获取环境变量中XComponent实例*/
468 napi_value exportInstance;
469 if (napi_get_named_property(env, thisArg, OH_NATIVE_XCOMPONENT_OBJ,
470 &exportInstance) != napi_ok) {
471 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginRender",
472 "NapiDrawPattern: napi_get_named_property fail");
473 return nullptr;
474 }
475
476 OH_NativeXComponent *nativeXComponent = nullptr;
477 if (napi_unwrap(env, exportInstance,
478 reinterpret_cast<void **>(&nativeXComponent)) != napi_ok) {
479 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginRender",
480 "NapiDrawPattern: napi_unwrap fail");
481 return nullptr;
482 }
483 // 获取XComponent实例的id
484 char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {'\0'};
485 uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1;
486 if (OH_NativeXComponent_GetXComponentId(nativeXComponent, idStr, &idSize) !=
487 OH_NATIVEXCOMPONENT_RESULT_SUCCESS) {
488 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginRender",
489 "NapiDrawPattern: Unable to get XComponent id");
490 return nullptr;
491 }
492
493 size_t argc = 1;
494 napi_value args[1] = {nullptr};
495 napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
496
497 napi_valuetype valuetype0;
498 napi_typeof(env, args[0], &valuetype0);
499
500 int32_t alg_type;
501 napi_get_value_int32(env, args[0], &alg_type);
502
503 std::string id(idStr);
504 PluginRender *render = PluginRender::GetInstance(id);
505 if (render != nullptr) {
506 render->renderThread_->StopAlgorithm();
507 }
508 return nullptr;
509}
510
511void PluginRender::CreateCamera() {
512 std::string surfaceIdStr =

Callers

nothing calls this directly

Calls 1

StopAlgorithmMethod · 0.80

Tested by

no test coverage detected