4b5a8dc98aab869bdc8d06ebd2dde0fcabade042
[mirrors/FD230.git] /
1 /*
2  * Copyright (c) 2020-2022 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 REQUEST_SURFACE_BUFFER_FATAL (-2)
37
38 #define NOT_FOUND_ACTIVE_STREAME (-9)
39
40 #define MAX_AUD_DECODER_PATH_LEN  256
41
42 typedef enum {
43     MEDIA_TYPE_VIDEO,
44     MEDIA_TYPE_VIDEO_AUDIO,
45     MEDIA_TYPE_IMAGE,
46     MEDIA_TYPE_AUDIO,
47     MEDIA_TYPE_BUTT
48 } MediaType;
49
50 typedef enum {
51     DATA_VIDEO,
52     DATA_AUDIO,
53     DATA_SUB,
54     DATA_BUTT
55 } DataType;
56
57 typedef enum {
58     EVNET_ON_STATE_CHANGE,
59     EVNET_FIRST_VIDEO_REND,
60     EVNET_VIDEO_PTS_ERRGAP,
61     EVNET_AUDIO_PTS_ERRGAP,
62     EVNET_VIDEO_RUNNING_ERR,
63     EVNET_AUDIO_RUNNING_ERR,
64     EVNET_VIDEO_PLAY_EOS,
65     EVNET_VIDEO_PLAY_SOS,
66     EVNET_AUDIO_PLAY_EOS,
67     EVNET_AUDIO_BUFFER_EMPTY,
68     EVNET_ON_JPEG_FRAME_RENDED,
69     EVNET_FRAME_CONTINUE_LOST,
70     EVNET_FIRST_AUDIO_REND,
71     EVNET_BUTT
72 } EventCbType;
73
74 typedef enum {
75     PLAY_STATUS_IDLE = 0,
76     PLAY_STATUS_INIT,
77     PLAY_STATUS_PREPARED,
78     PLAY_STATUS_PLAY,
79     PLAY_STATUS_PAUSE,
80     PLAY_STATUS_ERR,
81     PLAY_STATUS_BUTT
82 } PlayerStatus;
83
84 typedef enum {
85     RENDER_MODE_NORMAL = 0,
86     RENDER_MODE_PAUSE_AFTER_PLAY, /* pause after play the first frame */
87     RENDER_MODE_BUTT
88 } RenderMode;
89
90 typedef struct {
91     int32_t type;
92     uint32_t maxWidth;
93     uint32_t maxHeight;
94     uint32_t frameBufCnt;
95     uint32_t errRecover;
96 } PlayControlVdecAttr;
97
98 typedef struct {
99     int32_t type;
100     uint32_t sampleRate;
101     uint32_t channel;
102     uint32_t bitWidth; /* bits */
103 } PlayControlAdecAttr;
104
105 typedef struct {
106     RenderMode playMode;
107     uint32_t videoBufSize;
108     uint32_t audioBufSize;
109 } PlayControlStreamAttr;
110
111 struct PlayVideoStreamInfo {
112     uint32_t decWidth;
113     uint32_t decHeight;
114     uint32_t fpsInteger;
115     uint32_t fpsDecimal;
116     uint32_t freeEsBufSize;
117     uint32_t esBufSize;
118 };
119
120 struct PlayAudioStreamInfo {
121     uint32_t sampleRate;
122     uint32_t channel; /* only support 1-2 */
123     uint32_t bitwith;
124     uint32_t freeEsBufSize;
125     uint32_t esBufSize;
126 };
127
128 struct PlaySyncStatus {
129     int64_t firstVidPts;
130     int64_t lastVidPts;
131     int64_t firstAudPts;
132     int64_t lastAudPts;
133     int64_t localTime;
134     int64_t diffTime;
135 };
136
137 typedef enum {
138     DECODER_STATUS_IDLE = 0,
139     DECODER_STATUS_PLAY,
140     DECODER_STATUS_TPLAY,
141     DECODER_STATUS_PAUSE,
142     DECODER_STATUS_ERR,
143     DECODER_STATUS_BUTT
144 } DecoderStatus;
145
146 struct PlayStatusInfo {
147     DecoderStatus vidStatus;
148     DecoderStatus audStatus;
149     PlaySyncStatus syncStatus;
150     uint64_t vidFrameCount;
151     uint64_t audFrameCount;
152 };
153
154 struct PlayerStreamInfo {
155     PlayVideoStreamInfo videoInfo;
156     PlayAudioStreamInfo audioInfo;
157     PlayStatusInfo avStatus;
158 };
159
160 struct VolumeAttr {
161     float leftVolume;
162     float rightVolume;
163 };
164
165 enum PlayerInvoke {
166     INVOKE_ENABLE_PAUSE_AFTER_PLAYER = 0x100,
167     INVOKE_SET_AUDIO_SESSION,
168     INVOKE_SET_OUTPUT_DEVICE,
169     INVOKE_SET_AUDIOSTREAM_TYPE
170 };
171
172 struct InvokeParameter {
173     PlayerInvoke id;
174     const void* param;
175 };
176
177 typedef int32_t (*OnEventCallback)(void* priv, EventCbType event, int32_t ext1, int32_t ext2);
178
179 typedef struct {
180     OnEventCallback onEventCallback;
181     void* priv;
182 } PlayEventCallback;
183
184 #ifdef __cplusplus
185 #if __cplusplus
186 }
187 #endif
188 #endif /* __cplusplus */
189
190 #endif /* PLAYER_DEFINE_H */