blob: 12515a5316fe608c3c7a49d4592bbdd092823b91 [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; /**< ??? */
54} DVR_PlaybackSegmentInfo_t;
hualing chenb31a6c62020-01-13 17:27:00 +080055
56/**\brief play flag, if set this flag, player need pause when decode first frame */
57typedef enum
58{
Gong Ke3489c0f2020-01-16 18:11:44 +080059 DVR_PLAYBACK_STARTED_PAUSEDLIVE = (1 << 0) /**< dvr play stat,need change to pause state if set */
60} DVR_PlaybackFlag_t;
hualing chen86e7d482020-01-16 15:13:33 +080061
62/**\brief playback speed mode*/
hualing chenb31a6c62020-01-13 17:27:00 +080063typedef enum
64{
Gong Ke3489c0f2020-01-16 18:11:44 +080065 DVR_PLAYBACK_FAST_FORWARD = 0, /**< fast forward */
66 DVR_PLAYBACK_FAST_BACKWARD = 1, /**< fast backward */
hualing chen31140872020-03-25 12:29:26 +080067 DVR_PLAYBACK_KERNEL_SUPPORT = 2, /**< kernel support mode */
Gong Ke3489c0f2020-01-16 18:11:44 +080068} DVR_PlaybackSpeedMode_t;
hualing chenb31a6c62020-01-13 17:27:00 +080069
hualing chen2aba4022020-03-02 13:49:55 +080070/**\brief playback speed*/
71typedef enum
72{
hualing chena540a7e2020-03-27 16:44:05 +080073 PLAYBACK_SPEED_FBX2 = -200, /**<FB X 2 speed*/
74 PLAYBACK_SPEED_FBX4 = -400, /**<FB X 4 speed*/
75 PLAYBACK_SPEED_FBX8 = -800, /**<FB X 8 speed*/
hualing chen041c4092020-04-05 15:11:50 +080076 PLAYBACK_SPEED_FBX12 = -1200, /**< FB 12 speed*/
77 PLAYBACK_SPEED_FBX16 = -1600, /**<FB X 16 speed*/
78 PLAYBACK_SPEED_FBX32 = -3200, /**<FB X 32 speed*/
79 PLAYBACK_SPEED_FBX48 = -4800, /**<FB X 48 speed*/
80 PLAYBACK_SPEED_FBX64 = -6400, /**<FB X 64 speed*/
81 PLAYBACK_SPEED_FBX128 = -12800, /**<FB X 128 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080082 PLAYBACK_SPEED_S8 = 12, /**<slow 1/8 speed*/
83 PLAYBACK_SPEED_S4 = 25, /**<slow 1/4 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080084 PLAYBACK_SPEED_S2 = 50, /**<slow 1/2 speed*/
85 PLAYBACK_SPEED_X1 = 100, /**< X 1 normal speed*/
86 PLAYBACK_SPEED_X2 = 200, /**< X 2 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080087 PLAYBACK_SPEED_X3 = 300, /**< X 3 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080088 PLAYBACK_SPEED_X4 = 400, /**< X 4 speed*/
hualing chena540a7e2020-03-27 16:44:05 +080089 PLAYBACK_SPEED_X5 = 500, /**< X 5 speed*/
90 PLAYBACK_SPEED_X6 = 600, /**< X 6 speed*/
91 PLAYBACK_SPEED_X7 = 700, /**< X 7 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080092 PLAYBACK_SPEED_X8 = 800, /**< X 8 speed*/
hualing chen041c4092020-04-05 15:11:50 +080093 PLAYBACK_SPEED_X12 = 1200, /**< X 12 speed*/
94 PLAYBACK_SPEED_X16 = 1600, /**< X 16 speed*/
95 PLAYBACK_SPEED_X32 = 3200, /**< X 32 speed*/
96 PLAYBACK_SPEED_X48 = 4800, /**< X 48 speed*/
97 PLAYBACK_SPEED_X64 = 6400, /**< X 64 speed*/
98 PLAYBACK_SPEED_X128 = 12800, /**< X 128 speed*/
hualing chen2aba4022020-03-02 13:49:55 +080099 PlayBack_Speed_MAX,
100} Playback_SpeedValue_t;
101
Gong Ke497c4c22020-03-20 10:15:42 +0800102/**\brief playback speed*/
hualing chen2aba4022020-03-02 13:49:55 +0800103typedef struct Playback_Speeds_s {
Gong Ke497c4c22020-03-20 10:15:42 +0800104 int speed; /**< playback speed value*/
hualing chen2aba4022020-03-02 13:49:55 +0800105} Playback_Speeds_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800106
Gong Ke3489c0f2020-01-16 18:11:44 +0800107/**\brief playback play speed*/
hualing chenb31a6c62020-01-13 17:27:00 +0800108typedef struct
109{
hualing chen2aba4022020-03-02 13:49:55 +0800110 Playback_Speeds_t speed; /**< playback speed */
Gong Ke3489c0f2020-01-16 18:11:44 +0800111 DVR_PlaybackSpeedMode_t mode; /**< playback 0: fast forword or 1: fast backword*/
112} DVR_PlaybackSpeed_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800113
hualing chen2aba4022020-03-02 13:49:55 +0800114
Gong Ke3489c0f2020-01-16 18:11:44 +0800115/**Maximum supported speed modes.*/
hualing chenb31a6c62020-01-13 17:27:00 +0800116#define DVR_MAX_SUPPORTED_SPEEDS 32
Gong Ke3489c0f2020-01-16 18:11:44 +0800117
hualing chenb31a6c62020-01-13 17:27:00 +0800118/**\brief playback capability*/
119typedef struct
120{
hualing chen86e7d482020-01-16 15:13:33 +0800121 int nb_supported_speeds; /**< support playback speed count*/
122 int supported_speeds[DVR_MAX_SUPPORTED_SPEEDS]; /**< support playback speed*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800123} DVR_PlaybackCapability_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800124
Gong Ke3489c0f2020-01-16 18:11:44 +0800125/**Playback handle.*/
126typedef void* DVR_PlaybackHandle_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800127
hualing chencc91e1c2020-02-28 13:26:17 +0800128
129/**\brief playback error reason*/
130typedef enum
131{
132 DVR_PLAYBACK_PID_ERROR, /**< uninit state */
133 DVR_PLAYBACK_FMT_ERROR /**< fmt not surport backword */
134} DVR_PlaybackError_t;
135
136
hualing chenb31a6c62020-01-13 17:27:00 +0800137/**\brief playback play state*/
138typedef enum
139{
Gong Ke3489c0f2020-01-16 18:11:44 +0800140 DVR_PLAYBACK_STATE_START, /**< start play */
141 DVR_PLAYBACK_STATE_STOP, /**< stop */
142 DVR_PLAYBACK_STATE_PAUSE, /**< pause */
143 DVR_PLAYBACK_STATE_FF, /**< fast forward */
144 DVR_PLAYBACK_STATE_FB /**< fast backword */
145} DVR_PlaybackPlayState_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800146
147/**\brief playback play status*/
148typedef struct
149{
Gong Ke3489c0f2020-01-16 18:11:44 +0800150 DVR_PlaybackPlayState_t state; /**< playback play state */
hualing chen5cbe1a62020-02-10 16:36:36 +0800151 uint64_t segment_id; /**< playback ongoing segment index */
hualing chencc91e1c2020-02-28 13:26:17 +0800152 uint32_t time_cur; /**< playback cur time,0 <--> time_end Ms*/
153 uint32_t time_end; /**< playback ongoing segment dur,Ms */
Gong Ke3489c0f2020-01-16 18:11:44 +0800154 DVR_PlaybackPids_t pids; /**< playback played pids */
hualing chen5cbe1a62020-02-10 16:36:36 +0800155 int speed; /**< playback speed */
156 DVR_PlaybackSegmentFlag_t flags; /**< playback played segment flag */
Gong Ke3489c0f2020-01-16 18:11:44 +0800157} DVR_PlaybackStatus_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800158
hualing chencc91e1c2020-02-28 13:26:17 +0800159/**\brief DVR playback event*/
160typedef enum {
161 DVR_PLAYBACK_EVENT_ERROR = 0x1000, /**< Signal a critical playback error*/
162 DVR_PLAYBACK_EVENT_TRANSITION_OK , /**< transition ok*/
163 DVR_PLAYBACK_EVENT_TRANSITION_FAILED, /**< transition failed*/
164 DVR_PLAYBACK_EVENT_KEY_FAILURE, /**< key failure*/
165 DVR_PLAYBACK_EVENT_NO_KEY, /**< no key*/
166 DVR_PLAYBACK_EVENT_REACHED_BEGIN , /**< reached begin*/
hualing chen2aba4022020-03-02 13:49:55 +0800167 DVR_PLAYBACK_EVENT_REACHED_END, /**< reached end*/
hualing chen6e4bfa52020-03-13 14:37:11 +0800168 DVR_PLAYBACK_EVENT_NOTIFY_PLAYTIME, /**< notify play cur segmeng time ms*/
hualing chen2aba4022020-03-02 13:49:55 +0800169 DVR_PLAYBACK_EVENT_FIRST_FRAME /**< first frame*/
hualing chencc91e1c2020-02-28 13:26:17 +0800170} DVR_PlaybackEvent_t;
171
172/**\brief DVR playback event notify function*/
173typedef struct
174{
Gong Ke497c4c22020-03-20 10:15:42 +0800175 DVR_PlaybackEvent_t event; /**< event type*/
176 DVR_PlaybackStatus_t play_status; /**< play status*/
hualing chencc91e1c2020-02-28 13:26:17 +0800177 union
178 {
Gong Ke497c4c22020-03-20 10:15:42 +0800179 uint8_t unused;
180 uint8_t error_reason;/**< error reason*/
hualing chencc91e1c2020-02-28 13:26:17 +0800181 struct
182 {
Gong Ke497c4c22020-03-20 10:15:42 +0800183 uint64_t segment_id; /**< error segment id*/
184 uint32_t key_data_id; /**< key data id*/
185 uint8_t error; /**< error*/
hualing chencc91e1c2020-02-28 13:26:17 +0800186 } transition_failed_data;
Gong Ke497c4c22020-03-20 10:15:42 +0800187 } info; /**< information*/
hualing chencc91e1c2020-02-28 13:26:17 +0800188} DVR_Play_Notify_t;
189
190/**\brief DVR playback event notify function*/
191typedef DVR_Result_t (*DVR_PlaybackEventFunction_t) (DVR_PlaybackEvent_t event, void *params, void *userdata);
192
193
hualing chenb31a6c62020-01-13 17:27:00 +0800194/**\brief playback open params*/
195typedef struct
196{
Gong Ke3489c0f2020-01-16 18:11:44 +0800197 int dmx_dev_id; /**< playback used dmx device index*/
198 int block_size; /**< playback inject block size*/
199 DVR_Bool_t is_timeshift; /**< 0:playback mode, 1 : is timeshift mode*/
hualing chen2aba4022020-03-02 13:49:55 +0800200 am_tsplayer_handle player_handle; /**< am tsplayer handle.*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800201 DVR_CryptoFunction_t crypto_fn; /**< Crypto function.*/
202 void *crypto_data; /**< Crypto function's user data.*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800203 DVR_Bool_t has_pids; /**< has video audo pid fmt info*/
hualing chencc91e1c2020-02-28 13:26:17 +0800204 DVR_PlaybackEventFunction_t event_fn; /**< playback event callback function*/
205 void *event_userdata; /**< event userdata*/
Gong Ke3489c0f2020-01-16 18:11:44 +0800206} DVR_PlaybackOpenParams_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800207
208/**\brief playback play state*/
209typedef enum
210{
hualing chen040df222020-01-17 13:35:02 +0800211 DVR_PLAYBACK_CMD_START, /**< start av */
212 DVR_PLAYBACK_CMD_STOP, /**< stop av */
213 DVR_PLAYBACK_CMD_VSTART, /**< v start */
214 DVR_PLAYBACK_CMD_ASTART , /**< a start */
215 DVR_PLAYBACK_CMD_VSTOP , /**< v stop */
216 DVR_PLAYBACK_CMD_ASTOP, /**< a stop */
217 DVR_PLAYBACK_CMD_VRESTART, /**< v restart */
218 DVR_PLAYBACK_CMD_ARESTART, /**< a restart */
hualing chen5cbe1a62020-02-10 16:36:36 +0800219 DVR_PLAYBACK_CMD_AVRESTART, /**< av restart */
hualing chen040df222020-01-17 13:35:02 +0800220 DVR_PLAYBACK_CMD_VSTOPASTART, /**< v stop a start*/
221 DVR_PLAYBACK_CMD_ASTOPVSTART, /**< a stop vstart */
222 DVR_PLAYBACK_CMD_VSTOPARESTART, /**<v stop a restart*/
223 DVR_PLAYBACK_CMD_ASTOPVRESTART, /**<a stop v restart*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800224 DVR_PLAYBACK_CMD_VSTARTARESTART, /**<v start a restart*/
225 DVR_PLAYBACK_CMD_ASTARTVRESTART, /**<a start v restart*/
hualing chen040df222020-01-17 13:35:02 +0800226 DVR_PLAYBACK_CMD_PAUSE, /**< pause */
227 DVR_PLAYBACK_CMD_RESUME, /**< resume */
228 DVR_PLAYBACK_CMD_SEEK, /**< seek */
229 DVR_PLAYBACK_CMD_FF, /**< fast forward */
230 DVR_PLAYBACK_CMD_FB, /**< fast backword */
hualing chen5cbe1a62020-02-10 16:36:36 +0800231 DVR_PLAYBACK_CMD_NONE, /**< none */
hualing chen040df222020-01-17 13:35:02 +0800232} DVR_PlaybackCmd_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800233
234
235/**\brief playback struct*/
236typedef struct
237{
hualing chen5cbe1a62020-02-10 16:36:36 +0800238 DVR_PlaybackSpeed_t speed; /**< play speed */
239 DVR_PlaybackPlayState_t state; /**< play state */
hualing chen040df222020-01-17 13:35:02 +0800240 DVR_PlaybackCmd_t cur_cmd; /**< cur send cmd */
241 DVR_PlaybackCmd_t last_cmd; /**< last cmd */
242 int pos; /**< seek pos at cur segment*/
243} DVR_PlaybackCmdInfo_t;
hualing chenb31a6c62020-01-13 17:27:00 +0800244
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800245/**\brief DVR playback decrypt function*/
246typedef DVR_Result_t (*DVR_PlaybackDecryptFunction_t) (uint8_t *p_in,
247 uint32_t in_len,
248 uint8_t *p_out,
249 uint32_t *p_out_len,
250 void *userdata);
hualing chenb31a6c62020-01-13 17:27:00 +0800251
Gong Ke497c4c22020-03-20 10:15:42 +0800252/**\cond */
hualing chenb31a6c62020-01-13 17:27:00 +0800253/**\brief playback struct*/
254typedef struct
255{
hualing chen2aba4022020-03-02 13:49:55 +0800256 am_tsplayer_handle handle; /**< tsplayer handle */
hualing chencc91e1c2020-02-28 13:26:17 +0800257 DVR_Bool_t segment_is_open; /**<segment is opend*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800258 uint64_t cur_segment_id; /**< Current segment id*/
hualing chen040df222020-01-17 13:35:02 +0800259 DVR_PlaybackSegmentInfo_t cur_segment; /**< Current playing segment*/
hualing chencc91e1c2020-02-28 13:26:17 +0800260 uint64_t last_segment_id; /**< last segment id*/
261 DVR_PlaybackSegmentInfo_t last_segment; /**< last playing segment*/
hualing chen040df222020-01-17 13:35:02 +0800262 struct list_head segment_list; /**< segment list head*/
263 pthread_t playback_thread; /**< playback thread*/
264 pthread_mutex_t lock; /**< playback lock*/
hualing chen2aba4022020-03-02 13:49:55 +0800265 pthread_mutex_t segment_lock; /**< playback segment lock*/
hualing chen040df222020-01-17 13:35:02 +0800266 pthread_cond_t cond; /**< playback cond*/
267 void *user_data; /**< playback userdata, used to send event*/
hualing chen6d24aa92020-03-23 18:43:47 +0800268 float speed; /**< playback speed*/
hualing chen040df222020-01-17 13:35:02 +0800269 DVR_PlaybackPlayState_t state; /**< playback state*/
270 DVR_PlaybackFlag_t play_flag; /**< playback play flag*/
hualing chen86e7d482020-01-16 15:13:33 +0800271 int is_running; /**< playback htread is runing*/
hualing chen040df222020-01-17 13:35:02 +0800272 DVR_PlaybackCmdInfo_t cmd; /**< playback cmd*/
273 int offset; /**< segment read offset*/
hualing chencc91e1c2020-02-28 13:26:17 +0800274 uint32_t dur; /**< segment dur*/
hualing chen86e7d482020-01-16 15:13:33 +0800275 Segment_Handle_t r_handle; /**< playback current segment handle*/
hualing chen040df222020-01-17 13:35:02 +0800276 DVR_PlaybackOpenParams_t openParams; /**< playback openParams*/
hualing chen86e7d482020-01-16 15:13:33 +0800277 DVR_Bool_t has_video; /**< has video playing*/
278 DVR_Bool_t has_audio; /**< has audio playing*/
hualing chendf118dd2020-05-21 15:49:11 +0800279 DVR_Bool_t has_ad_audio; /**< has ad audio playing*/
hualing chen5cbe1a62020-02-10 16:36:36 +0800280 DVR_Bool_t has_pids; /**< has video audo pid fmt info*/
281 int fffb_start; /**< fffb start time ms*/
282 int fffb_current; /**< fffb current time*/
283 int fffb_start_pcr; /**< fffb start pcr time*/
hualing chena540a7e2020-03-27 16:44:05 +0800284 int next_fffb_time;/**< fffb start pcr time*/
285 int seek_time;/**< fffb start pcr time*/
286 event_callback player_callback_func;/**< tsplayer cb*/
287 void *player_callback_userdata;/**< tsplayer cb data*/
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800288 int send_time;/**< send event time*/
289 int first_frame;/**< show first frame*/
290 DVR_CryptoFunction_t dec_func; /**< Decrypt function*/
291 void *dec_userdata; /**< Decrypt userdata*/
292 int is_secure_mode; /**< Playback session run in secure pipeline */
293 uint8_t *secure_buffer; /* Playback session secure buffer */
294 uint32_t secure_buffer_size; /* Playback session secure buffer size */
hualing chen266b9502020-04-04 17:39:39 +0800295 DVR_Bool_t drop_ts;
hualing chen4b7c15d2020-04-07 16:13:48 +0800296 DVR_Bool_t fffb_play;
297 int32_t last_cur_time;
298 uint64_t last_send_time_id;
hualing chen5605eed2020-05-26 18:18:06 +0800299 int ts_cache_len;
hualing chen040df222020-01-17 13:35:02 +0800300} DVR_Playback_t;
Gong Ke497c4c22020-03-20 10:15:42 +0800301/**\endcond*/
hualing chenb31a6c62020-01-13 17:27:00 +0800302
303/**\brief Open an dvr palyback
304 * \param[out] p_handle dvr playback addr
305 * \param[in] params dvr playback open parameters
306 * \retval DVR_SUCCESS On success
307 * \return Error code
308 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800309int dvr_playback_open(DVR_PlaybackHandle_t *p_handle, DVR_PlaybackOpenParams_t *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800310
311/**\brief Close an dvr palyback
312 * \param[in] handle playback handle
313 * \retval DVR_SUCCESS On success
314 * \return Error code
315 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800316int dvr_playback_close(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800317
318
319/**\brief Start play audio and video, used start auido api and start video api
320 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800321 * \param[in] flag playback flag
hualing chenb31a6c62020-01-13 17:27:00 +0800322 * \retval DVR_SUCCESS On success
323 * \return Error code
324 */
Gong Ke3489c0f2020-01-16 18:11:44 +0800325int dvr_playback_start(DVR_PlaybackHandle_t handle, DVR_PlaybackFlag_t flag);
hualing chenb31a6c62020-01-13 17:27:00 +0800326
hualing chen040df222020-01-17 13:35:02 +0800327/**\brief dvr play back add segment info to segment list
hualing chenb31a6c62020-01-13 17:27:00 +0800328 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800329 * \param[in] info added segment info,con vpid fmt apid fmt.....
hualing chenb31a6c62020-01-13 17:27:00 +0800330 * \retval DVR_SUCCESS On success
331 * \return Error code
332 */
hualing chen040df222020-01-17 13:35:02 +0800333int dvr_playback_add_segment(DVR_PlaybackHandle_t handle, DVR_PlaybackSegmentInfo_t *info);
hualing chenb31a6c62020-01-13 17:27:00 +0800334
hualing chen040df222020-01-17 13:35:02 +0800335/**\brief dvr play back remove segment info by segmentkid
hualing chenb31a6c62020-01-13 17:27:00 +0800336 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800337 * \param[in] segmentid need removed segment id
hualing chenb31a6c62020-01-13 17:27:00 +0800338 * \retval DVR_SUCCESS On success
339 * \return Error code
340 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800341int dvr_playback_remove_segment(DVR_PlaybackHandle_t handle, uint64_t segmentid);
hualing chenb31a6c62020-01-13 17:27:00 +0800342
hualing chen040df222020-01-17 13:35:02 +0800343/**\brief dvr play back add segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800344 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800345 * \param[in] segment_id the segment's index
346 * \param[in] flags the segment's flags
hualing chenb31a6c62020-01-13 17:27:00 +0800347 * \retval DVR_SUCCESS On success
348 * \return Error code
349 */
hualing chen040df222020-01-17 13:35:02 +0800350int dvr_playback_update_segment_flags(DVR_PlaybackHandle_t handle,
hualing chen5cbe1a62020-02-10 16:36:36 +0800351 uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800352 DVR_PlaybackSegmentFlag_t flags);
Gong Ke497c4c22020-03-20 10:15:42 +0800353
hualing chen040df222020-01-17 13:35:02 +0800354/**\brief dvr play back up1date segment pids
355 * if updated segment is ongoing segment, we need start new
hualing chenb31a6c62020-01-13 17:27:00 +0800356 * add pid stream and stop remove pid stream.
357 * \param[in] handle playback handle
hualing chen040df222020-01-17 13:35:02 +0800358 * \param[in] segment_id need updated pids segment id
Gong Ke497c4c22020-03-20 10:15:42 +0800359 * \param[in] p_pids the new PIDs
hualing chenb31a6c62020-01-13 17:27:00 +0800360 * \retval DVR_SUCCESS On success
361 * \return Error code
362 */
Gong Ke497c4c22020-03-20 10:15:42 +0800363int dvr_playback_update_segment_pids(DVR_PlaybackHandle_t handle, uint64_t segment_id,
hualing chen040df222020-01-17 13:35:02 +0800364DVR_PlaybackPids_t *p_pids);
hualing chenb31a6c62020-01-13 17:27:00 +0800365
Gong Ke497c4c22020-03-20 10:15:42 +0800366/**\brief Stop playing, will stop video and audio
hualing chenb31a6c62020-01-13 17:27:00 +0800367 * \param[in] handle playback handle
368 * \param[in] clear is clear last frame
369 * \retval DVR_SUCCESS On success
370 * \return Error code
371 */
hualing chen040df222020-01-17 13:35:02 +0800372int dvr_playback_stop(DVR_PlaybackHandle_t handle, DVR_Bool_t clear);
hualing chenb31a6c62020-01-13 17:27:00 +0800373
Gong Ke497c4c22020-03-20 10:15:42 +0800374/**\brief Start audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800375 * \param[in] handle playback handle
376 * \param[in] params audio playback params,contains fmt and pid...
hualing chendf118dd2020-05-21 15:49:11 +0800377 * \param[in] adparams ad audio playback params,contains fmt and pid...
hualing chenb31a6c62020-01-13 17:27:00 +0800378 * \retval DVR_SUCCESS On success
379 * \return Error code
380 */
hualing chendf118dd2020-05-21 15:49:11 +0800381int dvr_playback_audio_start(DVR_PlaybackHandle_t handle, am_tsplayer_audio_params *param, am_tsplayer_audio_params *adparam);
382
hualing chenb31a6c62020-01-13 17:27:00 +0800383
Gong Ke497c4c22020-03-20 10:15:42 +0800384/**\brief Stop audio playing
hualing chenb31a6c62020-01-13 17:27:00 +0800385 * \param[in] handle playback handle
386 * \retval DVR_SUCCESS On success
387 * \return Error code
388 */
hualing chen040df222020-01-17 13:35:02 +0800389int dvr_playback_audio_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800390
Gong Ke497c4c22020-03-20 10:15:42 +0800391/**\brief Start video playing
hualing chenb31a6c62020-01-13 17:27:00 +0800392 * \param[in] handle playback handle
393 * \param[in] params video playback params,contains fmt and pid...
394 * \retval DVR_SUCCESS On success
395 * \return Error code
396 */
Gong Ke497c4c22020-03-20 10:15:42 +0800397int dvr_playback_video_start(DVR_PlaybackHandle_t handle, am_tsplayer_video_params *params);
hualing chenb31a6c62020-01-13 17:27:00 +0800398
399/**\brief Stop play video
400 * \param[in] handle playback handle
401 * \retval DVR_SUCCESS On success
402 * \return Error code
403 */
hualing chen040df222020-01-17 13:35:02 +0800404int dvr_playback_video_stop(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800405
406/**\brief Pause play
407 * \param[in] handle playback handle
408 * \param[in] flush whether its internal buffers should be flushed
409 * \retval DVR_SUCCESS On success
410 * \return Error code
411 */
hualing chen040df222020-01-17 13:35:02 +0800412int dvr_playback_pause(DVR_PlaybackHandle_t handle, DVR_Bool_t flush);
hualing chenb31a6c62020-01-13 17:27:00 +0800413
hualing chen31140872020-03-25 12:29:26 +0800414/**\brief resume play
415 * \param[in] handle playback handle
416 * \retval DVR_SUCCESS On success
417 * \return Error code
418 */
419int dvr_playback_resume(DVR_PlaybackHandle_t handle);
hualing chenb31a6c62020-01-13 17:27:00 +0800420
Gong Ke497c4c22020-03-20 10:15:42 +0800421/**\brief Seek the playing position
hualing chenb31a6c62020-01-13 17:27:00 +0800422 * \param[in] handle playback handle
Gong Ke497c4c22020-03-20 10:15:42 +0800423 * \param[in] segment_id the segment's index
hualing chen040df222020-01-17 13:35:02 +0800424 * \param[in] time_offset time offset base cur segment
hualing chenb31a6c62020-01-13 17:27:00 +0800425 * \retval DVR_SUCCESS On success
426 * \return Error code
427 */
hualing chencc91e1c2020-02-28 13:26:17 +0800428int dvr_playback_seek(DVR_PlaybackHandle_t handle, uint64_t segment_id, uint32_t time_offset);
hualing chenb31a6c62020-01-13 17:27:00 +0800429
430/**\brief Set play speed
431 * \param[in] handle playback handle
432 * \param[in] speed playback speed
433 * \retval DVR_SUCCESS On success
434 * \return Error code
435 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800436int dvr_playback_set_speed(DVR_PlaybackHandle_t handle, DVR_PlaybackSpeed_t speed);
hualing chenb31a6c62020-01-13 17:27:00 +0800437
438/**\brief Get playback status
439 * \param[in] handle playback handle
440 * \param[out] p_status playback status
441 * \retval DVR_SUCCESS On success
442 * \return Error code
443 */
hualing chen040df222020-01-17 13:35:02 +0800444int dvr_playback_get_status(DVR_PlaybackHandle_t handle, DVR_PlaybackStatus_t *p_status);
hualing chenb31a6c62020-01-13 17:27:00 +0800445
446/**\brief Get playback capabilities
447 * \param[out] p_capability playback capability
448 * \retval DVR_SUCCESS On success
449 * \return Error code
450 */
hualing chen040df222020-01-17 13:35:02 +0800451int dvr_playback_get_capabilities(DVR_PlaybackCapability_t *p_capability);
hualing chenb31a6c62020-01-13 17:27:00 +0800452
hualing chen040df222020-01-17 13:35:02 +0800453/**\brief dump segmentinfo throw print log
Gong Ke497c4c22020-03-20 10:15:42 +0800454 * \param[in] handle playback
455 * \param[in] segment_id if segment_id > 0, only dump this log. else dump all segment info
hualing chenb31a6c62020-01-13 17:27:00 +0800456 * \retval DVR_SUCCESS On success
457 * \return Error code
458 */
hualing chen5cbe1a62020-02-10 16:36:36 +0800459int dvr_dump_segmentinfo(DVR_PlaybackHandle_t handle, uint64_t segment_id);
hualing chenb31a6c62020-01-13 17:27:00 +0800460
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800461/**\brief Set DVR playback decrypt function
462 * \param[in] handle, DVR playback session handle
463 * \param[in] func, DVR playback encrypt function
464 * \param[in] userdata, DVR playback userdata from the caller
465 * \return DVR_SUCCESS on success
466 * \return error code on failure
467 */
pengfei.liu27cc4ec2020-04-03 16:28:16 +0800468int dvr_playback_set_decrypt_callback(DVR_PlaybackHandle_t handle, DVR_CryptoFunction_t func, void *userdata);
pengfei.liu07ddc8a2020-03-24 23:36:53 +0800469
470/**\brief Set DVR playback secure buffer used for protect the secure content
471 * \param[in] handle, DVR playback session handle
472 * \param[in] p_secure_buf, Secure buffer address which can NOT access by ACPU
473 * \param[in] len, Secure buffer length
474 * \return DVR_SUCCESS on success
475 * \return error code on failure
476 */
477int dvr_playback_set_secure_buffer(DVR_PlaybackHandle_t handle, uint8_t *p_secure_buf, uint32_t len);
478
hualing chenb31a6c62020-01-13 17:27:00 +0800479#ifdef __cplusplus
480}
481#endif
482
483#endif /*END DVR_PLAYBACK_H_*/