Add colour space auto guess option to UI.
[xy_vsfilter.git] / src / filters / transform / vsfilter / DirectVobSubFilter.h
blobf24a1cd394356d08f93a77d0cca718d197698d34
1 /*
2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #pragma once
24 #include <atlsync.h>
25 #include "DirectVobSub.h"
26 #include "../BaseVideoFilter/BaseVideoFilter.h"
27 #include "../../../subtitles/VobSubFile.h"
28 #include "../../../subtitles/RTS.h"
29 #include "../../../subtitles/SSF.h"
31 typedef struct
33 HWND hSystrayWnd;
34 IFilterGraph* graph;
35 IDirectVobSub* dvs;
36 bool fRunOnce, fShowIcon;
37 } SystrayIconData;
39 /* This is for graphedit */
41 [uuid("93A22E7A-5091-45ef-BA61-6DA26156A5D0")]
42 class CDirectVobSubFilter
43 : public CBaseVideoFilter
44 , public CDirectVobSub
45 , public ISpecifyPropertyPages
46 , public IAMStreamSelect
47 , public CAMThread
49 friend class CTextInputPin;
51 CCritSec m_csQueueLock;
52 CComPtr<ISubPicQueueEx> m_pSubPicQueue;
53 void InitSubPicQueue();
54 SubPicDesc m_spd;
56 bool AdjustFrameSize(CSize& s);
58 HRESULT TryNotCopy( IMediaSample* pIn, const CMediaType& mt, const BITMAPINFOHEADER& bihIn );
59 protected:
60 void GetOutputSize(int& w, int& h, int& arx, int& ary);
61 HRESULT Transform(IMediaSample* pIn);
62 public:
63 CDirectVobSubFilter(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid = __uuidof(CDirectVobSubFilter));
64 virtual ~CDirectVobSubFilter();
66 DECLARE_IUNKNOWN;
67 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
69 // CBaseFilter
71 CBasePin* GetPin(int n);
72 int GetPinCount();
74 STDMETHODIMP JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName);
75 STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
77 // CTransformFilter
78 HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pMediaType),
79 CheckConnect(PIN_DIRECTION dir, IPin* pPin),
80 CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePin),
81 BreakConnect(PIN_DIRECTION dir),
82 StartStreaming(),
83 StopStreaming(),
84 NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
86 CAtlArray<CTextInputPin*> m_pTextInput;
88 // IDirectVobSub
89 STDMETHODIMP put_FileName(WCHAR* fn);
90 STDMETHODIMP get_LanguageCount(int* nLangs);
91 STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName);
92 STDMETHODIMP put_SelectedLanguage(int iSelected);
93 STDMETHODIMP put_HideSubtitles(bool fHideSubtitles);
94 STDMETHODIMP put_PreBuffering(bool fDoPreBuffering);
95 STDMETHODIMP put_ColourSpace(int colourSpace);
96 STDMETHODIMP put_Placement(bool fOverridePlacement, int xperc, int yperc);
97 STDMETHODIMP put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fPolygonize);
98 STDMETHODIMP put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer);
99 STDMETHODIMP put_SubtitleTiming(int delay, int speedmul, int speeddiv);
101 STDMETHODIMP put_OverlayCacheMaxItemNum(int overlay_cache_max_item_num);
102 STDMETHODIMP put_ScanLineDataCacheMaxItemNum(int scan_line_data_cache_max_item_num);
103 STDMETHODIMP put_PathDataCacheMaxItemNum(int path_data_cache_max_item_num);
104 STDMETHODIMP put_OverlayNoBlurCacheMaxItemNum(int overlay_no_blur_cache_max_item_num);
106 STDMETHODIMP get_CachesInfo(CachesInfo* caches_info);
108 STDMETHODIMP put_SubpixelPositionLevel(int subpixel_pos_level);
110 STDMETHODIMP get_MediaFPS(bool* fEnabled, double* fps);
111 STDMETHODIMP put_MediaFPS(bool fEnabled, double fps);
112 STDMETHODIMP get_ZoomRect(NORMALIZEDRECT* rect);
113 STDMETHODIMP put_ZoomRect(NORMALIZEDRECT* rect);
114 STDMETHODIMP HasConfigDialog(int iSelected);
115 STDMETHODIMP ShowConfigDialog(int iSelected, HWND hWndParent);
117 // IDirectVobSub2
118 STDMETHODIMP put_TextSettings(STSStyle* pDefStyle);
119 STDMETHODIMP put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType);
121 // ISpecifyPropertyPages
122 STDMETHODIMP GetPages(CAUUID* pPages);
124 // IAMStreamSelect
125 STDMETHODIMP Count(DWORD* pcStreams);
126 STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
127 STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
129 // CPersistStream
130 STDMETHODIMP GetClassID(CLSID* pClsid);
132 protected:
133 HRESULT ChangeMediaType(int iPosition);
135 HDC m_hdc;
136 HBITMAP m_hbm;
137 HFONT m_hfont;
138 void PrintMessages(BYTE* pOut);
140 /* ResX2 */
141 CAutoVectorPtr<BYTE> m_pTempPicBuff;
142 HRESULT Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, int bpp, const GUID& subtype, DWORD black);
143 // segment start time, absolute time
144 CRefTime m_tPrev;
145 REFERENCE_TIME CalcCurrentTime();
147 double m_fps;
149 // 3.x- versions of microsoft's mpeg4 codec output flipped image
150 bool m_fMSMpeg4Fix;
152 // don't set the "hide subtitles" stream until we are finished with loading
153 bool m_fLoading;
155 bool Open();
157 int FindPreferedLanguage(bool fHideToo = true);
158 void UpdatePreferedLanguages(CString lang);
160 CCritSec m_csSubLock;
161 CInterfaceList<ISubStream> m_pSubStreams;
162 DWORD_PTR m_nSubtitleId;
163 void UpdateSubtitle(bool fApplyDefStyle = true);
164 void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = true);
165 void InvalidateSubtitle(REFERENCE_TIME rtInvalidate = -1, DWORD_PTR nSubtitleId = -1);
167 // the text input pin is using these
168 void AddSubStream(ISubStream* pSubStream);
169 void RemoveSubStream(ISubStream* pSubStream);
170 void Post_EC_OLE_EVENT(CString str, DWORD_PTR nSubtitleId = -1);
172 private:
173 class CFileReloaderData
175 public:
176 ATL::CEvent EndThreadEvent, RefreshEvent;
177 CAtlList<CString> files;
178 CAtlArray<CTime> mtime;
179 } m_frd;
181 void SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handles);
182 DWORD ThreadProc();
184 private:
185 HANDLE m_hSystrayThread;
186 SystrayIconData m_tbid;
188 VIDEOINFOHEADER2 m_CurrentVIH2;
190 //xy TIMING
191 long m_time_rasterization, m_time_alphablt;
194 /* The "auto-loading" version */
196 [uuid("9852A670-F845-491b-9BE6-EBD841B8A613")]
197 class CDirectVobSubFilter2 : public CDirectVobSubFilter
199 bool ShouldWeAutoload(IFilterGraph* pGraph);
200 void GetRidOfInternalScriptRenderer();
202 public:
203 CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid = __uuidof(CDirectVobSubFilter2));
205 HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
206 STDMETHODIMP JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName);
207 HRESULT CheckInputType(const CMediaType* mtIn);