From: Sangchul Lee Date: Tue, 5 Mar 2024 08:26:53 +0000 (+0900) Subject: webrtc_internal: Add function to create session description from sdp string X-Git-Tag: accepted/tizen/8.0/unified/20240308.173324~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63a0c7ac8e865bdcbf2affc68dd9bb50e0788685;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_internal: Add function to create session description from sdp string webrtc_util_create_description() has been added. [Version] 0.4.49 [Issue Type] Internal API Change-Id: I3718e504f37c165a9bc5d39c83ec976f2a111bde Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h index c9fb1faa..40c1772c 100644 --- a/include/webrtc_internal.h +++ b/include/webrtc_internal.h @@ -518,7 +518,7 @@ int webrtc_start_sync(webrtc_h webrtc); * @brief Strips the session description. * @since_tizen 8.0 * @remarks @a origin_description is a JSON string. It should be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n - * @a description will be {"..."} the string member of "sdp" object in @a origin_description.\n + * @a description will be the string member of the "sdp" object in @a origin_description.\n * The @a description should be released using free(). * @param[in] origin_description The original session description * @param[out] description The stripped session description @@ -527,9 +527,29 @@ int webrtc_start_sync(webrtc_h webrtc); * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation + * @see webrtc_util_create_description() */ int webrtc_util_strip_description(const char *origin_description, char **description); +/** + * @internal + * @brief Create the session description from sdp string. + * @since_tizen 8.0 + * @remarks @a sdp should be a string that follows the sdp format like "v=0\r\no=- 1832017678083131571 0 IN IP4 0.0.0.0\r\ns=-\r\n...".\n + * @a description is a JSON string. It will be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n + * The @a description should be released using free(). + * @param[in] offer SDP type (@c true = offer, @c false = answer) + * @param[in] sdp SDP string + * @param[out] description The session description + * @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_util_strip_description() + */ +int webrtc_util_create_description(bool is_offer, const char *sdp, char **description); + /** * @internal * @brief Creates a signaling server for private network. diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index b4ccab3d..71fea89b 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.4.48 +Version: 0.4.49 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index 208375a6..d23234bd 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -405,6 +405,32 @@ int webrtc_util_strip_description(const char *origin_description, char **descrip return WEBRTC_ERROR_NONE; } +int webrtc_util_create_description(bool is_offer, const char *sdp, char **description) +{ + JsonObject *desc, *sdp_desc; + gchar *result; + + RET_VAL_IF(sdp == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "sdp is NULL"); + RET_VAL_IF(description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "description is NULL"); + + sdp_desc = json_object_new(); + json_object_set_string_member(sdp_desc, "type", is_offer ? "offer": "answer"); + json_object_set_string_member(sdp_desc, "sdp", sdp); + + desc = json_object_new(); + json_object_set_object_member(desc, "sdp", sdp_desc); + + result = _get_string_from_json_object(desc); + json_object_unref(desc); + + *description = strdup(result); + g_free(result); + + LOG_INFO("description:\n%s", *description); + + return WEBRTC_ERROR_NONE; +} + int webrtc_set_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float probability) { webrtc_s *_webrtc = (webrtc_s *)webrtc;