|
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 * Contains base class for process engine (CBaseEngine) and an abstract class |
|
16 * (MProcessEngineObserver) which has callback methods to indicate events like |
|
17 * completion of encoding, processing of a command etc. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef ARIBASEENGINE_H |
|
23 #define ARIBASEENGINE_H |
|
24 |
|
25 #include <E32base.h> |
|
26 #include "aribasecodec.h" |
|
27 |
|
28 /** |
|
29 * An abstract class which contains call back functions to be derived and |
|
30 * implemented by any module wishing to use the process engine. |
|
31 */ |
|
32 |
|
33 class MProcessEngineObserver |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 * From MProcessEngineObserver |
|
39 * The function is a callback to indicate the input buffer is consumed |
|
40 * @param aInp |
|
41 * Pointer to the input picture that has been processed |
|
42 * @param aError |
|
43 * Error code returned by process engine |
|
44 * @return error value |
|
45 */ |
|
46 virtual TInt InputBufferConsumed( TAny* aInp, TInt aError ) = 0; |
|
47 |
|
48 /** |
|
49 * From MProcessEngineObserver |
|
50 * The function is a callback to indicate the output buffer is ready |
|
51 * @param aOup |
|
52 * Pointer to the output picture that has been processed |
|
53 * @param aError |
|
54 * Error code returned by process engine |
|
55 * @return error value |
|
56 */ |
|
57 virtual TInt OutputBufferReady( TAny* aOup, TInt aError ) = 0; |
|
58 |
|
59 /** |
|
60 * From MProcessEngineObserver |
|
61 * The function indicates to hwdevice that process engine has finished |
|
62 * with the processing of command requested by hwdevice |
|
63 * @param aCmd |
|
64 * Command that has been processed by process engine |
|
65 * @param aCmdData |
|
66 * Pointer to command data that has been processed by process engine |
|
67 * @param aError |
|
68 * Error code corresponding to the command |
|
69 */ |
|
70 virtual void CommandProcessed( TInt aCmd, TAny* aCmdData, |
|
71 TInt aError ) = 0; |
|
72 /** |
|
73 * From CMMFVideoEncodeHwDevice |
|
74 * The function indicates to hwdevice that process engine has met with |
|
75 * an unrecoverable error during its processing |
|
76 * @param aError |
|
77 * The fatal error code |
|
78 */ |
|
79 virtual void FatalErrorFromProcessEngine( TInt aError ) = 0; |
|
80 }; |
|
81 |
|
82 |
|
83 /** |
|
84 * Base class for base process engine. This calls creates class |
|
85 * CAriH264encHwDeviceImpl which derives this class & provides |
|
86 * implementation for pure virtual functions present in this class. |
|
87 */ |
|
88 class CBaseEngine |
|
89 { |
|
90 public: |
|
91 |
|
92 /** |
|
93 * Enumeration to be used to set priority of an command |
|
94 */ |
|
95 enum TCmdPriority |
|
96 { |
|
97 ENormalPriority = 0, |
|
98 EStandardPriority = 1, |
|
99 EHighPriority = 2, |
|
100 EVeryHighPriority = 3 |
|
101 }; |
|
102 |
|
103 /** |
|
104 * Two-phased constructor. |
|
105 * @param aObserver |
|
106 * Pointer to observer to the process engine - HwDevice |
|
107 * @param aCodec |
|
108 * Pointer to wrapper |
|
109 * @param aInPlaceProcessing |
|
110 * |
|
111 * @param aProcessingAutomatic |
|
112 * |
|
113 * @return pointer to an instance of CBaseProcessEngine |
|
114 */ |
|
115 |
|
116 IMPORT_C static CBaseEngine* NewL( MProcessEngineObserver* aObserver, |
|
117 MBaseCodec* aCodec, |
|
118 TBool aInPlaceProcessing, |
|
119 TBool aProcessingAutomatic = ETrue ); |
|
120 |
|
121 /**> Destructor */ |
|
122 virtual ~CBaseEngine () |
|
123 { |
|
124 } |
|
125 |
|
126 |
|
127 public: |
|
128 |
|
129 /** |
|
130 * Adds an input buffer to the Q |
|
131 * @param aBuffer |
|
132 * Pointer to an input buffer. |
|
133 * @return symbian wide error code |
|
134 */ |
|
135 virtual TInt AddInput( TAny* aBuffer ) = 0; |
|
136 |
|
137 /** |
|
138 * Adds an output buffer to the Q |
|
139 * @param aBuffer |
|
140 * Pointer to an output buffer. |
|
141 * @return symbian wide error code |
|
142 */ |
|
143 virtual TInt AddOutput( TAny* aBuffer ) = 0; |
|
144 |
|
145 /** |
|
146 * Starts the processing |
|
147 * @return symbian wide error code, KErrNone on success |
|
148 */ |
|
149 virtual TInt Start() = 0; |
|
150 |
|
151 /** |
|
152 * Stops the processing |
|
153 * @return symbian wide error code, KErrNone on success |
|
154 */ |
|
155 virtual TInt Stop() = 0; |
|
156 |
|
157 /** |
|
158 * Processes the commands |
|
159 * @param aPriority |
|
160 * Priority of the encode command object |
|
161 */ |
|
162 virtual void DoProcessL( TInt aPriority ) = 0; |
|
163 |
|
164 /** |
|
165 * Adds a new command to the priority queue of commands |
|
166 * @param aPriority |
|
167 * Priority of the command object |
|
168 * @param aCmd |
|
169 * The command |
|
170 * @param aCmdData |
|
171 * Command specific data |
|
172 */ |
|
173 virtual void AddCommandL( TInt aPriority, TInt aCmd, TAny* aCmdData ) = 0; |
|
174 |
|
175 /** |
|
176 * Resets the processing engine and flushes all the pending input and |
|
177 * output buffers. |
|
178 * Calls InputBufferConsumed and OutputBufferReady to give pending |
|
179 * input & output buffers with aError = KErrCancel. |
|
180 */ |
|
181 virtual void Reset() = 0; |
|
182 |
|
183 /** |
|
184 * Returns a output buffer back to the HwDevice |
|
185 */ |
|
186 virtual void ReturnOutputBuffers() = 0; |
|
187 |
|
188 /** |
|
189 * Gets the number of input buffers |
|
190 * @return returns the number of input buffers in process engine q |
|
191 */ |
|
192 virtual TInt NumInputBuffers() = 0; |
|
193 |
|
194 /** |
|
195 * Gets the number of output buffers |
|
196 * @return returns the number of output buffers in process engine q |
|
197 */ |
|
198 virtual TInt NumOutputBuffers() = 0; |
|
199 |
|
200 /** |
|
201 * Returns whether processing of an input buffer is going on or else |
|
202 * @return ETrue if processing in on going, else EFalse |
|
203 */ |
|
204 virtual TBool IsProcessing() = 0; |
|
205 |
|
206 /** |
|
207 * Returns input buffer back to the HwDevice |
|
208 */ |
|
209 virtual void ReturnInputBuffers() = 0; |
|
210 |
|
211 /** |
|
212 * Returns all the input pictures added previously. |
|
213 */ |
|
214 virtual void ReturnInput() = 0; |
|
215 |
|
216 public: |
|
217 |
|
218 /** |
|
219 * Called by MBaseCodec when processing is complete |
|
220 * @param aInpBuf |
|
221 * The input buffer sent for processing |
|
222 * @param aOutBuf |
|
223 * The output buffer |
|
224 * @param aState |
|
225 * The result of processing |
|
226 * @param aError |
|
227 * Error value returned from DoProcessL |
|
228 */ |
|
229 virtual void ProcessingComplete( TAny *aInpBuf, TAny* aOutBuf, |
|
230 MBaseCodec::TCodecState aState, TInt aError ) = 0; |
|
231 |
|
232 /** |
|
233 * Called by MBaseCodec when processing of commmands is complete |
|
234 * @param aCommand |
|
235 * The command which has been processed |
|
236 * @param aCmdData |
|
237 * Command specific data |
|
238 * @param aState |
|
239 * The result of processing |
|
240 * @param aError |
|
241 * Result of processing command |
|
242 */ |
|
243 |
|
244 virtual void ProcessingCommandComplete( TInt aCommand, TAny* aCmdData, |
|
245 TInt aError ) = 0; |
|
246 /** |
|
247 * Returns the 1st buffer from the output buffer queue |
|
248 * @return returns pointer to the fetched output buffer |
|
249 */ |
|
250 virtual TAny* FetchOutputBuffer() = 0; |
|
251 }; |
|
252 |
|
253 #endif //ARIBASEENGINE_H |
|
254 |
|
255 |
|
256 |