The form of URL should be turn(s)://username:password@host:port.
If the username has ':', for example '
1221435:someidstring',
this could not be applied properly inside of webrtcbin.
In this case, this patch fixes it with using URL encoding
to avoid this situation.
[Version] 0.3.181
[Issue Type] Bug fix
Change-Id: Icd30fdbea39469526abde8016745fc291bf2d4a5
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
* @since_tizen 6.5
* @remarks Regarding TURN, refer to the RFC7065(https://tools.ietf.org/html/rfc7065).
* @param[in] webrtc WebRTC handle
- * @param[in] turn_server The TURN server URL of the form turn(s)://username:password\@host:port
+ * @param[in] turn_server The TURN server URL of the form turn(s)://username:password@host:port
* @return @c 0 on success,
* otherwise a negative error value
* @retval #WEBRTC_ERROR_NONE Successful
int _add_no_target_ghostpad_to_slot(webrtc_gst_slot_s *slot, bool is_src, GstPad **new_pad);
int _set_ghost_pad_target(GstPad *ghost_pad, GstElement *target_element, bool is_src);
void _generate_dot(GstElement *pipeline, const gchar *name);
+gchar *_check_and_encode_turn_url(const char *url);
#ifdef __cplusplus
}
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.3.180
+Version: 0.3.181
Release: 0
Group: Multimedia/API
License: Apache-2.0
gboolean ret = FALSE;
g_autoptr(GMutexLocker) locker = NULL;
webrtc_s *_webrtc = (webrtc_s *)webrtc;
+ gchar *turn_url;
RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(turn_server == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "turn_server is NULL");
RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE");
- g_signal_emit_by_name(G_OBJECT(_webrtc->gst.webrtcbin), "add-turn-server", turn_server, &ret);
- RET_VAL_IF(!ret, WEBRTC_ERROR_INVALID_PARAMETER, "invalid turn server url (%s)", turn_server);
+ turn_url = _check_and_encode_turn_url(turn_server);
- _webrtc->turn_server_urls = g_list_append(_webrtc->turn_server_urls, g_strdup(turn_server));
+ g_signal_emit_by_name(G_OBJECT(_webrtc->gst.webrtcbin), "add-turn-server", turn_url, &ret);
+ if (!ret) {
+ LOG_ERROR("invalid turn server url (%s)", turn_url);
+ g_free(turn_url);
+ return WEBRTC_ERROR_INVALID_PARAMETER;
+ }
+
+ _webrtc->turn_server_urls = g_list_append(_webrtc->turn_server_urls, turn_url);
- LOG_INFO("webrtc[%p] turn_server[%s]", webrtc, turn_server);
+ LOG_INFO("webrtc[%p] turn_server[%s]", webrtc, turn_url);
return WEBRTC_ERROR_NONE;
}
}
//LCOV_EXCL_STOP
+gchar *_check_and_encode_turn_url(const char *url)
+{
+ g_auto(GStrv) str_arr = g_strsplit(url, "@", 2);
+ g_auto(GStrv) str_arr2 = g_strsplit(str_arr[0], ":", 0);
+
+ if (g_strv_length(str_arr2) > 3) /* NOTE: assume id has ':' character */
+ return g_strdup_printf("%s:%s%s%s:%s@%s",
+ str_arr2[0], str_arr2[1], "%3A", str_arr2[2], str_arr2[3], str_arr[1]);
+
+ return g_strdup(url);
+}
+
/* Use g_free() to release the return value. */
-static gchar* __get_string_from_json_object(JsonObject *object)
+static gchar *__get_string_from_json_object(JsonObject *object)
{
JsonNode *root;
JsonGenerator *generator;
}
/* Use g_free() to release the return value. */
-static gchar* __make_sdp_message(GstWebRTCSessionDescription *desc)
+static gchar *__make_sdp_message(GstWebRTCSessionDescription *desc)
{
gchar *text;
JsonObject *msg, *sdp;