[ITC][webrtc][non-ACR] Fix to wait for signaling state change before creating answer 60/264660/2
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 28 Sep 2021 03:40:09 +0000 (12:40 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 28 Sep 2021 03:52:11 +0000 (12:52 +0900)
Change-Id: I2329f439d4120500a763a49ffa36fb0b233ff09e
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
src/itc/webrtc/ITs-webrtc.c

index 204694b4df65649c8d0ba57ca0405e934cee07e8..04b8476e16eeafd72dd59afee27ea43027650066 100755 (executable)
@@ -117,6 +117,7 @@ static void webrtcStateChangedCB(webrtc_h webrtc, webrtc_state_e previous, webrt
 */
 static void webrtcSignalingStateChangeCB(webrtc_h webrtc, webrtc_signaling_state_e state, void *user_data)
 {
+       g_bCallbackCalled = true;
        FPRINTF("[Line : %d][%s] Callback webrtcSignalingStateChangeCB called\\n", __LINE__, API_NAMESPACE);
        if (g_pMainLoop )
        {
@@ -937,7 +938,7 @@ int ITc_media_webrtc_create_offer_answer_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1031,7 +1032,7 @@ int ITc_media_webrtc_set_local_description_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1090,7 +1091,7 @@ int ITc_media_webrtc_set_remote_description_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1114,7 +1115,7 @@ int ITc_media_webrtc_set_remote_description_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1170,7 +1171,7 @@ int ITc_media_webrtc_add_ice_candidate_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1399,7 +1400,7 @@ int ITc_media_webrtc_create_offer_async_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1456,7 +1457,7 @@ int ITc_media_webrtc_create_answer_async_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1473,14 +1474,16 @@ int ITc_media_webrtc_create_answer_async_p(void)
        nRet = webrtc_set_state_changed_cb(hLocalWebRtcHandle, webrtcStateChangedCB, NULL);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_state_changed_cb", WebRtcGetError(nRet));
 
+       nRet = webrtc_set_signaling_state_change_cb(hLocalWebRtcHandle, webrtcSignalingStateChangeCB, NULL);
+       PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_signaling_state_change_cb", WebRtcGetError(nRet));
+
        nRet = webrtc_start(hLocalWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
        if(g_bCallbackCalled != true)
        {
-
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1488,6 +1491,11 @@ int ITc_media_webrtc_create_answer_async_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_remote_description", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
+       if(g_bCallbackCalled != true)
+       {
+               FPRINTF("[Line : %d][%s] Callback webrtcSignalingStateChangeCB not invoked\\n", __LINE__, API_NAMESPACE);
+               return 1;
+       }
 
        nRet = webrtc_create_answer_async(hLocalWebRtcHandle, NULL, webrtcSessionDescriptionCreatedCB, NULL);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create_answer_async", WebRtcGetError(nRet));
@@ -1555,7 +1563,7 @@ int ITc_media_webrtc_media_source_set_audio_loopback_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1613,7 +1621,7 @@ int ITc_media_webrtc_media_source_set_video_loopback_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1669,7 +1677,7 @@ int ITc_media_webrtc_set_get_display_mode_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
 
@@ -1732,7 +1740,7 @@ int ITc_media_webrtc_set_get_display_visible_p(void)
        if(g_bCallbackCalled != true)
        {
 
-               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "rpc_port_proxy_add_rejected_event_cb");
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }