[commabody] setup and run live stream encoders (#29087)

* op changes needed for body

* remove logmessaged callback

* add newlines

* add stream arg

* add stream_encoder to config

* supersets, avoid two encoderd

* fix recursive exit error

* fix loggerd crash

* add stream_encoderd cpu usage to test

* Update system/loggerd/loggerd.h

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* resolve comments

* stream_encoderd onroad to false

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
Vivek Aithal
2023-08-11 15:34:25 -07:00
committed by GitHub
parent 62c1e65924
commit 81322a4805
4 changed files with 76 additions and 13 deletions
+16 -6
View File
@@ -121,7 +121,8 @@ void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) {
}
}
void encoderd_thread() {
template <size_t N>
void encoderd_thread(const LogCameraInfo (&cameras)[N]) {
EncoderdState s;
std::set<VisionStreamType> streams;
@@ -136,9 +137,9 @@ void encoderd_thread() {
if (!streams.empty()) {
std::vector<std::thread> encoder_threads;
for (auto stream : streams) {
auto it = std::find_if(std::begin(cameras_logged), std::end(cameras_logged),
auto it = std::find_if(std::begin(cameras), std::end(cameras),
[stream](auto &cam) { return cam.stream_type == stream; });
assert(it != std::end(cameras_logged));
assert(it != std::end(cameras));
++s.max_waiting;
encoder_threads.push_back(std::thread(encoder_thread, &s, *it));
}
@@ -147,7 +148,7 @@ void encoderd_thread() {
}
}
int main() {
int main(int argc, char* argv[]) {
if (!Hardware::PC()) {
int ret;
ret = util::set_realtime_priority(52);
@@ -155,6 +156,15 @@ int main() {
ret = util::set_core_affinity({3});
assert(ret == 0);
}
encoderd_thread();
return 0;
if (argc > 1) {
std::string arg1(argv[1]);
if (arg1 == "--stream") {
encoderd_thread(stream_cameras_logged);
} else {
LOGE("Argument '%s' is not supported", arg1.c_str());
}
} else {
encoderd_thread(cameras_logged);
}
return 0;
}