|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition of Advance Audio Encoder base class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CADVANCEDAUDIOENCODER_H |
|
21 #define CADVANCEDAUDIOENCODER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <sounddevice.h> |
|
26 #include <mmfcodecimplementationuids.hrh> |
|
27 |
|
28 // CONSTANTS |
|
29 const TUid KUidConfig = {KUidMmfCodecAudioSettings}; |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CMMFBuffer; |
|
33 class CMMFDataBuffer; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Mixin observer class to define an object capable of handling a callback from |
|
39 * CAdvancedAudioEncoder objects |
|
40 * |
|
41 * @lib AdvancedAudioController.lib |
|
42 * @since 3.0 |
|
43 */ |
|
44 class MAdvancedAudioEncoderObserver |
|
45 { |
|
46 public: |
|
47 |
|
48 /** |
|
49 * Callback function from CAdvancedAudioEncoder when the specified buffer |
|
50 * has been emptied. |
|
51 * @return - |
|
52 */ |
|
53 virtual void BufferEmptied() = 0; |
|
54 |
|
55 /** |
|
56 * Callback function from CAdvancedAudioEncoder when the specified buffer |
|
57 * needs to be emptied. This indicates a shared buffer is to be written to |
|
58 * external storage. |
|
59 * @param aBuffer an empty buffer to be refilled |
|
60 * @return - |
|
61 */ |
|
62 virtual void EmptyBuffer( CMMFBuffer* aBuffer ) = 0; |
|
63 |
|
64 /** |
|
65 * Callback function from CAdvancedAudioDecoder to handle specified event |
|
66 * @param aEvent the event to be handled |
|
67 * @return void |
|
68 */ |
|
69 virtual void SendEvent( const TMMFEvent& aEvent ) = 0; |
|
70 }; |
|
71 |
|
72 /** |
|
73 * This is the base class for all audio encoder classes. |
|
74 * It contains common behaviour for all audio encoders. The audio encoder class |
|
75 * provides the interface to audio codec. |
|
76 * |
|
77 * @lib AdvancedAudioController.lib |
|
78 * @since 3.0 |
|
79 */ |
|
80 class CAdvancedAudioEncoder : public CActive |
|
81 { |
|
82 public: |
|
83 |
|
84 /** |
|
85 * Destructor. |
|
86 */ |
|
87 IMPORT_C virtual ~CAdvancedAudioEncoder(); |
|
88 |
|
89 protected: |
|
90 |
|
91 /** |
|
92 * C++ default constructor. |
|
93 */ |
|
94 IMPORT_C CAdvancedAudioEncoder( TInt aPriority ); |
|
95 |
|
96 public: // New functions |
|
97 |
|
98 /** |
|
99 * Sets the DevSound instance to be used by the audio decoder. |
|
100 * @since 3.0 |
|
101 * @param aDevSound Devsound instance |
|
102 * @return void |
|
103 */ |
|
104 IMPORT_C virtual void SetDevSound( CMMFDevSound& aDevSound ); |
|
105 |
|
106 /** |
|
107 * Sets the observer object that will handle callbacks |
|
108 * @since 3.0 |
|
109 * @param aObserver Observer object that will handle callbacks |
|
110 * @return void |
|
111 */ |
|
112 IMPORT_C virtual void SetObserver( MAdvancedAudioEncoderObserver& aObserver ); |
|
113 |
|
114 /** |
|
115 * Sets the sink buffer for encoding operations. |
|
116 * @since 3.0 |
|
117 * @param aBuffers Pointer to shared buffers. |
|
118 * @return void |
|
119 */ |
|
120 IMPORT_C virtual void SetSinkBuffers( RPointerArray<CMMFDataBuffer>* aBuffers ); |
|
121 |
|
122 /** |
|
123 * Provides the audio encoder a buffer to process. |
|
124 * @since 3.0 |
|
125 * @param aBuffer a data buffer with data to encode. |
|
126 * @return - |
|
127 */ |
|
128 IMPORT_C virtual void EmptyBuffer( CMMFBuffer* aBuffer ); |
|
129 |
|
130 /** |
|
131 * Sets audio decoder settings and attributes. |
|
132 * @since 3.0 |
|
133 * @param aSampleRate a sink sampling rate |
|
134 * @param aNumChannel required number of channels (mono/stereo indication) |
|
135 * @param aSWConvertSampleRate a sampling rate after conversion |
|
136 * @param aSWConvertChannels number of channels after conversion |
|
137 * @param aCodecConfigData specific codec configuration data |
|
138 * |
|
139 * @return void |
|
140 */ |
|
141 IMPORT_C virtual void SetConfigL( TUint aSampleRate, TUint aChannels, |
|
142 TUint aSWConvertSampleRate, TUint aSWConvertChannels, |
|
143 const RArray<TInt>& aCodecConfigData ) = 0; |
|
144 |
|
145 /** |
|
146 * Sets the bit rate. |
|
147 * @since 3.0 |
|
148 * @param aBitRate bit rate |
|
149 * @param aCodecConfigData specific codec configuration data |
|
150 * |
|
151 * @return void |
|
152 */ |
|
153 IMPORT_C virtual void SetBitRateL( TUint aBitRate, const RArray<TInt>& aCodecConfigData ) = 0; |
|
154 |
|
155 /** |
|
156 * Resets audio encoder settings and attributes. |
|
157 * @since 3.0 |
|
158 * @return void |
|
159 */ |
|
160 IMPORT_C virtual void ResetL() = 0; |
|
161 |
|
162 /** |
|
163 * Check if the audio encoder is hardware accelerated. |
|
164 * @since 3.0 |
|
165 * @return ETrue if hardare accelerated, otherwise, EFalse. |
|
166 */ |
|
167 IMPORT_C virtual TBool IsHwAccelerated() = 0; |
|
168 |
|
169 /** |
|
170 * Stops encoding process. |
|
171 * @since 3.0 |
|
172 * @param none |
|
173 * @return void |
|
174 */ |
|
175 IMPORT_C virtual void Stop(); |
|
176 |
|
177 protected: // New functions |
|
178 |
|
179 /** |
|
180 * Handle emptying of the buffer received in EmptyBuffer(). |
|
181 * @param none |
|
182 * @return void |
|
183 */ |
|
184 IMPORT_C virtual void HandleEmptyBufferL() = 0; |
|
185 |
|
186 /** |
|
187 * Completes own request. |
|
188 */ |
|
189 IMPORT_C void Ready( TInt aRequest ); |
|
190 |
|
191 /** |
|
192 * Gets the next available shared buffer from the pool of shared buffers. |
|
193 * @param none |
|
194 * @return void |
|
195 */ |
|
196 IMPORT_C void NextSharedBufferL(); |
|
197 |
|
198 protected: // Functions from base classes |
|
199 |
|
200 /** |
|
201 * From CActive |
|
202 */ |
|
203 IMPORT_C virtual void RunL(); |
|
204 |
|
205 /** |
|
206 * From CActive |
|
207 */ |
|
208 IMPORT_C virtual void DoCancel(); |
|
209 |
|
210 protected: // Data |
|
211 |
|
212 enum TAudioEncoderState |
|
213 { |
|
214 EIdle, |
|
215 EEncoding |
|
216 }; |
|
217 |
|
218 enum TNextEvent |
|
219 { |
|
220 EDoNothing, |
|
221 EFlushBuffer, |
|
222 EPlayEnd |
|
223 }; |
|
224 |
|
225 // Encoder state |
|
226 TAudioEncoderState iState; |
|
227 |
|
228 // The request being handled asynchronously |
|
229 TInt iRequest; |
|
230 |
|
231 // array of shared buffers |
|
232 RPointerArray<CMMFDataBuffer>* iSharedBuffers; |
|
233 // next available buffer index |
|
234 TInt iSharedBufferIndex; |
|
235 |
|
236 // audio buffer to empty pointer |
|
237 CMMFBuffer* iBufferToEmpty; |
|
238 // next available buffer pointer |
|
239 CMMFBuffer* iNextBuffer; |
|
240 |
|
241 // DevSound pointer |
|
242 CMMFDevSound* iMMFDevSound; |
|
243 |
|
244 // Audio Converter observer |
|
245 MAdvancedAudioEncoderObserver* iObserver; |
|
246 }; |
|
247 |
|
248 #endif // CADVANCEDAUDIOENCODER_H |