- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# MatroskaSplitter.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 "MatroskaFile.h"
    00028 #include "..\BaseSplitter\BaseSplitter.h"
    00029 #include "..\..\..\..\include\ITrackInfo.h"
    00030
    00031 class MatroskaPacket : public Packet
    00032 {
    00033 protected:
    00034         int GetSize()
    00035         {
    00036                 int size = 0;
    00037                 POSITION pos = bg->Block.BlockData.GetHeadPosition();
    00038                 while(pos) {size += bg->Block.BlockData.GetNext(pos)->GetSize();}
    00039                 return size;
    00040         }
    00041 public:
    00042         CAutoPtr<MatroskaReader::BlockGroup> bg;
    00043 };
    00044
    00045 class CMatroskaSplitterOutputPin : public CBaseSplitterOutputPin
    00046 {
    00047         HRESULT DeliverBlock(MatroskaPacket* p);
    00048
    00049         int m_nMinCache;
    00050         REFERENCE_TIME m_rtDefaultDuration;
    00051
    00052         CCritSec m_csQueue;
    00053         CAutoPtrList<MatroskaPacket> m_packets;
    00054         CList<MatroskaPacket*> m_rob;
    00055
    00056         typedef struct {REFERENCE_TIME rtStart, rtStop;} timeoverride;
    00057         CList<timeoverride> m_tos;
    00058
    00059 protected:
    00060         HRESULT DeliverPacket(CAutoPtr<Packet> p);
    00061
    00062 public:
    00063         CMatroskaSplitterOutputPin(
    00064                 int nMinCache, REFERENCE_TIME rtDefaultDuration,
    00065                 CArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
    00066         virtual ~CMatroskaSplitterOutputPin();
    00067
    00068         HRESULT DeliverEndFlush();
    00069         HRESULT DeliverEndOfStream();
    00070 };
    00071
    00072 [uuid("149D2E01-C32E-4939-80F6-C07B81015A7A")]
    00073 class CMatroskaSplitterFilter : public CBaseSplitterFilter, public ITrackInfo
    00074 {
    00075         void SendVorbisHeaderSample();
    00076         void InstallFonts();
    00077
    00078         CAutoPtr<MatroskaReader::CMatroskaNode> m_pSegment, m_pCluster, m_pBlock;
    00079
    00080 protected:
    00081         CAutoPtr<MatroskaReader::CMatroskaFile> m_pFile;
    00082         HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
    00083
    00084         CMap<DWORD, DWORD, MatroskaReader::TrackEntry*, MatroskaReader::TrackEntry*> m_pTrackEntryMap;
    00085         CArray<MatroskaReader::TrackEntry* > m_pOrderedTrackArray;
    00086         MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
    00087
    00088         bool DemuxInit();
    00089         void DemuxSeek(REFERENCE_TIME rt);
    00090         bool DemuxLoop();
    00091
    00092 public:
    00093         CMatroskaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
    00094         virtual ~CMatroskaSplitterFilter();
    00095
    00096         DECLARE_IUNKNOWN;
    00097     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
    00098
    00099         // IMediaSeeking
    00100
    00101         STDMETHODIMP GetDuration(LONGLONG* pDuration);
    00102
    00103         // IKeyFrameInfo
    00104
    00105         STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
    00106         STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
    00107
    00108         // ITrackInfo
    00109
    00110         STDMETHODIMP_(UINT) GetTrackCount();
    00111         STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
    00112         STDMETHODIMP_(BOOL) GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill);
    00113         STDMETHODIMP_(BSTR) GetTrackName(UINT aTrackIdx);
    00114         STDMETHODIMP_(BSTR) GetTrackCodecID(UINT aTrackIdx);
    00115         STDMETHODIMP_(BSTR) GetTrackCodecName(UINT aTrackIdx);
    00116         STDMETHODIMP_(BSTR) GetTrackCodecInfoURL(UINT aTrackIdx);
    00117         STDMETHODIMP_(BSTR) GetTrackCodecDownloadURL(UINT aTrackIdx);
    00118 };
    00119
    00120 [uuid("0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4")]
    00121 class CMatroskaSourceFilter : public CMatroskaSplitterFilter
    00122 {
    00123 public:
    00124         CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
    00125 };