Revise codes to comply with coding convention 20/260220/4
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 22 Jun 2021 06:45:32 +0000 (15:45 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 22 Jun 2021 07:08:54 +0000 (16:08 +0900)
Use tab for spacing.
Add or remove space.
Some set/unset callback functions are moved to it's getter API.
Revise doxygen.

[Version] 0.2.19
[Issue Type] Improvement

Change-Id: Ia9ffa82d93b91b77aa2dfd61e4466297d8da48ac
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc.h
packaging/capi-media-webrtc.spec
src/webrtc.c
src/webrtc_display.c
src/webrtc_private.c
src/webrtc_resource.c
src/webrtc_signaling_client.c
src/webrtc_sink.c
src/webrtc_source.c

index e595b901404885ffe91332b293d60f1332704ef1..43909be021143d700b82589fb028c1b26fc968b0 100644 (file)
@@ -84,12 +84,12 @@ typedef enum {
  * @since_tizen 6.5
  */
 typedef enum {
-    WEBRTC_PEER_CONNECTION_STATE_NEW,          /**<  New */
-    WEBRTC_PEER_CONNECTION_STATE_CONNECTING,   /**<  Connecting */
-    WEBRTC_PEER_CONNECTION_STATE_CONNECTED,    /**<  Connected */
-    WEBRTC_PEER_CONNECTION_STATE_DISCONNECTED, /**<  Disconnected */
-    WEBRTC_PEER_CONNECTION_STATE_FAILED,       /**<  Failed */
-    WEBRTC_PEER_CONNECTION_STATE_CLOSED,       /**<  Closed */
+       WEBRTC_PEER_CONNECTION_STATE_NEW,          /**<  New */
+       WEBRTC_PEER_CONNECTION_STATE_CONNECTING,   /**<  Connecting */
+       WEBRTC_PEER_CONNECTION_STATE_CONNECTED,    /**<  Connected */
+       WEBRTC_PEER_CONNECTION_STATE_DISCONNECTED, /**<  Disconnected */
+       WEBRTC_PEER_CONNECTION_STATE_FAILED,       /**<  Failed */
+       WEBRTC_PEER_CONNECTION_STATE_CLOSED,       /**<  Closed */
 } webrtc_peer_connection_state_e;
 
 /**
@@ -97,12 +97,12 @@ typedef enum {
  * @since_tizen 6.5
  */
 typedef enum {
-    WEBRTC_SIGNALING_STATE_STABLE,               /**<  Stable */
-    WEBRTC_SIGNALING_STATE_HAVE_LOCAL_OFFER,     /**<  Have local offer */
-    WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER,    /**<  Have remote offer */
-    WEBRTC_SIGNALING_STATE_HAVE_LOCAL_PRANSWER,  /**<  Have local provisional answer */
-    WEBRTC_SIGNALING_STATE_HAVE_REMOTE_PRANSWER, /**<  Have remote provisional answer */
-    WEBRTC_SIGNALING_STATE_CLOSED,               /**<  Closed */
+       WEBRTC_SIGNALING_STATE_STABLE,               /**<  Stable */
+       WEBRTC_SIGNALING_STATE_HAVE_LOCAL_OFFER,     /**<  Have local offer */
+       WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER,    /**<  Have remote offer */
+       WEBRTC_SIGNALING_STATE_HAVE_LOCAL_PRANSWER,  /**<  Have local provisional answer */
+       WEBRTC_SIGNALING_STATE_HAVE_REMOTE_PRANSWER, /**<  Have remote provisional answer */
+       WEBRTC_SIGNALING_STATE_CLOSED,               /**<  Closed */
 } webrtc_signaling_state_e;
 
 /**
@@ -110,9 +110,9 @@ typedef enum {
  * @since_tizen 6.5
  */
 typedef enum {
-    WEBRTC_ICE_GATHERING_STATE_NEW,        /**<  New */
-    WEBRTC_ICE_GATHERING_STATE_GATHERING,  /**<  Gathering */
-    WEBRTC_ICE_GATHERING_STATE_COMPLETE,   /**<  Complete */
+       WEBRTC_ICE_GATHERING_STATE_NEW,        /**<  New */
+       WEBRTC_ICE_GATHERING_STATE_GATHERING,  /**<  Gathering */
+       WEBRTC_ICE_GATHERING_STATE_COMPLETE,   /**<  Complete */
 } webrtc_ice_gathering_state_e;
 
 /**
@@ -524,35 +524,6 @@ int webrtc_set_error_cb(webrtc_h webrtc, webrtc_error_cb callback, void *user_da
  */
 int webrtc_unset_error_cb(webrtc_h webrtc);
 
-/**
- * @brief Sets a callback function to be invoked when the WebRTC state is changed.
- * @since_tizen 6.5
- * @param[in] webrtc      WebRTC handle
- * @param[in] callback    Callback function pointer
- * @param[in] user_data   The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #WEBRTC_ERROR_NONE    Successful
- * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
- * @post webrtc_state_changed_cb() will be invoked.
- * @see webrtc_unset_state_changed_cb()
- * @see webrtc_state_changed_cb()
- */
-int webrtc_set_state_changed_cb(webrtc_h webrtc, webrtc_state_changed_cb callback, void *user_data);
-
-/**
- * @brief Unsets the state changed callback function.
- * @since_tizen 6.5
- * @param[in] webrtc      WebRTC handle
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #WEBRTC_ERROR_NONE    Successful
- * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
- * @see webrtc_set_state_changed_cb()
- */
-int webrtc_unset_state_changed_cb(webrtc_h webrtc);
-
 /**
  * @brief Creates an instance of WebRTC.
  * @since_tizen 6.5
@@ -622,6 +593,36 @@ int webrtc_stop(webrtc_h webrtc);
  */
 int webrtc_destroy(webrtc_h webrtc);
 
+/**
+ * @brief Sets a callback function to be invoked when the WebRTC state is changed.
+ * @since_tizen 6.5
+ * @param[in] webrtc      WebRTC handle
+ * @param[in] callback    Callback function pointer
+ * @param[in] user_data   The user data to be passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE    Successful
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post webrtc_state_changed_cb() will be invoked.
+ * @see webrtc_unset_state_changed_cb()
+ * @see webrtc_state_changed_cb()
+ * @see webrtc_get_state()
+ */
+int webrtc_set_state_changed_cb(webrtc_h webrtc, webrtc_state_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unsets the state changed callback function.
+ * @since_tizen 6.5
+ * @param[in] webrtc      WebRTC handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE    Successful
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
+ * @see webrtc_set_state_changed_cb()
+ */
+int webrtc_unset_state_changed_cb(webrtc_h webrtc);
+
 /**
  * @brief Gets the WebRTC state.
  * @since_tizen 6.5
@@ -631,7 +632,8 @@ int webrtc_destroy(webrtc_h webrtc);
  *         otherwise a negative error value
  * @retval #WEBRTC_ERROR_NONE    Successful
  * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
- * @see #webrtc_state_e
+ * @see webrtc_set_state_changed_cb()
+ * @see webrtc_unset_state_changed_cb()
  */
 int webrtc_get_state(webrtc_h webrtc, webrtc_state_e *state);
 
index 7aade4961b704c981fb9c69635c1cd6a50642835..f0fbf8f2debc78f17738e50a778b984fdc43da29 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.18
+Version:    0.2.19
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 4d9c776ad3b301a3f753f39c4889c908507c3b5e..4d62247cd7b4ceaa1316a7b6289ee3fb59bc8bf6 100644 (file)
@@ -69,48 +69,6 @@ int webrtc_unset_error_cb(webrtc_h webrtc)
        return WEBRTC_ERROR_NONE;
 }
 
-int webrtc_set_state_changed_cb(webrtc_h webrtc, webrtc_state_changed_cb callback, void *user_data)
-{
-       webrtc_s *_webrtc = (webrtc_s*)webrtc;
-
-       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
-       RET_VAL_IF(callback == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "callback is NULL");
-
-       g_mutex_lock(&_webrtc->mutex);
-
-       LOG_WARNING_IF_CALLBACK_EXISTS(_webrtc->state_changed_cb);
-
-       _webrtc->state_changed_cb.callback = callback;
-       _webrtc->state_changed_cb.user_data = user_data;
-
-       LOG_INFO("callback[%p] user_data[%p]", callback, user_data);
-
-       g_mutex_unlock(&_webrtc->mutex);
-
-       return WEBRTC_ERROR_NONE;
-}
-
-int webrtc_unset_state_changed_cb(webrtc_h webrtc)
-{
-       webrtc_s *_webrtc = (webrtc_s*)webrtc;
-
-       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
-
-       g_mutex_lock(&_webrtc->mutex);
-
-       RET_VAL_WITH_UNLOCK_IF(_webrtc->state_changed_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex, "callback was not set");
-
-       LOG_INFO("callback[%p] user_data[%p] is reset to NULL",
-               _webrtc->state_changed_cb.callback, _webrtc->state_changed_cb.user_data);
-
-       _webrtc->state_changed_cb.callback = NULL;
-       _webrtc->state_changed_cb.user_data = NULL;
-
-       g_mutex_unlock(&_webrtc->mutex);
-
-       return WEBRTC_ERROR_NONE;
-}
-
 int webrtc_create(webrtc_h *webrtc)
 {
 #ifndef TIZEN_TV
@@ -234,6 +192,48 @@ int webrtc_stop(webrtc_h webrtc)
        return _webrtc_stop(_webrtc);
 }
 
+int webrtc_set_state_changed_cb(webrtc_h webrtc, webrtc_state_changed_cb callback, void *user_data)
+{
+       webrtc_s *_webrtc = (webrtc_s*)webrtc;
+
+       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+       RET_VAL_IF(callback == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "callback is NULL");
+
+       g_mutex_lock(&_webrtc->mutex);
+
+       LOG_WARNING_IF_CALLBACK_EXISTS(_webrtc->state_changed_cb);
+
+       _webrtc->state_changed_cb.callback = callback;
+       _webrtc->state_changed_cb.user_data = user_data;
+
+       LOG_INFO("callback[%p] user_data[%p]", callback, user_data);
+
+       g_mutex_unlock(&_webrtc->mutex);
+
+       return WEBRTC_ERROR_NONE;
+}
+
+int webrtc_unset_state_changed_cb(webrtc_h webrtc)
+{
+       webrtc_s *_webrtc = (webrtc_s*)webrtc;
+
+       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+
+       g_mutex_lock(&_webrtc->mutex);
+
+       RET_VAL_WITH_UNLOCK_IF(_webrtc->state_changed_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex, "callback was not set");
+
+       LOG_INFO("callback[%p] user_data[%p] is reset to NULL",
+               _webrtc->state_changed_cb.callback, _webrtc->state_changed_cb.user_data);
+
+       _webrtc->state_changed_cb.callback = NULL;
+       _webrtc->state_changed_cb.user_data = NULL;
+
+       g_mutex_unlock(&_webrtc->mutex);
+
+       return WEBRTC_ERROR_NONE;
+}
+
 int webrtc_get_state(webrtc_h webrtc, webrtc_state_e *state)
 {
        webrtc_s *_webrtc = (webrtc_s*)webrtc;
@@ -391,7 +391,7 @@ int webrtc_media_source_set_mute(webrtc_h webrtc, unsigned int source_id, webrtc
                ret = _set_video_mute(_webrtc, source_id, mute);
                break;
 
-       default :
+       default:
                LOG_ERROR_IF_REACHED("media type(%d)", media_type);
                ret = WEBRTC_ERROR_INVALID_PARAMETER;
                break;
@@ -423,7 +423,7 @@ int webrtc_media_source_get_mute(webrtc_h webrtc, unsigned int source_id, webrtc
                ret = _get_video_mute(_webrtc, source_id, muted);
                break;
 
-       default :
+       default:
                LOG_ERROR_IF_REACHED("media type(%d)", media_type);
                ret = WEBRTC_ERROR_INVALID_PARAMETER;
                break;
@@ -652,7 +652,7 @@ int webrtc_add_turn_server(webrtc_h webrtc, const char *turn_server)
 
        RET_VAL_WITH_UNLOCK_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, &_webrtc->mutex, "the state should be IDLE");
 
-       g_signal_emit_by_name (G_OBJECT(_webrtc->gst.webrtcbin), "add-turn-server", turn_server, &ret);
+       g_signal_emit_by_name(G_OBJECT(_webrtc->gst.webrtcbin), "add-turn-server", turn_server, &ret);
        RET_VAL_WITH_UNLOCK_IF(!ret, WEBRTC_ERROR_INVALID_PARAMETER, &_webrtc->mutex, "invalid turn server url (%s)", turn_server);
 
        _webrtc->turn_server_urls = g_list_append(_webrtc->turn_server_urls, g_strdup(turn_server));
index 04296af1995c3ab319a4099e0748e3bd55397743..d5cb07f4ef817047abcbf0cc0006a52bd6ee96a2 100644 (file)
@@ -765,4 +765,4 @@ void _release_display(webrtc_display_s *display)
        LOG_DEBUG("free display[%p]", display);
 
        g_free(display);
-}
\ No newline at end of file
+}
index f6910eef79a79e3ef8a26e6763c7b33603bb0266..fdd9e7c2ff0e1a8a928a83bd32afc718284922df 100644 (file)
@@ -841,7 +841,7 @@ int _add_no_target_ghostpad_to_slot(webrtc_gst_slot_s *slot, bool is_src, GstPad
        RET_VAL_IF(new_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "new_pad is NULL");
 
        pad_name = g_strdup_printf("%s_%u", is_src ? "src" : "sink", slot->id);
-       if (!(*new_pad =__add_no_target_ghostpad(slot->bin, pad_name, is_src))) {
+       if (!(*new_pad = __add_no_target_ghostpad(slot->bin, pad_name, is_src))) {
                LOG_ERROR("failed to add new ghost pad[%s] for bin[%s]", pad_name, GST_ELEMENT_NAME(slot->bin));
                g_free(pad_name);
                return WEBRTC_ERROR_INVALID_OPERATION;
@@ -1319,7 +1319,7 @@ static int __get_sdp_from_description(const char *description, gchar **sdp, gcha
        LOG_DEBUG("type: %s", *type);
        LOG_DEBUG("sdp:\n%s", *sdp);
 end:
-       g_object_unref (parser);
+       g_object_unref(parser);
        return ret;
 }
 
@@ -1359,13 +1359,13 @@ int _webrtcbin_set_session_description(webrtc_s *webrtc, const char *description
        desc = gst_webrtc_session_description_new(sdp_type, gst_sdp);
 
        promise = gst_promise_new();
-       g_signal_emit_by_name(webrtc->gst.webrtcbin, is_remote? "set-remote-description" : "set-local-description", desc, promise);
+       g_signal_emit_by_name(webrtc->gst.webrtcbin, is_remote ? "set-remote-description" : "set-local-description", desc, promise);
        gst_promise_interrupt(promise);
        gst_promise_unref(promise);
 
        gst_webrtc_session_description_free(desc);
 
-       LOG_DEBUG("[%s] signal is emitted", is_remote? "set-remote-description" : "set-local-description");
+       LOG_DEBUG("[%s] signal is emitted", is_remote ? "set-remote-description" : "set-local-description");
 
 end:
        g_free(sdp);
index 86a29dac5d7d4731ef424265a0a17cd9f66010e0..53603f398df4ad25672a3ea5f20285eba4e1295d 100644 (file)
@@ -117,7 +117,7 @@ int _release_all_resources(webrtc_s *webrtc)
        RET_VAL_IF(webrtc->resource.mgr == NULL, WEBRTC_ERROR_INVALID_PARAMETER,
                        "resource manager is NULL");
 
-       if(webrtc->resource.release_cb_is_calling) {
+       if (webrtc->resource.release_cb_is_calling) {
                LOG_INFO("__resource_release_cb is calling, so skip");
                return WEBRTC_ERROR_NONE;
        }
index 7b8e1dd36eda23dc8a06717448a3f1a8dfdd1d2f..2076ec9194c55629d26db0cf82db89bcdf4bedfc 100644 (file)
@@ -303,4 +303,4 @@ int webrtc_signaling_get_id(webrtc_signaling_client_h client, int *id)
        *id = _client->id;
 
        return WEBRTC_ERROR_NONE;
-}
\ No newline at end of file
+}
index 287e8857288868904b751bfe83fa360acf563d85..b8eb833071a29c41d5d2368e029787eedd663761 100644 (file)
@@ -137,7 +137,7 @@ static int __build_videosink(webrtc_s *webrtc, GstElement *decodebin, GstPad *sr
        }
 #ifndef TIZEN_TV
        if (sink->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY && webrtc->ini.resource_acquisition.video_overlay) {
-               if ((ret =_acquire_resource_for_type(webrtc, MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY)))
+               if ((ret = _acquire_resource_for_type(webrtc, MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY)))
                        return ret;
        }
 #endif
index a20c76798c1f2832cf51fe99b9273a4f6f16e7e4..b773533e1de8b4239104ca3c07f83cee6515cad3 100644 (file)
@@ -2477,7 +2477,7 @@ int _set_video_mute(webrtc_s *webrtc, unsigned int source_id, bool mute)
                ret = __mute_videosrc(source, mute);
                break;
 
-       default :
+       default:
                LOG_ERROR_IF_REACHED("type(%d)", source->type);
                return WEBRTC_ERROR_INVALID_PARAMETER;
        }
@@ -2516,7 +2516,7 @@ int _set_audio_mute(webrtc_s *webrtc, unsigned int source_id, bool mute)
                g_object_set(G_OBJECT(volume), "mute", mute, NULL);
                break;
 
-       default :
+       default:
                LOG_ERROR_IF_REACHED("type(%d)", source->type);
                return WEBRTC_ERROR_INVALID_PARAMETER;
        }
@@ -2546,7 +2546,7 @@ int _get_video_mute(webrtc_s *webrtc, unsigned int source_id, bool *muted)
                *muted = source->video_muted;
                break;
 
-       default :
+       default:
                LOG_ERROR_IF_REACHED("type(%d)", source->type);
                return WEBRTC_ERROR_INVALID_PARAMETER;
        }
@@ -2584,7 +2584,7 @@ int _get_audio_mute(webrtc_s *webrtc, unsigned int source_id, bool *muted)
                g_object_get(G_OBJECT(volume), "mute", muted, NULL);
                break;
 
-       default :
+       default:
                LOG_ERROR_IF_REACHED("type(%d)", source->type);
                return WEBRTC_ERROR_INVALID_PARAMETER;
        }