webrtc_source: Save audio mute value if required element does not exist 99/275999/2
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 8 Jun 2022 06:59:36 +0000 (15:59 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 9 Jun 2022 07:35:51 +0000 (16:35 +0900)
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 <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_source.c

index 3163f10995e3f712f698b9a1310b5468523c4ed2..a93bd5148517d3f5cd8fcd9776a641e1fa298aad 100644 (file)
@@ -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
index fed43ab3148b3e0b5a8d4d12b606ffb2aca8c583..eb2c5995e12ec04e248a02c03e9963bf9a56799c 100644 (file)
@@ -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);