remove redundant code 56/278956/5
authorhj kim <backto.kim@samsung.com>
Fri, 29 Jul 2022 01:22:22 +0000 (10:22 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 1 Sep 2022 02:45:48 +0000 (11:45 +0900)
Plus, apply tizen coding rule.

[Version] 0.3.225
[Issue Type] Refactoring

Change-Id: I31ac8625327a316cafdf3db7aeeeffc150d6c512

packaging/capi-media-webrtc.spec
src/webrtc_source_file.c
src/webrtc_source_mediapacket.c
src/webrtc_source_private.c
src/webrtc_source_screen.c

index c771cc628e5705c424b4c75cee804bf0810a6b53..ae99a9378af903fef2bca9223eb96d3df6bd4317 100644 (file)
@@ -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
index b63ee8c51157c1a1fb5fc98d8e3cec50b2497340..4bc936fac467a9f3ac3da26153f9598437e74bef 100644 (file)
@@ -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);
 
index ef371e535611168492c5a7b4edf99a53e08dd809..6ce30bbad7989d63721f3f839002fccd3f9935d5 100644 (file)
@@ -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) &&
index 7448aab71c81cb4e87dd32c42c8efae4ddde9919..10ebe1a99526e72cb1057b9b40ba99ff52e77d8e 100644 (file)
@@ -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))) {
index 019247466316425e31538d60a8039f7204e81672..6b929238f2aa8bf15ce1ba2cca750167a6a20210 100644 (file)
@@ -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);