* @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
* @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.
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;