00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <atlbase.h>
00025 #include <atlcoll.h>
00026 #include <afxtempl.h>
00027 #include "..\BaseSplitter\BaseSplitter.h"
00028
00029 class CMpegSplitterFile : public CBaseSplitterFileEx
00030 {
00031 CMap<WORD,WORD,BYTE,BYTE> m_pid2pes;
00032
00033 HRESULT Init();
00034
00035 public:
00036 CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr);
00037
00038 REFERENCE_TIME NextPTS(DWORD TrackNum);
00039
00040 enum {us, ps, ts, es, pva} m_type;
00041
00042 REFERENCE_TIME m_rtMin, m_rtMax;
00043 __int64 m_posMin, m_posMax;
00044 int m_rate;
00045
00046 struct stream
00047 {
00048 CMediaType mt;
00049 WORD pid;
00050 BYTE pesid, ps1id;
00051 struct stream() {pid = pesid = ps1id = 0;}
00052 operator DWORD() const {return pid ? pid : ((pesid<<8)|ps1id);}
00053 bool operator == (const struct stream& s) const {return (DWORD)*this == (DWORD)s;}
00054 };
00055
00056 enum {video, audio, subpic, unknown};
00057
00058 class CStreamList : public CList<stream>
00059 {
00060 public:
00061 void Insert(stream& s)
00062 {
00063 for(POSITION pos = GetHeadPosition(); pos; GetNext(pos))
00064 {
00065 stream& s2 = GetAt(pos);
00066 if(s < s2) {InsertBefore(pos, s); return;}
00067 }
00068
00069 AddTail(s);
00070 }
00071
00072 static CStringW ToString(int type)
00073 {
00074 return
00075 type == video ? L"Video" :
00076 type == audio ? L"Audio" :
00077 type == subpic ? L"Subtitle" :
00078 L"Unknown";
00079 }
00080 } m_streams[unknown];
00081
00082 HRESULT SearchStreams(__int64 start, __int64 stop);
00083 DWORD AddStream(WORD pid, BYTE pesid, DWORD len);
00084 };