#ifdef __cplusplus
+#include <type_traits>
+#include <string>
+#include <optional>
+#include <tuple>
+
+#include <sound_manager.h>
+#include <sound_manager_internal.h>
namespace tizen_media_audio {
+ template<typename E>
+ constexpr auto to_integral(E e) -> typename std::underlying_type<E>::type {
+ return static_cast<typename std::underlying_type<E>::type>(e);
+ }
/**
* Audio Information
*/
class CAudioInfo {
public:
- const static unsigned int MIN_SYSTEM_SAMPLERATE = 8000;
- const static unsigned int MAX_SYSTEM_SAMPLERATE = 48000;
-
- enum EChannel {
+ enum class EChannel : unsigned int {
CHANNEL_MONO = 1, /**< 1 channel, mono */
CHANNEL_STEREO, /**< 2 channel, stereo */
+ CHANNEL_MULTI_3, /**< 3 channel */
+ CHANNEL_MULTI_4, /**< 4 channel */
+ CHANNEL_MULTI_5, /**< 5 channel */
+ CHANNEL_MULTI_6, /**< 6 channel */
+ CHANNEL_MULTI_7, /**< 7 channel */
+ CHANNEL_MULTI_8, /**< 8 channel */
+ CHANNEL_MULTI_9, /**< 9 channel */
+ CHANNEL_MULTI_10, /**< 10 channel */
+ CHANNEL_MULTI_11, /**< 11 channel */
+ CHANNEL_MULTI_12, /**< 12 channel */
+ CHANNEL_MULTI_13, /**< 13 channel */
+ CHANNEL_MULTI_14, /**< 14 channel */
+ CHANNEL_MULTI_15, /**< 15 channel */
+ CHANNEL_MULTI_16, /**< 16 channel */
CHANNEL_MAX
};
- enum ESampleType {
+ enum class ESampleType : unsigned int {
SAMPLE_TYPE_U8 = 1, /**< Unsigned 8-bit audio samples */
SAMPLE_TYPE_S16_LE, /**< Signed 16-bit audio samples */
+ SAMPLE_TYPE_S24_LE, /**< Signed 24-bit audio samples */
+ SAMPLE_TYPE_S24_32_LE, /**< Signed 24-bit packed in 32-bit audio samples */
+ SAMPLE_TYPE_S32_LE, /**< Signed 32-bit audio samples */
SAMPLE_TYPE_MAX
};
- enum EAudioType {
+ enum class EAudioType : unsigned int {
/* Input Type */
AUDIO_IN_TYPE_MEDIA = 0,
//AUDIO_IN_TYPE_SYSTEM,
AUDIO_IN_TYPE_VOICE_RECOGNITION,
//AUDIO_IN_TYPE_RINGTONE_VOIP,
AUDIO_IN_TYPE_VOIP,
+ AUDIO_IN_TYPE_MEDIA_EXTERNAL_ONLY,
//AUDIO_IN_TYPE_RINGTONE_CALL,
//AUDIO_IN_TYPE_VOICE_CALL,
//AUDIO_IN_TYPE_VIDEO_CALL,
//AUDIO_IN_TYPE_RADIO,
AUDIO_IN_TYPE_LOOPBACK,
+ AUDIO_IN_TYPE_VOICE_RECOGNITION_SERVICE,
+ //AUDIO_IN_TYPE_MEDIA_NETWORK_SOURCE,
/* Output Type */
AUDIO_OUT_TYPE_MEDIA,
//AUDIO_OUT_TYPE_VOICE_RECOGNITION,
AUDIO_OUT_TYPE_RINGTONE_VOIP,
AUDIO_OUT_TYPE_VOIP,
+ AUDIO_OUT_TYPE_MEDIA_EXTERNAL_ONLY,
AUDIO_OUT_TYPE_RINGTONE_CALL,
//AUDIO_OUT_TYPE_VOICE_CALL,
//AUDIO_OUT_TYPE_VIDEO_CALL,
//AUDIO_OUT_TYPE_RADIO,
//AUDIO_OUT_TYPE_LOOPBACK,
+ //AUDIO_OUT_TYPE_VOICE_RECOGNITION_SERVICE,
+ AUDIO_OUT_TYPE_MEDIA_NETWORK_SOURCE,
AUDIO_TYPE_MAX
};
- enum EAudioIOState {
+ enum class EAudioIOState : unsigned int {
AUDIO_IO_STATE_NONE, /**< Audio-io handle is not created */
AUDIO_IO_STATE_IDLE, /**< Audio-io handle is created, but not prepared */
AUDIO_IO_STATE_RUNNING, /**< Audio-io handle is ready and the stream is running */
AUDIO_IO_STATE_PAUSED, /**< Audio-io handle is ready and the stream is paused */
+ AUDIO_IO_STATE_MAX
};
- private:
- unsigned int mSampleRate;
- EChannel mChannel;
- ESampleType mSampleType;
- EAudioType mAudioType;
- int mAudioIndex;
+ enum class EAudioDirection : unsigned int {
+ AUDIO_DIRECTION_IN, /**< Audio direction input */
+ AUDIO_DIRECTION_OUT, /**< Audio direction output */
+ AUDIO_DIRECTION_MAX
+ };
+
+ static constexpr auto MIN_SYSTEM_SAMPLERATE = 8000;
+ static constexpr auto MAX_SYSTEM_SAMPLERATE = 192000;
+
+ static constexpr auto MIN_RECORD_VOLUME = 0.0;
+ static constexpr auto MAX_RECORD_VOLUME = 2.0;
+ static constexpr auto DEFAULT_RECORD_VOLUME = 1.0;
+
+ /* Constructor & Destructor */
+ CAudioInfo(unsigned int sampleRate, EChannel channel, ESampleType sampleType, EAudioType audioType, int audioIndex);
+ virtual ~CAudioInfo() = default;
+
+ /* Audio Specification */
+ std::tuple<ESampleType, unsigned int, EChannel> getSpec() const noexcept;
+ int getSampleSize() const noexcept;
+
+ /* Stream Properties */
+ void setAudioIndex(int audioIndex) noexcept;
+ void setAudioTypeByInputStreamType(const char* streamType);
+ void setAudioTypeByOutputStreamType(const char* streamType);
+ EAudioType getAudioType() const noexcept;
+ std::pair<const char*, int> getStreamProperties() const;
- const char *StreamTypeTable[AUDIO_TYPE_MAX] = {
+ /* Effect */
+ void setEffectMethod(int method) noexcept;
+ std::string getEffectNoiseSuppressionMethod() const noexcept;
+ std::string getEffectAutomaticGainControlMethod() const noexcept;
+
+ void setEffectMethodWithReference(sound_effect_method_with_reference_e method, int id) noexcept;
+ std::pair<std::string, int> getEffectMethodWithReference() const noexcept;
+
+ /* Utilities */
+ size_t msToBytes(size_t milliseconds) const noexcept;
+ size_t bytesToMs(size_t bytes) const noexcept;
+
+ private:
+ const char *__STREAM_TYPE_TABLE[(unsigned int)EAudioType::AUDIO_TYPE_MAX] = {
/* Input Type */
"media", /**< AUDIO_IN_TYPE_MEDIA */
- //"system", /**< AUDIO_IN_TYPE_SYSTEM */
- //"alarm", /**< AUDIO_IN_TYPE_ALARM */
- //"notification", /**< AUDIO_IN_TYPE_NOTIFICATION */
- //"emergency", /**< AUDIO_IN_TYPE_EMERGENCY */
- //"voice-information", /**< AUDIO_IN_TYPE_VOICE_INFORMATION */
+ //"system", /**< AUDIO_IN_TYPE_SYSTEM */
+ //"alarm", /**< AUDIO_IN_TYPE_ALARM */
+ //"notification", /**< AUDIO_IN_TYPE_NOTIFICATION */
+ //"emergency", /**< AUDIO_IN_TYPE_EMERGENCY */
+ //"voice-information", /**< AUDIO_IN_TYPE_VOICE_INFORMATION */
"voice-recognition", /**< AUDIO_IN_TYPE_VOICE_RECOGNITION */
- //"ringtone-voip", /**< AUDIO_IN_TYPE_RINGTONE_VOIP */
+ //"ringtone-voip", /**< AUDIO_IN_TYPE_RINGTONE_VOIP */
"voip", /**< AUDIO_IN_TYPE_VOIP */
- //"ringtone-call", /**< AUDIO_IN_TYPE_RINGTONE_CALL */
- //"call-voice", /**< AUDIO_IN_TYPE_VOICE_CALL */
- //"call-video", /**< AUDIO_IN_TYPE_VIDEO_CALL */
- //"radio", /**< AUDIO_IN_TYPE_RADIO */
- "loopback", /**< AUDIO_IN_TYPE_LOOPBACK */
+ "ext-media", /**< AUDIO_IN_TYPE_MEDIA_EXTERNAL_ONLY */
+ //"ringtone-call", /**< AUDIO_IN_TYPE_RINGTONE_CALL */
+ //"call-voice", /**< AUDIO_IN_TYPE_VOICE_CALL */
+ //"call-video", /**< AUDIO_IN_TYPE_VIDEO_CALL */
+ //"radio", /**< AUDIO_IN_TYPE_RADIO */
+ "loopback-mirroring", /**< AUDIO_IN_TYPE_LOOPBACK */
+ "voice-recognition-service", /**< AUDIO_IN_TYPE_VOICE_RECOGNITION_SERVICE */
+ //"network-source-media", /**< AUDIO_IN_TYPE_MEDIA_NETWORK_SOURCE */
/* Output Type */
"media", /**< AUDIO_OUT_TYPE_MEDIA */
"notification", /**< AUDIO_OUT_TYPE_NOTIFICATION */
"emergency", /**< AUDIO_OUT_TYPE_EMERGENCY */
"voice-information", /**< AUDIO_OUT_TYPE_VOICE_INFORMATION */
- //"voice-recognition", /**< AUDIO_OUT_TYPE_VOICE_RECOGNITION */
+ //"voice-recognition", /**< AUDIO_OUT_TYPE_VOICE_RECOGNITION */
"ringtone-voip", /**< AUDIO_OUT_TYPE_RINGTONE_VOIP */
"voip", /**< AUDIO_OUT_TYPE_VOIP */
+ "ext-media", /**< AUDIO_OUT_TYPE_MEDIA_EXTERNAL_ONLY */
"ringtone-call", /**< AUDIO_OUT_TYPE_RINGTONE_CALL */
- //"call-voice", /**< AUDIO_OUT_TYPE_VOICE_CALL */
- //"call-video", /**< AUDIO_OUT_TYPE_VIDEO_CALL */
- //"radio", /**< AUDIO_OUT_TYPE_RADIO */
- //"loopback", /**< AUDIO_OUT_TYPE_LOOPBACK */
+ //"call-voice", /**< AUDIO_OUT_TYPE_VOICE_CALL */
+ //"call-video", /**< AUDIO_OUT_TYPE_VIDEO_CALL */
+ //"radio", /**< AUDIO_OUT_TYPE_RADIO */
+ //"loopback-mirroring", /**< AUDIO_OUT_TYPE_LOOPBACK */
+ //"voice-recognition-service",/**< AUDIO_OUT_TYPE_VOICE_RECOGNITION_SERVICE */
+ "network-source-media", /**< AUDIO_OUT_TYPE_MEDIA_NETWORK_SOURCE */
};
- public:
- /* Constructors */
- CAudioInfo();
- CAudioInfo(unsigned int sampleRate, EChannel channel, ESampleType sampleType, EAudioType audioType, int audioIndex) throw (CAudioError);
-
- /* Setter & Getter */
- unsigned int getSampleRate();
- EChannel getChannel();
- ESampleType getSampleType();
- EAudioType getAudioType();
- void setAudioType(EAudioType AudioType);
- int getAudioIndex();
- void setAudioIndex(int AudioIndex);
- void convertAudioType2StreamType (CAudioInfo::EAudioType audioType, char **streamType);
- void convertInputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType);
- void convertOutputStreamType2AudioType (char *streamType, CAudioInfo::EAudioType *audioType);
+ EAudioType convertInputStreamTypeToAudioType(const char *streamType);
+ EAudioType convertOutputStreamTypeToAudioType(const char *streamType);
+
+ unsigned int __mSampleRate { MAX_SYSTEM_SAMPLERATE };
+ EChannel __mChannel { EChannel::CHANNEL_MAX };
+ ESampleType __mSampleType { ESampleType::SAMPLE_TYPE_MAX };
+ EAudioType __mAudioType { EAudioType::AUDIO_TYPE_MAX };
+ int __mAudioIndex { -1 };
+
+ std::optional<sound_effect_method_with_reference_e>
+ __mEffectMethodWithReference;
+ int __mEffectMethodReferenceDeviceId { 0 };
+ int __mEffectMethod { 0 };
};
+
} /* namespace tizen_media_audio */
#endif