Remove meaningless parameter checks 06/302006/1
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 23 Nov 2023 01:56:42 +0000 (10:56 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 23 Nov 2023 02:47:29 +0000 (11:47 +0900)
The first parameter of callbacks from gstreamer would be always not null.

Once webrtc handle has been created, there's no possibility that
'gst.webrtcbin' or 'gst.source_slots' is null.

A typo is also fixed.

[Version] 0.4.24
[Issue Type] Clean up

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

index d5ec19449a22b0f24a6fea8f011488d307ffe24a..c71cb49a7f3152133d5dbe2706ba3703c049a813 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.4.23
+Version:    0.4.24
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index ee5cd589472c7a672270e50c84fd78f7e54cdf44..aa2e29257188e73c6bfab9341cfa8893e7eb8ca7 100644 (file)
@@ -232,7 +232,7 @@ static int __get_media_packet_mimetype(int pixel_format, media_format_mimetype_e
                *mimetype = MEDIA_FORMAT_ARGB;
                break;
        default:
-               LOGE("not suppported pixel_format(%d)", pixel_format);
+               LOGE("not supported pixel_format(%d)", pixel_format);
                return WEBRTC_ERROR_INVALID_PARAMETER;
        }
 
index 00090bf71dd52b86df479ced0e0b032cdddcdcfe..6a376a0ccb75b8929649b99362b833994ef64f4a 100644 (file)
@@ -1110,7 +1110,6 @@ static void __webrtcbin_on_negotiation_needed_cb(GstElement *webrtcbin, gpointer
 {
        webrtc_s *webrtc = (webrtc_s *)user_data;
 
-       RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
        RET_IF(webrtc == NULL, "webrtc is NULL");
 
        _post_state_cb_in_idle(webrtc, WEBRTC_STATE_NEGOTIATING);
@@ -1133,7 +1132,6 @@ static void __webrtcbin_on_ice_candidate_cb(GstElement *webrtcbin, guint mlinein
        gchar *candidate_with_hostname = NULL;
        char *_param_candidate;
 
-       RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
        RET_IF(webrtc == NULL, "webrtc is NULL");
        RET_IF(webrtc->ice_candidate_cb.callback == NULL, "ice_candidate_cb is NULL");
 
@@ -1165,7 +1163,6 @@ static void __webrtcbin_peer_connection_state_cb(GstElement *webrtcbin, GParamSp
        GstWebRTCPeerConnectionState state;
        g_autoptr(GMutexLocker) locker = NULL;
 
-       RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
        RET_IF(webrtc == NULL, "webrtc is NULL");
 
        g_object_get(webrtcbin, "connection-state", &state, NULL);
@@ -1220,7 +1217,6 @@ static void __webrtcbin_ice_gathering_state_cb(GstElement *webrtcbin, GParamSpec
        GstWebRTCICEGatheringState state;
        g_autoptr(GMutexLocker) locker = NULL;
 
-       RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
        RET_IF(webrtc == NULL, "webrtc is NULL");
 
        g_object_get(webrtcbin, "ice-gathering-state", &state, NULL);
@@ -1239,7 +1235,6 @@ static void __webrtcbin_ice_connection_state_cb(GstElement *webrtcbin, GParamSpe
        GstWebRTCICEConnectionState state;
        g_autoptr(GMutexLocker) locker = NULL;
 
-       RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
        RET_IF(webrtc == NULL, "webrtc is NULL");
 
        g_object_get(webrtcbin, "ice-connection-state", &state, NULL);
@@ -1486,7 +1481,6 @@ static void __webrtcbin_no_more_pads_cb(GstElement *webrtcbin, gpointer user_dat
 {
        webrtc_s *webrtc = (webrtc_s *)user_data;
 
-       RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
        RET_IF(webrtc == NULL, "webrtc is NULL");
 
        LOG_DEBUG_LEAVE();
index db575a649c9583b7f5cb049941bf6bbc57d3d530..f6aafa79def71b3936fb51179c491f677f02f7e1 100644 (file)
@@ -745,7 +745,6 @@ int _set_pause(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e med
        bool prev;
 
        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 = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
        RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
 
@@ -779,7 +778,6 @@ int _get_pause(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e med
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(paused == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "paused is NULL");
-       RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
        RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
        RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
 
index 582a2804aacf118643bbc06d17ff37ee612287f4..35f904a194c887e8074670a354f2803840a1ecd2 100644 (file)
@@ -87,8 +87,6 @@ void _webrtcbin_on_new_transceiver_cb(GstElement *webrtcbin, GstWebRTCRTPTransce
        GstWebRTCKind kind;
        GstCaps *caps;
 
-       RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
-       RET_IF(transceiver == NULL, "transceiver is NULL");
        RET_IF(webrtc == NULL, "webrtc is NULL");
 
        g_object_get(G_OBJECT(transceiver),
@@ -437,8 +435,6 @@ int _set_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(direction > WEBRTC_TRANSCEIVER_DIRECTION_SENDRECV, WEBRTC_ERROR_INVALID_PARAMETER, "invalid direction");
-       RET_VAL_IF(webrtc->gst.webrtcbin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtcbin is NULL");
-       RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
        RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL && direction != WEBRTC_TRANSCEIVER_DIRECTION_RECVONLY,
                WEBRTC_ERROR_INVALID_PARAMETER, "null source only allow RECVONLY direction");
@@ -471,8 +467,6 @@ int _get_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(direction == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "direction is NULL");
-       RET_VAL_IF(webrtc->gst.webrtcbin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtcbin is NULL");
-       RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
        RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
 
        if (media_type == WEBRTC_MEDIA_TYPE_AUDIO && source->media_types & MEDIA_TYPE_AUDIO) {
@@ -554,8 +548,6 @@ int _foreach_supported_transceiver_codec(webrtc_s *webrtc, webrtc_media_source_t
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(callback == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "callback is NULL");
-       RET_VAL_IF(webrtc->gst.webrtcbin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtcbin is NULL");
-       RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
        RET_VAL_IF((source_type == WEBRTC_MEDIA_SOURCE_TYPE_FILE), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the file source");
        RET_VAL_IF((source_type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
        RET_VAL_IF((source_type > WEBRTC_MEDIA_SOURCE_TYPE_NULL), WEBRTC_ERROR_INVALID_PARAMETER, "invalid source_type");
@@ -641,8 +633,6 @@ int _set_transceiver_codec(webrtc_s *webrtc, unsigned int source_id, webrtc_medi
        rtp_payload_info_s *payload_info = NULL;
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
-       RET_VAL_IF(webrtc->gst.webrtcbin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtcbin is NULL");
-       RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
        RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the file source");
        RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
@@ -682,8 +672,6 @@ int _get_transceiver_codec(webrtc_s *webrtc, unsigned int source_id, webrtc_medi
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(codec == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "codec is NULL");
-       RET_VAL_IF(webrtc->gst.webrtcbin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtcbin is NULL");
-       RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
        RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
 
        if (media_type == WEBRTC_MEDIA_TYPE_AUDIO && source->media_types & MEDIA_TYPE_AUDIO) {
@@ -705,4 +693,4 @@ int _get_transceiver_codec(webrtc_s *webrtc, unsigned int source_id, webrtc_medi
        LOG_INFO("webrtc[%p] source_id[%u] media_type[%d] codec[%s]", webrtc, source_id, media_type, codec_str);
 
        return WEBRTC_ERROR_NONE;
-}
\ No newline at end of file
+}