webrtc_source: Revise error values 70/257370/1
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 23 Apr 2021 06:17:14 +0000 (15:17 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 23 Apr 2021 06:28:00 +0000 (15:28 +0900)
Return WEBRTC_ERROR_INVALID_OPERATION if handle has a member of
not expected value.

[Version] 0.1.155
[Issue Type] Improvement

Change-Id: Ibeb30dc6b0864bb6ecd492af1ddf2444b2cc9bf7
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_source.c

index 0ce85501bf6840922bd5b820157e7506287d726c..930a42b128f0b31d6f882baf81889bfab1ddf2b7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.1.154
+Version:    0.1.155
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 1460f36e75cd620d4d7384636d545cff6d09fd3d..c7fe2b0d7ff5da766ced35382dffa42ea94af3d2 100644 (file)
@@ -775,8 +775,8 @@ static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
-       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "src_pad is NULL");
        RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
+       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL");
 
        source->media_types = MEDIA_TYPE_VIDEO;
 
@@ -789,6 +789,7 @@ static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
        gst_bin_add_many(source->bin, screensrc, capsfilter1, videoconvert, capsfilter2, videoenc, videopay, queue, capsfilter3, NULL);
        if (!gst_element_link_many(screensrc, capsfilter1, videoconvert, capsfilter2, videoenc, videopay, queue, capsfilter3, NULL)) {
                LOG_ERROR("failed to gst_element_link_many()");
+               ret = WEBRTC_ERROR_INVALID_OPERATION;
                goto exit_with_remove_from_bin;
        }
 
@@ -799,10 +800,9 @@ static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
        return WEBRTC_ERROR_NONE;
 
 exit_with_remove_from_bin:
+       /* elements will be dereferenced */
        gst_bin_remove_many(source->bin, screensrc, capsfilter1, videoconvert, capsfilter2, videoenc, videopay, queue, capsfilter3, NULL);
-
-       return WEBRTC_ERROR_INVALID_OPERATION;
-
+       return ret;
 exit:
        SAFE_GST_OBJECT_UNREF(screensrc);
        SAFE_GST_OBJECT_UNREF(capsfilter1);
@@ -812,7 +812,6 @@ exit:
        SAFE_GST_OBJECT_UNREF(videopay);
        SAFE_GST_OBJECT_UNREF(queue);
        SAFE_GST_OBJECT_UNREF(capsfilter3);
-
        return ret;
 }
 
@@ -829,7 +828,7 @@ static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "src_pad is NULL");
+       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL");
 
        source->media_types = MEDIA_TYPE_VIDEO;
 #ifdef TIZEN_FEATURE_RES_MGR
@@ -889,7 +888,7 @@ static int __build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "src_pad is NULL");
+       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL");
 
        source->media_types = MEDIA_TYPE_AUDIO;
 
@@ -941,7 +940,7 @@ static int __build_videotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "src_pad is NULL");
+       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL");
 
        source->media_types = MEDIA_TYPE_VIDEO;
 
@@ -994,7 +993,7 @@ static int __build_audiotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "src_pad is NULL");
+       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL");
 
        source->media_types = MEDIA_TYPE_AUDIO;
 
@@ -1139,7 +1138,7 @@ static int __complete_mediapacketsrc_from_raw_format(webrtc_s *webrtc, webrtc_gs
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "src_pad is NULL");
+       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL");
 
        appsrc = __find_element_in_bin(source->bin, "appsrc");
        RET_VAL_IF(appsrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "appsrc is NULL");
@@ -1204,7 +1203,7 @@ static int __complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrt
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "src_pad is NULL");
+       RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL");
 
        appsrc = __find_element_in_bin(source->bin, "appsrc");
        RET_VAL_IF(appsrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "appsrc is NULL");
@@ -1382,9 +1381,9 @@ int _add_media_source(webrtc_s *webrtc, webrtc_media_source_type_e type, unsigne
        gchar *bin_name = NULL;
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
-       RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
        RET_VAL_IF(source_id == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is NULL");
        RET_VAL_IF(type > WEBRTC_MEDIA_SOURCE_TYPE_SCREEN, WEBRTC_ERROR_INVALID_PARAMETER, "invalid source type(%d)", type);
+       RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
 
        /* bin_name/source will be freed by function which is set to g_hash_table_new_full() */
        id = __get_unoccupied_id(webrtc->gst.source_slots);