blob: 0c118591af8a6990cab2bbc14fdf1627ccca513e [file] [log] [blame]
Gong Ke497c4c22020-03-20 10:15:42 +08001/**
Pengfei Liub4734232020-01-17 18:25:10 +08002 * \file
Gong Ke497c4c22020-03-20 10:15:42 +08003 * \brief Segment operation module
4 *
5 * A record is separated to several segments.
6 * Each segment contains many files.
7 * \li TS file: stored the TS data.
8 * \li Information file: stored the information of this segment.
9 * \li Index file: stored the timestamp lookup table of this segment.
Pengfei Liub4734232020-01-17 18:25:10 +080010 */
11
Pengfei Liu2afc35d2020-01-07 10:47:39 +080012#ifndef _DVR_SEGMENT_H_
13#define _DVR_SEGMENT_H_
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Gong Ke3489c0f2020-01-16 18:11:44 +080019#include "dvr_types.h"
Pengfei Liu2afc35d2020-01-07 10:47:39 +080020
Pengfei Liub4734232020-01-17 18:25:10 +080021/**\brief Delete a segment
Gong Ke497c4c22020-03-20 10:15:42 +080022 * \param[in] location The record file's location
23 * \param[in] segment_id The segment's index
Pengfei Liub4734232020-01-17 18:25:10 +080024 * \return DVR_SUCCESS On success
25 * \return Error code On failure
26 */
Pengfei Liuc181a982020-01-07 19:27:13 +080027int dvr_segment_delete(const char *location, uint64_t segment_id);
Pengfei Liu2afc35d2020-01-07 10:47:39 +080028
Pengfei Liub4734232020-01-17 18:25:10 +080029/**\brief Get the segment list of a record file
Gong Ke497c4c22020-03-20 10:15:42 +080030 * \param[in] location The record file's location
31 * \param[out] p_segment_nb Return the segments number
32 * \param[out] pp_segment_ids Return the segments index
Pengfei Liub4734232020-01-17 18:25:10 +080033 * \return DVR_SUCCESS On success
34 * \return Error code On failure
35 */
Pengfei Liuc181a982020-01-07 19:27:13 +080036int dvr_segment_get_list(const char *location, uint32_t *p_segment_nb, uint64_t **pp_segment_ids);
Pengfei Liu2afc35d2020-01-07 10:47:39 +080037
hualing chen4b7c15d2020-04-07 16:13:48 +080038/**\brief Del all info of segment whose location is "*location"
39 * \param[in] location The record of need del file's location
40 * \return DVR_SUCCESS On success
41 * \return Error code On failure
42 */
43int dvr_segment_del_by_location(const char *location);
44
45
Pengfei Liub4734232020-01-17 18:25:10 +080046/**\brief Get the segment's information
Gong Ke497c4c22020-03-20 10:15:42 +080047 * \param[in] location The record file's location
48 * \param[in] segment_id The segment index
49 * \param[out] p_info Return the segment's information
Pengfei Liub4734232020-01-17 18:25:10 +080050 * \return DVR_SUCCESS On success
51 * \return Error code On failure
52 */
53int dvr_segment_get_info(const char *location, uint64_t segment_id, DVR_RecordSegmentInfo_t *p_info);
Pengfei Liuc181a982020-01-07 19:27:13 +080054
hualing chenb9a02922021-12-14 11:29:47 +080055/**\brief Get the segment's information
56 * \param[in] location The record file's location
57 * \param[in] segment_id The segment index
58 * \param[out] p_info Return the segment's information
59 * \return DVR_SUCCESS On success
60 * \return Error code On failure
61 */
62
63int dvr_segment_get_allInfo(const char *location, struct list_head *list);
64
Pengfei Liub4734232020-01-17 18:25:10 +080065/**\brief Link a segment group as the record file's list
Gong Ke497c4c22020-03-20 10:15:42 +080066 * \param[in] location The record file's location
67 * \param[in] nb_segments The number of segments
68 * \param[in] p_segment_ids The segments index in the group
Pengfei Liub4734232020-01-17 18:25:10 +080069 * \return DVR_SUCCESS On success
70 * \return Error code On failure
71 */
Pengfei Liuc181a982020-01-07 19:27:13 +080072int dvr_segment_link(const char *location, uint32_t nb_segments, uint64_t *p_segment_ids);
Pengfei Liu2afc35d2020-01-07 10:47:39 +080073
Zhiqiang Hane0a1c382021-06-08 11:28:05 +080074
Wentao MAe8ba5172022-08-09 11:18:17 +080075#define SEGMENT_OP_NEW 0
76#define SEGMENT_OP_ADD 1
Zhiqiang Hane0a1c382021-06-08 11:28:05 +080077int dvr_segment_link_op(const char *location, uint32_t nb_segments, uint64_t *p_segment_ids, int op);
78
Pengfei Liu2afc35d2020-01-07 10:47:39 +080079#ifdef __cplusplus
80}
81#endif
82
83#endif /*END _DVR_SEGMENT_H_*/