blob: 8d3c5e276430611d25da87c25dcaadad8b4796d2 [file] [log] [blame]
Gong Ke3489c0f2020-01-16 18:11:44 +08001/**
2 * \file
Gong Ke497c4c22020-03-20 10:15:42 +08003 * \brief Playback module.
Gong Ke3489c0f2020-01-16 18:11:44 +08004 */
5
hualing chenb31a6c62020-01-13 17:27:00 +08006#ifndef DVR_PLAYBACK_H_
7#define DVR_PLAYBACK_H_
hualing chenb31a6c62020-01-13 17:27:00 +08008#include "list.h"
Gong Ke3489c0f2020-01-16 18:11:44 +08009#include "dvr_types.h"
hualing chen86e7d482020-01-16 15:13:33 +080010#include "segment.h"
hualing chen2aba4022020-03-02 13:49:55 +080011#include "AmTsPlayer.h"
hualing chen040df222020-01-17 13:35:02 +080012#include "dvr_types.h"
13#include "dvr_crypto.h"
Zhiqiang Hanf9c0e272022-06-14 13:54:03 +080014#include "dvr_mutex.h"
hualing chen040df222020-01-17 13:35:02 +080015
hualing chenb31a6c62020-01-13 17:27:00 +080016#ifdef __cplusplus
17extern "C" {
18#endif
Gong Ke3489c0f2020-01-16 18:11:44 +080019
hualing chen040df222020-01-17 13:35:02 +080020/**\brief dvr play segment flag */
hualing chenb31a6c62020-01-13 17:27:00 +080021typedef enum
22{
Gong Ke3489c0f2020-01-16 18:11:44 +080023 DVR_PLAYBACK_SEGMENT_ENCRYPTED = (1 << 0), /**< encrypted stream */
24 DVR_PLAYBACK_SEGMENT_DISPLAYABLE = (1 << 1), /**< displayable stream */
Gong Ke497c4c22020-03-20 10:15:42 +080025 DVR_PLAYBACK_SEGMENT_CONTINUOUS = (1 << 2) /**< continuous stream with pre one */
Gong Ke3489c0f2020-01-16 18:11:44 +080026} DVR_PlaybackSegmentFlag_t;
hualing chenb31a6c62020-01-13 17:27:00 +080027
28/**\brief dvr pid type*/
29typedef enum
30{
Gong Ke3489c0f2020-01-16 18:11:44 +080031 DVR_PLAYBACK_SYNC, /**< sync play mode */
32 DVR_PLAYBACK_ASYNC /**< out of sync play mode */
33} DVR_PlaybackSyncMode_t;
hualing chenb31a6c62020-01-13 17:27:00 +080034
35
36/**\brief dvr play pids */
37typedef struct
38{
Gong Ke3489c0f2020-01-16 18:11:44 +080039 DVR_StreamInfo_t video; /**< Video.*/
40 DVR_StreamInfo_t audio; /**< Audio.*/
41 DVR_StreamInfo_t ad; /**< AD.*/
42 DVR_StreamInfo_t subtitle; /**< Subtitle.*/
43 DVR_StreamInfo_t pcr; /**< PCR.*/
44} DVR_PlaybackPids_t;
hualing chenb31a6c62020-01-13 17:27:00 +080045
hualing chen1679f812021-11-08 15:17:46 +080046/**\brief dvr play pids */
47typedef struct
48{
49 DVR_PlaybackPids_t pids; /**< Video.*/
50 int av_scale;
51} DVR_Playback_info_t;
52
Gong Ke3489c0f2020-01-16 18:11:44 +080053/**\brief dvr segments info */
hualing chenb31a6c62020-01-13 17:27:00 +080054typedef struct
55{
Gong Ke3489c0f2020-01-16 18:11:44 +080056 struct list_head head; /**< Segment node.*/
hualing chen5cbe1a62020-02-10 16:36:36 +080057 uint64_t segment_id; /**< Segment's index.*/
58 char location[DVR_MAX_LOCATION_SIZE]; /**< chunk location */
Gong Ke3489c0f2020-01-16 18:11:44 +080059 DVR_PlaybackPids_t pids; /**< Streams' PIDs.*/
hualing chen040df222020-01-17 13:35:02 +080060 DVR_PlaybackSegmentFlag_t flags; /**< Segment's flag */
Gong Ke3489c0f2020-01-16 18:11:44 +080061 int key_data_id; /**< ??? */
hualing chen03fd4942021-07-15 15:56:41 +080062 int duration; /**< Segment dur time ms*/
Gong Ke3489c0f2020-01-16 18:11:44 +080063} DVR_PlaybackSegmentInfo_t;
hualing chenb31a6c62020-01-13 17:27:00 +080064
65/**\brief play flag, if set this flag, player need pause when decode first frame */
66typedef enum
67{
Gong Ke3489c0f2020-01-16 18:11:44 +080068 DVR_PLAYBACK_STARTED_PAUSEDLIVE = (1 << 0) /**< dvr play stat,need change to pause state if set */
69} DVR_PlaybackFlag_t;
hualing chen86e7d482020-01-16 15:13:33 +080070
71/**\brief playback speed mode*/
hualing chenb31a6c62020-01-13 17:27:00 +080072typedef enum
73{
Gong Ke3489c0f2020-01-16 18:11:44 +080074 DVR_PLAYBACK_FAST_FORWARD = 0, /**< fast forward */
75 DVR_PLAYBACK_FAST_BACKWARD = 1, /**< fast backward */
hualing chen31140872020-03-25 12:29:26 +080076 DVR_PLAYBACK_KERNEL_SUPPORT = 2, /**< kernel support mode */
Gong Ke3489c0f2020-01-16 18:11:44 +080077} DVR_PlaybackSpeedMode_t;
hualing chenb31a6c62020-01-13 17:27:00 +080078
hualing chen2aba4022020-03-02 13:49:55 +080079/**\brief playback speed*/
80typedef enum
81{
hualing chene41f4372020-06-06 16:29:17 +080082 PLAYBACK_SPEED_FBX1 = -100, /**<FB X 1 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080083 PLAYBACK_SPEED_FBX2 = -200, /**<FB X 2 speed*/
84 PLAYBACK_SPEED_FBX4 = -400, /**<FB X 4 speed*/
85 PLAYBACK_SPEED_FBX8 = -800, /**<FB X 8 speed*/
hualing chen041c4092020-04-05 15:11:50 +080086 PLAYBACK_SPEED_FBX12 = -1200, /**< FB 12 speed*/
87 PLAYBACK_SPEED_FBX16 = -1600, /**<FB X 16 speed*/
88 PLAYBACK_SPEED_FBX32 = -3200, /**<FB X 32 speed*/
89 PLAYBACK_SPEED_FBX48 = -4800, /**<FB X 48 speed*/
90 PLAYBACK_SPEED_FBX64 = -6400, /**<FB X 64 speed*/
91 PLAYBACK_SPEED_FBX128 = -12800, /**<FB X 128 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080092 PLAYBACK_SPEED_S8 = 12, /**<slow 1/8 speed*/
93 PLAYBACK_SPEED_S4 = 25, /**<slow 1/4 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080094 PLAYBACK_SPEED_S2 = 50, /**<slow 1/2 speed*/
95 PLAYBACK_SPEED_X1 = 100, /**< X 1 normal speed*/
96 PLAYBACK_SPEED_X2 = 200, /**< X 2 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080097 PLAYBACK_SPEED_X3 = 300, /**< X 3 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080098 PLAYBACK_SPEED_X4 = 400, /**< X 4 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080099 PLAYBACK_SPEED_X5 = 500, /**< X 5 speed*/
100 PLAYBACK_SPEED_X6 = 600, /**< X 6 speed*/
101 PLAYBACK_SPEED_X7 = 700, /**< X 7 speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800102 PLAYBACK_SPEED_X8 = 800, /**< X 8 speed*/
hualing chen041c4092020-04-05 15:11:50 +0800103 PLAYBACK_SPEED_X12 = 1200, /**< X 12 speed*/
104 PLAYBACK_SPEED_X16 = 1600, /**< X 16 speed*/
105 PLAYBACK_SPEED_X32 = 3200, /**< X 32 speed*/
106 PLAYBACK_SPEED_X48 = 4800, /**< X 48 speed*/
107 PLAYBACK_SPEED_X64 = 6400, /**< X 64 speed*/
108 PLAYBACK_SPEED_X128 = 12800, /**< X 128 speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800109 PlayBack_Speed_MAX,
110} Playback_SpeedValue_t;
111
Gong Ke497c4c22020-03-20 10:15:42 +0800112/**\brief playback speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800113typedef struct Playback_Speeds_s {
Gong Ke497c4c22020-03-20 10:15:42 +0800114 int speed; /**< playback speed value*/
hualing chen2aba4022020-03-02 13:49:55 +0800115} Playback_Speeds_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800116
Gong Ke3489c0f2020-01-16 18:11:44 +0800117/**\brief playback play speed*/
hualing chenb31a6c62020-01-13 17:27:00 +0800118typedef struct
119{
hualing chen2aba4022020-03-02 13:49:55 +0800120 Playback_Speeds_t speed; /**< playback speed */
Gong Ke3489c0f2020-01-16 18:11:44 +0800121 DVR_PlaybackSpeedMode_t mode; /**< playback 0: fast forword or 1: fast backword*/
122} DVR_PlaybackSpeed_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800123
hualing chen2aba4022020-03-02 13:49:55 +0800124
Gong Ke3489c0f2020-01-16 18:11:44 +0800125/**Maximum supported speed modes.*/
hualing chenb31a6c62020-01-13 17:27:00 +0800126#define DVR_MAX_SUPPORTED_SPEEDS 32
Gong Ke3489c0f2020-01-16 18:11:44 +0800127
hualing chenb31a6c62020-01-13 17:27:00 +0800128/**\brief playback capability*/
129typedef struct
130{
hualing chen86e7d482020-01-16 15:13:33 +0800131 int nb_supported_speeds; /**< support playback speed count*/
132 int supported_speeds[DVR_MAX_SUPPORTED_SPEEDS]; /**< support playback speed*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800133} DVR_PlaybackCapability_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800134
Gong Ke3489c0f2020-01-16 18:11:44 +0800135/**Playback handle.*/
136typedef void* DVR_PlaybackHandle_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800137
hualing chencc91e1c2020-02-28 13:26:17 +0800138
139/**\brief playback error reason*/
140typedef enum
141{
142 DVR_PLAYBACK_PID_ERROR, /**< uninit state */
143 DVR_PLAYBACK_FMT_ERROR /**< fmt not surport backword */
144} DVR_PlaybackError_t;
145
146
hualing chenb31a6c62020-01-13 17:27:00 +0800147/**\brief playback play state*/
148typedef enum
149{
Gong Ke3489c0f2020-01-16 18:11:44 +0800150 DVR_PLAYBACK_STATE_START, /**< start play */
151 DVR_PLAYBACK_STATE_STOP, /**< stop */
152 DVR_PLAYBACK_STATE_PAUSE, /**< pause */
153 DVR_PLAYBACK_STATE_FF, /**< fast forward */
154 DVR_PLAYBACK_STATE_FB /**< fast backword */
155} DVR_PlaybackPlayState_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800156
157/**\brief playback play status*/
158typedef struct
159{
Gong Ke3489c0f2020-01-16 18:11:44 +0800160 DVR_PlaybackPlayState_t state; /**< playback play state */
hualing chen5cbe1a62020-02-10 16:36:36 +0800161 uint64_t segment_id; /**< playback ongoing segment index */
Wentao MAac5ea062022-08-11 11:44:27 +0800162 int32_t time_cur; /**< current playback time position in ms of a segment.
163 It can be a negative value to refer to relative time
164 position of previous segment*/
165 int32_t time_end; /**< end time position of a segment in ms */
Gong Ke3489c0f2020-01-16 18:11:44 +0800166 DVR_PlaybackPids_t pids; /**< playback played pids */
hualing chen5cbe1a62020-02-10 16:36:36 +0800167 int speed; /**< playback speed */
168 DVR_PlaybackSegmentFlag_t flags; /**< playback played segment flag */
Gong Ke3489c0f2020-01-16 18:11:44 +0800169} DVR_PlaybackStatus_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800170
hualing chenfbf8e022020-06-15 13:43:11 +0800171/**\brief DVR playback vendor*/
172typedef enum {
173 DVR_PLAYBACK_VENDOR_DEF , /**< default*/
hualing chen90b3ae62021-03-30 10:49:28 +0800174 DVR_PLAYBACK_VENDOR_AML, /**< aml*/
175 DVR_PLAYBACK_VENDOR_AMAZON /**< amazon*/
hualing chenfbf8e022020-06-15 13:43:11 +0800176} DVR_PlaybackVendor_t;
177
178
hualing chencc91e1c2020-02-28 13:26:17 +0800179/**\brief DVR playback event*/
180typedef enum {
181 DVR_PLAYBACK_EVENT_ERROR = 0x1000, /**< Signal a critical playback error*/
182 DVR_PLAYBACK_EVENT_TRANSITION_OK , /**< transition ok*/
183 DVR_PLAYBACK_EVENT_TRANSITION_FAILED, /**< transition failed*/
184 DVR_PLAYBACK_EVENT_KEY_FAILURE, /**< key failure*/
185 DVR_PLAYBACK_EVENT_NO_KEY, /**< no key*/
186 DVR_PLAYBACK_EVENT_REACHED_BEGIN , /**< reached begin*/
hualing chen2aba4022020-03-02 13:49:55 +0800187 DVR_PLAYBACK_EVENT_REACHED_END, /**< reached end*/
Wentao MA270dc0f2022-08-23 13:17:26 +0800188 DVR_PLAYBACK_EVENT_NOTIFY_PLAYTIME, /**< notify play cur segment time ms*/
hualing chene3797f02021-01-13 14:53:28 +0800189 DVR_PLAYBACK_EVENT_FIRST_FRAME, /**< first frame*/
190 DVR_PLAYBACK_EVENT_NODATA, /**< no data*/
191 DVR_PLAYBACK_EVENT_DATARESUME /**< data resume*/
hualing chencc91e1c2020-02-28 13:26:17 +0800192} DVR_PlaybackEvent_t;
193
194/**\brief DVR playback event notify function*/
195typedef struct
196{
Gong Ke497c4c22020-03-20 10:15:42 +0800197 DVR_PlaybackEvent_t event; /**< event type*/
198 DVR_PlaybackStatus_t play_status; /**< play status*/
hualing chencc91e1c2020-02-28 13:26:17 +0800199 union
200 {
Gong Ke497c4c22020-03-20 10:15:42 +0800201 uint8_t unused;
202 uint8_t error_reason;/**< error reason*/
hualing chencc91e1c2020-02-28 13:26:17 +0800203 struct
204 {
Gong Ke497c4c22020-03-20 10:15:42 +0800205 uint64_t segment_id; /**< error segment id*/
206 uint32_t key_data_id; /**< key data id*/
207 uint8_t error; /**< error*/
hualing chencc91e1c2020-02-28 13:26:17 +0800208 } transition_failed_data;
Gong Ke497c4c22020-03-20 10:15:42 +0800209 } info; /**< information*/
hualing chencc91e1c2020-02-28 13:26:17 +0800210} DVR_Play_Notify_t;
211
212/**\brief DVR playback event notify function*/
213typedef DVR_Result_t (*DVR_PlaybackEventFunction_t) (DVR_PlaybackEvent_t event, void *params, void *userdata);
214
215
hualing chenb31a6c62020-01-13 17:27:00 +0800216/**\brief playback open params*/
217typedef struct
218{
Gong Ke3489c0f2020-01-16 18:11:44 +0800219 int dmx_dev_id; /**< playback used dmx device index*/
220 int block_size; /**< playback inject block size*/
221 DVR_Bool_t is_timeshift; /**< 0:playback mode, 1 : is timeshift mode*/
hualing chen2aba4022020-03-02 13:49:55 +0800222 am_tsplayer_handle player_handle; /**< am tsplayer handle.*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800223 DVR_CryptoFunction_t crypto_fn; /**< Crypto function.*/
Yahui Han1fbf3292021-11-08 18:17:19 +0800224 void *crypto_data; /**< Crypto function's user data.*/
225 uint8_t *clearkey; /**< key for encrypted PVR on FTA.*/
Wentao MAe8ba5172022-08-09 11:18:17 +0800226 uint8_t *cleariv; /**< iv for encrypted PVR on FTA.*/
Yahui Han1fbf3292021-11-08 18:17:19 +0800227 uint32_t keylen; /**< key/iv length.*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800228 DVR_Bool_t has_pids; /**< has video audo pid fmt info*/
hualing chencc91e1c2020-02-28 13:26:17 +0800229 DVR_PlaybackEventFunction_t event_fn; /**< playback event callback function*/
230 void *event_userdata; /**< event userdata*/
hualing chenfbf8e022020-06-15 13:43:11 +0800231 DVR_PlaybackVendor_t vendor; /**< vendor type,default is 0*/
hualing chene3797f02021-01-13 14:53:28 +0800232 DVR_Bool_t is_notify_time; /**< notify play time info true or not*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800233} DVR_PlaybackOpenParams_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800234
235/**\brief playback play state*/
236typedef enum
237{
hualing chen040df222020-01-17 13:35:02 +0800238 DVR_PLAYBACK_CMD_START, /**< start av */
239 DVR_PLAYBACK_CMD_STOP, /**< stop av */
Wentao MA270dc0f2022-08-23 13:17:26 +0800240 DVR_PLAYBACK_CMD_V_START, /**< v start */
241 DVR_PLAYBACK_CMD_A_START , /**< a start */
242 DVR_PLAYBACK_CMD_V_STOP , /**< v stop */
243 DVR_PLAYBACK_CMD_A_STOP, /**< a stop */
244 DVR_PLAYBACK_CMD_V_RESTART, /**< v restart */
245 DVR_PLAYBACK_CMD_A_RESTART, /**< a restart */
246 DVR_PLAYBACK_CMD_AV_RESTART, /**< av restart */
247 DVR_PLAYBACK_CMD_V_STOP_A_START, /**< v stop a start*/
248 DVR_PLAYBACK_CMD_A_STOP_V_START, /**< a stop v_start */
249 DVR_PLAYBACK_CMD_V_STOP_A_RESTART, /**<v stop a restart*/
250 DVR_PLAYBACK_CMD_A_STOP_V_RESTART, /**<a stop v restart*/
251 DVR_PLAYBACK_CMD_V_START_A_RESTART, /**<v start a restart*/
252 DVR_PLAYBACK_CMD_A_START_V_RESTART, /**<a start v restart*/
hualing chen040df222020-01-17 13:35:02 +0800253 DVR_PLAYBACK_CMD_PAUSE, /**< pause */
254 DVR_PLAYBACK_CMD_RESUME, /**< resume */
255 DVR_PLAYBACK_CMD_SEEK, /**< seek */
256 DVR_PLAYBACK_CMD_FF, /**< fast forward */
257 DVR_PLAYBACK_CMD_FB, /**< fast backword */
hualing chen5cbe1a62020-02-10 16:36:36 +0800258 DVR_PLAYBACK_CMD_NONE, /**< none */
hualing chen040df222020-01-17 13:35:02 +0800259} DVR_PlaybackCmd_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800260
261
262/**\brief playback struct*/
263typedef struct
264{
hualing chen5cbe1a62020-02-10 16:36:36 +0800265 DVR_PlaybackSpeed_t speed; /**< play speed */
266 DVR_PlaybackPlayState_t state; /**< play state */
hualing chen040df222020-01-17 13:35:02 +0800267 DVR_PlaybackCmd_t cur_cmd; /**< cur send cmd */
268 DVR_PlaybackCmd_t last_cmd; /**< last cmd */
269 int pos; /**< seek pos at cur segment*/
270} DVR_PlaybackCmdInfo_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800271
hualing chend241c7a2021-06-22 13:34:27 +0800272/**\brief playback struct*/
273typedef struct
274{
hualing chen7ea70a72021-09-09 11:25:13 +0800275 uint32_t sys_dur; /**< system duration */
276 uint32_t sys_sta; /**< system start time */
277 uint32_t ply_dur; /**< play duration */
278 uint32_t ply_sta; /**< play start time */
hualing chend241c7a2021-06-22 13:34:27 +0800279} DVR_PlaybackConSpe_t;
280
281
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800282/**\brief DVR playback decrypt function*/
283typedef DVR_Result_t (*DVR_PlaybackDecryptFunction_t) (uint8_t *p_in,
284 uint32_t in_len,
285 uint8_t *p_out,
286 uint32_t *p_out_len,
287 void *userdata);
hualing chenb31a6c62020-01-13 17:27:00 +0800288
Gong Ke497c4c22020-03-20 10:15:42 +0800289/**\cond */
hualing chenb31a6c62020-01-13 17:27:00 +0800290/**\brief playback struct*/
291typedef struct
292{
hualing chen2aba4022020-03-02 13:49:55 +0800293 am_tsplayer_handle handle; /**< tsplayer handle */
hualing chencc91e1c2020-02-28 13:26:17 +0800294 DVR_Bool_t segment_is_open; /**<segment is opend*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800295 uint64_t cur_segment_id; /**< Current segment id*/
hualing chen040df222020-01-17 13:35:02 +0800296 DVR_PlaybackSegmentInfo_t cur_segment; /**< Current playing segment*/
hualing chencc91e1c2020-02-28 13:26:17 +0800297 uint64_t last_segment_id; /**< last segment id*/
298 DVR_PlaybackSegmentInfo_t last_segment; /**< last playing segment*/
hualing chen040df222020-01-17 13:35:02 +0800299 struct list_head segment_list; /**< segment list head*/
300 pthread_t playback_thread; /**< playback thread*/
Zhiqiang Hanf9c0e272022-06-14 13:54:03 +0800301 dvr_mutex_t lock; /**< playback lock*/
hualing chen2aba4022020-03-02 13:49:55 +0800302 pthread_mutex_t segment_lock; /**< playback segment lock*/
hualing chen040df222020-01-17 13:35:02 +0800303 pthread_cond_t cond; /**< playback cond*/
304 void *user_data; /**< playback userdata, used to send event*/
hualing chen6d24aa92020-03-23 18:43:47 +0800305 float speed; /**< playback speed*/
hualing chen040df222020-01-17 13:35:02 +0800306 DVR_PlaybackPlayState_t state; /**< playback state*/
307 DVR_PlaybackFlag_t play_flag; /**< playback play flag*/
hualing chen86e7d482020-01-16 15:13:33 +0800308 int is_running; /**< playback htread is runing*/
hualing chen040df222020-01-17 13:35:02 +0800309 DVR_PlaybackCmdInfo_t cmd; /**< playback cmd*/
310 int offset; /**< segment read offset*/
hualing chencc91e1c2020-02-28 13:26:17 +0800311 uint32_t dur; /**< segment dur*/
hualing chen86e7d482020-01-16 15:13:33 +0800312 Segment_Handle_t r_handle; /**< playback current segment handle*/
hualing chen040df222020-01-17 13:35:02 +0800313 DVR_PlaybackOpenParams_t openParams; /**< playback openParams*/
hualing chen86e7d482020-01-16 15:13:33 +0800314 DVR_Bool_t has_video; /**< has video playing*/
315 DVR_Bool_t has_audio; /**< has audio playing*/
hualing chendf118dd2020-05-21 15:49:11 +0800316 DVR_Bool_t has_ad_audio; /**< has ad audio playing*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800317 DVR_Bool_t has_pids; /**< has video audo pid fmt info*/
hualing chen7ea70a72021-09-09 11:25:13 +0800318 uint32_t fffb_start; /**< fffb start time ms*/
319 uint32_t fffb_current; /**< fffb current time*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800320 int fffb_start_pcr; /**< fffb start pcr time*/
hualing chen7ea70a72021-09-09 11:25:13 +0800321 uint32_t next_fffb_time;/**< fffb start pcr time*/
hualing chena540a7e2020-03-27 16:44:05 +0800322 int seek_time;/**< fffb start pcr time*/
323 event_callback player_callback_func;/**< tsplayer cb*/
324 void *player_callback_userdata;/**< tsplayer cb data*/
hualing chen7ea70a72021-09-09 11:25:13 +0800325 uint32_t send_time;/**< send event time*/
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800326 int first_frame;/**< show first frame*/
327 DVR_CryptoFunction_t dec_func; /**< Decrypt function*/
328 void *dec_userdata; /**< Decrypt userdata*/
Yahui Han1fbf3292021-11-08 18:17:19 +0800329 void *cryptor; /**< Cryptor for encrypted PVR on FTA.*/
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800330 int is_secure_mode; /**< Playback session run in secure pipeline */
331 uint8_t *secure_buffer; /* Playback session secure buffer */
332 uint32_t secure_buffer_size; /* Playback session secure buffer size */
hualing chen266b9502020-04-04 17:39:39 +0800333 DVR_Bool_t drop_ts;
hualing chen4b7c15d2020-04-07 16:13:48 +0800334 DVR_Bool_t fffb_play;
335 int32_t last_cur_time;
336 uint64_t last_send_time_id;
hualing chen5605eed2020-05-26 18:18:06 +0800337 int ts_cache_len;
hualing chene41f4372020-06-06 16:29:17 +0800338 DVR_Bool_t first_trans_ok;
hualing chenfbf8e022020-06-15 13:43:11 +0800339 DVR_PlaybackVendor_t vendor;
hualing chene3797f02021-01-13 14:53:28 +0800340 int noData;
hualing chena5f03222021-12-02 11:22:35 +0800341 DVR_Bool_t seek_pause; /**<set true when user call seek at pause state,we will start inject data, if first frame is got,set false and stop inject data*/
Wentao MA270dc0f2022-08-23 13:17:26 +0800342 int last_segment_total; /**< last segment total time*/
hualing chen969fe7b2021-05-26 15:13:17 +0800343
hualing chen03fd4942021-07-15 15:56:41 +0800344 DVR_PlaybackConSpe_t con_spe; /**< inject data speed info*/
345
346 //limit info
347 int obsolete; /**< rec obsolete time in ms*/
hualing chen7ea70a72021-09-09 11:25:13 +0800348 uint32_t rec_start; /**< rec start time in ms*/
349 uint32_t limit; /**< rec data limit time in ms*/
hualing chen8a657f32021-08-30 13:12:49 +0800350 //first play need seek to start time
hualing chen7ea70a72021-09-09 11:25:13 +0800351 uint32_t first_start_time;
Wentao MA01de0e62022-01-10 18:48:23 +0800352 //The segment id where a playback is initially started
353 uint64_t first_start_id;
354 //Determine whether it is needed to check the cache value from AmTsPlayer_getDelayTime
355 //It is only allowed to check cache one time in a single playback
356 DVR_Bool_t check_cache_flag;
hualing chen8a657f32021-08-30 13:12:49 +0800357 DVR_Bool_t need_seek_start;
hualing chena5f03222021-12-02 11:22:35 +0800358 //init fake pid
359 int fake_pid;
Wentao MA5629ad82022-08-24 10:03:02 +0800360 //Audio presentation id, used for dolby AC4 audio
361 int32_t audio_presentation_id;
hualing chen040df222020-01-17 13:35:02 +0800362} DVR_Playback_t;
Gong Ke497c4c22020-03-20 10:15:42 +0800363/**\endcond*/
hualing chenb31a6c62020-01-13 17:27:00 +0800364
365/**\brief Open an dvr palyback
366 * \param[out] p_handle dvr playback addr
367 * \param[in] params dvr playback open parameters
368 * \retval DVR_SUCCESS On success
369 * \return Error code
370 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800371int dvr_playback_open(DVR_PlaybackHandle_t *p_handle, DVR_PlaybackOpenParams_t *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800372
373/**\brief Close an dvr palyback
374 * \param[in] handle playback handle
375 * \retval DVR_SUCCESS On success
376 * \return Error code
377 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800378int dvr_playback_close(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800379
380
Wentao MA270dc0f2022-08-23 13:17:26 +0800381/**\brief Start play audio and video, used start audio api and start video api
hualing chenb31a6c62020-01-13 17:27:00 +0800382 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800383 * \param[in] flag playback flag
hualing chenb31a6c62020-01-13 17:27:00 +0800384 * \retval DVR_SUCCESS On success
385 * \return Error code
386 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800387int dvr_playback_start(DVR_PlaybackHandle_t handle, DVR_PlaybackFlag_t flag);
hualing chenb31a6c62020-01-13 17:27:00 +0800388
hualing chen040df222020-01-17 13:35:02 +0800389/**\brief dvr play back add segment info to segment list
hualing chenb31a6c62020-01-13 17:27:00 +0800390 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800391 * \param[in] info added segment info,con vpid fmt apid fmt.....
hualing chenb31a6c62020-01-13 17:27:00 +0800392 * \retval DVR_SUCCESS On success
393 * \return Error code
394 */
hualing chen040df222020-01-17 13:35:02 +0800395int dvr_playback_add_segment(DVR_PlaybackHandle_t handle, DVR_PlaybackSegmentInfo_t *info);
hualing chenb31a6c62020-01-13 17:27:00 +0800396
hualing chen040df222020-01-17 13:35:02 +0800397/**\brief dvr play back remove segment info by segmentkid
hualing chenb31a6c62020-01-13 17:27:00 +0800398 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800399 * \param[in] segmentid need removed segment id
hualing chenb31a6c62020-01-13 17:27:00 +0800400 * \retval DVR_SUCCESS On success
401 * \return Error code
402 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800403int dvr_playback_remove_segment(DVR_PlaybackHandle_t handle, uint64_t segmentid);
hualing chenb31a6c62020-01-13 17:27:00 +0800404
hualing chen040df222020-01-17 13:35:02 +0800405/**\brief dvr play back add segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800406 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800407 * \param[in] segment_id the segment's index
408 * \param[in] flags the segment's flags
hualing chenb31a6c62020-01-13 17:27:00 +0800409 * \retval DVR_SUCCESS On success
410 * \return Error code
411 */
hualing chen040df222020-01-17 13:35:02 +0800412int dvr_playback_update_segment_flags(DVR_PlaybackHandle_t handle,
hualing chen5cbe1a62020-02-10 16:36:36 +0800413 uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800414 DVR_PlaybackSegmentFlag_t flags);
Gong Ke497c4c22020-03-20 10:15:42 +0800415
hualing chen040df222020-01-17 13:35:02 +0800416/**\brief dvr play back up1date segment pids
417 * if updated segment is ongoing segment, we need start new
hualing chenb31a6c62020-01-13 17:27:00 +0800418 * add pid stream and stop remove pid stream.
419 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800420 * \param[in] segment_id need updated pids segment id
Gong Ke497c4c22020-03-20 10:15:42 +0800421 * \param[in] p_pids the new PIDs
hualing chenb31a6c62020-01-13 17:27:00 +0800422 * \retval DVR_SUCCESS On success
423 * \return Error code
424 */
Gong Ke497c4c22020-03-20 10:15:42 +0800425int dvr_playback_update_segment_pids(DVR_PlaybackHandle_t handle, uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800426DVR_PlaybackPids_t *p_pids);
hualing chenb31a6c62020-01-13 17:27:00 +0800427
hualing chena5f03222021-12-02 11:22:35 +0800428/**\brief dvr play back only up1date segment pids
429 * only update segment info, not stop start codec.
430 * \param[in] handle playback handle
431 * \param[in] segment_id need updated pids segment id
432 * \param[in] p_pids the new PIDs
433 * \retval DVR_SUCCESS On success
434 * \return Error code
435 */
436int dvr_playback_only_update_segment_pids(DVR_PlaybackHandle_t handle, uint64_t segment_id, DVR_PlaybackPids_t *p_pids);
437
Gong Ke497c4c22020-03-20 10:15:42 +0800438/**\brief Stop playing, will stop video and audio
hualing chenb31a6c62020-01-13 17:27:00 +0800439 * \param[in] handle playback handle
440 * \param[in] clear is clear last frame
441 * \retval DVR_SUCCESS On success
442 * \return Error code
443 */
hualing chen040df222020-01-17 13:35:02 +0800444int dvr_playback_stop(DVR_PlaybackHandle_t handle, DVR_Bool_t clear);
hualing chenb31a6c62020-01-13 17:27:00 +0800445
Gong Ke497c4c22020-03-20 10:15:42 +0800446/**\brief Start audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800447 * \param[in] handle playback handle
448 * \param[in] params audio playback params,contains fmt and pid...
Wentao MA270dc0f2022-08-23 13:17:26 +0800449 * \param[in] ad_params ad audio playback params,contains fmt and pid...
hualing chenb31a6c62020-01-13 17:27:00 +0800450 * \retval DVR_SUCCESS On success
451 * \return Error code
452 */
Wentao MA270dc0f2022-08-23 13:17:26 +0800453int dvr_playback_audio_start(DVR_PlaybackHandle_t handle, am_tsplayer_audio_params *param, am_tsplayer_audio_params *ad_param);
hualing chendf118dd2020-05-21 15:49:11 +0800454
hualing chenb31a6c62020-01-13 17:27:00 +0800455
Gong Ke497c4c22020-03-20 10:15:42 +0800456/**\brief Stop audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800457 * \param[in] handle playback handle
458 * \retval DVR_SUCCESS On success
459 * \return Error code
460 */
hualing chen040df222020-01-17 13:35:02 +0800461int dvr_playback_audio_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800462
Gong Ke497c4c22020-03-20 10:15:42 +0800463/**\brief Start video playing
hualing chenb31a6c62020-01-13 17:27:00 +0800464 * \param[in] handle playback handle
465 * \param[in] params video playback params,contains fmt and pid...
466 * \retval DVR_SUCCESS On success
467 * \return Error code
468 */
Gong Ke497c4c22020-03-20 10:15:42 +0800469int dvr_playback_video_start(DVR_PlaybackHandle_t handle, am_tsplayer_video_params *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800470
471/**\brief Stop play video
472 * \param[in] handle playback handle
473 * \retval DVR_SUCCESS On success
474 * \return Error code
475 */
hualing chen040df222020-01-17 13:35:02 +0800476int dvr_playback_video_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800477
478/**\brief Pause play
479 * \param[in] handle playback handle
480 * \param[in] flush whether its internal buffers should be flushed
481 * \retval DVR_SUCCESS On success
482 * \return Error code
483 */
hualing chen040df222020-01-17 13:35:02 +0800484int dvr_playback_pause(DVR_PlaybackHandle_t handle, DVR_Bool_t flush);
hualing chenb31a6c62020-01-13 17:27:00 +0800485
hualing chen31140872020-03-25 12:29:26 +0800486/**\brief resume play
487 * \param[in] handle playback handle
488 * \retval DVR_SUCCESS On success
489 * \return Error code
490 */
491int dvr_playback_resume(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800492
hualing chen03fd4942021-07-15 15:56:41 +0800493/**\brief set limit
494 * \param[in] handle playback handle
495 * \param[in] rec start time ms
496 * \param[in] rec limit time ms
497 * \retval DVR_SUCCESS On success
498 * \return Error code
499 */
hualing chen7ea70a72021-09-09 11:25:13 +0800500int dvr_playback_setlimit(DVR_PlaybackHandle_t handle, uint32_t time, uint32_t limit);
hualing chen03fd4942021-07-15 15:56:41 +0800501
Gong Ke497c4c22020-03-20 10:15:42 +0800502/**\brief Seek the playing position
hualing chenb31a6c62020-01-13 17:27:00 +0800503 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800504 * \param[in] segment_id the segment's index
hualing chen040df222020-01-17 13:35:02 +0800505 * \param[in] time_offset time offset base cur segment
hualing chenb31a6c62020-01-13 17:27:00 +0800506 * \retval DVR_SUCCESS On success
507 * \return Error code
508 */
hualing chencc91e1c2020-02-28 13:26:17 +0800509int dvr_playback_seek(DVR_PlaybackHandle_t handle, uint64_t segment_id, uint32_t time_offset);
hualing chenb31a6c62020-01-13 17:27:00 +0800510
511/**\brief Set play speed
512 * \param[in] handle playback handle
513 * \param[in] speed playback speed
514 * \retval DVR_SUCCESS On success
515 * \return Error code
516 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800517int dvr_playback_set_speed(DVR_PlaybackHandle_t handle, DVR_PlaybackSpeed_t speed);
hualing chenb31a6c62020-01-13 17:27:00 +0800518
519/**\brief Get playback status
520 * \param[in] handle playback handle
521 * \param[out] p_status playback status
522 * \retval DVR_SUCCESS On success
523 * \return Error code
524 */
hualing chen040df222020-01-17 13:35:02 +0800525int dvr_playback_get_status(DVR_PlaybackHandle_t handle, DVR_PlaybackStatus_t *p_status);
hualing chenb31a6c62020-01-13 17:27:00 +0800526
527/**\brief Get playback capabilities
528 * \param[out] p_capability playback capability
529 * \retval DVR_SUCCESS On success
530 * \return Error code
531 */
hualing chen040df222020-01-17 13:35:02 +0800532int dvr_playback_get_capabilities(DVR_PlaybackCapability_t *p_capability);
hualing chenb31a6c62020-01-13 17:27:00 +0800533
hualing chen040df222020-01-17 13:35:02 +0800534/**\brief dump segmentinfo throw print log
Gong Ke497c4c22020-03-20 10:15:42 +0800535 * \param[in] handle playback
536 * \param[in] segment_id if segment_id > 0, only dump this log. else dump all segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800537 * \retval DVR_SUCCESS On success
538 * \return Error code
539 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800540int dvr_dump_segmentinfo(DVR_PlaybackHandle_t handle, uint64_t segment_id);
hualing chenb31a6c62020-01-13 17:27:00 +0800541
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800542/**\brief Set DVR playback decrypt function
543 * \param[in] handle, DVR playback session handle
544 * \param[in] func, DVR playback encrypt function
545 * \param[in] userdata, DVR playback userdata from the caller
546 * \return DVR_SUCCESS on success
547 * \return error code on failure
548 */
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800549int dvr_playback_set_decrypt_callback(DVR_PlaybackHandle_t handle, DVR_CryptoFunction_t func, void *userdata);
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800550
551/**\brief Set DVR playback secure buffer used for protect the secure content
552 * \param[in] handle, DVR playback session handle
553 * \param[in] p_secure_buf, Secure buffer address which can NOT access by ACPU
554 * \param[in] len, Secure buffer length
555 * \return DVR_SUCCESS on success
556 * \return error code on failure
557 */
558int dvr_playback_set_secure_buffer(DVR_PlaybackHandle_t handle, uint8_t *p_secure_buf, uint32_t len);
559
hualing chen03fd4942021-07-15 15:56:41 +0800560/**\brief set DVR playback calculate expired time len
561 * \param[in] handle, DVR playback session handle
562 * \return DVR_SUCCESS on success
563 * \return error code on failure
564 */
hualing chen7ea70a72021-09-09 11:25:13 +0800565uint32_t dvr_playback_calculate_expiredlen(DVR_PlaybackHandle_t handle);
hualing chen03fd4942021-07-15 15:56:41 +0800566
567/**\brief set DVR playback obsolete time
568 * \param[in] handle, DVR playback session handle
569 * \param[in] obsolete, obsolete len
570 * \return DVR_SUCCESS on success
571 * \return error code on failure
572 */
573int dvr_playback_set_obsolete(DVR_PlaybackHandle_t handle, int obsolete);
574
575/**\brief update DVR playback newest segment duration
576 * \param[in] handle, DVR playback session handle
577 * \param[in] segmentid, newest segment id
578 * \param[in] dur dur time ms
579 * \return DVR_SUCCESS on success
580 * \return error code on failure
581 */
582int dvr_playback_update_duration(DVR_PlaybackHandle_t handle,
583uint64_t segmentid, int dur);
584
585/**\brief check DVR playback is set limit info
586 * \param[in] handle, DVR playback session handle
587 * \return DVR_FALSE or DVR_TRUE
588 */
589DVR_Bool_t dvr_playback_check_limit(DVR_PlaybackHandle_t handle);
590
Wentao MA5629ad82022-08-24 10:03:02 +0800591/**\brief set ac4 audio preselection id for playback
592 * \param[in] handle, DVR playback session handle
593 * \param[in] presel_id, ac4 preselection id
594 * \return DVR_SUCCESS on success
595 * \return error code on failure
596 */
597int dvr_playback_set_ac4_preselection_id(DVR_PlaybackHandle_t handle, int presel_id);
598
hualing chenb31a6c62020-01-13 17:27:00 +0800599#ifdef __cplusplus
600}
601#endif
602
603#endif /*END DVR_PLAYBACK_H_*/