SmartSpectra C++ SDK
Measure human vitals from video with SmartSpectra C++ SDK.
Loading...
Searching...
No Matches
core_metrics_provider_impl.hpp
1
2// metrics_provider.cpp
3// Created by greg on 2/19/25.
4// Copyright (C) 2025 Presage Security, Inc.
5//
6// This program is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 3 of the License, or (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public License
17// along with this program; if not, write to the Free Software Foundation,
18// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21// === standard library includes (if any) ===
22// === third-party includes (if any) ===
23// === local includes (if any) ===
24#include "core_metrics_provider.hpp"
25
26namespace presage::smartspectra::grpc_bindings {
27
28template<container::settings::IntegrationMode TIntegrationMode>
29CoreMetricsProvider<TIntegrationMode>::CoreMetricsProvider(std::shared_ptr<BackgroundContainer> container) {
30 SwapContainer(container);
31}
32
33template<container::settings::IntegrationMode TIntegrationMode>
34void CoreMetricsProvider<TIntegrationMode>::SwapContainer(std::shared_ptr<BackgroundContainer> new_container) {
35 this->container.reset();
36 this->container = std::move(new_container);
37 if (this->container == nullptr) {
38 this->Finish(grpc::Status(
39 grpc::StatusCode::FAILED_PRECONDITION,
40 "Physiology Preprocessing is not running, unable to get metrics."
41 ));
42 }
43 auto status = this->container->SetOnCoreMetricsOutput(
44 [this](const presage::physiology::MetricsBuffer& metrics_output, int64_t /*time_stamp*/) {
45 this->EnqueueWrite(metrics_output);
46 return absl::OkStatus();
47 }
48 );
49 if (!status.ok()) {
50 this->Finish(rpc::abslStatusToGrpc(status));
51 }
52}
53
54} // namespace presage::smartspectra::grpc_bindings