TSParse.cpp
资源名称:PSParse.rar [点击查看]
上传用户:thjx518
上传日期:2022-03-16
资源大小:179k
文件大小:1k
源码类别:
mpeg/mp3
开发平台:
Visual C++
- // TSParse.cpp: implementation of the CTSPacket class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "PSParse.h"
- #include "TSParse.h"
- CTSParse::CTSParse(CQueue*queue)
- {
- Queue=queue;
- }
- CTSParse::~CTSParse()
- {
- }
- USHORT CTSParse::GetPID()
- {
- return GET_13(Pack,1);
- }
- UCHAR CTSParse::GetContinueCounter()
- {
- UCHAR v=GET_4(Pack,3,3);
- return v;
- }
- int CTSParse::GetData(UCHAR *data)
- {
- int sb=GET_1(Pack,1,6)?(5+(UCHAR)Pack[4]):4;
- memcpy(data,Pack+sb,188-sb);
- return 188-sb;
- }
- int CTSParse::GetPacket(USHORT pid,bool first)
- {
- Queue->Pop(Pack);
- if(Pack[0]!=0x47)
- return ptSyncError;
- if(GetPID()!=pid)
- return ptPIDError;
- switch(GET_1(Pack,1,6))//get payload_unit_start_indicator
- {
- case 0: if(first)
- return ptPayLoad;
- if(GetContinueCounter()==(last_cc+1)%32){
- last_cc=GetContinueCounter();
- return ptPayLoad;
- }else
- return ptContinueError;
- default:if(first){
- last_cc=GetContinueCounter();
- return ptFirst;
- }else
- return ptContinueError;
- }
- }