[ITC][webrtc][non-ACR] Add parameter to RUN_POLLING_LOOP and QUIT_LOOP macros 86/268886/2
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 4 Jan 2022 07:02:14 +0000 (16:02 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 6 Jan 2022 02:45:33 +0000 (11:45 +0900)
Change-Id: I94a93bc8d1b59a0db6796636d43b7f0f4def3a09
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
src/itc/webrtc/ITs-webrtc-common.h
src/itc/webrtc/ITs-webrtc.c

index 787bfa2b9fe20b5c0fd8b28eece9a78bfc79ac31..76c04758b85881eacb414bcaba66a01049440ee4 100755 (executable)
        }\
 }
 
-#define RUN_POLLING_LOOP {\
-       if(!g_bCallbackCalled) {\
-               guint nTimeoutId;\
-               g_pMainLoop = g_main_loop_new(NULL, false);\
-               nTimeoutId = g_timeout_add(TIMEOUT_CB, Timeout, g_pMainLoop);\
-               dlog_print(DLOG_DEBUG, "NativeTCT", "[%s(%d)] call g_main_loop_run(), g_pMainLoop[%p]", __FUNCTION__, __LINE__, g_pMainLoop);\
-               g_main_loop_run(g_pMainLoop);\
-               g_source_remove(nTimeoutId);\
-               g_pMainLoop = NULL;\
-       }\
-}
+#define RUN_POLLING_LOOP(x_mainloop, x_cb_called)\
+do {\
+       if(x_cb_called)\
+               break;\
+       x_mainloop = g_main_loop_new(NULL, false);\
+       guint timeout_id = g_timeout_add(TIMEOUT_CB, Timeout, x_mainloop);\
+       dlog_print(DLOG_DEBUG, "NativeTCT", "[%s(%d)] call g_main_loop_run(), mainloop[%p]", __FUNCTION__, __LINE__, x_mainloop);\
+       g_main_loop_run(x_mainloop);\
+       g_source_remove(timeout_id);\
+       x_mainloop = NULL;\
+} while (0)
 
-#define QUIT_LOOP {\
-       if (g_pMainLoop) {\
-               dlog_print(DLOG_DEBUG, "NativeTCT", "[%s(%d)] call g_main_loop_quit(), g_pMainLoop[%p]", __FUNCTION__, __LINE__, g_pMainLoop);\
-               g_main_loop_quit(g_pMainLoop);\
-       }\
-}
+#define QUIT_LOOP(x_mainloop)\
+do {\
+       if (!x_mainloop)\
+               break;\
+       dlog_print(DLOG_DEBUG, "NativeTCT", "[%s(%d)] call g_main_loop_quit(), mainloop[%p]", __FUNCTION__, __LINE__, x_mainloop);\
+       g_main_loop_quit(x_mainloop);\
+} while (0)
 
 #define CHECK_HANDLE_CLEANUP(Handle, API, FreeResource) {\
        if (!Handle) {\
index 89758d18922c122b636c708a2ab265f7a743124a..f7d614ddbe7163a5b493f1ba024c1af2187d03ce 100755 (executable)
@@ -67,7 +67,7 @@ static void webrtcSessionDescriptionCreatedCB(webrtc_h webrtc, const char *descr
 {
        g_bCallbackCalled = true;
        FPRINTF("[Line : %d][%s] Callback webrtcSessionDescriptionCreatedCB called\\n", __LINE__, API_NAMESPACE);
-       QUIT_LOOP;
+       QUIT_LOOP(g_pMainLoop);
 }
 
 /**
@@ -99,7 +99,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);
-       QUIT_LOOP;
+       QUIT_LOOP(g_pMainLoop);
 }
 
 /**
@@ -111,7 +111,7 @@ static void webrtcSignalingStateChangeCB(webrtc_h webrtc, webrtc_signaling_state
 {
        g_bCallbackCalled = true;
        FPRINTF("[Line : %d][%s] Callback webrtcSignalingStateChangeCB called\\n", __LINE__, API_NAMESPACE);
-       QUIT_LOOP;
+       QUIT_LOOP(g_pMainLoop);
 }
 
 /**
@@ -246,7 +246,7 @@ int ITc_webrtc_start_stop_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked for %s\\n", __LINE__, API_NAMESPACE, "webrtc_set_state_changed_cb");
                return 1;
@@ -916,7 +916,7 @@ int ITc_media_webrtc_create_offer_answer_p(void)
        nRet = webrtc_start(hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -942,7 +942,7 @@ int ITc_media_webrtc_create_offer_answer_p(void)
        nRet = webrtc_start(hLocalWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -952,7 +952,7 @@ int ITc_media_webrtc_create_offer_answer_p(void)
        nRet = webrtc_set_remote_description(hLocalWebRtcHandle, pszOffer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_remote_description", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcSignalingStateChangeCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1016,7 +1016,7 @@ int ITc_media_webrtc_set_local_description_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1072,7 +1072,7 @@ int ITc_media_webrtc_set_remote_description_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1094,7 +1094,7 @@ int ITc_media_webrtc_set_remote_description_p(void)
        nRet = webrtc_start(hLocalWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1147,7 +1147,7 @@ int ITc_media_webrtc_add_ice_candidate_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1373,7 +1373,7 @@ int ITc_media_webrtc_create_offer_async_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1382,7 +1382,7 @@ int ITc_media_webrtc_create_offer_async_p(void)
        nRet = webrtc_create_offer_async(g_hWebRtcHandle, NULL, webrtcSessionDescriptionCreatedCB, NULL);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create_offer_async", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcSessionDescriptionCreatedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1430,7 +1430,7 @@ int ITc_media_webrtc_create_answer_async_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1455,7 +1455,7 @@ int ITc_media_webrtc_create_answer_async_p(void)
        nRet = webrtc_start(hLocalWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1465,7 +1465,7 @@ int ITc_media_webrtc_create_answer_async_p(void)
        nRet = webrtc_set_remote_description(hLocalWebRtcHandle, pszOffer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_remote_description", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcSignalingStateChangeCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1475,7 +1475,7 @@ int ITc_media_webrtc_create_answer_async_p(void)
        nRet = webrtc_create_answer_async(hLocalWebRtcHandle, NULL, webrtcSessionDescriptionCreatedCB, NULL);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create_answer_async", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcSessionDescriptionCreatedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1537,7 +1537,7 @@ int ITc_media_webrtc_media_source_set_audio_loopback_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1591,7 +1591,7 @@ int ITc_media_webrtc_media_source_set_video_loopback_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1643,7 +1643,7 @@ int ITc_media_webrtc_set_get_display_mode_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1706,7 +1706,7 @@ int ITc_media_webrtc_set_get_display_visible_p(void)
        nRet = webrtc_start(g_hWebRtcHandle);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet));
 
-       RUN_POLLING_LOOP;
+       RUN_POLLING_LOOP(g_pMainLoop, g_bCallbackCalled);
        if (!g_bCallbackCalled) {
                FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;