ADTF
Loading...
Searching...
No Matches
Example Substream Dumper

Description

Shows how to access incoming substreams.

Prebuilt Binaries

Source Code

./examples/demo_adtfplugins/substream_dumper/

Filter

substream_dumper_filter.cpp

#include "substream_dumper_filter.h"
using namespace adtf::ucom;
using namespace adtf::base;
using namespace adtf::streaming;
using namespace adtf::mediadescription;
using namespace adtf::filter;
using namespace ddl;
cDemoSubStreamDumper::cDemoSubStreamDumper()
{
// sets a short description for the component
SetDescription("Use this filter to dump data of all samples of all available substreams.");
// set help link to jump to documentation from ADTF Configuration Editor
SetHelpLink("$(ADTF_DIR)/doc/html/page_substream_dumper.html");
m_pReader = CreateInputPin("input", stream_meta_type_substreams());
SetDescription("input", "Incoming data of substreams for printing.");
// Every filter that uses a substream input is required to request transmission of the substreams that it is interested in.
// It will not receive any data otherwise! Non-interactive requests need to be performed within the following callback!
m_pReader->SetSynchronousTypeUpdateCallback([&](const iobject_ptr<const IStreamType>& pStreamType) -> tResult
{
// this callback is called synchronously whenever the source changes the type and once when the connection is established.
// Never use this callback to setup data structures to decode and/or access sample data, request handling is completely
// independent of the data transmission. Use the AcceptType method instead.
// first we clear all ongoing requests
m_oRequests.clear();
// and then request samples from all substreams
stream_meta_type_substreams::ListSubStreams(*pStreamType.Get(), [&](const char* /*strName*/, uint32_t nSubStreamId)
{
object_ptr<IStreamingRequest> pRequest;
THROW_IF_FAILED(m_pReader->RequestSamples(pRequest, nSubStreamId));
// we store the request object for as long as we want those samples.
m_oRequests.push_back(pRequest);
});
});
}
cDemoSubStreamDumper::~cDemoSubStreamDumper() = default;
tResult cDemoSubStreamDumper::AcceptType(ISampleReader* pReader, const iobject_ptr<const IStreamType>& pStreamType)
{
// let the base class do basic compatibility checks (i.e. if the stream meta type matches)
RETURN_IF_FAILED(cFilter::AcceptType(pReader, pStreamType));
// iterate over all available substreams.
stream_meta_type_substreams::ListSubStreams(*pStreamType.Get(), [&](const char* strName, uint32_t nSubStreamId)
{
// first we try to generate a codec factory for the substream.
auto pSubStreamType = stream_meta_type_substreams::GetSubStreamType(*pStreamType.Get(), strName);
cSampleCodecFactory oCodecFactory(pSubStreamType);
if (IS_OK(oCodecFactory.IsValid()))
{
m_oCodecFactories[nSubStreamId] = {oCodecFactory, strName};
}
});
}
tResult cDemoSubStreamDumper::ProcessInput(ISampleReader* /*pReader*/, const iobject_ptr<const ISample>& pSample)
{
// check the substreamid of the sample.
auto itCodecFactory = m_oCodecFactories.find(get_sample_substream_id(pSample));
if (itCodecFactory != m_oCodecFactories.end())
{
// and dump it with the matching decoder.
auto oDecoder = itCodecFactory->second.oCodecFactory.MakeDecoderFor(pSample);
LOG_INFO("Sample from %s:", itCodecFactory->second.strName.c_str());
DumpSample(oDecoder);
}
}
void cDemoSubStreamDumper::DumpSample(const adtf::mediadescription::cSampleDecoder& oDecoder)
{
LOG_INFO("%s = %s",
oElement.getFullName().c_str(),
oElement.getStringValue().c_str());
});
}
// this creates the plugin entry methods and class factories
ADTF_PLUGIN("Substream Dumper Plugin", cDemoSubStreamDumper);
#define ADTF_PLUGIN(__plugin_identifier,...)
Definition adtf_plugin.h:29
#define LOG_INFO(...)
Logs an info message.
Definition log.h:388
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
virtual tResult AcceptType(streaming::flash::ISampleReader *pReader, const ucom::ant::iobject_ptr< const streaming::ant::IStreamType > &pType)
ddl::codec::DecoderElement< sample_decoder_access< const cSampleDecoderBase > > tElement
Definition sample_codec.h:69
Definition samplestreamer_intf.h:188
virtual T * Get() const =0
Get raw pointer to shared object.
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
void for_each_leaf_element(ElementsType &oElements, const element_callback< ElementsType > &fnCallback)
Iterates ALL leaf elements within ALL array elements.
Definition sample_codec.h:1414
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
uint32_t get_sample_substream_id(const ant::ISample &oSample)
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:437
definition of the ddl namespace
Definition codec.h:21
Use cSubStreamTypes to create a Stream Type instance for this Stream Meta Type.
Definition streammetatypesubstreams.h:32
static void ListSubStreams(const ant::IStreamType &oStreamType, std::function< void(const char *)> fnCallback)