ADTF  3.14.3
streammetatypeaudio.h
Go to the documentation of this file.
1 
7 #pragma once
9 #include <adtfbase/property.h>
10 #include "streamtype.h"
11 
12 namespace adtf
13 {
14 namespace streaming
15 {
16 namespace ant
17 {
18 
19 
29 {
31  static constexpr const tChar *const MetaTypeName = "adtf/audio";
32 
37  static constexpr const tChar *const FormatName = "format_name";
42  static constexpr const tChar *const ChannelCount = "channel_count";
47  static constexpr const tChar *const SampleRateHz = "sample_rate_hz";
52  static constexpr const tChar *const BitsPerSample = "bits_per_sample";
57  static constexpr const tChar *const SampleCount = "sample_count";
58 
64  {
65  pProperties->SetProperty(adtf::base::property<adtf_util::cString>(FormatName, ""));
66  pProperties->SetProperty(adtf::base::property<unsigned int>(ChannelCount, 0));
67  pProperties->SetProperty(adtf::base::property<unsigned int>(SampleRateHz, 0));
68  pProperties->SetProperty(adtf::base::property<unsigned int>(BitsPerSample, 0));
69  pProperties->SetProperty(adtf::base::property<unsigned int>(SampleCount, 0));
70  }
71 };
72 
73 }
74 
75 namespace lucky
76 {
82 {
86  adtf_util::cString m_strFormatName;
90  unsigned int m_ui32ChannelCount = 0;
94  unsigned int m_ui32SampleRateHz = 0;
98  unsigned int m_ui32BitsPerSample = 0;
102  unsigned int m_ui32SampleCount = 0;
103 };
104 
112 inline bool operator==(const tStreamAudioFormat& oLeft, const tStreamAudioFormat& oRight)
113 {
114  return (oLeft.m_strFormatName == oRight.m_strFormatName)
115  && (oLeft.m_ui32BitsPerSample == oRight.m_ui32BitsPerSample)
116  && (oLeft.m_ui32ChannelCount == oRight.m_ui32ChannelCount)
117  && (oLeft.m_ui32SampleCount == oRight.m_ui32SampleCount)
118  && (oLeft.m_ui32SampleRateHz == oRight.m_ui32SampleRateHz);
119 }
120 
128 inline bool operator!=(const tStreamAudioFormat& oLeft, const tStreamAudioFormat& oRight)
129 {
130  return !(oLeft == oRight);
131 }
132 
133 
142 inline tResult set_stream_type_audio_format(IStreamType& oType, const tStreamAudioFormat& sFormat)
143 {
144  adtf_util::cString strMetaType;
145  oType.GetMetaTypeName(adtf_string_intf(strMetaType));
147  {
148  set_property<adtf_util::cString>(oType, adtf::streaming::ant::stream_meta_type_audio::FormatName, sFormat.m_strFormatName);
153  RETURN_NOERROR;
154  }
155  else
156  {
157  RETURN_ERROR(ERR_INVALID_TYPE);
158  }
159 }
160 
169 inline tResult get_stream_type_audio_format(tStreamAudioFormat& sFormat, const IStreamType& oType)
170 {
171  adtf_util::cString strMetaType;
172  oType.GetMetaTypeName(adtf_string_intf(strMetaType));
174  {
175  sFormat.m_strFormatName = get_property<adtf_util::cString>(oType, adtf::streaming::ant::stream_meta_type_audio::FormatName, "");
176  sFormat.m_ui32ChannelCount = get_property<uint32_t>(oType, adtf::streaming::ant::stream_meta_type_audio::ChannelCount, 0);
177  sFormat.m_ui32SampleRateHz = get_property<uint32_t>(oType, adtf::streaming::ant::stream_meta_type_audio::SampleRateHz, 0);
178  sFormat.m_ui32BitsPerSample = get_property<uint32_t>(oType, adtf::streaming::ant::stream_meta_type_audio::BitsPerSample, 0);
179  sFormat.m_ui32SampleCount = get_property<uint32_t>(oType, adtf::streaming::ant::stream_meta_type_audio::SampleCount, 0);
180  RETURN_NOERROR;
181  }
182  else
183  {
184  RETURN_ERROR(ERR_INVALID_TYPE);
185  }
186 }
192 {
193  return ucom::ant::make_object_ptr<adtf::streaming::ant::cStreamType>(adtf::streaming::ant::stream_meta_type_audio());
194 }
195 
202 {
203  auto oCreatedType = create_adtf_audio_stream_type();
204  THROW_IF_FAILED(set_stream_type_audio_format(*oCreatedType, sFormat));
205  return oCreatedType;
206 }
207 
208 } //namespace lucky
209 
210 using ant::stream_meta_type_audio;
211 using lucky::tStreamAudioFormat;
215 
216 }
217 }
218 
219 
Property property implementation template.
Definition: property.h:373
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.
Base object pointer to realize binary compatible reference counting in interface methods.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:158
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.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
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:285
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

Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Thu Jun 9 2022 by doxygen 1.9.1)