1 // CoderMixer2MT.h 2 3 #ifndef __CODER_MIXER2_MT_H 4 #define __CODER_MIXER2_MT_H 5 6 #include "CoderMixer2.h" 7 #include "../../../Common/MyCom.h" 8 #include "../../Common/StreamBinder.h" 9 #include "../../Common/VirtThread.h" 10 11 namespace NCoderMixer { 12 13 struct CCoder2: public CCoderInfo2, public CVirtThread 14 { 15 CRecordVector<ISequentialInStream*> InStreamPointers; 16 CRecordVector<ISequentialOutStream*> OutStreamPointers; 17 18 public: 19 HRESULT Result; 20 CObjectVector< CMyComPtr<ISequentialInStream> > InStreams; 21 CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams; 22 23 CCoder2(UInt32 numInStreams, UInt32 numOutStreams); ~CCoder2CCoder224 ~CCoder2() { CVirtThread::WaitThreadFinish(); } 25 // void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes); 26 virtual void Execute(); 27 void Code(ICompressProgressInfo *progress); 28 }; 29 30 31 /* 32 SetBindInfo() 33 for each coder 34 AddCoder[2]() 35 SetProgressIndex(UInt32 coderIndex); 36 37 for each file 38 { 39 ReInit() 40 for each coder 41 SetCoderInfo 42 Code 43 } 44 */ 45 46 class CCoderMixer2MT: 47 public ICompressCoder2, 48 public CCoderMixer2, 49 public CMyUnknownImp 50 { 51 CBindInfo _bindInfo; 52 CObjectVector<CStreamBinder> _streamBinders; 53 unsigned _progressCoderIndex; 54 55 void AddCoderCommon(); 56 HRESULT Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams); 57 HRESULT ReturnIfError(HRESULT code); 58 public: 59 CObjectVector<CCoder2> _coders; 60 MY_UNKNOWN_IMP 61 62 STDMETHOD(Code)(ISequentialInStream **inStreams, 63 const UInt64 **inSizes, 64 UInt32 numInStreams, 65 ISequentialOutStream **outStreams, 66 const UInt64 **outSizes, 67 UInt32 numOutStreams, 68 ICompressProgressInfo *progress); 69 70 HRESULT SetBindInfo(const CBindInfo &bindInfo); 71 void AddCoder(ICompressCoder *coder); 72 void AddCoder2(ICompressCoder2 *coder); SetProgressCoderIndex(unsigned coderIndex)73 void SetProgressCoderIndex(unsigned coderIndex) { _progressCoderIndex = coderIndex; } 74 75 void ReInit(); SetCoderInfo(UInt32 coderIndex,const UInt64 ** inSizes,const UInt64 ** outSizes)76 void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) 77 { _coders[coderIndex].SetCoderInfo(inSizes, outSizes); } GetWriteProcessedSize(UInt32 binderIndex)78 UInt64 GetWriteProcessedSize(UInt32 binderIndex) const 79 { return _streamBinders[binderIndex].ProcessedSize; } 80 }; 81 82 } 83 #endif 84