from:http://blog.csdn.net/xioahw/article/details/4093491

PMT结构定义:

typedef struct TS_PMT_Stream
{
 unsigned stream_type                    : 8; //指示特定PID的节目元素包的类型。该处PID由elementary PID指定
 unsigned elementary_PID                    : 13; //该域指示TS包的PID值。这些TS包含有相关的节目元素
 unsigned ES_info_length                    : 12; //前两位bit为00。该域指示跟随其后的描述相关节目元素的byte数
 unsigned descriptor;
}TS_PMT_Stream;

//PMT 表结构体
typedef struct TS_PMT
{
    unsigned table_id                        : 8; //固定为0x02, 表示PMT表
    unsigned section_syntax_indicator        : 1; //固定为0x01
    unsigned zero                            : 1; //0x01
    unsigned reserved_1                      : 2; //0x03
    unsigned section_length                  : 12;//首先两位bit置为00,它指示段的byte数,由段长度域开始,包含CRC。
    unsigned program_number                    : 16;// 指出该节目对应于可应用的Program map PID
    unsigned reserved_2                        : 2; //0x03
    unsigned version_number                    : 5; //指出TS流中Program map section的版本号
    unsigned current_next_indicator            : 1; //当该位置1时,当前传送的Program map section可用;
   //当该位置0时,指示当前传送的Program map section不可用,下一个TS流的Program map section有效。
    unsigned section_number                    : 8; //固定为0x00
    unsigned last_section_number            : 8; //固定为0x00
    unsigned reserved_3                        : 3; //0x07
    unsigned PCR_PID                        : 13; //指明TS包的PID值,该TS包含有PCR域,
            //该PCR值对应于由节目号指定的对应节目。
            //如果对于私有数据流的节目定义与PCR无关,这个域的值将为0x1FFF。
    unsigned reserved_4                        : 4; //预留为0x0F
    unsigned program_info_length            : 12; //前两位bit为00。该域指出跟随其后对节目信息的描述的byte数。
   
 std::vector<TS_PMT_Stream> PMT_Stream;  //每个元素包含8位, 指示特定PID的节目元素包的类型。该处PID由elementary PID指定
    unsigned reserved_5                        : 3; //0x07
    unsigned reserved_6                        : 4; //0x0F
    unsigned CRC_32                            : 32;
} TS_PMT;

解析代码为:

HRESULT CTS_Stream_Parse::adjust_PMT_table ( TS_PMT * packet, unsigned char * buffer )
{
    packet->table_id                            = buffer[0];
    packet->section_syntax_indicator            = buffer[1] >> 7;
    packet->zero                                = buffer[1] >> 6 & 0x01;
    packet->reserved_1                            = buffer[1] >> 4 & 0x03;
    packet->section_length                        = (buffer[1] & 0x0F) << 8 | buffer[2];   
    packet->program_number                        = buffer[3] << 8 | buffer[4];
    packet->reserved_2                            = buffer[5] >> 6;
    packet->version_number                        = buffer[5] >> 1 & 0x1F;
    packet->current_next_indicator                = (buffer[5] << 7) >> 7;
    packet->section_number                        = buffer[6];
    packet->last_section_number                    = buffer[7];
    packet->reserved_3                            = buffer[8] >> 5;
    packet->PCR_PID                                = ((buffer[8] << 8) | buffer[9]) & 0x1FFF;

PCRID = packet->PCR_PID;

packet->reserved_4                            = buffer[10] >> 4;
    packet->program_info_length                    = (buffer[10] & 0x0F) << 8 | buffer[11];
    // Get CRC_32
 int len = 0;
    len = packet->section_length + 3;   
    packet->CRC_32                = (buffer[len-4] & 0x000000FF) << 24
  | (buffer[len-3] & 0x000000FF) << 16
  | (buffer[len-2] & 0x000000FF) << 8
  | (buffer[len-1] & 0x000000FF);

int pos = 12;
    // program info descriptor
    if ( packet->program_info_length != 0 )
        pos += packet->program_info_length;   
    // Get stream type and PID   
    for ( ; pos <= (packet->section_length + 2 ) -  4; )
    {
  TS_PMT_Stream pmt_stream;
  pmt_stream.stream_type =  buffer[pos];
  packet->reserved_5  =   buffer[pos+1] >> 5;
  pmt_stream.elementary_PID =  ((buffer[pos+1] << 8) | buffer[pos+2]) & 0x1FFF;
  packet->reserved_6     =   buffer[pos+3] >> 4;
  pmt_stream.ES_info_length =   (buffer[pos+3] & 0x0F) << 8 | buffer[pos+4];
  
  pmt_stream.descriptor = 0x00;
  if (pmt_stream.ES_info_length != 0)
  {
   pmt_stream.descriptor = buffer[pos + 5];
   
   for( int len = 2; len <= pmt_stream.ES_info_length; len ++ )
   {
    pmt_stream.descriptor = pmt_stream.descriptor<< 8 | buffer[pos + 4 + len];
   }
   pos += pmt_stream.ES_info_length;
  }
  pos += 5;
  packet->PMT_Stream.push_back( pmt_stream );
  TS_Stream_type.push_back( pmt_stream );
    }
 return 0;
}

举例如下:

0x47 0x43 0xe8 0x12 0x00 0x02 0xb0 0x12 0x00 0x01 0xc1 0x00 0x00 0xe3 0xe9 0xf0 0x00  0x1b 0xe3 0xe9 0xf0 0x00 0xf0 0xaf 0xb4 0x4f 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

TS头部

sync_byte   :0x47
transport_error_indicator: 0x00
payload_unit_start_indicator: 0x01
transport_priority  : 0x00

PID                     :0x03e8
transport_scrambling_control  :0x00
adaptation_field_control  :0x01

continuity_counter   :0x02

PMT数据

table_id     :0x02                          // 8
section_syntax_indicator  :0x01            //  1
'0'                :0x00                   //  1
reserved       :0x03                       //  2
section_length :      0x012                 //  12
program_number    :0x00 01                    //  16
reserved               :0x03               //  2
version_number    :0x00                    //  5
current_next_indicator   0x01             //  1
section_number      :0x00                  //  8
last_section_number    :0x00               //  8
reserved                   0x07           //  3
PCR_PID           :0x03 e9   // PCR(节目参考时钟)所在TS分组的PID          //  13
reser ved       :0x0f                 //4
program_info_length     :0x000              //  12
stream_type       :0x1b                    //  8
reserved            0x07                  //  3
elementary_PID        :0x03 e9    //  13//该节目中包括的视频流,音频流等对应的TS分组的PID
reserved                    :0x0f          //  4
ES_info_length         :0x000               //  12
CRC        : 0xf0 af b4 4f

TS流解析之PMT表格解析相关推荐

  1. TS流解析之PAT表格解析

    from: http://blog.csdn.net/xioahw/article/details/4093488 PAT表格定义如下: typedef struct TS_PAT_Program { ...

  2. TS流PAT、PMT、ES、PES分析及解析代码

    TS流即是我们所熟知的传输流,其是由定长的TS包组成(188字节),包括包头和负载数据.其中包头固定为4字节,用来指明包的起始位置.负载的PID以及各种标志位:负载则由各种表及基础流组成: PAT表给 ...

  3. TS流PAT、PMT、SDT内容

    TS流: TS流.PS流.PES流和ES流都是什么? ES流(ElementaryStream):基本码流,不分段的音频.视频或其他信息的连续码流. PES流:把基本流ES分割成段,并加上相应头文件打 ...

  4. TS流结构分析(PAT和PMT)

    TS流也是由一个或多个PES组合而来的,他们可以具有相同的时间基准,也可以不同.其基本的复用思想是,对具有相同时间基准[color="#000000"]的多个PES现进行节目复用, ...

  5. DVB中TS流数据解析

    引  言 数字生活方式是现代文明的一个重要标志.在与人们工作生活密切相关的电脑.手机和电视三大信息平台中,电脑和手机已实现了数字化和网络化,为人们带来了多姿多彩的资讯和娱乐服务,也为相关企业带来了巨额 ...

  6. TS流解析【PCR】自己的总结

    http://www.cnblogs.com/ztteng/articles/3166025.html http://blog.csdn.net/liuhongxiangm/article/detai ...

  7. c语言解析ts流文件,TS流解析

    1. 介绍:​TS即是"Transport Stream"的缩写.他是分包发送的,每一个包长为188字节或者是204的字节(204字节的就是在后面添加了16字节主要用于高清解码), ...

  8. 数字电视之TS流解析

    做了这么久的TV方案,对数字电视也很了解,今天来总结一下,MPEG-2 TS流解析的细节: TS流中有两种标识符,一种是包标识符,一种是表标识符.具有相同PID的不用信息表由表标识符table Id来 ...

  9. TS流解析 二 *****

    1.TS格式介绍 TS:全称为MPEG2-TS.TS即"Transport Stream"的缩写.它是分包发送的,每一个包长为188字节(还有192和204个字节的包).包的结构为 ...

最新文章

  1. 第十一章:WEB浏览器中的javascript
  2. 《数据结构》是计算机应用,《数据结构》期中测试-2014计算机应用技术用.doc
  3. es每次结果不一样_电子血压计不准!每次测血压都不一样……
  4. Python中最常用的字符串方法!
  5. 怎样将WPS转换word格式?如何进行操作
  6. sqlmap绕过d盾_Waf功能、分类与绕过
  7. Javolution 2.2.5 - Java Struct/Union Simplified
  8. 声纹识别PLDA模型的理解
  9. GridView”的控件 必须放在具有 runat=server 的窗体标记内 “错误提示”
  10. mysql homedir迁移
  11. HibernateCRUD基础框架(1)-实体类
  12. Linux时间子系统之(四):timekeeping
  13. CentOS7安装无线网卡驱动和更新yum源
  14. linux 锐捷 自动,Ubuntu下锐捷自动认证设置
  15. java星号心形代码_心形原创符号
  16. 北京工业大学 计算机学院分数线,2019年北京工业大学计算机专业录取分数线
  17. python象棋博弈算法_python做中国国粹——象棋
  18. uniapp 实现微信小程序全局分享及自定义分享按钮样式
  19. 记几个智能手表相关芯片 蓝牙芯片 低功耗
  20. HCIP网络配置(MGRE+OSPF+优化)

热门文章

  1. 迷你世界维护服务器几点到几点,迷你世界服务器房间是什么 | 手游网游页游攻略大全...
  2. leetcode算法题--链表中倒数第k个节点
  3. js路由在php上面使用,React中路由使用详解
  4. 怎么给电脑设密码_怎么给电脑中重要的文件夹设置密码?
  5. 1067. [SCOI2007]降雨量【线段树】
  6. 《Swift 权威指南》——导读
  7. 【玩转Golang】 通过组合嵌入实现代码复用
  8. Firebug高级用法 - Web开发的利器
  9. 分布式缓存redis 方案_Redis缓存和MySQL数据一致性方案详解
  10. Codeforces 463E Caisa and Tree