|
1 /* |
|
2 * Copyright (c) 2009 Aricent and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Aricent - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Header file of process engine. Declares class CBaseProcessEngine |
|
16 * which derives from CBaseEngine and provides implementation for |
|
17 * all pure virtual functions |
|
18 * |
|
19 */ |
|
20 #ifndef ARIPROCESSENGINE_H |
|
21 #define ARIPROCESSENGINE_H |
|
22 |
|
23 #include <E32base.h> |
|
24 #include "aribaseengine.h" |
|
25 #include "ariprint.h" |
|
26 |
|
27 NONSHARABLE_CLASS (CCmdPckg): public CBase |
|
28 { |
|
29 public: |
|
30 /** |
|
31 * Enumeration to be used to specify command type. All commands should |
|
32 * be of one of the 2 types given in this enumeration. |
|
33 */ |
|
34 enum TCmdType |
|
35 { |
|
36 /** |
|
37 * All commands for encoding a buffer should be of this type |
|
38 * @see CCmdPckg::CCmdPckg |
|
39 * |
|
40 */ |
|
41 EDoProcess, |
|
42 |
|
43 /** |
|
44 * Rest of the commands will be of this type |
|
45 */ |
|
46 EOther |
|
47 }; |
|
48 /** |
|
49 * Default constructor.Assigns the parameteres to corresponding |
|
50 * member variables. |
|
51 * @param aCmdType |
|
52 * The type of command (EDoProcess/EOther) |
|
53 * @param aPriority |
|
54 * The priority assigned to this command |
|
55 * @param aCmd |
|
56 * The command |
|
57 * @param aCmdData |
|
58 * Command specific data |
|
59 */ |
|
60 CCmdPckg ( TCmdType aCmdType, TInt aPriority, TInt aCmd = -1, |
|
61 TAny* aCmdData = NULL ); |
|
62 |
|
63 /**> Destructor */ |
|
64 ~CCmdPckg(); |
|
65 public: |
|
66 /** |
|
67 * Command type which will be either one of - EDoProcess/EOther |
|
68 */ |
|
69 TCmdType iCmdType; |
|
70 |
|
71 /** |
|
72 * The command. Any command which is not of type EDoProcess will be |
|
73 * processed in the wrapper. |
|
74 */ |
|
75 TInt iCmd; |
|
76 |
|
77 /** |
|
78 * Command specific data. |
|
79 */ |
|
80 TAny* iCmdData; |
|
81 |
|
82 /** |
|
83 * The priority link to store the commands in a priority based doubly |
|
84 * linked list. |
|
85 */ |
|
86 TPriQueLink iPriorityLink; |
|
87 }; |
|
88 |
|
89 NONSHARABLE_CLASS ( CBaseProcessEngine ) : public CBaseEngine, |
|
90 public CActive |
|
91 { |
|
92 public: |
|
93 |
|
94 /** |
|
95 * Enumeration to be used to specify the state of the process engine |
|
96 */ |
|
97 enum TState |
|
98 { |
|
99 EStart, |
|
100 EStop |
|
101 }; |
|
102 |
|
103 public: |
|
104 /** |
|
105 * Two-phased constructor. |
|
106 * @param aObserver |
|
107 * Pointer to observer to the process engine - HwDevice |
|
108 * @param aCodec |
|
109 * Pointer to wrapper |
|
110 * @param aInPlaceProcessing |
|
111 * |
|
112 * @param aProcessingAutomatic |
|
113 * |
|
114 * @return pointer to an instance of CBaseProcessEngine |
|
115 */ |
|
116 static CBaseProcessEngine* NewL ( MProcessEngineObserver* aObserver, |
|
117 MBaseCodec* aCodec, |
|
118 TBool aInPlaceProcessing, |
|
119 TBool aProcessingAutomatic = ETrue ); |
|
120 /**> Destructor */ |
|
121 virtual ~CBaseProcessEngine (); |
|
122 |
|
123 /** |
|
124 * Default constructor |
|
125 */ |
|
126 CBaseProcessEngine(); |
|
127 |
|
128 public: |
|
129 /** |
|
130 * From CBaseEngine |
|
131 * To add the input buffer to the Q |
|
132 * @param aBuffer |
|
133 * Pointer to an input buffer. |
|
134 * @return symbian wide error code |
|
135 */ |
|
136 TInt AddInput( TAny* aBuffer); |
|
137 |
|
138 /** |
|
139 * From CBaseEngine |
|
140 * To add the output buffer to the Q |
|
141 * @param aBuffer |
|
142 * Pointer to an output buffer. |
|
143 * @return symbian wide error code, KErrNone on success |
|
144 */ |
|
145 TInt AddOutput( TAny* aBuffer); |
|
146 |
|
147 /** |
|
148 * From CBaseEngine |
|
149 * Starts the processing |
|
150 * @return symbian wide error code, KErrNone on success |
|
151 */ |
|
152 TInt Start(); |
|
153 |
|
154 /** |
|
155 * From CBaseEngine |
|
156 * Stops the processing |
|
157 * @return symbian wide error code, KErrNone on success |
|
158 */ |
|
159 TInt Stop(); |
|
160 |
|
161 /** |
|
162 * From CBaseEngine |
|
163 * Processes the commands |
|
164 * @param aPriority |
|
165 * Priority of the encode command object |
|
166 */ |
|
167 void DoProcessL( TInt aPriority); |
|
168 |
|
169 /** |
|
170 * From CBaseEngine |
|
171 * Adds a new command to the priority queue of commands |
|
172 * @param aPriority |
|
173 * Priority of the command object |
|
174 * @param aCmd |
|
175 * The command |
|
176 * @param aCmdData |
|
177 * Command specific data |
|
178 */ |
|
179 void AddCommandL( TInt aPriority, TInt aCmd, TAny* aCmdData ); |
|
180 |
|
181 |
|
182 /** |
|
183 * From CBaseEngine |
|
184 * Resets the processing engine and flushes all the pending input and |
|
185 * output buffers. |
|
186 * Calls InputBufferConsumed and OutputBufferReady to give pending |
|
187 * input & output buffers with aError = KErrCancel. |
|
188 */ |
|
189 void Reset(); |
|
190 |
|
191 /** |
|
192 * From CBaseEngine |
|
193 * Returns a output buffer back to the HwDevice |
|
194 */ |
|
195 void ReturnOutputBuffers(); |
|
196 |
|
197 /** |
|
198 * From CBaseEngine |
|
199 * Gets the number of input buffers |
|
200 * @return returns the number of input buffers in process engine q |
|
201 */ |
|
202 TInt NumInputBuffers(); |
|
203 |
|
204 /** |
|
205 * From CBaseEngine |
|
206 * Gets the number of output buffers |
|
207 * @return returns the number of output buffers in process engine q |
|
208 */ |
|
209 TInt NumOutputBuffers(); |
|
210 |
|
211 /** |
|
212 * From CBaseEngine |
|
213 * Returns whether processing of an input buffer is going on or else |
|
214 * @return ETrue if processing in on going, else EFalse |
|
215 */ |
|
216 TBool IsProcessing(); |
|
217 |
|
218 /** |
|
219 * From CBaseEngine |
|
220 * Returns input buffer back to the HwDevice through callback |
|
221 */ |
|
222 void ReturnInputBuffers(); |
|
223 |
|
224 /** |
|
225 * From CBaseEngine |
|
226 * Returns all the input pictures added previously through callback |
|
227 */ |
|
228 void ReturnInput(); |
|
229 |
|
230 |
|
231 /** |
|
232 * From CBaseEngine |
|
233 * Returns the 1st buffer from the output buffer queue |
|
234 * @return returns pointer to the fetched output buffer |
|
235 */ |
|
236 virtual TAny* FetchOutputBuffer(); |
|
237 |
|
238 public: |
|
239 /** |
|
240 * From CBaseEngine |
|
241 * Called by MBaseCodec when processing is complete |
|
242 * @param aInpBuf |
|
243 * The input buffer sent for processing |
|
244 * @param aOutBuf |
|
245 * The output buffer |
|
246 * @param aState |
|
247 * The result of processing |
|
248 * @param aError |
|
249 * Error value returned from DoProcessL |
|
250 */ |
|
251 void ProcessingComplete( TAny *aInpBuf, TAny* aOutBuf, |
|
252 MBaseCodec::TCodecState aState, |
|
253 TInt aError ); |
|
254 |
|
255 /** |
|
256 * From CBaseEngine |
|
257 * Called by MBaseCodec when processing of commmands is complete |
|
258 * @param aCommand |
|
259 * The command which has been processed |
|
260 * @param aCmdData |
|
261 * Command specific data |
|
262 * @param aState |
|
263 * The result of processing |
|
264 * @param aError |
|
265 * Result of processing command |
|
266 */ |
|
267 void ProcessingCommandComplete( TInt aCommand, TAny* aCmdData, |
|
268 TInt aError ); |
|
269 |
|
270 private: |
|
271 |
|
272 void RunL (); |
|
273 |
|
274 void DoCancel (); |
|
275 |
|
276 TInt RunError( TInt aError ); |
|
277 |
|
278 private: |
|
279 |
|
280 void IssueRequest (); |
|
281 |
|
282 void ConstructL( MProcessEngineObserver* aObserver, |
|
283 MBaseCodec* aCodec, |
|
284 TBool aInPlaceProcessing, |
|
285 TBool aProcessingAutomatic ); |
|
286 |
|
287 TBool IsReadyForProcessing (); |
|
288 |
|
289 void ProcessNextCommand (); |
|
290 |
|
291 private: |
|
292 |
|
293 TPriQue<CCmdPckg> iCmdArray; |
|
294 RArray<TAny*> iInputArray; |
|
295 RArray<TAny*> iOutputArray; |
|
296 TState iState; |
|
297 MProcessEngineObserver* iProcEngineObserver; |
|
298 MBaseCodec* iCodec; |
|
299 TBool iInPlaceProc; |
|
300 TBool iAutomaticProc; |
|
301 TAny* iCurInputBuf; |
|
302 TAny* iCurOutputBuf; |
|
303 CCmdPckg* iCurCmd; |
|
304 TBool iIsProcessing; |
|
305 TBool iOutputBufferReadyCallBackPending; |
|
306 TInt iError; |
|
307 |
|
308 TInt iInputBufsAddedSoFar; |
|
309 TInt iOutputBufsAddedSoFar; |
|
310 }; |
|
311 |
|
312 |
|
313 #endif //ARIPROCESSENGINE_H |
|
314 |
|
315 |
|
316 |