Shows how to create samples provided by a DDL description file.
#pragma once
#include <random>
#ifndef ADTF_EXAMPLES_CID
#define ADTF_EXAMPLES_CID ".local.cid"
#endif
{
public:
"demo_media_description_data_generator.filter" ADTF_EXAMPLES_CID,
"Media Description Data Generator");
cMediaDescriptionDataGenerator();
~cMediaDescriptionDataGenerator() override;
private:
std::mt19937 m_oRandomGenerator;
std::uniform_real_distribution<double> m_oDistribution;
};
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Definition class_id.h:33
Property Variable template for the given T. A Property Variable will store a copy of a property value...
Definition configuration.h:808
tResult Init(tInitStage eStage) override
virtual tResult Process(base::flash::tNanoSeconds tmTrigger, streaming::ant::IRunner *pRunner)
Definition runner_intf.h:24
A timestamp with nanosecond precision.
Definition chrono.h:23
#include "demo_md_data_generator.h"
#include <adtfddl/pkg_ddl.h>
ADTF_PLUGIN(
"Media Description Data Generator Plugin", cMediaDescriptionDataGenerator);
cMediaDescriptionDataGenerator::cMediaDescriptionDataGenerator(): m_oDistribution(0.0, 100.0)
{
m_pWriter = CreateOutputPin<encoding_sample_writer<>>("data");
SetDescription("data", "Provides the generated data based on the configured media description structure");
CreateRunner("data_generator_function", cTimerTriggerHint(std::chrono::seconds{1}));
SetDescription("data_generator_function",
"Runner to periodically trigger the function which generates the output samples");
m_strMediaDescriptionStructName.SetDescription("The name of the DDL structure to generate.");
RegisterPropertyVariable("data_generator_function/media_description_struct_name", m_strMediaDescriptionStructName);
m_strDescriptionFile.SetDescription(
"A description file containing the DDL description for the samples to generate.");
RegisterPropertyVariable("description_file", m_strDescriptionFile);
m_bMarkSamplesAsDeserialized.SetDescription(
"Determines whether the data representation of the configured DDL description file is deserialized.");
RegisterPropertyVariable("mark_samples_as_deserialized", m_bMarkSamplesAsDeserialized);
SetDescription("Use this filter to generate random values for a specified Media Description structure configured "
"by property 'media_description_struct_name'.");
SetHelpLink("$(ADTF_DIR)/doc/html/page_media_description_data_generator.html");
}
cMediaDescriptionDataGenerator::~cMediaDescriptionDataGenerator() = default;
tResult cMediaDescriptionDataGenerator::Init(tInitStage eStage)
{
if (eStage == StageNormal)
{
try
{
m_strMediaDescriptionStructName->GetPtr(), oDataDefinition,
RETURN_IF_FAILED(m_pWriter->ChangeType(pType));
}
catch (...)
{
}
}
}
{
double fRandomValue = m_oDistribution(m_oRandomGenerator);
auto oSample = m_pWriter->MakeSample(tmTimeOfTrigger);
for_each_leaf_element(oSample.GetElements(), [&fRandomValue](
auto& oElement) { oElement.setValue(fRandomValue); });
m_pWriter->Write(oSample);
}
#define ADTF_PLUGIN(__plugin_identifier,...)
Definition adtf_plugin.h:29
#define RETURN_CURRENT_EXCEPTION()
returns the current exception as a tResult, use it in a catch block.
Definition result.h:111
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
Definition object_ptr.h:384
static dd::DataDefinition fromXMLFile(const std::string &xml_filepath, bool strict=false)
Read a file containing a data definiton in XML.
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 Streaming SDK.
Definition bindingproxyinport.h:14
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
object_ptr< Implementation > make_object_ptr(Args &&... args)
Alias always bringing the latest version of ant::make_object_ptr() into scope.
Definition object_ptr_utilities.h:129
@ Deserialized
alias names for legacy reasons
Definition data_representation.h:29
@ Serialized
alias names for legacy reasons
Definition data_representation.h:28