ADTF  3.16.2
streammetatypeaudio.h
Go to the documentation of this file.
1 
7 #pragma once
9 #include <adtfbase/property.h>
10 #include "streamtype.h"
11 
12 #include <adtf_base_deprecated.h>
13 
14 namespace adtf
15 {
16 namespace streaming
17 {
18 namespace ant
19 {
20 
21 
31 {
33  static constexpr const tChar *const MetaTypeName = "adtf/audio";
34 
39  static constexpr const tChar *const FormatName = "format_name";
44  static constexpr const tChar *const ChannelCount = "channel_count";
49  static constexpr const tChar *const SampleRateHz = "sample_rate_hz";
54  static constexpr const tChar *const BitsPerSample = "bits_per_sample";
59  static constexpr const tChar *const SampleCount = "sample_count";
60 
66  {
67  pProperties->SetProperty(adtf::base::property<adtf_util::cString>(FormatName, ""));
68  pProperties->SetProperty(adtf::base::property<unsigned int>(ChannelCount, 0));
69  pProperties->SetProperty(adtf::base::property<unsigned int>(SampleRateHz, 0));
70  pProperties->SetProperty(adtf::base::property<unsigned int>(BitsPerSample, 0));
71  pProperties->SetProperty(adtf::base::property<unsigned int>(SampleCount, 0));
72  }
73 };
74 
75 }
76 
77 namespace lucky
78 {
84 {
92  unsigned int m_ui32ChannelCount = 0;
96  unsigned int m_ui32SampleRateHz = 0;
100  unsigned int m_ui32BitsPerSample = 0;
104  unsigned int m_ui32SampleCount = 0;
105 };
106 
114 inline bool operator==(const tStreamAudioFormat& oLeft, const tStreamAudioFormat& oRight)
115 {
116  return (oLeft.m_strFormatName == oRight.m_strFormatName)
117  && (oLeft.m_ui32BitsPerSample == oRight.m_ui32BitsPerSample)
118  && (oLeft.m_ui32ChannelCount == oRight.m_ui32ChannelCount)
119  && (oLeft.m_ui32SampleCount == oRight.m_ui32SampleCount)
120  && (oLeft.m_ui32SampleRateHz == oRight.m_ui32SampleRateHz);
121 }
122 
130 inline bool operator!=(const tStreamAudioFormat& oLeft, const tStreamAudioFormat& oRight)
131 {
132  return !(oLeft == oRight);
133 }
134 
135 
145 {
146  adtf_util::cString strMetaType;
147  oType.GetMetaTypeName(adtf_string_intf(strMetaType));
149  {
150  set_property<adtf_util::cString>(oType, adtf::streaming::ant::stream_meta_type_audio::FormatName, sFormat.m_strFormatName);
156  }
157  else
158  {
159  RETURN_ERROR(ERR_INVALID_TYPE);
160  }
161 }
162 
172 {
173  adtf_util::cString strMetaType;
174  oType.GetMetaTypeName(adtf_string_intf(strMetaType));
176  {
177  sFormat.m_strFormatName = get_property<adtf_util::cString>(oType, adtf::streaming::ant::stream_meta_type_audio::FormatName, "");
178  sFormat.m_ui32ChannelCount = get_property<uint32_t>(oType, adtf::streaming::ant::stream_meta_type_audio::ChannelCount, 0);
179  sFormat.m_ui32SampleRateHz = get_property<uint32_t>(oType, adtf::streaming::ant::stream_meta_type_audio::SampleRateHz, 0);
180  sFormat.m_ui32BitsPerSample = get_property<uint32_t>(oType, adtf::streaming::ant::stream_meta_type_audio::BitsPerSample, 0);
181  sFormat.m_ui32SampleCount = get_property<uint32_t>(oType, adtf::streaming::ant::stream_meta_type_audio::SampleCount, 0);
183  }
184  else
185  {
186  RETURN_ERROR(ERR_INVALID_TYPE);
187  }
188 }
194 ADTF3_DEPRECATED("Use adtf::ucom::make_object_ptr<stream_type_audio<>>() instead!")
196 {
197  return ucom::ant::make_object_ptr<adtf::streaming::ant::cStreamType>(adtf::streaming::ant::stream_meta_type_audio());
198 }
199 
206 ADTF3_DEPRECATED("Use adtf::ucom::make_object_ptr<stream_type_audio<>>(const tStreamAudioFormat&) instead!")
208 {
209  auto oCreatedType =
210  ucom::ant::make_object_ptr<adtf::streaming::ant::cStreamType>(adtf::streaming::ant::stream_meta_type_audio());
211  THROW_IF_FAILED(set_stream_type_audio_format(*oCreatedType, sFormat));
212  return oCreatedType;
213 }
214 
215 } //namespace lucky
216 
217 namespace penguin
218 {
226 template<typename T = lucky::tStreamAudioFormat>
228 {
229  static_assert(std::is_same_v<lucky::tStreamAudioFormat, T>,
230  "Currently only T=lucky::tStreamAudioFormat is possible."
231  "To support your own type you need to specialize this template stream_type_audio<T>");
232 
233 public:
236  {
237  }
238  stream_type_audio(const T& sAudioFormat):
240  {
242  }
243 };
244 } // namespace penguin
245 
252 
253 }
254 }
255 
256 
Copyright © Audi Electronics Venture GmbH.
#define ADTF3_DEPRECATED(_depr_message_)
Mark a function or variable as deprecated.
A common result class usable as return value throughout.
Property property implementation template.
Definition: property.h:380
Defines access methods for the interface of a Stream Type - see also Stream Type and Stream Meta Type...
virtual tResult GetMetaTypeName(base::ant::IString &&strTypeName) const =0
Get the meta type name of this instance.
Default StreamType implementation.
Definition: streamtype.h:282
Generator template to create an instance of a ant::IStreamType class for ant::stream_meta_type_audio ...
Base object pointer to realize binary compatible reference counting in interface methods.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
Definition: string.h:2772
ucom::ant::object_ptr< ant::IStreamType > create_adtf_audio_stream_type()
Convinience functionality to create a stream type audio - see Stream Meta Type "adtf/audio".
tResult set_stream_type_audio_format(IStreamType &oType, const tStreamAudioFormat &sFormat)
sets the audio format properties within the stream type if meta type "adtf/audio" is set
bool operator==(const tStreamAudioFormat &oLeft, const tStreamAudioFormat &oRight)
is equal operator to compare tStreamAudioFormat
bool operator!=(const tStreamAudioFormat &oLeft, const tStreamAudioFormat &oRight)
is not equal operator to compare tStreamAudioFormat
tResult get_stream_type_audio_format(tStreamAudioFormat &sFormat, const IStreamType &oType)
retrievs the audio format from the properties of the stream type if meta type "adtf/audio" is set.
ant::object_ptr< T > object_ptr
Alias always bringing the latest version of ant::object_ptr into scope.
Definition: object_ptr.h:408
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
Copyright © Audi Electronics Venture GmbH.
#define adtf_string_intf(__string__)
The adtf_string_intf Macro helps to easily create a rvalue reference of a adtf::util::cString.
Definition: string_intf.h:303
Use this Stream Meta Type for describing a audio stream with samples and sample rate.
static void SetProperties(const adtf::ucom::iobject_ptr< adtf::base::IProperties > &pProperties)
Sets the default properties to the given pProperties.
static constexpr const tChar *const FormatName
Name for the Property of the format name.
static constexpr const tChar *const MetaTypeName
StreamMetaTypeName for audiotype (audio stream).
static constexpr const tChar *const ChannelCount
Name for the Property for the amount of channels.
static constexpr const tChar *const BitsPerSample
Name for the Property for number of bits per sample.
static constexpr const tChar *const SampleCount
Name for the Property for number of samples.
static constexpr const tChar *const SampleRateHz
Name for the Property for the sample rate in hz.
unsigned int m_ui32BitsPerSample
bits per audio sample
unsigned int m_ui32SampleCount
audio sample count
unsigned int m_ui32SampleRateHz
audio sample rate in Hz
adtf_util::cString m_strFormatName
choose a format name.
#define THROW_IF_FAILED(s)
throws if the expression returns a failed tResult