Browse Source

Add ts_section_data_copy()

Georgi Chorbadzhiyski 13 years ago
parent
commit
dc9e6f29f1
2 changed files with 18 additions and 0 deletions
  1. 2
    0
      tsfuncs.h
  2. 16
    0
      tsfuncs_section_data.c

+ 2
- 0
tsfuncs.h View File

@@ -88,6 +88,8 @@ uint8_t *					ts_section_data_alloc_packet	();
88 88
 struct ts_section_header *	ts_section_data_alloc			();
89 89
 void						ts_section_data_free			(struct ts_section_header **ts_section_header);
90 90
 
91
+void						ts_section_data_copy			(struct ts_section_header *src, struct ts_section_header *dst);
92
+
91 93
 void						ts_section_add_packet		(struct ts_section_header *sec, struct ts_header *ts_header, uint8_t *ts_packet);
92 94
 
93 95
 uint32_t					ts_section_data_calculate_crc	(uint8_t *section_data, int section_data_size);

+ 16
- 0
tsfuncs_section_data.c View File

@@ -36,6 +36,22 @@ void ts_section_data_free(struct ts_section_header **psection_data) {
36 36
 	}
37 37
 }
38 38
 
39
+void ts_section_data_copy(struct ts_section_header *src, struct ts_section_header *dst) {
40
+	if (!src || !dst)
41
+		return;
42
+	uint8_t *section_data = dst->section_data;
43
+	uint8_t *packet_data = dst->packet_data;
44
+
45
+	memcpy(section_data, src->section_data, 4096);
46
+	memcpy(packet_data , src->packet_data, 5120);
47
+	*dst = *src;
48
+
49
+	dst->section_data = section_data;
50
+	dst->packet_data  = packet_data;
51
+
52
+	ts_section_header_set_private_vars(dst);
53
+}
54
+
39 55
 // Fill CRC of the section data after secdata_size bytes
40 56
 uint32_t ts_section_data_calculate_crc(uint8_t *section_data, int secdata_size) {
41 57
 	uint32_t check_crc = ts_crc32(section_data, secdata_size);

Loading…
Cancel
Save