blob: 1b25de078dc0306560ac827c3e54ef60437a3e7b [file] [log] [blame]
Gong Ke80b8d2a2020-02-04 18:34:35 +08001/**
Gong Ke497c4c22020-03-20 10:15:42 +08002 * \mainpage Amlogic DVR library
3 *
4 * \section Introduction
5 * "libdvr" is a library provides basic DVR functions used by Amlogic platform.
6 * It supports:
7 * \li Record
8 * \li Playback
9 * \li Index file generated
10 * \li Segment split
11 * \li Encrypt and decrypt
12 * \endsection
13 *
Gong Ke80b8d2a2020-02-04 18:34:35 +080014 * \file
Gong Ke497c4c22020-03-20 10:15:42 +080015 * \brief libdvr wrapper layer
16 *
17 * Wrapper layer is upper layer of libdvr.
18 * It is on top of dvr_record and dvr_playback.
19 * It supports:
20 * \li Separate record segments automatically.
21 * \li Load segments automatically.
Gong Ke80b8d2a2020-02-04 18:34:35 +080022 */
23
24#ifndef DVR_WRAPPER_H_
25#define DVR_WRAPPER_H_
26
27#include "dvr_types.h"
28#include "dvr_crypto.h"
29#include "dvr_playback.h"
30#include "dvr_record.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/**Record wrapper handle.*/
37typedef void* DVR_WrapperRecord_t;
38/**Playback wrapper handle.*/
39typedef void* DVR_WrapperPlayback_t;
40
41/**Record wrapper open parameters.*/
42typedef struct {
43 int dmx_dev_id; /**< Demux device's index.*/
44 char location[DVR_MAX_LOCATION_SIZE]; /**< Location of the record file.*/
45 DVR_Bool_t is_timeshift; /**< The record file is used by timeshift.*/
46 loff_t segment_size; /**< Segment file's size.*/
47 size_t max_size; /**< Maximum record file size in bytes.*/
48 int max_time; /**< Maximum record time in seconds.*/
49 DVR_RecordFlag_t flags; /**< Flags.*/
50 DVR_CryptoPeriod_t crypto_period; /**< Crypto period.*/
51 DVR_CryptoFunction_t crypto_fn; /**< Crypto callback function.*/
52 void *crypto_data; /**< User data of crypto function.*/
53} DVR_WrapperRecordOpenParams_t;
54
55/**Record start parameters.*/
56typedef struct {
57 uint32_t nb_pids; /**< Number of PIDs.*/
58 DVR_StreamPid_t pids[DVR_MAX_RECORD_PIDS_COUNT]; /**< PIDs to be recorded.*/
59} DVR_WrapperRecordStartParams_t;
60
61/**Update PID parameters.*/
62typedef struct {
63 uint32_t nb_pids; /**< Number of PID actions.*/
64 DVR_StreamPid_t pids[DVR_MAX_RECORD_PIDS_COUNT]; /**< PIDs.*/
65 DVR_RecordPidAction_t pid_action[DVR_MAX_RECORD_PIDS_COUNT]; /**< Actions.*/
66} DVR_WrapperUpdatePidsParams_t;
67
68/**Playback wrapper open parameters.*/
69typedef struct {
70 int dmx_dev_id; /**< playback used dmx device index*/
71 char location[DVR_MAX_LOCATION_SIZE]; /**< Location of the record file.*/
72 int block_size; /**< playback inject block size*/
73 DVR_Bool_t is_timeshift; /**< 0:playback mode, 1 : is timeshift mode*/
74 Playback_DeviceHandle_t playback_handle; /**< Playback device handle.*/
75 DVR_CryptoFunction_t crypto_fn; /**< Crypto function.*/
76 void *crypto_data; /**< Crypto function's user data.*/
77} DVR_WrapperPlaybackOpenParams_t;
78
79/**
80 * Open a new record wrapper.
81 * \param[out] rec Return the new record handle.
82 * \param params Record open parameters.
83 * \retval DVR_SUCCESS On success.
84 * \return Error code.
85 */
86int dvr_wrapper_open_record (DVR_WrapperRecord_t *rec, DVR_WrapperRecordOpenParams_t *params);
87
88/**
89 * Close an unused record wrapper.
90 * \param rec The record handle.
91 * \retval DVR_SUCCESS On success.
92 * \return Error code.
93 */
94int dvr_wrapper_close_record (DVR_WrapperRecord_t rec);
95
96/**
97 * Start recording.
98 * \param rec The record handle.
99 * \param params Record start parameters.
100 * \retval DVR_SUCCESS On success.
101 * \return Error code.
102 */
103int dvr_wrapper_start_record (DVR_WrapperRecord_t rec, DVR_WrapperRecordStartParams_t *params);
104
105/**
106 * Stop recording..
107 * \param rec The record handle.
108 * \retval DVR_SUCCESS On success.
109 * \return Error code.
110 */
111int dvr_wrapper_stop_record (DVR_WrapperRecord_t rec);
112
113/**
114 * Update the recording PIDs.
115 * \param rec The record handle.
116 * \param params The new PIDs.
117 * \retval DVR_SUCCESS On success.
118 * \return Error code.
119 */
120int dvr_wrapper_update_record_pids (DVR_WrapperRecord_t rec, DVR_WrapperUpdatePidsParams_t *params);
121
122/**
123 * Open a new playback wrapper handle.
124 * \param[out] playback Return the new playback handle.
125 * \param params Playback handle open parameters.
126 * \retval DVR_SUCCESS On success.
127 * \return Error code.
128 */
129int dvr_wrapper_open_playback (DVR_WrapperPlayback_t *playback, DVR_WrapperPlaybackOpenParams_t *params);
130
131/**
132 * Close a unused playback handle.
133 * \param playback The playback handle to be closed.
134 * \retval DVR_SUCCESS On success.
135 * \return Error code.
136 */
137int dvr_wrapper_close_playback (DVR_WrapperPlayback_t playback);
138
139/**
140 * Start playback.
141 * \param playback The playback handle.
142 * \param flags Playback flags.
143 * \retval DVR_SUCCESS On success.
144 * \return Error code.
145 */
146int dvr_wrapper_start_playback (DVR_WrapperPlayback_t playback, DVR_PlaybackFlag_t flags);
147
148/**
149 * Stop playback.
150 * \param playback The playback handle.
151 * \retval DVR_SUCCESS On success.
152 * \return Error code.
153 */
154int dvr_wrapper_stop_playback (DVR_WrapperPlayback_t playback);
155
156/**
157 * Pause the playback.
158 * \param playback The playback handle.
159 * \retval DVR_SUCCESS On success.
160 * \return Error code.
161 */
162int dvr_wrapper_pause_playback (DVR_WrapperPlayback_t playback);
163
164/**
165 * Set the playback speed.
166 * \param playback The playback handle.
167 * \param speed The new speed.
168 * \retval DVR_SUCCESS On success.
169 * \return Error code.
170 */
171int dvr_wrapper_set_playback_speed (DVR_WrapperPlayback_t playback, Playback_DeviceSpeeds_t speed);
172
173/**
174 * Seek the current playback position.
175 * \param playback The playback handle.
176 * \param time_offset The current time in milliseconds.
177 * \retval DVR_SUCCESS On success.
178 * \return Error code.
179 */
180int dvr_wrapper_seek_playback (DVR_WrapperPlayback_t playback, int time_offset);
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif /*DVR_WRAPPER_H_*/
187