Add effect methods information to AudioInfo
[platform/core/api/audio-io.git] / src / cpp / CAudioInfo.cpp
index f35f3f4..367fd4f 100644 (file)
@@ -19,6 +19,8 @@
 #include <string.h>
 #include "CAudioIODef.h"
 
+#include <sound_manager.h>
+#include <sound_manager_internal.h>
 
 using namespace std;
 using namespace tizen_media_audio;
@@ -32,7 +34,10 @@ CAudioInfo::CAudioInfo() :
     __mChannel(EChannel::CHANNEL_MONO),
     __mSampleType(ESampleType::SAMPLE_TYPE_U8),
     __mAudioType(EAudioType::AUDIO_IN_TYPE_MEDIA),
-    __mAudioIndex(-1) {
+    __mAudioIndex(-1),
+    __mEffectMethodWithReference((sound_effect_method_with_reference_e)0),
+    __mEffectMethodReferenceDeviceId(0),
+    __mEffectMethod(0) {
 }
 
 CAudioInfo::CAudioInfo(unsigned int sampleRate, EChannel channel, ESampleType sampleType, EAudioType audioType, int audioIndex) :
@@ -40,7 +45,10 @@ CAudioInfo::CAudioInfo(unsigned int sampleRate, EChannel channel, ESampleType sa
     __mChannel(channel),
     __mSampleType(sampleType),
     __mAudioType(audioType),
-    __mAudioIndex(audioIndex) {
+    __mAudioIndex(audioIndex),
+    __mEffectMethodWithReference((sound_effect_method_with_reference_e)0),
+    __mEffectMethodReferenceDeviceId(0),
+    __mEffectMethod(0) {
     // Check to invalid AudioInfo
     if (sampleRate < CAudioInfo::MIN_SYSTEM_SAMPLERATE ||
         sampleRate > CAudioInfo::MAX_SYSTEM_SAMPLERATE)
@@ -121,6 +129,46 @@ int CAudioInfo::getSampleSize() noexcept {
     return bytes_in_sample * static_cast<int>(__mChannel);
 }
 
+void CAudioInfo::setEffectMethod(int method) noexcept {
+    __mEffectMethod = method;
+}
+
+std::string CAudioInfo::getEffectMethod() noexcept {
+    std::string method;
+
+    if (__mEffectMethod & SOUND_EFFECT_NOISE_SUPPRESSION_VOIP)
+        method += "ns-rnnoise,";
+
+    if (__mEffectMethod & SOUND_EFFECT_NOISE_SUPPRESSION_VOICE_RECOGNITION)
+        method += "ns-pse,";
+
+    if (__mEffectMethod & SOUND_EFFECT_NOISE_SUPPRESSION_DOORBELL)
+        method += "ns-srid,";
+
+    if (__mEffectMethod & SOUND_EFFECT_AUTOMATIC_GAIN_CONTROL_CAPTURE)
+        method += "agc-speex,";
+
+    return method;
+}
+
+void CAudioInfo::setEffectMethodWithReference(sound_effect_method_with_reference_e method, int id) noexcept {
+    __mEffectMethodWithReference = method;
+    __mEffectMethodReferenceDeviceId = id;
+}
+
+std::pair<std::string, int> CAudioInfo::getEffectMethodWithReference() noexcept {
+    std::string method;
+
+    if (__mEffectMethodWithReference == SOUND_EFFECT_REFERENCE_COPY)
+        method += "reference_copy,";
+    else if (__mEffectMethodWithReference == SOUND_EFFECT_ACOUSTIC_ECHO_CANCEL_SPEEX)
+        method += "aec-speex,";
+    else if (__mEffectMethodWithReference == SOUND_EFFECT_ACOUSTIC_ECHO_CANCEL_WEBRTC)
+        method += "aec-webrtc,";
+
+    return make_pair(method, __mEffectMethodReferenceDeviceId);
+}
+
 const char* CAudioInfo::getConvertedStreamType() {
     if (__mAudioType < CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA ||
         __mAudioType >= CAudioInfo::EAudioType::AUDIO_TYPE_MAX)
@@ -150,4 +198,4 @@ CAudioInfo::EAudioType CAudioInfo::convertOutputStreamTypeToAudioType(const char
     }
     THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE,
                            "The streamType of output is not supported [streamType:%s]", streamType);
-}
\ No newline at end of file
+}