Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health & Error Callback Implementation , Improved Abs Control Module #377

Merged
merged 43 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
43956e4
Added Error & Health Status Objects
yashrajsapra Jul 15, 2024
773fdcd
Added Error & Health Callbacks
yashrajsapra Jul 22, 2024
acb0df3
Removed unwanted Header Declarartion
yashrajsapra Jul 22, 2024
1236c00
Added Health & Error Callback Listener
yashrajsapra Jul 22, 2024
d8f2bb2
Fixed Build Issue
yashrajsapra Jul 22, 2024
3117128
-> Added Virtual Function to register error callback
yashrajsapra Jul 22, 2024
3d06ac2
Added Error & Health Callback in ImageEncoder Module
yashrajsapra Jul 22, 2024
adda1d9
control module changes wip
mraduldubey Jul 23, 2024
c77a061
1. defined Control module type at framework level 2. enforced data fr…
mraduldubey Jul 24, 2024
47094c9
Merge branch 'yash/CallbackImpl' into control_module_fixes
mraduldubey Jul 24, 2024
b4de50d
added a virtual method to add control module so that it can be overri…
mraduldubey Jul 29, 2024
bfded5f
Merge branch 'control_module_fixes' of https://github.com/Apra-Labs/A…
mraduldubey Jul 29, 2024
7d55a29
resolved conflict
mraduldubey Jul 29, 2024
96752b4
Fixed Build Issue
yashrajsapra Jul 29, 2024
03111cf
Merge remote-tracking branch 'origin/control_module_fixes' into yash/…
yashrajsapra Jul 29, 2024
a79c916
Fixed Linking Error
yashrajsapra Jul 29, 2024
2a9e70d
Fixed Typo
yashrajsapra Jul 29, 2024
26bc046
revert the multiple pipelines with control module idea
mraduldubey Jul 30, 2024
0450430
Do not allow roles to be updated once registered
mraduldubey Jul 30, 2024
4fef791
Merge branch 'main' into yash/CallbackImpl
mraduldubey Jul 30, 2024
f01f962
Added COndition to check for input and output pins
yashrajsapra Jul 30, 2024
a0fb1fc
Updated handleError and Callback as a virtual function
yashrajsapra Jul 30, 2024
9b1c3f7
Added handle Error & Healthback method in Simple Control Module
yashrajsapra Jul 30, 2024
ad8fbb4
Removed Dummy Error Callbacks from ImageEncoder Module
yashrajsapra Jul 30, 2024
676e7e5
USing Simple Control Module in ImageEncoder Tests
yashrajsapra Jul 30, 2024
16dc104
Fixed Indentation and typo
yashrajsapra Jul 30, 2024
2bc132e
Merge branch 'main' into yash/CallbackImpl
mraduldubey Jul 30, 2024
d95e537
Renamed Error, Health and Callback class
yashrajsapra Jul 30, 2024
af31646
Code Cleanup
yashrajsapra Jul 30, 2024
560379b
Fixed warning
yashrajsapra Jul 30, 2024
3daa884
Using Updated Health & Error Object class
yashrajsapra Jul 30, 2024
f420c07
-> Fixed Formatting
yashrajsapra Jul 30, 2024
33fb9c9
Renamed Health & ErrorCallback function
yashrajsapra Jul 30, 2024
4a3066b
Updated GtkGL to use updated APErrorCallback method
yashrajsapra Jul 30, 2024
3e57fa3
Merge branch 'yash/CallbackImpl' of https://github.com/Apra-Labs/Apra…
yashrajsapra Jul 30, 2024
89a56e9
Update Module.h
yashrajsapra Jul 30, 2024
14ae1f1
Added Generic Implementation of Error Callback
yashrajsapra Aug 1, 2024
46a2fe3
Formatted APErrorObject class
yashrajsapra Aug 1, 2024
e46ceab
Updated GtkGLRenderer to Use Generic Error Callbacks, Added Test for …
yashrajsapra Aug 1, 2024
8635a48
Removed Unwanted errors
yashrajsapra Aug 1, 2024
683c4af
Added healthUpdateIntervalInSec in ModuleProps, To make HealtCallback…
yashrajsapra Aug 1, 2024
5c0fd2b
Added Defination of getCurrentTimestamp
yashrajsapra Aug 5, 2024
11b71c8
Merge branch 'main' into yash/CallbackImpl
mraduldubey Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,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 @@ -257,6 +260,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);
mraduldubey marked this conversation as resolved.
Show resolved Hide resolved
bool handlePropsChange(frame_sp &frame);

private:
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;
};
2 changes: 0 additions & 2 deletions base/include/ImageEncoderCV.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ class ImageEncoderCV : public Module
virtual ~ImageEncoderCV();
bool init();
bool term();

protected:
bool process(frame_container& frames);
bool processSOS(frame_sp& frame);
bool validateInputPins();
bool validateOutputPins();

private:
void setMetadata(framemetadata_sp& metadata);
int mFrameType;
ImageEncoderCVProps props;
class Detail;
Expand Down
Loading
Loading