Enums are added as below.
- WEBRTC_ICE_TRANSPORT_POLICY_ALL
- WEBRTC_ICE_TRANSPORT_POLICY_RELAY
Functions are added as below
- webrtc_set_ice_transport_policy()
- webrtc_get_ice_transport_policy()
[Version] 0.2.47
[Issue Type] API
Change-Id: I4d882d48038dc77fb2be848ae45d228de7a907c8
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
WEBRTC_ICE_CONNECTION_STATE_CLOSED, /**< Closed */
} webrtc_ice_connection_state_e;
+/**
+ * @brief Enumeration for WebRTC ICE transport policy.
+ * @since_tizen 6.5
+ */
+typedef enum {
+ WEBRTC_ICE_TRANSPORT_POLICY_ALL, /**< All */
+ WEBRTC_ICE_TRANSPORT_POLICY_RELAY, /**< Relay */
+} webrtc_ice_transport_policy_e;
+
/**
* @brief Enumeration for WebRTC media type.
* @since_tizen 6.5
* #WEBRTC_MEDIA_SOURCE_TYPE_MIC\n
* #WEBRTC_MEDIA_SOURCE_TYPE_FILE
* @since_tizen 6.5
- * @remarks The following sound stream types can be used for the @a stream_info:\n
+ * @remarks The following sound stream types can be used for the @a stream_info :\n
* #SOUND_STREAM_TYPE_MEDIA\n
* #SOUND_STREAM_TYPE_VOIP\n
* #SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY
*/
int webrtc_foreach_turn_server(webrtc_h webrtc, webrtc_turn_server_cb callback, void *user_data);
+/**
+ * @brief Sets a ICE transport policy that represents which candidates the ICE Agent is allowed to use.
+ * @since_tizen 6.5
+ * @remarks The @a policy enum corresponds with the RTCIceTransportPolicy enum described in https://www.w3.org/TR/webrtc/#rtcicetransportpolicy-enum.\n
+ * @param[in] webrtc WebRTC handle
+ * @param[in] policy The ICE transport policy
+ * @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_STATE Invalid state
+ * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE.
+ * @see webrtc_get_ice_transport_policy()
+ */
+int webrtc_set_ice_transport_policy(webrtc_h webrtc, webrtc_ice_transport_policy_e policy);
+
+/**
+ * @brief Gets the ICE transport policy.
+ * @since_tizen 6.5
+ * @remarks The @a policy enum corresponds with the RTCIceTransportPolicy enum described in https://www.w3.org/TR/webrtc/#rtcicetransportpolicy-enum.\n
+ * The default value is #WEBRTC_ICE_TRANSPORT_POLICY_ALL.
+ * @param[in] webrtc WebRTC handle
+ * @param[out] policy The ICE transport policy
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE Successful
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see webrtc_set_ice_transport_policy()
+ */
+int webrtc_get_ice_transport_policy(webrtc_h webrtc, webrtc_ice_transport_policy_e *policy);
+
/**
* @brief Sets a callback function to be invoked when the WebRTC peer connection state is changed.
* @since_tizen 6.5
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.2.46
+Version: 0.2.47
Release: 0
Group: Multimedia/API
License: Apache-2.0
return WEBRTC_ERROR_NONE;
}
+int webrtc_set_ice_transport_policy(webrtc_h webrtc, webrtc_ice_transport_policy_e policy)
+{
+ webrtc_s *_webrtc = (webrtc_s*)webrtc;
+
+ RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(policy > WEBRTC_ICE_TRANSPORT_POLICY_RELAY, WEBRTC_ERROR_INVALID_PARAMETER, "invalid policy(%d)", policy);
+
+ g_mutex_lock(&_webrtc->mutex);
+
+ RET_VAL_WITH_UNLOCK_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, &_webrtc->mutex, "the state should be IDLE");
+
+ g_object_set(G_OBJECT(_webrtc->gst.webrtcbin), "ice-transport-policy", (GstWebRTCICETransportPolicy)policy, NULL);
+
+ LOG_INFO("policy[%s]", (policy == WEBRTC_ICE_TRANSPORT_POLICY_ALL) ? "all" : "relay");
+
+ g_mutex_unlock(&_webrtc->mutex);
+
+ return WEBRTC_ERROR_NONE;
+}
+
+int webrtc_get_ice_transport_policy(webrtc_h webrtc, webrtc_ice_transport_policy_e *policy)
+{
+ webrtc_s *_webrtc = (webrtc_s*)webrtc;
+ GstWebRTCICETransportPolicy _policy;
+
+ RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(policy == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "policy is NULL");
+
+ g_mutex_lock(&_webrtc->mutex);
+
+ g_object_get(G_OBJECT(_webrtc->gst.webrtcbin), "ice-transport-policy", &_policy, NULL);
+
+ *policy = (webrtc_ice_transport_policy_e)_policy;
+
+ LOG_INFO("policy[%s]", (*policy == WEBRTC_ICE_TRANSPORT_POLICY_ALL) ? "all" : "relay");
+
+ g_mutex_unlock(&_webrtc->mutex);
+
+ return WEBRTC_ERROR_NONE;
+}
+
int webrtc_set_peer_connection_state_change_cb(webrtc_h webrtc, webrtc_peer_connection_state_change_cb callback, void *user_data)
{
webrtc_s *_webrtc = (webrtc_s*)webrtc;
CURRENT_STATUS_DATA_CHANNEL_SEND_FILE,
CURRENT_STATUS_SET_STUN_SERVER,
CURRENT_STATUS_ADD_TURN_SERVER,
+ CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY,
CURRENT_STATUS_SET_LOCAL_DESCRIPTION,
CURRENT_STATUS_SET_REMOTE_DESCRIPTION,
CURRENT_STATUS_SETTING_SIGNALING_SERVER,
g_print("webrtc_foreach_turn_server() success\n");
}
+static void _webrtc_set_ice_transport_policy(int index, int policy)
+{
+ int ret = 0;
+
+ ret = webrtc_set_ice_transport_policy(g_conns[index].webrtc, policy);
+ RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+
+ g_print("webrtc_set_ice_transport_policy() success\n");
+}
+
+static void _webrtc_get_ice_transport_policy(int index)
+{
+ int ret = 0;
+ webrtc_ice_transport_policy_e policy;
+
+ ret = webrtc_get_ice_transport_policy(g_conns[index].webrtc, &policy);
+ RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+
+ g_print("webrtc_get_ice_transport_policy() success, policy[%d]\n", policy);
+}
+
static char * __get_channel_label(webrtc_data_channel_h channel)
{
int ret = WEBRTC_ERROR_NONE;
} else if (strncmp(cmd, "gan", 3) == 0) {
_webrtc_get_all_negotiation_states(g_conn_index);
+ } else if (strncmp(cmd, "stp", 3) == 0) {
+ g_conns[g_conn_index].menu_state = CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY;
+
+ } else if (strncmp(cmd, "gtp", 3) == 0) {
+ _webrtc_get_ice_transport_policy(g_conn_index);
+
} else if (strncmp(cmd, "ssc", 3) == 0) {
g_conns[g_conn_index].menu_state = CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER;
g_print("gt. Get STUN server\n");
g_print("su. Add TURN server\t");
g_print("gu. Get TURN servers\n");
+ g_print("stp. Set ICE transport policy\t");
+ g_print("gtp. Get ICE transport policy\n");
g_print("co. Create offer\t");
g_print("ca. Create answer\n");
g_print("sl. Set local description\t");
} else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_ADD_TURN_SERVER) {
g_print("*** input TURN server address.\n");
+ } else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY) {
+ g_print("*** input ICE transport policy.(0:all, 1:relay)\n");
+
} else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_SET_LOCAL_DESCRIPTION) {
g_print("*** input type of local description.(1:offer, 2:answer)\n");
reset_menu_state();
break;
}
+ case CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY: {
+ value = atoi(cmd);
+ _webrtc_set_ice_transport_policy(g_conn_index, value);
+ reset_menu_state();
+ break;
+ }
case CURRENT_STATUS_SET_LOCAL_DESCRIPTION: {
value = atoi(cmd);
if (value == 1)