From: Sangchul Lee Date: Thu, 29 Apr 2021 10:51:20 +0000 (+0900) Subject: webrtc_test: Add test cases for new negotiation callbacks X-Git-Tag: submit/tizen/20210729.023123~76 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F257687%2F6;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_test: Add test cases for new negotiation callbacks san. Set all the negotiation change callbacks uan. Unset all the negotiation change callbacks [Version] 0.1.165 [Issue Type] Test application Change-Id: Ib7eb8e7f89806d6fda22d32ecc12d94d2e5501c4 Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index bd22eb32..98cd78c7 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.1.164 +Version: 0.1.165 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/test/webrtc_test.c b/test/webrtc_test.c index be8f62de..61c5b01a 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -1301,6 +1301,84 @@ static void _webrtc_unset_ice_candidate_cb(int index) g_print("webrtc_unset_ice_candidate_cb() success\n"); } +static void __peer_connection_state_change_cb(webrtc_h webrtc, webrtc_peer_connection_state_e state, void *user_data) +{ + g_print("__peer_connection_state_change_cb() is invoked, state[%d]\n", state); +} + +static void __signaling_state_change_cb(webrtc_h webrtc, webrtc_signaling_state_e state, void *user_data) +{ + g_print("__signaling_state_change_cb() is invoked, state[%d]\n", state); +} + +static void __ice_gathering_state_change_cb(webrtc_h webrtc, webrtc_ice_gathering_state_e state, void *user_data) +{ + g_print("__ice_gathering_state_change_cb() is invoked, state[%d]\n", state); +} + +static void __ice_connection_state_change_cb(webrtc_h webrtc, webrtc_ice_connection_state_e state, void *user_data) +{ + g_print("__ice_connection_state_change_cb() is invoked, state[%d]\n", state); +} + +static void _webrtc_set_all_negotiation_state_change_cbs(int index) +{ + int ret = WEBRTC_ERROR_NONE; + + ret = webrtc_set_peer_connection_state_change_cb(g_conns[index].webrtc, __peer_connection_state_change_cb, g_conns[index].webrtc); + if (ret != WEBRTC_ERROR_NONE) + g_print("failed to webrtc_set_peer_connection_state_change_cb()\n"); + else + g_print("webrtc_set_peer_connection_state_change_cb() success\n"); + + ret = webrtc_set_signaling_state_change_cb(g_conns[index].webrtc, __signaling_state_change_cb, g_conns[index].webrtc); + if (ret != WEBRTC_ERROR_NONE) + g_print("failed to webrtc_set_signaling_state_change_cb()\n"); + else + g_print("webrtc_set_signaling_state_change_cb() success\n"); + + ret = webrtc_set_ice_gathering_state_change_cb(g_conns[index].webrtc, __ice_gathering_state_change_cb, g_conns[index].webrtc); + if (ret != WEBRTC_ERROR_NONE) + g_print("failed to webrtc_set_ice_gathering_state_change_cb()\n"); + else + g_print("webrtc_set_ice_gathering_state_change_cb() success\n"); + + ret = webrtc_set_ice_connection_state_change_cb(g_conns[index].webrtc, __ice_connection_state_change_cb, g_conns[index].webrtc); + if (ret != WEBRTC_ERROR_NONE) + g_print("failed to webrtc_set_ice_connection_state_change_cb()\n"); + else + g_print("webrtc_set_ice_connection_state_change_cb() success\n"); +} + +static void _webrtc_unset_all_negotiation_state_change_cbs(int index) +{ + int ret = WEBRTC_ERROR_NONE; + + ret = webrtc_unset_peer_connection_state_change_cb(g_conns[index].webrtc); + if (ret != WEBRTC_ERROR_NONE) + g_print("failed to webrtc_unset_peer_connection_state_change_cb()\n"); + else + g_print("webrtc_unset_peer_connection_state_change_cb() success\n"); + + ret = webrtc_unset_signaling_state_change_cb(g_conns[index].webrtc); + if (ret != WEBRTC_ERROR_NONE) + g_print("failed to webrtc_unset_signaling_state_change_cb()\n"); + else + g_print("webrtc_unset_signaling_state_change_cb() success\n"); + + ret = webrtc_unset_ice_gathering_state_change_cb(g_conns[index].webrtc); + if (ret != WEBRTC_ERROR_NONE) + g_print("failed to webrtc_unset_ice_gathering_state_change_cb()\n"); + else + g_print("webrtc_unset_ice_gathering_state_change_cb() success\n"); + + ret = webrtc_unset_ice_connection_state_change_cb(g_conns[index].webrtc); + if (ret != WEBRTC_ERROR_NONE) + g_print("failed to webrtc_unset_ice_connection_state_change_cb()\n"); + else + g_print("webrtc_unset_ice_connection_state_change_cb() success\n"); +} + static void __track_added_cb(webrtc_h webrtc, webrtc_media_type_e type, unsigned int id, void *user_data) { connection_s *conn = (connection_s *)user_data; @@ -2968,12 +3046,19 @@ void _interpret_main_menu(char *cmd) _webrtc_set_ice_candidate_cb(g_conn_index); _webrtc_set_track_added_cb(g_conn_index); _webrtc_set_data_channel_cb(g_conn_index); + _webrtc_set_all_negotiation_state_change_cbs(g_conn_index); for (i = 0; i < MAX_MEDIA_PACKET_SOURCE_LEN; i++) { if (g_conns[g_conn_index].packet_sources[i].source_id > 0) _webrtc_media_packet_source_set_buffer_state_changed_cb(g_conn_index, g_conns[g_conn_index].packet_sources[i].source_id); } + } else if (strncmp(cmd, "san", 3) == 0) { + _webrtc_set_all_negotiation_state_change_cbs(g_conn_index); + + } else if (strncmp(cmd, "uan", 3) == 0) { + _webrtc_unset_all_negotiation_state_change_cbs(g_conn_index); + } else if (strncmp(cmd, "ssc", 3) == 0) { g_conns[g_conn_index].menu_state = CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER; @@ -3083,6 +3168,8 @@ void display_sub_basic() g_print("zf. Send file via data channel\n"); g_print("------------------------------------- Callbacks -----------------------------------------\n"); g_print("sac. Set all callbacks below (except for the encoded frame callbacks)\n"); + g_print("san. Set all the negotiation change callbacks\t"); + g_print("uan. Unset all the negotiation change callbacks\n"); g_print("se. Set error callback\t"); g_print("ue. Unset error callback\n"); g_print("sc. Set state changed callback\t");