#define TEST_STRING_DATA "test string"
#define TEST_BUFFER_SIZE 16
#define TEST_FPS 30
+#define TEST_PAYLOAD_TYPE_OPUS 96
static char g_test_buffer[TEST_BUFFER_SIZE] = {'t', 'e', 's', 't', 'b', 'u', 'f', '\0', };
static bool g_bIsMicrophoneFeatureSupported;
return 0;
}
+
+
+//& purpose: Starts the WebRTC synchronously
+//& type: auto
+/**
+* @testcase ITc_webrtc_start_sync_p
+* @since_tizen 9.0
+* @author SRID(shobhit.v)
+* @reviewer SRID(tarun1.kumar)
+* @type auto
+* @description Starts the WebRTC.
+* @scenario Create a webrtc handle, set ice candidate callback and start webRTC
+* @apicovered webrtc_set_ice_candidate_cb and webrtc_start_sync
+* @passcase If webrtc_set_ice_candidate_cb and webrtc_start_sync is successful
+* @failcase If webrtc_set_ice_candidate_cb Or webrtc_start_sync fails
+* @precondition NA
+* @postcondition NA
+*/
+int ITc_webrtc_start_sync_p(void)
+{
+ START_TEST;
+
+ int nRet = webrtc_set_ice_candidate_cb(g_hWebRtcHandle, webrtcIceCandidateCB, NULL);
+ PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_set_ice_candidate_cb", WebRtcGetError(nRet));
+
+ nRet = webrtc_start_sync(g_hWebRtcHandle);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_start_sync", WebRtcGetError(nRet), webrtc_unset_ice_candidate_cb(g_hWebRtcHandle));
+
+ webrtc_unset_ice_candidate_cb(g_hWebRtcHandle);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_unset_ice_candidate_cb", WebRtcGetError(nRet));
+ return 0;
+}
+
+//& purpose: Sets the RTP payload type to the media source and get RTP payload type of the media source
+//& type: auto
+/**
+* @testcase ITc_webrtc_media_source_set_get_payload_type_p
+* @since_tizen 9.0
+* @author SRID(shobhit.v)
+* @reviewer SRID(tarun1.kumar)
+* @type auto
+* @description Set RTP payload type to the media source and get it
+* @scenario Create a webrtc handle, Add media source, Set and Get payload type
+* @apicovered webrtc_add_media_source, webrtc_media_source_set_payload_type and webrtc_media_source_get_payload_type
+* @passcase If webrtc_add_media_source, webrtc_media_source_set_payload_type and webrtc_media_source_get_payload_type is successful
+* @failcase If webrtc_add_media_source Or webrtc_media_source_set_payload_type Or webrtc_media_source_get_payload_type fails
+* @precondition NA
+* @postcondition NA
+*/
+int ITc_webrtc_media_source_set_get_payload_type_p(void)
+{
+ START_TEST;
+ unsigned int nId = -1;
+ unsigned int nGetpayloadType = -1;
+
+ int nRet = webrtc_add_media_source(g_hWebRtcHandle, WEBRTC_MEDIA_SOURCE_TYPE_MIC, &nId);
+ if (!g_bIsMicrophoneFeatureSupported)
+ {
+ PRINT_RESULT(WEBRTC_ERROR_NOT_SUPPORTED, nRet, "webrtc_add_media_source", WebRtcGetError(nRet));
+ nRet = webrtc_add_media_source(g_hWebRtcHandle, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, &nId);
+ }
+ PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_add_media_source", WebRtcGetError(nRet));
+ if (nId < 0)
+ {
+ FPRINTF("[Line : %d][%s] webrtc_add_media_source failed, ID is invalid\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ nRet = webrtc_media_source_set_payload_type(g_hWebRtcHandle, nId, WEBRTC_TRANSCEIVER_CODEC_OPUS, TEST_PAYLOAD_TYPE_OPUS);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_media_source_set_payload_type", WebRtcGetError(nRet), webrtc_remove_media_source(g_hWebRtcHandle, nId));
+
+ nRet = webrtc_media_source_get_payload_type(g_hWebRtcHandle, nId, WEBRTC_TRANSCEIVER_CODEC_OPUS, &nGetpayloadType);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_media_source_get_payload_type", WebRtcGetError(nRet), webrtc_remove_media_source(g_hWebRtcHandle, nId));
+
+ if (nGetpayloadType != TEST_PAYLOAD_TYPE_OPUS)
+ {
+ FPRINTF("[Line : %d][%s] Set and get Payload type is different\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+ nRet = webrtc_remove_media_source(g_hWebRtcHandle, nId);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_remove_media_source", WebRtcGetError(nRet));
+
+ return 0;
+}
+
+//& purpose: Gets the local session description
+//& type: auto
+/**
+* @testcase ITc_webrtc_get_local_description_p
+* @since_tizen 9.0
+* @author SRID(shobhit.v)
+* @reviewer SRID(tarun1.kumar)
+* @type auto
+* @description Gets the local session description
+* @scenario Create a webrtc handle, Set the offer message as local description and Gets the local session description
+* @apicovered webrtc_add_media_source, webrtc_set_ice_candidate_cb, webrtc_create_offer, webrtc_set_local_description and webrtc_get_local_description
+* @passcase If Pre condition APIs and webrtc_get_local_description pass
+* @failcase If Pre condition APIs Or webrtc_get_local_description fails
+* @precondition NA
+* @postcondition NA
+*/
+int ITc_webrtc_get_local_description_p(void)
+{
+ START_TEST;
+ callback_data cb_data;
+ unsigned int nId = -1;
+ char *pszOffer = NULL;
+ char *pszLocalDesc = NULL;
+ INIT_CALLBACK_DATA(cb_data);
+
+ int nRet = webrtc_add_media_source(g_hWebRtcHandle, WEBRTC_MEDIA_SOURCE_TYPE_MIC, &nId);
+ if (!g_bIsMicrophoneFeatureSupported)
+ {
+ PRINT_RESULT(WEBRTC_ERROR_NOT_SUPPORTED, nRet, "webrtc_add_media_source", WebRtcGetError(nRet));
+ nRet = webrtc_add_media_source(g_hWebRtcHandle, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, &nId);
+ }
+ PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_add_media_source", WebRtcGetError(nRet));
+ if (nId < 0)
+ {
+ FPRINTF("[Line : %d][%s] webrtc_add_media_source failed, ID is invalid\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ nRet = webrtc_set_ice_candidate_cb(g_hWebRtcHandle, webrtcIceCandidateCB, NULL);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_ice_candidate_cb", WebRtcGetError(nRet), webrtc_remove_media_source(g_hWebRtcHandle, nId));
+
+ nRet = webrtc_set_state_changed_cb(g_hWebRtcHandle, webrtcStateChangedCB, &cb_data);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_state_changed_cb", WebRtcGetError(nRet), webrtc_unset_ice_candidate_cb(g_hWebRtcHandle); webrtc_remove_media_source(g_hWebRtcHandle, nId));
+
+ g_mutex_lock(&cb_data.mutex);
+
+ nRet = webrtc_start(g_hWebRtcHandle);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet), webrtc_unset_state_changed_cb(g_hWebRtcHandle); webrtc_unset_ice_candidate_cb(g_hWebRtcHandle); webrtc_remove_media_source(g_hWebRtcHandle, nId));
+
+ RUN_POLLING_LOOP(cb_data);
+ if (!cb_data.is_invoked) {
+ FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
+ webrtc_unset_state_changed_cb(g_hWebRtcHandle);
+ webrtc_unset_ice_candidate_cb(g_hWebRtcHandle);
+ webrtc_remove_media_source(g_hWebRtcHandle, nId);
+ return 1;
+ }
+
+ nRet = webrtc_create_offer(g_hWebRtcHandle, NULL, &pszOffer);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_create_offer", WebRtcGetError(nRet), webrtc_stop(g_hWebRtcHandle); webrtc_unset_state_changed_cb(g_hWebRtcHandle); webrtc_unset_ice_candidate_cb(g_hWebRtcHandle); webrtc_remove_media_source(g_hWebRtcHandle, nId));
+ CHECK_HANDLE(pszOffer, "webrtc_create_offer");
+
+ nRet = webrtc_set_local_description(g_hWebRtcHandle, pszOffer);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_local_description", WebRtcGetError(nRet), webrtc_stop(g_hWebRtcHandle); webrtc_unset_state_changed_cb(g_hWebRtcHandle); webrtc_unset_ice_candidate_cb(g_hWebRtcHandle); webrtc_remove_media_source(g_hWebRtcHandle, nId));
+
+ nRet = webrtc_get_local_description(g_hWebRtcHandle, &pszLocalDesc);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_local_description", WebRtcGetError(nRet), webrtc_stop(g_hWebRtcHandle); webrtc_unset_state_changed_cb(g_hWebRtcHandle); webrtc_unset_ice_candidate_cb(g_hWebRtcHandle); webrtc_remove_media_source(g_hWebRtcHandle, nId));
+ CHECK_HANDLE(pszLocalDesc, "webrtc_get_local_description");
+
+ if (strcmp(pszOffer, pszLocalDesc) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Set and get local description mismatch\\n", __LINE__, API_NAMESPACE);
+ free(pszOffer);
+ free(pszLocalDesc);
+
+ //Cleanup API call
+ webrtc_stop(g_hWebRtcHandle);
+ webrtc_unset_state_changed_cb(g_hWebRtcHandle);
+ webrtc_unset_ice_candidate_cb(g_hWebRtcHandle);
+ webrtc_remove_media_source(g_hWebRtcHandle, nId);
+ return 1;
+ }
+
+ //Cleanup API call
+ nRet = webrtc_stop(g_hWebRtcHandle);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_stop", WebRtcGetError(nRet));
+ nRet = webrtc_unset_state_changed_cb(g_hWebRtcHandle);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_unset_state_changed_cb", WebRtcGetError(nRet));
+ nRet = webrtc_unset_ice_candidate_cb(g_hWebRtcHandle);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_unset_ice_candidate_cb", WebRtcGetError(nRet));
+ nRet = webrtc_remove_media_source(g_hWebRtcHandle, nId);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_remove_media_source", WebRtcGetError(nRet));
+
+ return 0;
+}
+
+
+//& purpose: Gets the remote session description
+//& type: auto
+/**
+* @testcase ITc_webrtc_get_remote_description_p
+* @since_tizen 9.0
+* @author SRID(shobhit.v)
+* @reviewer SRID(tarun1.kumar)
+* @type auto
+* @description Gets the local session description
+* @scenario Create a webrtc handle, Set the offer message as local description and Gets the local session description
+* @apicovered webrtc_add_media_source, webrtc_set_ice_candidate_cb, webrtc_create_offer, webrtc_set_remote_description and webrtc_get_remote_description
+* @passcase If Pre condition APIs and webrtc_get_remote_description pass
+* @failcase If Pre condition APIs Or webrtc_get_remote_description fails
+* @precondition NA
+* @postcondition NA
+*/
+int ITc_webrtc_get_remote_description_p(void)
+{
+ START_TEST;
+ callback_data cb_data;
+ unsigned int nId = -1;
+ char *pszOffer = NULL;
+ char *pszLocalDesc = NULL;
+ webrtc_h hWebrtc = NULL;
+ webrtc_h hWebrtc2 = NULL;
+ INIT_CALLBACK_DATA(cb_data);
+
+ int nRet = webrtc_create(&hWebrtc);
+ PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create", WebRtcGetError(nRet));
+ CHECK_HANDLE(hWebrtc, "webrtc_create");
+
+ nRet = webrtc_add_media_source(hWebrtc, WEBRTC_MEDIA_SOURCE_TYPE_MIC, &nId);
+ if (!g_bIsMicrophoneFeatureSupported)
+ {
+ PRINT_RESULT(WEBRTC_ERROR_NOT_SUPPORTED, nRet, "webrtc_add_media_source", WebRtcGetError(nRet));
+ nRet = webrtc_add_media_source(hWebrtc, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, &nId);
+ }
+ PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_add_media_source", WebRtcGetError(nRet));
+ if (nId < 0)
+ {
+ FPRINTF("[Line : %d][%s] webrtc_add_media_source failed, ID is invalid\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ nRet = webrtc_set_ice_candidate_cb(hWebrtc, webrtcIceCandidateCB, NULL);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_ice_candidate_cb", WebRtcGetError(nRet), webrtc_remove_media_source(hWebrtc, nId));
+
+ nRet = webrtc_set_state_changed_cb(hWebrtc, webrtcStateChangedCB, &cb_data);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_state_changed_cb", WebRtcGetError(nRet), webrtc_unset_ice_candidate_cb(hWebrtc); webrtc_remove_media_source(hWebrtc, nId));
+
+ g_mutex_lock(&cb_data.mutex);
+
+ nRet = webrtc_start(hWebrtc);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet), webrtc_unset_state_changed_cb(hWebrtc); webrtc_unset_ice_candidate_cb(hWebrtc); webrtc_remove_media_source(hWebrtc, nId));
+
+ RUN_POLLING_LOOP(cb_data);
+ if (!cb_data.is_invoked) {
+ FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
+ webrtc_unset_state_changed_cb(hWebrtc);
+ webrtc_unset_ice_candidate_cb(hWebrtc);
+ webrtc_remove_media_source(hWebrtc, nId);
+ webrtc_destroy(hWebrtc);
+ return 1;
+ }
+
+ nRet = webrtc_create_offer(hWebrtc, NULL, &pszOffer);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_create_offer", WebRtcGetError(nRet), webrtc_stop(hWebrtc); webrtc_unset_state_changed_cb(hWebrtc); webrtc_unset_ice_candidate_cb(hWebrtc); webrtc_remove_media_source(hWebrtc, nId));
+ CHECK_HANDLE(pszOffer, "webrtc_create_offer");
+
+ INIT_CALLBACK_DATA(cb_data);
+ nRet = webrtc_create(&hWebrtc2);
+ PRINT_RESULT(WEBRTC_ERROR_NONE, nRet, "webrtc_create", WebRtcGetError(nRet));
+ CHECK_HANDLE(hWebrtc2, "webrtc_create");
+
+ nRet = webrtc_set_ice_candidate_cb(hWebrtc2, webrtcIceCandidateCB, NULL);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_ice_candidate_cb", WebRtcGetError(nRet), webrtc_destroy(hWebrtc2));
+
+ nRet = webrtc_set_state_changed_cb(hWebrtc2, webrtcStateChangedCB, &cb_data);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_state_changed_cb", WebRtcGetError(nRet), webrtc_unset_ice_candidate_cb(hWebrtc2);webrtc_destroy(hWebrtc2));
+
+ g_mutex_lock(&cb_data.mutex);
+
+ nRet = webrtc_start(hWebrtc2);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_start", WebRtcGetError(nRet), webrtc_unset_state_changed_cb(hWebrtc2); webrtc_unset_ice_candidate_cb(hWebrtc2);webrtc_destroy(hWebrtc2));
+
+ RUN_POLLING_LOOP(cb_data);
+ if (!cb_data.is_invoked) {
+ FPRINTF("[Line : %d][%s] Callback webrtcStateChangedCB not invoked\\n", __LINE__, API_NAMESPACE);
+
+ //Cleanup API call
+ webrtc_stop(hWebrtc);
+ webrtc_unset_state_changed_cb(hWebrtc);
+ webrtc_unset_ice_candidate_cb(hWebrtc);
+ webrtc_remove_media_source(hWebrtc, nId);
+ webrtc_destroy(hWebrtc);
+
+ webrtc_unset_state_changed_cb(hWebrtc2);
+ webrtc_unset_ice_candidate_cb(hWebrtc2);
+ webrtc_destroy(hWebrtc2);
+ return 1;
+ }
+
+ nRet = webrtc_set_remote_description(hWebrtc2, pszOffer);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_remote_description", WebRtcGetError(nRet), webrtc_stop(hWebrtc2); webrtc_unset_state_changed_cb(hWebrtc2); webrtc_unset_ice_candidate_cb(hWebrtc2);webrtc_destroy(hWebrtc2));
+
+ nRet = webrtc_get_remote_description(hWebrtc2, &pszLocalDesc);
+ PRINT_RESULT_CLEANUP(WEBRTC_ERROR_NONE, nRet, "webrtc_set_local_description", WebRtcGetError(nRet), webrtc_stop(hWebrtc2); webrtc_unset_state_changed_cb(hWebrtc2); webrtc_unset_ice_candidate_cb(hWebrtc2);webrtc_destroy(hWebrtc2));
+ CHECK_HANDLE(pszLocalDesc, "webrtc_get_remote_description");
+
+ if (strcmp(pszOffer, pszLocalDesc) != 0)
+ {
+ FPRINTF("[Line : %d][%s] Set and get local description mismatch\\n", __LINE__, API_NAMESPACE);
+ free(pszOffer);
+ free(pszLocalDesc);
+
+ //Cleanup API call
+ webrtc_stop(hWebrtc);
+ webrtc_unset_state_changed_cb(hWebrtc);
+ webrtc_unset_ice_candidate_cb(hWebrtc);
+ webrtc_remove_media_source(hWebrtc, nId);
+ webrtc_destroy(hWebrtc);
+
+ webrtc_stop(hWebrtc2);
+ webrtc_unset_state_changed_cb(hWebrtc2);
+ webrtc_unset_ice_candidate_cb(hWebrtc2);
+ webrtc_destroy(hWebrtc2);
+ return 1;
+ }
+
+ nRet = webrtc_stop(hWebrtc);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_stop", WebRtcGetError(nRet));
+ nRet = webrtc_unset_state_changed_cb(hWebrtc);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_unset_state_changed_cb", WebRtcGetError(nRet));
+ nRet = webrtc_unset_ice_candidate_cb(hWebrtc);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_unset_ice_candidate_cb", WebRtcGetError(nRet));
+ nRet = webrtc_remove_media_source(hWebrtc, nId);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_remove_media_source", WebRtcGetError(nRet));
+ nRet = webrtc_destroy(hWebrtc);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_destroy", WebRtcGetError(nRet));
+
+ nRet = webrtc_stop(hWebrtc2);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_stop", WebRtcGetError(nRet));
+ nRet = webrtc_unset_state_changed_cb(hWebrtc2);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_unset_state_changed_cb", WebRtcGetError(nRet));
+ nRet = webrtc_unset_ice_candidate_cb(hWebrtc2);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_unset_ice_candidate_cb", WebRtcGetError(nRet));
+ nRet = webrtc_destroy(hWebrtc2);
+ PRINT_RESULT_NORETURN(WEBRTC_ERROR_NONE, nRet, "webrtc_destroy", WebRtcGetError(nRet));
+ return 0;
+}
/** @} */
/** @} */