@@ -42,11 +42,16 @@ Napi::Object osn::Global::Init(Napi::Env env, Napi::Object exports)
4242
4343 StaticMethod (" getOutputFlagsFromId" , &osn::Global::getOutputFlagsFromId),
4444
45- StaticAccessor (" laggedFrames" , &osn::Global::laggedFrames, nullptr ),
46- StaticAccessor (" totalFrames" , &osn::Global::totalFrames, nullptr ),
47-
45+ StaticAccessor (" laggedFrames" , &osn::Global::GetLaggedFrames, nullptr ),
46+ StaticAccessor (" totalFrames" , &osn::Global::GetTotalFrames, nullptr ),
4847 StaticAccessor (" locale" , &osn::Global::getLocale, &osn::Global::setLocale),
4948 StaticAccessor (" multipleRendering" , &osn::Global::getMultipleRendering, &osn::Global::setMultipleRendering),
49+
50+ StaticAccessor (" cpuPercentage" , &osn::Global::GetCPUPercentage, nullptr ),
51+ StaticAccessor (" currentFrameRate" , &osn::Global::GetCurrentFrameRate, nullptr ),
52+ StaticAccessor (" averageFrameRenderTime" , &osn::Global::GetAverageTimeToRenderFrame, nullptr ),
53+ StaticAccessor (" diskSpaceAvailable" , &osn::Global::GetDiskSpaceAvailable, nullptr ),
54+ StaticAccessor (" memoryUsage" , &osn::Global::GetMemoryUsage, nullptr ),
5055 });
5156 exports.Set (" Global" , func);
5257 osn::Global::constructor = Napi::Persistent (func);
@@ -154,27 +159,27 @@ Napi::Value osn::Global::getOutputFlagsFromId(const Napi::CallbackInfo &info)
154159 return Napi::Number::New (info.Env (), response[1 ].value_union .ui32 );
155160}
156161
157- Napi::Value osn::Global::laggedFrames (const Napi::CallbackInfo &info)
162+ Napi::Value osn::Global::GetLaggedFrames (const Napi::CallbackInfo &info)
158163{
159164 auto conn = GetConnection (info);
160165 if (!conn)
161166 return info.Env ().Undefined ();
162167
163- std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " LaggedFrames " , {});
168+ std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " GetLaggedFrames " , {});
164169
165170 if (!ValidateResponse (info, response))
166171 return info.Env ().Undefined ();
167172
168173 return Napi::Number::New (info.Env (), response[1 ].value_union .ui32 );
169174}
170175
171- Napi::Value osn::Global::totalFrames (const Napi::CallbackInfo &info)
176+ Napi::Value osn::Global::GetTotalFrames (const Napi::CallbackInfo &info)
172177{
173178 auto conn = GetConnection (info);
174179 if (!conn)
175180 return info.Env ().Undefined ();
176181
177- std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " TotalFrames " , {});
182+ std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " GetTotalFrames " , {});
178183
179184 if (!ValidateResponse (info, response))
180185 return info.Env ().Undefined ();
@@ -227,3 +232,73 @@ void osn::Global::setMultipleRendering(const Napi::CallbackInfo &info, const Nap
227232
228233 conn->call (" Global" , " SetMultipleRendering" , {ipc::value (value.ToBoolean ().Value ())});
229234}
235+
236+ Napi::Value osn::Global::GetCPUPercentage (const Napi::CallbackInfo &info)
237+ {
238+ auto conn = GetConnection (info);
239+ if (!conn)
240+ return info.Env ().Undefined ();
241+
242+ std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " GetCPUPercentage" , {});
243+
244+ if (!ValidateResponse (info, response))
245+ return info.Env ().Undefined ();
246+
247+ return Napi::Number::New (info.Env (), response[1 ].value_union .ui32 );
248+ }
249+
250+ Napi::Value osn::Global::GetCurrentFrameRate (const Napi::CallbackInfo &info)
251+ {
252+ auto conn = GetConnection (info);
253+ if (!conn)
254+ return info.Env ().Undefined ();
255+
256+ std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " GetCurrentFrameRate" , {});
257+
258+ if (!ValidateResponse (info, response))
259+ return info.Env ().Undefined ();
260+
261+ return Napi::Number::New (info.Env (), response[1 ].value_union .ui32 );
262+ }
263+
264+ Napi::Value osn::Global::GetAverageTimeToRenderFrame (const Napi::CallbackInfo &info)
265+ {
266+ auto conn = GetConnection (info);
267+ if (!conn)
268+ return info.Env ().Undefined ();
269+
270+ std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " GetAverageTimeToRenderFrame" , {});
271+
272+ if (!ValidateResponse (info, response))
273+ return info.Env ().Undefined ();
274+
275+ return Napi::Number::New (info.Env (), response[1 ].value_union .ui32 );
276+ }
277+
278+ Napi::Value osn::Global::GetDiskSpaceAvailable (const Napi::CallbackInfo &info)
279+ {
280+ auto conn = GetConnection (info);
281+ if (!conn)
282+ return info.Env ().Undefined ();
283+
284+ std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " GetDiskSpaceAvailable" , {});
285+
286+ if (!ValidateResponse (info, response))
287+ return info.Env ().Undefined ();
288+
289+ return Napi::String::New (info.Env (), response[1 ].value_str );
290+ }
291+
292+ Napi::Value osn::Global::GetMemoryUsage (const Napi::CallbackInfo &info)
293+ {
294+ auto conn = GetConnection (info);
295+ if (!conn)
296+ return info.Env ().Undefined ();
297+
298+ std::vector<ipc::value> response = conn->call_synchronous_helper (" Global" , " GetMemoryUsage" , {});
299+
300+ if (!ValidateResponse (info, response))
301+ return info.Env ().Undefined ();
302+
303+ return Napi::Number::New (info.Env (), response[1 ].value_union .ui32 );
304+ }
0 commit comments