VobSubFileRipper.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 #pragma once
00023 
00024 #include <afxtempl.h>
00025 #include "..\decss\VobFile.h"
00026 #include "VobSubFile.h"
00027 
00028 #pragma pack(push)
00029 #pragma pack(1)
00030 
00031 typedef struct
00032 {
00033         WORD perm_displ       : 2;
00034         WORD ratio            : 2;
00035         WORD system           : 2;
00036         WORD compression      : 2;
00037         WORD mode             : 1;
00038         WORD letterboxed      : 1;
00039         WORD source_res       : 2;
00040         WORD cbrvbr           : 2;
00041         WORD line21_2         : 1;
00042         WORD line21_1         : 1;
00043 } vidinfo;
00044 
00045 typedef struct 
00046 {
00047         BYTE vob, cell; 
00048         DWORD tTime, tOffset, tTotal; 
00049         DWORD start, end;
00050         int iAngle; 
00051         bool fDiscontinuity;
00052 } vc_t;
00053 
00054 typedef struct 
00055 {
00056         int nAngles;
00057         CArray<vc_t> angles[10];
00058         int iSelAngle;
00059         RGBQUAD pal[16];
00060         WORD ids[32];
00061 } PGC;
00062 
00063 typedef struct VSFRipperData_t
00064 {
00065         CSize vidsize;
00066         vidinfo vidinfo;
00067         CArray<PGC> pgcs;
00068         int iSelPGC;
00069         bool fResetTime, fClosedCaption, fForcedOnly;
00070 
00071         bool fClose, fBeep, fAuto; // only used by the UI externally, but may be set through the parameter file
00072         bool fCloseIgnoreError;
00073 
00074         CUIntArray selvcs;
00075         CMap<BYTE, BYTE, bool, bool> selids;
00076 
00077         void Reset();
00078         void Copy(struct VSFRipperData_t& rd);
00079 
00080 } VSFRipperData;
00081 
00082 typedef struct {__int64 start, end; DWORD vc;} vcchunk;
00083 
00084 #pragma pack(pop)
00085 
00086 // note: these interfaces only meant to be used internally with static linking
00087 
00088 //
00089 // IVSFRipperCallback
00090 //
00091 
00092 [uuid("9E2EBB5C-AD7C-452f-A48B-38685716AC46")]
00093 interface IVSFRipperCallback : public IUnknown
00094 {
00095         STDMETHOD (OnMessage) (LPCTSTR msg) PURE;
00096         STDMETHOD (OnProgress) (double progress /*0->1*/) PURE;
00097         STDMETHOD (OnFinished) (bool fSucceeded) PURE;
00098 };
00099 
00100 // IVSFRipperCallbackImpl
00101 
00102 #ifndef QI
00103 #define QI(i) (riid == __uuidof(i)) ? GetInterface((i*)this, ppv) :
00104 #endif
00105 
00106 class IVSFRipperCallbackImpl : public CUnknown, public IVSFRipperCallback
00107 {
00108 protected:
00109         DECLARE_IUNKNOWN
00110     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
00111         {
00112                 return 
00113                         QI(IVSFRipperCallback)
00114                         __super::NonDelegatingQueryInterface(riid, ppv);
00115         }
00116 
00117         // IVSFRipperCallback
00118         STDMETHODIMP OnMessage(LPCTSTR msg) {return S_FALSE;}
00119         STDMETHODIMP OnProgress(double progress /*0->1*/) {return S_FALSE;}
00120         STDMETHODIMP OnFinished(bool fSucceeded) {return S_FALSE;}
00121 
00122 public:
00123         IVSFRipperCallbackImpl() : CUnknown(NAME("IVSFRipperCallbackImpl"), NULL) {}
00124 };
00125 
00126 //
00127 // IVSFRipper
00128 //
00129 
00130 [uuid("69F935BB-B8D0-43f5-AA2E-BBD0851CC9A6")]
00131 interface IVSFRipper : public IUnknown
00132 {
00133         STDMETHOD (SetCallBack) (IVSFRipperCallback* pCallback) PURE;
00134         STDMETHOD (LoadParamFile) (CString fn) PURE;
00135         STDMETHOD (SetInput) (CString infn) PURE;
00136         STDMETHOD (SetOutput) (CString outfn) PURE;
00137         STDMETHOD (GetRipperData) (VSFRipperData& rd) PURE;
00138         STDMETHOD (UpdateRipperData) (VSFRipperData& rd) PURE;
00139         STDMETHOD (Index) () PURE;
00140         STDMETHOD (IsIndexing) () PURE;
00141         STDMETHOD (Abort) (bool fSavePartial) PURE;
00142 };
00143 
00144 class CVobSubFileRipper : public CVobSubFile, protected CAMThread, public IVSFRipper
00145 {
00146 private:
00147         bool m_fThreadActive, m_fBreakThread, m_fIndexing;
00148         enum {CMD_EXIT, CMD_INDEX};
00149         DWORD ThreadProc();
00150         bool Create();
00151 
00152         //
00153 
00154         typedef enum {LOG_INFO, LOG_WARNING, LOG_ERROR} log_t;
00155         void Log(log_t type, LPCTSTR lpszFormat, ...);
00156         void Progress(double progress);
00157         void Finished(bool fSucceeded);
00158 
00159         //
00160 
00161         CCritSec m_csAccessLock;
00162         CString m_infn, m_outfn;
00163         CVobFile m_vob;
00164         VSFRipperData m_rd;
00165 
00166         bool LoadIfo(CString fn);
00167         bool LoadVob(CString fn);
00168         bool LoadChunks(CArray<vcchunk>& chunks), SaveChunks(CArray<vcchunk>& chunks);
00169 
00170         //
00171 
00172         CCritSec m_csCallback;
00173         CComPtr<IVSFRipperCallback> m_pCallback;
00174 
00175 public:
00176     CVobSubFileRipper();
00177     virtual ~CVobSubFileRipper();
00178 
00179         DECLARE_IUNKNOWN
00180     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00181 
00182         // IVSFRipper
00183         STDMETHODIMP SetCallBack(IVSFRipperCallback* pCallback);
00184         STDMETHODIMP LoadParamFile(CString fn);
00185         STDMETHODIMP SetInput(CString infn);
00186         STDMETHODIMP SetOutput(CString outfn);
00187         STDMETHODIMP GetRipperData(VSFRipperData& rd);
00188         STDMETHODIMP UpdateRipperData(VSFRipperData& rd);
00189         STDMETHODIMP Index();
00190         STDMETHODIMP IsIndexing();
00191         STDMETHODIMP Abort(bool fSavePartial);
00192 };

Generated on Tue Dec 13 14:47:56 2005 for guliverkli by  doxygen 1.4.5