#include <unordered_map>
class cDemoSubStreamDumper: public cFilter
{
public:
"demo_substream_dumper.filter.adtf.cid",
"Substream Dumper");
public:
cDemoSubStreamDumper()
{
SetDescription("Use this filter to dump data of all samples of all available substreams.");
SetHelpLink("$(ADTF_DIR)/doc/adtf_html/page_demo_substream_dumper.html");
m_pReader = CreateInputPin("input", stream_meta_type_substreams());
SetDescription("input", "Incoming data of substreams for printing.");
m_pReader->SetSynchronousTypeUpdateCallback([&](
const iobject_ptr<const IStreamType>& pStreamType) ->
tResult
{
m_oRequests.clear();
stream_meta_type_substreams::ListSubStreams(*pStreamType.Get(), [&](const char* , uint32_t nSubStreamId)
{
object_ptr<IStreamingRequest> pRequest;
THROW_IF_FAILED(m_pReader->RequestSamples(pRequest, nSubStreamId));
m_oRequests.push_back(pRequest);
});
});
}
tResult AcceptType(ISampleReader* pReader,
const iobject_ptr<const IStreamType>& pStreamType)
override
{
stream_meta_type_substreams::ListSubStreams(*pStreamType.Get(), [&](const char* strName, uint32_t nSubStreamId)
{
auto pSubStreamType = stream_meta_type_substreams::GetSubStreamType(*pStreamType.Get(), strName);
cSampleCodecFactory oCodecFactory(pSubStreamType);
if (IS_OK(oCodecFactory.IsValid()))
{
m_oCodecFactories[nSubStreamId] = {oCodecFactory, strName};
}
});
}
tResult ProcessInput(ISampleReader* ,
const iobject_ptr<const ISample>& pSample)
override
{
if (itCodecFactory != m_oCodecFactories.end())
{
auto oDecoder = itCodecFactory->second.oCodecFactory.MakeDecoderFor(pSample);
LOG_INFO(
"Sample from %s:", itCodecFactory->second.strName.c_str());
DumpSample(oDecoder);
}
}
private:
{
LOG_INFO("%s = %s",
oElement.getFullName().c_str(),
oElement.getStringValue().c_str());
});
}
std::vector<object_ptr<IStreamingRequest>> m_oRequests;
struct tCodecFactoryAndName
{
cSampleCodecFactory oCodecFactory;
std::string strName;
};
std::unordered_map<uint32_t, tCodecFactoryAndName> m_oCodecFactories;
};
ADTF_PLUGIN(
"Substream Dumper Plugin", cDemoSubStreamDumper);
#define ADTF_PLUGIN(__plugin_identifier,...)
The ADTF Plugin Macro will add the code of a adtf::ucom::ant::IPlugin implementation.
Copyright © Audi Electronics Venture GmbH.
#define LOG_INFO(...)
Logs an info message.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Common macro to enable correct treatment of class identifier AND Class Name by IClassInfo.
A common result class usable as return value throughout.
Namespace for the ADTF Base SDK.
adtf::streaming::ant::cDynamicSampleReader cPinReader
use cSampleReader as cPinReader
Namespace for the ADTF Filter SDK.
uint32_t get_sample_substream_id(const ant::ISample &oSample)
Namespace for the ADTF Streaming SDK.
Namespace for the ADTF uCOM3 SDK.
definition of the ddl namespace