ADTF  3.18.2
Source Code for Media Description Dumper Plugin
Location
./src/examples/src/adtf/filters/standard_filters/demo_md_dumper_filter/
Namespace for entire ADTF SDK.
Build Environment
To see how to set up the build environment have a look at ADTF CMake Environment
this implementation shows:
Header
#pragma once
using namespace adtf::base;
using namespace adtf::streaming;
using namespace adtf::filter;
using namespace adtf::mediadescription;
class cMediaDescriptionDumper: public cFilter
{
public:
ADTF_CLASS_ID_NAME(cMediaDescriptionDumper,
"demo_media_description_dumper.filter.adtf.cid",
"Media Description Dumper");
cMediaDescriptionDumper();
tResult ProcessInput(tNanoSeconds tmTrigger, ISampleReader* pReader) override;
private:
decoding_sample_reader<>* m_pReader = nullptr;
};
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Common macro to enable correct treatment of class identifier AND Class Name by IClassInfo.
Definition: class_id.h:33
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Namespace for the ADTF Base SDK.
Namespace for the ADTF Filter SDK.
Namespace for the ADTF Media Description SDK.
Namespace for the ADTF Streaming SDK.
Implementation
#include "demo_md_dumper.h"
#include <cinttypes>
ADTF_PLUGIN("Media Description Dumper Plugin",
cMediaDescriptionDumper);
cMediaDescriptionDumper::cMediaDescriptionDumper()
{
m_pReader = CreateInputPin<decoding_sample_reader<>>("input");
SetDescription("input", "Input Pin from which the received DDL structure will be printed to console.");
// sets a short description for the component
SetDescription("Use this filter to print the sampla data of a received input.");
// set help link to jump to documentation from ADTF Configuration Editor
SetHelpLink("$(ADTF_DIR)/doc/adtf_html/page_demo_md_dumper_filter.html");
}
static adtf::util::cString decode_to_json(const cSampleDecoder& oDecoder, tNanoSeconds nTimeStamp)
{
// this method does not resolve substructures, as this would make this example code more complicated than neccessary.
adtf::util::cString strJSONObject = adtf::util::cString::Format("{\n \"timestamp\": %" PRIi64 ",\n \"data\":\n {", nTimeStamp.nCount);
size_t nElementIndex = 0;
for_each_leaf_element(oDecoder.GetElements(), [&strJSONObject, &nElementIndex](const auto& oElement) {
strJSONObject.Append(adtf::util::cString::Format("%s\n \"%s\": %s",
nElementIndex > 0 ? "," : "",
oElement.getFullName().c_str(),
oElement.getStringValue().c_str()));
++nElementIndex;
});
strJSONObject.Append("\n }\n}");
return strJSONObject;
}
tResult cMediaDescriptionDumper::ProcessInput(tNanoSeconds /*tmTrigger*/,
ISampleReader* /*pReader*/)
{
cSampleDecoder oDecoder;
tNanoSeconds tmSampleTime;
while (m_pReader->GetNextDecoder(oDecoder, tmSampleTime))
{
LOG_INFO("%s", decode_to_json(oDecoder, tmSampleTime).GetPtr());
}
}
#define ADTF_PLUGIN(__plugin_identifier,...)
The ADTF Plugin Macro will add the code of a adtf::ucom::ant::IPlugin implementation.
Definition: adtf_plugin.h:22
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
Definition: string.h:2778
void for_each_leaf_element(ElementsType &oElements, const element_callback< ElementsType > &fnCallback)
Iterates ALL leaf elements within ALL array elements.