Support unrar64.dll
[xy_vsfilter.git] / src / subtitles / VobSubFileRipper.h
blob2abccc4ad0c41424e8485433b0e2c01a3cf0297f
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 <atlcoll.h>
25 #include "..\decss\VobFile.h"
26 #include "VobSubFile.h"
28 #pragma pack(push)
29 #pragma pack(1)
31 typedef struct
33 WORD perm_displ : 2;
34 WORD ratio : 2;
35 WORD system : 2;
36 WORD compression : 2;
37 WORD mode : 1;
38 WORD letterboxed : 1;
39 WORD source_res : 2;
40 WORD cbrvbr : 2;
41 WORD line21_2 : 1;
42 WORD line21_1 : 1;
43 } vidinfo;
45 typedef struct
47 BYTE vob, cell;
48 DWORD tTime, tOffset, tTotal;
49 DWORD start, end;
50 int iAngle;
51 bool fDiscontinuity;
52 } vc_t;
54 typedef struct
56 int nAngles;
57 CAtlArray<vc_t> angles[10];
58 int iSelAngle;
59 RGBQUAD pal[16];
60 WORD ids[32];
61 } PGC;
63 typedef struct VSFRipperData_t
65 CSize vidsize;
66 vidinfo vidinfo;
67 CAtlArray<PGC> pgcs;
68 int iSelPGC;
69 bool fResetTime, fClosedCaption, fForcedOnly;
71 bool fClose, fBeep, fAuto; // only used by the UI externally, but may be set through the parameter file
72 bool fCloseIgnoreError;
74 CAtlArray<UINT> selvcs;
75 CAtlMap<BYTE, bool> selids;
77 void Reset();
78 void Copy(struct VSFRipperData_t& rd);
80 } VSFRipperData;
82 typedef struct {__int64 start, end; DWORD vc;} vcchunk;
84 #pragma pack(pop)
86 // note: these interfaces only meant to be used internally with static linking
89 // IVSFRipperCallback
92 [uuid("9E2EBB5C-AD7C-452f-A48B-38685716AC46")]
93 interface IVSFRipperCallback : public IUnknown
95 STDMETHOD (OnMessage) (LPCTSTR msg) PURE;
96 STDMETHOD (OnProgress) (double progress /*0->1*/) PURE;
97 STDMETHOD (OnFinished) (bool fSucceeded) PURE;
100 // IVSFRipperCallbackImpl
102 #ifndef QI
103 #define QI(i) (riid == __uuidof(i)) ? GetInterface((i*)this, ppv) :
104 #endif
106 class IVSFRipperCallbackImpl : public CUnknown, public IVSFRipperCallback
108 protected:
109 DECLARE_IUNKNOWN
110 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
112 return
113 QI(IVSFRipperCallback)
114 __super::NonDelegatingQueryInterface(riid, ppv);
117 // IVSFRipperCallback
118 STDMETHODIMP OnMessage(LPCTSTR msg) {return S_FALSE;}
119 STDMETHODIMP OnProgress(double progress /*0->1*/) {return S_FALSE;}
120 STDMETHODIMP OnFinished(bool fSucceeded) {return S_FALSE;}
122 public:
123 IVSFRipperCallbackImpl() : CUnknown(NAME("IVSFRipperCallbackImpl"), NULL) {}
127 // IVSFRipper
130 [uuid("69F935BB-B8D0-43f5-AA2E-BBD0851CC9A6")]
131 interface IVSFRipper : public IUnknown
133 STDMETHOD (SetCallBack) (IVSFRipperCallback* pCallback) PURE;
134 STDMETHOD (LoadParamFile) (CString fn) PURE;
135 STDMETHOD (SetInput) (CString infn) PURE;
136 STDMETHOD (SetOutput) (CString outfn) PURE;
137 STDMETHOD (GetRipperData) (VSFRipperData& rd) PURE;
138 STDMETHOD (UpdateRipperData) (VSFRipperData& rd) PURE;
139 STDMETHOD (Index) () PURE;
140 STDMETHOD (IsIndexing) () PURE;
141 STDMETHOD (Abort) (bool fSavePartial) PURE;
144 class CVobSubFileRipper : public CVobSubFile, protected CAMThread, public IVSFRipper
146 private:
147 bool m_fThreadActive, m_fBreakThread, m_fIndexing;
148 enum {CMD_EXIT, CMD_INDEX};
149 DWORD ThreadProc();
150 bool Create();
154 typedef enum {LOG_INFO, LOG_WARNING, LOG_ERROR} log_t;
155 void Log(log_t type, LPCTSTR lpszFormat, ...);
156 void Progress(double progress);
157 void Finished(bool fSucceeded);
161 CCritSec m_csAccessLock;
162 CString m_infn, m_outfn;
163 CVobFile m_vob;
164 VSFRipperData m_rd;
166 bool LoadIfo(CString fn);
167 bool LoadVob(CString fn);
168 bool LoadChunks(CAtlArray<vcchunk>& chunks);
169 bool SaveChunks(CAtlArray<vcchunk>& chunks);
173 CCritSec m_csCallback;
174 CComPtr<IVSFRipperCallback> m_pCallback;
176 public:
177 CVobSubFileRipper();
178 virtual ~CVobSubFileRipper();
180 DECLARE_IUNKNOWN
181 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
183 // IVSFRipper
184 STDMETHODIMP SetCallBack(IVSFRipperCallback* pCallback);
185 STDMETHODIMP LoadParamFile(CString fn);
186 STDMETHODIMP SetInput(CString infn);
187 STDMETHODIMP SetOutput(CString outfn);
188 STDMETHODIMP GetRipperData(VSFRipperData& rd);
189 STDMETHODIMP UpdateRipperData(VSFRipperData& rd);
190 STDMETHODIMP Index();
191 STDMETHODIMP IsIndexing();
192 STDMETHODIMP Abort(bool fSavePartial);