Add a switch option for switching between use upstream filter's preferred media type...
[xy_vsfilter.git] / src / filters / transform / vsfilter / DirectVobSubFilter.h
blobf1dff5155a407541149d1c14df069addeec7631d
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 protected:
59 void GetOutputSize(int& w, int& h, int& arx, int& ary);
60 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 //CBaseVideoFilter
89 void GetInputColorspaces(ColorSpaceId *preferredOrder, UINT *count);
90 void GetOutputColorspaces(ColorSpaceId *preferredOrder, UINT *count);
92 // IDirectVobSub
93 STDMETHODIMP put_FileName(WCHAR* fn);
94 STDMETHODIMP get_LanguageCount(int* nLangs);
95 STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName);
96 STDMETHODIMP put_SelectedLanguage(int iSelected);
97 STDMETHODIMP put_HideSubtitles(bool fHideSubtitles);
98 STDMETHODIMP put_PreBuffering(bool fDoPreBuffering);
99 STDMETHODIMP put_UseBT709(bool fUseBT709);
100 STDMETHODIMP put_Placement(bool fOverridePlacement, int xperc, int yperc);
101 STDMETHODIMP put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fPolygonize);
102 STDMETHODIMP put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer);
103 STDMETHODIMP put_SubtitleTiming(int delay, int speedmul, int speeddiv);
105 STDMETHODIMP put_OverlayCacheMaxItemNum(int overlay_cache_max_item_num);
106 STDMETHODIMP put_ScanLineDataCacheMaxItemNum(int scan_line_data_cache_max_item_num);
107 STDMETHODIMP put_PathDataCacheMaxItemNum(int path_data_cache_max_item_num);
108 STDMETHODIMP put_OverlayNoBlurCacheMaxItemNum(int overlay_no_blur_cache_max_item_num);
110 STDMETHODIMP get_CachesInfo(CachesInfo* caches_info);
112 STDMETHODIMP put_SubpixelPositionLevel(int subpixel_pos_level);
114 STDMETHODIMP put_FollowUpstreamPreferredOrder(bool fFollowUpstreamPreferredOrder);
116 STDMETHODIMP get_MediaFPS(bool* fEnabled, double* fps);
117 STDMETHODIMP put_MediaFPS(bool fEnabled, double fps);
118 STDMETHODIMP get_ZoomRect(NORMALIZEDRECT* rect);
119 STDMETHODIMP put_ZoomRect(NORMALIZEDRECT* rect);
120 STDMETHODIMP HasConfigDialog(int iSelected);
121 STDMETHODIMP ShowConfigDialog(int iSelected, HWND hWndParent);
123 // IDirectVobSub2
124 STDMETHODIMP put_TextSettings(STSStyle* pDefStyle);
125 STDMETHODIMP put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType);
127 // ISpecifyPropertyPages
128 STDMETHODIMP GetPages(CAUUID* pPages);
130 // IAMStreamSelect
131 STDMETHODIMP Count(DWORD* pcStreams);
132 STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
133 STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
135 // CPersistStream
136 STDMETHODIMP GetClassID(CLSID* pClsid);
138 protected:
139 HRESULT ChangeMediaType(int iPosition);
141 HDC m_hdc;
142 HBITMAP m_hbm;
143 HFONT m_hfont;
144 void PrintMessages(BYTE* pOut);
146 /* ResX2 */
147 CAutoVectorPtr<BYTE> m_pTempPicBuff;
148 HRESULT Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, int bpp, const GUID& subtype, DWORD black);
150 // segment start time, absolute time
151 CRefTime m_tPrev;
152 REFERENCE_TIME CalcCurrentTime();
154 double m_fps;
156 // 3.x- versions of microsoft's mpeg4 codec output flipped image
157 bool m_fMSMpeg4Fix;
159 // don't set the "hide subtitles" stream until we are finished with loading
160 bool m_fLoading;
162 bool Open();
164 int FindPreferedLanguage(bool fHideToo = true);
165 void UpdatePreferedLanguages(CString lang);
167 CCritSec m_csSubLock;
168 CInterfaceList<ISubStream> m_pSubStreams;
169 DWORD_PTR m_nSubtitleId;
170 void UpdateSubtitle(bool fApplyDefStyle = true);
171 void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = true);
172 void InvalidateSubtitle(REFERENCE_TIME rtInvalidate = -1, DWORD_PTR nSubtitleId = -1);
174 // the text input pin is using these
175 void AddSubStream(ISubStream* pSubStream);
176 void RemoveSubStream(ISubStream* pSubStream);
177 void Post_EC_OLE_EVENT(CString str, DWORD_PTR nSubtitleId = -1);
179 private:
180 class CFileReloaderData
182 public:
183 ATL::CEvent EndThreadEvent, RefreshEvent;
184 CAtlList<CString> files;
185 CAtlArray<CTime> mtime;
186 } m_frd;
188 void SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handles);
189 DWORD ThreadProc();
191 private:
192 HANDLE m_hSystrayThread;
193 SystrayIconData m_tbid;
195 VIDEOINFOHEADER2 m_CurrentVIH2;
197 //xy TIMING
198 long m_time_rasterization, m_time_alphablt;
201 /* The "auto-loading" version */
203 [uuid("9852A670-F845-491b-9BE6-EBD841B8A613")]
204 class CDirectVobSubFilter2 : public CDirectVobSubFilter
206 bool ShouldWeAutoload(IFilterGraph* pGraph);
207 void GetRidOfInternalScriptRenderer();
209 public:
210 CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid = __uuidof(CDirectVobSubFilter2));
212 HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
213 STDMETHODIMP JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName);
214 HRESULT CheckInputType(const CMediaType* mtIn);