From: Sangchul Lee Date: Thu, 19 May 2022 03:21:27 +0000 (+0900) Subject: Add support for mic source echo cancellation X-Git-Tag: submit/tizen/20220602.125915~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8b44cf3d1009f65913f906cc63344f9d69f4a1f;p=platform%2Fcore%2Fapi%2Fwebrtc.git Add support for mic source echo cancellation [Version] 0.3.112 [Issue Type] New feature Change-Id: I5bb9e9a604b67aef7011ed13c9caf7d50fe81d73 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index a1e560fd..ed1de41f 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -626,7 +626,7 @@ int _set_video_resolution(webrtc_s *webrtc, unsigned int source_id, int width, i int _get_video_resolution(webrtc_s *webrtc, unsigned int source_id, int *width, int *height); int _set_video_framerate(webrtc_s *webrtc, unsigned int source_id, int framerate); int _get_video_framerate(webrtc_s *webrtc, unsigned int source_id, int *framerate); -int _apply_stream_info(GstElement *element, const char *stream_type, int stream_index); +int _apply_stream_info(GstElement *element, const char *stream_type, int stream_index, int aec_ref_device_id); int _set_sound_stream_info(webrtc_s *webrtc, unsigned int source_id, sound_stream_info_h stream_info); int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h format); bool _check_if_format_is_set_to_packet_sources(webrtc_s *webrtc); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index ea3c57e2..15e3e0e6 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.3.111 +Version: 0.3.112 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 85276d8c..5c93d947 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -2199,21 +2199,28 @@ int _webrtc_stop(webrtc_s *webrtc) return ret; } -int _apply_stream_info(GstElement *element, const char *stream_type, int stream_index) +int _apply_stream_info(GstElement *element, const char *stream_type, int stream_index, int aec_ref_device_id) { GstStructure *structure; - char values[64] = {'\0',}; + g_autofree gchar *prop = NULL; + g_autofree gchar *prop_with_aec = NULL; + bool aec = (aec_ref_device_id != SOUND_MANAGER_STREAM_NO_REFERENCE_DEVICE); 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"); RET_VAL_IF(!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(element)), "stream-properties"), WEBRTC_ERROR_INVALID_OPERATION, "could not find 'stream-properties'"); - snprintf(values, sizeof(values) - 1, "props,%s=%s, %s=%d", PA_PROP_MEDIA_ROLE, stream_type, PA_PROP_MEDIA_PARENT_ID, stream_index); - RET_VAL_IF(!(structure = gst_structure_from_string(values, NULL)), - WEBRTC_ERROR_INVALID_OPERATION, "failed to gst_structure_from_string(), [%s]", values); + prop = g_strdup_printf("props,%s=%s, %s=%d", PA_PROP_MEDIA_ROLE, stream_type, PA_PROP_MEDIA_PARENT_ID, stream_index); + if (aec) { + prop_with_aec = g_strdup_printf("%s, %s=%s, %s=%d", + prop, PA_PROP_MEDIA_ECHO_CANCEL_METHOD, "default", PA_PROP_MEDIA_ECHO_CANCEL_REFERENCE_DEVICE, aec_ref_device_id); + } + + RET_VAL_IF(!(structure = gst_structure_from_string(aec ? prop_with_aec : prop, NULL)), + WEBRTC_ERROR_INVALID_OPERATION, "failed to gst_structure_from_string(), [%s]", aec ? prop_with_aec : prop); - LOG_INFO("stream-properties[%s]", values); + LOG_INFO("stream-properties[%s]", aec ? prop_with_aec : prop); g_object_set(G_OBJECT(element), "stream-properties", structure, NULL); gst_structure_free(structure); diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index 11b0077b..9c1feb22 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -250,7 +250,8 @@ 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); + ret = _apply_stream_info(audiosink, sink->sound_stream_info.type, sink->sound_stream_info.index, + SOUND_MANAGER_STREAM_NO_REFERENCE_DEVICE); if (ret != WEBRTC_ERROR_NONE) /* FIXME: unref all the created elements */ return WEBRTC_ERROR_INVALID_OPERATION; } diff --git a/src/webrtc_source.c b/src/webrtc_source.c index c96352a7..239c4f07 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -2993,6 +2993,7 @@ 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; 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"); @@ -3004,6 +3005,7 @@ 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); ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_WEBRTC, &available); if (ret != SOUND_MANAGER_ERROR_NONE) { @@ -3016,9 +3018,10 @@ 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]", webrtc, source_id, stream_info, stream_type, stream_index); + LOG_INFO("webrtc[%p], source_id[%u], stream_info[%p, type:%s, index:%d, aec_ref_device_id:%d]", + webrtc, source_id, stream_info, stream_type, stream_index, aec_ref_device_id); - return _apply_stream_info(element, stream_type, stream_index); + return _apply_stream_info(element, stream_type, stream_index, aec_ref_device_id); } int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h format) @@ -3826,7 +3829,8 @@ 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); + ret = _apply_stream_info(audiosink, source->sound_stream_info.type, source->sound_stream_info.index, + SOUND_MANAGER_STREAM_NO_REFERENCE_DEVICE); if (ret != WEBRTC_ERROR_NONE) goto exit; }