Add effect methods information to AudioInfo
[platform/core/api/audio-io.git] / src / cpp / CAudioInfo.cpp
index f5d2666..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;
@@ -33,8 +35,9 @@ CAudioInfo::CAudioInfo() :
     __mSampleType(ESampleType::SAMPLE_TYPE_U8),
     __mAudioType(EAudioType::AUDIO_IN_TYPE_MEDIA),
     __mAudioIndex(-1),
-    __mReferenceDeviceId(0),
-    __mNoiseSuppression(false) {
+    __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) :
@@ -43,8 +46,9 @@ CAudioInfo::CAudioInfo(unsigned int sampleRate, EChannel channel, ESampleType sa
     __mSampleType(sampleType),
     __mAudioType(audioType),
     __mAudioIndex(audioIndex),
-    __mReferenceDeviceId(0),
-    __mNoiseSuppression(false) {
+    __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)
@@ -125,37 +129,44 @@ int CAudioInfo::getSampleSize() noexcept {
     return bytes_in_sample * static_cast<int>(__mChannel);
 }
 
-void CAudioInfo::bindEchoCancelReferenceDeviceId(int id, sound_acoustic_echo_cancel_type_e type) {
-    if (type == SOUND_ACOUSTIC_ECHO_CANCEL_VOICE_CALL)
-        __mProcessorProperty += "webrtc,";
-    else if (type == SOUND_ACOUSTIC_ECHO_CANCEL_REFERENCE_COPY)
-        __mProcessorProperty += "reference_copy,";
-    else
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE,
-                               "The echo cancel is not supported [type:%d]", type);
+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,";
 
-    __mReferenceDeviceId = id;
+    if (__mEffectMethod & SOUND_EFFECT_NOISE_SUPPRESSION_DOORBELL)
+        method += "ns-srid,";
+
+    if (__mEffectMethod & SOUND_EFFECT_AUTOMATIC_GAIN_CONTROL_CAPTURE)
+        method += "agc-speex,";
+
+    return method;
 }
 
-int CAudioInfo::getEchoCancelReferenceDeviceId() noexcept {
-    return __mReferenceDeviceId;
+void CAudioInfo::setEffectMethodWithReference(sound_effect_method_with_reference_e method, int id) noexcept {
+    __mEffectMethodWithReference = method;
+    __mEffectMethodReferenceDeviceId = id;
 }
 
-void CAudioInfo::setNoiseSuppression(bool enable, sound_noise_suppression_type_e type) {
-    if (type == SOUND_NOISE_SUPPRESSION_VOICE_CALL) {
-        __mProcessorProperty += "rnnoise,";
-    } else if (type == SOUND_NOISE_SUPPRESSION_VOICE_RECOGNITION) {
-        __mProcessorProperty += "pse,";
-    } else {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE,
-                               "The noise suppression type is not supported [type:%d]", type);
-    }
+std::pair<std::string, int> CAudioInfo::getEffectMethodWithReference() noexcept {
+    std::string method;
 
-    __mNoiseSuppression = enable;
-}
+    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,";
 
-std::string& CAudioInfo::getProcessorProperty() noexcept {
-    return __mProcessorProperty;
+    return make_pair(method, __mEffectMethodReferenceDeviceId);
 }
 
 const char* CAudioInfo::getConvertedStreamType() {