Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 2 | #include <unistd.h> |
| 3 | #include <stdlib.h> |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 4 | #include <string.h> |
Zhiqiang Han | e0a1c38 | 2021-06-08 11:28:05 +0800 | [diff] [blame] | 5 | #include <errno.h> |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 6 | #include <pthread.h> |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 7 | #include "dvr_segment.h" |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 8 | #include <segment.h> |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 9 | |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 10 | /**\brief DVR segment file information*/ |
| 11 | typedef struct { |
| 12 | char location[DVR_MAX_LOCATION_SIZE]; /**< DVR record file location*/ |
| 13 | uint64_t id; /**< DVR Segment id*/ |
| 14 | } DVR_SegmentFile_t; |
| 15 | |
| 16 | void *dvr_segment_thread(void *arg) |
| 17 | { |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 18 | int ret; |
hualing chen | e83bf81 | 2020-04-23 13:42:37 +0800 | [diff] [blame] | 19 | DVR_SegmentFile_t *segment_file = (DVR_SegmentFile_t*)arg; |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 20 | |
hualing chen | 3114087 | 2020-03-25 12:29:26 +0800 | [diff] [blame] | 21 | pthread_detach(pthread_self()); |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 22 | DVR_INFO("%s try to delete [%s-%lld]", __func__, segment_file->location, segment_file->id); |
hualing chen | e83bf81 | 2020-04-23 13:42:37 +0800 | [diff] [blame] | 23 | ret = segment_delete(segment_file->location, segment_file->id); |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 24 | DVR_INFO("%s delete segment [%s-%lld] %s", __func__, segment_file->location, segment_file->id, |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 25 | ret == DVR_SUCCESS ? "success" : "failed"); |
hualing chen | e83bf81 | 2020-04-23 13:42:37 +0800 | [diff] [blame] | 26 | if (segment_file != NULL) { |
| 27 | //malloc at delete api.free at this |
| 28 | free(segment_file); |
| 29 | segment_file = NULL; |
| 30 | } |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 31 | return NULL; |
| 32 | } |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 33 | |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 34 | int dvr_segment_delete(const char *location, uint64_t segment_id) |
| 35 | { |
hualing chen | 6d24aa9 | 2020-03-23 18:43:47 +0800 | [diff] [blame] | 36 | |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 37 | pthread_t thread; |
hualing chen | e83bf81 | 2020-04-23 13:42:37 +0800 | [diff] [blame] | 38 | DVR_SegmentFile_t *segment; |
| 39 | //this segment will be free at del thread when used end.if thread |
| 40 | //creat error.will be free now. |
| 41 | segment = (DVR_SegmentFile_t *)malloc(sizeof(DVR_SegmentFile_t)); |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 42 | |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 43 | DVR_INFO("%s in, %s,id:%lld", __func__, location, segment_id); |
hualing chen | e83bf81 | 2020-04-23 13:42:37 +0800 | [diff] [blame] | 44 | DVR_RETURN_IF_FALSE(segment); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 45 | DVR_RETURN_IF_FALSE(location); |
| 46 | DVR_RETURN_IF_FALSE(strlen(location) < DVR_MAX_LOCATION_SIZE); |
hualing chen | e83bf81 | 2020-04-23 13:42:37 +0800 | [diff] [blame] | 47 | memset(segment->location, 0, sizeof(segment->location)); |
| 48 | memcpy(segment->location, location, strlen(location)); |
| 49 | segment->id = segment_id; |
Zhiqiang Han | 2d8cd82 | 2020-03-16 13:58:10 +0800 | [diff] [blame] | 50 | |
hualing chen | e83bf81 | 2020-04-23 13:42:37 +0800 | [diff] [blame] | 51 | int ret = pthread_create(&thread, NULL, dvr_segment_thread, segment); |
| 52 | if (ret != 0) { |
| 53 | //creat thread error,need free segment |
| 54 | if (segment != NULL) { |
| 55 | free(segment); |
| 56 | segment = NULL; |
| 57 | } |
| 58 | } |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 59 | return DVR_SUCCESS; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 60 | } |
| 61 | |
hualing chen | 4b7c15d | 2020-04-07 16:13:48 +0800 | [diff] [blame] | 62 | int dvr_segment_del_by_location(const char *location) |
| 63 | { |
| 64 | FILE *fp; |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 65 | char cmd[DVR_MAX_LOCATION_SIZE + 64]; |
hualing chen | 4b7c15d | 2020-04-07 16:13:48 +0800 | [diff] [blame] | 66 | |
| 67 | DVR_RETURN_IF_FALSE(location); |
| 68 | |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 69 | DVR_INFO("%s location:%s", __func__, location); |
hualing chen | 4b7c15d | 2020-04-07 16:13:48 +0800 | [diff] [blame] | 70 | { |
| 71 | /* del file */ |
| 72 | memset(cmd, 0, sizeof(cmd)); |
hualing chen | 926a8ec | 2021-12-20 20:38:24 +0800 | [diff] [blame] | 73 | sprintf(cmd, "rm %s-* %s.list %s.stats %s.odb %s.dat", location, location, location, location, location); |
hualing chen | 4b7c15d | 2020-04-07 16:13:48 +0800 | [diff] [blame] | 74 | fp = popen(cmd, "r"); |
| 75 | DVR_RETURN_IF_FALSE(fp); |
| 76 | } |
Zhiqiang Han | 5c805cf | 2020-05-09 16:51:08 +0800 | [diff] [blame] | 77 | pclose(fp); |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 78 | DVR_INFO("%s location:%s end", __func__, location); |
hualing chen | 4b7c15d | 2020-04-07 16:13:48 +0800 | [diff] [blame] | 79 | return DVR_SUCCESS; |
| 80 | } |
| 81 | |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 82 | int dvr_segment_get_list(const char *location, uint32_t *p_segment_nb, uint64_t **pp_segment_ids) |
| 83 | { |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 84 | FILE *fp; |
| 85 | char fpath[DVR_MAX_LOCATION_SIZE]; |
Zhiqiang Han | ee5ac41 | 2020-05-07 20:54:32 +0800 | [diff] [blame] | 86 | uint32_t i = 0, j = 0, n = 0; |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 87 | char buf[DVR_MAX_LOCATION_SIZE + 10]; |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 88 | uint64_t *p = NULL; |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 89 | char cmd[DVR_MAX_LOCATION_SIZE + 64]; |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 90 | |
| 91 | DVR_RETURN_IF_FALSE(location); |
| 92 | DVR_RETURN_IF_FALSE(p_segment_nb); |
| 93 | DVR_RETURN_IF_FALSE(pp_segment_ids); |
| 94 | |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 95 | //DVR_INFO("%s location:%s", __func__, location); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 96 | memset(fpath, 0, sizeof(fpath)); |
| 97 | sprintf(fpath, "%s.list", location); |
| 98 | |
| 99 | if (access(fpath, 0) != -1) { |
| 100 | /*the list file is exist*/ |
| 101 | fp = fopen(fpath, "r"); |
| 102 | DVR_RETURN_IF_FALSE(fp); |
| 103 | /*get segment numbers*/ |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 104 | while (fgets(buf, sizeof(buf), fp) != NULL) { |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 105 | i++; |
| 106 | } |
| 107 | *p_segment_nb = i; |
| 108 | rewind(fp); |
| 109 | /*malloc*/ |
| 110 | p = malloc(i * sizeof(uint64_t)); |
| 111 | i = 0; |
| 112 | /*set value*/ |
| 113 | memset(buf, 0, sizeof(buf)); |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 114 | while (fgets(buf, sizeof(buf), fp) != NULL) { |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 115 | p[i++] = strtoull(buf, NULL, 10); |
| 116 | memset(buf, 0, sizeof(buf)); |
| 117 | } |
| 118 | *pp_segment_ids = p; |
| 119 | fclose(fp); |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 120 | DVR_INFO("%s location:%s segments:%d", __func__, location, i); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 121 | } else { |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 122 | uint32_t id = 0; |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 123 | /*the list file does not exist*/ |
| 124 | memset(cmd, 0, sizeof(cmd)); |
Zhiqiang Han | ade34ff | 2020-04-17 16:50:59 +0800 | [diff] [blame] | 125 | sprintf(cmd, "ls -l %s-*.ts | wc -l", location); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 126 | fp = popen(cmd, "r"); |
| 127 | DVR_RETURN_IF_FALSE(fp); |
| 128 | memset(buf, 0, sizeof(buf)); |
| 129 | if (fgets(buf, sizeof(buf), fp) != NULL) { |
| 130 | i = strtoull(buf, NULL, 10); |
| 131 | pclose(fp); |
| 132 | } else { |
| 133 | pclose(fp); |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 134 | DVR_INFO("%s location:%s get null", __func__, location); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 135 | return DVR_FAILURE; |
| 136 | } |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 137 | //DVR_INFO("%s location:%s i: %d ls buf:%s", __func__, location, i, buf); |
Zhiqiang Han | ee5ac41 | 2020-05-07 20:54:32 +0800 | [diff] [blame] | 138 | n = i; |
| 139 | p = malloc(n * sizeof(uint64_t)); |
Zhiqiang Han | 8dd08b3 | 2020-05-13 16:50:04 +0800 | [diff] [blame] | 140 | /*try to get the 1st segment id*/ |
| 141 | memset(cmd, 0, sizeof(cmd)); |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 142 | sprintf(cmd, "ls %s-*.ts", location); |
Zhiqiang Han | 8dd08b3 | 2020-05-13 16:50:04 +0800 | [diff] [blame] | 143 | fp = popen(cmd, "r"); |
| 144 | DVR_RETURN_IF_FALSE(fp); |
| 145 | memset(buf, 0, sizeof(buf)); |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 146 | j = 0; |
| 147 | snprintf(fpath, sizeof(fpath), "%s-%%d.ts", location); |
| 148 | while (fgets(buf, sizeof(buf), fp) != NULL) { |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 149 | //DVR_INFO("%s buf:%s", __func__, buf); |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 150 | if (sscanf(buf, fpath, &id) != 1) { |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 151 | DVR_INFO("%s location:%s buf:%s not get id", __func__, location, buf); |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 152 | id = 0; |
| 153 | n = n -1; |
| 154 | } else { |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 155 | //DVR_INFO("%s location:%s buf:%s get id:%d", __func__, location, buf, id); |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 156 | p[j++] = id; |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 157 | } |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 158 | memset(buf, 0, sizeof(buf)); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 159 | } |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 160 | DVR_DEBUG("%s location:%s n=%d j=%d end", __func__, location, n, j); |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 161 | pclose(fp); |
| 162 | *p_segment_nb = n; |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 163 | *pp_segment_ids = p; |
| 164 | } |
Pengfei Liu | faf38e4 | 2020-05-22 00:28:02 +0800 | [diff] [blame] | 165 | |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 166 | return DVR_SUCCESS; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 167 | } |
| 168 | |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 169 | int dvr_segment_get_info(const char *location, uint64_t segment_id, DVR_RecordSegmentInfo_t *p_info) |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 170 | { |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 171 | int ret; |
| 172 | Segment_OpenParams_t open_params; |
| 173 | Segment_Handle_t segment_handle; |
| 174 | |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 175 | DVR_RETURN_IF_FALSE(location); |
| 176 | DVR_RETURN_IF_FALSE(p_info); |
| 177 | DVR_RETURN_IF_FALSE(strlen((const char *)location) < DVR_MAX_LOCATION_SIZE); |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 178 | |
| 179 | memset(&open_params, 0, sizeof(open_params)); |
| 180 | memcpy(open_params.location, location, strlen(location)); |
| 181 | open_params.segment_id = segment_id; |
| 182 | open_params.mode = SEGMENT_MODE_READ; |
| 183 | ret = segment_open(&open_params, &segment_handle); |
Zhiqiang Han | 5c805cf | 2020-05-09 16:51:08 +0800 | [diff] [blame] | 184 | if (ret == DVR_SUCCESS) { |
| 185 | ret = segment_load_info(segment_handle, p_info); |
| 186 | } |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 187 | DVR_DEBUG("%s, id:%lld, nb_pids:%d, duration:%ld ms, size:%zu, nb_packets:%d", |
hualing chen | 926a8ec | 2021-12-20 20:38:24 +0800 | [diff] [blame] | 188 | __func__, p_info->id, p_info->nb_pids, p_info->duration, p_info->size, p_info->nb_packets); |
hualing chen | b224235 | 2021-05-18 17:16:16 +0800 | [diff] [blame] | 189 | //DVR_RETURN_IF_FALSE(ret == DVR_SUCCESS); |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 190 | ret = segment_close(segment_handle); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 191 | DVR_RETURN_IF_FALSE(ret == DVR_SUCCESS); |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 192 | |
| 193 | return DVR_SUCCESS; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 194 | } |
| 195 | |
hualing chen | b9a0292 | 2021-12-14 11:29:47 +0800 | [diff] [blame] | 196 | int dvr_segment_get_allInfo(const char *location, struct list_head *list) |
| 197 | { |
| 198 | int ret; |
| 199 | Segment_OpenParams_t open_params; |
| 200 | Segment_Handle_t segment_handle; |
| 201 | |
| 202 | DVR_RETURN_IF_FALSE(location); |
| 203 | DVR_RETURN_IF_FALSE(list); |
| 204 | DVR_RETURN_IF_FALSE(strlen((const char *)location) < DVR_MAX_LOCATION_SIZE); |
| 205 | |
| 206 | memset(&open_params, 0, sizeof(open_params)); |
| 207 | memcpy(open_params.location, location, strlen(location)); |
| 208 | open_params.segment_id = 0; |
| 209 | open_params.mode = SEGMENT_MODE_READ; |
| 210 | ret = segment_open(&open_params, &segment_handle); |
| 211 | if (ret == DVR_SUCCESS) { |
| 212 | ret = segment_load_allInfo(segment_handle, list); |
hualing chen | 926a8ec | 2021-12-20 20:38:24 +0800 | [diff] [blame] | 213 | if (ret == DVR_FAILURE) { |
| 214 | segment_close(segment_handle); |
| 215 | return DVR_FAILURE; |
| 216 | } |
hualing chen | b9a0292 | 2021-12-14 11:29:47 +0800 | [diff] [blame] | 217 | } |
| 218 | ret = segment_close(segment_handle); |
| 219 | DVR_RETURN_IF_FALSE(ret == DVR_SUCCESS); |
| 220 | |
| 221 | return DVR_SUCCESS; |
| 222 | } |
| 223 | |
| 224 | |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 225 | int dvr_segment_link(const char *location, uint32_t nb_segments, uint64_t *p_segment_ids) |
| 226 | { |
Wentao MA | e8ba517 | 2022-08-09 11:18:17 +0800 | [diff] [blame^] | 227 | return dvr_segment_link_op(location, nb_segments, p_segment_ids, SEGMENT_OP_NEW); |
Zhiqiang Han | e0a1c38 | 2021-06-08 11:28:05 +0800 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | int dvr_segment_link_op(const char *location, uint32_t nb_segments, uint64_t *p_segment_ids, int op) |
| 231 | { |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 232 | FILE *fp; |
| 233 | char fpath[DVR_MAX_LOCATION_SIZE]; |
| 234 | uint32_t i; |
hualing chen | b270cfa | 2020-08-19 15:04:35 +0800 | [diff] [blame] | 235 | char buf[DVR_MAX_LOCATION_SIZE + 64]; |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 236 | |
| 237 | DVR_RETURN_IF_FALSE(location); |
| 238 | DVR_RETURN_IF_FALSE(p_segment_ids); |
| 239 | DVR_RETURN_IF_FALSE(strlen((const char *)location) < DVR_MAX_LOCATION_SIZE); |
| 240 | |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 241 | DVR_INFO("%s op[%d] location:%s, nb_segments:%d", __func__, op, location, nb_segments); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 242 | memset(fpath, 0, sizeof(fpath)); |
| 243 | sprintf(fpath, "%s.list", location); |
Wentao MA | e8ba517 | 2022-08-09 11:18:17 +0800 | [diff] [blame^] | 244 | fp = fopen(fpath, (op == SEGMENT_OP_ADD) ? "a+" : "w+"); |
Zhiqiang Han | e0a1c38 | 2021-06-08 11:28:05 +0800 | [diff] [blame] | 245 | if (!fp) { |
Wentao MA | 96f6896 | 2022-06-15 19:45:35 +0800 | [diff] [blame] | 246 | DVR_INFO("failed to open list file, err:%d:%s", errno, strerror(errno)); |
Zhiqiang Han | e0a1c38 | 2021-06-08 11:28:05 +0800 | [diff] [blame] | 247 | return DVR_FAILURE; |
| 248 | } |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 249 | for (i = 0; i< nb_segments; i++) { |
| 250 | memset(buf, 0, sizeof(buf)); |
Zhiqiang Han | e0a1c38 | 2021-06-08 11:28:05 +0800 | [diff] [blame] | 251 | sprintf(buf, "%lld\n", p_segment_ids[i]); |
Pengfei Liu | 3b1a820 | 2020-02-12 23:04:21 +0800 | [diff] [blame] | 252 | fwrite(buf, 1, strlen(buf), fp); |
| 253 | } |
| 254 | |
| 255 | fflush(fp); |
| 256 | fsync(fileno(fp)); |
| 257 | fclose(fp); |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 258 | return DVR_SUCCESS; |
Pengfei Liu | c181a98 | 2020-01-07 19:27:13 +0800 | [diff] [blame] | 259 | } |