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 "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
00100
00101 STDMETHODIMP GetDuration(LONGLONG* pDuration);
00102
00103
00104
00105 STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
00106 STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
00107
00108
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 };