[ITC][webrtc][non-ACR] Fix failure on emulator 29/265229/1
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 13 Oct 2021 04:50:08 +0000 (13:50 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 13 Oct 2021 04:51:55 +0000 (13:51 +0900)
Missing initializing global variable for polling is added.
Remove unnecessary global variable and use the previous one.

Change-Id: I7596aaeb43d23da52213626eee0e377bcdf77def
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
src/itc/webrtc/ITs-webrtc-common.h
src/itc/webrtc/ITs-webrtc.c

index 2ac1b7a3621be2a968edfcd16c32c5ed7274719d..48d882c5ff8dc2822fb97bb6c5eaaa4167179523 100755 (executable)
@@ -65,7 +65,6 @@ webrtc_h g_hWebRtcHandle;
 int g_nTimeoutId;
 static GMainLoop *g_pMainLoop = NULL;
 bool g_bCallbackCalled;
-bool g_bCallbackSessionCalled;
 gboolean Timeout(gpointer data);
 char* WebRtcGetError(int nErrorType);
 /** @} */
index 04b8476e16eeafd72dd59afee27ea43027650066..4c989ce283490a28d278f3bfbee2e9e59d1f53f5 100755 (executable)
@@ -65,9 +65,9 @@ static void destroyWindow()
 */
 static void webrtcSessionDescriptionCreatedCB(webrtc_h webrtc, const char *description, void *user_data)
 {
-       g_bCallbackSessionCalled = true;
+       g_bCallbackCalled = true;
        FPRINTF("[Line : %d][%s] Callback webrtcSessionDescriptionCreatedCB called\\n", __LINE__, API_NAMESPACE);
-       if (g_pMainLoop )
+       if (g_pMainLoop)
        {
                g_main_loop_quit(g_pMainLoop);
                g_pMainLoop = NULL;
@@ -103,7 +103,7 @@ static void webrtcStateChangedCB(webrtc_h webrtc, webrtc_state_e previous, webrt
 {
        g_bCallbackCalled = true;
        FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB called\\n", __LINE__, API_NAMESPACE);
-       if (g_pMainLoop )
+       if (g_pMainLoop)
        {
                g_main_loop_quit(g_pMainLoop);
                g_pMainLoop = NULL;
@@ -119,7 +119,7 @@ static void webrtcSignalingStateChangeCB(webrtc_h webrtc, webrtc_signaling_state
 {
        g_bCallbackCalled = true;
        FPRINTF("[Line : %d][%s] Callback webrtcSignalingStateChangeCB called\\n", __LINE__, API_NAMESPACE);
-       if (g_pMainLoop )
+       if (g_pMainLoop)
        {
                g_main_loop_quit(g_pMainLoop);
                g_pMainLoop = NULL;
@@ -269,11 +269,8 @@ int ITc_webrtc_start_stop_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "webrtc_set_state_changed_cb");
-               webrtc_stop(g_hWebRtcHandle);
                return 1;
        }
 
@@ -935,17 +932,15 @@ int ITc_media_webrtc_create_offer_answer_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
+       g_bCallbackCalled = false;
 
        nRet = webrtc_create_offer(hWebRtcHandle, NULL, &pszOffer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create_offer", WebRtcGetError(nRet));
 
-       g_bCallbackCalled = false;
        nRet = webrtc_create(&hLocalWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create", WebRtcGetError(nRet));
        CHECK_HANDLE(hLocalWebRtcHandle, "webrtc_create");
@@ -963,11 +958,20 @@ int ITc_media_webrtc_create_offer_answer_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
+       if (!g_bCallbackCalled) {
+               FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
+               return 1;
+       }
+       g_bCallbackCalled = false;
 
        nRet = webrtc_set_remote_description(hLocalWebRtcHandle, pszOffer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_remote_description", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
+       if (!g_bCallbackCalled) {
+               FPRINTF("[Line : %d][%s] Callback webrtcSignalingStateChangeCB not invoked\\n", __LINE__, API_NAMESPACE);
+               return 1;
+       }
 
        nRet = webrtc_create_answer(hLocalWebRtcHandle, NULL, &pszAnswer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create_answer", WebRtcGetError(nRet));
@@ -1029,9 +1033,7 @@ int ITc_media_webrtc_set_local_description_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
@@ -1088,9 +1090,7 @@ int ITc_media_webrtc_set_remote_description_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
@@ -1112,9 +1112,7 @@ int ITc_media_webrtc_set_remote_description_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
@@ -1168,9 +1166,7 @@ int ITc_media_webrtc_add_ice_candidate_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
@@ -1381,7 +1377,6 @@ int ITc_media_webrtc_create_offer_async_p(void)
        char *pszOffer, *pszAnswer;
        webrtc_h hLocalWebRtcHandle;
        g_bCallbackCalled = false;
-       g_bCallbackSessionCalled = false;
        int nTimeoutId = -1;
 
        int nRet = webrtc_add_media_source(g_hWebRtcHandle, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA, &nId);
@@ -1397,9 +1392,7 @@ int ITc_media_webrtc_create_offer_async_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
@@ -1408,6 +1401,10 @@ int ITc_media_webrtc_create_offer_async_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create_offer_async", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
+       if (!g_bCallbackCalled) {
+               FPRINTF("[Line : %d][%s] Callback webrtcSessionDescriptionCreatedCB not invoked\\n", __LINE__, API_NAMESPACE);
+               return 1;
+       }
 
        nRet = webrtc_stop(g_hWebRtcHandle);
        PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_stop", WebRtcGetError(nRet));
@@ -1438,7 +1435,6 @@ int ITc_media_webrtc_create_answer_async_p(void)
        char *pszOffer, *pszAnswer;
        webrtc_h hLocalWebRtcHandle, hWebRtcHandle;
        g_bCallbackCalled = false;
-       g_bCallbackSessionCalled = false;
        int nTimeoutId = -1;
 
        int nRet = webrtc_add_media_source(g_hWebRtcHandle, WEBRTC_MEDIA_SOURCE_TYPE_MIC, &nId);
@@ -1454,17 +1450,15 @@ int ITc_media_webrtc_create_answer_async_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
+       g_bCallbackCalled = false;
 
        nRet = webrtc_create_offer(g_hWebRtcHandle, NULL, &pszOffer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create_offer", WebRtcGetError(nRet));
 
-       g_bCallbackCalled = false;
        nRet = webrtc_create(&hLocalWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create", WebRtcGetError(nRet));
 
@@ -1481,26 +1475,30 @@ int ITc_media_webrtc_create_answer_async_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
+       g_bCallbackCalled = false;
 
        nRet = webrtc_set_remote_description(hLocalWebRtcHandle, pszOffer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_remote_description", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcSignalingStateChangeCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
+       g_bCallbackCalled = false;
 
        nRet = webrtc_create_answer_async(hLocalWebRtcHandle, NULL, webrtcSessionDescriptionCreatedCB, NULL);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create_answer_async", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
+       if (!g_bCallbackCalled) {
+               FPRINTF("[Line : %d][%s] Callback webrtcSessionDescriptionCreatedCB not invoked\\n", __LINE__, API_NAMESPACE);
+               return 1;
+       }
 
        FREE_MEMORY(pszOffer);
 
@@ -1560,9 +1558,7 @@ int ITc_media_webrtc_media_source_set_audio_loopback_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
@@ -1618,9 +1614,7 @@ int ITc_media_webrtc_media_source_set_video_loopback_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
@@ -1674,9 +1668,7 @@ int ITc_media_webrtc_set_get_display_mode_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
@@ -1737,9 +1729,7 @@ int ITc_media_webrtc_set_get_display_visible_p(void)
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
        RUN_POLLING_LOOP;
-       if(g_bCallbackCalled != true)
-       {
-
+       if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }