Browse Source

Add test program

Georgi Chorbadzhiyski 9 years ago
parent
commit
6965e337e9
6 changed files with 121 additions and 110 deletions
  1. 1
    0
      .gitignore
  2. 7
    2
      Makefile
  3. 0
    51
      tsfuncs_eit_test.c
  4. 0
    39
      tsfuncs_pat_test.c
  5. 0
    18
      tsfuncs_sdt_test.c
  6. 113
    0
      tstest.c

+ 1
- 0
.gitignore View File

@@ -1,2 +1,3 @@
1 1
 *.o
2 2
 *.a
3
+tstest

+ 7
- 2
Makefile View File

@@ -19,11 +19,16 @@ OBJS = log.o tsfuncs.o tsfuncs_crc.o tsfuncs_misc.o tsfuncs_time.o \
19 19
 	tsfuncs_pes_es.o
20 20
 PROG = libts.a
21 21
 
22
-all: $(PROG)
22
+tstest_OBJS = tstest.o libts.a
23
+all: $(PROG) tstest
23 24
 
24 25
 $(PROG): $(OBJS) tsdata.h tsfuncs.h
25 26
 	$(Q)echo "  LINK	$(PROG)"
26
-	$(Q)$(LINK) $@ $(LIBRARY_LINK_OPTS) $(OBJS) 
27
+	$(Q)$(LINK) $@ $(LIBRARY_LINK_OPTS) $(OBJS)
28
+
29
+tstest: $(tstest_OBJS)
30
+	$(Q)echo "  LINK	$(PROG)"
31
+	$(Q)$(CC) $(CFLAGS) $(tstest_OBJS) -o tstest
27 32
 
28 33
 %.o: %.c tsdata.h tsfuncs.h
29 34
 	$(Q)echo "  CC	libts	$<"

+ 0
- 51
tsfuncs_eit_test.c View File

@@ -1,51 +0,0 @@
1
-#include "tsfuncs.h"
2
-
3
-void test1(struct ts_eit *eit) { // Exactly one TS packet (188 bytes)
4
-	ts_eit_add_short_event_descriptor(eit, 4, time(NULL), 3600,
5
-		"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
6
-		"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy****");
7
-}
8
-
9
-void test2(struct ts_eit *eit) { // One TS packet + 2 bytes (2 bytes of the CRC are in the next packet
10
-	ts_eit_add_short_event_descriptor(eit, 4, time(NULL), 3600,
11
-		"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
12
-		"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy**");
13
-}
14
-
15
-void test3(struct ts_eit *eit) { // Test 4096 PSI packet
16
-	int i;
17
-	for (i=0;i<15;i++) {
18
-		// Maximum descriptor size, 255 bytes
19
-		if (ts_eit_add_short_event_descriptor(eit, 4, time(NULL), 3600, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") != 1) {
20
-			break;
21
-		}
22
-	}
23
-	ts_eit_add_short_event_descriptor(eit, 4, time(NULL), 3600, "00000000000000000000000", "1111111111111111111111111111111");
24
-}
25
-
26
-void test4(struct ts_eit *eit) { // Test almost full PSI packet on the TS packet boundary
27
-	int i;
28
-	for (i=0;i<15;i++) {
29
-		// Maximum descriptor size, 255 bytes
30
-		if (ts_eit_add_short_event_descriptor(eit, 4, time(NULL), 3600, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") != 1) {
31
-			break;
32
-		}
33
-	}
34
-	ts_eit_add_short_event_descriptor(eit, 4, time(NULL), 3600, "aaaaaaaaBBBB", NULL);
35
-}
36
-
37
-int main(int argc, char **argv) {
38
-	int i;
39
-	struct ts_eit *eit = ts_eit_alloc_init(1, 2, 3);
40
-
41
-//	test1(eit);
42
-//	test2(eit);
43
-//	test3(eit);
44
-//	test4(eit);
45
-
46
-	ts_eit_dump(eit);
47
-//	write(1, eit->section_header->packet_data, eit->section_header->num_packets * TS_PACKET_SIZE);
48
-
49
-	ts_eit_free(eit);
50
-	return 0;
51
-}

+ 0
- 39
tsfuncs_pat_test.c View File

@@ -1,39 +0,0 @@
1
-
2
-void ts_test_pat() {
3
-	struct ts_pat *pat = ts_pat_init_empty();
4
-
5
-	ts_pat_dump(pat);
6
-	ts_pat_check_generator(pat, 0);
7
-
8
-	ts_pat_add_program(pat, 1, 0x100);
9
-	ts_pat_dump(pat);
10
-/*
11
-//	ts_pat_check_generator(pat);
12
-
13
-	struct ts_pat *pat1 = calloc(1, sizeof(struct ts_pat));
14
-
15
-	ts_pat_init(pat1, pat->packet_data);
16
-	ts_pat_dump(pat1);
17
-	ts_pat_free(pat1);
18
-*/
19
-/*
20
-	ts_pat_add_program(pat, 1, 0x100);
21
-	ts_pat_add_program(pat, 2, 0x100);
22
-	ts_pat_add_program(pat, 3, 0x100);
23
-	ts_pat_dump(pat);
24
-	ts_pat_check_generator(pat);
25
-
26
-	ts_pat_del_program(pat, 3);
27
-	ts_pat_dump(pat);
28
-	ts_pat_check_generator(pat);
29
-
30
-//	int i;
31
-//	for (i=0;i<10;i++) {
32
-//		ts_pat_add_program(pat, i+10, (i+5)*10);
33
-//	}
34
-
35
-	ts_pat_dump(pat);
36
-	ts_pat_check_generator(pat);
37
-*/
38
-	ts_pat_free(pat);
39
-}

+ 0
- 18
tsfuncs_sdt_test.c View File

@@ -1,18 +0,0 @@
1
-int ts_sdt_test() {
2
-	struct ts_sdt *sdt = ts_sdt_alloc_init(1, 2);
3
-
4
-	ts_sdt_add_service_descriptor(sdt, 1007, 1, "BULSATCOM", "bTV");
5
-	ts_sdt_dump(sdt);
6
-
7
-	int i;
8
-	for (i=0;i<120;i++) {
9
-		ts_sdt_add_service_descriptor(sdt, 9,  0, "PROVIDER", "SERVICE33333333333333333333333333333333333333333333333333333333333333");
10
-		ts_sdt_add_service_descriptor(sdt, 13, 0, "PROddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddVIDER", "SERVICE");
11
-		ts_sdt_add_service_descriptor(sdt, 7,  0, "PROVIDER", "SERVICE");
12
-	}
13
-	ts_sdt_dump(sdt);
14
-
15
-	write(1, sdt->section_header->packet_data, sdt->section_header->num_packets * 188);
16
-	ts_sdt_free(sdt);
17
-	return 0;
18
-}

+ 113
- 0
tstest.c View File

@@ -0,0 +1,113 @@
1
+#include "tsfuncs.h"
2
+
3
+void ts_pat_test() {
4
+	struct ts_pat *pat = ts_pat_alloc_init(0x7878);
5
+
6
+	ts_pat_dump(pat);
7
+	ts_pat_add_program(pat, 1, 0x100);
8
+	ts_pat_add_program(pat, 2, 0x100);
9
+	ts_pat_add_program(pat, 3, 0x100);
10
+	ts_pat_dump(pat);
11
+
12
+	ts_pat_del_program(pat, 2);
13
+	ts_pat_dump(pat);
14
+
15
+	ts_pat_del_program(pat, 3);
16
+	ts_pat_dump(pat);
17
+
18
+	int i;
19
+	for (i=0;i<10;i++) {
20
+		ts_pat_add_program(pat, i+10, (i+5)*10);
21
+	}
22
+
23
+	ts_pat_dump(pat);
24
+
25
+	ts_pat_free(&pat);
26
+}
27
+
28
+int ts_sdt_test() {
29
+	struct ts_sdt *sdt = ts_sdt_alloc_init(1, 2);
30
+
31
+	ts_sdt_add_service_descriptor(sdt, 1007, 1, "BULSATCOM", "bTV");
32
+	ts_sdt_dump(sdt);
33
+
34
+	int i;
35
+	for (i=0;i<25;i++) {
36
+		ts_sdt_add_service_descriptor(sdt, 9,  0, "PROVIDER", "SERVICE33333333333333333333333333333333333333333333333333333333333333");
37
+		ts_sdt_add_service_descriptor(sdt, 13, 0, "PROddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddVIDER", "SERVICE");
38
+		ts_sdt_add_service_descriptor(sdt, 7,  0, "PROVIDER", "SERVICE");
39
+	}
40
+	ts_sdt_dump(sdt);
41
+
42
+//	write(1, sdt->section_header->packet_data, sdt->section_header->num_packets * 188);
43
+	ts_sdt_free(&sdt);
44
+	return 0;
45
+}
46
+
47
+void ts_eit_test1(struct ts_eit *eit) { // Exactly one TS packet (188 bytes)
48
+//int ts_eit_add_short_event_descriptor(struct ts_eit *eit, uint16_t event_id, uint8_t running, time_t start_time, int duration_sec, char *event_name, char *event_short_descr) {
49
+
50
+	ts_eit_add_short_event_descriptor(eit, 4, 1, time(NULL), 3600,
51
+		"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
52
+		"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy****");
53
+}
54
+
55
+void ts_eit_test2(struct ts_eit *eit) { // One TS packet + 2 bytes (2 bytes of the CRC are in the next packet
56
+	ts_eit_add_short_event_descriptor(eit, 4, 1, time(NULL), 3600,
57
+		"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
58
+		"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy**");
59
+}
60
+
61
+void ts_eit_test3(struct ts_eit *eit) { // Test 4096 PSI packet
62
+	int i;
63
+	for (i=0;i<15;i++) {
64
+		// Maximum descriptor size, 255 bytes
65
+		if (ts_eit_add_short_event_descriptor(eit, 4, 1, time(NULL), 3600, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") != 1) {
66
+			break;
67
+		}
68
+	}
69
+	ts_eit_add_short_event_descriptor(eit, 4, 1, time(NULL), 3600, "00000000000000000000000", "1111111111111111111111111111111");
70
+}
71
+
72
+void ts_eit_test4(struct ts_eit *eit) { // Test almost full PSI packet on the TS packet boundary
73
+	int i;
74
+	for (i=0;i<15;i++) {
75
+		// Maximum descriptor size, 255 bytes
76
+		if (ts_eit_add_short_event_descriptor(eit, 4, 1, time(NULL), 3600, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") != 1) {
77
+			break;
78
+		}
79
+	}
80
+	ts_eit_add_short_event_descriptor(eit, 4, 1, time(NULL), 3600, "aaaaaaaaBBBB", NULL);
81
+}
82
+
83
+void ts_eit_test() {
84
+	struct ts_eit *eit;
85
+
86
+	eit = ts_eit_alloc_init(1, 2, 3, 1, 0, 0);
87
+	ts_eit_test1(eit);
88
+	ts_eit_dump(eit);
89
+	ts_eit_free(&eit);
90
+
91
+	eit = ts_eit_alloc_init(1, 2, 3, 1, 0, 0);
92
+	ts_eit_test2(eit);
93
+	ts_eit_dump(eit);
94
+	ts_eit_free(&eit);
95
+
96
+	eit = ts_eit_alloc_init(1, 2, 3, 1, 0, 0);
97
+	ts_eit_test3(eit);
98
+	ts_eit_dump(eit);
99
+	ts_eit_free(&eit);
100
+
101
+	eit = ts_eit_alloc_init(1, 2, 3, 1, 0, 0);
102
+	ts_eit_test4(eit);
103
+	ts_eit_dump(eit);
104
+	ts_eit_free(&eit);
105
+//	write(1, eit->section_header->packet_data, eit->section_header->num_packets * TS_PACKET_SIZE);
106
+}
107
+
108
+int main() {
109
+	ts_pat_test();
110
+	ts_sdt_test();
111
+	ts_eit_test();
112
+	return 0;
113
+}

Loading…
Cancel
Save