1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/*
* libtsfuncs test program
* Copyright (C) 2010-2011 Unix Solutions Ltd.
*
* Released under MIT license.
* See LICENSE-MIT.txt for license terms.
*/
#include "tsfuncs.h"
#define NOW 1234567890
#define NOW2 1000000000
void ts_pat_test(void) {
struct ts_pat *pat = ts_pat_alloc_init(0x7878);
ts_pat_dump(pat);
ts_pat_add_program(pat, 1, 0x100);
ts_pat_add_program(pat, 2, 0x100);
ts_pat_add_program(pat, 3, 0x100);
ts_pat_dump(pat);
ts_pat_del_program(pat, 2);
ts_pat_dump(pat);
ts_pat_del_program(pat, 3);
ts_pat_dump(pat);
int i;
for (i=0;i<10;i++) {
ts_pat_add_program(pat, i+10, (i+5)*10);
}
ts_pat_dump(pat);
ts_pat_free(&pat);
}
void ts_tdt_test(void) {
struct ts_tdt *tdt = ts_tdt_alloc_init(NOW);
ts_tdt_dump(tdt);
ts_tdt_set_time(tdt, NOW2);
ts_tdt_dump(tdt);
ts_tdt_free(&tdt);
}
void ts_tot_test(void) {
struct ts_tdt *tot;
tot = ts_tot_alloc_init(NOW);
ts_tdt_dump(tot);
ts_tdt_free(&tot);
tot = ts_tot_alloc_init(NOW);
ts_tot_set_localtime_offset_sofia(tot, NOW);
ts_tdt_dump(tot);
ts_tdt_free(&tot);
tot = ts_tot_alloc_init(NOW2);
ts_tot_set_localtime_offset_sofia(tot, NOW2);
ts_tdt_dump(tot);
ts_tdt_free(&tot);
}
int ts_sdt_test(void) {
struct ts_sdt *sdt = ts_sdt_alloc_init(1, 2);
ts_sdt_add_service_descriptor(sdt, 1007, 1, "BULSATCOM", "bTV");
ts_sdt_dump(sdt);
int i;
for (i=0;i<25;i++) {
ts_sdt_add_service_descriptor(sdt, 9, 0, "PROVIDER", "SERVICE33333333333333333333333333333333333333333333333333333333333333");
ts_sdt_add_service_descriptor(sdt, 13, 0, "PROddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddVIDER", "SERVICE");
ts_sdt_add_service_descriptor(sdt, 7, 0, "PROVIDER", "SERVICE");
}
ts_sdt_dump(sdt);
// write(1, sdt->section_header->packet_data, sdt->section_header->num_packets * 188);
ts_sdt_free(&sdt);
return 0;
}
void ts_eit_test1(struct ts_eit *eit) { // Exactly one TS packet (188 bytes)
//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) {
ts_eit_add_short_event_descriptor(eit, 4, 1, NOW, 3600,
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy****");
}
void ts_eit_test2(struct ts_eit *eit) { // One TS packet + 2 bytes (2 bytes of the CRC are in the next packet
ts_eit_add_short_event_descriptor(eit, 4, 1, NOW, 3600,
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy**");
}
void ts_eit_test3(struct ts_eit *eit) { // Test 4096 PSI packet
int i;
for (i=0;i<15;i++) {
// Maximum descriptor size, 255 bytes
if (ts_eit_add_short_event_descriptor(eit, 4, 1, NOW, 3600, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") != 1) {
break;
}
}
ts_eit_add_short_event_descriptor(eit, 4, 1, NOW, 3600, "00000000000000000000000", "1111111111111111111111111111111");
}
void ts_eit_test4(struct ts_eit *eit) { // Test almost full PSI packet on the TS packet boundary
int i;
for (i=0;i<15;i++) {
// Maximum descriptor size, 255 bytes
if (ts_eit_add_short_event_descriptor(eit, 4, 1, NOW, 3600, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") != 1) {
break;
}
}
ts_eit_add_short_event_descriptor(eit, 4, 1, NOW, 3600, "aaaaaaaaBBBB", NULL);
}
void ts_eit_test(void) {
struct ts_eit *eit;
eit = ts_eit_alloc_init(1, 2, 3, 1, 0, 0);
ts_eit_test1(eit);
ts_eit_dump(eit);
ts_eit_free(&eit);
eit = ts_eit_alloc_init(1, 2, 3, 1, 0, 0);
ts_eit_test2(eit);
ts_eit_dump(eit);
ts_eit_free(&eit);
eit = ts_eit_alloc_init(1, 2, 3, 1, 0, 0);
ts_eit_test3(eit);
ts_eit_dump(eit);
ts_eit_free(&eit);
eit = ts_eit_alloc_init(1, 2, 3, 1, 0, 0);
ts_eit_test4(eit);
ts_eit_dump(eit);
ts_eit_free(&eit);
// write(1, eit->section_header->packet_data, eit->section_header->num_packets * TS_PACKET_SIZE);
}
int main(void) {
ts_pat_test();
ts_tdt_test();
ts_tot_test();
ts_sdt_test();
ts_eit_test();
return 0;
}
|