re-organize folder structure
This commit is contained in:
61
include/vizionstreamer/CameraController.h
Normal file
61
include/vizionstreamer/CameraController.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* VizionStreamer - Camera Control 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/StreamingEngine.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
|
||||
class CameraController {
|
||||
public:
|
||||
explicit CameraController(std::shared_ptr<VxCamera> camera);
|
||||
|
||||
// Process JSON command and return JSON response
|
||||
std::string processCommand(const std::string& jsonCommand);
|
||||
|
||||
// Get streaming engine for external control
|
||||
std::shared_ptr<StreamingEngine> getStreamingEngine() { return streamingEngine_; }
|
||||
|
||||
private:
|
||||
// Command handlers
|
||||
std::string handleSetFormat(const std::string& width, const std::string& height,
|
||||
const std::string& framerate, const std::string& format);
|
||||
std::string handleGetFormats();
|
||||
std::string handleSetExposure(const std::string& mode, const std::string& value);
|
||||
std::string handleSetWhiteBalance(const std::string& mode, const std::string& temperature);
|
||||
std::string handleSetBrightness(const std::string& value);
|
||||
std::string handleSetContrast(const std::string& value);
|
||||
std::string handleSetSaturation(const std::string& value);
|
||||
std::string handleSetSharpness(const std::string& value);
|
||||
std::string handleSetGamma(const std::string& value);
|
||||
std::string handleSetGain(const std::string& value);
|
||||
std::string handleGetStatus();
|
||||
std::string handleStartStream();
|
||||
std::string handleStopStream();
|
||||
std::string handleSetPipeline(const std::string& pipeline);
|
||||
std::string handleSetEHDRMode(const std::string& value);
|
||||
std::string handleSetEHDRExposureMin(const std::string& value);
|
||||
std::string handleSetEHDRExposureMax(const std::string& value);
|
||||
std::string handleSetEHDRRatioMin(const std::string& value);
|
||||
std::string handleSetEHDRRatioMax(const std::string& value);
|
||||
std::string handleGetEHDRStatus();
|
||||
|
||||
// Helper functions
|
||||
VX_IMAGE_FORMAT stringToFormat(const std::string& format);
|
||||
std::string formatToString(VX_IMAGE_FORMAT format);
|
||||
std::string createErrorResponse(const std::string& error);
|
||||
std::string createSuccessResponse(const std::string& message = "");
|
||||
|
||||
std::shared_ptr<VxCamera> camera_;
|
||||
std::shared_ptr<StreamingEngine> streamingEngine_;
|
||||
std::mutex mutex_;
|
||||
std::string gstPipeline_;
|
||||
};
|
||||
40
include/vizionstreamer/GStreamerPipeline.h
Normal file
40
include/vizionstreamer/GStreamerPipeline.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* VizionStreamer - GStreamer Pipeline 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 <gst/gst.h>
|
||||
#include <gst/app/gstappsrc.h>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class GStreamerPipeline {
|
||||
public:
|
||||
explicit GStreamerPipeline(std::string pipelineDescription);
|
||||
~GStreamerPipeline();
|
||||
|
||||
bool start();
|
||||
void stop();
|
||||
bool pushBuffer(const uint8_t* data, size_t size, int width, int height, const std::string& format);
|
||||
bool isRunning() const { return running_; }
|
||||
|
||||
void setPipelineDescription(const std::string& description);
|
||||
|
||||
private:
|
||||
static void onNeedData(GstAppSrc* appsrc, guint unused, gpointer user_data);
|
||||
static void onEnoughData(GstAppSrc* appsrc, gpointer user_data);
|
||||
|
||||
GstElement* pipeline_;
|
||||
GstElement* appsrc_;
|
||||
GstBus* bus_;
|
||||
bool running_;
|
||||
std::string pipelineDescription_;
|
||||
int width_;
|
||||
int height_;
|
||||
std::string format_;
|
||||
};
|
||||
37
include/vizionstreamer/SocketServer.h
Normal file
37
include/vizionstreamer/SocketServer.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* VizionStreamer - Unix Socket Server 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 <string>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
class SocketServer {
|
||||
public:
|
||||
using CommandCallback = std::function<std::string(const std::string&)>;
|
||||
|
||||
explicit SocketServer(const std::string& socketPath);
|
||||
~SocketServer();
|
||||
|
||||
bool start(CommandCallback callback);
|
||||
void stop();
|
||||
bool isRunning() const { return running_; }
|
||||
|
||||
private:
|
||||
void serverLoop();
|
||||
void handleClient(int clientFd);
|
||||
|
||||
std::string socketPath_;
|
||||
int serverFd_;
|
||||
std::atomic<bool> running_;
|
||||
std::unique_ptr<std::thread> serverThread_;
|
||||
CommandCallback commandCallback_;
|
||||
};
|
||||
43
include/vizionstreamer/StreamingEngine.h
Normal file
43
include/vizionstreamer/StreamingEngine.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 <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);
|
||||
|
||||
private:
|
||||
void acquisitionLoop();
|
||||
|
||||
std::shared_ptr<VxCamera> camera_;
|
||||
std::unique_ptr<GStreamerPipeline> gstPipeline_;
|
||||
std::unique_ptr<std::thread> acquisitionThread_;
|
||||
std::atomic<bool> running_;
|
||||
std::mutex mutex_;
|
||||
VxFormat currentFormat_;
|
||||
std::unique_ptr<uint8_t[]> buffer_;
|
||||
size_t bufferSize_;
|
||||
};
|
||||
Reference in New Issue
Block a user