From: Eunhae Choi Date: Wed, 5 Sep 2018 03:43:43 +0000 (+0900) Subject: [TCT][player][Non-ACR][Add network connection checking at each streaming tct] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04c81c03f39c9b93e027719ac34d060fe1800522;p=test%2Ftct%2Fnative%2Fapi.git [TCT][player][Non-ACR][Add network connection checking at each streaming tct] - check online state and print out the result - check connection statistics and print out the result at each streaming tct case Change-Id: I7233bf19966d360789e3bd737ddb76cbddeb3be2 --- diff --git a/packaging/itc/native-player-itc.spec b/packaging/itc/native-player-itc.spec index dce6b750f..8c174b685 100755 --- a/packaging/itc/native-player-itc.spec +++ b/packaging/itc/native-player-itc.spec @@ -16,6 +16,8 @@ BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(capi-network-connection) +BuildRequires: pkgconfig(libcurl) %description Native API Integration TC (%{name}) diff --git a/packaging/utc/core-player-tests.spec b/packaging/utc/core-player-tests.spec index 37ecfa13b..185961caf 100755 --- a/packaging/utc/core-player-tests.spec +++ b/packaging/utc/core-player-tests.spec @@ -19,6 +19,9 @@ BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(storage) +BuildRequires: pkgconfig(capi-network-connection) +BuildRequires: pkgconfig(libcurl) + %description Core API unit TC (%{name}) diff --git a/src/itc/player/CMakeLists.txt b/src/itc/player/CMakeLists.txt index bb9e556f4..907a8e748 100755 --- a/src/itc/player/CMakeLists.txt +++ b/src/itc/player/CMakeLists.txt @@ -41,11 +41,13 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED ${CAPI_LIB} capi-appfw-application capi-system-info + capi-network-connection dlog glib-2.0 gobject-2.0 gthread-2.0 storage + libcurl ) ENDIF() IF( DEFINED MOBILE ) @@ -55,11 +57,13 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED bundle capi-appfw-application capi-system-info + capi-network-connection dlog ecore elementary evas glib-2.0 + libcurl ) ENDIF() IF( DEFINED WEARABLE ) @@ -69,11 +73,13 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED bundle capi-appfw-application capi-system-info + capi-network-connection dlog ecore elementary evas glib-2.0 + libcurl ) ENDIF() diff --git a/src/itc/player/ITs-player-common.c b/src/itc/player/ITs-player-common.c index 6cf0ae6b6..31573e233 100755 --- a/src/itc/player/ITs-player-common.c +++ b/src/itc/player/ITs-player-common.c @@ -15,6 +15,9 @@ // #include "ITs-player-common.h" +extern bool PlayerPrepareWithConnectionCheck(player_h g_player); +extern bool CheckOnlineStatus(char *media_path); + /** @addtogroup itc-player * @ingroup itc * @{ @@ -121,7 +124,7 @@ char* PlayerGetError(int nRet) case PLAYER_ERROR_DRM_NOT_PERMITTED: szErrorVal = "PLAYER_ERROR_DRM_NOT_PERMITTED"; break; case PLAYER_ERROR_RESOURCE_LIMIT: szErrorVal = "PLAYER_ERROR_RESOURCE_LIMIT"; break; case PLAYER_ERROR_PERMISSION_DENIED: szErrorVal = "PLAYER_ERROR_PERMISSION_DENIED"; break; - case PLAYER_ERROR_BUFFER_SPACE: szErrorVal = "PLAYER_ERROR_BUFFER_SPACE"; break; + case PLAYER_ERROR_BUFFER_SPACE: szErrorVal = "PLAYER_ERROR_BUFFER_SPACE"; break; default: szErrorVal = "Unknown Error"; break; } @@ -133,7 +136,7 @@ char* PlayerGetError(int nRet) * @description Creates a player handler, sets an uri and prepares the handler * @parameter[IN] bool bPrepare [if it is true, player would be prepared. Otherwise, player would not be prepared] * [IN] int nMediaType [if it is 0, player_set_uri would be set with an audio file. if it is 1, player_set_uri would be set with a video file. Otherwise, player_set_uri would be set with a download source file] -* @return true if successful, otherwise false. +* @return true if successful, otherwise false. */ bool InitializePlayerHandler(bool bPrepare, int nMediaType) { @@ -190,7 +193,7 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType) #endif } else if ( nMediaType == 1 ) - { + { nRet = player_set_uri(g_player, pPath2); #if defined(WEARABLE) bValue = false; @@ -206,7 +209,7 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType) #endif } else if ( nMediaType == 2 ) - { + { char pstrValue[CONFIG_VALUE_LEN_MAX] = {0,}; if ( true == GetValueFromConfigFile("PLAYER_DOWNLOAD_URL", pstrValue, API_NAMESPACE) ) { @@ -230,12 +233,16 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType) FPRINTF("[Line : %d][%s] player_set_uri API call returned mismatch %s error for unsupported internet feature\\n", __LINE__, API_NAMESPACE, PlayerGetError(nRet)); return false; } - + } #endif + + if (!CheckOnlineStatus(pstrValue)) { + FPRINTF("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE); + } } else if ( nMediaType == 3 ) - { + { char pstrValue[CONFIG_VALUE_LEN_MAX] = {0,}; if ( true == GetValueFromConfigFile("PLAYER_DOWNLOAD_URL_AUDIO", pstrValue, API_NAMESPACE) ) { @@ -259,7 +266,7 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType) FPRINTF("[Line : %d][%s] player_set_uri API call returned mismatch %s error for unsupported internet feature\\n", __LINE__, API_NAMESPACE, PlayerGetError(nRet)); return false; } - + } #endif } @@ -294,6 +301,10 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType) } } #endif + + if (!CheckOnlineStatus(pstrValue)) { + FPRINTF("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE); + } } if ( nRet != PLAYER_ERROR_NONE ) @@ -304,7 +315,11 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType) if ( bPrepare ) { - nRet = player_prepare(g_player); + if (nMediaType == 5 ) { /* need to check connection statistics */ + nRet = PlayerPrepareWithConnectionCheck(g_player); + } else { + nRet = player_prepare(g_player); + } player_get_state(g_player,&state); PlayerGetState(state); if ( nRet != PLAYER_ERROR_NONE ) @@ -327,7 +342,7 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType) * @function WinDel * @description Callback function registered by evas_object_smart_callback_add API * @parameter[IN] void*, Evas_Object*, void* -* @return NA. +* @return NA. */ void WinDel(void *data, Evas_Object *obj, void *event) { @@ -338,7 +353,7 @@ void WinDel(void *data, Evas_Object *obj, void *event) * @function CreateEvasWindow * @description Creates an Evas window object * @parameter[IN] NA -* @return Evas_Object if successful, otherwise NULL. +* @return Evas_Object if successful, otherwise NULL. */ void CreateEvasWindow() { @@ -394,7 +409,7 @@ char* MediaPacketGetError(int nRet) char *szErrorVal = NULL; switch ( nRet ) - { + { case MEDIA_PACKET_ERROR_NONE: szErrorVal = "MEDIA_PACKET_ERROR_NONE"; break; case MEDIA_PACKET_ERROR_INVALID_PARAMETER: szErrorVal = "MEDIA_PACKET_ERROR_INVALID_PARAMETER"; break; case MEDIA_PACKET_ERROR_OUT_OF_MEMORY: szErrorVal = "MEDIA_PACKET_ERROR_OUT_OF_MEMORY"; break; @@ -416,7 +431,7 @@ char* MediaFormatGetError(int nRet) char *szErrorVal = NULL; switch ( nRet ) - { + { case MEDIA_FORMAT_ERROR_NONE: szErrorVal = "MEDIA_FORMAT_ERROR_NONE"; break; case MEDIA_FORMAT_ERROR_OUT_OF_MEMORY: szErrorVal = "MEDIA_FORMAT_ERROR_OUT_OF_MEMORY"; break; case MEDIA_FORMAT_ERROR_INVALID_PARAMETER: szErrorVal = "MEDIA_FORMAT_ERROR_INVALID_PARAMETER"; break; diff --git a/src/itc/player/ITs-player.c b/src/itc/player/ITs-player.c index 3a67fa77e..5c78afeec 100755 --- a/src/itc/player/ITs-player.c +++ b/src/itc/player/ITs-player.c @@ -13,7 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. // +#include #include "ITs-player-common.h" +#include "net_connection.h" /** @addtogroup itc-player * @ingroup itc @@ -41,6 +43,8 @@ bool g_bPlayerMediaStreamBufferStatus; bool g_bPlayerCallbackParameter; bool g_bPlayerInterruptCbCallback; +static connection_h g_connection = NULL; + #ifdef TIZENIOT // For TIZENIOT int g_nTimeoutId; GMainLoop *g_pMainLoop; @@ -680,6 +684,160 @@ static void PlayerPreparedCB(void *user_data) } #endif // End MOBILE or WEARABLE +bool CheckOnlineStatus(char *media_path) +{ + bool ret = true; + CURL *curl = NULL; + CURLcode res = CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, media_path); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L); + + res = curl_easy_perform(curl); + if(res != CURLE_OK) { + FPRINTF("[Line : %d][%s] curl_easy_perform() failed: %s\n", __LINE__, API_NAMESPACE, curl_easy_strerror(res)); + ret = false; + } + + curl_easy_cleanup(curl); + } + + return ret; + +} + +bool CheckConnectionStatistics(connection_h connection, long long *size) +{ +#define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi" +#define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony" + + long long rv = 0; + int err = CONNECTION_ERROR_NONE; + connection_type_e type = CONNECTION_TYPE_DISCONNECTED; + bool wifi_supported = false; + bool telepony_supported = false; + + system_info_get_platform_bool(_FEATURE_NAME_WIFI, &wifi_supported); + system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &telepony_supported); + + if (wifi_supported) { + type = CONNECTION_TYPE_WIFI; + } else if (telepony_supported) { + type = CONNECTION_TYPE_CELLULAR; + } else { + FPRINTF("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return false; + } + + err = connection_get_statistics(connection, type, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv); + + if (err != CONNECTION_ERROR_NONE) { + FPRINTF("[Line : %d][%s] Failed to check connection statistics.\\n", __LINE__, API_NAMESPACE); + return false; + } else { + FPRINTF("[Line : %d][%s] WiFi last recv data size [%lld]\\n", __LINE__, API_NAMESPACE, rv); + } + + *size = rv; + return true; +} + + +int PlayerPrepareWithConnectionCheck(player_h g_player) +{ + int ret = PLAYER_ERROR_NONE; + long long before = 0, after = 0; + + if (connection_create(&g_connection) != CONNECTION_ERROR_NONE) { + FPRINTF("[Line : %d][%s] Failed to create connection handle\\n", __LINE__, API_NAMESPACE); + } else { + FPRINTF("[Line : %d][%s] Success to create connection handle %p\\n", __LINE__, API_NAMESPACE, g_connection); + } + + if (g_connection && !CheckConnectionStatistics(g_connection, &before)) { + FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } + + ret = player_prepare(g_player); + if (g_connection) { + if (!CheckConnectionStatistics(g_connection, &after)) { + FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } else { + FPRINTF("[Line : %d][%s][Reference] total received data [%lld]\\n", + __LINE__, API_NAMESPACE, (after-before)); + } + } + + if (g_connection && connection_destroy(g_connection) != CONNECTION_ERROR_NONE) { + FPRINTF("[Line : %d][%s] Failed to destroy connection handle\\n", __LINE__, API_NAMESPACE); + } + + return ret; +} + + +static int PlayerStartWithConnectionCheck(player_h g_player, char* media_path) +{ + int ret = PLAYER_ERROR_NONE; + long long before = 0, after = 0; + + if (!CheckOnlineStatus(media_path)) { + FPRINTF("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE); + } + + if (connection_create(&g_connection) != CONNECTION_ERROR_NONE) { + FPRINTF("[Line : %d][%s] Failed to create connection handle\\n", __LINE__, API_NAMESPACE); + } else { + FPRINTF("[Line : %d][%s] Success to create connection handle %p\\n", __LINE__, API_NAMESPACE, g_connection); + } + + if (g_connection && !CheckConnectionStatistics(g_connection, &before)) { + FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } + + ret = player_prepare(g_player); + if (ret != PLAYER_ERROR_NONE) { + if (g_connection) { + if (!CheckConnectionStatistics(g_connection, &after)) { + FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } else { + FPRINTF("[Line : %d][%s][Reference] total received data [%lld]\\n", + __LINE__, API_NAMESPACE, (after-before)); + } + } + + FPRINTF("[Line : %d][%s] player_prepare failed, error returned = %s\\n", + __LINE__, API_NAMESPACE, PlayerGetError(ret)); + goto EXIT; + } + + sleep(3); + + /* progressive download case have to include player_start for checking network env */ + ret = player_start(g_player); + + if (g_connection) { + if (!CheckConnectionStatistics(g_connection, &after)) { + FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } else { + FPRINTF("[Line : %d][%s][Reference] total received data [%lld]\\n", __LINE__, API_NAMESPACE, (after-before)); + } + } + + if (ret != PLAYER_ERROR_NONE) { + FPRINTF("[Line : %d][%s] player_start failed, error returned = %s\\n", + __LINE__, API_NAMESPACE, PlayerGetError(ret)); + } + +EXIT: + if (g_connection && connection_destroy(g_connection) != CONNECTION_ERROR_NONE) { + FPRINTF("[Line : %d][%s] Failed to destroy connection handle\\n", __LINE__, API_NAMESPACE); + } + + return ret; +} /** @addtogroup itc-player-testcases @@ -951,7 +1109,7 @@ int ITc_player_set_unset_buffering_cb_p(void) sleep(3); - nRet = player_prepare(g_player); + nRet = PlayerPrepareWithConnectionCheck(g_player); PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet)); nRet = player_get_state(g_player,&state); @@ -1130,13 +1288,8 @@ int ITc_player_get_progressive_download_status_p(void) sleep(3); - nRet = player_prepare(g_player); - PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet)); - - sleep(3); - - nRet = player_start(g_player); - PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_start", PlayerGetError(nRet), player_unprepare(g_player)); + nRet = PlayerStartWithConnectionCheck(g_player, pstrValue); + PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "start playback", PlayerGetError(nRet), player_unprepare(g_player)); nRet = player_get_state(g_player,&state); PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_get_state", PlayerGetError(nRet), player_stop(g_player);player_unprepare(g_player)); @@ -1249,13 +1402,8 @@ int ITc_player_get_streaming_download_progress_p(void) sleep(3); - nRet = player_prepare(g_player); - PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet)); - - sleep(3); - - nRet = player_start(g_player); - PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_start", PlayerGetError(nRet), player_unprepare(g_player)); + nRet = PlayerStartWithConnectionCheck(g_player, pstrValue); + PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "start playback", PlayerGetError(nRet), player_unprepare(g_player)); nRet = player_get_state(g_player,&state); PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_get_state", PlayerGetError(nRet), player_stop(g_player);player_unprepare(g_player)); @@ -3144,23 +3292,8 @@ int ITc_player_set_unset_progressive_download_message_cb_p(void) sleep(3); - nRet = player_prepare(g_player); - PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet)); - - nRet = player_get_state(g_player,&state); - PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_get_state", PlayerGetError(nRet), player_unprepare(g_player)); - - PlayerGetState(state); - if ( state != PLAYER_STATE_READY ) - { - FPRINTF("[Line : %d][%s] Player state does not change after player_prepare() call", __LINE__, API_NAMESPACE); - return 1; - } - - sleep(3); - - nRet = player_start(g_player); - PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_start", PlayerGetError(nRet), player_unprepare(g_player)); + nRet = PlayerStartWithConnectionCheck(g_player, pstrValue); + PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "start playback", PlayerGetError(nRet), player_unprepare(g_player)); nRet = player_get_state(g_player,&state); PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_get_state", PlayerGetError(nRet), player_stop(g_player);player_unprepare(g_player)); diff --git a/src/utc/player/CMakeLists.txt b/src/utc/player/CMakeLists.txt index 07d4c9c5f..7eb0bbf5a 100644 --- a/src/utc/player/CMakeLists.txt +++ b/src/utc/player/CMakeLists.txt @@ -37,17 +37,20 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED ${CAPI_LIB} capi-appfw-application capi-system-info + capi-network-connection glib-2.0 gthread-2.0 gobject-2.0 storage dlog + libcurl ) ELSE() PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED ${CAPI_LIB} capi-appfw-application capi-system-info + capi-network-connection glib-2.0 gthread-2.0 gobject-2.0 @@ -56,6 +59,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED evas storage dlog + libcurl ) ENDIF() INCLUDE_DIRECTORIES( diff --git a/src/utc/player/utc-media-player-callback.c b/src/utc/player/utc-media-player-callback.c index c9a453325..f83aba997 100644 --- a/src/utc/player/utc-media-player-callback.c +++ b/src/utc/player/utc-media-player-callback.c @@ -19,15 +19,19 @@ #include #include #include "tct_common.h" +#include "net_connection.h" #define API_NAMESPACE "[PLAYER]" extern bool get_value_from_config(char* key, char* value); extern bool check_network_supportable(void); +extern bool check_connection_statistics(connection_h connection, long long *size); +extern bool check_online_status(char *media_path); //& set: MediaPlayerCallback -static player_h player; +static player_h player = NULL; +static connection_h connection = NULL; static bool _is_broken = false; static bool _is_pass = false; @@ -64,6 +68,46 @@ static void wait_for_async() g_mainloop = NULL; } +static int _player_prepare_with_connection_check(char *media_path) +{ + int ret = PLAYER_ERROR_NONE; + long long before = 0, after = 0; + + if (!check_online_status(media_path)) { + PRINT_UTC_LOG("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE); + } + + if (connection_create(&connection) != CONNECTION_ERROR_NONE) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to create connection handle\\n", __LINE__, API_NAMESPACE); + } else { + PRINT_UTC_LOG("[Line : %d][%s] Success to create connection handle %p\\n", __LINE__, API_NAMESPACE, connection); + } + + if (connection && !check_connection_statistics(connection, &before)) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } + + ret = player_prepare(player); + + if (connection) { + if (!check_connection_statistics(connection, &after)) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } else { + PRINT_UTC_LOG("[Line : %d][%s][Reference] total received data [%lld]\\n", __LINE__, API_NAMESPACE, (after-before)); + } + } + + if (ret != PLAYER_ERROR_NONE) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to player_prepare 0x%X\\n", __LINE__, API_NAMESPACE, ret); + } + + if (connection && (connection_destroy(connection) != CONNECTION_ERROR_NONE)) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to destroy connection handle\\n", __LINE__, API_NAMESPACE); + } + + return ret; +} + /** * @function utc_media_player_callback_startup * @description Called before each test @@ -192,39 +236,39 @@ static void player_subtitle_update_cb(unsigned long duration, char *text, void */ int utc_media_player_set_buffering_cb_p(void) { - assert(!_is_broken); + assert(!_is_broken); - int repeat = 0; + int repeat = 0; bool _is_network_supportable = check_network_supportable(); - int ret = player_set_uri(player, media_download_path); - if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && - (!_is_network_supportable)) { - PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret, PLAYER_ERROR_NONE); + int ret = player_set_uri(player, media_download_path); + if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && + (!_is_network_supportable)) { + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return 0; + } + assert_eq(ret, PLAYER_ERROR_NONE); - ret = player_set_buffering_cb(player, player_buffer_cb, NULL); - if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && - (!_is_network_supportable)) { - PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret, PLAYER_ERROR_NONE); + ret = player_set_buffering_cb(player, player_buffer_cb, NULL); + if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && + (!_is_network_supportable)) { + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return 0; + } + assert_eq(ret, PLAYER_ERROR_NONE); - ret = player_prepare(player); - assert_eq(ret, PLAYER_ERROR_NONE); + ret = _player_prepare_with_connection_check(media_download_path); + assert_eq(ret, PLAYER_ERROR_NONE); - for (repeat = 0 ; repeat < 11 ; repeat++) { - wait_for_async(); - if (_is_pass) - break; - } - assert(_is_pass); - _is_pass = false; + for (repeat = 0 ; repeat < 11 ; repeat++) { + wait_for_async(); + if (_is_pass) + break; + } + assert(_is_pass); + _is_pass = false; - return 0; + return 0; } /** diff --git a/src/utc/player/utc-media-player-streaming.c b/src/utc/player/utc-media-player-streaming.c index 0dec3ff71..4cafb072c 100644 --- a/src/utc/player/utc-media-player-streaming.c +++ b/src/utc/player/utc-media-player-streaming.c @@ -14,12 +14,14 @@ // limitations under the License. // #include "assert.h" -#include #include #include #include #include +#include +#include #include "tct_common.h" +#include "net_connection.h" #define API_NAMESPACE "[PLAYER]" @@ -32,7 +34,11 @@ static char* download = "test.pd"; static char* download_path = NULL; -static player_h player; +static player_h player = NULL; +static connection_h connection = NULL; +static bool wifi_supported = false; +static bool telepony_supported = false; +static bool ethernet_supported = false; static bool _is_broken = false; static bool _is_pass = false; @@ -125,25 +131,150 @@ bool get_value_from_config(char* key, char* value) return true; } +bool check_online_status(char *media_path) +{ + bool ret = true; + CURL *curl = NULL; + CURLcode res = CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, media_path); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L); + + res = curl_easy_perform(curl); + if(res != CURLE_OK) { + PRINT_UTC_LOG("[Line : %d][%s] curl_easy_perform() failed: %s\n", __LINE__, API_NAMESPACE, curl_easy_strerror(res)); + ret = false; + } + + curl_easy_cleanup(curl); + } + + return ret; + +} + +bool check_connection_statistics(connection_h connection, long long *size) +{ + long long rv = 0; + int err = CONNECTION_ERROR_NONE; + connection_type_e type = CONNECTION_TYPE_DISCONNECTED; + + if (wifi_supported) { + type = CONNECTION_TYPE_WIFI; + } else if (telepony_supported) { + type = CONNECTION_TYPE_CELLULAR; + } else { + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return false; + } + + err = connection_get_statistics(connection, type, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv); + + if (err != CONNECTION_ERROR_NONE) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to check connection statistics.\\n", __LINE__, API_NAMESPACE); + return false; + } else { + PRINT_UTC_LOG("[Line : %d][%s] WiFi last recv data size [%lld]\\n", __LINE__, API_NAMESPACE, rv); + } + + *size = rv; + return true; +} + +static int _player_prepare_with_connection_check(gchar *media_path) +{ + int ret = PLAYER_ERROR_NONE; + long long before = 0, after = 0; + + if (!check_online_status(media_path)) { + PRINT_UTC_LOG("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE); + } + + if (connection && !check_connection_statistics(connection, &before)) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } + + ret = player_prepare(player); + + if (connection) { + if (!check_connection_statistics(connection, &after)) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } else { + PRINT_UTC_LOG("[Line : %d][%s][Reference] total received data [%lld]\\n", __LINE__, API_NAMESPACE, (after-before)); + } + } + + if (ret != PLAYER_ERROR_NONE) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to player_prepare 0x%X\\n", __LINE__, API_NAMESPACE, ret); + } + + return ret; +} + +static int _player_prepare_start_with_connection_check(gchar *media_path) +{ + int ret = PLAYER_ERROR_NONE; + long long before = 0, after = 0; + + if (!check_online_status(media_path)) { + PRINT_UTC_LOG("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE); + } + + if (connection && !check_connection_statistics(connection, &before)) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } + + ret = player_prepare(player); + + if (ret != PLAYER_ERROR_NONE) { + if (connection) { + if (!check_connection_statistics(connection, &after)) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } else { + PRINT_UTC_LOG("[Line : %d][%s][Reference] total received data [%lld]\\n", + __LINE__, API_NAMESPACE, (after-before)); + } + } + + PRINT_UTC_LOG("[Line : %d][%s] Failed to player_prepare 0x%X\\n", __LINE__, API_NAMESPACE, ret); + return ret; + } + + /* progressive download case have to include player_start for checking network env */ + ret = player_start(player); + + if (connection) { + if (!check_connection_statistics(connection, &after)) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE); + } else { + PRINT_UTC_LOG("[Line : %d][%s][Reference] total received data [%lld]\\n", __LINE__, API_NAMESPACE, (after-before)); + } + } + + if (ret != PLAYER_ERROR_NONE) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to player_start 0x%X\\n", __LINE__, API_NAMESPACE, ret); + } + + return ret; +} bool check_network_supportable(void) { -#define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi" -#define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony" -#define _FEATURE_NAME_ETHERNET "http://tizen.org/feature/network.ethernet" - bool wifi_supported = FALSE; - bool telepony_supported = FALSE; - bool ethernet_supported = FALSE; +#define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi" +#define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony" +#define _FEATURE_NAME_ETHERNET "http://tizen.org/feature/network.ethernet" - system_info_get_platform_bool(_FEATURE_NAME_WIFI, &wifi_supported); - system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &telepony_supported); - system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, ðernet_supported); + system_info_get_platform_bool(_FEATURE_NAME_WIFI, &wifi_supported); + system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &telepony_supported); + system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, ðernet_supported); - if (wifi_supported || telepony_supported || ethernet_supported) - return true; + if (wifi_supported || telepony_supported || ethernet_supported) + return true; - PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); - return false; + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return false; } /** @@ -161,26 +292,21 @@ void utc_media_player_streaming_startup(void) _is_network_supportable = check_network_supportable(); - if ( true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE )) - { + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) { PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received = %s\\n", __LINE__, API_NAMESPACE, pszValue); unsigned int size_of_path = strlen(pszValue) + strlen(download) + 11; download_path = (char*)malloc(size_of_path); snprintf(download_path, size_of_path, "%s/res/res/%s", pszValue, download); - } - else - { + } else { PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE); } - if ( true != get_value_from_config("PLAYER_DOWNLOAD_PROGRESS_URL", g_media_path) ) - { + if (true != get_value_from_config("PLAYER_DOWNLOAD_PROGRESS_URL", g_media_path)) { PRINT_UTC_LOG("[Line : %d][%s] Failed to get value from config\\n", __LINE__, API_NAMESPACE); _is_broken = true; } - if ( true != get_value_from_config("PLAYER_ADAPTIVE_STREAMING_URL", g_media_adaptive_path) ) - { + if (true != get_value_from_config("PLAYER_ADAPTIVE_STREAMING_URL", g_media_adaptive_path)) { PRINT_UTC_LOG("[Line : %d][%s] Failed to get value from config\\n", __LINE__, API_NAMESPACE); _is_broken = true; } @@ -190,6 +316,12 @@ void utc_media_player_streaming_startup(void) _is_broken = true; return; } + + if (connection_create(&connection) != CONNECTION_ERROR_NONE) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to create connection handle\\n", __LINE__, API_NAMESPACE); + } else { + PRINT_UTC_LOG("[Line : %d][%s] Success to create connection handle %p\\n", __LINE__, API_NAMESPACE, connection); + } } /** @@ -200,14 +332,18 @@ void utc_media_player_streaming_startup(void) */ void utc_media_player_streaming_cleanup(void) { + if (connection && connection_destroy(connection) != CONNECTION_ERROR_NONE) { + PRINT_UTC_LOG("[Line : %d][%s] Failed to destroy connection handle\\n", __LINE__, API_NAMESPACE); + } + player_destroy(player); - if(download_path) + if (download_path) free(download_path); } static void _player_pd_message_cb(player_pd_message_type_e type, void *user_data) { - if(type==PLAYER_PD_STARTED || type==PLAYER_PD_COMPLETED) + if (type == PLAYER_PD_STARTED || type == PLAYER_PD_COMPLETED) _is_pass = TRUE; } @@ -218,42 +354,38 @@ static void _player_pd_message_cb(player_pd_message_type_e type, void *user_dat */ int utc_media_player_get_streaming_download_progress_p(void) { - assert(!_is_broken); - int start; - int current; + assert(!_is_broken); - int ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE)); - assert_eq(ret, PLAYER_ERROR_NONE); + int ret = PLAYER_ERROR_NONE; + int start; + int current; - int ret2 = player_set_uri(player, g_media_path); - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE)); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret3 = player_prepare(player); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if(ret3==PLAYER_ERROR_CONNECTION_FAILED) { - PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret3, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret4 = player_start(player); - assert_eq(ret4, PLAYER_ERROR_NONE); + ret = _player_prepare_with_connection_check(g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret5 = player_get_streaming_download_progress(player, &start, ¤t); - assert_eq(ret5, PLAYER_ERROR_NONE); + ret = player_start(player); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret6 = player_stop(player); - assert_eq(ret6, PLAYER_ERROR_NONE); + ret = player_get_streaming_download_progress(player, &start, ¤t); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret7 = player_unprepare(player); - assert_eq(ret7, PLAYER_ERROR_NONE); + ret = player_stop(player); + assert_eq(ret, PLAYER_ERROR_NONE); - if (start < 0 || start > 100 || current < 0 || current > 100) { - assert(false); - } + ret = player_unprepare(player); + assert_eq(ret, PLAYER_ERROR_NONE); - return 0; + if (start < 0 || start > 100 || current < 0 || current > 100) { + assert(false); + } + + return 0; } /** @@ -263,37 +395,32 @@ int utc_media_player_get_streaming_download_progress_p(void) */ int utc_media_player_get_streaming_download_progress_n(void) { - int start; - int current; + int ret = PLAYER_ERROR_NONE; + int start; + int current; - int ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE)); - assert_eq(ret, PLAYER_ERROR_NONE); + ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE)); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret2 = player_set_uri(player, g_media_path); - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret3 = player_prepare(player); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if(ret3==PLAYER_ERROR_CONNECTION_FAILED) { - PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret3, PLAYER_ERROR_NONE); + ret = _player_prepare_with_connection_check(g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret4 = player_start(player); - assert_eq(ret4, PLAYER_ERROR_NONE); + ret = player_start(player); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret5 = player_get_streaming_download_progress(NULL, &start, ¤t); - assert_eq(ret5, PLAYER_ERROR_INVALID_PARAMETER); + ret = player_get_streaming_download_progress(NULL, &start, ¤t); + assert_eq(ret, PLAYER_ERROR_INVALID_PARAMETER); - int ret6 = player_stop(player); - assert_eq(ret6, PLAYER_ERROR_NONE); + ret = player_stop(player); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret7 = player_unprepare(player); - assert_eq(ret7, PLAYER_ERROR_NONE); + ret = player_unprepare(player); + assert_eq(ret, PLAYER_ERROR_NONE); - return 0; + return 0; } /** @@ -303,17 +430,18 @@ int utc_media_player_get_streaming_download_progress_n(void) */ int utc_media_player_get_streaming_download_progress_n2(void) { + int ret = PLAYER_ERROR_NONE; int start; int current; - int ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE)); + ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE)); assert_eq(ret, PLAYER_ERROR_NONE); - int ret2 = player_set_uri(player, g_media_path); - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret5 = player_get_streaming_download_progress(player, &start, ¤t); - assert_eq(ret5, PLAYER_ERROR_INVALID_STATE); + ret = player_get_streaming_download_progress(player, &start, ¤t); + assert_eq(ret, PLAYER_ERROR_INVALID_STATE); return 0; } @@ -325,38 +453,37 @@ int utc_media_player_get_streaming_download_progress_n2(void) */ int utc_media_player_get_progressive_download_status_p(void) { - assert(!_is_broken); - unsigned long current; - unsigned long total_size; + assert(!_is_broken); - int ret = player_set_uri(player, g_media_path); - assert_eq(ret, PLAYER_ERROR_NONE); + int ret = PLAYER_ERROR_NONE; + unsigned long current; + unsigned long total_size; - int ret2 = player_set_progressive_download_path(player, download_path); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if ((ret2==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && - (!_is_network_supportable)) { - PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret3 = player_prepare(player); - assert_eq(ret3, PLAYER_ERROR_NONE); + ret = player_set_progressive_download_path(player, download_path); + // if wifi isn't connected or internet modules don't exist, this error will be returned. + // and it is wrongly detected as a fail. so we will skip the test on these cases. + if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && + (!_is_network_supportable)) { + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return 0; + } + assert_eq(ret, PLAYER_ERROR_NONE); - int ret4 = player_start(player); - assert_eq(ret4, PLAYER_ERROR_NONE); + ret = _player_prepare_start_with_connection_check(g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret5 = player_get_progressive_download_status(player, ¤t, &total_size); - assert_eq(ret5, PLAYER_ERROR_NONE); + ret = player_get_progressive_download_status(player, ¤t, &total_size); + assert_eq(ret, PLAYER_ERROR_NONE); - wait_for_async(); + wait_for_async(); - int ret7 = player_unprepare(player); - assert_eq(ret7, PLAYER_ERROR_NONE); + ret = player_unprepare(player); + assert_eq(ret, PLAYER_ERROR_NONE); - return 0; + return 0; } /** @@ -366,37 +493,35 @@ int utc_media_player_get_progressive_download_status_p(void) */ int utc_media_player_get_progressive_download_status_n(void) { - unsigned long current; - unsigned long total_size; + int ret = PLAYER_ERROR_NONE; + unsigned long current; + unsigned long total_size; - int ret = player_set_uri(player, g_media_path); - assert_eq(ret, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret2 = player_set_progressive_download_path(player, download_path); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if ((ret2==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && - (!_is_network_supportable)) { - PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = player_set_progressive_download_path(player, download_path); + // if wifi isn't connected or internet modules don't exist, this error will be returned. + // and it is wrongly detected as a fail. so we will skip the test on these cases. + if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && + (!_is_network_supportable)) { + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return 0; + } + assert_eq(ret, PLAYER_ERROR_NONE); - int ret3 = player_prepare(player); - assert_eq(ret3, PLAYER_ERROR_NONE); + ret = _player_prepare_start_with_connection_check(g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret4 = player_start(player); - assert_eq(ret4, PLAYER_ERROR_NONE); + ret = player_get_progressive_download_status(NULL, ¤t, &total_size); + assert_eq(ret, PLAYER_ERROR_INVALID_PARAMETER); - int ret5 = player_get_progressive_download_status(NULL, ¤t, &total_size); - assert_eq(ret5, PLAYER_ERROR_INVALID_PARAMETER); + wait_for_async(); - wait_for_async(); + ret = player_unprepare(player); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret7 = player_unprepare(player); - assert_eq(ret7, PLAYER_ERROR_NONE); - - return 0; + return 0; } /** @@ -406,26 +531,27 @@ int utc_media_player_get_progressive_download_status_n(void) */ int utc_media_player_get_progressive_download_status_n2(void) { - unsigned long current; - unsigned long total_size; - - int ret = player_set_uri(player, g_media_path); - assert_eq(ret, PLAYER_ERROR_NONE); - - int ret2 = player_set_progressive_download_path(player, download_path); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if ((ret2==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && - (!_is_network_supportable)) { - PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret2, PLAYER_ERROR_NONE); - - int ret5 = player_get_progressive_download_status(player, ¤t, &total_size); - assert_eq(ret5, PLAYER_ERROR_INVALID_STATE); - - return 0; + int ret = PLAYER_ERROR_NONE; + unsigned long current; + unsigned long total_size; + + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); + + ret = player_set_progressive_download_path(player, download_path); + // if wifi isn't connected or internet modules don't exist, this error will be returned. + // and it is wrongly detected as a fail. so we will skip the test on these cases. + if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && + (!_is_network_supportable)) { + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return 0; + } + assert_eq(ret, PLAYER_ERROR_NONE); + + ret = player_get_progressive_download_status(player, ¤t, &total_size); + assert_eq(ret, PLAYER_ERROR_INVALID_STATE); + + return 0; } /** @@ -435,20 +561,22 @@ int utc_media_player_get_progressive_download_status_n2(void) */ int utc_media_player_set_progressive_download_path_p(void) { - int ret = player_set_uri(player, g_media_path); - assert_eq(ret, PLAYER_ERROR_NONE); - - int ret2 = player_set_progressive_download_path(player, download_path); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if ((ret2==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && - (!_is_network_supportable)) { - PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret2, PLAYER_ERROR_NONE); - - return 0; + int ret = PLAYER_ERROR_NONE; + + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); + + ret = player_set_progressive_download_path(player, download_path); + // if wifi isn't connected or internet modules don't exist, this error will be returned. + // and it is wrongly detected as a fail. so we will skip the test on these cases. + if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && + (!_is_network_supportable)) { + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return 0; + } + assert_eq(ret, PLAYER_ERROR_NONE); + + return 0; } /** @@ -458,15 +586,17 @@ int utc_media_player_set_progressive_download_path_p(void) */ int utc_media_player_set_progressive_download_path_n(void) { - assert(!_is_broken); + assert(!_is_broken); - int ret = player_set_uri(player, g_media_path); - assert_eq(ret, PLAYER_ERROR_NONE); + int ret = PLAYER_ERROR_NONE; - int ret2 = player_set_progressive_download_path(NULL, download_path); - assert_eq(ret2, PLAYER_ERROR_INVALID_PARAMETER); + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - return 0; + ret = player_set_progressive_download_path(NULL, download_path); + assert_eq(ret, PLAYER_ERROR_INVALID_PARAMETER); + + return 0; } /** @@ -476,44 +606,40 @@ int utc_media_player_set_progressive_download_path_n(void) */ int utc_media_player_set_progressive_download_message_cb_p(void) { - assert(!_is_broken); + assert(!_is_broken); + int ret = PLAYER_ERROR_NONE; - int ret = player_set_uri(player, g_media_path); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player_set_uri is failed\\n", __LINE__, API_NAMESPACE); - - ret = player_set_display(player, PLAYER_DISPLAY_TYPE_NONE, NULL); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player_set_display failed\\n", __LINE__, API_NAMESPACE); - - ret = player_set_progressive_download_path(player, download_path); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player_set_progressive_download_path is failed\\n", __LINE__, API_NAMESPACE); - - ret = player_set_progressive_download_message_cb(player, _player_pd_message_cb, NULL); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if ((ret==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && - (!_is_network_supportable)) { - PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_path); + if (PLAYER_ERROR_NONE != ret) + PRINT_UTC_LOG("[Line : %d][%s] player_set_uri is failed\\n", __LINE__, API_NAMESPACE); - ret = player_prepare(player); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player isn't prepared\\n", __LINE__, API_NAMESPACE); + ret = player_set_display(player, PLAYER_DISPLAY_TYPE_NONE, NULL); + if (PLAYER_ERROR_NONE != ret) + PRINT_UTC_LOG("[Line : %d][%s] player_set_display failed\\n", __LINE__, API_NAMESPACE); - ret = player_start(player); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player isn't started\\n", __LINE__, API_NAMESPACE); + ret = player_set_progressive_download_path(player, download_path); + if (PLAYER_ERROR_NONE != ret) + PRINT_UTC_LOG("[Line : %d][%s] player_set_progressive_download_path is failed\\n", __LINE__, API_NAMESPACE); - wait_for_async(); + ret = player_set_progressive_download_message_cb(player, _player_pd_message_cb, NULL); + // if wifi isn't connected or internet modules don't exist, this error will be returned. + // and it is wrongly detected as a fail. so we will skip the test on these cases. + if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) && + (!_is_network_supportable)) { + PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE); + return 0; + } + assert_eq(ret, PLAYER_ERROR_NONE); - if(_is_pass) - PRINT_UTC_LOG("[Line : %d][%s] pd_message_callback is called!\\n", __LINE__, API_NAMESPACE); + ret = _player_prepare_start_with_connection_check(g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - return 0; + wait_for_async(); + + if(_is_pass) + PRINT_UTC_LOG("[Line : %d][%s] pd_message_callback is called!\\n", __LINE__, API_NAMESPACE); + + return 0; } /** @@ -536,34 +662,25 @@ int utc_media_player_set_progressive_download_message_cb_n(void) */ int utc_media_player_set_progressive_download_message_cb_n2(void) { - int ret = player_set_uri(player, g_media_path); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player_set_uri is failed\\n", __LINE__, API_NAMESPACE); + int ret = player_set_uri(player, g_media_path); + if (PLAYER_ERROR_NONE != ret) + PRINT_UTC_LOG("[Line : %d][%s] player_set_uri is failed\\n", __LINE__, API_NAMESPACE); - ret = player_set_display(player, PLAYER_DISPLAY_TYPE_NONE, NULL); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player_set_display failed\\n", __LINE__, API_NAMESPACE); + ret = player_set_display(player, PLAYER_DISPLAY_TYPE_NONE, NULL); + if (PLAYER_ERROR_NONE != ret) + PRINT_UTC_LOG("[Line : %d][%s] player_set_display failed\\n", __LINE__, API_NAMESPACE); - ret = player_set_progressive_download_path(player, download_path); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player_set_progressive_download_path is failed\\n", __LINE__, API_NAMESPACE); + ret = player_set_progressive_download_path(player, download_path); + if (PLAYER_ERROR_NONE != ret) + PRINT_UTC_LOG("[Line : %d][%s] player_set_progressive_download_path is failed\\n", __LINE__, API_NAMESPACE); - ret = player_prepare(player); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if(ret==PLAYER_ERROR_CONNECTION_FAILED) { - PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE); - return 0; - } + ret = _player_prepare_start_with_connection_check(g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - ret = player_start(player); - if (PLAYER_ERROR_NONE != ret) - PRINT_UTC_LOG("[Line : %d][%s] player isn't started\\n", __LINE__, API_NAMESPACE); + ret = player_set_progressive_download_message_cb(player, _player_pd_message_cb, NULL); + assert_eq(ret, PLAYER_ERROR_INVALID_STATE); - ret = player_set_progressive_download_message_cb(player, _player_pd_message_cb, NULL); - assert_eq(ret, PLAYER_ERROR_INVALID_STATE); - - return 0; + return 0; } /** @@ -637,25 +754,20 @@ void _player_adaptive_variant_cb(int bandwidth, int width, int height, void *use */ int utc_media_player_foreach_adaptive_variant_p(void) { - assert(!_is_broken); + assert(!_is_broken); + int ret = PLAYER_ERROR_NONE; - int ret = player_set_uri(player, g_media_adaptive_path); - assert_eq(ret, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_adaptive_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret2 = player_prepare(player); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if (ret2 == PLAYER_ERROR_CONNECTION_FAILED) { - PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = _player_prepare_with_connection_check(g_media_adaptive_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret3 = player_foreach_adaptive_variant(player, (player_adaptive_variant_cb)_player_adaptive_variant_cb, player); - assert_eq(ret3, PLAYER_ERROR_NONE); - assert(_is_pass); + ret = player_foreach_adaptive_variant(player, (player_adaptive_variant_cb)_player_adaptive_variant_cb, player); + assert_eq(ret, PLAYER_ERROR_NONE); + assert(_is_pass); - return 0; + return 0; } /** @@ -665,24 +777,19 @@ int utc_media_player_foreach_adaptive_variant_p(void) */ int utc_media_player_foreach_adaptive_variant_n(void) { - assert(!_is_broken); + assert(!_is_broken); + int ret = PLAYER_ERROR_NONE; - int ret = player_set_uri(player, g_media_adaptive_path); - assert_eq(ret, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_adaptive_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret2 = player_prepare(player); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if (ret2 == PLAYER_ERROR_CONNECTION_FAILED) { - PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = _player_prepare_with_connection_check(g_media_adaptive_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret3 = player_foreach_adaptive_variant(player, NULL, player); - assert_eq(ret3, PLAYER_ERROR_INVALID_PARAMETER); + ret = player_foreach_adaptive_variant(player, NULL, player); + assert_eq(ret, PLAYER_ERROR_INVALID_PARAMETER); - return 0; + return 0; } /** @@ -692,32 +799,28 @@ int utc_media_player_foreach_adaptive_variant_n(void) */ int utc_media_player_set_get_max_adaptive_variant_limit_p(void) { - assert(!_is_broken); - int bandwidth = 500000, width = 1920, height = 1080; - int get_bandwidth = 0, get_width = 0, get_height = 0; + assert(!_is_broken); - int ret = player_set_uri(player, g_media_adaptive_path); - assert_eq(ret, PLAYER_ERROR_NONE); + int ret = PLAYER_ERROR_NONE; + int bandwidth = 500000, width = 1920, height = 1080; + int get_bandwidth = 0, get_width = 0, get_height = 0; - int ret2 = player_prepare(player); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if (ret2 == PLAYER_ERROR_CONNECTION_FAILED) { - PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_adaptive_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret3 = player_set_max_adaptive_variant_limit(player, bandwidth, width, height); - assert_eq(ret3, PLAYER_ERROR_NONE); + ret = _player_prepare_with_connection_check(g_media_adaptive_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret4 = player_get_max_adaptive_variant_limit(player, &get_bandwidth, &get_width, &get_height); - assert_eq(ret4, PLAYER_ERROR_NONE); - assert_eq(bandwidth, get_bandwidth); - assert_eq(width, get_width); - assert_eq(height, get_height); + ret = player_set_max_adaptive_variant_limit(player, bandwidth, width, height); + assert_eq(ret, PLAYER_ERROR_NONE); - return 0; + ret = player_get_max_adaptive_variant_limit(player, &get_bandwidth, &get_width, &get_height); + assert_eq(ret, PLAYER_ERROR_NONE); + assert_eq(bandwidth, get_bandwidth); + assert_eq(width, get_width); + assert_eq(height, get_height); + + return 0; } /** @@ -760,31 +863,26 @@ int utc_media_player_get_max_adaptive_variant_limit_n(void) */ int utc_media_player_set_get_streaming_buffering_time_p(void) { - assert(!_is_broken); - int btime = 50000, rbtime = 100000; - int get_btime = 0, get_rbtime = 0; + assert(!_is_broken); + int ret = PLAYER_ERROR_NONE; + int btime = 50000, rbtime = 100000; + int get_btime = 0, get_rbtime = 0; - int ret = player_set_uri(player, g_media_path); - assert_eq(ret, PLAYER_ERROR_NONE); + ret = player_set_uri(player, g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret2 = player_set_streaming_buffering_time(player, btime, rbtime); - assert_eq(ret2, PLAYER_ERROR_NONE); + ret = player_set_streaming_buffering_time(player, btime, rbtime); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret3 = player_prepare(player); - // if wifi isn't connected or internet modules don't exist, this error will be returned. - // and it is wrongly detected as a fail. so we will skip the test on these cases. - if (ret3 == PLAYER_ERROR_CONNECTION_FAILED) { - PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE); - return 0; - } - assert_eq(ret3, PLAYER_ERROR_NONE); + ret = _player_prepare_with_connection_check(g_media_path); + assert_eq(ret, PLAYER_ERROR_NONE); - int ret4 = player_get_streaming_buffering_time(player, &get_btime, &get_rbtime); - assert_eq(ret4, PLAYER_ERROR_NONE); - assert_eq(btime, get_btime); - assert_eq(rbtime, get_rbtime); + ret = player_get_streaming_buffering_time(player, &get_btime, &get_rbtime); + assert_eq(ret, PLAYER_ERROR_NONE); + assert_eq(btime, get_btime); + assert_eq(rbtime, get_rbtime); - return 0; + return 0; } /**