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.2.179
[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 _webrtcbin_add_ice_candidate(webrtc_s *webrtc, const char *candidate);
void _webrtcbin_on_data_channel_cb(GstElement *webrtcbin, GObject *data_channel, gpointer user_data);
bool _webrtcbin_have_remote_offer(webrtc_s *webrtc);
+gchar *_check_and_encode_turn_url(const char *url);
void _init_data_channels(webrtc_s *webrtc);
void _destroy_data_channels(webrtc_s *webrtc);
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.2.178
+Version: 0.2.179
Release: 0
Group: Multimedia/API
License: Apache-2.0
{
gboolean ret = FALSE;
g_autoptr(GMutexLocker) locker = NULL;
- webrtc_s *_webrtc = (webrtc_s*)webrtc;
+ 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);
+
+ 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, g_strdup(turn_server));
+ _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;
}
g_free(dot_name);
}
+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;