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