webrtc_private: Change to use effect_method API 27/296227/2 accepted/tizen/unified/20230727.173034
authorJaechul Lee <jcsing.lee@samsung.com>
Mon, 24 Jul 2023 06:07:03 +0000 (15:07 +0900)
committerJaechul Lee <jcsing.lee@samsung.com>
Tue, 25 Jul 2023 06:50:04 +0000 (15:50 +0900)
AEC APIs in sound-manager have been changed.

[Version] 0.4.16
[Issue Type] Feature

Change-Id: Idd9a9988b80aa47e72639e14724d40ce0a4406b7
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_private.c
src/webrtc_sink.c
src/webrtc_source.c
src/webrtc_source_loopback.c
test/webrtc_test.c

index 19116c7747cf69fd24a5236264bf974b77baa8e8..1efae2d0a6169ff42ba870ec5e44d906e509e736 100644 (file)
@@ -302,6 +302,8 @@ typedef enum {
 #define SIGNALING_MESSAGE_PREFIX_ICE_CANDIDATE       "ICE_CANDIDATE"
 #define SIGNALING_MESSAGE_PREFIX_ERROR               "ERROR"
 
+#define STREAM_NO_REFERENCE_DEVICE                   0
+
 typedef enum {
        MEDIA_TYPE_AUDIO = 0x01,
        MEDIA_TYPE_VIDEO = 0x02,
index 8298e48fcfc794edd9afce1b579c5a3f4fe10e85..aecd121c813c66084f1124af496b31206687348f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.4.15
+Version:    0.4.16
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 719b42a83bd402eaedcf7134f95a607e5aab6ea3..10c39a12efebc3e80be50a66faf32b7f888e25cb 100644 (file)
@@ -2164,7 +2164,7 @@ int _apply_stream_info(GstElement *element, const char *stream_type, int stream_
        GstStructure *structure;
        g_autofree gchar *prop = NULL;
        g_autofree gchar *prop_with_aec = NULL;
-       bool aec = (aec_ref_device_id != SOUND_MANAGER_STREAM_NO_REFERENCE_DEVICE);
+       bool aec = false;
 
        RET_VAL_IF(element == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "element is NULL");
        RET_VAL_IF(stream_type == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "stream_type is NULL");
@@ -2172,9 +2172,10 @@ int _apply_stream_info(GstElement *element, const char *stream_type, int stream_
                WEBRTC_ERROR_INVALID_OPERATION, "could not find 'stream-properties'");
 
        prop = g_strdup_printf("props,%s=%s, %s=%d", PA_PROP_MEDIA_ROLE, stream_type, PA_PROP_MEDIA_PARENT_ID, stream_index);
-       if (aec) {
+       if (aec_ref_device_id > STREAM_NO_REFERENCE_DEVICE) {
                prop_with_aec = g_strdup_printf("%s, %s=%s, %s=%d",
                        prop, PA_PROP_MEDIA_PREPROCESSOR_METHOD, "webrtc", PA_PROP_MEDIA_ECHO_CANCEL_REFERENCE_DEVICE, aec_ref_device_id);
+               aec = true;
        }
 
        RET_VAL_IF(!(structure = gst_structure_from_string(aec ? prop_with_aec : prop, NULL)),
index 59328adc9e8da0e4cee38079f922244d4a3b9e13..7fdde98a184c112ad12a32512f519e49f6479fef 100644 (file)
@@ -319,7 +319,7 @@ static int __build_audiosink(webrtc_s *webrtc, GstElement *decodebin, GstPad *sr
                if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(audiosink)), "stream-properties")) {
                        if (sink->sound_stream_info.type) {
                                ret = _apply_stream_info(audiosink, sink->sound_stream_info.type, sink->sound_stream_info.index,
-                                       SOUND_MANAGER_STREAM_NO_REFERENCE_DEVICE);
+                                       STREAM_NO_REFERENCE_DEVICE);
                                if (ret != WEBRTC_ERROR_NONE)
                                        goto exit;
                        }
index 5a6f4343b5c0135bf2007c4fb922ee46518a1db3..db575a649c9583b7f5cb049941bf6bbc57d3d530 100644 (file)
@@ -969,8 +969,8 @@ int _set_sound_stream_info(webrtc_s *webrtc, unsigned int source_id, sound_strea
        bool available = false;
        char *stream_type;
        int stream_index;
-       int aec_ref_device_id = 0;
-       sound_acoustic_echo_cancel_type_e aec_type;
+       int aec_ref_device_id = STREAM_NO_REFERENCE_DEVICE;
+       sound_effect_method_with_reference_e method;
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
@@ -982,7 +982,10 @@ int _set_sound_stream_info(webrtc_s *webrtc, unsigned int source_id, sound_strea
 
        sound_manager_get_type_from_stream_information(stream_info, &stream_type);
        sound_manager_get_index_from_stream_information(stream_info, &stream_index);
-       sound_manager_get_echo_cancel_reference_device(stream_info, &aec_ref_device_id, &aec_type);
+
+       ret = sound_manager_get_effect_method_with_reference(stream_info, &method, &aec_ref_device_id);
+       if (ret == SOUND_MANAGER_ERROR_NONE)
+               LOG_INFO("Got effect method information. method[%d], aec_ref_device_id[%d]", method, aec_ref_device_id);
 
        ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_WEBRTC, &available);
        if (ret != SOUND_MANAGER_ERROR_NONE) {
@@ -995,8 +998,8 @@ int _set_sound_stream_info(webrtc_s *webrtc, unsigned int source_id, sound_strea
                return WEBRTC_ERROR_INVALID_PARAMETER;
        }
 
-       LOG_INFO("webrtc[%p], source_id[%u], stream_info[%p, type:%s, index:%d, aec_ref_device_id:%d, aec_type:%d]",
-               webrtc, source_id, stream_info, stream_type, stream_index, aec_ref_device_id, aec_type);
+       LOG_INFO("webrtc[%p], source_id[%u], stream_info[%p, type:%s, index:%d]",
+               webrtc, source_id, stream_info, stream_type, stream_index);
 
        return _apply_stream_info(element, stream_type, stream_index, aec_ref_device_id);
 }
index a9a1efe5c21ae638f106f0503fce8a0f86f952e7..7455f6e6a0c1dd44669685b0c2d932fababac5d4 100644 (file)
@@ -50,7 +50,7 @@ static int __build_loopback_audiosink(webrtc_gst_slot_s *source, GstElement *lin
        if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(audiosink)), "stream-properties")) {
                if (source->sound_stream_info.type) {
                        ret = _apply_stream_info(audiosink, source->sound_stream_info.type, source->sound_stream_info.index,
-                               SOUND_MANAGER_STREAM_NO_REFERENCE_DEVICE);
+                               STREAM_NO_REFERENCE_DEVICE);
                        if (ret != WEBRTC_ERROR_NONE)
                                goto exit;
                }
index 85c99882f5dced60cd69e5440eedefc8d725c1fb..feb3a986ff7f34f64e86c5a54e53627186b6f9ef 100644 (file)
@@ -382,7 +382,7 @@ static void __set_aec_reference_device(sound_stream_info_h stream_info)
 
                found = true;
 
-               ret = sound_manager_set_echo_cancel_reference_device(stream_info, device, SOUND_ACOUSTIC_ECHO_CANCEL_VOICE_CALL);
+               ret = sound_manager_set_effect_method_with_reference(stream_info, SOUND_EFFECT_ACOUSTIC_ECHO_CANCEL_WEBRTC, device);
                if (ret != SOUND_MANAGER_ERROR_NONE) {
                        g_printerr("failed to sound_manager_set_echo_cancel_reference_device()\n");
                } else {