Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 1 | #ifndef _DVR_RECORD_H_ |
| 2 | #define _DVR_RECORD_H_ |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
Pengfei Liu | b038b6a | 2020-01-14 15:57:01 +0800 | [diff] [blame] | 8 | #include "dvr_types.h" |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 9 | #include "dvr_crypto.h" |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 10 | |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 11 | typedef void* DVR_RecordHandle_t; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 12 | |
| 13 | typedef enum { |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 14 | 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 Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 19 | |
| 20 | typedef enum |
| 21 | { |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 22 | 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 Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 25 | } DVR_RecordPidAction_t; |
| 26 | |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 27 | typedef enum { |
| 28 | DVR_RECORD_FLAG_SCRAMBLED = (1 << 0), |
| 29 | DVR_RECORD_FLAG_ACCURATE = (1 << 1), |
| 30 | } DVR_RecordFlag_t; |
| 31 | |
| 32 | typedef enum { |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 33 | 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 Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 36 | } DVR_CryptoParity_t; |
| 37 | |
| 38 | typedef enum { |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 39 | DVR_CRYPTO_FILTER_TYPE_AUDIO, /**< Indicate current notification concerns audio packets*/ |
| 40 | DVR_CRYPTO_FILTER_TYPE_VIDEO, /**< Indicate current notification concerns video packets*/ |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 41 | } DVR_CryptoFilterType_t; |
| 42 | |
| 43 | typedef struct |
| 44 | { |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 45 | 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 Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 49 | } DVR_CryptoPeriodInfo_t; |
| 50 | |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 51 | #if 0 |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 52 | typedef void (*DVR_CryptoPeriodNotifyFn_t)( |
| 53 | DVR_RecordHandle_t handle, |
| 54 | const DVR_CryptoPeriodInfo_t *p_info); |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 55 | #endif |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 56 | |
| 57 | typedef struct { |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 58 | //DVR_CryptoPeriodNotifyFn_t notify_func; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 59 | uint64_t interval_bytes; |
Pengfei Liu | b038b6a | 2020-01-14 15:57:01 +0800 | [diff] [blame] | 60 | DVR_Bool_t notify_clear_periods; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 61 | } DVR_CryptoPeriod_t;; |
| 62 | |
| 63 | typedef struct { |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 64 | 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 Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 69 | } DVR_RecordOpenParams_t; |
| 70 | |
| 71 | typedef struct { |
| 72 | uint64_t segment_id; |
| 73 | uint32_t nb_pids; |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 74 | DVR_StreamPid_t pids[DVR_MAX_RECORD_PIDS_COUNT]; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 75 | DVR_RecordPidAction_t pid_action[DVR_MAX_RECORD_PIDS_COUNT]; |
| 76 | } DVR_RecordSegmentStartParams_t; |
| 77 | |
| 78 | typedef struct { |
| 79 | char location[DVR_MAX_LOCATION_SIZE]; |
| 80 | DVR_RecordSegmentStartParams_t segment; |
| 81 | } DVR_RecordStartParams_t; |
| 82 | |
| 83 | typedef 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 | */ |
| 92 | int 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 | */ |
| 99 | int dvr_record_close(DVR_RecordHandle_t handle); |
| 100 | |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 101 | /**\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 | */ |
| 107 | int 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 | */ |
| 116 | int 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 | */ |
| 124 | int 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_*/ |