Browse Source

Use ts_section_is_same() to remove duplicated code

Georgi Chorbadzhiyski 9 years ago
parent
commit
76eaef3b15
3 changed files with 3 additions and 62 deletions
  1. 1 11
      tsfuncs_cat.c
  2. 1 24
      tsfuncs_pat.c
  3. 1 27
      tsfuncs_pmt.c

+ 1 - 11
tsfuncs_cat.c View File

@@ -169,17 +169,7 @@ void ts_cat_dump(struct ts_cat *cat) {
169 169
 }
170 170
 
171 171
 int ts_cat_is_same(struct ts_cat *cat1, struct ts_cat *cat2) {
172
-	if (cat1->section_header->CRC == cat2->section_header->CRC) // Same
173
-		return 1;
174
-
175
-	// If some version is not current, just claim the structures are the same
176
-	if (!cat1->section_header->current_next_indicator || cat2->section_header->version_number)
177
-		return 1;
178
-
179
-	if (cat1->section_header->version_number != cat2->section_header->version_number) // Different
180
-		return 0;
181
-
182
-	return 1; // Same
172
+	return ts_section_is_same(cat1->section_header, cat2->section_header);
183 173
 }
184 174
 
185 175
 enum CA_system ts_get_CA_sys(uint16_t CA_id) {

+ 1 - 24
tsfuncs_pat.c View File

@@ -206,28 +206,5 @@ void ts_pat_dump(struct ts_pat *pat) {
206 206
 }
207 207
 
208 208
 int ts_pat_is_same(struct ts_pat *pat1, struct ts_pat *pat2) {
209
-	int i;
210
-
211
-	if (pat1->section_header->CRC == pat2->section_header->CRC) // Same
212
-		return 1;
213
-
214
-	// If some version is not current, just claim the structures are the same
215
-	if (!pat1->section_header->current_next_indicator || pat2->section_header->version_number)
216
-		return 1;
217
-
218
-	if (pat1->section_header->version_number != pat2->section_header->version_number) // Different
219
-		return 0;
220
-
221
-	if (pat1->programs_num != pat2->programs_num) // Different
222
-		return 0;
223
-
224
-	// Check each program and PIDs
225
-	for (i=0;i<pat1->programs_num;i++) {
226
-		struct ts_pat_program *prg1 = pat1->programs[i];
227
-		struct ts_pat_program *prg2 = pat2->programs[i];
228
-		if (prg1->program != prg2->program || prg1->pid != prg2->pid) // Different
229
-			return 0;
230
-	}
231
-
232
-	return 1; // Same
209
+	return ts_section_is_same(pat1->section_header, pat2->section_header);
233 210
 }

+ 1 - 27
tsfuncs_pmt.c View File

@@ -293,31 +293,5 @@ int parse_pmt(uint8_t *ts_packet, uint16_t pmt_pid, uint16_t *pcr_pid, uint16_t
293 293
 */
294 294
 
295 295
 int ts_pmt_is_same(struct ts_pmt *pmt1, struct ts_pmt *pmt2) {
296
-	int i;
297
-
298
-	if (pmt1->section_header->CRC == pmt2->section_header->CRC) // Same
299
-		return 1;
300
-
301
-	// If some version is not current, just claim the structures are the same
302
-	if (!pmt1->section_header->current_next_indicator || pmt2->section_header->version_number)
303
-		return 1;
304
-
305
-	if (pmt1->section_header->version_number != pmt2->section_header->version_number) // Different
306
-		return 0;
307
-
308
-	if (pmt1->PCR_pid != pmt2->PCR_pid) // Different
309
-		return 0;
310
-
311
-	if (pmt1->streams_num != pmt2->streams_num) // Different
312
-		return 0;
313
-
314
-	// Check each program and PIDs
315
-	for (i=0;i<pmt1->streams_num;i++) {
316
-		struct ts_pmt_stream *stream1 = pmt1->streams[i];
317
-		struct ts_pmt_stream *stream2 = pmt2->streams[i];
318
-		if (stream1->pid != stream2->pid) // Different
319
-			return 0;
320
-	}
321
-
322
-	return 1; // Same
296
+	return ts_section_is_same(pmt1->section_header, pmt2->section_header);
323 297
 }