ADTF
Loading...
Searching...
No Matches
md_sample_data_legacy.h
Go to the documentation of this file.
1
7#pragma once
10#include "sample_codec_legacy.h"
11
12#include <memory>
13#include <cstdint>
14#include <string>
15
16namespace adtf
17{
18namespace mediadescription
19{
20namespace flash
21{
22
34template <typename T>
35struct description
36{
37 description()
38 {
40 "There is no description specialization available for this type."
41 " Please make sure that you generate and include the corresponding header file.");
42 }
43};
44
48template <typename T>
49struct indices;
50
63template <typename T>
64class md_sample_data
65{
66 public:
67 md_sample_data()
68 {
70 "There is no md_sample_data specialization available for this type."
71 " Please make sure that you generate and include the corresponding header file.");
72 }
73};
74
83template <typename T, typename UnderlyingType = T>
84class md_array
85{
86 public:
87 md_array(const size_t aIndices[],
88 std::shared_ptr<adtf::mediadescription::ant::cSampleDecoder> pDecoder):
89 m_pIndices(aIndices),
90 m_pDecoder(pDecoder)
91 {
92 }
93
94 T operator[](size_t nIndex) const
95 {
96 return static_cast<T>(static_cast<UnderlyingType>(m_pDecoder->GetElementValue(m_pIndices[nIndex])));
97 }
98
99 private:
100 const size_t* m_pIndices = nullptr;
101 std::shared_ptr<adtf::mediadescription::ant::cSampleDecoder> m_pDecoder;
102};
103
112template <typename T>
113class md_struct_array
114{
115 public:
116 md_struct_array(const indices<T> aIndices[],
117 std::shared_ptr<adtf::mediadescription::ant::cSampleDecoder> decoder):
118 m_pIndices(aIndices),
119 m_pDecoder(decoder)
120 {
121 }
122
123 md_sample_data<T> operator[](size_t nIndex) const
124 {
125 return md_sample_data<T>(m_pIndices[nIndex], m_pDecoder);
126 }
127
128 private:
129 const indices<T>* m_pIndices = nullptr;
130 std::shared_ptr<adtf::mediadescription::ant::cSampleDecoder> m_pDecoder;
131};
132
134namespace detail
135{
136
137template <typename T>
138struct decoder_with_indices: public ant::cSampleDecoder
139{
140 decoder_with_indices(ant::cSampleDecoder&& oDecoder,
141 std::shared_ptr<indices<T>> pIndices):
142 ant::cSampleDecoder(std::move(oDecoder)),
143 pIndices(std::move(pIndices))
144 {}
145
146 std::shared_ptr<indices<T>> pIndices;
147};
148
149} // namespace detail
151
163template <typename T>
164class md_sample_data_factory
165{
166 public:
167 /*
168 * Default constructor that intializes the factory with the generated media description.
169 */
170 md_sample_data_factory():
171 md_sample_data_factory(description<T>::name,
173 {
174 }
175
176 md_sample_data_factory(md_sample_data_factory&&) = default;
177 md_sample_data_factory& operator=(md_sample_data_factory&&) = default;
178
179
187 md_sample_data_factory(*pStreamType.Get())
188 {
189 }
190
198 m_oFactory(oStreamType),
199 m_pIndices(std::make_shared<indices<T>>())
200 {
201 THROW_IF_FAILED(m_oFactory.IsValid());
202 m_pIndices->Find(m_oFactory, "");
203 }
204
211 md_sample_data_factory(const char* strStructName, const char* strDefinition):
212 m_oFactory(strStructName, strDefinition),
213 m_pIndices(std::make_shared<indices<T>>())
214 {
215 THROW_IF_FAILED(m_oFactory.IsValid());
216 m_pIndices->Find(m_oFactory, "");
217 }
218
225 {
226 return md_sample_data<T>(*m_pIndices,
227 std::make_shared<detail::decoder_with_indices<T>>(m_oFactory.MakeDecoderFor(pSample),
228 m_pIndices));
229 }
230
231 private:
233 std::shared_ptr<indices<T>> m_pIndices;
234};
235
236}
237
238}
239}
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
Definition sample_codec_legacy.h:96
Definition sample_codec_legacy.h:463
md_sample_data_factory(const char *strStructName, const char *strDefinition)
Definition md_sample_data_legacy.h:211
md_sample_data< T > Make(const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::ISample > &pSample)
Definition md_sample_data_legacy.h:224
md_sample_data_factory(const adtf::streaming::IStreamType &oStreamType)
Definition md_sample_data_legacy.h:197
md_sample_data_factory(const adtf::ucom::ant::iobject_ptr< const adtf::streaming::IStreamType > &pStreamType)
Definition md_sample_data_legacy.h:186
Definition md_sample_data_legacy.h:65
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 media_description_type_legacy.h:31
Namespace for all internally used functionality implemented.
Definition adtf_mediadescription_version_namespaces.dox:34
Namespace for all functionality of the ADTF Mediadescription SDK provided since v3....
Definition codec_sample_streamer_legacy.h:20
Namespace for the ADTF Mediadescription SDK.
Definition codec_sample_streamer.h:22
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
Definition md_sample_data_legacy.h:36
Definition md_sample_data_legacy.h:49