blob: a435c79e22549e326c35550fe2fd62574e8aa461 [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*/
hualing chen6e4bfa52020-03-13 14:37:11 +0800188 DVR_PLAYBACK_EVENT_NOTIFY_PLAYTIME, /**< notify play cur segmeng 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 */
240 DVR_PLAYBACK_CMD_VSTART, /**< v start */
241 DVR_PLAYBACK_CMD_ASTART , /**< a start */
242 DVR_PLAYBACK_CMD_VSTOP , /**< v stop */
243 DVR_PLAYBACK_CMD_ASTOP, /**< a stop */
244 DVR_PLAYBACK_CMD_VRESTART, /**< v restart */
245 DVR_PLAYBACK_CMD_ARESTART, /**< a restart */
hualing chen5cbe1a62020-02-10 16:36:36 +0800246 DVR_PLAYBACK_CMD_AVRESTART, /**< av restart */
hualing chen040df222020-01-17 13:35:02 +0800247 DVR_PLAYBACK_CMD_VSTOPASTART, /**< v stop a start*/
248 DVR_PLAYBACK_CMD_ASTOPVSTART, /**< a stop vstart */
249 DVR_PLAYBACK_CMD_VSTOPARESTART, /**<v stop a restart*/
250 DVR_PLAYBACK_CMD_ASTOPVRESTART, /**<a stop v restart*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800251 DVR_PLAYBACK_CMD_VSTARTARESTART, /**<v start a restart*/
252 DVR_PLAYBACK_CMD_ASTARTVRESTART, /**<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*/
hualing chen969fe7b2021-05-26 15:13:17 +0800342 int last_segment_tatol; /**< last segment tatol time*/
343
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;
hualing chen040df222020-01-17 13:35:02 +0800360} DVR_Playback_t;
Gong Ke497c4c22020-03-20 10:15:42 +0800361/**\endcond*/
hualing chenb31a6c62020-01-13 17:27:00 +0800362
363/**\brief Open an dvr palyback
364 * \param[out] p_handle dvr playback addr
365 * \param[in] params dvr playback open parameters
366 * \retval DVR_SUCCESS On success
367 * \return Error code
368 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800369int dvr_playback_open(DVR_PlaybackHandle_t *p_handle, DVR_PlaybackOpenParams_t *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800370
371/**\brief Close an dvr palyback
372 * \param[in] handle playback handle
373 * \retval DVR_SUCCESS On success
374 * \return Error code
375 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800376int dvr_playback_close(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800377
378
379/**\brief Start play audio and video, used start auido api and start video api
380 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800381 * \param[in] flag playback flag
hualing chenb31a6c62020-01-13 17:27:00 +0800382 * \retval DVR_SUCCESS On success
383 * \return Error code
384 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800385int dvr_playback_start(DVR_PlaybackHandle_t handle, DVR_PlaybackFlag_t flag);
hualing chenb31a6c62020-01-13 17:27:00 +0800386
hualing chen040df222020-01-17 13:35:02 +0800387/**\brief dvr play back add segment info to segment list
hualing chenb31a6c62020-01-13 17:27:00 +0800388 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800389 * \param[in] info added segment info,con vpid fmt apid fmt.....
hualing chenb31a6c62020-01-13 17:27:00 +0800390 * \retval DVR_SUCCESS On success
391 * \return Error code
392 */
hualing chen040df222020-01-17 13:35:02 +0800393int dvr_playback_add_segment(DVR_PlaybackHandle_t handle, DVR_PlaybackSegmentInfo_t *info);
hualing chenb31a6c62020-01-13 17:27:00 +0800394
hualing chen040df222020-01-17 13:35:02 +0800395/**\brief dvr play back remove segment info by segmentkid
hualing chenb31a6c62020-01-13 17:27:00 +0800396 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800397 * \param[in] segmentid need removed segment id
hualing chenb31a6c62020-01-13 17:27:00 +0800398 * \retval DVR_SUCCESS On success
399 * \return Error code
400 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800401int dvr_playback_remove_segment(DVR_PlaybackHandle_t handle, uint64_t segmentid);
hualing chenb31a6c62020-01-13 17:27:00 +0800402
hualing chen040df222020-01-17 13:35:02 +0800403/**\brief dvr play back add segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800404 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800405 * \param[in] segment_id the segment's index
406 * \param[in] flags the segment's flags
hualing chenb31a6c62020-01-13 17:27:00 +0800407 * \retval DVR_SUCCESS On success
408 * \return Error code
409 */
hualing chen040df222020-01-17 13:35:02 +0800410int dvr_playback_update_segment_flags(DVR_PlaybackHandle_t handle,
hualing chen5cbe1a62020-02-10 16:36:36 +0800411 uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800412 DVR_PlaybackSegmentFlag_t flags);
Gong Ke497c4c22020-03-20 10:15:42 +0800413
hualing chen040df222020-01-17 13:35:02 +0800414/**\brief dvr play back up1date segment pids
415 * if updated segment is ongoing segment, we need start new
hualing chenb31a6c62020-01-13 17:27:00 +0800416 * add pid stream and stop remove pid stream.
417 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800418 * \param[in] segment_id need updated pids segment id
Gong Ke497c4c22020-03-20 10:15:42 +0800419 * \param[in] p_pids the new PIDs
hualing chenb31a6c62020-01-13 17:27:00 +0800420 * \retval DVR_SUCCESS On success
421 * \return Error code
422 */
Gong Ke497c4c22020-03-20 10:15:42 +0800423int dvr_playback_update_segment_pids(DVR_PlaybackHandle_t handle, uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800424DVR_PlaybackPids_t *p_pids);
hualing chenb31a6c62020-01-13 17:27:00 +0800425
hualing chena5f03222021-12-02 11:22:35 +0800426/**\brief dvr play back only up1date segment pids
427 * only update segment info, not stop start codec.
428 * \param[in] handle playback handle
429 * \param[in] segment_id need updated pids segment id
430 * \param[in] p_pids the new PIDs
431 * \retval DVR_SUCCESS On success
432 * \return Error code
433 */
434int dvr_playback_only_update_segment_pids(DVR_PlaybackHandle_t handle, uint64_t segment_id, DVR_PlaybackPids_t *p_pids);
435
Gong Ke497c4c22020-03-20 10:15:42 +0800436/**\brief Stop playing, will stop video and audio
hualing chenb31a6c62020-01-13 17:27:00 +0800437 * \param[in] handle playback handle
438 * \param[in] clear is clear last frame
439 * \retval DVR_SUCCESS On success
440 * \return Error code
441 */
hualing chen040df222020-01-17 13:35:02 +0800442int dvr_playback_stop(DVR_PlaybackHandle_t handle, DVR_Bool_t clear);
hualing chenb31a6c62020-01-13 17:27:00 +0800443
Gong Ke497c4c22020-03-20 10:15:42 +0800444/**\brief Start audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800445 * \param[in] handle playback handle
446 * \param[in] params audio playback params,contains fmt and pid...
hualing chendf118dd2020-05-21 15:49:11 +0800447 * \param[in] adparams ad audio playback params,contains fmt and pid...
hualing chenb31a6c62020-01-13 17:27:00 +0800448 * \retval DVR_SUCCESS On success
449 * \return Error code
450 */
hualing chendf118dd2020-05-21 15:49:11 +0800451int dvr_playback_audio_start(DVR_PlaybackHandle_t handle, am_tsplayer_audio_params *param, am_tsplayer_audio_params *adparam);
452
hualing chenb31a6c62020-01-13 17:27:00 +0800453
Gong Ke497c4c22020-03-20 10:15:42 +0800454/**\brief Stop audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800455 * \param[in] handle playback handle
456 * \retval DVR_SUCCESS On success
457 * \return Error code
458 */
hualing chen040df222020-01-17 13:35:02 +0800459int dvr_playback_audio_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800460
Gong Ke497c4c22020-03-20 10:15:42 +0800461/**\brief Start video playing
hualing chenb31a6c62020-01-13 17:27:00 +0800462 * \param[in] handle playback handle
463 * \param[in] params video playback params,contains fmt and pid...
464 * \retval DVR_SUCCESS On success
465 * \return Error code
466 */
Gong Ke497c4c22020-03-20 10:15:42 +0800467int dvr_playback_video_start(DVR_PlaybackHandle_t handle, am_tsplayer_video_params *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800468
469/**\brief Stop play video
470 * \param[in] handle playback handle
471 * \retval DVR_SUCCESS On success
472 * \return Error code
473 */
hualing chen040df222020-01-17 13:35:02 +0800474int dvr_playback_video_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800475
476/**\brief Pause play
477 * \param[in] handle playback handle
478 * \param[in] flush whether its internal buffers should be flushed
479 * \retval DVR_SUCCESS On success
480 * \return Error code
481 */
hualing chen040df222020-01-17 13:35:02 +0800482int dvr_playback_pause(DVR_PlaybackHandle_t handle, DVR_Bool_t flush);
hualing chenb31a6c62020-01-13 17:27:00 +0800483
hualing chen31140872020-03-25 12:29:26 +0800484/**\brief resume play
485 * \param[in] handle playback handle
486 * \retval DVR_SUCCESS On success
487 * \return Error code
488 */
489int dvr_playback_resume(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800490
hualing chen03fd4942021-07-15 15:56:41 +0800491/**\brief set limit
492 * \param[in] handle playback handle
493 * \param[in] rec start time ms
494 * \param[in] rec limit time ms
495 * \retval DVR_SUCCESS On success
496 * \return Error code
497 */
hualing chen7ea70a72021-09-09 11:25:13 +0800498int dvr_playback_setlimit(DVR_PlaybackHandle_t handle, uint32_t time, uint32_t limit);
hualing chen03fd4942021-07-15 15:56:41 +0800499
Gong Ke497c4c22020-03-20 10:15:42 +0800500/**\brief Seek the playing position
hualing chenb31a6c62020-01-13 17:27:00 +0800501 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800502 * \param[in] segment_id the segment's index
hualing chen040df222020-01-17 13:35:02 +0800503 * \param[in] time_offset time offset base cur segment
hualing chenb31a6c62020-01-13 17:27:00 +0800504 * \retval DVR_SUCCESS On success
505 * \return Error code
506 */
hualing chencc91e1c2020-02-28 13:26:17 +0800507int dvr_playback_seek(DVR_PlaybackHandle_t handle, uint64_t segment_id, uint32_t time_offset);
hualing chenb31a6c62020-01-13 17:27:00 +0800508
509/**\brief Set play speed
510 * \param[in] handle playback handle
511 * \param[in] speed playback speed
512 * \retval DVR_SUCCESS On success
513 * \return Error code
514 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800515int dvr_playback_set_speed(DVR_PlaybackHandle_t handle, DVR_PlaybackSpeed_t speed);
hualing chenb31a6c62020-01-13 17:27:00 +0800516
517/**\brief Get playback status
518 * \param[in] handle playback handle
519 * \param[out] p_status playback status
520 * \retval DVR_SUCCESS On success
521 * \return Error code
522 */
hualing chen040df222020-01-17 13:35:02 +0800523int dvr_playback_get_status(DVR_PlaybackHandle_t handle, DVR_PlaybackStatus_t *p_status);
hualing chenb31a6c62020-01-13 17:27:00 +0800524
525/**\brief Get playback capabilities
526 * \param[out] p_capability playback capability
527 * \retval DVR_SUCCESS On success
528 * \return Error code
529 */
hualing chen040df222020-01-17 13:35:02 +0800530int dvr_playback_get_capabilities(DVR_PlaybackCapability_t *p_capability);
hualing chenb31a6c62020-01-13 17:27:00 +0800531
hualing chen040df222020-01-17 13:35:02 +0800532/**\brief dump segmentinfo throw print log
Gong Ke497c4c22020-03-20 10:15:42 +0800533 * \param[in] handle playback
534 * \param[in] segment_id if segment_id > 0, only dump this log. else dump all segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800535 * \retval DVR_SUCCESS On success
536 * \return Error code
537 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800538int dvr_dump_segmentinfo(DVR_PlaybackHandle_t handle, uint64_t segment_id);
hualing chenb31a6c62020-01-13 17:27:00 +0800539
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800540/**\brief Set DVR playback decrypt function
541 * \param[in] handle, DVR playback session handle
542 * \param[in] func, DVR playback encrypt function
543 * \param[in] userdata, DVR playback userdata from the caller
544 * \return DVR_SUCCESS on success
545 * \return error code on failure
546 */
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800547int dvr_playback_set_decrypt_callback(DVR_PlaybackHandle_t handle, DVR_CryptoFunction_t func, void *userdata);
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800548
549/**\brief Set DVR playback secure buffer used for protect the secure content
550 * \param[in] handle, DVR playback session handle
551 * \param[in] p_secure_buf, Secure buffer address which can NOT access by ACPU
552 * \param[in] len, Secure buffer length
553 * \return DVR_SUCCESS on success
554 * \return error code on failure
555 */
556int dvr_playback_set_secure_buffer(DVR_PlaybackHandle_t handle, uint8_t *p_secure_buf, uint32_t len);
557
hualing chen03fd4942021-07-15 15:56:41 +0800558/**\brief set DVR playback calculate expired time len
559 * \param[in] handle, DVR playback session handle
560 * \return DVR_SUCCESS on success
561 * \return error code on failure
562 */
hualing chen7ea70a72021-09-09 11:25:13 +0800563uint32_t dvr_playback_calculate_expiredlen(DVR_PlaybackHandle_t handle);
hualing chen03fd4942021-07-15 15:56:41 +0800564
565/**\brief set DVR playback obsolete time
566 * \param[in] handle, DVR playback session handle
567 * \param[in] obsolete, obsolete len
568 * \return DVR_SUCCESS on success
569 * \return error code on failure
570 */
571int dvr_playback_set_obsolete(DVR_PlaybackHandle_t handle, int obsolete);
572
573/**\brief update DVR playback newest segment duration
574 * \param[in] handle, DVR playback session handle
575 * \param[in] segmentid, newest segment id
576 * \param[in] dur dur time ms
577 * \return DVR_SUCCESS on success
578 * \return error code on failure
579 */
580int dvr_playback_update_duration(DVR_PlaybackHandle_t handle,
581uint64_t segmentid, int dur);
582
583/**\brief check DVR playback is set limit info
584 * \param[in] handle, DVR playback session handle
585 * \return DVR_FALSE or DVR_TRUE
586 */
587DVR_Bool_t dvr_playback_check_limit(DVR_PlaybackHandle_t handle);
588
hualing chenb31a6c62020-01-13 17:27:00 +0800589#ifdef __cplusplus
590}
591#endif
592
593#endif /*END DVR_PLAYBACK_H_*/