2 static const char *desc_name1[] = {
5 /* 02 */ "video_stream_descr",
6 /* 03 */ "audio_stream_descr",
7 /* 04 */ "hierarchy_descr",
8 /* 05 */ "registration_descr",
9 /* 06 */ "data_stream_align_descr",
10 /* 07 */ "target_background_grid_descr",
11 /* 08 */ "video_window_descr",
13 /* 0a */ "ISO_639_lang_descr",
14 /* 0b */ "syst_clk_descr",
15 /* 0c */ "multiplex_buf_utilization_descr",
16 /* 0d */ "copyright_descr",
17 /* 0e */ "max_bitrate_descr",
18 /* 0f */ "private_data_indicator_descr",
19 /* 10 */ "smoothing_buf_descr",
23 /* 14 */ "assoc_tag_descr",
26 static const char *desc_name2[] = {
27 /* 80 */ "stuffing_descr",
28 /* 81 */ 0, 0, 0, 0, 0, /* - 85 */
29 /* 86 */ "caption_serv_descr",
30 /* 87 */ "content_advisory_descr",
31 /* 88 */ 0, 0, 0, 0, 0, 0, 0, 0, /* - 8f */
32 /* 90 */ 0, 0, 0, 0, 0, 0, 0, 0, /* - 97 */
33 /* 98 */ 0, 0, 0, 0, 0, 0, 0, 0, /* - 9f */
34 /* a0 */ "extended_ch_name_descr",
35 /* a1 */ "serv_location_descr",
36 /* a2 */ "time_shifted_serv_descr",
37 /* a3 */ "component_name_descr",
38 /* a4 */ "data_service_descr",
39 /* a5 */ "PID_count_descr",
40 /* a6 */ "Download_descr",
41 /* a7 */ "multiprotocol_encapsulate_descr",
42 /* a8 */ "DCC_departing_event_descr",
43 /* a9 */ "DCC_arriving_event_descr",
44 /* aa */ "Content_Protect_Copy_Mngt_descr",
45 /* ab */ 0, 0, 0, 0, 0, 0, 0, 0, 0, /* - b3 */
46 /* b4 */ "Module_Link_descr",
47 /* b5 */ "CRC32_descr",
48 /* b6 */ 0, 0, /* - b7 */
49 /* b8 */ "Group_Link_descr",
52 /* print descr tag info */
54 static uint32_t prt_descr(uint8_t *descr)
59 uint32_t tag = descr[0];
62 printf(" tag/len=0x%02x/%u (", tag,len);
63 if( tag < lengthof(desc_name1) )
65 else if( (n=tag-0x80) >= 0 && n<=lengthof(desc_name2) )
67 if( nm == 0 ) nm = "n/a";
72 if( (i&0x0f) == 0 ) printf("%04x: ",i);
73 printf("%02x ", *bp++);
74 if( (++i & 0x0f) == 0 ) {
77 printf("%c", *cp>=0x20 && *cp<0x80 ? *cp : '.');
84 while( (i++ & 0xf) ) printf(" ");
87 printf("%c", *cp>=0x20 && *cp<0x80 ? *cp : '.');
93 case 0xa1: /* serv_location_descr */
94 n = (descr[2]<<8) | descr[3];
95 printf(" pcr_pid=0x%04x\n",n);
99 for( i=0; i<n && bp+6<=cp; ++i ) {
102 printf(" stream=0x%02x", st);
103 printf(" (%s)", ( (st==0x02) ? "video" :
104 ((st==0x81) ? "AC3-audio" :
105 ((st==0x03) ? "MPEG1-audio" :
106 ((st==0x04) ? "MPEG1-audio" :
108 printf(" pid=0x%04x", (bp[1]<<8) | bp[2]);
109 printf(" lang_code=%c", bp[3]);
110 printf("%c", bp[4]>=0x20 && bp[4]<0x80 ? bp[4] : '.');
111 printf("%c", bp[5]>=0x20 && bp[5]<0x80 ? bp[5] : '.');
119 /* print the list of descr info */
121 static void prt_all_descr(uint8_t *descr,int len)
124 int n = prt_descr(descr);
130 static void prt_vct(zvct_t *vct)
132 printf("VCT table -");
133 printf(" ver=0x%04x", vct->version_number);
134 printf(" items=0x%04x", vct->items);
135 printf(" ts_stream_id=0x%04x\n", vct->transport_stream_id);
136 prt_all_descr(vct->descr, vct->descr_length);
137 for( int i=0; i<vct->items; ++i ) {
138 zvitem_t *item = vct->vct_tbl[i];
139 printf(" %2d. name= ", i);
140 for( int j=0; j<7; ++j ) {
141 int ch = item->short_name[j];
142 printf("%c", ch>=0x20 && ch<0x80 ? ch : '.');
144 printf(" maj =0x%04x", item->major_channel_number);
145 printf(" min =0x%04x", item->minor_channel_number);
146 printf(" mod =0x%04x", item->modulation_mode );
147 printf(" freq=0x%04x", item->carrier_frequency );
148 printf(" TSid=0x%04x", item->channel_TSID );
149 printf(" prog=0x%04x", item->program_number );
150 printf(" etm =0x%04x", item->etm_location );
151 printf(" acc =0x%04x", item->access_controlled );
152 printf(" hide=0x%04x", item->hidden );
153 printf(" serv=0x%04x", item->service_type );
154 printf(" s_id=0x%04x", item->source_id );
155 printf(" pcr =0x%04x", item->pcr_pid );
156 for( int k=0; k<item->num_ch_elts; ++k ) {
158 printf(" stream=0x%04x",item->elts[k].stream_id );
159 printf(" pid=0x%04x",item->elts[k].pes_pid );
160 int ch0 = item->elts[k].code_639[0];
161 int ch1 = item->elts[k].code_639[1];
162 int ch2 = item->elts[k].code_639[2];
163 printf(" lang_code=%c",ch0>=0x20 && ch0<0x80 ? ch0 : '.');
164 printf("%c",ch1>=0x20 && ch1<0x80 ? ch1 : '.');
165 printf("%c",ch2>=0x20 && ch2<0x80 ? ch2 : '.');
167 printf(" descr_len=0x%04x\n", item->descr_length );
168 prt_all_descr(item->descr, item->descr_length);
172 static void prt_mgt(zmgt_t *mgt)
174 printf("\nMGT table -");
175 printf(" items=0x%x", mgt->items);
176 printf(" descr_len=0x%x\n", mgt->descr_len);
177 prt_all_descr(mgt->descr, mgt->descr_len);
178 zmitem_t *item = mgt->mgt_tbl;
179 for( int i=0; i<mgt->items; ++i,++item ) {
181 printf(" typ=0x%x", item->type);
182 printf(" pid=0x%x", item->pid);
183 printf(" ver=0x%x", item->version);
184 printf(" size=0x%x", item->size);
185 printf(" descr_len=0x%x\n", item->descr_len);
186 prt_all_descr(item->descr, item->descr_len);
191 #define prt_vct(s) do {} while(0)
192 #define prt_mgt(s) do {} while(0)