MpegSplitterFile.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
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; // byte/sec
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 };

Generated on Tue Dec 13 14:47:21 2005 for guliverkli by  doxygen 1.4.5