From: Sangchul Lee Date: Tue, 22 Jun 2021 06:45:32 +0000 (+0900) Subject: Revise codes to comply with coding convention X-Git-Tag: submit/tizen/20210729.023123~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84924eb79342b9e3f8823eb00710a9ab2d7ba782;p=platform%2Fcore%2Fapi%2Fwebrtc.git Revise codes to comply with coding convention 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 --- diff --git a/include/webrtc.h b/include/webrtc.h index e595b901..43909be0 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -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); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 7aade496..f0fbf8f2 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.2.18 +Version: 0.2.19 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc.c b/src/webrtc.c index 4d9c776a..4d62247c 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -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)); diff --git a/src/webrtc_display.c b/src/webrtc_display.c index 04296af1..d5cb07f4 100644 --- a/src/webrtc_display.c +++ b/src/webrtc_display.c @@ -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 +} diff --git a/src/webrtc_private.c b/src/webrtc_private.c index f6910eef..fdd9e7c2 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -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); diff --git a/src/webrtc_resource.c b/src/webrtc_resource.c index 86a29dac..53603f39 100644 --- a/src/webrtc_resource.c +++ b/src/webrtc_resource.c @@ -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; } diff --git a/src/webrtc_signaling_client.c b/src/webrtc_signaling_client.c index 7b8e1dd3..2076ec91 100644 --- a/src/webrtc_signaling_client.c +++ b/src/webrtc_signaling_client.c @@ -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 +} diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index 287e8857..b8eb8330 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -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 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index a20c7679..b773533e 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -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; }