ADTF  3.18.2
md_sample_data_factory< T >

This factory provides instances of md_sample_data for incoming samples. More...

Public Member Functions

 md_sample_data_factory (md_sample_data_factory &&)=default
 
md_sample_data_factoryoperator= (md_sample_data_factory &&)=default
 
 md_sample_data_factory (const adtf::ucom::ant::iobject_ptr< const adtf::streaming::IStreamType > &pStreamType)
 Initializes the factory with a stream type that has a media description set. More...
 
 md_sample_data_factory (const adtf::streaming::IStreamType &oStreamType)
 Initializes the factory with a stream type that has a media description set. More...
 
 md_sample_data_factory (const char *strStructName, const char *strDefinition)
 Initializes the factory with a media description. More...
 
md_sample_data< T > Make (const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::ISample > &pSample)
 Returns a data access wrapper for the given sample. More...
 

Private Attributes

adtf::mediadescription::osborn::cSampleCodecFactory m_oFactory
 
std::shared_ptr< indices< T > > m_pIndices
 

Detailed Description

template<typename T>
class adtf::mediadescription::osborn::md_sample_data_factory< T >

This factory provides instances of md_sample_data for incoming samples.

Make sure that you created a header containing the struct definition and the required template specializations of description and md_sample_data with the MD Generator Tool.

Example Usage

test_struct.description:

<structs>
<struct name="tChild" alignment="4" version="1">
<element name="nA" type="tUInt32" arraysize="1">
<deserialized alignment="4"/>
<serialized bytepos="0" byteorder="LE"/>
</element>
<element name="nB" type="tUInt32" arraysize="1">
<deserialized alignment="4"/>
<serialized bytepos="4" byteorder="LE"/>
</element>
</struct>
<struct name="tTest" alignment="4" version="1">
<element name="nValue" type="tUInt32" arraysize="1">
<deserialized alignment="4"/>
<serialized bytepos="0" byteorder="LE"/>
</element>
<element name="aArray" type="tUInt32" arraysize="2">
<deserialized alignment="4"/>
<serialized bytepos="4" byteorder="LE"/>
</element>
<element name="sChild" type="tChild" arraysize="1">
<deserialized alignment="4"/>
<serialized bytepos="12" byteorder="LE"/>
</element>
<element name="aChildren" type="tChild" arraysize="2">
<deserialized alignment="4"/>
<serialized bytepos="20" byteorder="LE"/>
</element>
</struct>
</structs>
// include the generated header
#include <test_struct.h>
class cMyFilter: public adtf::filter::cFilter
{
public:
ADTF_CLASS_ID_NAME(cMyFilter, "my_filter.filter.example.cid", "My Filter");
cMyFilter()
{
CreateInputPin("input", adtf::mediadescription::description<tTest>());
}
tResult AcceptType(adtf::streaming::ISampleReader* /*pReader*/,
{
}
tResult ProcessInput(adtf::streaming::ISampleReader* /*pReader*/,
{
auto oSampleData = m_oSampleDataFactory.Make(pSample);
LOG_INFO("received a sample:\n"
" nValue = %u\n"
" aArray[0] = %u\n"
" sChild.nA = %u\n"
" aChildren[0].nA = %u",
oSampleData.nValue(),
oSampleData.aArray()[0],
oSampleData.sChild().nA(),
oSampleData.aChildren()[0].nB());
}
private:
};
Copyright © Audi Electronics Venture GmbH.
#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.
Definition: class_id.h:33
This factory provides instances of md_sample_data for incoming samples.
Interface for sample reads that read from sample streams via input pins.
Base object pointer to realize binary compatible reference counting in interface methods.
Template to provide struct name and definition for a generated struct.

Definition at line 174 of file md_sample_data.h.

Constructor & Destructor Documentation

◆ md_sample_data_factory() [1/3]

Initializes the factory with a stream type that has a media description set.

Parameters
[in]pStreamTypeA stream type.
Exceptions
ERR_NOT_FOUNDIf a struct element was not defined in the media description of the stream type.

Definition at line 199 of file md_sample_data.h.

◆ md_sample_data_factory() [2/3]

md_sample_data_factory ( const adtf::streaming::IStreamType oStreamType)
inline

Initializes the factory with a stream type that has a media description set.

Parameters
[in]oStreamTypeA stream type.
Exceptions
ERR_NOT_FOUNDIf a struct element was not defined in the media description of the stream type.

Definition at line 210 of file md_sample_data.h.

References cSampleCodecFactory::IsValid(), and THROW_IF_FAILED.

◆ md_sample_data_factory() [3/3]

md_sample_data_factory ( const char *  strStructName,
const char *  strDefinition 
)
inline

Initializes the factory with a media description.

Parameters
[in]strStructNameThe name of the structure.
[in]strDefinitionThe description defining the structure.
Exceptions
ERR_NOT_FOUNDIf a struct element was not defined in the media description.

Definition at line 224 of file md_sample_data.h.

References cSampleCodecFactory::IsValid(), and THROW_IF_FAILED.

Member Function Documentation

◆ Make()

md_sample_data<T> Make ( const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::ISample > &  pSample)
inline

Returns a data access wrapper for the given sample.

Parameters
[in]pSampleThe sample that you want to access.
Returns
A sample data wrapper. This will keep a reference to the sample and its buffer as long as it exists.

Definition at line 237 of file md_sample_data.h.

References cSampleCodecFactory::MakeDecoderFor().