*/
int webrtc_set_stun_server(webrtc_h webrtc, const char *stun_server);
+/**
+ * @brief Gets the STUN server URL.
+ * @since_tizen 6.5
+ * @remarks The @a stun_server should be released using free().
+ * @param[in] webrtc WebRTC handle
+ * @param[out] stun_server The STUN server URL
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE Successful
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int webrtc_get_stun_server(webrtc_h webrtc, char **stun_server);
+
/**
* @brief Sets a negotiation needed callback function to be invoked when a change has occurred which requires session negotiation.
* @since_tizen 6.5
return WEBRTC_ERROR_NONE;
}
+int webrtc_get_stun_server(webrtc_h webrtc, char **stun_server)
+{
+ webrtc_s *_webrtc = (webrtc_s*)webrtc;
+
+ RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(stun_server == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "stun_server is NULL");
+
+ g_mutex_lock(&_webrtc->mutex);
+
+ if (_webrtc->stun_server_url == NULL)
+ *stun_server = NULL;
+ else
+ *stun_server = strdup(_webrtc->stun_server_url);
+
+ LOG_INFO("stun_server[%s]", *stun_server);
+
+ g_mutex_unlock(&_webrtc->mutex);
+
+ return WEBRTC_ERROR_NONE;
+}
+
int webrtc_set_negotiation_needed_cb(webrtc_h webrtc, webrtc_negotiation_needed_cb callback, void *user_data)
{
webrtc_s *_webrtc = (webrtc_s*)webrtc;
static SoupWebsocketConnection *g_ws_conn;
static gint32 g_local_peer_id;
static gchar g_signaling_server[MAX_STRING_LEN];
-static gchar g_stun_server[MAX_STRING_LEN];
static gchar g_proxy[MAX_STRING_LEN];
static int g_server_status = SERVER_STATUS_DISCONNECTED;
static int g_menu_state = CURRENT_STATUS_MAINMENU;
if (!uri)
return;
- ret = __copy_string_arr(g_stun_server, uri);
- if (ret != 0)
- return;
-
- ret = webrtc_set_stun_server(g_webrtc, g_stun_server);
+ webrtc_set_stun_server(g_webrtc, uri);
if (ret != WEBRTC_ERROR_NONE)
- g_print("failed to webrtc_set_stun_server(), uri[%s]\n", g_stun_server);
+ g_print("failed to webrtc_set_stun_server(), uri[%s], ret[0x%x]\n", uri, ret);
else
- g_print("webrtc_set_stun_server() success, uri[%s]\n", g_stun_server);
+ g_print("webrtc_set_stun_server() success, uri[%s]\n", uri);
+}
+
+static void _webrtc_get_stun_server(void)
+{
+ int ret = WEBRTC_ERROR_NONE;
+ char *stun_server;
+
+ ret = webrtc_get_stun_server(g_webrtc, &stun_server);
+ if (ret != WEBRTC_ERROR_NONE) {
+ g_print("failed to webrtc_get_stun_server(), ret[0x%x]\n", ret);
+ } else {
+ g_print("STUN server[%s]", stun_server);
+ free(stun_server);
+ }
}
static void __data_channel_open_cb(webrtc_data_channel_h channel, void *user_data)
} else if (strncmp(cmd, "st", 2) == 0) {
g_menu_state = CURRENT_STATUS_SET_STUN_SERVER;
+ } else if (strncmp(cmd, "gt", 2) == 0) {
+ _webrtc_get_stun_server();
+
} else if (strncmp(cmd, "ss", 2) == 0) {
g_menu_state = CURRENT_STATUS_SETTING_SIGNALING_SERVER;
{
int ret = WEBRTC_ERROR_NONE;
webrtc_state_e state;
- int len_stun_server = strlen(g_stun_server);
+ char *stun_server;
if (g_webrtc == NULL)
return;
if (ret != WEBRTC_ERROR_NONE)
return;
+ ret = webrtc_get_stun_server(g_webrtc, &stun_server);
+ if (ret != WEBRTC_ERROR_NONE)
+ return;
+
g_print(" state[%s]", g_webrtc_state_str[state]);
- if (len_stun_server > 0)
- g_print(" STUN server[%s]", g_stun_server); /* FIXME: get from API */
+ if (strlen(stun_server) > 0)
+ g_print(" STUN server[%s]", stun_server);
+
+ free(stun_server);
g_print("\n-----------------------------------------------------------------------------------------\n");
}
g_print("sz. Set data channel callback\t");
g_print("uz. Unset data channel callback\n");
g_print("------------------------------------- Negotiation ---------------------------------------\n");
- g_print("st. Set STUN server\n");
+ g_print("st. Set STUN server\t");
+ g_print("gt. Get STUN server\n");
g_print("co. Create offer\t");
g_print("ca. Create answer\n");
g_print("sl. Set local description\t");