ADTF
Loading...
Searching...
No Matches
Example Demo Substream Generator

Description

Shows how to create substreams.

Prebuilt Binaries

Source Code

./examples/demo_adtfplugins/demo_substream_generator/

Filter

substream_generator_filter.cpp

#include "substream_generator_filter.h"
using namespace adtf::base;
using namespace adtf::filter;
using namespace adtf::mediadescription;
using namespace adtf::streaming;
using namespace adtf::ucom;
using namespace adtf::util;
using namespace ddl;
// this creates the plugin entry methods and class factories
ADTF_PLUGIN("Demo Substream Generator Plugin", cDemoSubStreamGenerator);
cDemoSubStreamGenerator::cDemoSubStreamGenerator()
{
// sets a short description for the component
SetDescription("Use this filter to generate data of multiple substreams whenever a timer triggers.");
// set help link to jump to documentation from ADTF Configuration Editor
SetHelpLink("$(ADTF_DIR)/doc/html/page_demo_substream_generator.html");
CreateRunner("generate_samples");
SetDescription("generate_samples", "Runner to periodically trigger the function which generates the substreams.");
// we create the definition of substream "stream 4" by using the DDL type reflection of ADTF
auto oExampleStructDefinition =
structure<tExampleStructWithUnit>("tExampleStructWithUnit").Add("val", &tExampleStructWithUnit::val);
oExampleStructDefinition.setElementUnit("val", ddl::BaseUnit<ddl::unit::Kelvin>());
// we use the helper class cSubStreamTypes to generate a stream type with the
// adtf::streaming::stream_meta_type_substreams meta type that contains
// multiple stream type definitions.
cSubStreamTypes oSubStreams;
oSubStreams.SetSubStream("stream1", 0, stream_type_plain<uint32_t>());
oSubStreams.SetSubStream("stream2", 1, stream_type_plain<uint32_t>());
oSubStreams.SetSubStream("stream3", 2, stream_type_plain<uint32_t>());
oSubStreams.SetSubStream("stream4", 3, oExampleStructDefinition);
m_pWriter = CreateOutputPin("output", oSubStreams);
SetDescription("output", "Provides the generated substreams.");
}
cDemoSubStreamGenerator::~cDemoSubStreamGenerator() = default;
tResult cDemoSubStreamGenerator::Process(tNanoSeconds tmTrigger, IRunner* /*pRunner*/)
{
++m_nTriggerCounter;
for (uint32_t nSubStreamId : {0, 1, 2})
{
// when generating samples we set the substream id.
// in this case we just pass it to the output_sample_data constructor.
// Otherwise take a look at adtf::streaming::set_sample_substream_id() and
// adtf::streaming::hollow::ISample::SetSubStreamId().
output_sample_data<uint32_t> oNewData(tmTrigger, m_nTriggerCounter + (nSubStreamId * 1000), nSubStreamId);
m_pWriter->Write(oNewData.Release());
}
// we create a sample containing the time, value and substream id
// the value is copied into the sample buffer in this process
tmTrigger, tExampleStructWithUnit{m_nTriggerCounter + (3 /*substreamId*/ * 1000)}, 3);
m_pWriter->Write(oExampleOutputSampleData.Release());
}
#define ADTF_PLUGIN(__plugin_identifier,...)
Definition adtf_plugin.h:29
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
Definition stream_type_helper.h:154
void SetSubStream(const char *strName, uint32_t nSubStreamId, const flash::cStreamTypeHelper &oType)
Definition type_reflection.h:124
structure & Add(const std::string &strName, MemberType T::*pMemberOffset)
Definition type_reflection.h:167
Definition runner_intf.h:24
Generator template to create an instance of a ant::IStreamType class for penguin::stream_meta_type_pl...
Definition streammetatypeplain.h:315
void setElementUnit(const std::string &element_name, const DDUnit &unit)
Sets additional element unit information to the given element_name. Any other unit information will b...
Definition ddstructure_generator.h:551
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
Namespace for the ADTF Mediadescription SDK.
Definition codec_sample_streamer.h:22
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
definition of the ddl namespace
Definition codec.h:21
A timestamp with nanosecond precision.
Definition chrono.h:23
Generator template to create baseunits.
Definition dd_predefined_units.h:33