blob: d660123b15ee1c90056236ba9fd05e4c5b6afb42 [file] [log] [blame]
Pengfei Liuc181a982020-01-07 19:27:13 +08001#ifndef _DVR_RECORD_H_
2#define _DVR_RECORD_H_
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
Pengfei Liub038b6a2020-01-14 15:57:01 +08008#include "dvr_types.h"
Pengfei Liu47ed6c92020-01-17 11:23:41 +08009#include "dvr_crypto.h"
Pengfei Liuc181a982020-01-07 19:27:13 +080010
Gong Ke3489c0f2020-01-16 18:11:44 +080011typedef void* DVR_RecordHandle_t;
Pengfei Liuc181a982020-01-07 19:27:13 +080012
13typedef enum {
Pengfei Liu47ed6c92020-01-17 11:23:41 +080014 DVR_RECORD_STATE_OPENED, /**< Record state is opened*/
15 DVR_RECORD_STATE_STARTED, /**< Record state is started*/
16 DVR_RECORD_STATE_STOPPED, /**< Record state is stopped*/
17 DVR_RECORD_STATE_CLOSED, /**< Record state is closed*/
18} DVR_RecordState_t;
Pengfei Liuc181a982020-01-07 19:27:13 +080019
20typedef enum
21{
Pengfei Liu47ed6c92020-01-17 11:23:41 +080022 DVR_RECORD_PID_CREATE, /**< Create a new pid used to record*/
23 DVR_RECORD_PID_KEEP, /**< Indicate this pid keep last state*/
24 DVR_RECORD_PID_CLOSE /**< Close this pid record*/
Pengfei Liuc181a982020-01-07 19:27:13 +080025} DVR_RecordPidAction_t;
26
Pengfei Liuc181a982020-01-07 19:27:13 +080027typedef enum {
28 DVR_RECORD_FLAG_SCRAMBLED = (1 << 0),
29 DVR_RECORD_FLAG_ACCURATE = (1 << 1),
30} DVR_RecordFlag_t;
31
32typedef enum {
Pengfei Liu47ed6c92020-01-17 11:23:41 +080033 DVR_CRYPTO_PARITY_CLEAR, /**< Current period is clear*/
34 DVR_CRYPTO_PARITY_ODD, /**< Current period is ODD*/
35 DVR_CRYPTO_PARITY_EVEN, /**< Current period is EVEN*/
Pengfei Liuc181a982020-01-07 19:27:13 +080036} DVR_CryptoParity_t;
37
38typedef enum {
Pengfei Liu47ed6c92020-01-17 11:23:41 +080039 DVR_CRYPTO_FILTER_TYPE_AUDIO, /**< Indicate current notification concerns audio packets*/
40 DVR_CRYPTO_FILTER_TYPE_VIDEO, /**< Indicate current notification concerns video packets*/
Pengfei Liuc181a982020-01-07 19:27:13 +080041} DVR_CryptoFilterType_t;
42
43typedef struct
44{
Pengfei Liu47ed6c92020-01-17 11:23:41 +080045 DVR_Bool_t transition; /**< DVR_TRUE is transition, DVR_FALSE is not transition. At the start of a recording this shall be set to DVR_TRUE*/
46 DVR_CryptoParity_t parity; /**< The crypto parity at the ts_offset*/
47 loff_t ts_offset; /**< TS packet offset correspongding to this crypto period*/
48 DVR_CryptoFilterType_t filter_type; /**< Indicate this notification concerns audio or video*/
Pengfei Liuc181a982020-01-07 19:27:13 +080049} DVR_CryptoPeriodInfo_t;
50
Pengfei Liu47ed6c92020-01-17 11:23:41 +080051#if 0
Pengfei Liuc181a982020-01-07 19:27:13 +080052typedef void (*DVR_CryptoPeriodNotifyFn_t)(
53 DVR_RecordHandle_t handle,
54 const DVR_CryptoPeriodInfo_t *p_info);
Pengfei Liu47ed6c92020-01-17 11:23:41 +080055#endif
Pengfei Liuc181a982020-01-07 19:27:13 +080056
57typedef struct {
Pengfei Liu47ed6c92020-01-17 11:23:41 +080058 //DVR_CryptoPeriodNotifyFn_t notify_func;
Pengfei Liuc181a982020-01-07 19:27:13 +080059 uint64_t interval_bytes;
Pengfei Liub038b6a2020-01-14 15:57:01 +080060 DVR_Bool_t notify_clear_periods;
Pengfei Liuc181a982020-01-07 19:27:13 +080061} DVR_CryptoPeriod_t;;
62
63typedef struct {
Gong Ke3489c0f2020-01-16 18:11:44 +080064 int dmx_dev_id;
65 DVR_RecordFlag_t flags;
66 DVR_CryptoPeriod_t crypto_period;
67 DVR_CryptoFunction_t crypto_fn;
68 void *crypto_data;
Pengfei Liuc181a982020-01-07 19:27:13 +080069} DVR_RecordOpenParams_t;
70
71typedef struct {
72 uint64_t segment_id;
73 uint32_t nb_pids;
Gong Ke3489c0f2020-01-16 18:11:44 +080074 DVR_StreamPid_t pids[DVR_MAX_RECORD_PIDS_COUNT];
Pengfei Liuc181a982020-01-07 19:27:13 +080075 DVR_RecordPidAction_t pid_action[DVR_MAX_RECORD_PIDS_COUNT];
76} DVR_RecordSegmentStartParams_t;
77
78typedef struct {
79 char location[DVR_MAX_LOCATION_SIZE];
80 DVR_RecordSegmentStartParams_t segment;
81} DVR_RecordStartParams_t;
82
83typedef struct {
84} DVR_RecordSegmentInfo_t;
85
86/**\brief Open a recording session for a target giving some open parameters
87 * \param[out] p_handle Return the handle of the newly created dvr session
88 * \param[in] params Open parameters
89 * \return DVR_SUCCESS on success
90 * \return error code
91 */
92int dvr_record_open(DVR_RecordHandle_t *p_handle, DVR_RecordOpenParams_t *params);
93
94/**\brief Close a recording session
95 * \param[in] handle Dvr recording session handle
96 * \return DVR_SUCCESS on success
97 * \return error code
98 */
99int dvr_record_close(DVR_RecordHandle_t handle);
100
Pengfei Liuc181a982020-01-07 19:27:13 +0800101/**\brief Start recording on a segment
102 * \param[in] handle Dvr recording session handle
103 * \param[in] params Dvr start parameters
104 * \return DVR_SUCCESS on success
105 * \return error code
106 */
107int dvr_record_start_segment(DVR_RecordHandle_t handle, DVR_RecordStartParams_t *params);
108
109/**\brief Stop the ongoing segment and start recording a new segment
110 * \param[in] handle Dvr recording session handle
111 * \param[in] params Dvr start parameters
112 * \param[out] p_info
113 * \return DVR_SUCCESS on success
114 * \return error code
115 */
116int dvr_record_next_segment(DVR_RecordHandle_t handle, DVR_RecordStartParams_t *params, DVR_RecordSegmentInfo_t *p_info);
117
118/**\brief Stop the ongoing segment
119 * \param[in] handle Dvr recording session handle
120 * \param[out] p_info
121 * \return DVR_SUCCESS on success
122 * \return error code
123 */
124int dvr_record_stop_segment(DVR_RecordHandle_t handle, DVR_RecordSegmentInfo_t *p_info);
125
126#ifdef __cplusplus
127}
128#endif
129
130#endif /*END _DVR_RECORD_H_*/