TS流解析
TS包结构:
1.每个section数据中都有tid,sectionnum,last section num,partnum,last part num 这几个信息
2.如果数据较小,256个section就可以放下,那么partnum 和last part num 都为0
3.如果数据较大,lastpart num就不为0,可能为1,为2。。。
如果为lastpart num 为1,则section中的section信息就为
tid part num last part num section num last section num
xx 0 1 0 255
xx 0 1 1 255
xx 0 1 2 255
xx 0 1 3 255
xx 0 1 4 255
xx 0 1 5 255
xx 0 1 6 255
。。。。。
。。。。。
。。。。。
xx 0 1 254 255
xx 0 1 255 255
这时候第一个part的数据就全部得到了
然后下面就是第二个part的数据了
tid part num last part num section num last section num
xx 1 1 0 200
xx 1 1 1 200
xx 1 1 2 200
xx 1 1 3 200
xx 1 1 4 200
xx 1 1 5 200
xx 1 1 6 200
。。。。。
。。。。。
。。。。。
xx 1 1 199 200
xx 1 1 200 200
这样两个part的数据都收齐了,其中第二个part还没有满,如果满的话就需要第三个part了
所以,我们共需要受到的section个数为 256(part1)+201(part2)
所以section的总数可以通过lastpart和last part的lastsection算出来
每个section的位置是通过partnum和section num来定位的
示例:
通过filter后去掉每个section的前5个字节,即从第6个字节0x80起
第0个字节:TID=0x80
第1-2个字节:section_length=0x07FD& 0x0FFF
第4个字节:part_num=0x12
第5个字节:last_part_num=0x17
第6个字节:section_num=0xA4
第7个字节:last_section_num=0xFF