Browse Source

Add CRC field to struct ts_section_header and calculate it in common code

Georgi Chorbadzhiyski 13 years ago
parent
commit
ca207fc6d5
3 changed files with 10 additions and 0 deletions
  1. 2
    0
      tsdata.h
  2. 7
    0
      tsfuncs_section_data.c
  3. 1
    0
      tsfuncs_sections.c

+ 2
- 0
tsdata.h View File

@@ -62,6 +62,8 @@ struct ts_section_header {
62 62
 
63 63
 	int			data_len;						// Data size without the CRC32 (4 bytes)
64 64
 	uint8_t		*data;							// Offset into section_data (where the section data start without the section header)
65
+
66
+	uint32_t	CRC;
65 67
 };
66 68
 
67 69
 struct ts_pat_program {

+ 7
- 0
tsfuncs_section_data.c View File

@@ -115,4 +115,11 @@ void ts_section_add_packet(struct ts_section_header *sec, struct ts_header *ts_h
115 115
 	sec->section_pos += to_copy;
116 116
 	sec->num_packets++;
117 117
 	sec->initialized = (sec->section_pos+1) >= (sec->section_length + 4); // +4 to include the CRC
118
+	if (sec->initialized) {
119
+		// CRC is after sec->data[sec->data_len]
120
+		sec->CRC = (sec->CRC << 8) | sec->data[sec->data_len + 3];
121
+		sec->CRC = (sec->CRC << 8) | sec->data[sec->data_len + 2];
122
+		sec->CRC = (sec->CRC << 8) | sec->data[sec->data_len + 1];
123
+		sec->CRC = (sec->CRC << 8) | sec->data[sec->data_len + 0];
124
+	}
118 125
 }

+ 1
- 0
tsfuncs_sections.c View File

@@ -124,6 +124,7 @@ void ts_section_header_dump(struct ts_section_header *t) {
124 124
 				t->current_next_indicator,
125 125
 				t->section_number,
126 126
 				t->last_section_number);
127
+		ts_LOGf("    - CRC 0x%08x\n", t->CRC);
127 128
 	}
128 129
 	ts_LOGf("    - Private vars       : num_packets:%d section_pos:%d\n",
129 130
 			t->num_packets,

Loading…
Cancel
Save