blob: 68b0b1a04ebf65e41a57eb1f27e09e2932e51f06 [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
Gong Ke3489c0f2020-01-16 18:11:44 +080045/**\brief dvr segments info */
hualing chenb31a6c62020-01-13 17:27:00 +080046typedef struct
47{
Gong Ke3489c0f2020-01-16 18:11:44 +080048 struct list_head head; /**< Segment node.*/
hualing chen5cbe1a62020-02-10 16:36:36 +080049 uint64_t segment_id; /**< Segment's index.*/
50 char location[DVR_MAX_LOCATION_SIZE]; /**< chunk location */
Gong Ke3489c0f2020-01-16 18:11:44 +080051 DVR_PlaybackPids_t pids; /**< Streams' PIDs.*/
hualing chen040df222020-01-17 13:35:02 +080052 DVR_PlaybackSegmentFlag_t flags; /**< Segment's flag */
Gong Ke3489c0f2020-01-16 18:11:44 +080053 int key_data_id; /**< ??? */
hualing chen03fd4942021-07-15 15:56:41 +080054 int duration; /**< Segment dur time ms*/
Gong Ke3489c0f2020-01-16 18:11:44 +080055} DVR_PlaybackSegmentInfo_t;
hualing chenb31a6c62020-01-13 17:27:00 +080056
57/**\brief play flag, if set this flag, player need pause when decode first frame */
58typedef enum
59{
Gong Ke3489c0f2020-01-16 18:11:44 +080060 DVR_PLAYBACK_STARTED_PAUSEDLIVE = (1 << 0) /**< dvr play stat,need change to pause state if set */
61} DVR_PlaybackFlag_t;
hualing chen86e7d482020-01-16 15:13:33 +080062
63/**\brief playback speed mode*/
hualing chenb31a6c62020-01-13 17:27:00 +080064typedef enum
65{
Gong Ke3489c0f2020-01-16 18:11:44 +080066 DVR_PLAYBACK_FAST_FORWARD = 0, /**< fast forward */
67 DVR_PLAYBACK_FAST_BACKWARD = 1, /**< fast backward */
hualing chen31140872020-03-25 12:29:26 +080068 DVR_PLAYBACK_KERNEL_SUPPORT = 2, /**< kernel support mode */
Gong Ke3489c0f2020-01-16 18:11:44 +080069} DVR_PlaybackSpeedMode_t;
hualing chenb31a6c62020-01-13 17:27:00 +080070
hualing chen2aba4022020-03-02 13:49:55 +080071/**\brief playback speed*/
72typedef enum
73{
hualing chene41f4372020-06-06 16:29:17 +080074 PLAYBACK_SPEED_FBX1 = -100, /**<FB X 1 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080075 PLAYBACK_SPEED_FBX2 = -200, /**<FB X 2 speed*/
76 PLAYBACK_SPEED_FBX4 = -400, /**<FB X 4 speed*/
77 PLAYBACK_SPEED_FBX8 = -800, /**<FB X 8 speed*/
hualing chen041c4092020-04-05 15:11:50 +080078 PLAYBACK_SPEED_FBX12 = -1200, /**< FB 12 speed*/
79 PLAYBACK_SPEED_FBX16 = -1600, /**<FB X 16 speed*/
80 PLAYBACK_SPEED_FBX32 = -3200, /**<FB X 32 speed*/
81 PLAYBACK_SPEED_FBX48 = -4800, /**<FB X 48 speed*/
82 PLAYBACK_SPEED_FBX64 = -6400, /**<FB X 64 speed*/
83 PLAYBACK_SPEED_FBX128 = -12800, /**<FB X 128 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080084 PLAYBACK_SPEED_S8 = 12, /**<slow 1/8 speed*/
85 PLAYBACK_SPEED_S4 = 25, /**<slow 1/4 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080086 PLAYBACK_SPEED_S2 = 50, /**<slow 1/2 speed*/
87 PLAYBACK_SPEED_X1 = 100, /**< X 1 normal speed*/
88 PLAYBACK_SPEED_X2 = 200, /**< X 2 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080089 PLAYBACK_SPEED_X3 = 300, /**< X 3 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080090 PLAYBACK_SPEED_X4 = 400, /**< X 4 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080091 PLAYBACK_SPEED_X5 = 500, /**< X 5 speed*/
92 PLAYBACK_SPEED_X6 = 600, /**< X 6 speed*/
93 PLAYBACK_SPEED_X7 = 700, /**< X 7 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080094 PLAYBACK_SPEED_X8 = 800, /**< X 8 speed*/
hualing chen041c4092020-04-05 15:11:50 +080095 PLAYBACK_SPEED_X12 = 1200, /**< X 12 speed*/
96 PLAYBACK_SPEED_X16 = 1600, /**< X 16 speed*/
97 PLAYBACK_SPEED_X32 = 3200, /**< X 32 speed*/
98 PLAYBACK_SPEED_X48 = 4800, /**< X 48 speed*/
99 PLAYBACK_SPEED_X64 = 6400, /**< X 64 speed*/
100 PLAYBACK_SPEED_X128 = 12800, /**< X 128 speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800101 PlayBack_Speed_MAX,
102} Playback_SpeedValue_t;
103
Gong Ke497c4c22020-03-20 10:15:42 +0800104/**\brief playback speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800105typedef struct Playback_Speeds_s {
Gong Ke497c4c22020-03-20 10:15:42 +0800106 int speed; /**< playback speed value*/
hualing chen2aba4022020-03-02 13:49:55 +0800107} Playback_Speeds_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800108
Gong Ke3489c0f2020-01-16 18:11:44 +0800109/**\brief playback play speed*/
hualing chenb31a6c62020-01-13 17:27:00 +0800110typedef struct
111{
hualing chen2aba4022020-03-02 13:49:55 +0800112 Playback_Speeds_t speed; /**< playback speed */
Gong Ke3489c0f2020-01-16 18:11:44 +0800113 DVR_PlaybackSpeedMode_t mode; /**< playback 0: fast forword or 1: fast backword*/
114} DVR_PlaybackSpeed_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800115
hualing chen2aba4022020-03-02 13:49:55 +0800116
Gong Ke3489c0f2020-01-16 18:11:44 +0800117/**Maximum supported speed modes.*/
hualing chenb31a6c62020-01-13 17:27:00 +0800118#define DVR_MAX_SUPPORTED_SPEEDS 32
Gong Ke3489c0f2020-01-16 18:11:44 +0800119
hualing chenb31a6c62020-01-13 17:27:00 +0800120/**\brief playback capability*/
121typedef struct
122{
hualing chen86e7d482020-01-16 15:13:33 +0800123 int nb_supported_speeds; /**< support playback speed count*/
124 int supported_speeds[DVR_MAX_SUPPORTED_SPEEDS]; /**< support playback speed*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800125} DVR_PlaybackCapability_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800126
Gong Ke3489c0f2020-01-16 18:11:44 +0800127/**Playback handle.*/
128typedef void* DVR_PlaybackHandle_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800129
hualing chencc91e1c2020-02-28 13:26:17 +0800130
131/**\brief playback error reason*/
132typedef enum
133{
134 DVR_PLAYBACK_PID_ERROR, /**< uninit state */
135 DVR_PLAYBACK_FMT_ERROR /**< fmt not surport backword */
136} DVR_PlaybackError_t;
137
138
hualing chenb31a6c62020-01-13 17:27:00 +0800139/**\brief playback play state*/
140typedef enum
141{
Gong Ke3489c0f2020-01-16 18:11:44 +0800142 DVR_PLAYBACK_STATE_START, /**< start play */
143 DVR_PLAYBACK_STATE_STOP, /**< stop */
144 DVR_PLAYBACK_STATE_PAUSE, /**< pause */
145 DVR_PLAYBACK_STATE_FF, /**< fast forward */
146 DVR_PLAYBACK_STATE_FB /**< fast backword */
147} DVR_PlaybackPlayState_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800148
149/**\brief playback play status*/
150typedef struct
151{
Gong Ke3489c0f2020-01-16 18:11:44 +0800152 DVR_PlaybackPlayState_t state; /**< playback play state */
hualing chen5cbe1a62020-02-10 16:36:36 +0800153 uint64_t segment_id; /**< playback ongoing segment index */
hualing chencc91e1c2020-02-28 13:26:17 +0800154 uint32_t time_cur; /**< playback cur time,0 <--> time_end Ms*/
155 uint32_t time_end; /**< playback ongoing segment dur,Ms */
Gong Ke3489c0f2020-01-16 18:11:44 +0800156 DVR_PlaybackPids_t pids; /**< playback played pids */
hualing chen5cbe1a62020-02-10 16:36:36 +0800157 int speed; /**< playback speed */
158 DVR_PlaybackSegmentFlag_t flags; /**< playback played segment flag */
Gong Ke3489c0f2020-01-16 18:11:44 +0800159} DVR_PlaybackStatus_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800160
hualing chenfbf8e022020-06-15 13:43:11 +0800161/**\brief DVR playback vendor*/
162typedef enum {
163 DVR_PLAYBACK_VENDOR_DEF , /**< default*/
hualing chen90b3ae62021-03-30 10:49:28 +0800164 DVR_PLAYBACK_VENDOR_AML, /**< aml*/
165 DVR_PLAYBACK_VENDOR_AMAZON /**< amazon*/
hualing chenfbf8e022020-06-15 13:43:11 +0800166} DVR_PlaybackVendor_t;
167
168
hualing chencc91e1c2020-02-28 13:26:17 +0800169/**\brief DVR playback event*/
170typedef enum {
171 DVR_PLAYBACK_EVENT_ERROR = 0x1000, /**< Signal a critical playback error*/
172 DVR_PLAYBACK_EVENT_TRANSITION_OK , /**< transition ok*/
173 DVR_PLAYBACK_EVENT_TRANSITION_FAILED, /**< transition failed*/
174 DVR_PLAYBACK_EVENT_KEY_FAILURE, /**< key failure*/
175 DVR_PLAYBACK_EVENT_NO_KEY, /**< no key*/
176 DVR_PLAYBACK_EVENT_REACHED_BEGIN , /**< reached begin*/
hualing chen2aba4022020-03-02 13:49:55 +0800177 DVR_PLAYBACK_EVENT_REACHED_END, /**< reached end*/
hualing chen6e4bfa52020-03-13 14:37:11 +0800178 DVR_PLAYBACK_EVENT_NOTIFY_PLAYTIME, /**< notify play cur segmeng time ms*/
hualing chene3797f02021-01-13 14:53:28 +0800179 DVR_PLAYBACK_EVENT_FIRST_FRAME, /**< first frame*/
180 DVR_PLAYBACK_EVENT_NODATA, /**< no data*/
181 DVR_PLAYBACK_EVENT_DATARESUME /**< data resume*/
hualing chencc91e1c2020-02-28 13:26:17 +0800182} DVR_PlaybackEvent_t;
183
184/**\brief DVR playback event notify function*/
185typedef struct
186{
Gong Ke497c4c22020-03-20 10:15:42 +0800187 DVR_PlaybackEvent_t event; /**< event type*/
188 DVR_PlaybackStatus_t play_status; /**< play status*/
hualing chencc91e1c2020-02-28 13:26:17 +0800189 union
190 {
Gong Ke497c4c22020-03-20 10:15:42 +0800191 uint8_t unused;
192 uint8_t error_reason;/**< error reason*/
hualing chencc91e1c2020-02-28 13:26:17 +0800193 struct
194 {
Gong Ke497c4c22020-03-20 10:15:42 +0800195 uint64_t segment_id; /**< error segment id*/
196 uint32_t key_data_id; /**< key data id*/
197 uint8_t error; /**< error*/
hualing chencc91e1c2020-02-28 13:26:17 +0800198 } transition_failed_data;
Gong Ke497c4c22020-03-20 10:15:42 +0800199 } info; /**< information*/
hualing chencc91e1c2020-02-28 13:26:17 +0800200} DVR_Play_Notify_t;
201
202/**\brief DVR playback event notify function*/
203typedef DVR_Result_t (*DVR_PlaybackEventFunction_t) (DVR_PlaybackEvent_t event, void *params, void *userdata);
204
205
hualing chenb31a6c62020-01-13 17:27:00 +0800206/**\brief playback open params*/
207typedef struct
208{
Gong Ke3489c0f2020-01-16 18:11:44 +0800209 int dmx_dev_id; /**< playback used dmx device index*/
210 int block_size; /**< playback inject block size*/
211 DVR_Bool_t is_timeshift; /**< 0:playback mode, 1 : is timeshift mode*/
hualing chen2aba4022020-03-02 13:49:55 +0800212 am_tsplayer_handle player_handle; /**< am tsplayer handle.*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800213 DVR_CryptoFunction_t crypto_fn; /**< Crypto function.*/
214 void *crypto_data; /**< Crypto function's user data.*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800215 DVR_Bool_t has_pids; /**< has video audo pid fmt info*/
hualing chencc91e1c2020-02-28 13:26:17 +0800216 DVR_PlaybackEventFunction_t event_fn; /**< playback event callback function*/
217 void *event_userdata; /**< event userdata*/
hualing chenfbf8e022020-06-15 13:43:11 +0800218 DVR_PlaybackVendor_t vendor; /**< vendor type,default is 0*/
hualing chene3797f02021-01-13 14:53:28 +0800219 DVR_Bool_t is_notify_time; /**< notify play time info true or not*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800220} DVR_PlaybackOpenParams_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800221
222/**\brief playback play state*/
223typedef enum
224{
hualing chen040df222020-01-17 13:35:02 +0800225 DVR_PLAYBACK_CMD_START, /**< start av */
226 DVR_PLAYBACK_CMD_STOP, /**< stop av */
227 DVR_PLAYBACK_CMD_VSTART, /**< v start */
228 DVR_PLAYBACK_CMD_ASTART , /**< a start */
229 DVR_PLAYBACK_CMD_VSTOP , /**< v stop */
230 DVR_PLAYBACK_CMD_ASTOP, /**< a stop */
231 DVR_PLAYBACK_CMD_VRESTART, /**< v restart */
232 DVR_PLAYBACK_CMD_ARESTART, /**< a restart */
hualing chen5cbe1a62020-02-10 16:36:36 +0800233 DVR_PLAYBACK_CMD_AVRESTART, /**< av restart */
hualing chen040df222020-01-17 13:35:02 +0800234 DVR_PLAYBACK_CMD_VSTOPASTART, /**< v stop a start*/
235 DVR_PLAYBACK_CMD_ASTOPVSTART, /**< a stop vstart */
236 DVR_PLAYBACK_CMD_VSTOPARESTART, /**<v stop a restart*/
237 DVR_PLAYBACK_CMD_ASTOPVRESTART, /**<a stop v restart*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800238 DVR_PLAYBACK_CMD_VSTARTARESTART, /**<v start a restart*/
239 DVR_PLAYBACK_CMD_ASTARTVRESTART, /**<a start v restart*/
hualing chen040df222020-01-17 13:35:02 +0800240 DVR_PLAYBACK_CMD_PAUSE, /**< pause */
241 DVR_PLAYBACK_CMD_RESUME, /**< resume */
242 DVR_PLAYBACK_CMD_SEEK, /**< seek */
243 DVR_PLAYBACK_CMD_FF, /**< fast forward */
244 DVR_PLAYBACK_CMD_FB, /**< fast backword */
hualing chen5cbe1a62020-02-10 16:36:36 +0800245 DVR_PLAYBACK_CMD_NONE, /**< none */
hualing chen040df222020-01-17 13:35:02 +0800246} DVR_PlaybackCmd_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800247
248
249/**\brief playback struct*/
250typedef struct
251{
hualing chen5cbe1a62020-02-10 16:36:36 +0800252 DVR_PlaybackSpeed_t speed; /**< play speed */
253 DVR_PlaybackPlayState_t state; /**< play state */
hualing chen040df222020-01-17 13:35:02 +0800254 DVR_PlaybackCmd_t cur_cmd; /**< cur send cmd */
255 DVR_PlaybackCmd_t last_cmd; /**< last cmd */
256 int pos; /**< seek pos at cur segment*/
257} DVR_PlaybackCmdInfo_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800258
hualing chend241c7a2021-06-22 13:34:27 +0800259/**\brief playback struct*/
260typedef struct
261{
hualing chen03fd4942021-07-15 15:56:41 +0800262 uint64_t sys_dur; /**< system duration */
263 uint64_t sys_sta; /**< system start time */
264 uint64_t ply_dur; /**< play duration */
265 uint64_t ply_sta; /**< play start time */
hualing chend241c7a2021-06-22 13:34:27 +0800266} DVR_PlaybackConSpe_t;
267
268
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800269/**\brief DVR playback decrypt function*/
270typedef DVR_Result_t (*DVR_PlaybackDecryptFunction_t) (uint8_t *p_in,
271 uint32_t in_len,
272 uint8_t *p_out,
273 uint32_t *p_out_len,
274 void *userdata);
hualing chenb31a6c62020-01-13 17:27:00 +0800275
Gong Ke497c4c22020-03-20 10:15:42 +0800276/**\cond */
hualing chenb31a6c62020-01-13 17:27:00 +0800277/**\brief playback struct*/
278typedef struct
279{
hualing chen2aba4022020-03-02 13:49:55 +0800280 am_tsplayer_handle handle; /**< tsplayer handle */
hualing chencc91e1c2020-02-28 13:26:17 +0800281 DVR_Bool_t segment_is_open; /**<segment is opend*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800282 uint64_t cur_segment_id; /**< Current segment id*/
hualing chen040df222020-01-17 13:35:02 +0800283 DVR_PlaybackSegmentInfo_t cur_segment; /**< Current playing segment*/
hualing chencc91e1c2020-02-28 13:26:17 +0800284 uint64_t last_segment_id; /**< last segment id*/
285 DVR_PlaybackSegmentInfo_t last_segment; /**< last playing segment*/
hualing chen040df222020-01-17 13:35:02 +0800286 struct list_head segment_list; /**< segment list head*/
287 pthread_t playback_thread; /**< playback thread*/
288 pthread_mutex_t lock; /**< playback lock*/
hualing chen2aba4022020-03-02 13:49:55 +0800289 pthread_mutex_t segment_lock; /**< playback segment lock*/
hualing chen040df222020-01-17 13:35:02 +0800290 pthread_cond_t cond; /**< playback cond*/
291 void *user_data; /**< playback userdata, used to send event*/
hualing chen6d24aa92020-03-23 18:43:47 +0800292 float speed; /**< playback speed*/
hualing chen040df222020-01-17 13:35:02 +0800293 DVR_PlaybackPlayState_t state; /**< playback state*/
294 DVR_PlaybackFlag_t play_flag; /**< playback play flag*/
hualing chen86e7d482020-01-16 15:13:33 +0800295 int is_running; /**< playback htread is runing*/
hualing chen040df222020-01-17 13:35:02 +0800296 DVR_PlaybackCmdInfo_t cmd; /**< playback cmd*/
297 int offset; /**< segment read offset*/
hualing chencc91e1c2020-02-28 13:26:17 +0800298 uint32_t dur; /**< segment dur*/
hualing chen86e7d482020-01-16 15:13:33 +0800299 Segment_Handle_t r_handle; /**< playback current segment handle*/
hualing chen040df222020-01-17 13:35:02 +0800300 DVR_PlaybackOpenParams_t openParams; /**< playback openParams*/
hualing chen86e7d482020-01-16 15:13:33 +0800301 DVR_Bool_t has_video; /**< has video playing*/
302 DVR_Bool_t has_audio; /**< has audio playing*/
hualing chendf118dd2020-05-21 15:49:11 +0800303 DVR_Bool_t has_ad_audio; /**< has ad audio playing*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800304 DVR_Bool_t has_pids; /**< has video audo pid fmt info*/
hualing chen03fd4942021-07-15 15:56:41 +0800305 uint64_t fffb_start; /**< fffb start time ms*/
306 uint64_t fffb_current; /**< fffb current time*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800307 int fffb_start_pcr; /**< fffb start pcr time*/
hualing chen03fd4942021-07-15 15:56:41 +0800308 uint64_t next_fffb_time;/**< fffb start pcr time*/
hualing chena540a7e2020-03-27 16:44:05 +0800309 int seek_time;/**< fffb start pcr time*/
310 event_callback player_callback_func;/**< tsplayer cb*/
311 void *player_callback_userdata;/**< tsplayer cb data*/
hualing chen03fd4942021-07-15 15:56:41 +0800312 uint64_t send_time;/**< send event time*/
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800313 int first_frame;/**< show first frame*/
314 DVR_CryptoFunction_t dec_func; /**< Decrypt function*/
315 void *dec_userdata; /**< Decrypt userdata*/
316 int is_secure_mode; /**< Playback session run in secure pipeline */
317 uint8_t *secure_buffer; /* Playback session secure buffer */
318 uint32_t secure_buffer_size; /* Playback session secure buffer size */
hualing chen266b9502020-04-04 17:39:39 +0800319 DVR_Bool_t drop_ts;
hualing chen4b7c15d2020-04-07 16:13:48 +0800320 DVR_Bool_t fffb_play;
321 int32_t last_cur_time;
322 uint64_t last_send_time_id;
hualing chen5605eed2020-05-26 18:18:06 +0800323 int ts_cache_len;
hualing chene41f4372020-06-06 16:29:17 +0800324 DVR_Bool_t first_trans_ok;
hualing chenfbf8e022020-06-15 13:43:11 +0800325 DVR_PlaybackVendor_t vendor;
hualing chene3797f02021-01-13 14:53:28 +0800326 int noData;
hualing chen30423862021-04-16 14:39:12 +0800327 DVR_Bool_t seek_pause;
hualing chen969fe7b2021-05-26 15:13:17 +0800328 int last_segment_tatol; /**< last segment tatol time*/
329
hualing chen03fd4942021-07-15 15:56:41 +0800330 DVR_PlaybackConSpe_t con_spe; /**< inject data speed info*/
331
332 //limit info
333 int obsolete; /**< rec obsolete time in ms*/
334 uint64_t rec_start; /**< rec start time in ms*/
335 int limit; /**< rec data limit time in ms*/
hualing chen8a657f32021-08-30 13:12:49 +0800336 //first play need seek to start time
337 uint64_t first_start_time;
338 DVR_Bool_t need_seek_start;
hualing chen040df222020-01-17 13:35:02 +0800339} DVR_Playback_t;
Gong Ke497c4c22020-03-20 10:15:42 +0800340/**\endcond*/
hualing chenb31a6c62020-01-13 17:27:00 +0800341
342/**\brief Open an dvr palyback
343 * \param[out] p_handle dvr playback addr
344 * \param[in] params dvr playback open parameters
345 * \retval DVR_SUCCESS On success
346 * \return Error code
347 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800348int dvr_playback_open(DVR_PlaybackHandle_t *p_handle, DVR_PlaybackOpenParams_t *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800349
350/**\brief Close an dvr palyback
351 * \param[in] handle playback handle
352 * \retval DVR_SUCCESS On success
353 * \return Error code
354 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800355int dvr_playback_close(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800356
357
358/**\brief Start play audio and video, used start auido api and start video api
359 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800360 * \param[in] flag playback flag
hualing chenb31a6c62020-01-13 17:27:00 +0800361 * \retval DVR_SUCCESS On success
362 * \return Error code
363 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800364int dvr_playback_start(DVR_PlaybackHandle_t handle, DVR_PlaybackFlag_t flag);
hualing chenb31a6c62020-01-13 17:27:00 +0800365
hualing chen040df222020-01-17 13:35:02 +0800366/**\brief dvr play back add segment info to segment list
hualing chenb31a6c62020-01-13 17:27:00 +0800367 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800368 * \param[in] info added segment info,con vpid fmt apid fmt.....
hualing chenb31a6c62020-01-13 17:27:00 +0800369 * \retval DVR_SUCCESS On success
370 * \return Error code
371 */
hualing chen040df222020-01-17 13:35:02 +0800372int dvr_playback_add_segment(DVR_PlaybackHandle_t handle, DVR_PlaybackSegmentInfo_t *info);
hualing chenb31a6c62020-01-13 17:27:00 +0800373
hualing chen040df222020-01-17 13:35:02 +0800374/**\brief dvr play back remove segment info by segmentkid
hualing chenb31a6c62020-01-13 17:27:00 +0800375 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800376 * \param[in] segmentid need removed segment id
hualing chenb31a6c62020-01-13 17:27:00 +0800377 * \retval DVR_SUCCESS On success
378 * \return Error code
379 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800380int dvr_playback_remove_segment(DVR_PlaybackHandle_t handle, uint64_t segmentid);
hualing chenb31a6c62020-01-13 17:27:00 +0800381
hualing chen040df222020-01-17 13:35:02 +0800382/**\brief dvr play back add segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800383 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800384 * \param[in] segment_id the segment's index
385 * \param[in] flags the segment's flags
hualing chenb31a6c62020-01-13 17:27:00 +0800386 * \retval DVR_SUCCESS On success
387 * \return Error code
388 */
hualing chen040df222020-01-17 13:35:02 +0800389int dvr_playback_update_segment_flags(DVR_PlaybackHandle_t handle,
hualing chen5cbe1a62020-02-10 16:36:36 +0800390 uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800391 DVR_PlaybackSegmentFlag_t flags);
Gong Ke497c4c22020-03-20 10:15:42 +0800392
hualing chen040df222020-01-17 13:35:02 +0800393/**\brief dvr play back up1date segment pids
394 * if updated segment is ongoing segment, we need start new
hualing chenb31a6c62020-01-13 17:27:00 +0800395 * add pid stream and stop remove pid stream.
396 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800397 * \param[in] segment_id need updated pids segment id
Gong Ke497c4c22020-03-20 10:15:42 +0800398 * \param[in] p_pids the new PIDs
hualing chenb31a6c62020-01-13 17:27:00 +0800399 * \retval DVR_SUCCESS On success
400 * \return Error code
401 */
Gong Ke497c4c22020-03-20 10:15:42 +0800402int dvr_playback_update_segment_pids(DVR_PlaybackHandle_t handle, uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800403DVR_PlaybackPids_t *p_pids);
hualing chenb31a6c62020-01-13 17:27:00 +0800404
Gong Ke497c4c22020-03-20 10:15:42 +0800405/**\brief Stop playing, will stop video and audio
hualing chenb31a6c62020-01-13 17:27:00 +0800406 * \param[in] handle playback handle
407 * \param[in] clear is clear last frame
408 * \retval DVR_SUCCESS On success
409 * \return Error code
410 */
hualing chen040df222020-01-17 13:35:02 +0800411int dvr_playback_stop(DVR_PlaybackHandle_t handle, DVR_Bool_t clear);
hualing chenb31a6c62020-01-13 17:27:00 +0800412
Gong Ke497c4c22020-03-20 10:15:42 +0800413/**\brief Start audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800414 * \param[in] handle playback handle
415 * \param[in] params audio playback params,contains fmt and pid...
hualing chendf118dd2020-05-21 15:49:11 +0800416 * \param[in] adparams ad audio playback params,contains fmt and pid...
hualing chenb31a6c62020-01-13 17:27:00 +0800417 * \retval DVR_SUCCESS On success
418 * \return Error code
419 */
hualing chendf118dd2020-05-21 15:49:11 +0800420int dvr_playback_audio_start(DVR_PlaybackHandle_t handle, am_tsplayer_audio_params *param, am_tsplayer_audio_params *adparam);
421
hualing chenb31a6c62020-01-13 17:27:00 +0800422
Gong Ke497c4c22020-03-20 10:15:42 +0800423/**\brief Stop audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800424 * \param[in] handle playback handle
425 * \retval DVR_SUCCESS On success
426 * \return Error code
427 */
hualing chen040df222020-01-17 13:35:02 +0800428int dvr_playback_audio_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800429
Gong Ke497c4c22020-03-20 10:15:42 +0800430/**\brief Start video playing
hualing chenb31a6c62020-01-13 17:27:00 +0800431 * \param[in] handle playback handle
432 * \param[in] params video playback params,contains fmt and pid...
433 * \retval DVR_SUCCESS On success
434 * \return Error code
435 */
Gong Ke497c4c22020-03-20 10:15:42 +0800436int dvr_playback_video_start(DVR_PlaybackHandle_t handle, am_tsplayer_video_params *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800437
438/**\brief Stop play video
439 * \param[in] handle playback handle
440 * \retval DVR_SUCCESS On success
441 * \return Error code
442 */
hualing chen040df222020-01-17 13:35:02 +0800443int dvr_playback_video_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800444
445/**\brief Pause play
446 * \param[in] handle playback handle
447 * \param[in] flush whether its internal buffers should be flushed
448 * \retval DVR_SUCCESS On success
449 * \return Error code
450 */
hualing chen040df222020-01-17 13:35:02 +0800451int dvr_playback_pause(DVR_PlaybackHandle_t handle, DVR_Bool_t flush);
hualing chenb31a6c62020-01-13 17:27:00 +0800452
hualing chen31140872020-03-25 12:29:26 +0800453/**\brief resume play
454 * \param[in] handle playback handle
455 * \retval DVR_SUCCESS On success
456 * \return Error code
457 */
458int dvr_playback_resume(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800459
hualing chen03fd4942021-07-15 15:56:41 +0800460/**\brief set limit
461 * \param[in] handle playback handle
462 * \param[in] rec start time ms
463 * \param[in] rec limit time ms
464 * \retval DVR_SUCCESS On success
465 * \return Error code
466 */
467int dvr_playback_setlimit(DVR_PlaybackHandle_t handle, uint64_t time, int32_t limit);
468
Gong Ke497c4c22020-03-20 10:15:42 +0800469/**\brief Seek the playing position
hualing chenb31a6c62020-01-13 17:27:00 +0800470 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800471 * \param[in] segment_id the segment's index
hualing chen040df222020-01-17 13:35:02 +0800472 * \param[in] time_offset time offset base cur segment
hualing chenb31a6c62020-01-13 17:27:00 +0800473 * \retval DVR_SUCCESS On success
474 * \return Error code
475 */
hualing chencc91e1c2020-02-28 13:26:17 +0800476int dvr_playback_seek(DVR_PlaybackHandle_t handle, uint64_t segment_id, uint32_t time_offset);
hualing chenb31a6c62020-01-13 17:27:00 +0800477
478/**\brief Set play speed
479 * \param[in] handle playback handle
480 * \param[in] speed playback speed
481 * \retval DVR_SUCCESS On success
482 * \return Error code
483 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800484int dvr_playback_set_speed(DVR_PlaybackHandle_t handle, DVR_PlaybackSpeed_t speed);
hualing chenb31a6c62020-01-13 17:27:00 +0800485
486/**\brief Get playback status
487 * \param[in] handle playback handle
488 * \param[out] p_status playback status
489 * \retval DVR_SUCCESS On success
490 * \return Error code
491 */
hualing chen040df222020-01-17 13:35:02 +0800492int dvr_playback_get_status(DVR_PlaybackHandle_t handle, DVR_PlaybackStatus_t *p_status);
hualing chenb31a6c62020-01-13 17:27:00 +0800493
494/**\brief Get playback capabilities
495 * \param[out] p_capability playback capability
496 * \retval DVR_SUCCESS On success
497 * \return Error code
498 */
hualing chen040df222020-01-17 13:35:02 +0800499int dvr_playback_get_capabilities(DVR_PlaybackCapability_t *p_capability);
hualing chenb31a6c62020-01-13 17:27:00 +0800500
hualing chen040df222020-01-17 13:35:02 +0800501/**\brief dump segmentinfo throw print log
Gong Ke497c4c22020-03-20 10:15:42 +0800502 * \param[in] handle playback
503 * \param[in] segment_id if segment_id > 0, only dump this log. else dump all segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800504 * \retval DVR_SUCCESS On success
505 * \return Error code
506 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800507int dvr_dump_segmentinfo(DVR_PlaybackHandle_t handle, uint64_t segment_id);
hualing chenb31a6c62020-01-13 17:27:00 +0800508
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800509/**\brief Set DVR playback decrypt function
510 * \param[in] handle, DVR playback session handle
511 * \param[in] func, DVR playback encrypt function
512 * \param[in] userdata, DVR playback userdata from the caller
513 * \return DVR_SUCCESS on success
514 * \return error code on failure
515 */
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800516int dvr_playback_set_decrypt_callback(DVR_PlaybackHandle_t handle, DVR_CryptoFunction_t func, void *userdata);
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800517
518/**\brief Set DVR playback secure buffer used for protect the secure content
519 * \param[in] handle, DVR playback session handle
520 * \param[in] p_secure_buf, Secure buffer address which can NOT access by ACPU
521 * \param[in] len, Secure buffer length
522 * \return DVR_SUCCESS on success
523 * \return error code on failure
524 */
525int dvr_playback_set_secure_buffer(DVR_PlaybackHandle_t handle, uint8_t *p_secure_buf, uint32_t len);
526
hualing chen03fd4942021-07-15 15:56:41 +0800527/**\brief set DVR playback calculate expired time len
528 * \param[in] handle, DVR playback session handle
529 * \return DVR_SUCCESS on success
530 * \return error code on failure
531 */
532int dvr_playback_calculate_expiredlen(DVR_PlaybackHandle_t handle);
533
534/**\brief set DVR playback obsolete time
535 * \param[in] handle, DVR playback session handle
536 * \param[in] obsolete, obsolete len
537 * \return DVR_SUCCESS on success
538 * \return error code on failure
539 */
540int dvr_playback_set_obsolete(DVR_PlaybackHandle_t handle, int obsolete);
541
542/**\brief update DVR playback newest segment duration
543 * \param[in] handle, DVR playback session handle
544 * \param[in] segmentid, newest segment id
545 * \param[in] dur dur time ms
546 * \return DVR_SUCCESS on success
547 * \return error code on failure
548 */
549int dvr_playback_update_duration(DVR_PlaybackHandle_t handle,
550uint64_t segmentid, int dur);
551
552/**\brief check DVR playback is set limit info
553 * \param[in] handle, DVR playback session handle
554 * \return DVR_FALSE or DVR_TRUE
555 */
556DVR_Bool_t dvr_playback_check_limit(DVR_PlaybackHandle_t handle);
557
hualing chenb31a6c62020-01-13 17:27:00 +0800558#ifdef __cplusplus
559}
560#endif
561
562#endif /*END DVR_PLAYBACK_H_*/