From: hj kim Date: Fri, 29 Jul 2022 01:22:22 +0000 (+0900) Subject: remove redundant code X-Git-Tag: submit/tizen/20220902.031026~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2d892e287b05bb1f346340946c37e0d80cc8ad8;p=platform%2Fcore%2Fapi%2Fwebrtc.git remove redundant code Plus, apply tizen coding rule. [Version] 0.3.225 [Issue Type] Refactoring Change-Id: I31ac8625327a316cafdf3db7aeeeffc150d6c512 --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index c771cc62..ae99a937 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.224 +Version: 0.3.225 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source_file.c b/src/webrtc_source_file.c index b63ee8c5..4bc936fa 100644 --- a/src/webrtc_source_file.c +++ b/src/webrtc_source_file.c @@ -171,7 +171,7 @@ static GstElement * __prepare_capsfilter_for_filesrc_pipeline(webrtc_gst_slot_s if (!(capsfilter = _create_element(DEFAULT_ELEMENT_CAPSFILTER, _get_element_name(GET_AV_IDX(is_audio), ELEMENT_CAPSFILTER)))) return NULL; - if(_set_payload_type(source->webrtc, source, GET_AV_IDX(is_audio), NULL) != WEBRTC_ERROR_NONE) { + if (_set_payload_type(source->webrtc, source, GET_AV_IDX(is_audio), NULL) != WEBRTC_ERROR_NONE) { SAFE_GST_OBJECT_UNREF(capsfilter); return NULL; } @@ -605,7 +605,7 @@ static int __create_rest_of_raw_audio_elements_for_filesrc_pipeline(webrtc_s *we if (_create_rest_of_elements(webrtc, source, false, &_element_list, true) != WEBRTC_ERROR_NONE) goto exit; - if(!(fakesink = __prepare_fakesink_for_filesrc_pipeline(source, true))) + if (!(fakesink = __prepare_fakesink_for_filesrc_pipeline(source, true))) goto exit; APPEND_ELEMENT(_element_list, fakesink); diff --git a/src/webrtc_source_mediapacket.c b/src/webrtc_source_mediapacket.c index ef371e53..6ce30bba 100644 --- a/src/webrtc_source_mediapacket.c +++ b/src/webrtc_source_mediapacket.c @@ -255,50 +255,41 @@ static GstCaps *__make_encoded_caps_from_media_format(webrtc_gst_slot_s *source, { GstCaps *caps; const char *_media_type; + media_format_mimetype_e mime_type; RET_VAL_IF(source == NULL, NULL, "source is NULL"); RET_VAL_IF(source->media_format == NULL, NULL, "media_format is NULL"); + RET_VAL_IF(source->type != WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, NULL, "invalid type[%d]", source->type); - switch (source->type) { - case WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET: { - media_format_mimetype_e mime_type; - - if (source->media_types == MEDIA_TYPE_AUDIO) { - int channels; - int samplerate; - - RET_VAL_IF(media_format_get_audio_info(source->media_format, &mime_type, &channels, &samplerate, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE, - NULL, "failed to media_format_get_audio_info()"); + if (source->media_types == MEDIA_TYPE_AUDIO) { + int channels; + int samplerate; - _media_type = _get_audio_media_type(source->av[AV_IDX_AUDIO].codec); - RET_VAL_IF(_media_type == NULL, NULL, "media_type is NULL"); + RET_VAL_IF(media_format_get_audio_info(source->media_format, &mime_type, &channels, &samplerate, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE, + NULL, "failed to media_format_get_audio_info()"); - caps = _get_caps_from_encoded_audio_media_type(_media_type, channels, samplerate); + _media_type = _get_audio_media_type(source->av[AV_IDX_AUDIO].codec); + RET_VAL_IF(_media_type == NULL, NULL, "media_type is NULL"); - } else if (source->media_types == MEDIA_TYPE_VIDEO) { - int width; - int height; - int framerate; + caps = _get_caps_from_encoded_audio_media_type(_media_type, channels, samplerate); - RET_VAL_IF(media_format_get_video_info(source->media_format, &mime_type, &width, &height, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE, - NULL, "failed to media_format_get_video_info()"); - RET_VAL_IF(media_format_get_video_frame_rate(source->media_format, &framerate) != MEDIA_FORMAT_ERROR_NONE, - NULL, "failed to media_format_get_video_frame_rate()"); + } else if (source->media_types == MEDIA_TYPE_VIDEO) { + int width; + int height; + int framerate; - _media_type = _get_video_media_type(source->av[AV_IDX_VIDEO].codec); - RET_VAL_IF(_media_type == NULL, NULL, "media_type is NULL"); + RET_VAL_IF(media_format_get_video_info(source->media_format, &mime_type, &width, &height, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE, + NULL, "failed to media_format_get_video_info()"); + RET_VAL_IF(media_format_get_video_frame_rate(source->media_format, &framerate) != MEDIA_FORMAT_ERROR_NONE, + NULL, "failed to media_format_get_video_frame_rate()"); - caps = _get_caps_from_encoded_video_media_type(_media_type, width, height); + _media_type = _get_video_media_type(source->av[AV_IDX_VIDEO].codec); + RET_VAL_IF(_media_type == NULL, NULL, "media_type is NULL"); - } else { - LOG_ERROR_IF_REACHED("source->media_types(0x%x)", source->media_types); - return NULL; - } - break; - } + caps = _get_caps_from_encoded_video_media_type(_media_type, width, height); - default: - LOG_ERROR_IF_REACHED("type(%d)", source->type); + } else { + LOG_ERROR_IF_REACHED("source->media_types(0x%x)", source->media_types); return NULL; } @@ -307,9 +298,7 @@ static GstCaps *__make_encoded_caps_from_media_format(webrtc_gst_slot_s *source, return caps; } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static int __create_rest_of_elements_for_encoded_format(webrtc_s *webrtc, webrtc_gst_slot_s *source, GList **element_list) { @@ -341,7 +330,7 @@ static int __create_rest_of_elements_for_encoded_format(webrtc_s *webrtc, webrtc goto error; APPEND_ELEMENT(*element_list, capsfilter); - if(_set_payload_type(webrtc, source, GET_AV_IDX_BY_TYPE(source->media_types), NULL) != WEBRTC_ERROR_NONE) + if (_set_payload_type(webrtc, source, GET_AV_IDX_BY_TYPE(source->media_types), NULL) != WEBRTC_ERROR_NONE) goto error; if ((sink_caps = _make_rtp_caps(media_type, source->av[GET_AV_IDX_BY_TYPE(source->media_types)].pt, source, NULL))) { @@ -745,7 +734,7 @@ int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h f media_format_ref(format); source->media_format = format; - if((ret = __set_mediapacketsrc_codec_info(webrtc, source, mime_type)) != WEBRTC_ERROR_NONE) + if ((ret = __set_mediapacketsrc_codec_info(webrtc, source, mime_type)) != WEBRTC_ERROR_NONE) goto error; if ((mime_type & MEDIA_FORMAT_RAW) && diff --git a/src/webrtc_source_private.c b/src/webrtc_source_private.c index 7448aab7..10ebe1a9 100644 --- a/src/webrtc_source_private.c +++ b/src/webrtc_source_private.c @@ -1170,7 +1170,7 @@ skip_encoder: goto error; APPEND_ELEMENT(*element_list, capsfilter2); - if(_set_payload_type(webrtc, source, idx, media_type) != WEBRTC_ERROR_NONE) + if (_set_payload_type(webrtc, source, idx, media_type) != WEBRTC_ERROR_NONE) goto error; if ((sink_caps = _make_rtp_caps(media_type, source->av[idx].pt, source, encoder))) { diff --git a/src/webrtc_source_screen.c b/src/webrtc_source_screen.c index 01924746..6b929238 100644 --- a/src/webrtc_source_screen.c +++ b/src/webrtc_source_screen.c @@ -95,7 +95,7 @@ int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int _width = output_width - (left + right); _height = output_height - (top + bottom); - if((ret = _update_caps_for_render_with_resolution(source, _width, _height)) != WEBRTC_ERROR_NONE) + if ((ret = _update_caps_for_render_with_resolution(source, _width, _height)) != WEBRTC_ERROR_NONE) return ret; _set_video_src_resolution(source, _width, _height); @@ -112,7 +112,6 @@ int _unset_screen_source_crop(webrtc_s *webrtc, unsigned int source_id) { webrtc_gst_slot_s *source = NULL; GstElement *videocrop = NULL; - GstElement *screen_source = NULL; int ret; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); @@ -121,9 +120,6 @@ int _unset_screen_source_crop(webrtc_s *webrtc, unsigned int source_id) RET_VAL_IF(source->type != WEBRTC_MEDIA_SOURCE_TYPE_SCREEN, WEBRTC_ERROR_INVALID_PARAMETER, "source type is not screen"); RET_VAL_IF(!_is_screen_source_cropped(source), WEBRTC_ERROR_INVALID_OPERATION, "source is not cropped"); - screen_source = gst_bin_get_by_name(source->bin, ELEMENT_NAME_SCREENSRC); - RET_VAL_IF(screen_source == NULL, WEBRTC_ERROR_INVALID_OPERATION, "sreen_source is NULL"); - videocrop = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEOCROP); RET_VAL_IF(videocrop == NULL, WEBRTC_ERROR_INVALID_OPERATION, "videocrop is NULL"); @@ -134,7 +130,7 @@ int _unset_screen_source_crop(webrtc_s *webrtc, unsigned int source_id) "bottom", 0, NULL); - if((ret = _update_caps_for_render_with_resolution(source, source->video_info.origin_width, source->video_info.origin_height)) != WEBRTC_ERROR_NONE) + if ((ret = _update_caps_for_render_with_resolution(source, source->video_info.origin_width, source->video_info.origin_height)) != WEBRTC_ERROR_NONE) return ret; _set_video_src_resolution(source, source->video_info.origin_width, source->video_info.origin_height);