blob: b8f5cdec8ce062bd076aedd8105a6c05e860f0ef [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"
14
hualing chenb31a6c62020-01-13 17:27:00 +080015#ifdef __cplusplus
16extern "C" {
17#endif
Gong Ke3489c0f2020-01-16 18:11:44 +080018
hualing chen040df222020-01-17 13:35:02 +080019/**\brief dvr play segment flag */
hualing chenb31a6c62020-01-13 17:27:00 +080020typedef enum
21{
Gong Ke3489c0f2020-01-16 18:11:44 +080022 DVR_PLAYBACK_SEGMENT_ENCRYPTED = (1 << 0), /**< encrypted stream */
23 DVR_PLAYBACK_SEGMENT_DISPLAYABLE = (1 << 1), /**< displayable stream */
Gong Ke497c4c22020-03-20 10:15:42 +080024 DVR_PLAYBACK_SEGMENT_CONTINUOUS = (1 << 2) /**< continuous stream with pre one */
Gong Ke3489c0f2020-01-16 18:11:44 +080025} DVR_PlaybackSegmentFlag_t;
hualing chenb31a6c62020-01-13 17:27:00 +080026
27/**\brief dvr pid type*/
28typedef enum
29{
Gong Ke3489c0f2020-01-16 18:11:44 +080030 DVR_PLAYBACK_SYNC, /**< sync play mode */
31 DVR_PLAYBACK_ASYNC /**< out of sync play mode */
32} DVR_PlaybackSyncMode_t;
hualing chenb31a6c62020-01-13 17:27:00 +080033
34
35/**\brief dvr play pids */
36typedef struct
37{
Gong Ke3489c0f2020-01-16 18:11:44 +080038 DVR_StreamInfo_t video; /**< Video.*/
39 DVR_StreamInfo_t audio; /**< Audio.*/
40 DVR_StreamInfo_t ad; /**< AD.*/
41 DVR_StreamInfo_t subtitle; /**< Subtitle.*/
42 DVR_StreamInfo_t pcr; /**< PCR.*/
43} DVR_PlaybackPids_t;
hualing chenb31a6c62020-01-13 17:27:00 +080044
hualing chen1679f812021-11-08 15:17:46 +080045/**\brief dvr play pids */
46typedef struct
47{
48 DVR_PlaybackPids_t pids; /**< Video.*/
49 int av_scale;
50} DVR_Playback_info_t;
51
Gong Ke3489c0f2020-01-16 18:11:44 +080052/**\brief dvr segments info */
hualing chenb31a6c62020-01-13 17:27:00 +080053typedef struct
54{
Gong Ke3489c0f2020-01-16 18:11:44 +080055 struct list_head head; /**< Segment node.*/
hualing chen5cbe1a62020-02-10 16:36:36 +080056 uint64_t segment_id; /**< Segment's index.*/
57 char location[DVR_MAX_LOCATION_SIZE]; /**< chunk location */
Gong Ke3489c0f2020-01-16 18:11:44 +080058 DVR_PlaybackPids_t pids; /**< Streams' PIDs.*/
hualing chen040df222020-01-17 13:35:02 +080059 DVR_PlaybackSegmentFlag_t flags; /**< Segment's flag */
Gong Ke3489c0f2020-01-16 18:11:44 +080060 int key_data_id; /**< ??? */
hualing chen03fd4942021-07-15 15:56:41 +080061 int duration; /**< Segment dur time ms*/
Gong Ke3489c0f2020-01-16 18:11:44 +080062} DVR_PlaybackSegmentInfo_t;
hualing chenb31a6c62020-01-13 17:27:00 +080063
64/**\brief play flag, if set this flag, player need pause when decode first frame */
65typedef enum
66{
Gong Ke3489c0f2020-01-16 18:11:44 +080067 DVR_PLAYBACK_STARTED_PAUSEDLIVE = (1 << 0) /**< dvr play stat,need change to pause state if set */
68} DVR_PlaybackFlag_t;
hualing chen86e7d482020-01-16 15:13:33 +080069
70/**\brief playback speed mode*/
hualing chenb31a6c62020-01-13 17:27:00 +080071typedef enum
72{
Gong Ke3489c0f2020-01-16 18:11:44 +080073 DVR_PLAYBACK_FAST_FORWARD = 0, /**< fast forward */
74 DVR_PLAYBACK_FAST_BACKWARD = 1, /**< fast backward */
hualing chen31140872020-03-25 12:29:26 +080075 DVR_PLAYBACK_KERNEL_SUPPORT = 2, /**< kernel support mode */
Gong Ke3489c0f2020-01-16 18:11:44 +080076} DVR_PlaybackSpeedMode_t;
hualing chenb31a6c62020-01-13 17:27:00 +080077
hualing chen2aba4022020-03-02 13:49:55 +080078/**\brief playback speed*/
79typedef enum
80{
hualing chene41f4372020-06-06 16:29:17 +080081 PLAYBACK_SPEED_FBX1 = -100, /**<FB X 1 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080082 PLAYBACK_SPEED_FBX2 = -200, /**<FB X 2 speed*/
83 PLAYBACK_SPEED_FBX4 = -400, /**<FB X 4 speed*/
84 PLAYBACK_SPEED_FBX8 = -800, /**<FB X 8 speed*/
hualing chen041c4092020-04-05 15:11:50 +080085 PLAYBACK_SPEED_FBX12 = -1200, /**< FB 12 speed*/
86 PLAYBACK_SPEED_FBX16 = -1600, /**<FB X 16 speed*/
87 PLAYBACK_SPEED_FBX32 = -3200, /**<FB X 32 speed*/
88 PLAYBACK_SPEED_FBX48 = -4800, /**<FB X 48 speed*/
89 PLAYBACK_SPEED_FBX64 = -6400, /**<FB X 64 speed*/
90 PLAYBACK_SPEED_FBX128 = -12800, /**<FB X 128 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080091 PLAYBACK_SPEED_S8 = 12, /**<slow 1/8 speed*/
92 PLAYBACK_SPEED_S4 = 25, /**<slow 1/4 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080093 PLAYBACK_SPEED_S2 = 50, /**<slow 1/2 speed*/
94 PLAYBACK_SPEED_X1 = 100, /**< X 1 normal speed*/
95 PLAYBACK_SPEED_X2 = 200, /**< X 2 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080096 PLAYBACK_SPEED_X3 = 300, /**< X 3 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080097 PLAYBACK_SPEED_X4 = 400, /**< X 4 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080098 PLAYBACK_SPEED_X5 = 500, /**< X 5 speed*/
99 PLAYBACK_SPEED_X6 = 600, /**< X 6 speed*/
100 PLAYBACK_SPEED_X7 = 700, /**< X 7 speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800101 PLAYBACK_SPEED_X8 = 800, /**< X 8 speed*/
hualing chen041c4092020-04-05 15:11:50 +0800102 PLAYBACK_SPEED_X12 = 1200, /**< X 12 speed*/
103 PLAYBACK_SPEED_X16 = 1600, /**< X 16 speed*/
104 PLAYBACK_SPEED_X32 = 3200, /**< X 32 speed*/
105 PLAYBACK_SPEED_X48 = 4800, /**< X 48 speed*/
106 PLAYBACK_SPEED_X64 = 6400, /**< X 64 speed*/
107 PLAYBACK_SPEED_X128 = 12800, /**< X 128 speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800108 PlayBack_Speed_MAX,
109} Playback_SpeedValue_t;
110
Gong Ke497c4c22020-03-20 10:15:42 +0800111/**\brief playback speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800112typedef struct Playback_Speeds_s {
Gong Ke497c4c22020-03-20 10:15:42 +0800113 int speed; /**< playback speed value*/
hualing chen2aba4022020-03-02 13:49:55 +0800114} Playback_Speeds_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800115
Gong Ke3489c0f2020-01-16 18:11:44 +0800116/**\brief playback play speed*/
hualing chenb31a6c62020-01-13 17:27:00 +0800117typedef struct
118{
hualing chen2aba4022020-03-02 13:49:55 +0800119 Playback_Speeds_t speed; /**< playback speed */
Gong Ke3489c0f2020-01-16 18:11:44 +0800120 DVR_PlaybackSpeedMode_t mode; /**< playback 0: fast forword or 1: fast backword*/
121} DVR_PlaybackSpeed_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800122
hualing chen2aba4022020-03-02 13:49:55 +0800123
Gong Ke3489c0f2020-01-16 18:11:44 +0800124/**Maximum supported speed modes.*/
hualing chenb31a6c62020-01-13 17:27:00 +0800125#define DVR_MAX_SUPPORTED_SPEEDS 32
Gong Ke3489c0f2020-01-16 18:11:44 +0800126
hualing chenb31a6c62020-01-13 17:27:00 +0800127/**\brief playback capability*/
128typedef struct
129{
hualing chen86e7d482020-01-16 15:13:33 +0800130 int nb_supported_speeds; /**< support playback speed count*/
131 int supported_speeds[DVR_MAX_SUPPORTED_SPEEDS]; /**< support playback speed*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800132} DVR_PlaybackCapability_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800133
Gong Ke3489c0f2020-01-16 18:11:44 +0800134/**Playback handle.*/
135typedef void* DVR_PlaybackHandle_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800136
hualing chencc91e1c2020-02-28 13:26:17 +0800137
138/**\brief playback error reason*/
139typedef enum
140{
141 DVR_PLAYBACK_PID_ERROR, /**< uninit state */
142 DVR_PLAYBACK_FMT_ERROR /**< fmt not surport backword */
143} DVR_PlaybackError_t;
144
145
hualing chenb31a6c62020-01-13 17:27:00 +0800146/**\brief playback play state*/
147typedef enum
148{
Gong Ke3489c0f2020-01-16 18:11:44 +0800149 DVR_PLAYBACK_STATE_START, /**< start play */
150 DVR_PLAYBACK_STATE_STOP, /**< stop */
151 DVR_PLAYBACK_STATE_PAUSE, /**< pause */
152 DVR_PLAYBACK_STATE_FF, /**< fast forward */
153 DVR_PLAYBACK_STATE_FB /**< fast backword */
154} DVR_PlaybackPlayState_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800155
156/**\brief playback play status*/
157typedef struct
158{
Gong Ke3489c0f2020-01-16 18:11:44 +0800159 DVR_PlaybackPlayState_t state; /**< playback play state */
hualing chen5cbe1a62020-02-10 16:36:36 +0800160 uint64_t segment_id; /**< playback ongoing segment index */
hualing chencc91e1c2020-02-28 13:26:17 +0800161 uint32_t time_cur; /**< playback cur time,0 <--> time_end Ms*/
162 uint32_t time_end; /**< playback ongoing segment dur,Ms */
Gong Ke3489c0f2020-01-16 18:11:44 +0800163 DVR_PlaybackPids_t pids; /**< playback played pids */
hualing chen5cbe1a62020-02-10 16:36:36 +0800164 int speed; /**< playback speed */
165 DVR_PlaybackSegmentFlag_t flags; /**< playback played segment flag */
Gong Ke3489c0f2020-01-16 18:11:44 +0800166} DVR_PlaybackStatus_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800167
hualing chenfbf8e022020-06-15 13:43:11 +0800168/**\brief DVR playback vendor*/
169typedef enum {
170 DVR_PLAYBACK_VENDOR_DEF , /**< default*/
hualing chen90b3ae62021-03-30 10:49:28 +0800171 DVR_PLAYBACK_VENDOR_AML, /**< aml*/
172 DVR_PLAYBACK_VENDOR_AMAZON /**< amazon*/
hualing chenfbf8e022020-06-15 13:43:11 +0800173} DVR_PlaybackVendor_t;
174
175
hualing chencc91e1c2020-02-28 13:26:17 +0800176/**\brief DVR playback event*/
177typedef enum {
178 DVR_PLAYBACK_EVENT_ERROR = 0x1000, /**< Signal a critical playback error*/
179 DVR_PLAYBACK_EVENT_TRANSITION_OK , /**< transition ok*/
180 DVR_PLAYBACK_EVENT_TRANSITION_FAILED, /**< transition failed*/
181 DVR_PLAYBACK_EVENT_KEY_FAILURE, /**< key failure*/
182 DVR_PLAYBACK_EVENT_NO_KEY, /**< no key*/
183 DVR_PLAYBACK_EVENT_REACHED_BEGIN , /**< reached begin*/
hualing chen2aba4022020-03-02 13:49:55 +0800184 DVR_PLAYBACK_EVENT_REACHED_END, /**< reached end*/
hualing chen6e4bfa52020-03-13 14:37:11 +0800185 DVR_PLAYBACK_EVENT_NOTIFY_PLAYTIME, /**< notify play cur segmeng time ms*/
hualing chene3797f02021-01-13 14:53:28 +0800186 DVR_PLAYBACK_EVENT_FIRST_FRAME, /**< first frame*/
187 DVR_PLAYBACK_EVENT_NODATA, /**< no data*/
188 DVR_PLAYBACK_EVENT_DATARESUME /**< data resume*/
hualing chencc91e1c2020-02-28 13:26:17 +0800189} DVR_PlaybackEvent_t;
190
191/**\brief DVR playback event notify function*/
192typedef struct
193{
Gong Ke497c4c22020-03-20 10:15:42 +0800194 DVR_PlaybackEvent_t event; /**< event type*/
195 DVR_PlaybackStatus_t play_status; /**< play status*/
hualing chencc91e1c2020-02-28 13:26:17 +0800196 union
197 {
Gong Ke497c4c22020-03-20 10:15:42 +0800198 uint8_t unused;
199 uint8_t error_reason;/**< error reason*/
hualing chencc91e1c2020-02-28 13:26:17 +0800200 struct
201 {
Gong Ke497c4c22020-03-20 10:15:42 +0800202 uint64_t segment_id; /**< error segment id*/
203 uint32_t key_data_id; /**< key data id*/
204 uint8_t error; /**< error*/
hualing chencc91e1c2020-02-28 13:26:17 +0800205 } transition_failed_data;
Gong Ke497c4c22020-03-20 10:15:42 +0800206 } info; /**< information*/
hualing chencc91e1c2020-02-28 13:26:17 +0800207} DVR_Play_Notify_t;
208
209/**\brief DVR playback event notify function*/
210typedef DVR_Result_t (*DVR_PlaybackEventFunction_t) (DVR_PlaybackEvent_t event, void *params, void *userdata);
211
212
hualing chenb31a6c62020-01-13 17:27:00 +0800213/**\brief playback open params*/
214typedef struct
215{
Gong Ke3489c0f2020-01-16 18:11:44 +0800216 int dmx_dev_id; /**< playback used dmx device index*/
217 int block_size; /**< playback inject block size*/
218 DVR_Bool_t is_timeshift; /**< 0:playback mode, 1 : is timeshift mode*/
hualing chen2aba4022020-03-02 13:49:55 +0800219 am_tsplayer_handle player_handle; /**< am tsplayer handle.*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800220 DVR_CryptoFunction_t crypto_fn; /**< Crypto function.*/
Yahui Han1fbf3292021-11-08 18:17:19 +0800221 void *crypto_data; /**< Crypto function's user data.*/
222 uint8_t *clearkey; /**< key for encrypted PVR on FTA.*/
223 uint8_t *cleariv; /**< iv for encrpted PVR on FTA.*/
224 uint32_t keylen; /**< key/iv length.*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800225 DVR_Bool_t has_pids; /**< has video audo pid fmt info*/
hualing chencc91e1c2020-02-28 13:26:17 +0800226 DVR_PlaybackEventFunction_t event_fn; /**< playback event callback function*/
227 void *event_userdata; /**< event userdata*/
hualing chenfbf8e022020-06-15 13:43:11 +0800228 DVR_PlaybackVendor_t vendor; /**< vendor type,default is 0*/
hualing chene3797f02021-01-13 14:53:28 +0800229 DVR_Bool_t is_notify_time; /**< notify play time info true or not*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800230} DVR_PlaybackOpenParams_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800231
232/**\brief playback play state*/
233typedef enum
234{
hualing chen040df222020-01-17 13:35:02 +0800235 DVR_PLAYBACK_CMD_START, /**< start av */
236 DVR_PLAYBACK_CMD_STOP, /**< stop av */
237 DVR_PLAYBACK_CMD_VSTART, /**< v start */
238 DVR_PLAYBACK_CMD_ASTART , /**< a start */
239 DVR_PLAYBACK_CMD_VSTOP , /**< v stop */
240 DVR_PLAYBACK_CMD_ASTOP, /**< a stop */
241 DVR_PLAYBACK_CMD_VRESTART, /**< v restart */
242 DVR_PLAYBACK_CMD_ARESTART, /**< a restart */
hualing chen5cbe1a62020-02-10 16:36:36 +0800243 DVR_PLAYBACK_CMD_AVRESTART, /**< av restart */
hualing chen040df222020-01-17 13:35:02 +0800244 DVR_PLAYBACK_CMD_VSTOPASTART, /**< v stop a start*/
245 DVR_PLAYBACK_CMD_ASTOPVSTART, /**< a stop vstart */
246 DVR_PLAYBACK_CMD_VSTOPARESTART, /**<v stop a restart*/
247 DVR_PLAYBACK_CMD_ASTOPVRESTART, /**<a stop v restart*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800248 DVR_PLAYBACK_CMD_VSTARTARESTART, /**<v start a restart*/
249 DVR_PLAYBACK_CMD_ASTARTVRESTART, /**<a start v restart*/
hualing chen040df222020-01-17 13:35:02 +0800250 DVR_PLAYBACK_CMD_PAUSE, /**< pause */
251 DVR_PLAYBACK_CMD_RESUME, /**< resume */
252 DVR_PLAYBACK_CMD_SEEK, /**< seek */
253 DVR_PLAYBACK_CMD_FF, /**< fast forward */
254 DVR_PLAYBACK_CMD_FB, /**< fast backword */
hualing chen5cbe1a62020-02-10 16:36:36 +0800255 DVR_PLAYBACK_CMD_NONE, /**< none */
hualing chen040df222020-01-17 13:35:02 +0800256} DVR_PlaybackCmd_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800257
258
259/**\brief playback struct*/
260typedef struct
261{
hualing chen5cbe1a62020-02-10 16:36:36 +0800262 DVR_PlaybackSpeed_t speed; /**< play speed */
263 DVR_PlaybackPlayState_t state; /**< play state */
hualing chen040df222020-01-17 13:35:02 +0800264 DVR_PlaybackCmd_t cur_cmd; /**< cur send cmd */
265 DVR_PlaybackCmd_t last_cmd; /**< last cmd */
266 int pos; /**< seek pos at cur segment*/
267} DVR_PlaybackCmdInfo_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800268
hualing chend241c7a2021-06-22 13:34:27 +0800269/**\brief playback struct*/
270typedef struct
271{
hualing chen7ea70a72021-09-09 11:25:13 +0800272 uint32_t sys_dur; /**< system duration */
273 uint32_t sys_sta; /**< system start time */
274 uint32_t ply_dur; /**< play duration */
275 uint32_t ply_sta; /**< play start time */
hualing chend241c7a2021-06-22 13:34:27 +0800276} DVR_PlaybackConSpe_t;
277
278
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800279/**\brief DVR playback decrypt function*/
280typedef DVR_Result_t (*DVR_PlaybackDecryptFunction_t) (uint8_t *p_in,
281 uint32_t in_len,
282 uint8_t *p_out,
283 uint32_t *p_out_len,
284 void *userdata);
hualing chenb31a6c62020-01-13 17:27:00 +0800285
Gong Ke497c4c22020-03-20 10:15:42 +0800286/**\cond */
hualing chenb31a6c62020-01-13 17:27:00 +0800287/**\brief playback struct*/
288typedef struct
289{
hualing chen2aba4022020-03-02 13:49:55 +0800290 am_tsplayer_handle handle; /**< tsplayer handle */
hualing chencc91e1c2020-02-28 13:26:17 +0800291 DVR_Bool_t segment_is_open; /**<segment is opend*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800292 uint64_t cur_segment_id; /**< Current segment id*/
hualing chen040df222020-01-17 13:35:02 +0800293 DVR_PlaybackSegmentInfo_t cur_segment; /**< Current playing segment*/
hualing chencc91e1c2020-02-28 13:26:17 +0800294 uint64_t last_segment_id; /**< last segment id*/
295 DVR_PlaybackSegmentInfo_t last_segment; /**< last playing segment*/
hualing chen040df222020-01-17 13:35:02 +0800296 struct list_head segment_list; /**< segment list head*/
297 pthread_t playback_thread; /**< playback thread*/
298 pthread_mutex_t lock; /**< playback lock*/
hualing chen2aba4022020-03-02 13:49:55 +0800299 pthread_mutex_t segment_lock; /**< playback segment lock*/
hualing chen040df222020-01-17 13:35:02 +0800300 pthread_cond_t cond; /**< playback cond*/
301 void *user_data; /**< playback userdata, used to send event*/
hualing chen6d24aa92020-03-23 18:43:47 +0800302 float speed; /**< playback speed*/
hualing chen040df222020-01-17 13:35:02 +0800303 DVR_PlaybackPlayState_t state; /**< playback state*/
304 DVR_PlaybackFlag_t play_flag; /**< playback play flag*/
hualing chen86e7d482020-01-16 15:13:33 +0800305 int is_running; /**< playback htread is runing*/
hualing chen040df222020-01-17 13:35:02 +0800306 DVR_PlaybackCmdInfo_t cmd; /**< playback cmd*/
307 int offset; /**< segment read offset*/
hualing chencc91e1c2020-02-28 13:26:17 +0800308 uint32_t dur; /**< segment dur*/
hualing chen86e7d482020-01-16 15:13:33 +0800309 Segment_Handle_t r_handle; /**< playback current segment handle*/
hualing chen040df222020-01-17 13:35:02 +0800310 DVR_PlaybackOpenParams_t openParams; /**< playback openParams*/
hualing chen86e7d482020-01-16 15:13:33 +0800311 DVR_Bool_t has_video; /**< has video playing*/
312 DVR_Bool_t has_audio; /**< has audio playing*/
hualing chendf118dd2020-05-21 15:49:11 +0800313 DVR_Bool_t has_ad_audio; /**< has ad audio playing*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800314 DVR_Bool_t has_pids; /**< has video audo pid fmt info*/
hualing chen7ea70a72021-09-09 11:25:13 +0800315 uint32_t fffb_start; /**< fffb start time ms*/
316 uint32_t fffb_current; /**< fffb current time*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800317 int fffb_start_pcr; /**< fffb start pcr time*/
hualing chen7ea70a72021-09-09 11:25:13 +0800318 uint32_t next_fffb_time;/**< fffb start pcr time*/
hualing chena540a7e2020-03-27 16:44:05 +0800319 int seek_time;/**< fffb start pcr time*/
320 event_callback player_callback_func;/**< tsplayer cb*/
321 void *player_callback_userdata;/**< tsplayer cb data*/
hualing chen7ea70a72021-09-09 11:25:13 +0800322 uint32_t send_time;/**< send event time*/
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800323 int first_frame;/**< show first frame*/
324 DVR_CryptoFunction_t dec_func; /**< Decrypt function*/
325 void *dec_userdata; /**< Decrypt userdata*/
Yahui Han1fbf3292021-11-08 18:17:19 +0800326 void *cryptor; /**< Cryptor for encrypted PVR on FTA.*/
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800327 int is_secure_mode; /**< Playback session run in secure pipeline */
328 uint8_t *secure_buffer; /* Playback session secure buffer */
329 uint32_t secure_buffer_size; /* Playback session secure buffer size */
hualing chen266b9502020-04-04 17:39:39 +0800330 DVR_Bool_t drop_ts;
hualing chen4b7c15d2020-04-07 16:13:48 +0800331 DVR_Bool_t fffb_play;
332 int32_t last_cur_time;
333 uint64_t last_send_time_id;
hualing chen5605eed2020-05-26 18:18:06 +0800334 int ts_cache_len;
hualing chene41f4372020-06-06 16:29:17 +0800335 DVR_Bool_t first_trans_ok;
hualing chenfbf8e022020-06-15 13:43:11 +0800336 DVR_PlaybackVendor_t vendor;
hualing chene3797f02021-01-13 14:53:28 +0800337 int noData;
hualing chena5f03222021-12-02 11:22:35 +0800338 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*/
hualing chen969fe7b2021-05-26 15:13:17 +0800339 int last_segment_tatol; /**< last segment tatol time*/
340
hualing chen03fd4942021-07-15 15:56:41 +0800341 DVR_PlaybackConSpe_t con_spe; /**< inject data speed info*/
342
343 //limit info
344 int obsolete; /**< rec obsolete time in ms*/
hualing chen7ea70a72021-09-09 11:25:13 +0800345 uint32_t rec_start; /**< rec start time in ms*/
346 uint32_t limit; /**< rec data limit time in ms*/
hualing chen8a657f32021-08-30 13:12:49 +0800347 //first play need seek to start time
hualing chen7ea70a72021-09-09 11:25:13 +0800348 uint32_t first_start_time;
Wentao MA01de0e62022-01-10 18:48:23 +0800349 //The segment id where a playback is initially started
350 uint64_t first_start_id;
351 //Determine whether it is needed to check the cache value from AmTsPlayer_getDelayTime
352 //It is only allowed to check cache one time in a single playback
353 DVR_Bool_t check_cache_flag;
hualing chen8a657f32021-08-30 13:12:49 +0800354 DVR_Bool_t need_seek_start;
hualing chena5f03222021-12-02 11:22:35 +0800355 //init fake pid
356 int fake_pid;
hualing chen040df222020-01-17 13:35:02 +0800357} DVR_Playback_t;
Gong Ke497c4c22020-03-20 10:15:42 +0800358/**\endcond*/
hualing chenb31a6c62020-01-13 17:27:00 +0800359
360/**\brief Open an dvr palyback
361 * \param[out] p_handle dvr playback addr
362 * \param[in] params dvr playback open parameters
363 * \retval DVR_SUCCESS On success
364 * \return Error code
365 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800366int dvr_playback_open(DVR_PlaybackHandle_t *p_handle, DVR_PlaybackOpenParams_t *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800367
368/**\brief Close an dvr palyback
369 * \param[in] handle playback handle
370 * \retval DVR_SUCCESS On success
371 * \return Error code
372 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800373int dvr_playback_close(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800374
375
376/**\brief Start play audio and video, used start auido api and start video api
377 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800378 * \param[in] flag playback flag
hualing chenb31a6c62020-01-13 17:27:00 +0800379 * \retval DVR_SUCCESS On success
380 * \return Error code
381 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800382int dvr_playback_start(DVR_PlaybackHandle_t handle, DVR_PlaybackFlag_t flag);
hualing chenb31a6c62020-01-13 17:27:00 +0800383
hualing chen040df222020-01-17 13:35:02 +0800384/**\brief dvr play back add segment info to segment list
hualing chenb31a6c62020-01-13 17:27:00 +0800385 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800386 * \param[in] info added segment info,con vpid fmt apid fmt.....
hualing chenb31a6c62020-01-13 17:27:00 +0800387 * \retval DVR_SUCCESS On success
388 * \return Error code
389 */
hualing chen040df222020-01-17 13:35:02 +0800390int dvr_playback_add_segment(DVR_PlaybackHandle_t handle, DVR_PlaybackSegmentInfo_t *info);
hualing chenb31a6c62020-01-13 17:27:00 +0800391
hualing chen040df222020-01-17 13:35:02 +0800392/**\brief dvr play back remove segment info by segmentkid
hualing chenb31a6c62020-01-13 17:27:00 +0800393 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800394 * \param[in] segmentid need removed segment id
hualing chenb31a6c62020-01-13 17:27:00 +0800395 * \retval DVR_SUCCESS On success
396 * \return Error code
397 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800398int dvr_playback_remove_segment(DVR_PlaybackHandle_t handle, uint64_t segmentid);
hualing chenb31a6c62020-01-13 17:27:00 +0800399
hualing chen040df222020-01-17 13:35:02 +0800400/**\brief dvr play back add segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800401 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800402 * \param[in] segment_id the segment's index
403 * \param[in] flags the segment's flags
hualing chenb31a6c62020-01-13 17:27:00 +0800404 * \retval DVR_SUCCESS On success
405 * \return Error code
406 */
hualing chen040df222020-01-17 13:35:02 +0800407int dvr_playback_update_segment_flags(DVR_PlaybackHandle_t handle,
hualing chen5cbe1a62020-02-10 16:36:36 +0800408 uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800409 DVR_PlaybackSegmentFlag_t flags);
Gong Ke497c4c22020-03-20 10:15:42 +0800410
hualing chen040df222020-01-17 13:35:02 +0800411/**\brief dvr play back up1date segment pids
412 * if updated segment is ongoing segment, we need start new
hualing chenb31a6c62020-01-13 17:27:00 +0800413 * add pid stream and stop remove pid stream.
414 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800415 * \param[in] segment_id need updated pids segment id
Gong Ke497c4c22020-03-20 10:15:42 +0800416 * \param[in] p_pids the new PIDs
hualing chenb31a6c62020-01-13 17:27:00 +0800417 * \retval DVR_SUCCESS On success
418 * \return Error code
419 */
Gong Ke497c4c22020-03-20 10:15:42 +0800420int dvr_playback_update_segment_pids(DVR_PlaybackHandle_t handle, uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800421DVR_PlaybackPids_t *p_pids);
hualing chenb31a6c62020-01-13 17:27:00 +0800422
hualing chena5f03222021-12-02 11:22:35 +0800423/**\brief dvr play back only up1date segment pids
424 * only update segment info, not stop start codec.
425 * \param[in] handle playback handle
426 * \param[in] segment_id need updated pids segment id
427 * \param[in] p_pids the new PIDs
428 * \retval DVR_SUCCESS On success
429 * \return Error code
430 */
431int dvr_playback_only_update_segment_pids(DVR_PlaybackHandle_t handle, uint64_t segment_id, DVR_PlaybackPids_t *p_pids);
432
Gong Ke497c4c22020-03-20 10:15:42 +0800433/**\brief Stop playing, will stop video and audio
hualing chenb31a6c62020-01-13 17:27:00 +0800434 * \param[in] handle playback handle
435 * \param[in] clear is clear last frame
436 * \retval DVR_SUCCESS On success
437 * \return Error code
438 */
hualing chen040df222020-01-17 13:35:02 +0800439int dvr_playback_stop(DVR_PlaybackHandle_t handle, DVR_Bool_t clear);
hualing chenb31a6c62020-01-13 17:27:00 +0800440
Gong Ke497c4c22020-03-20 10:15:42 +0800441/**\brief Start audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800442 * \param[in] handle playback handle
443 * \param[in] params audio playback params,contains fmt and pid...
hualing chendf118dd2020-05-21 15:49:11 +0800444 * \param[in] adparams ad audio playback params,contains fmt and pid...
hualing chenb31a6c62020-01-13 17:27:00 +0800445 * \retval DVR_SUCCESS On success
446 * \return Error code
447 */
hualing chendf118dd2020-05-21 15:49:11 +0800448int dvr_playback_audio_start(DVR_PlaybackHandle_t handle, am_tsplayer_audio_params *param, am_tsplayer_audio_params *adparam);
449
hualing chenb31a6c62020-01-13 17:27:00 +0800450
Gong Ke497c4c22020-03-20 10:15:42 +0800451/**\brief Stop audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800452 * \param[in] handle playback handle
453 * \retval DVR_SUCCESS On success
454 * \return Error code
455 */
hualing chen040df222020-01-17 13:35:02 +0800456int dvr_playback_audio_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800457
Gong Ke497c4c22020-03-20 10:15:42 +0800458/**\brief Start video playing
hualing chenb31a6c62020-01-13 17:27:00 +0800459 * \param[in] handle playback handle
460 * \param[in] params video playback params,contains fmt and pid...
461 * \retval DVR_SUCCESS On success
462 * \return Error code
463 */
Gong Ke497c4c22020-03-20 10:15:42 +0800464int dvr_playback_video_start(DVR_PlaybackHandle_t handle, am_tsplayer_video_params *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800465
466/**\brief Stop play video
467 * \param[in] handle playback handle
468 * \retval DVR_SUCCESS On success
469 * \return Error code
470 */
hualing chen040df222020-01-17 13:35:02 +0800471int dvr_playback_video_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800472
473/**\brief Pause play
474 * \param[in] handle playback handle
475 * \param[in] flush whether its internal buffers should be flushed
476 * \retval DVR_SUCCESS On success
477 * \return Error code
478 */
hualing chen040df222020-01-17 13:35:02 +0800479int dvr_playback_pause(DVR_PlaybackHandle_t handle, DVR_Bool_t flush);
hualing chenb31a6c62020-01-13 17:27:00 +0800480
hualing chen31140872020-03-25 12:29:26 +0800481/**\brief resume play
482 * \param[in] handle playback handle
483 * \retval DVR_SUCCESS On success
484 * \return Error code
485 */
486int dvr_playback_resume(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800487
hualing chen03fd4942021-07-15 15:56:41 +0800488/**\brief set limit
489 * \param[in] handle playback handle
490 * \param[in] rec start time ms
491 * \param[in] rec limit time ms
492 * \retval DVR_SUCCESS On success
493 * \return Error code
494 */
hualing chen7ea70a72021-09-09 11:25:13 +0800495int dvr_playback_setlimit(DVR_PlaybackHandle_t handle, uint32_t time, uint32_t limit);
hualing chen03fd4942021-07-15 15:56:41 +0800496
Gong Ke497c4c22020-03-20 10:15:42 +0800497/**\brief Seek the playing position
hualing chenb31a6c62020-01-13 17:27:00 +0800498 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800499 * \param[in] segment_id the segment's index
hualing chen040df222020-01-17 13:35:02 +0800500 * \param[in] time_offset time offset base cur segment
hualing chenb31a6c62020-01-13 17:27:00 +0800501 * \retval DVR_SUCCESS On success
502 * \return Error code
503 */
hualing chencc91e1c2020-02-28 13:26:17 +0800504int dvr_playback_seek(DVR_PlaybackHandle_t handle, uint64_t segment_id, uint32_t time_offset);
hualing chenb31a6c62020-01-13 17:27:00 +0800505
506/**\brief Set play speed
507 * \param[in] handle playback handle
508 * \param[in] speed playback speed
509 * \retval DVR_SUCCESS On success
510 * \return Error code
511 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800512int dvr_playback_set_speed(DVR_PlaybackHandle_t handle, DVR_PlaybackSpeed_t speed);
hualing chenb31a6c62020-01-13 17:27:00 +0800513
514/**\brief Get playback status
515 * \param[in] handle playback handle
516 * \param[out] p_status playback status
517 * \retval DVR_SUCCESS On success
518 * \return Error code
519 */
hualing chen040df222020-01-17 13:35:02 +0800520int dvr_playback_get_status(DVR_PlaybackHandle_t handle, DVR_PlaybackStatus_t *p_status);
hualing chenb31a6c62020-01-13 17:27:00 +0800521
522/**\brief Get playback capabilities
523 * \param[out] p_capability playback capability
524 * \retval DVR_SUCCESS On success
525 * \return Error code
526 */
hualing chen040df222020-01-17 13:35:02 +0800527int dvr_playback_get_capabilities(DVR_PlaybackCapability_t *p_capability);
hualing chenb31a6c62020-01-13 17:27:00 +0800528
hualing chen040df222020-01-17 13:35:02 +0800529/**\brief dump segmentinfo throw print log
Gong Ke497c4c22020-03-20 10:15:42 +0800530 * \param[in] handle playback
531 * \param[in] segment_id if segment_id > 0, only dump this log. else dump all segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800532 * \retval DVR_SUCCESS On success
533 * \return Error code
534 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800535int dvr_dump_segmentinfo(DVR_PlaybackHandle_t handle, uint64_t segment_id);
hualing chenb31a6c62020-01-13 17:27:00 +0800536
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800537/**\brief Set DVR playback decrypt function
538 * \param[in] handle, DVR playback session handle
539 * \param[in] func, DVR playback encrypt function
540 * \param[in] userdata, DVR playback userdata from the caller
541 * \return DVR_SUCCESS on success
542 * \return error code on failure
543 */
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800544int dvr_playback_set_decrypt_callback(DVR_PlaybackHandle_t handle, DVR_CryptoFunction_t func, void *userdata);
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800545
546/**\brief Set DVR playback secure buffer used for protect the secure content
547 * \param[in] handle, DVR playback session handle
548 * \param[in] p_secure_buf, Secure buffer address which can NOT access by ACPU
549 * \param[in] len, Secure buffer length
550 * \return DVR_SUCCESS on success
551 * \return error code on failure
552 */
553int dvr_playback_set_secure_buffer(DVR_PlaybackHandle_t handle, uint8_t *p_secure_buf, uint32_t len);
554
hualing chen03fd4942021-07-15 15:56:41 +0800555/**\brief set DVR playback calculate expired time len
556 * \param[in] handle, DVR playback session handle
557 * \return DVR_SUCCESS on success
558 * \return error code on failure
559 */
hualing chen7ea70a72021-09-09 11:25:13 +0800560uint32_t dvr_playback_calculate_expiredlen(DVR_PlaybackHandle_t handle);
hualing chen03fd4942021-07-15 15:56:41 +0800561
562/**\brief set DVR playback obsolete time
563 * \param[in] handle, DVR playback session handle
564 * \param[in] obsolete, obsolete len
565 * \return DVR_SUCCESS on success
566 * \return error code on failure
567 */
568int dvr_playback_set_obsolete(DVR_PlaybackHandle_t handle, int obsolete);
569
570/**\brief update DVR playback newest segment duration
571 * \param[in] handle, DVR playback session handle
572 * \param[in] segmentid, newest segment id
573 * \param[in] dur dur time ms
574 * \return DVR_SUCCESS on success
575 * \return error code on failure
576 */
577int dvr_playback_update_duration(DVR_PlaybackHandle_t handle,
578uint64_t segmentid, int dur);
579
580/**\brief check DVR playback is set limit info
581 * \param[in] handle, DVR playback session handle
582 * \return DVR_FALSE or DVR_TRUE
583 */
584DVR_Bool_t dvr_playback_check_limit(DVR_PlaybackHandle_t handle);
585
hualing chenb31a6c62020-01-13 17:27:00 +0800586#ifdef __cplusplus
587}
588#endif
589
590#endif /*END DVR_PLAYBACK_H_*/