[ITC][webrtc][Non-ACR] Fix bug in ITc_webrtc_start_and_finish_negotiation_p() 75/281175/1
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 14 Sep 2022 05:14:50 +0000 (14:14 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 14 Sep 2022 05:16:19 +0000 (14:16 +0900)
Previously, checking track_added_cb was omitted and the webrtc state was
released immediately after setting remote description to offerer handle
which is not expected. It is fixed now.

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

index aa9607cbd49da7c173c014191196cfd645729459..231465ce7d00ae49ec5973061669eb900ca5e49c 100755 (executable)
@@ -2065,8 +2065,10 @@ int ITc_webrtc_start_and_finish_negotiation_p(void)
        GList *answerICECandidates = NULL;
        callback_data cb_data;
        callback_data cb_data2;
+       callback_data cb_data3;
        INIT_CALLBACK_DATA(cb_data);
        INIT_CALLBACK_DATA(cb_data2);
+       INIT_CALLBACK_DATA(cb_data3);
 
        nRet = webrtc_create(&webrtcOfferer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create", WebRtcGetError(nRet));
@@ -2113,7 +2115,7 @@ int ITc_webrtc_start_and_finish_negotiation_p(void)
        nRet = webrtc_set_ice_gathering_state_change_cb(webrtcAnswerer, webrtcIceGatheringStateChangeCB, &cb_data2);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_ice_gathering_state_change_cb", WebRtcGetError(nRet));
 
-       nRet = webrtc_set_track_added_cb(webrtcAnswerer, webrtcTrackAddedCB, &cb_data2);
+       nRet = webrtc_set_track_added_cb(webrtcAnswerer, webrtcTrackAddedCB, &cb_data3);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_track_added_cb", WebRtcGetError(nRet));
 
        g_mutex_lock(&cb_data2.mutex);
@@ -2169,22 +2171,24 @@ int ITc_webrtc_start_and_finish_negotiation_p(void)
                FPRINTF("[Line : %d][%s] Callback webrtcIceGatheringStateChangeCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
+       cb_data2.is_invoked = false;
 
        g_list_foreach(offerICECandidates, __foreach_ice_candidate, webrtcAnswerer);
        g_list_foreach(answerICECandidates, __foreach_ice_candidate, webrtcOfferer);
 
-       g_mutex_lock(&cb_data2.mutex);
+       g_mutex_lock(&cb_data3.mutex);
 
        nRet = webrtc_set_remote_description(webrtcOfferer, answerSDP);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_remote_description", WebRtcGetError(nRet));
        FREE_MEMORY(answerSDP);
 
        /* wait for track added callback of answerer */
-       RUN_POLLING_LOOP(cb_data2);
-       if (!cb_data2.is_invoked) {
+       RUN_POLLING_LOOP(cb_data3);
+       if (!cb_data3.is_invoked) {
                FPRINTF("[Line : %d][%s] Callback webrtcTrackAddedCB not invoked\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
+       cb_data3.is_invoked = false;
 
        nRet = webrtc_stop(webrtcOfferer);
        PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_stop", WebRtcGetError(nRet));