encoderd: get avaiable streams from vipc server (#28935)

* get avaiable streams

* use std::thread

* assert buf size

* Update system/loggerd/encoderd.cc

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
pull/28966/head
Dean Lee 2 years ago committed by GitHub
parent 713d2ec586
commit cbed057789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      system/loggerd/encoderd.cc

@ -1,3 +1,5 @@
#include <cassert>
#include "system/loggerd/loggerd.h"
#ifdef QCOM2
@ -59,16 +61,11 @@ void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) {
if (encoders.empty()) {
VisionBuf buf_info = vipc_client.buffers[0];
LOGW("encoder %s init %dx%d", cam_info.thread_name, buf_info.width, buf_info.height);
assert(buf_info.width > 0 && buf_info.height > 0);
if (buf_info.width > 0 && buf_info.height > 0) {
for (const auto &encoder_info : cam_info.encoder_infos) {
encoders.push_back(new Encoder(encoder_info, buf_info.width, buf_info.height));
}
} else {
LOGE("not initting empty encoder");
s->max_waiting--;
break;
}
}
for (int i = 0; i < encoders.size(); ++i) {
@ -127,13 +124,28 @@ void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) {
void encoderd_thread() {
EncoderdState s;
std::set<VisionStreamType> streams;
while (!do_exit) {
streams = VisionIpcClient::getAvailableStreams("camerad", false);
if (!streams.empty()) {
break;
}
util::sleep_for(100);
}
if (!streams.empty()) {
std::vector<std::thread> encoder_threads;
for (const auto &cam : cameras_logged) {
encoder_threads.push_back(std::thread(encoder_thread, &s, cam));
s.max_waiting++;
for (auto stream : streams) {
auto it = std::find_if(std::begin(cameras_logged), std::end(cameras_logged),
[stream](auto &cam) { return cam.stream_type == stream; });
assert(it != std::end(cameras_logged));
++s.max_waiting;
encoder_threads.push_back(std::thread(encoder_thread, &s, *it));
}
for (auto &t : encoder_threads) t.join();
}
}
int main() {
if (!Hardware::PC()) {

Loading…
Cancel
Save