From: Sangchul Lee Date: Wed, 8 Jun 2022 06:59:36 +0000 (+0900) Subject: webrtc_source: Save audio mute value if required element does not exist X-Git-Tag: submit/tizen/20220613.225802~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a92b2c01a90a7ee3324c8a8988b8c2f454caa21d;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_source: Save audio mute value if required element does not exist This is a preparation for setting option values regardless of elements creation or linking pads. [Version] 0.3.120 [Issue Type] Improvement Change-Id: I7747fe7df7a4e5e0cef0ffe21ccad1358bb27d4b Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 3163f109..a93bd514 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.119 +Version: 0.3.120 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index fed43ab3..eb2c5995 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -1532,8 +1532,14 @@ static int __build_rest_of_audiosrc(webrtc_s *webrtc, GstPad *src_pad, GstElemen if (!(volume = _create_element(DEFAULT_ELEMENT_VOLUME, ELEMENT_NAME_VOLUME))) goto exit; + if (!g_object_class_find_property(G_OBJECT_GET_CLASS(volume), "mute")) { + LOG_ERROR("there is no mute property"); + goto exit; + } APPEND_ELEMENT(element_list, volume); + g_object_set(volume, "mute", (gboolean)source->av[AV_IDX_AUDIO].mute, NULL); + source->av[AV_IDX_AUDIO].inbandfec = ini_source->use_inbandfec; source->av[AV_IDX_AUDIO].packet_loss_percentage = ini_source->packet_loss_percentage; @@ -3732,7 +3738,6 @@ int _set_video_mute(webrtc_s *webrtc, unsigned int source_id, bool mute) static int __validate_audio_source_for_mute(webrtc_s *webrtc, unsigned int source_id, webrtc_gst_slot_s **source) { webrtc_gst_slot_s *_source; - GstElement *volume; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0"); @@ -3749,14 +3754,6 @@ static int __validate_audio_source_for_mute(webrtc_s *webrtc, unsigned int sourc return WEBRTC_ERROR_INVALID_PARAMETER; } - volume = gst_bin_get_by_name(_source->bin, ELEMENT_NAME_VOLUME); - RET_VAL_IF(volume == NULL, WEBRTC_ERROR_INVALID_OPERATION, "volume is NULL"); - - if (!g_object_class_find_property(G_OBJECT_GET_CLASS(volume), "mute")) { - LOG_ERROR("there is no mute property"); - return WEBRTC_ERROR_INVALID_OPERATION; - } - if (source) *source = _source; @@ -3767,13 +3764,22 @@ int _set_audio_mute(webrtc_s *webrtc, unsigned int source_id, bool mute) { int ret; webrtc_gst_slot_s *source; + GstElement *volume; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0"); if ((ret = __validate_audio_source_for_mute(webrtc, source_id, &source)) != WEBRTC_ERROR_NONE) return ret; - g_object_set(gst_bin_get_by_name(source->bin, ELEMENT_NAME_VOLUME), "mute", mute, NULL); + if ((volume = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VOLUME))) { + if (!g_object_class_find_property(G_OBJECT_GET_CLASS(volume), "mute")) { + LOG_ERROR("there is no mute property"); + return WEBRTC_ERROR_INVALID_OPERATION; + } + g_object_set(volume, "mute", mute, NULL); + } + + source->av[AV_IDX_AUDIO].mute = mute; LOG_INFO("webrtc[%p] source_id[%u] mute[%d]", webrtc, source_id, mute); @@ -3804,7 +3810,6 @@ int _get_audio_mute(webrtc_s *webrtc, unsigned int source_id, bool *muted) { int ret; webrtc_gst_slot_s *source; - gboolean _muted; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0"); @@ -3812,9 +3817,7 @@ int _get_audio_mute(webrtc_s *webrtc, unsigned int source_id, bool *muted) if ((ret = __validate_audio_source_for_mute(webrtc, source_id, &source)) != WEBRTC_ERROR_NONE) return ret; - g_object_get(gst_bin_get_by_name(source->bin, ELEMENT_NAME_VOLUME), "mute", &_muted, NULL); - - *muted = (bool)_muted; + *muted = source->av[AV_IDX_AUDIO].mute; LOG_INFO("webrtc[%p] source_id[%u] muted[%d]", webrtc, source_id, *muted);