Browse Source

Rename ts_pes_reset() to ts_pes_clear()

Georgi Chorbadzhiyski 13 years ago
parent
commit
2fe32e33e6
2 changed files with 11 additions and 5 deletions
  1. 1
    1
      tsfuncs.h
  2. 10
    4
      tsfuncs_pes.c

+ 1
- 1
tsfuncs.h View File

@@ -229,8 +229,8 @@ char *			h222_stream_id_desc		(uint8_t stream_id);
229 229
 
230 230
 // PES
231 231
 struct ts_pes *		ts_pes_alloc			();
232
+void				ts_pes_clear			(struct ts_pes *pes);
232 233
 void				ts_pes_free				(struct ts_pes **pes);
233
-struct ts_pes *		ts_pes_reset			(struct ts_pes *pes);
234 234
 
235 235
 void				ts_pes_fill_type		(struct ts_pes *pes, struct ts_pmt *pmt, uint16_t pid);
236 236
 int					ts_pes_is_finished		(struct ts_pes *pes, uint8_t *ts_packet);

+ 10
- 4
tsfuncs_pes.c View File

@@ -25,13 +25,18 @@ void ts_pes_free(struct ts_pes **ppes) {
25 25
 	}
26 26
 }
27 27
 
28
-struct ts_pes *ts_pes_reset(struct ts_pes *pes) {
28
+void ts_pes_clear(struct ts_pes *pes) {
29
+	if (!pes)
30
+		return;
31
+	// save
29 32
 	uint8_t *pes_data = pes->pes_data;
30 33
 	uint32_t pes_data_size = pes->pes_data_size;
34
+	// clear
35
+	memset(pes_data, 0x33, pes_data_size);
31 36
 	memset(pes, 0, sizeof(struct ts_pes));
37
+	// restore
32 38
 	pes->pes_data = pes_data;
33 39
 	pes->pes_data_size = pes_data_size;
34
-	return pes;
35 40
 }
36 41
 
37 42
 static void ts_pes_add_payload_to_pes_data(struct ts_pes *pes, uint8_t *payload, uint8_t payload_size) {
@@ -67,7 +72,7 @@ int ts_pes_is_finished(struct ts_pes *pes, uint8_t *ts_packet) {
67 72
 //		ts_LOGf("packet finished, len:%d\n", pes->real_pes_packet_len);
68 73
 		if (!ts_pes_parse(pes)) {
69 74
 			ts_LOGf("error parsing!\n");
70
-			pes = ts_pes_reset(pes);
75
+			ts_pes_clear(pes);
71 76
 			return 0;
72 77
 		}
73 78
 //		ts_LOGf("parsed OK!\n");
@@ -249,7 +254,8 @@ OUT:
249 254
 	return pes;
250 255
 
251 256
 ERROR:
252
-	return ts_pes_reset(pes);
257
+	ts_pes_clear(pes);
258
+	return pes;
253 259
 }
254 260
 
255 261
 int ts_pes_parse(struct ts_pes *pes) {

Loading…
Cancel
Save