-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcamera_manager.cpp
More file actions
53 lines (42 loc) · 1.19 KB
/
Copy pathcamera_manager.cpp
File metadata and controls
53 lines (42 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "core.hpp"
#include "libcamera-rs/src/bridge.rs.h"
#include <bits/stdc++.h>
BindCameraManager make_camera_manager() {
BindCameraManager manager{
.inner = std::make_unique<CameraManager>(
std::make_unique<libcamera::CameraManager>()),
};
return manager;
}
void CameraManager::start() {
VALIDATE_POINTERS()
int ret = this->inner->start();
if (ret < 0) {
throw error_from_code(-ret);
}
}
void CameraManager::stop() {
VALIDATE_POINTERS()
this->inner->stop();
}
rust::Vec<rust::String> CameraManager::get_camera_ids() const {
VALIDATE_POINTERS()
rust::Vec<rust::String> camera_ids;
for (std::shared_ptr<libcamera::Camera> cam : this->inner->cameras()) {
camera_ids.push_back(cam->id());
}
return camera_ids;
}
BindCamera CameraManager::get_camera_by_id(rust::Str rust_id) {
VALIDATE_POINTERS()
std::string cam_id = std::string(rust_id);
std::shared_ptr<libcamera::Camera> cam = this->inner->get(cam_id);
// C++ header mismatch will cause this to be completely silly
if (!cam || cam.use_count() > INT_MAX) {
throw error_from_code(ENODEV);
}
BindCamera bind_cam{
.inner = std::make_unique<Camera>(cam),
};
return bind_cam;
}