1 - include/AclLog.h
include/AclLog.h
Namespaces
Name |
---|
AclLog A namespace for logging utilities. |
Classes
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <filesystem>
#include <string>
#include <spdlog/details/log_msg.h>
#include <spdlog/fmt/fmt.h>
#include <spdlog/formatter.h>
#include <spdlog/pattern_formatter.h>
#include <sys/prctl.h>
namespace AclLog {
enum class Level {
kTrace, // Detailed diagnostics (for development only)
kDebug, // Messages intended for debugging only
kInfo, // Messages about normal behavior (default log level)
kWarning, // Warnings (functionality intact)
kError, // Recoverable errors (functionality impaired)
kCritical, // Unrecoverable errors (application must stop)
kOff // Turns off all logging
};
void init(const std::string& name);
void initCommandLog(const std::string& name);
void setLevel(Level level);
void logCommand(const std::string& origin, const std::string& command);
AclLog::Level getLogLevel();
size_t getMaxFileSize();
size_t getMaxLogRotations();
std::filesystem::path getLogFileFullPath(const std::string& name);
class CommandLogFormatter : public spdlog::formatter {
public:
CommandLogFormatter();
void format(const spdlog::details::log_msg& msg, spdlog::memory_buf_t& dest) override;
[[nodiscard]] std::unique_ptr<spdlog::formatter> clone() const override;
private:
std::unique_ptr<spdlog::pattern_formatter> mCommandLogPattern;
};
inline std::string getThreadName() {
static const size_t RECOMMENDED_BUFFER_SIZE = 20;
static thread_local std::string name;
if (name.empty()) {
char buffer[RECOMMENDED_BUFFER_SIZE];
int retval = prctl(PR_GET_NAME, buffer);
if (retval == -1) {
throw spdlog::spdlog_ex("Failed to get thread name: ", errno);
}
name = std::string(buffer);
}
return name;
}
class ThreadNameFormatterFlag : public spdlog::custom_flag_formatter {
public:
void format(const spdlog::details::log_msg&, const std::tm&, spdlog::memory_buf_t& dest) override {
std::string threadName = getThreadName();
dest.append(threadName.data(), threadName.data() + threadName.size());
}
[[nodiscard]] std::unique_ptr<custom_flag_formatter> clone() const override {
return spdlog::details::make_unique<ThreadNameFormatterFlag>();
}
};
class FileLocationFormatterFlag : public spdlog::custom_flag_formatter {
public:
void format(const spdlog::details::log_msg& msg, const std::tm&, spdlog::memory_buf_t& dest) override {
if (!msg.source.empty()) {
using namespace spdlog::details;
dest.push_back('[');
const char* filename = short_filename_formatter<null_scoped_padder>::basename(msg.source.filename);
fmt_helper::append_string_view(filename, dest);
dest.push_back(':');
fmt_helper::append_int(msg.source.line, dest);
dest.push_back(']');
}
}
[[nodiscard]] std::unique_ptr<custom_flag_formatter> clone() const override {
return spdlog::details::make_unique<FileLocationFormatterFlag>();
}
};
} // namespace AclLog
Updated on 2024-04-08 at 15:15:27 +0200
2 - include/AlignedFrame.h
include/AlignedFrame.h
Classes
| Name |
---|
struct | AlignedAudioFrame AlignedAudioFrame is a frame of interleaved floating point audio samples with a given number of channels. |
struct | AlignedFrame A frame of aligned data that is passed to the rendering engine from the MediaReceiver. A DataFrame contains a time stamped frame of media, which might be video, audio and auxiliary data such as subtitles. A single DataFrame can contain one or multiple types of media. Which media types are included can be probed by nullptr-checking/size checking the data members. The struct has ownership of all data pointers included. The struct includes all logic for freeing the resources held by this struct and the user should therefore just make sure the struct itself is deallocated to ensure all resources are freed. |
Types
Functions
| Name |
---|
AlignedAudioFramePtr | createAlignedAudioFrame(uint8_t numberOfChannels, uint32_t numberOfSamplesPerChannel) Create a new AudioFrame with a given amount of samples allocated and all samples initialized to 0.0f. |
AlignedAudioFramePtr | extractChannel(AlignedAudioFrameConstPtr sourceFrame, uint8_t channelIndex) Extract one channel from an AlignedAudioFrame as a new AlignedAudioFrame. The new AlignedAudioFrame will share no data with the original frame, meaning the new frame can be edited without corrupting the old one. |
Types Documentation
using AlignedAudioFramePtr
using AlignedAudioFramePtr = std::shared_ptr<AlignedAudioFrame>;
using AlignedAudioFrameConstPtr
using AlignedAudioFrameConstPtr = std::shared_ptr<const AlignedAudioFrame>;
using AlignedFramePtr
using AlignedFramePtr = std::shared_ptr<AlignedFrame>;
Functions Documentation
function createAlignedAudioFrame
AlignedAudioFramePtr createAlignedAudioFrame(
uint8_t numberOfChannels,
uint32_t numberOfSamplesPerChannel
)
Create a new AudioFrame with a given amount of samples allocated and all samples initialized to 0.0f.
Parameters:
- numberOfChannels Number of channels to allocate space for
- numberOfSamplesPerChannel Number of samples per channel to allocate space for
Return: Shared pointer to the new AudioFrame
AlignedAudioFramePtr extractChannel(
AlignedAudioFrameConstPtr sourceFrame,
uint8_t channelIndex
)
Extract one channel from an AlignedAudioFrame as a new AlignedAudioFrame. The new AlignedAudioFrame will share no data with the original frame, meaning the new frame can be edited without corrupting the old one.
Parameters:
- sourceFrame The frame to extract a channel from
- channelIndex The zero-based channel index to extract
Return: Shared pointer to a new mono AlignedAudioFrame, or nullptr if channel is out of bounds
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <array>
#include <iostream>
#include <memory>
#include <vector>
#include <cuda_runtime_api.h>
#include "DeviceMemory.h"
#include "PixelFormat.h"
struct AlignedAudioFrame {
// The samples interleaved
std::vector<float> mSamples;
uint8_t mNumberOfChannels = 0;
uint32_t mNumberOfSamplesPerChannel = 0;
};
using AlignedAudioFramePtr = std::shared_ptr<AlignedAudioFrame>;
using AlignedAudioFrameConstPtr = std::shared_ptr<const AlignedAudioFrame>;
AlignedAudioFramePtr createAlignedAudioFrame(uint8_t numberOfChannels, uint32_t numberOfSamplesPerChannel);
AlignedAudioFramePtr extractChannel(AlignedAudioFrameConstPtr sourceFrame, uint8_t channelIndex);
struct AlignedFrame {
AlignedFrame() = default;
~AlignedFrame() = default;
AlignedFrame(AlignedFrame const&) = delete; // Copy construct
AlignedFrame& operator=(AlignedFrame const&) = delete; // Copy assign
[[nodiscard]] std::shared_ptr<AlignedFrame> makeShallowCopy() const;
int64_t mCaptureTimestamp = 0;
int64_t mRenderingTimestamp = 0;
// Video
std::shared_ptr<DeviceMemory> mVideoFrame = nullptr;
PixelFormat mPixelFormat = PixelFormat::kUnknown;
uint32_t mFrameRateN = 0;
uint32_t mFrameRateD = 0;
uint32_t mWidth = 0;
uint32_t mHeight = 0;
// Audio
AlignedAudioFramePtr mAudioFrame = nullptr;
uint32_t mAudioSamplingFrequency = 0;
};
using AlignedFramePtr = std::shared_ptr<AlignedFrame>;
Updated on 2024-04-08 at 15:15:27 +0200
3 - include/Base64.h
include/Base64.h
Functions
| Name |
---|
std::string | encodeBase64(const uint8_t * data, size_t size) Base64 encode some data. |
std::string | encodeBase64(const std::vector< uint8_t > & data) Base64 encode some data. |
std::vector< uint8_t > | decodeBase64(const std::string & data) Decode some Base64 encoded data. |
Functions Documentation
function encodeBase64
std::string encodeBase64(
const uint8_t * data,
size_t size
)
Base64 encode some data.
Parameters:
- data Pointer to the data to encode with Base64
- size The length of the data to encode with Base64
Return: The resulting Base64 encoded string
function encodeBase64
std::string encodeBase64(
const std::vector< uint8_t > & data
)
Base64 encode some data.
Parameters:
- data The data to encode with Base64
Return: The resulting Base64 encoded string
function decodeBase64
std::vector< uint8_t > decodeBase64(
const std::string & data
)
Decode some Base64 encoded data.
Parameters:
- data The Base64 encoded string to decode
Return: The resulting decoded data
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <string>
#include <vector>
std::string encodeBase64(const uint8_t* data, size_t size);
std::string encodeBase64(const std::vector<uint8_t>& data);
std::vector<uint8_t> decodeBase64(const std::string& data);
Updated on 2024-04-08 at 15:15:27 +0200
4 - include/ControlDataCommon.h
include/ControlDataCommon.h
Namespaces
Classes
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace ControlDataCommon {
enum class ConnectionType { CONNECTED, DISCONNECTED };
struct ConnectionStatus {
ConnectionStatus() = default;
ConnectionStatus(ConnectionType mConnectionType, const std::string& mIp, uint16_t mPort)
: mConnectionType(mConnectionType)
, mIP(mIp)
, mPort(mPort) {
}
ConnectionType mConnectionType = ConnectionType::DISCONNECTED;
std::string mIP;
uint16_t mPort = 0;
};
struct Response {
std::vector<uint8_t> mMessage;
uint64_t mRequestId = 0;
std::string mFromUUID;
};
struct StatusMessage {
std::vector<uint8_t> mMessage;
std::string mFromUUID;
};
} // namespace ControlDataCommon
Updated on 2024-04-08 at 15:15:27 +0200
5 - include/ControlDataSender.h
include/ControlDataSender.h
Classes
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <functional>
#include <memory>
#include <vector>
#include <ISystemControllerInterface.h>
#include "ControlDataCommon.h"
class ControlDataSender final {
public:
struct Settings {
std::function<void(const ControlDataCommon::ConnectionStatus&)>
mConnectionStatusCallback; // Callback for receiver connection/disconnection events
std::function<void(const ControlDataCommon::Response&)>
mResponseCallback; // Callback for response messages from receivers
std::function<void(const ControlDataCommon::StatusMessage&)>
mStatusMessageCallback; // Callback for status messages from receivers
};
ControlDataSender();
~ControlDataSender();
bool configure(const std::shared_ptr<ISystemControllerInterface>& controllerInterface, const Settings& settings);
bool sendRequestToReceivers(const std::vector<uint8_t>& request, uint64_t& requestId);
bool sendMultiRequestToReceivers(const std::vector<std::vector<uint8_t>>& request, uint64_t& requestId);
static std::string getVersion();
// ControlDataSender is not copyable
ControlDataSender(ControlDataSender const&) = delete; // Copy construct
ControlDataSender& operator=(ControlDataSender const&) = delete; // Copy assign
private:
class Impl;
std::unique_ptr<Impl> pImpl;
};
Updated on 2024-04-08 at 15:15:27 +0200
6 - include/DeviceMemory.h
include/DeviceMemory.h
Classes
Types
Types Documentation
using DeviceMemoryPtr
using DeviceMemoryPtr = std::shared_ptr<DeviceMemory>;
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <cstddef>
#include <cstdint>
#include <memory>
#include <cuda_runtime.h>
class DeviceMemory {
public:
DeviceMemory() = default;
explicit DeviceMemory(size_t numberOfBytes);
explicit DeviceMemory(size_t numberOfBytes, cudaStream_t cudaStream);
explicit DeviceMemory(void* deviceMemory) noexcept;
bool allocateMemory(size_t numberOfBytes);
bool allocateMemoryAsync(size_t numberOfBytes, cudaStream_t cudaStream);
bool reallocateMemory(size_t numberOfBytes);
bool reallocateMemoryAsync(size_t numberOfBytes, cudaStream_t cudaStream);
bool allocateAndResetMemory(size_t numberOfBytes);
bool allocateAndResetMemoryAsync(size_t numberOfBytes, cudaStream_t cudaStream);
bool freeMemory();
bool freeMemoryAsync(cudaStream_t cudaStream);
void setFreeingCudaStream(cudaStream_t cudaStream);
~DeviceMemory();
template <typename T = uint8_t> [[nodiscard]] T* getDevicePointer() const {
return reinterpret_cast<T*>(dMemory);
}
[[nodiscard]] size_t getSize() const;
DeviceMemory(DeviceMemory&& other) noexcept;
DeviceMemory& operator=(DeviceMemory&& other) noexcept;
void swap(DeviceMemory& other) noexcept;
DeviceMemory(DeviceMemory const&) = delete;
DeviceMemory operator=(DeviceMemory const&) = delete;
private:
uint8_t* dMemory = nullptr;
size_t mAllocatedBytes = 0;
cudaStream_t mCudaStream = nullptr; // Stream to use for Async free
};
using DeviceMemoryPtr = std::shared_ptr<DeviceMemory>;
Updated on 2024-04-08 at 15:15:27 +0200
7 - include/IControlDataReceiver.h
include/IControlDataReceiver.h
Classes
| Name |
---|
class | IControlDataReceiver IControlDataReceiver is the interface class for the control data receiver. An IControlDataReceiver can receive messages from a sender or other IControlDataReceivers using a network connection. It can also connect to and forward the incoming request messages to other receivers. The connections to the sender and the other receivers are controlled by an ISystemControllerInterface instance. The ControlDataReceiver has a receiving or listening side, as well as a sending side. The listening side can listen to one single network port and have multiple ControlDataSenders and ControlDataReceivers connected to that port to receive requests from them. On the sending side of the ControlDataReceiver, it can be connected to the listening side of other ControlDataReceivers, used to forward all incoming messages to that receiver, as well as sending its own requests. |
struct | IControlDataReceiver::IncomingRequest An incoming request to this ControlDataReceiver. |
struct | IControlDataReceiver::ReceiverResponse A response message to a request. |
struct | IControlDataReceiver::Settings Settings for a ControlDataReceiver. |
Source code
// Copyright (c) 2024, Edgeware AB. All rights reserved.
#pragma once
#include <memory>
#include <ISystemControllerInterface.h>
#include "ControlDataCommon.h"
class IControlDataReceiver {
public:
struct IncomingRequest {
std::vector<std::vector<uint8_t>> mMessages;
std::string mSenderUUID;
std::string mRequesterUUID;
uint64_t mRequestID = 0;
int64_t mSenderTimestampUs =
0;
int64_t mDeliveryTimestampUs =
0;
};
struct ReceiverResponse {
std::vector<uint8_t> mMessage;
};
struct Settings {
std::string mProductionPipelineUUID;
std::function<void(const IncomingRequest&)> mPreviewIncomingRequestCallback;
std::function<ReceiverResponse(const IncomingRequest&)> mIncomingRequestCallback;
std::function<void(const ControlDataCommon::ConnectionStatus&)>
mConnectionStatusCallback;
std::function<void(const ControlDataCommon::Response&)>
mResponseCallback;
};
virtual ~IControlDataReceiver() = default;
virtual bool configure(const Settings& settings) = 0;
virtual bool sendStatusMessageToSender(const std::vector<uint8_t>& message) = 0;
virtual bool sendRequestToReceivers(const std::vector<uint8_t>& request, uint64_t& requestId) = 0;
virtual bool sendMultiRequestToReceivers(const std::vector<std::vector<uint8_t>>& request, uint64_t& requestId) = 0;
};
Updated on 2024-04-08 at 15:15:27 +0200
8 - include/IMediaStreamer.h
Classes
| Name |
---|
class | IMediaStreamer IMediaStreamer is an interface class for MediaStreamers, that can take a single stream of uncompressed video and/or audio frames and encode and output it in some way. This output can either be a stream to a network or writing down the data to a file on the hard drive. This class is configured from two interfaces. The input configuration (input video resolution, frame rate, pixel format, number of audio channels…) is made through this C++ API. The output stream is then started from the System Controller. Any of these configurations can be made first. The actual stream to output will start once the first call to. |
struct | IMediaStreamer::Settings Settings used when creating a new MediaStreamer. |
struct | IMediaStreamer::Configuration The input configuration of the frames that will be sent to this MediaStreamer. The output stream configuration is made from the System controller via the ISystemControllerInterface. |
Source code
// Copyright (c) 2024, Edgeware AB. All rights reserved.
#pragma once
#include <memory>
#include <ISystemControllerInterface.h>
#include <cuda.h>
#include "AlignedFrame.h"
class IMediaStreamer {
public:
struct Settings {
std::string mName; // Human-readable name, presented in the REST API
};
struct Configuration {
// Video
PixelFormat mIncomingPixelFormat = PixelFormat::kUnknown;
uint32_t mWidth = 0; // Width of the incoming video frames in pixels
uint32_t mHeight = 0; // Height of the incoming video frames in pixels
uint32_t mFrameRateN = 0; // Frame rate numerator of the incoming video frames
uint32_t mFrameRateD = 0; // Frame rate denominator of the incoming video frames
// Audio
uint32_t mAudioSampleRate = 0; // Audio sample rate of the incoming frames in Hz
uint32_t mNumAudioChannels = 0; // Number of audio channels in the incoming frames
};
virtual ~IMediaStreamer() = default;
virtual bool configure(const std::string& uuid, const Settings& settings, CUcontext cudaContext) = 0;
virtual bool setInputFormatAndStart(const Configuration& configuration) = 0;
virtual bool stopAndResetFormat() = 0;
[[nodiscard]] virtual bool hasFormatAndIsRunning() const = 0;
[[nodiscard]] virtual bool hasOpenOutputStream() const = 0;
virtual bool outputData(const AlignedFramePtr& frame) = 0;
};
Updated on 2024-04-08 at 15:15:27 +0200
9 - include/IngestApplication.h
include/IngestApplication.h
Classes
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <memory>
#include "ISystemControllerInterface.h"
class IngestApplication {
public:
struct Settings {};
IngestApplication();
~IngestApplication();
bool start(const std::shared_ptr<ISystemControllerInterface>& controllerInterface, const Settings& settings);
bool stop();
static std::string getVersion();
static std::string getLibraryVersions();
private:
class Impl;
std::unique_ptr<Impl> pImpl;
};
Updated on 2024-04-08 at 15:15:27 +0200
10 - include/IngestUtils.h
include/IngestUtils.h
Namespaces
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
namespace IngestUtils {
bool isRunningWithRootPrivileges();
} // namespace IngestUtils
Updated on 2024-04-08 at 15:15:27 +0200
11 - include/ISystemControllerInterface.h
include/ISystemControllerInterface.h
Classes
| Name |
---|
class | ISystemControllerInterface An ISystemControllerInterface is the interface between a component and the System controller controlling the component. The interface allows for two-way communication between the component and the system controller by means of sending requests and getting responses. Classes deriving from the ISystemControllerInterface should provide the component side implementation of the communication with the system controller. This interface can be inherited and implemented by developers to connect to custom system controllers, or to directly control a component programmatically, without the need for connecting to a remote server. |
struct | ISystemControllerInterface::Response A response to a request, consists of a status code and an (optional) parameters JSON object. |
struct | ISystemControllerInterface::Callbacks A struct containing the callbacks that needs to be registered by the component using this interface. |
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <functional>
#include <json.hpp>
#include <optional>
#include <string>
class ISystemControllerInterface {
public:
enum class StatusCode : uint32_t {
SUCCESS = 3001, // Accept / Success
TOO_MANY_REQUESTS = 3101, // Too many requests, try again later
UUID_ALREADY_REGISTERED = 3201, // UUID is already registered
FORMAT_ERROR = 3202, // Message formatting error
ALREADY_CONFIGURED = 3203, // The requested thing to configure is already configured
OUT_OF_RESOURCES = 3204, // Out of resources (CPU/GPU close to max utilization, all available slots used, etc.)
NOT_FOUND = 3205, // The requested thing was not found
INTERNAL_ERROR = 3206, // Internal error when trying to serve the request
CONNECTION_FAILED = 3207, // Connection failure
TIMEOUT_EXCEEDED = 3208, // Timeout exceeded
KEY_MISMATCH = 3209, // Key mismatch (might be a timeout, 3007 in the future)
UNKNOWN_REQUEST = 3210, // The name of the request was not known
MALFORMED_REQUEST = 3211, // The request is not correctly formatted
ALREADY_IN_USE = 3212, // The requested resource is already in use
VERSION_MISMATCH = 3213, // The version of the request is not supported
// None, yet
};
struct Response {
StatusCode mCode;
nlohmann::json mParameters; // Can be empty
};
struct Callbacks {
std::function<Response(const std::string&, const nlohmann::json&)>
mRequestCallback; // Callback called when then controller has sent a request
std::function<void(uint32_t, const std::string&, const std::error_code&)>
mConnectionClosedCallback; // Callback called when the connection to the controller is closed
};
virtual ~ISystemControllerInterface() = default;
virtual std::optional<std::string> sendMessage(const std::string& messageTitle,
const nlohmann::json& parameters) = 0;
virtual bool registerRequestCallback(const Callbacks& callbacks) = 0;
virtual bool connect() = 0;
virtual bool disconnect() = 0;
[[nodiscard]] virtual bool isConnected() const = 0;
[[nodiscard]] virtual std::string getUUID() const = 0;
};
Updated on 2024-04-08 at 15:15:27 +0200
12 - include/MediaReceiver.h
Classes
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <memory>
#include <utility>
#include <cuda.h>
#include "AlignedFrame.h"
#include "ControlDataReceiver.h"
#include "ISystemControllerInterface.h"
#include "MediaStreamer.h"
class MediaReceiver {
public:
struct NewStreamParameters {
uint32_t mVideoHeight = 0; // Height of the video in pixels. 0 if the stream does not contain any video
uint32_t mVideoWidth = 0; // Width of the video in pixels. 0 if the stream does not contain any video
uint32_t mFrameRateN = 0; // Frame rate numerator
uint32_t mFrameRateD = 1; // Frame rate denominator
uint32_t mAudioSampleRate = 0; // Sample rate of the audio in Hz. 0 if the stream does not contain any audio
};
struct Settings {
PixelFormat mDecodedFormat = PixelFormat::kRgba64Le;
std::function<std::function<void(const AlignedFramePtr&)>(uint32_t inputSlot,
const std::string& streamID,
const NewStreamParameters& newStreamParameters)>
mNewConnectionCallback;
std::function<void(uint32_t inputSlot)> mClosedConnectionCallback;
std::function<std::optional<std::string>()> mResetCallback;
bool mUseMultiViewer = false;
bool mDeliverOld = false;
CUstream mAlignedFrameFreeStream = nullptr;
};
enum class TallyBorderColor : uint32_t { kNone, kRed, kGreen, kYellow };
MediaReceiver();
~MediaReceiver();
bool start(const std::shared_ptr<ISystemControllerInterface>& controllerInterface,
CUcontext cudaContext,
const Settings& settings,
const ControlDataReceiver::Settings& receiverSettings);
void stop();
std::function<void(const AlignedFramePtr&)> getCustomMultiViewSourceInput(uint32_t inputSlot,
const std::string& name = "");
bool removeCustomMultiViewSourceInput(uint32_t inputSlot);
std::shared_ptr<IMediaStreamer> createMediaStreamerOutput(const MediaStreamer::Settings& settings);
bool removeMediaStreamerOutput(const std::string& uuid);
std::shared_ptr<IControlDataReceiver> getControlDataReceiver();
void setTallyBorder(uint32_t inputSlot, TallyBorderColor color);
void clearTallyBorder(uint32_t inputSlot);
void clearAllTallyBorders();
[[nodiscard]] MediaReceiver::TallyBorderColor getTallyBorder(uint32_t inputSlot) const;
MediaReceiver(MediaReceiver const&) = delete; // Copy construct
MediaReceiver(MediaReceiver&&) = delete; // Move construct
MediaReceiver& operator=(MediaReceiver const&) = delete; // Copy assign
MediaReceiver& operator=(MediaReceiver&&) = delete; // Move assign
static std::string getVersion();
static std::string getLibraryVersions();
private:
class Impl;
std::unique_ptr<Impl> pImpl;
};
Updated on 2024-04-08 at 15:15:27 +0200
13 - include/PixelFormat.h
Namespaces
Types
| Name |
---|
enum uint32_t | PixelFormat { kUnknown = 0, kNv12 = ACL::makeFourCC(‘N’, ‘V’, ‘1’, ‘2’), kUyvy = ACL::makeFourCC(‘U’, ‘Y’, ‘V’, ‘Y’), kP010 = ACL::makeFourCC(‘P’, ‘0’, ‘1’, ‘0’), kP016 = ACL::makeFourCC(‘P’, ‘0’, ‘1’, ‘6’), kP210 = ACL::makeFourCC(‘P’, ‘2’, ‘1’, ‘0’), kP216 = ACL::makeFourCC(‘P’, ‘2’, ‘1’, ‘6’), kRgba = |
ACL::makeFourCC(‘R’, ‘G’, ‘B’, ‘A’), kV210 = ACL::makeFourCC(‘V’, ‘2’, ‘1’, ‘0’), kRgba64Le = | |
ACL::makeFourCC(‘R’, ‘G’, ‘B’, 64)} Enumeration of FourCC formats. | |
Functions
| Name |
---|
std::ostream & | operator«(std::ostream & stream, PixelFormat pixelFormat) Add the string representation of a PixelFormat to the output stream. |
Types Documentation
Enumerator | Value | Description |
---|
kUnknown | 0 | |
kNv12 | ACL::makeFourCC(‘N’, ‘V’, ‘1’, ‘2’) | |
kUyvy | ACL::makeFourCC(‘U’, ‘Y’, ‘V’, ‘Y’) | |
kP010 | ACL::makeFourCC(‘P’, ‘0’, ‘1’, ‘0’) | |
kP016 | ACL::makeFourCC(‘P’, ‘0’, ‘1’, ‘6’) | |
kP210 | ACL::makeFourCC(‘P’, ‘2’, ‘1’, ‘0’) | |
kP216 | ACL::makeFourCC(‘P’, ‘2’, ‘1’, ‘6’) | |
kRgba | = | |
ACL::makeFourCC(‘R’, ‘G’, ‘B’, ‘A’) | | |
kV210 | ACL::makeFourCC(‘V’, ‘2’, ‘1’, ‘0’) | |
kRgba64Le | = | |
ACL::makeFourCC(‘R’, ‘G’, ‘B’, 64) | | |
Enumeration of FourCC formats.
Functions Documentation
function operator«
std::ostream & operator<<(
std::ostream & stream,
PixelFormat pixelFormat
)
Add the string representation of a PixelFormat to the output stream.
Parameters:
- pixelFormat The PixelFormat to get as a string
Return: The ostream with the string representation of the PixelFormat appended
Source code
// Copyright (c) 2023, Edgeware AB. All rights reserved.
#pragma once
#include <cstdint>
#include <ostream>
namespace ACL {
constexpr uint32_t makeFourCC(char a, char b, char c, char d) {
return static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8) + (static_cast<uint32_t>(c) << 16) +
(static_cast<uint32_t>(d) << 24);
}
} // namespace ACL
enum PixelFormat : uint32_t {
kUnknown = 0, // Unknown format
kNv12 = ACL::makeFourCC('N', 'V', '1', '2'), // 4:2:0 format with Y plane followed by UVUVUV.. plane
kUyvy = ACL::makeFourCC('U', 'Y', 'V', 'Y'), // 4:2:2 format with packed UYVY macropixels
kP010 = ACL::makeFourCC('P', '0', '1', '0'), // 4:2:0 P016 with data in the 10 MSB
kP016 = ACL::makeFourCC('P', '0', '1', '6'), // 4:2:0 format with 16 bit words, Y plane followed by UVUVUV.. plane
kP210 = ACL::makeFourCC('P', '2', '1', '0'), // 4:2:2 P216 with data in the 10 MSB
kP216 = ACL::makeFourCC('P', '2', '1', '6'), // 4:2:2 format with 16 bit words, Y plane followed by UVUVUV.. plane
kRgba =
ACL::makeFourCC('R', 'G', 'B', 'A'), // 4:4:4:4 RGB format, 8 bit per channel, ordered RGBARGBARG.. in memory
kV210 = ACL::makeFourCC('V', '2', '1', '0'), // 4:2:2 packed format with 10 bit per component
kRgba64Le =
ACL::makeFourCC('R', 'G', 'B', 64) // 16 bit per component, ordered as RGBA in memory with little endian words.
};
std::ostream& operator<<(std::ostream& stream, PixelFormat pixelFormat);
Updated on 2024-04-08 at 15:15:27 +0200
14 - include/SystemControllerConnection.h
include/SystemControllerConnection.h
Classes
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <chrono>
#include "ISystemControllerInterface.h"
#include "json.hpp"
class SystemControllerConnection final : public ISystemControllerInterface {
public:
enum class ComponentType : uint32_t {
kIngest,
kPipeline,
kControlPanel,
};
struct Settings {
std::string mSystemControllerIP; // IP of the server
uint16_t mSystemControllerPort; // Port of the server
std::string mSystemControllerPostfix; // Postfix of the address that the backend uses if any
std::string mPSK; // The pre shared key used for authorization with the system controller server
std::string mUUID; // The UUID of the device using this library
ComponentType mType; // The component type of the component using this SystemControllerConnection
std::string mName; // The component name (optional)
std::string mMyIP; // The external IP of the system the component is running on. Will be sent to the system
// controller server in the announce message (optional)
std::chrono::milliseconds mConnectTimeout{
3000}; // Max time to wait on an announcement response from the server during connection
bool mEnableHTTPS; // Enable the communication between the system controller and a component encrypted
bool mInsecureHTTPS; // Disable the verification of the TLS certificate if requested.
std::string mCustomCaCertFile; // Custom CA certificate
};
SystemControllerConnection();
~SystemControllerConnection() override;
bool configure(const Settings& settings);
bool connect() override;
[[nodiscard]] bool isConnected() const override;
[[nodiscard]] std::string getUUID() const override;
std::optional<std::string> sendMessage(const std::string& messageTitle, const nlohmann::json& parameters) override;
bool disconnect() override;
bool registerRequestCallback(const Callbacks& callbacks) override;
SystemControllerConnection(SystemControllerConnection const&) = delete; // Copy construct
SystemControllerConnection(SystemControllerConnection&&) = delete; // Move construct
SystemControllerConnection& operator=(SystemControllerConnection const&) = delete; // Copy assign
SystemControllerConnection& operator=(SystemControllerConnection&&) = delete; // Move assign
private:
class Impl;
std::unique_ptr<Impl> pImpl;
};
Updated on 2024-04-08 at 15:15:27 +0200
15 - include/TimeCommon.h
include/TimeCommon.h
Namespaces
Classes
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <chrono>
#include <cstdint>
#include <fstream>
#include <sstream>
#include "expected.hpp"
namespace TimeCommon {
enum class StratumLevel {
UnknownStratum,
stratum0,
stratum1,
stratum2,
stratum3,
stratum4,
};
struct TAIStatus {
StratumLevel mStratum = StratumLevel::UnknownStratum;
bool mHasLock = false;
double mTimeDiffS = 0.0; // Time diff vs NTP in seconds, +/- value means slow/faster than NTP time
};
// Little endian
// Minimum size packet is 64 - bytes
struct TimeStructure {
uint64_t t1 = 0; // 8-bytes / Total 8-bytes == Client time T1
uint64_t t2 = 0; // 8-bytes / Total 16-bytes == Server
uint64_t t3 = 0; // 8-bytes / Total 24-bytes
uint64_t t4 = 0; // 8-bytes / Total 32-bytes
uint64_t token = 0; // 8-bytes / Total 40-bytes == t1 ^ key
uint64_t dummy1 = 0; // 8-bytes / Total 48-bytes == for future use
uint64_t dummy2 = 0; // 8-bytes / Total 56-bytes == for future use
uint64_t dummy3 = 0; // 8-bytes / Total 64-bytes == for future use
};
uint64_t getMonotonicClockMicro();
tl::expected<TimeCommon::TAIStatus, std::string> getStatus();
int64_t getTAIMicro();
std::string taiMicroToString(int64_t taiTimestamp);
} // namespace TimeCommon
Updated on 2024-04-08 at 15:15:27 +0200
16 - include/UUIDUtils.h
include/UUIDUtils.h
Namespaces
Name |
---|
UUIDUtils A namespace for UUID utility functions. |
Source code
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <string>
namespace UUIDUtils {
std::string generateRandomUUID();
bool isValidUUIDString(const std::string& uuid);
} // namespace UUIDUtils
Updated on 2024-04-08 at 15:15:27 +0200