53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
/*
|
|
* VizionStreamer - Streaming Engine Interface
|
|
* Copyright (c) 2025 Maik Jurischka
|
|
*
|
|
* Licensed under CC BY-NC-SA 4.0
|
|
* https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <vizionsdk/VizionSDK.h>
|
|
#include "vizionstreamer/GStreamerPipeline.h"
|
|
#include "vizionstreamer/SharedMemoryWriter.h"
|
|
#include <memory>
|
|
#include <thread>
|
|
#include <atomic>
|
|
#include <mutex>
|
|
|
|
class StreamingEngine {
|
|
public:
|
|
explicit StreamingEngine(std::shared_ptr<VxCamera> camera);
|
|
~StreamingEngine();
|
|
|
|
bool start(const std::string& gstPipeline);
|
|
void stop();
|
|
[[nodiscard]] bool isRunning() const { return running_; }
|
|
|
|
void setFormat(const VxFormat& format);
|
|
[[nodiscard]] VxFormat getCurrentFormat() const { return currentFormat_; }
|
|
|
|
void setPipelineDescription(const std::string& pipeline);
|
|
|
|
// Shared memory output control
|
|
bool enableSharedMemory(const std::string& name, size_t buffer_size);
|
|
void disableSharedMemory();
|
|
[[nodiscard]] bool isSharedMemoryEnabled() const { return shmWriter_ != nullptr && shmWriter_->isCreated(); }
|
|
[[nodiscard]] std::string getSharedMemoryName() const { return shmWriter_ ? shmWriter_->getName() : ""; }
|
|
[[nodiscard]] size_t getSharedMemorySize() const { return shmWriter_ ? shmWriter_->getBufferSize() : 0; }
|
|
|
|
private:
|
|
void acquisitionLoop();
|
|
|
|
std::shared_ptr<VxCamera> camera_;
|
|
std::unique_ptr<GStreamerPipeline> gstPipeline_;
|
|
std::unique_ptr<SharedMemoryWriter> shmWriter_;
|
|
std::unique_ptr<std::thread> acquisitionThread_;
|
|
std::atomic<bool> running_;
|
|
std::mutex mutex_;
|
|
VxFormat currentFormat_;
|
|
std::unique_ptr<uint8_t[]> buffer_;
|
|
size_t bufferSize_;
|
|
};
|