| 90 | } |
| 91 | |
| 92 | bool GrPluginInterface::OnCreate(const GrPluginParam& param) { |
| 93 | SnowflakeId::initialize(0, 103); |
| 94 | MemoryStat::Instance(); |
| 95 | this->param_ = param; |
| 96 | if (param.cluster_.contains("name")) { |
| 97 | auto n = param.cluster_.at("name"); |
| 98 | plugin_file_name_ = std::any_cast<std::string>(n); |
| 99 | } |
| 100 | |
| 101 | if (param.cluster_.contains("base_path")) { |
| 102 | base_path_ = std::any_cast<std::string>(param.cluster_.at("base_path")); |
| 103 | } |
| 104 | if (param.cluster_.contains("base_data_path")) { |
| 105 | base_data_path_ = std::any_cast<std::string>(param.cluster_.at("base_data_path")); |
| 106 | } |
| 107 | plugin_context_ = std::make_shared<GrPluginContext>(GetPluginName()); |
| 108 | |
| 109 | Logger::InitLog(base_data_path_ + "/gr_logs/" + plugin_file_name_+".log", true); |
| 110 | LOGI("{} OnCreate", GetPluginName()); |
| 111 | |
| 112 | capture_audio_device_id_ = GetConfigParam<std::string>("capture_audio_device_id"); |
| 113 | sys_settings_.device_id_ = GetConfigParam<std::string>("device_id"); |
| 114 | sys_settings_.relay_enabled_ = GetConfigBoolParam("relay_enabled"); |
| 115 | sys_settings_.language_ = (int)GetConfigIntParam("language"); |
| 116 | sys_settings_.appkey_ = GetConfigStringParam("appkey"); |
| 117 | |
| 118 | // print params |
| 119 | LOGI("Input params size : {}", param.cluster_.size()); |
| 120 | for (const auto& [key, value]: param.cluster_) { |
| 121 | if (value.type() == typeid(std::string)) { |
| 122 | LOGI(" * {} => {}", key, std::any_cast<std::string>(value)); |
| 123 | } |
| 124 | else if (value.type() == typeid(int64_t)) { |
| 125 | LOGI(" * {} => {}", key, std::any_cast<int64_t>(value)); |
| 126 | } |
| 127 | else if (value.type() == typeid(double)) { |
| 128 | LOGI(" * {} => {}", key, std::any_cast<double>(value)); |
| 129 | } |
| 130 | else if (value.type() == typeid(bool)) { |
| 131 | LOGI(" * {} => {}", key, std::any_cast<bool>(value)); |
| 132 | } |
| 133 | |
| 134 | // parse |
| 135 | if (key == "author") { |
| 136 | plugin_author_ = std::any_cast<std::string>(value); |
| 137 | } |
| 138 | else if (key == "description") { |
| 139 | plugin_desc_ = std::any_cast<std::string>(value); |
| 140 | } |
| 141 | else if (key == "version_name") { |
| 142 | plugin_version_name_ = std::any_cast<std::string>(value); |
| 143 | } |
| 144 | else if (key == "version_code") { |
| 145 | plugin_version_code_ = std::any_cast<int64_t>(value); |
| 146 | } |
| 147 | else if (key == "enabled") { |
| 148 | plugin_enabled_ = std::any_cast<bool>(value); |
| 149 | } |
nothing calls this directly
no outgoing calls
no test coverage detected