|
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 "../../../Windows/Thread.h" |
|
9 #include "../../Common/StreamBinder.h" |
|
10 |
|
11 namespace NCoderMixer2 { |
|
12 |
|
13 // CreateEvents(); |
|
14 // { |
|
15 // SetCoderInfo() |
|
16 // Init Streams |
|
17 // set CompressEvent() |
|
18 // wait CompressionCompletedEvent |
|
19 // } |
|
20 |
|
21 struct CThreadCoderInfo: public CCoderInfo |
|
22 { |
|
23 NWindows::NSynchronization::CAutoResetEvent *CompressEvent; |
|
24 HANDLE ExitEvent; |
|
25 NWindows::NSynchronization::CAutoResetEvent *CompressionCompletedEvent; |
|
26 |
|
27 CObjectVector< CMyComPtr<ISequentialInStream> > InStreams; |
|
28 CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams; |
|
29 CRecordVector<ISequentialInStream *> InStreamPointers; |
|
30 CRecordVector<ISequentialOutStream *> OutStreamPointers; |
|
31 |
|
32 CMyComPtr<ICompressProgressInfo> Progress; // CMyComPtr |
|
33 HRESULT Result; |
|
34 |
|
35 CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams); |
|
36 void SetCoderInfo(const UInt64 **inSizes, |
|
37 const UInt64 **outSizes, ICompressProgressInfo *progress); |
|
38 ~CThreadCoderInfo(); |
|
39 bool WaitAndCode(); |
|
40 void CreateEvents(); |
|
41 }; |
|
42 |
|
43 |
|
44 // SetBindInfo() |
|
45 // for each coder |
|
46 // { |
|
47 // AddCoder[2]() |
|
48 // } |
|
49 // |
|
50 // for each file |
|
51 // { |
|
52 // ReInit() |
|
53 // for each coder |
|
54 // { |
|
55 // SetCoderInfo |
|
56 // } |
|
57 // SetProgressIndex(UInt32 coderIndex); |
|
58 // Code |
|
59 // } |
|
60 |
|
61 |
|
62 class CCoderMixer2MT: |
|
63 public ICompressCoder2, |
|
64 public CCoderMixer2, |
|
65 public CMyUnknownImp |
|
66 { |
|
67 MY_UNKNOWN_IMP |
|
68 |
|
69 public: |
|
70 STDMETHOD(Init)(ISequentialInStream **inStreams, |
|
71 ISequentialOutStream **outStreams); |
|
72 |
|
73 STDMETHOD(Code)(ISequentialInStream **inStreams, |
|
74 const UInt64 **inSizes, |
|
75 UInt32 numInStreams, |
|
76 ISequentialOutStream **outStreams, |
|
77 const UInt64 **outSizes, |
|
78 UInt32 numOutStreams, |
|
79 ICompressProgressInfo *progress); |
|
80 |
|
81 |
|
82 CCoderMixer2MT(); |
|
83 ~CCoderMixer2MT(); |
|
84 void AddCoderCommon(); |
|
85 void AddCoder(ICompressCoder *coder); |
|
86 void AddCoder2(ICompressCoder2 *coder); |
|
87 |
|
88 void ReInit(); |
|
89 void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) |
|
90 { _coderInfoVector[coderIndex].SetCoderInfo(inSizes, outSizes, NULL); } |
|
91 void SetProgressCoderIndex(UInt32 coderIndex) |
|
92 { _progressCoderIndex = coderIndex; } |
|
93 |
|
94 |
|
95 UInt64 GetWriteProcessedSize(UInt32 binderIndex) const; |
|
96 |
|
97 |
|
98 bool MyCode(); |
|
99 |
|
100 private: |
|
101 CBindInfo _bindInfo; |
|
102 CObjectVector<CStreamBinder> _streamBinders; |
|
103 CObjectVector<CThreadCoderInfo> _coderInfoVector; |
|
104 CRecordVector<NWindows::CThread> _threads; |
|
105 NWindows::CThread _mainThread; |
|
106 |
|
107 NWindows::NSynchronization::CAutoResetEvent _startCompressingEvent; |
|
108 CRecordVector<HANDLE> _compressingCompletedEvents; |
|
109 NWindows::NSynchronization::CAutoResetEvent _compressingFinishedEvent; |
|
110 |
|
111 NWindows::NSynchronization::CManualResetEvent _exitEvent; |
|
112 UInt32 _progressCoderIndex; |
|
113 |
|
114 public: |
|
115 void SetBindInfo(const CBindInfo &bindInfo); |
|
116 |
|
117 }; |
|
118 |
|
119 } |
|
120 #endif |
|
121 |