mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-24 07:22:04 +08:00
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>
This commit is contained in:
+25
-13
@@ -1,3 +1,5 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "system/loggerd/loggerd.h"
|
||||
|
||||
#ifdef QCOM2
|
||||
@@ -59,15 +61,10 @@ 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 (const auto &encoder_info : cam_info.encoder_infos) {
|
||||
encoders.push_back(new Encoder(encoder_info, buf_info.width, buf_info.height));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,12 +124,27 @@ void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) {
|
||||
void encoderd_thread() {
|
||||
EncoderdState s;
|
||||
|
||||
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++;
|
||||
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 (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();
|
||||
}
|
||||
for (auto &t : encoder_threads) t.join();
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
Reference in New Issue
Block a user