webrtc_test: Add test cases for new negotiation callbacks 87/257687/6
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 29 Apr 2021 10:51:20 +0000 (19:51 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 6 May 2021 04:30:24 +0000 (13:30 +0900)
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 <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
test/webrtc_test.c

index bd22eb32dec2474f5d844fcd77b1004d15cf5ef1..98cd78c77b282f21e375c7cc91dc4d03ce053653 100644 (file)
@@ -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
index be8f62de16a653af020480da654c6c81e1923622..61c5b01a3cdf13c297fb94bbea28bfe6533e1de7 100644 (file)
@@ -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");