www.pudn.com > src.rar > SubtitleSource.h


#pragma once 
 
#include  
 
#include "../vobsub/vobsub.h" 
 
// in millisecs  
// don't set it too low, because e.g. at 100 it can increase the output by megabytes for a two hour long film 
#define SUBALIGN 10000 
 
// our first format id 
#define __GAB1__ "GAB1" 
 
// our tags for __GAB1__ (ushort) + size (ushort) 
 
// "lang" + '0' 
#define __GAB1_LANGUAGE__ 0 
// (int)start+(int)stop+(char*)line+'0' 
#define __GAB1_ENTRY__ 1 
// L"lang" + '0' 
#define __GAB1_LANGUAGE_UNICODE__ 2 
// (int)start+(int)stop+(WCHAR*)line+'0' 
#define __GAB1_ENTRY_UNICODE__ 3 
 
// same as __GAB1__, but the size is (uint) and only __GAB1_LANGUAGE_UNICODE__ is valid 
#define __GAB2__ "GAB2" 
 
// (BYTE*) 
#define __GAB1_RAWTEXTSUBTITLE__ 4 
 
 
////////////////////////////////////////////////////////////////////////////////////////// 
 
class CSubtitleSource :  
		public CSource, 
		public CPersistStream, 
		public IFileSourceFilter 
{ 
public: 
    DECLARE_IUNKNOWN; 
    static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr); 
 
    // Reveals ISubtitleSource and ISpecifyPropertyPages 
    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv); 
 
    // CPersistStream override 
	DWORD GetSoftwareVersion(); 
    HRESULT WriteToStream(IStream* pStream); 
    HRESULT ReadFromStream(IStream* pStream); 
    STDMETHODIMP GetClassID(CLSID* pClsid); 
 
	// IFileSourceFilter interface 
	STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName, AM_MEDIA_TYPE *pmt); 
	STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt); 
 
private: 
    CSubtitleSource(LPUNKNOWN lpunk, HRESULT* phr); 
 
    CCritSec m_propsLock; 
 
	CString m_fn; 
}; 
 
class CSubtitleStream : public CSourceStream 
{ 
public: 
    CSubtitleStream(char* fn, HRESULT* phr, CSubtitleSource* pParent, LPCWSTR pPinName); 
	virtual ~CSubtitleStream(); 
 
    HRESULT FillBuffer(IMediaSample* pms); 
 
    HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties); 
 
	HRESULT CheckConnect(IPin* pPin); 
    HRESULT CheckMediaType(const CMediaType* pMediaType); 
    HRESULT GetMediaType(int iPosition, CMediaType* pmt); 
 
    HRESULT OnThreadCreate(); 
 
	bool Open(CString fn); 
 
private: 
    CCritSec m_cSharedState; 
 
	bool m_fRAWOutput; 
 
	CSimpleTextSubtitle m_sts; 
	 
	CString m_name; 
	int m_duration, m_filesize; 
	BYTE* m_data; 
	bool m_fOutputDone; 
 
	int m_currentidx; 
};