How to define a MODULE_CALLBACK?


I’d like to know if there is an example to define a MODULE_CALLBACK for an IModule task? I want to use the setCallback to get the output in my own function. Can anyone help? Thanks.


Suppose you are using DeepStream1.5

The description of Callback function can be found in section 4.2.3.
The example code can found in ‘samples/nvDecInfer_classification/nvDecInfer.cpp


Hi AastaLLL,

I know there are some definitions like this:

    void setCallback(void *pUserData, MODULE_CALLBACK callback) override {
	pUserData_ = pUserData;
	callback_ = callback;

std::pair<void *, MODULE_CALLBACK> getCallback() const override {
	return std::pair<void*, MODULE_CALLBACK>(pUserData_, callback_);
    MODULE_CALLBACK callback_{ nullptr };

But there is no description of how to define the MODULE_CALLBACK object I need to pass into the setCallback function.

I try to define something like this:


and pass this testfun to setCallback as shown here:

IModule *pConvertor = pDeviceWorker->addColorSpaceConvertorTask(BGR_PLANAR);

But I got the error:

nvCuvidPerf.cpp: In function ‘int main(int, char**)’:
nvCuvidPerf.cpp:100:48: error: invalid conversion from ‘void (* ()())(void, std::vector<IStreamTensor*>&)’ to ‘MODULE_CALLBACK {aka void ()(void, std::vector<IStreamTensor*>&)}’ [-fpermissive]
In file included from …/…/include/deepStream.h:41:0,
from nvCuvidPerf.cpp:37:
…/…/include/module.h:456:15: note: initializing argument 2 of ‘virtual void IModule::setCallback(void*, MODULE_CALLBACK)’
virtual void setCallback(void *pUserData, MODULE_CALLBACK callback) = 0;
Makefile.sample_decPerf:66: recipe for target ‘…/bin/chobj/nvCuvidPerf.o’ failed
make: *** […/bin/chobj/nvCuvidPerf.o] Error 1

Please help!


We are checking if there is any callback example we can share.
Will update information with you later.