- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# OggSplitter.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 "OggFile.h"
    00028 #include "..\BaseSplitter\BaseSplitter.h"
    00029
    00030 class OggPacket : public Packet
    00031 {
    00032 public:
    00033         OggPacket() {fSkip = false;}
    00034         bool fSkip;
    00035 };
    00036
    00037 class COggSplitterOutputPin : public CBaseSplitterOutputPin
    00038 {
    00039         class CComment
    00040         {
    00041         public:
    00042                 CStringW m_key, m_value;
    00043                 CComment(CStringW key, CStringW value) : m_key(key), m_value(value) {m_key.MakeUpper();}
    00044         };
    00045
    00046         CAutoPtrList<CComment> m_pComments;
    00047
    00048 protected:
    00049         CCritSec m_csPackets;
    00050         CAutoPtrList<OggPacket> m_packets;
    00051         CAutoPtr<OggPacket> m_lastpacket;
    00052         int m_lastseqnum;
    00053         REFERENCE_TIME m_rtLast;
    00054         bool m_fSkip;
    00055
    00056         void ResetState(DWORD seqnum = -1);
    00057
    00058 public:
    00059         COggSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
    00060
    00061         void AddComment(BYTE* p, int len);
    00062         CStringW GetComment(CStringW key);
    00063
    00064         HRESULT UnpackPage(OggPage& page);
    00065         virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len) = 0;
    00066         virtual REFERENCE_TIME GetRefTime(__int64 granule_position) = 0;
    00067         CAutoPtr<OggPacket> GetPacket();
    00068
    00069         HRESULT DeliverEndFlush();
    00070     HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
    00071 };
    00072
    00073 class COggVorbisOutputPin : public COggSplitterOutputPin
    00074 {
    00075         CAutoPtrList<OggPacket> m_initpackets;
    00076
    00077         DWORD m_audio_sample_rate;
    00078         DWORD m_blocksize[2], m_lastblocksize;
    00079         CArray<bool> m_blockflags;
    00080
    00081         virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
    00082         virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
    00083
    00084         HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
    00085     HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
    00086
    00087 public:
    00088         COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
    00089
    00090         HRESULT UnpackInitPage(OggPage& page);
    00091         bool IsInitialized() {return m_initpackets.GetCount() >= 3;}
    00092 };
    00093
    00094 class COggDirectShowOutputPin : public COggSplitterOutputPin
    00095 {
    00096         virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
    00097         virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
    00098
    00099 public:
    00100         COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
    00101 };
    00102
    00103 class COggStreamOutputPin : public COggSplitterOutputPin
    00104 {
    00105         __int64 m_time_unit, m_samples_per_unit;
    00106         DWORD m_default_len;
    00107
    00108         virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
    00109         virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
    00110
    00111 public:
    00112         COggStreamOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
    00113 };
    00114
    00115 class COggVideoOutputPin : public COggStreamOutputPin
    00116 {
    00117 public:
    00118         COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
    00119 };
    00120
    00121 class COggAudioOutputPin : public COggStreamOutputPin
    00122 {
    00123 public:
    00124         COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
    00125 };
    00126
    00127 class COggTextOutputPin : public COggStreamOutputPin
    00128 {
    00129 public:
    00130         COggTextOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
    00131 };
    00132
    00133 [uuid("9FF48807-E133-40AA-826F-9B2959E5232D")]
    00134 class COggSplitterFilter : public CBaseSplitterFilter
    00135 {
    00136 protected:
    00137         CAutoPtr<COggFile> m_pFile;
    00138         HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
    00139
    00140         bool DemuxInit();
    00141         void DemuxSeek(REFERENCE_TIME rt);
    00142         bool DemuxLoop();
    00143
    00144 public:
    00145         COggSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
    00146         virtual ~COggSplitterFilter();
    00147 };
    00148
    00149 [uuid("6D3688CE-3E9D-42F4-92CA-8A11119D25CD")]
    00150 class COggSourceFilter : public COggSplitterFilter
    00151 {
    00152 public:
    00153         COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
    00154 };