From: Sangchul Lee Date: Fri, 27 May 2022 03:22:14 +0000 (+0900) Subject: webrtc_source: Fix invalid return value X-Git-Tag: submit/tizen/20220602.125915~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e92b1a70230f5fd67eb81bb02724b88c5669da7;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_source: Fix invalid return value Some cases returned ERROR_NONE despite error situations. These are fixed. [Version] 0.3.111 [Issue Type] Bug fix Change-Id: I1be17af6f644754a8181f5fe8c349b99edf75c14 Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index e5590360..ea3c57e2 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.110 +Version: 0.3.111 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 00f23495..c96352a7 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -1312,7 +1312,7 @@ static GstElement *__find_element_in_bin(GstBin *bin, const gchar *name) static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) { - int ret = WEBRTC_ERROR_NONE; + int ret; GstElement *screensrc; GstElement *videoconvert; GstElement *videotestsrc; @@ -1362,7 +1362,7 @@ static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) APPEND_ELEMENT(element_list, videoconvert); } - if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, false)) != WEBRTC_ERROR_NONE) + if (__create_rest_of_elements(webrtc, source, true, &element_list, false) != WEBRTC_ERROR_NONE) goto exit; if (!__add_elements_to_bin(source->bin, switch_src_list)) { @@ -1377,22 +1377,16 @@ static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) return WEBRTC_ERROR_INVALID_OPERATION; } - if (!__link_switch_srcs(videoswitch, switch_src_list)) { - ret = WEBRTC_ERROR_INVALID_OPERATION; + if (!__link_switch_srcs(videoswitch, switch_src_list)) goto exit_with_remove_from_bin; - } - if (!__link_elements(element_list)) { - ret = WEBRTC_ERROR_INVALID_OPERATION; + if (!__link_elements(element_list)) goto exit_with_remove_from_bin; - } - if (!(capsfilter = gst_bin_get_by_name(source->bin, ELEMENT_NAME_RTP_CAPSFILTER))) { - ret = WEBRTC_ERROR_INVALID_OPERATION; + if (!(capsfilter = gst_bin_get_by_name(source->bin, ELEMENT_NAME_RTP_CAPSFILTER))) goto exit_with_remove_from_bin; - } - ret = _set_ghost_pad_target(src_pad, capsfilter, true); - if (ret != WEBRTC_ERROR_NONE) + + if (_set_ghost_pad_target(src_pad, capsfilter, true) != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; __add_probe_to_pad_for_pause(source, AV_IDX_VIDEO, src_pad, __payloaded_data_probe_cb); @@ -1407,16 +1401,15 @@ exit_with_remove_from_bin: __remove_elements_from_bin(source->bin, element_list); SAFE_G_LIST_FREE(switch_src_list); SAFE_G_LIST_FREE(element_list); - return ret; + return WEBRTC_ERROR_INVALID_OPERATION; exit: SAFE_G_LIST_FREE_FULL(switch_src_list, gst_object_unref); SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref); - return ret; + return WEBRTC_ERROR_INVALID_OPERATION; } static int __build_rest_of_videosrc(webrtc_s *webrtc, GstPad *src_pad, GstElement *videosrc_element, webrtc_gst_slot_s *source) { - int ret = WEBRTC_ERROR_NONE; GList *element_list = NULL; GstElement *capsfilter; const ini_item_media_source_s *ini_source; @@ -1440,7 +1433,7 @@ static int __build_rest_of_videosrc(webrtc_s *webrtc, GstPad *src_pad, GstElemen if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(videosrc_element)), "empty-buffer-timeout")) g_object_set(G_OBJECT(videosrc_element), "empty-buffer-timeout", 0, NULL); - if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, false)) != WEBRTC_ERROR_NONE) + if (__create_rest_of_elements(webrtc, source, true, &element_list, false) != WEBRTC_ERROR_NONE) goto exit; if (!__add_elements_to_bin(source->bin, element_list)) { @@ -1448,17 +1441,13 @@ static int __build_rest_of_videosrc(webrtc_s *webrtc, GstPad *src_pad, GstElemen return WEBRTC_ERROR_INVALID_OPERATION; } - if (!__link_elements(element_list)) { - ret = WEBRTC_ERROR_INVALID_OPERATION; + if (!__link_elements(element_list)) goto exit_with_remove_from_bin; - } - if (!(capsfilter = gst_bin_get_by_name(source->bin, ELEMENT_NAME_RTP_CAPSFILTER))) { - ret = WEBRTC_ERROR_INVALID_OPERATION; + if (!(capsfilter = gst_bin_get_by_name(source->bin, ELEMENT_NAME_RTP_CAPSFILTER))) goto exit_with_remove_from_bin; - } - ret = _set_ghost_pad_target(src_pad, capsfilter, true); - if (ret != WEBRTC_ERROR_NONE) + + if (_set_ghost_pad_target(src_pad, capsfilter, true) != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; __add_probe_to_pad_for_pause(source, AV_IDX_VIDEO, src_pad, __payloaded_data_probe_cb); @@ -1470,10 +1459,10 @@ static int __build_rest_of_videosrc(webrtc_s *webrtc, GstPad *src_pad, GstElemen exit_with_remove_from_bin: __remove_elements_from_bin(source->bin, element_list); SAFE_G_LIST_FREE(element_list); - return ret; + return WEBRTC_ERROR_INVALID_OPERATION; exit: SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref); - return ret; + return WEBRTC_ERROR_INVALID_OPERATION; } static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) @@ -1503,7 +1492,6 @@ static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) static int __build_rest_of_audiosrc(webrtc_s *webrtc, GstPad *src_pad, GstElement *audiosrc_element, webrtc_gst_slot_s *source) { - int ret = WEBRTC_ERROR_NONE; GList *element_list = NULL; GstElement *volume; GstElement *capsfilter; @@ -1530,7 +1518,7 @@ static int __build_rest_of_audiosrc(webrtc_s *webrtc, GstPad *src_pad, GstElemen source->av[AV_IDX_AUDIO].inbandfec = ini_source->use_inbandfec; source->av[AV_IDX_AUDIO].packet_loss_percentage = ini_source->packet_loss_percentage; - if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, true)) != WEBRTC_ERROR_NONE) + if (__create_rest_of_elements(webrtc, source, true, &element_list, true) != WEBRTC_ERROR_NONE) goto exit; if (!__add_elements_to_bin(source->bin, element_list)) { @@ -1538,17 +1526,13 @@ static int __build_rest_of_audiosrc(webrtc_s *webrtc, GstPad *src_pad, GstElemen return WEBRTC_ERROR_INVALID_OPERATION; } - if (!__link_elements(element_list)) { - ret = WEBRTC_ERROR_INVALID_OPERATION; + if (!__link_elements(element_list)) goto exit_with_remove_from_bin; - } - if (!(capsfilter = gst_bin_get_by_name(source->bin, ELEMENT_NAME_RTP_CAPSFILTER))) { - ret = WEBRTC_ERROR_INVALID_OPERATION; + if (!(capsfilter = gst_bin_get_by_name(source->bin, ELEMENT_NAME_RTP_CAPSFILTER))) goto exit_with_remove_from_bin; - } - ret = _set_ghost_pad_target(src_pad, capsfilter, true); - if (ret != WEBRTC_ERROR_NONE) + + if (_set_ghost_pad_target(src_pad, capsfilter, true) != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; __add_probe_to_pad_for_pause(source, AV_IDX_AUDIO, src_pad, __payloaded_data_probe_cb); @@ -1560,10 +1544,10 @@ static int __build_rest_of_audiosrc(webrtc_s *webrtc, GstPad *src_pad, GstElemen exit_with_remove_from_bin: __remove_elements_from_bin(source->bin, element_list); SAFE_G_LIST_FREE(element_list); - return ret; + return WEBRTC_ERROR_INVALID_OPERATION; exit: SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref); - return ret; + return WEBRTC_ERROR_INVALID_OPERATION; } static int __build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, bool use_mic) @@ -1705,8 +1689,7 @@ static int __build_filesrc_bin(webrtc_gst_slot_s *source, media_type_e media_typ if (!__sync_elements_state_with_parent(element_list)) goto exit_with_remove_from_bin; - ret = _set_ghost_pad_target(src_pad, capsfilter, true); - if (ret != WEBRTC_ERROR_NONE) + if (_set_ghost_pad_target(src_pad, capsfilter, true) != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; __add_probe_to_pad_for_pause(source, av_idx, src_pad, __payloaded_data_probe_cb);