1 /* 2 * Copyright 2020 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SRC_TESTS_RT_MPI_COMMON_TEST_COMM_UTILS_H_ 18 #define SRC_TESTS_RT_MPI_COMMON_TEST_COMM_UTILS_H_ 19 20 #include "rk_type.h" 21 #include "rk_debug.h" 22 #include "rk_comm_video.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif 28 #endif /* End of #ifdef __cplusplus */ 29 30 #define CHECK_CHN_RET(express, chn, name) \ 31 do { \ 32 RK_S32 s32Ret; \ 33 s32Ret = express; \ 34 if (RK_SUCCESS != s32Ret) { \ 35 RK_LOGE("\033[0;31m%s chn %d failed with %#x!\033[0;39m", name, chn, s32Ret); \ 36 return s32Ret; \ 37 } \ 38 } while (0) 39 40 #define CHECK_RET(express, name) \ 41 do { \ 42 RK_S32 s32Ret; \ 43 s32Ret = express; \ 44 if (RK_SUCCESS != s32Ret) { \ 45 RK_LOGE("\033[0;31m%s failed with %#x!\033[0;39m", name, s32Ret); \ 46 return s32Ret; \ 47 } \ 48 } while (0) 49 50 #define RK_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) 51 #define RK_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 52 #define RK_ALIGN_16(x) RK_ALIGN(x, 16) 53 #define RK_ALIGN_64(x) RK_ALIGN(x, 64) 54 #define RK_ALIGN_256(x) RK_ALIGN(x, 256) 55 #define RK_ALIGN_256_ODD(x) (RK_ALIGN(x, 256) | 256) 56 57 typedef enum _RTUriSchemeType { 58 RK_URI_SCHEME_NONE = 0, 59 RK_URI_SCHEME_LOCAL, 60 RK_URI_SCHEME_HTTP, 61 RK_URI_SCHEME_RTSP, 62 RK_URI_SCHEME_SAMBA, 63 RK_URI_SCHEME_HLS, 64 RK_URI_SCHEME_RTP, 65 RK_URI_SCHEME_UDP, 66 RK_URI_SCHEME_MMS, 67 RK_URI_SCHEME_MMSH, 68 RK_URI_SCHEME_MMST, 69 RK_URI_SCHEME_TTS, 70 RK_URI_SCHEME_IPTV, 71 } URI_SCHEME_TYPE; 72 73 typedef enum _RKSocType { 74 RK_SOC_UNKOWN = 0, 75 RK_SOC_1126, 76 RK_SOC_3568, 77 RK_SOC_3588 78 } RKSocType; 79 80 RK_U64 TEST_COMM_GetNowUs(); 81 URI_SCHEME_TYPE TEST_COMM_GetUriSchemeType(const char* uri); 82 RK_S32 TEST_COMM_OpenFileUris(const char *pCfgFileUri, char **pFileUris, RK_U32 u32UriCount); 83 void TEST_COMM_CloseFileUris(char **pFileUris, RK_U32 u32UriCount); 84 void TEST_COMM_MkDirs(const char *muldir, RK_S32 mode); 85 RK_S32 TEST_COMM_CheckFileSizeInRange(const char *pFilePath, RK_S32 minSize, RK_S32 maxSize); 86 87 RK_S32 TEST_COMM_FileReadOneFrame(const char *pFileName, VIDEO_FRAME_INFO_S *pstVideoFrame); 88 RK_S32 TEST_COMM_FileWriteOneFrame(const char *pFileName, VIDEO_FRAME_INFO_S *pstVideoFrame); 89 RKSocType TEST_COMM_GetSocType(); 90 91 #ifdef __cplusplus 92 #if __cplusplus 93 } 94 #endif 95 #endif /* End of #ifdef __cplusplus */ 96 97 #endif // SRC_TESTS_RT_MPI_COMMON_TEST_COMM_UTILS_H_ 98 99