|
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 * Plugin class for HeAac decoder. This class inherits CMMFCodec |
|
16 * class and implements the pure virtual functions of CMMFCodec. |
|
17 * The class also has a few private funtions. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef ARIHEAACDECMMFCODEC_H |
|
23 #define ARIHEAACDECMMFCODEC_H |
|
24 |
|
25 #include <mmfcodec.h> |
|
26 |
|
27 /** |
|
28 * This is a T-Class that holds the configuration |
|
29 * information of an AAC frame.The class has 8 data members. |
|
30 * The data members of this should be set to value of respective parameters |
|
31 * passed by the application. |
|
32 */ |
|
33 class TAacFrameInfo |
|
34 { |
|
35 public: |
|
36 TInt iOutFrameSize; |
|
37 TInt iNoOfSamples; |
|
38 TInt iSamplingFrequency; |
|
39 TInt iNoOfChannels; |
|
40 TInt iProfile; |
|
41 TInt iOutSamplingFrequency; |
|
42 TInt iExtObjectType; |
|
43 TInt iDownSampledMode; |
|
44 }; |
|
45 |
|
46 //Forward Declaration |
|
47 class CAriHeAacDecWrapper; |
|
48 |
|
49 // Class declaration |
|
50 class CAriHeAacDecMmfCodec:public CMMFCodec |
|
51 { |
|
52 public: //constructors and destructors |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 * @return pointer to an instance of CMMFCodec |
|
56 */ |
|
57 static CMMFCodec* NewL(); |
|
58 |
|
59 /**> Destructor */ |
|
60 ~CAriHeAacDecMmfCodec(); |
|
61 |
|
62 public: // From CMMFCodec |
|
63 |
|
64 /** |
|
65 * From CMMFCodec |
|
66 * Sets codec configuration. |
|
67 * The configuration data is passed in as a descriptor of type TDesC8. |
|
68 * @param aConfigType |
|
69 * The UID of the configuration data. |
|
70 * @param aParam |
|
71 * Descriptor with frame info parameters in the form of RArray |
|
72 */ |
|
73 virtual void ConfigureL( TUid aConfigType, const TDesC8& aParam ); |
|
74 |
|
75 /** |
|
76 * From CMMFCodec |
|
77 * Codec reset function used to flush out status information when a |
|
78 * reposition occurs. |
|
79 * This is used if the codec requires resetting prior to use. |
|
80 */ |
|
81 virtual void ResetL(); |
|
82 |
|
83 /** |
|
84 * From CMMFCodec |
|
85 * Processes the data in the specified source buffer and writes the |
|
86 * processed data to the specified destination buffer. |
|
87 * This function is synchronous, when the function returns the data |
|
88 * has been processed. The source buffer is converted to the appropriate |
|
89 * coding type in the destination buffer. The buffers can be of any |
|
90 * size, therefore there is no guarantee that all the source buffer can |
|
91 * be processed to fill the destination buffer or that all the source |
|
92 * buffer may be processed before the destination is full. This function |
|
93 * therefore returns the number of source, and destination, bytes |
|
94 * processed along with a process result code indicating completion |
|
95 * status.This function is synchronous, when the function returns the |
|
96 * data has been processed. The source buffer is converted to the |
|
97 * appropriate coding type in the destination buffer. The buffers can be |
|
98 * of any size, therefore there is no guarantee that all the source |
|
99 * buffer can be processed to fill the destination buffer or that all |
|
100 * the source buffer may be processed before the destination is full. |
|
101 * This function therefore returns the number of source,and destination, |
|
102 * bytes processed along with a process result code indicating completion |
|
103 * status.The aSource and aSink buffers passed in are derived from |
|
104 * CMMFBuffer. The buffer type (e.g. a CMMFDataBuffer) passed in should |
|
105 * be supported by the codec otherwise this function should leave with |
|
106 * KErrNotSupported. The position of the source buffer should be checked |
|
107 * by calling the source buffer's Position() member which indicates the |
|
108 * current source read position in bytes. The codec should start |
|
109 * processing from the current source buffer read position. The position |
|
110 * of the destination buffer should be checked by calling the destination |
|
111 * buffer's Position() method which indicates the current destination |
|
112 * write position in bytes. The codec should start writing to the |
|
113 * destination buffer at the current destination buffer write position. |
|
114 * This is a virtual function that each derived class must implement. |
|
115 * @see enum TCodecProcessResult |
|
116 * @param aSource |
|
117 * The source buffer containing data to encode or decode. |
|
118 * @param aDestination |
|
119 * The destination buffer to hold the data after encoding or |
|
120 * decoding. |
|
121 * @return The result of the processing. |
|
122 * @pre The function ConfigureL() should have been called. |
|
123 */ |
|
124 virtual TCodecProcessResult ProcessL( const CMMFBuffer& aSource, |
|
125 CMMFBuffer& aDestination ); |
|
126 |
|
127 private: |
|
128 /** |
|
129 * Default Constructor |
|
130 */ |
|
131 CAriHeAacDecMmfCodec(); |
|
132 /** |
|
133 * Symbian 2nd phase constructor . |
|
134 */ |
|
135 void ConstructL(); |
|
136 |
|
137 /** |
|
138 * Update the result with result status, source bytes consumed |
|
139 * and destination bytes added. |
|
140 * @param aStatus |
|
141 * status of the result like EProcessComplete |
|
142 * @param aSrcBytesConsumed |
|
143 * total bytes consumed from the source buffer |
|
144 * @param aDstBytesAdded |
|
145 * total bytes added to the destination buffer |
|
146 * @return result of the processing |
|
147 */ |
|
148 TCodecProcessResult Result( |
|
149 TCodecProcessResult::TCodecProcessResultStatus aStatus, |
|
150 TInt aSrcBytesConsumed,TInt aDstBytesAdded); |
|
151 |
|
152 /** |
|
153 * Copy the bytes from internal output buffer to destination buffer |
|
154 * @param aDst |
|
155 * pointer to the destination buffer |
|
156 * @param aDstBytesConsumed |
|
157 * total bytes added to the destination buffer |
|
158 * @return number of bytes copied to the destination buffer. |
|
159 */ |
|
160 TInt CopyToDstBuffer( CMMFDataBuffer* aDst, TInt& aDstBytesConsumed); |
|
161 |
|
162 /** |
|
163 * Copy the bytes from the source buffer to the internal input burrer |
|
164 * @param aSrc |
|
165 * pointer to the source buffer |
|
166 * @param aSrcBytesConsumed |
|
167 * total bytes consumed from the source buffer |
|
168 * @return number bytes copied from the source buffer |
|
169 */ |
|
170 TInt CopyFromSrcBuffer(const CMMFDataBuffer* aSrc, |
|
171 TInt& aSrcBytesConsumed); |
|
172 /** |
|
173 * Shifts the data in the input internal buffer to start position |
|
174 * @param aFromPos |
|
175 * position from where data has to shift |
|
176 * @param aToPos |
|
177 * position to where data has to shift |
|
178 */ |
|
179 void ShiftData( TInt aFromPos, TInt aToPos ); |
|
180 |
|
181 /** |
|
182 * Calls Decode with NULL as source |
|
183 * @param aDstLen |
|
184 * destination size in bytes |
|
185 */ |
|
186 void DecodeLastFrame( TInt& aDstLen ); |
|
187 |
|
188 private: //Data |
|
189 |
|
190 // Handle to wrapper class |
|
191 CAriHeAacDecWrapper* iCodec; |
|
192 |
|
193 TBool iConfigured; |
|
194 TInt iOutFrameSize; |
|
195 TUint8* iInternalBuffer; |
|
196 TBool iLastFrameDecoded; |
|
197 TInt iSrcUsed; |
|
198 TInt iFrameNum; |
|
199 TAacFrameInfo iFrameInfo; |
|
200 TInt iInternalInputBufferResidueLen; |
|
201 TInt iInternalOutputBufferResidueLen; |
|
202 TUint8* iInternalInputBuffer; |
|
203 TUint8* iInternalOutputBuffer; |
|
204 TInt iInternalOutputBufferPos; |
|
205 |
|
206 }; |
|
207 |
|
208 #endif /* ARIHEAACDECMMFCODEC_H */ |