ADTF
Loading...
Searching...
No Matches
md_sample_data.h
Go to the documentation of this file.
1
7#pragma once
8
9#ifdef USE_ADTF_MEDIA_DESCRIPTION_LEGACY
10 #ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
12 #endif
13#endif
14
18
19#include <memory>
20#include <cstdint>
21#include <string>
22
23namespace adtf
24{
25namespace mediadescription
26{
27namespace osborn
28{
30namespace detail
31{
32
33template<typename, typename = void>
34constexpr bool is_defined_v = false;
35
36template<typename T>
37constexpr bool is_defined_v<T, std::void_t<decltype(sizeof(T))>> = true;
38
39} // namespace detail
41
53template<typename T>
55
60template<typename T>
61constexpr bool has_description_v = detail::is_defined_v<description<T>>;
62
66template<typename T>
67struct indices;
68
81template<typename T>
82class md_sample_data
83{
84public:
85 md_sample_data()
86 {
88 "There is no md_sample_data specialization available for this type."
89 " Please make sure that you generate and include the corresponding header file.");
90 }
91};
92
101template<typename T, typename UnderlyingType = T>
102class md_array
103{
104public:
105 md_array(const tCodecIndex aIndices[], std::shared_ptr<adtf::mediadescription::osborn::cSampleDecoder> pDecoder):
106 m_pIndices(aIndices), m_pDecoder(pDecoder)
107 {
108 }
109
110 T operator[](size_t nIndex) const
111 {
112 return static_cast<T>(m_pDecoder->template GetElementValue<UnderlyingType>(m_pIndices[nIndex]));
113 }
114
115private:
116 const tCodecIndex* m_pIndices = nullptr;
117 std::shared_ptr<adtf::mediadescription::osborn::cSampleDecoder> m_pDecoder;
118};
119
128template<typename T>
129class md_struct_array
130{
131public:
132 md_struct_array(const indices<T> aIndices[],
133 std::shared_ptr<adtf::mediadescription::osborn::cSampleDecoder> decoder):
134 m_pIndices(aIndices), m_pDecoder(decoder)
135 {
136 }
137
138 md_sample_data<T> operator[](size_t nIndex) const
139 {
140 return md_sample_data<T>(m_pIndices[nIndex], m_pDecoder);
141 }
142
143private:
144 const indices<T>* m_pIndices = nullptr;
145 std::shared_ptr<adtf::mediadescription::osborn::cSampleDecoder> m_pDecoder;
146};
147
149namespace detail
150{
151
152template<typename T>
153struct decoder_with_indices : public cSampleDecoder
154{
155 decoder_with_indices(cSampleDecoder&& oDecoder, std::shared_ptr<indices<T>> pIndices):
156 cSampleDecoder(std::move(oDecoder)), pIndices(std::move(pIndices))
157 {
158 }
159
160 std::shared_ptr<indices<T>> pIndices;
161};
162
163} // namespace detail
165
177template<typename T>
178class md_sample_data_factory
179{
180public:
181 static_assert(has_description_v<T>,
182 "md_sample_data_factory<T>() can only be used if ddl description was generated with adtf_mdgen!");
183
184 /*
185 * Default constructor that intializes the factory with the generated media description.
186 */
187 md_sample_data_factory(): md_sample_data_factory(description<T>::name, description<T>::definition)
188 {
189 }
190
191 md_sample_data_factory(md_sample_data_factory&&) = default;
192 md_sample_data_factory& operator=(md_sample_data_factory&&) = default;
193
201 md_sample_data_factory(*pStreamType.Get())
202 {
203 }
204
212 m_oFactory(oStreamType), m_pIndices(std::make_shared<indices<T>>())
213 {
214 THROW_IF_FAILED(m_oFactory.IsValid());
215 m_pIndices->Find(m_oFactory, "");
216 }
217
224 md_sample_data_factory(const char* strStructName, const char* strDefinition):
225 m_oFactory(strStructName, strDefinition), m_pIndices(std::make_shared<indices<T>>())
226 {
227 THROW_IF_FAILED(m_oFactory.IsValid());
228 m_pIndices->Find(m_oFactory, "");
229 }
230
237 {
238 return md_sample_data<T>(*m_pIndices, std::make_shared<detail::decoder_with_indices<T>>(
239 m_oFactory.MakeDecoderFor(pSample), m_pIndices));
240 }
241
242private:
244 std::shared_ptr<indices<T>> m_pIndices;
245};
246
247} // namespace osborn
248
249using osborn::md_sample_data_factory;
250using osborn::md_sample_data;
251using osborn::description;
253using osborn::md_array;
254using osborn::md_struct_array;
255
256} // namespace mediadescription
257} // namespace adtf
Definition for type traits helper Copyright © Audi Electronics Venture GmbH. All rights reserved.
#define THROW_IF_FAILED(s)
throws if the expression returns a failed tResult
Definition result.h:88
md_sample_data_factory(const adtf::ucom::ant::iobject_ptr< const adtf::streaming::IStreamType > &pStreamType)
Definition md_sample_data.h:200
md_sample_data_factory(const char *strStructName, const char *strDefinition)
Definition md_sample_data.h:224
md_sample_data_factory(const adtf::streaming::IStreamType &oStreamType)
Definition md_sample_data.h:211
md_sample_data< T > Make(const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::ISample > &pSample)
Definition md_sample_data.h:236
Defines access methods for the interface of a Stream Type.
Definition streamtype_intf.h:96
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
constexpr bool always_false
helper template to get a always false expression.
Definition adtf_base_type_traits.h:23
Namespace for all functionality of the ADTF Mediadescription SDK provided since v3....
Definition codec_sample_streamer.h:24
constexpr bool has_description_v
Definition md_sample_data.h:61
Namespace for the ADTF Mediadescription SDK.
Definition codec_sample_streamer.h:22
osborn::tCodecIndex tCodecIndex
Definition sample_codec_access_types.h:470
constexpr bool has_description_v
Definition md_sample_data.h:61
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
Definition md_sample_data.h:54
Definition md_sample_data.h:67