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)
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
25 #include "DirectVobSub.h"
26 #include "../BaseVideoFilter/BaseVideoFilter.h"
27 #include "../../../subtitles/VobSubFile.h"
28 #include "../../../subtitles/RTS.h"
29 #include "../../../subtitles/SSF.h"
36 bool fRunOnce
, fShowIcon
;
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
49 friend class CTextInputPin
;
51 CCritSec m_csQueueLock
;
52 CComPtr
<ISubPicQueueEx
> m_pSubPicQueue
;
53 void InitSubPicQueue();
56 bool AdjustFrameSize(CSize
& s
);
59 void GetOutputSize(int& w
, int& h
, int& arx
, int& ary
);
60 HRESULT
Transform(IMediaSample
* pIn
);
63 CDirectVobSubFilter(LPUNKNOWN punk
, HRESULT
* phr
, const GUID
& clsid
= __uuidof(CDirectVobSubFilter
));
64 virtual ~CDirectVobSubFilter();
67 STDMETHODIMP
NonDelegatingQueryInterface(REFIID riid
, void** ppv
);
71 CBasePin
* GetPin(int n
);
74 STDMETHODIMP
JoinFilterGraph(IFilterGraph
* pGraph
, LPCWSTR pName
);
75 STDMETHODIMP
QueryFilterInfo(FILTER_INFO
* pInfo
);
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
),
84 NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
);
86 CAtlArray
<CTextInputPin
*> m_pTextInput
;
89 void GetInputColorspaces(ColorSpaceId
*preferredOrder
, UINT
*count
);
90 void GetOutputColorspaces(ColorSpaceId
*preferredOrder
, UINT
*count
);
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
);
124 STDMETHODIMP
put_TextSettings(STSStyle
* pDefStyle
);
125 STDMETHODIMP
put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType
* ePARCompensationType
);
127 // ISpecifyPropertyPages
128 STDMETHODIMP
GetPages(CAUUID
* pPages
);
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
);
136 STDMETHODIMP
GetClassID(CLSID
* pClsid
);
139 HRESULT
ChangeMediaType(int iPosition
);
144 void PrintMessages(BYTE
* pOut
);
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
152 REFERENCE_TIME
CalcCurrentTime();
156 // 3.x- versions of microsoft's mpeg4 codec output flipped image
159 // don't set the "hide subtitles" stream until we are finished with loading
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);
180 class CFileReloaderData
183 ATL::CEvent EndThreadEvent
, RefreshEvent
;
184 CAtlList
<CString
> files
;
185 CAtlArray
<CTime
> mtime
;
188 void SetupFRD(CStringArray
& paths
, CAtlArray
<HANDLE
>& handles
);
192 HANDLE m_hSystrayThread
;
193 SystrayIconData m_tbid
;
195 VIDEOINFOHEADER2 m_CurrentVIH2
;
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();
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
);