1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PLAYERCONTROL_DEFINE_H 17 #define PLAYERCONTROL_DEFINE_H 18 #include <pthread.h> 19 #include "player_define.h" 20 #include "media_log.h" 21 22 #ifdef __cplusplus 23 #if __cplusplus 24 extern "C" { 25 #endif 26 #endif /* End of #ifdef __cplusplus */ 27 28 static const uint32_t MS_SCALE = 1000; 29 static const int64_t INVALID_PTS = -1; 30 31 static const uint32_t FULL_TPLAY_FRAMERATE_LIMIT = 30; 32 /* DEFAULT_BITRATE: 2 * 1024 */ 33 static const uint32_t FULL_TPLAY_BITRATE_LIMIT = 2048; 34 /* TPLAY_FULL_LIMIT_RESULITON: 1024 * 576 */ 35 static const uint32_t FULL_TPLAY_RESULITON_LIMIT = 589824; 36 static const uint32_t HI_RET_SKIP_PACKET = 1; 37 static const uint32_t EXTRA_MBUF_LEN = 1500; 38 39 static const uint32_t TPLAY_SPEED_DECIMAL_PRECISION = 1000; 40 static const uint32_t AUDIO_BITWIDTH = 16; 41 static const uint32_t MIN_NOTIFY_INTERVAL_MS = 50; 42 static const int32_t OFFSET_INCREASE_FOR_FRAME_LOST = 2; 43 /* video es stream buf max limit size: (200 * 1024 * 1024) */ 44 static const uint32_t VIDEO_ESBUF_SIZE_LIMIT = 209715200; 45 /* audio es stream buf max limit size: (100 * 1024 * 1024) */ 46 static const uint32_t AUDIO_ESBUF_SIZE_LIMIT = 104857600; 47 static const uint32_t AV_ESBUF_SIZE_MIN = 1024; 48 static const uint32_t VDEC_VBBUF_CONUT_MIN = 3; 49 50 static const uint32_t PLAYER_8K_WIDTH = 7680; 51 static const uint32_t PLAYER_8K_HEIGHT = 4320; 52 /* PLAYER_VID_BUF_SIZE_LEVEL1: (24 * 1024 * 1024) */ 53 static const uint32_t PLAYER_VID_BUF_SIZE_LEVEL1 = 25165824; 54 /* PLAYER_VID_BUF_SIZE_LEVEL2: (12 * 1024 * 1024) */ 55 static const uint32_t PLAYER_VID_BUF_SIZE_LEVEL2 = 12582912; 56 /* PLAYER_VID_BUF_SIZE_LEVEL3: (8 * 1024 * 1024) */ 57 static const uint32_t PLAYER_VID_BUF_SIZE_LEVEL3 = 8388608; 58 /* PLAYER_VID_BUF_SIZE_LEVEL4: (4 * 1024 * 1024) */ 59 static const uint32_t PLAYER_VID_BUF_SIZE_LEVEL4 = 4194304; 60 61 static const uint32_t PLAYER_4K_WIDTH = 3840; 62 static const uint32_t PLAYER_4K_HEIGHT = 2160; 63 static const uint32_t PLAYER_1080P_WIDTH = 1920; 64 static const uint32_t PLAYER_1080P_HEIGHT = 1080; 65 66 /* PLAYER_MPF_MBUF_SIZE: (600 * 1024) */ 67 static const uint32_t PLAYER_MPF_MBUF_SIZE = 614400; 68 /* PLAYER_MPF_BUF_EXTRA: (2 * 1024) */ 69 static const uint32_t PLAYER_MPF_BUF_EXTRA = 2048; 70 /* PLAYER_MPF_ESBUF_MIN: (32 * 1024) */ 71 static const uint32_t PLAYER_MPF_ESBUF_MIN = 32768; 72 73 static const int32_t AV_INVALID_PTS = -1; 74 75 static const uint32_t NO_WAIT = 0; 76 77 static const uint32_t ZERO_ARG = 0; 78 79 static const uint32_t MAX_MSG_QUEUE_SIZE = 50; 80 81 static const uint32_t MAX_MSG_QUEUE_PAYLOAD_SIZE = 1024; 82 83 #define PLAYER_LOCK(mutex) \ 84 do { \ 85 int32_t lockRet = pthread_mutex_lock(&(mutex)); \ 86 if (lockRet != 0) { \ 87 MEDIA_ERR_LOG("lock failed err: %d", lockRet); \ 88 } \ 89 } while (0) 90 91 #define PLAYER_UNLOCK(mutex) \ 92 do { \ 93 int32_t unLockRet = pthread_mutex_unlock(&(mutex)); \ 94 if (unLockRet != 0) { \ 95 MEDIA_ERR_LOG("unlock failed err: %d", unLockRet); \ 96 } \ 97 } while (0) 98 99 enum PlayerTplayMode { 100 PLAYER_TPLAY_FULL_PLAY, 101 PLAYER_TPLAY_ONLY_I_FRAME, 102 PLAYER_TPLAY_BUTT 103 }; 104 105 enum PlayerTplaySeekOffset { 106 TPLAY_SEEK_OFFSET_2X = 250, // ms 107 TPLAY_SEEK_OFFSET_4X = 250, 108 TPLAY_SEEK_OFFSET_8X = 400, 109 TPLAY_SEEK_OFFSET_16X = 800, 110 TPLAY_SEEK_OFFSET_32X = 1600, 111 TPLAY_SEEK_OFFSET_64X = 3200, 112 TPLAY_SEEK_OFFSET_128X = 6400 113 }; 114 115 #ifdef __cplusplus 116 #if __cplusplus 117 } 118 #endif 119 #endif /* End of #ifdef __cplusplus */ 120 121 #endif // PLAYERCONTROL_DEFINE_H