TS流解析之TS包头解析
来源:互联网 发布:淘宝退货多久自动退款 编辑:程序博客网 时间:2024/05/03 11:31
根据前一篇中各数据的定义及数据结构,对数据进行分别解析如下:
TS包头定义:
- typedef struct TS_packet_header
- {
- unsigned sync_byte : 8; //同步字节, 固定为0x47,表示后面的是一个TS分组
- unsigned transport_error_indicator : 1; //传输误码指示符
- unsigned payload_unit_start_indicator : 1; //有效荷载单元起始指示符
- unsigned transport_priority : 1; //传输优先, 1表示高优先级,传输机制可能用到,解码用不着
- unsigned PID : 13; //PID
- unsigned transport_scrambling_control : 2; //传输加扰控制
- unsigned adaption_field_control : 2; //自适应控制 01仅含有效负载,10仅含调整字段,
- //11含有调整字段和有效负载。为00解码器不进行处理
- unsigned continuity_counter : 4; //连续计数器 一个4bit的计数器,范围0-15
- } TS_packet_header;
TS包头解析代码:
- HRESULT CTS_Stream_Parse::adjust_TS_packet_header( TS_packet_header* TS_header )
- {
- unsigned char buf[4];
- memcpy(buf, TS_header, 4);
- TS_header->transport_error_indicator = buf[1] >> 7;
- TS_header->payload_unit_start_indicator = buf[1] >> 6 & 0x01;
- TS_header->transport_priority = buf[1] >> 5 & 0x01;
- TS_header->PID = (buf[1] & 0x1F) << 8 | buf[2];
- TS_header->transport_scrambling_control = buf[3] >> 6;
- TS_header->adaption_field_control = buf[3] >> 4 & 0x03;
- TS_header->continuity_counter = buf[3] & 0x0F; // 四位数据,应为0x0F xyy 09.03.18
- return 0;
- }
如下为一个TS包数据:
0x47 0x40 0x00 0x120x00 0x00 0xb0 0x0d 0x00 0x00 0xc1 0x00 0x00 0x00 0x01 0xe3 0xe8 0xf0 0x0b 0xd7 0x79 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
分析知道前四位0x47 0x40 0x00 0x12TS头部即为TS包头数据,解析如下:
- sync_byte: 0x47
- transport_error_indicator: 0x00
- payload_unit_start_indicator: 0x01
- transport_priority: 0x00
- PID: 0x0000
- transport_scrambling_control: 0x00
- adaptation_field_control: 0x01
- continuity_counter: 0x02
PID = 0x0000,表示此TS包的内容为PSI信息表格的PAT表格数据,在4字节的TS包头之后的第一个字节的Point_field = 0x00, 表示偏移量为0,即紧随其后的即为PAT的数据信息
- TS流解析之TS包头解析
- TS流解析之TS包头解析
- TS流解析之TS包头解析(转)
- 解析TS流之解析TS包头数据
- ts包头解析
- TS包头解析
- 数字电视之TS流解析
- TS流解析之PAT表格解析
- TS流解析之PMT表格解析
- TS流解析之PMT表格解析
- TS流解析之PAT表格解析
- TS流解析之PMT表格解析
- TS流解析之PAT表格解析
- TS流解析之PMT表格解析
- TS流的解析
- TS流的解析
- ts流PAT解析
- ts流PMT解析
- 数据库表中修改表的结构
- I, P, B帧和PTS, DTS的关系
- .net机试题总结
- CMOS/CCD图像传感器工作原理
- thinkphp 多字段排序
- TS流解析之TS包头解析
- 分布时钟
- TortoiseGit GitHub使用教程
- TS流结构图
- 多线程 并发编程与异步方法
- TS传输流标准介绍
- Linux 的多线程编程的高效开发经验
- 软件啊
- ThreadPool