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
 
62
 
63
 	int			data_len;						// Data size without the CRC32 (4 bytes)
63
 	int			data_len;						// Data size without the CRC32 (4 bytes)
64
 	uint8_t		*data;							// Offset into section_data (where the section data start without the section header)
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
 struct ts_pat_program {
69
 struct ts_pat_program {

+ 7
- 0
tsfuncs_section_data.c View File

115
 	sec->section_pos += to_copy;
115
 	sec->section_pos += to_copy;
116
 	sec->num_packets++;
116
 	sec->num_packets++;
117
 	sec->initialized = (sec->section_pos+1) >= (sec->section_length + 4); // +4 to include the CRC
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
 				t->current_next_indicator,
124
 				t->current_next_indicator,
125
 				t->section_number,
125
 				t->section_number,
126
 				t->last_section_number);
126
 				t->last_section_number);
127
+		ts_LOGf("    - CRC 0x%08x\n", t->CRC);
127
 	}
128
 	}
128
 	ts_LOGf("    - Private vars       : num_packets:%d section_pos:%d\n",
129
 	ts_LOGf("    - Private vars       : num_packets:%d section_pos:%d\n",
129
 			t->num_packets,
130
 			t->num_packets,

Loading…
Cancel
Save