Skip to content

Commit

Permalink
Merge branch 'main' into ks/removeLibreAndBaresip
Browse files Browse the repository at this point in the history
  • Loading branch information
kushaljain-apra authored Sep 13, 2024
2 parents 130ee2d + 9ecea0d commit 24df6a3
Show file tree
Hide file tree
Showing 33 changed files with 2,987 additions and 1,785 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-test-lin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ jobs:
uses: actions/checkout@v3
with:
submodules: 'recursive'
lfs: true
fetch-depth: 0

- name: List Submodules
Expand Down
7 changes: 7 additions & 0 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ SET(CORE_FILES
src/MotionVectorExtractor.cpp
src/OverlayModule.cpp
src/OrderedCacheOfFiles.cpp
src/SimpleControlModule.cpp
src/APErrorObject.cpp
src/APHealthObject.cpp
)

SET(CORE_FILES_H
Expand Down Expand Up @@ -253,6 +256,10 @@ SET(CORE_FILES_H
include/OrderedCacheOfFiles.h
include/TestSignalGeneratorSrc.h
include/AbsControlModule.h
include/SimpleControlModule.h
include/APErrorObject.h
include/APCallback.h
include/APHealthObject.h
)

IF(ENABLE_WINDOWS)
Expand Down
1 change: 1 addition & 0 deletions base/include/AIPExceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#define MP4_OCOF_INVALID_DUR 7823
#define MP4_UNEXPECTED_STATE 7824
#define MODULE_ENROLLMENT_FAILED 7825
#define CTRL_MODULE_INVALID_STATE 7826


#define AIPException_LOG_SEV(severity,type) for(std::ostringstream stream; Logger::getLogger()->push(severity, stream);) Logger::getLogger()->aipexceptionPre(stream, severity,type)
Expand Down
7 changes: 7 additions & 0 deletions base/include/APCallback.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
#include "APErrorObject.h"
#include "APHealthObject.h"
#include <functional>

using APErrorCallback = std::function<void(const APErrorObject &)>;
using APHealthCallback = std::function<void(const APHealthObject &)>;
28 changes: 28 additions & 0 deletions base/include/APErrorObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include <string>

class APErrorObject {
private:
int mErrorCode;
std::string mErrorMessage;
std::string mModuleName;
std::string mModuleId;
std::string mTimestamp;

std::string getCurrentTimestamp() const;

public:
APErrorObject(int errCode, const std::string &errorMsg);

int getErrorCode() const;
std::string getErrorMessage() const;
std::string getModuleName() const;
std::string getModuleId() const;
std::string getTimestamp() const;

void displayError() const;
void setErrorCode(int errCode);
void setErrorMessage(const std::string &errorMsg);
void setModuleName(const std::string &modName);
void setModuleId(const std::string &modId);
};
19 changes: 19 additions & 0 deletions base/include/APHealthObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#include <string>

class APHealthObject
{
private:
std::string mModuleId;
std::string mTimestamp;

std::string getCurrentTimestamp() const;

public:
APHealthObject(const std::string &modId);

std::string getModuleId() const;
std::string getTimestamp() const;

void setModuleId(const std::string &modId);
};
51 changes: 28 additions & 23 deletions base/include/AbsControlModule.h
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
#pragma once
#include "APCallback.h"
#include "Command.h"
#include "Module.h"
#include <map>

class PipeLine;
class AbsControlModuleProps : public ModuleProps {
public:
AbsControlModuleProps() {}
AbsControlModuleProps() {}
};

class AbsControlModule : public Module {
public:
AbsControlModule(AbsControlModuleProps _props);
~AbsControlModule();
bool init();
bool term();
std::string enrollModule(std::string pName, std::string role,
boost::shared_ptr<Module> module);
std::pair<bool, boost::shared_ptr<Module>> getModuleofRole(std::string pName,
std::string role);
virtual void handleMp4MissingVideotrack(std::string previousVideoFile, std::string nextVideoFile) {}
virtual void handleMMQExport(Command cmd, bool priority = false) {}
virtual void handleMMQExportView(uint64_t startTS, uint64_t endTS = 9999999999999, bool playabckDirection = true, bool Mp4ReaderExport = false, bool priority = false) {}
virtual void handleSendMMQTSCmd(uint64_t mmqBeginTS, uint64_t mmqEndTS, bool priority = false) {}
virtual void handleLastGtkGLRenderTS(uint64_t latestGtkGlRenderTS, bool priority) {}
virtual void handleGoLive(bool goLive, bool priority) {}
virtual void handleDecoderSpeed(DecoderPlaybackSpeed cmd, bool priority) {}
boost::container::deque<boost::shared_ptr<Module>> pipelineModules;
std::map<std::string, boost::shared_ptr<Module>> moduleRoles;
AbsControlModule(AbsControlModuleProps _props);
~AbsControlModule();
bool init();
bool term();
bool enrollModule(std::string role, boost::shared_ptr<Module> module);
boost::shared_ptr<Module> getModuleofRole(std::string role);
virtual void handleMp4MissingVideotrack(std::string previousVideoFile, std::string nextVideoFile) {}
virtual void handleMMQExport(Command cmd, bool priority = false) {}
virtual void handleMMQExportView(uint64_t startTS, uint64_t endTS = 9999999999999, bool playabckDirection = true, bool Mp4ReaderExport = false, bool priority = false) {}
virtual void handleSendMMQTSCmd(uint64_t mmqBeginTS, uint64_t mmqEndTS, bool priority = false) {}
virtual void handleLastGtkGLRenderTS(uint64_t latestGtkGlRenderTS, bool priority) {}
virtual void handleGoLive(bool goLive, bool priority) {}
virtual void handleDecoderSpeed(DecoderPlaybackSpeed cmd, bool priority) {}
boost::container::deque<boost::shared_ptr<Module>> pipelineModules;
std::map<std::string, boost::shared_ptr<Module>> moduleRoles;
virtual void handleError(const APErrorObject &error) {}
virtual void handleHealthCallback(const APHealthObject &healthObj) {}


protected:
bool process(frame_container &frames);
bool handleCommand(Command::CommandType type, frame_sp &frame);
bool handlePropsChange(frame_sp &frame);
bool process(frame_container& frames);
bool handleCommand(Command::CommandType type, frame_sp& frame);
bool handlePropsChange(frame_sp& frame);
virtual void sendEOS() {}
virtual void sendEOS(frame_sp& frame) {}
virtual void sendEOPFrame() {}

private:
class Detail;
boost::shared_ptr<Detail> mDetail;
class Detail;
boost::shared_ptr<Detail> mDetail;
};
1 change: 0 additions & 1 deletion base/include/BrightnessContrastControlXform.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class BrightnessContrastControl : public Module
bool validateInputPins();
bool validateOutputPins();
void addInputPin(framemetadata_sp &metadata, string &pinId);
void setProps(BrightnessContrastControl);
bool handlePropsChange(frame_sp &frame);

private:
Expand Down
8 changes: 6 additions & 2 deletions base/include/FramesMuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ class FramesMuxerProps : public ModuleProps
public:
enum Strategy {
ALL_OR_NONE,
MAX_DELAY_ANY
MAX_DELAY_ANY,
MAX_TIMESTAMP_DELAY
};

public:
FramesMuxerProps() : ModuleProps()
FramesMuxerProps() : ModuleProps()
{
maxTsDelayInMS = 16.67;
maxDelay = 30;
strategy = ALL_OR_NONE;
fIndexStrategyType = FIndexStrategy::FIndexStrategyType::NONE;
}

int maxDelay; // Difference between current frame and first frame in the queue
Strategy strategy;
double maxTsDelayInMS; // Max TimeStampDelay in Milli Seconds
};

class FramesMuxerStrategy;
Expand Down
37 changes: 19 additions & 18 deletions base/include/GtkGlRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,44 @@
#include <chrono>
#include <gtk/gtk.h>

class GtkGlRendererProps : public ModuleProps {
class GtkGlRendererProps : public ModuleProps
{
public:
GtkGlRendererProps(GtkWidget* _glArea, int _windowWidth, int _windowHeight, bool _isPlaybackRenderer = true) : ModuleProps() // take gtk string
GtkGlRendererProps(GtkWidget *_glArea, int _windowWidth, int _windowHeight, bool _isPlaybackRenderer = true) : ModuleProps() // take gtk string
{
// gladeFileName = _gladeFileName;
glArea = _glArea;
windowWidth = _windowWidth;
windowHeight = _windowHeight;
isPlaybackRenderer = _isPlaybackRenderer;
}
GtkWidget* glArea;
GtkWidget *glArea;
int windowWidth = 0;
int windowHeight = 0;
bool isPlaybackRenderer = true;
};

class GtkGlRenderer : public Module {
class GtkGlRenderer : public Module
{
public:
GtkGlRenderer(GtkGlRendererProps props);
~GtkGlRenderer();

bool init();
bool term();
bool changeProps(GtkWidget *glArea, int windowWidth, int windowHeight);

GtkGlRenderer(GtkGlRendererProps props);
~GtkGlRenderer();
bool init();
bool term();
bool changeProps(GtkWidget *glArea, int windowWidth, int windowHeight);
protected:
bool process(frame_container& frames);
bool process(frame_container &frames);
bool processSOS(frame_sp &frame);
bool validateInputPins();
bool shouldTriggerSOS();
bool handleCommand(Command::CommandType type, frame_sp &frame);
void pushFrame(frame_sp frame);

private:
class Detail;
boost::shared_ptr<Detail> mDetail;
std::chrono::steady_clock::time_point lastFrameTime =
std::chrono::steady_clock::now();
std::queue<frame_sp> frameQueue;
std::mutex queueMutex;
class Detail;
boost::shared_ptr<Detail> mDetail;
std::chrono::steady_clock::time_point lastFrameTime =
std::chrono::steady_clock::now();
std::queue<frame_sp> frameQueue;
std::mutex queueMutex;
};
58 changes: 49 additions & 9 deletions base/include/H264EncoderNVCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,70 @@
#include "Module.h"
#include "CudaCommon.h"

/**
* @brief Properties for the H264 encoder using NVCodec.
*/
class H264EncoderNVCodecProps : public ModuleProps
{
public:
/**
* @enum H264CodecProfile
* @brief Enum representing different H.264 codec profiles.
*/
enum H264CodecProfile
{
BASELINE,
MAIN,
HIGH,
BASELINE, /**< Baseline profile */
MAIN, /**< Main profile */
HIGH, /**< High profile */
};

/**
* @brief Constructor for H264EncoderNVCodecProps with all parameters.
*
* @param _bitRateKbps Bit rate in kilobits per second.
* @param _cuContext CUDA context.
* @param _gopLength Group of Pictures (GOP) length.
* @param _frameRate Frame rate.
* @param _vProfile Video profile from H264CodecProfile enum.
* @param _enableBFrames Enable or disable B-frames.
*/
H264EncoderNVCodecProps(const uint32_t &_bitRateKbps, const apracucontext_sp& _cuContext, const uint32_t &_gopLength,const uint32_t &_frameRate,H264CodecProfile _vProfile,bool _enableBFrames)
: cuContext(_cuContext), gopLength(_gopLength), frameRate(_frameRate), bitRateKbps(_bitRateKbps), vProfile(_vProfile), enableBFrames(_enableBFrames)
{
}

/**
* @brief Constructor for H264EncoderNVCodecProps with default bit rate.
*
* @param _cuContext CUDA context.
*/
H264EncoderNVCodecProps(apracucontext_sp& _cuContext) : bitRateKbps(0), cuContext(_cuContext)
{
}

/**
* @brief Constructor for H264EncoderNVCodecProps with buffer threshold.
*
* @param _bitRateKbps Bit rate in kilobits per second.
* @param _cuContext CUDA context.
* @param _gopLength Group of Pictures (GOP) length.
* @param _frameRate Frame rate.
* @param _vProfile Video profile from H264CodecProfile enum.
* @param _enableBFrames Enable or disable B-frames.
* @param _bufferThres Buffer threshold.
*/
H264EncoderNVCodecProps(const uint32_t &_bitRateKbps, const apracucontext_sp& _cuContext, const uint32_t &_gopLength,const uint32_t &_frameRate,H264CodecProfile _vProfile,bool _enableBFrames, uint32_t &_bufferThres)
: cuContext(_cuContext), gopLength(_gopLength), frameRate(_frameRate), bitRateKbps(_bitRateKbps), vProfile(_vProfile), enableBFrames(_enableBFrames), bufferThres(_bufferThres)
{
}
H264CodecProfile vProfile= H264EncoderNVCodecProps::BASELINE;
bool enableBFrames=false;
uint32_t gopLength = 30;
uint32_t bitRateKbps = 1000;
uint32_t frameRate = 30;
apracucontext_sp cuContext;

H264CodecProfile vProfile = H264EncoderNVCodecProps::BASELINE; /**< Video profile. */
bool enableBFrames = false; /**< Enable or disable B-frames. */
uint32_t gopLength = 30; /**< Group of Pictures (GOP) length. */
uint32_t bitRateKbps = 1000; /**< Bit rate in kilobits per second. */
uint32_t frameRate = 30; /**< Frame rate. */
apracucontext_sp cuContext; /**< CUDA context. */
uint32_t bufferThres = 30; /**< Buffer threshold. */
};

class H264EncoderNVCodec : public Module
Expand Down
Loading

0 comments on commit 24df6a3

Please sign in to comment.