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 PLAYER_DEFINE_H 17 #define PLAYER_DEFINE_H 18 19 #include <stdint.h> 20 #include "securec.h" 21 22 #ifdef __cplusplus 23 #if __cplusplus 24 extern "C" { 25 #endif 26 #endif /* __cplusplus */ 27 28 #ifndef HI_SUCCESS 29 #define HI_SUCCESS 0 30 #endif 31 32 #ifndef HI_FAILURE 33 #define HI_FAILURE -1 34 #endif 35 36 #define MAX_AUD_DECODER_PATH_LEN 256 37 38 typedef enum { 39 MEDIA_TYPE_VIDEO, 40 MEDIA_TYPE_VIDEO_AUDIO, 41 MEDIA_TYPE_IMAGE, 42 MEDIA_TYPE_AUDIO, 43 MEDIA_TYPE_BUTT 44 } MediaType; 45 46 typedef enum { 47 DATA_VIDEO, 48 DATA_AUDIO, 49 DATA_SUB, 50 DATA_BUTT 51 } DataType; 52 53 typedef enum { 54 EVNET_ON_STATE_CHANGE, 55 EVNET_FIRST_VIDEO_REND, 56 EVNET_VIDEO_PTS_ERRGAP, 57 EVNET_AUDIO_PTS_ERRGAP, 58 EVNET_VIDEO_RUNNING_ERR, 59 EVNET_AUDIO_RUNNING_ERR, 60 EVNET_VIDEO_PLAY_EOS, 61 EVNET_VIDEO_PLAY_SOS, 62 EVNET_AUDIO_PLAY_EOS, 63 EVNET_ON_JPEG_FRAME_RENDED, 64 EVNET_FRAME_CONTINUE_LOST, 65 EVNET_FIRST_AUDIO_REND, 66 EVNET_BUTT 67 } EventCbType; 68 69 typedef enum { 70 TPLAY_DIRECT_FORWARD, 71 TPLAY_DIRECT_BACKWARD, 72 TPLAY_DIRECT_BUTT 73 } TplayDirect; 74 75 typedef enum { 76 PLAY_STATUS_IDLE = 0, 77 PLAY_STATUS_INIT, 78 PLAY_STATUS_PREPARED, 79 PLAY_STATUS_PLAY, 80 PLAY_STATUS_TPLAY, 81 PLAY_STATUS_PAUSE, 82 PLAY_STATUS_ERR, 83 PLAY_STATUS_BUTT 84 } PlayerStatus; 85 86 typedef enum { 87 RENDER_MODE_NORMAL = 0, 88 RENDER_MODE_PAUSE_AFTER_PLAY, /* pause after play the first frame */ 89 RENDER_MODE_BUTT 90 } RenderMode; 91 92 typedef struct { 93 int32_t type; 94 uint32_t maxWidth; 95 uint32_t maxHeight; 96 uint32_t frameBufCnt; 97 uint32_t errRecover; 98 } PlayControlVdecAttr; 99 100 typedef struct { 101 int32_t type; 102 uint32_t sampleRate; 103 uint32_t channel; 104 uint32_t bitWidth; /* bits */ 105 } PlayControlAdecAttr; 106 107 typedef struct { 108 RenderMode playMode; 109 uint32_t videoBufSize; 110 uint32_t audioBufSize; 111 } PlayControlStreamAttr; 112 113 struct PlayVideoStreamInfo { 114 uint32_t decWidth; 115 uint32_t decHeight; 116 uint32_t fpsInteger; 117 uint32_t fpsDecimal; 118 uint32_t freeEsBufSize; 119 uint32_t esBufSize; 120 }; 121 122 struct PlayAudioStreamInfo { 123 uint32_t sampleRate; 124 uint32_t channel; /* only support 1-2 */ 125 uint32_t bitwith; 126 uint32_t freeEsBufSize; 127 uint32_t esBufSize; 128 }; 129 130 struct PlaySyncStatus { 131 int64_t firstVidPts; 132 int64_t lastVidPts; 133 int64_t firstAudPts; 134 int64_t lastAudPts; 135 int64_t localTime; 136 int64_t diffTime; 137 }; 138 139 typedef enum { 140 DECODER_STATUS_IDLE = 0, 141 DECODER_STATUS_PLAY, 142 DECODER_STATUS_TPLAY, 143 DECODER_STATUS_PAUSE, 144 DECODER_STATUS_ERR, 145 DECODER_STATUS_BUTT 146 } DecoderStatus; 147 148 struct PlayStatusInfo { 149 DecoderStatus vidStatus; 150 DecoderStatus audStatus; 151 PlaySyncStatus syncStatus; 152 uint64_t vidFrameCount; 153 uint64_t audFrameCount; 154 uint64_t nonDecVidCnt; 155 }; 156 157 struct PlayerStreamInfo { 158 PlayVideoStreamInfo videoInfo; 159 PlayAudioStreamInfo audioInfo; 160 PlayStatusInfo avStatus; 161 }; 162 163 struct TplayAttr { 164 TplayDirect direction; 165 float speed; 166 }; 167 168 struct VolumeAttr { 169 float leftVolume; 170 float rightVolume; 171 }; 172 173 enum PlaySpeed { 174 PLAY_SPEED_BASE = 1, 175 PLAY_SPEED_2X_FAST = 2, /* 2 x speed fast */ 176 PLAY_SPEED_4X_FAST = 4, /* 4 x speed fast */ 177 PLAY_SPEED_8X_FAST = 8, /* 8 x speed fast */ 178 PLAY_SPEED_16X_FAST = 16, /* 16 x speed fast */ 179 PLAY_SPEED_32X_FAST = 32, /* 32 x speed fast */ 180 PLAY_SPEED_64X_FAST = 64, /* 64 x speed fast */ 181 PLAY_SPEED_128X_FAST = 128, /* 128 x speed fast */ 182 PLAY_SPEED_BUTT /* Invalid speed value */ 183 }; 184 185 enum PlayerInvoke{ 186 INVOKE_ENABLE_PAUSE_AFTER_PLAYER = 0x100, 187 }; 188 189 struct InvokeParameter{ 190 PlayerInvoke id; 191 void* param; 192 }; 193 194 typedef int32_t (*OnEventCallback)(void* priv, EventCbType event, int32_t ext1, int32_t ext2); 195 196 typedef struct { 197 OnEventCallback onEventCallback; 198 void* priv; 199 } PlayEventCallback; 200 201 #ifdef __cplusplus 202 #if __cplusplus 203 } 204 #endif 205 #endif /* __cplusplus */ 206 207 #endif /* PLAYER_DEFINE_H */ 208