Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 1 | /** |
| 2 | * \file |
Gong Ke | 497c4c2 | 2020-03-20 10:15:42 +0800 | [diff] [blame] | 3 | * \brief Crypto function |
| 4 | * |
| 5 | * Crypto function is used as a callback function in dvr_record and dvr_playback module. |
| 6 | * User can used it to encrypt the TS data in recording and decrypt the TS data in playback process. |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 7 | */ |
| 8 | |
Pengfei Liu | 2afc35d | 2020-01-07 10:47:39 +0800 | [diff] [blame] | 9 | #ifndef _DVR_CRYPTO_H_ |
| 10 | #define _DVR_CRYPTO_H_ |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 16 | #include <dvr_types.h> |
| 17 | |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 18 | /**Work type.*/ |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 19 | typedef enum { |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 20 | DVR_CRYPTO_TYPE_ENCRYPT, /**< Encrypt.*/ |
| 21 | DVR_CRYPTO_TYPE_DECRYPT /**< Decrypt.*/ |
| 22 | } DVR_CryptoType_t; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 23 | |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 24 | /**Crypto parameters.*/ |
Pengfei Liu | 2afc35d | 2020-01-07 10:47:39 +0800 | [diff] [blame] | 25 | typedef struct DVR_CryptoParams_s { |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 26 | DVR_CryptoType_t type; /**< Work type.*/ |
| 27 | char location[DVR_MAX_LOCATION_SIZE]; /**< Location of the record file.*/ |
| 28 | int segment_id; /**< Current segment's index.*/ |
| 29 | loff_t offset; /**< Current offset in the segment file.*/ |
| 30 | DVR_Buffer_t input_buffer; /**< Input data buffer.*/ |
| 31 | DVR_Buffer_t output_buffer; /**< Output data buffer.*/ |
| 32 | size_t output_size; /**< Output data size in bytes.*/ |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 33 | } DVR_CryptoParams_t; |
Pengfei Liu | 2afc35d | 2020-01-07 10:47:39 +0800 | [diff] [blame] | 34 | |
Gong Ke | 3489c0f | 2020-01-16 18:11:44 +0800 | [diff] [blame] | 35 | /**Crypto function.*/ |
Pengfei Liu | 47ed6c9 | 2020-01-17 11:23:41 +0800 | [diff] [blame] | 36 | typedef DVR_Result_t (*DVR_CryptoFunction_t) (DVR_CryptoParams_t *params, void *userdata); |
Pengfei Liu | 2afc35d | 2020-01-07 10:47:39 +0800 | [diff] [blame] | 37 | |
| 38 | #ifdef __cplusplus |
| 39 | } |
| 40 | #endif |
| 41 | |
| 42 | #endif /*END _DVR_CRYPTO_H_*/ |