add SharedMemoryWriter support - without gstreamer

This commit is contained in:
Maik Jurischka
2026-01-29 12:27:37 +01:00
parent cd290bdd07
commit cc97528eca
2 changed files with 122 additions and 20 deletions

View File

@@ -35,8 +35,14 @@ bool StreamingEngine::start(const std::string& gstPipeline) {
return false;
}
// Set pipeline description
gstPipeline_->setPipelineDescription(gstPipeline);
// Check if at least one output is configured
const bool useGStreamer = !gstPipeline.empty();
const bool useSharedMemory = (shmWriter_ && shmWriter_->isCreated());
if (!useGStreamer && !useSharedMemory) {
std::cerr << "No output configured. Enable GStreamer pipeline or shared memory first." << std::endl;
return false;
}
// Start camera streaming
if (VxStartStreaming(camera_) != 0) {
@@ -58,11 +64,17 @@ bool StreamingEngine::start(const std::string& gstPipeline) {
bufferSize_ = calculatedBufferSize;
buffer_ = std::make_unique<uint8_t[]>(bufferSize_);
// Start GStreamer pipeline
if (!gstPipeline_->start()) {
std::cerr << "Failed to start GStreamer pipeline" << std::endl;
VxStopStreaming(camera_);
return false;
// Start GStreamer pipeline if configured
if (useGStreamer) {
gstPipeline_->setPipelineDescription(gstPipeline);
if (!gstPipeline_->start()) {
std::cerr << "Failed to start GStreamer pipeline" << std::endl;
VxStopStreaming(camera_);
return false;
}
std::cout << "GStreamer pipeline started" << std::endl;
} else {
std::cout << "GStreamer pipeline disabled (using shared memory only)" << std::endl;
}
// Start acquisition thread
@@ -85,8 +97,10 @@ void StreamingEngine::stop() {
acquisitionThread_->join();
}
// Stop GStreamer pipeline
gstPipeline_->stop();
// Stop GStreamer pipeline if running
if (gstPipeline_->isRunning()) {
gstPipeline_->stop();
}
// Stop camera streaming
VxStopStreaming(camera_);
@@ -131,11 +145,13 @@ void StreamingEngine::acquisitionLoop() {
default: formatStr = "UNKNOWN"; break;
}
// Push frame to GStreamer pipeline
if (!gstPipeline_->pushBuffer(buffer_.get(), dataSize,
currentFormat_.width, currentFormat_.height,
formatStr)) {
std::cerr << "Failed to push frame to GStreamer pipeline" << std::endl;
// Push frame to GStreamer pipeline if active
if (gstPipeline_->isRunning()) {
if (!gstPipeline_->pushBuffer(buffer_.get(), dataSize,
currentFormat_.width, currentFormat_.height,
formatStr)) {
std::cerr << "Failed to push frame to GStreamer pipeline" << std::endl;
}
}
// Push frame to shared memory if enabled