|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __CPROCENCODER_H__ |
|
22 #define __CPROCENCODER_H__ |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 #include <MMFCodec.h> |
|
27 |
|
28 #include "AudCommon.h" |
|
29 #include "ProcConstants.h" |
|
30 |
|
31 class CProcEncoder : public CBase |
|
32 { |
|
33 |
|
34 public: |
|
35 |
|
36 /* |
|
37 * Symbian constructors |
|
38 */ |
|
39 |
|
40 static CProcEncoder* NewL(); |
|
41 |
|
42 static CProcEncoder* NewLC(); |
|
43 |
|
44 /* |
|
45 * Destructor |
|
46 */ |
|
47 ~CProcEncoder(); |
|
48 |
|
49 |
|
50 /* |
|
51 * Initializes encoder |
|
52 * |
|
53 * @param aAudioType target audio type, EAudAMR and EAudAAC_MPEG4 supported |
|
54 * @param aTargetSamplingRate target sampling rate, 8000, 16000 supported, later 48000 |
|
55 * @param aChannelMode target channel mode EAudSingleChannel supported, stereo later |
|
56 * |
|
57 * @return ETrue if successful, EFalse if not |
|
58 * |
|
59 */ |
|
60 |
|
61 TBool InitL(TAudType aAudioType, TInt aTargetSamplingRate, TChannelMode aChannelMode, TInt aBitrate); |
|
62 |
|
63 /* |
|
64 * Feed the encoder |
|
65 * If the encoder has enough data, output is written to aEncBuffer |
|
66 * |
|
67 * @param aRawFrame input for the encoder, must have the same sample rate |
|
68 * and channel mode as the desired target |
|
69 * @param aEncBuffer buffer for output |
|
70 * @param aOutputDurationMilli duration of the output buffer in return |
|
71 * |
|
72 * @return ETrue if data was written to aEncBuffer, EFalse otherwise |
|
73 * |
|
74 */ |
|
75 TBool FillEncBufferL(const TDesC8& aRawFrame, HBufC8* aEncBuffer, TInt& aOutputDurationMilli); |
|
76 |
|
77 /* |
|
78 * Returns the destination audio type |
|
79 * |
|
80 * @return destination audio type |
|
81 */ |
|
82 TAudType DestAudType(); |
|
83 |
|
84 protected: |
|
85 |
|
86 // constructL |
|
87 void ConstructL(); |
|
88 |
|
89 // C++ constructor |
|
90 CProcEncoder(); |
|
91 |
|
92 // reallocates a data buffer |
|
93 void ReAllocBufferL( CMMFDataBuffer* aBuffer, TInt aNewMaxSize ); |
|
94 |
|
95 // feed codec |
|
96 void FeedCodecL( CMMFCodec* aCodec, CMMFDataBuffer* aSourceBuffer, CMMFDataBuffer* aDestBuffer ); |
|
97 |
|
98 // encodeL |
|
99 TCodecProcessResult EncodeL( CMMFCodec* aCodec, CMMFDataBuffer* aInBuffer, CMMFDataBuffer* aOutBuffer); |
|
100 |
|
101 // is the destination codec supported? |
|
102 TBool GetIsSupportedDestCodec(); |
|
103 |
|
104 // configure AMR encoder |
|
105 void ConfigureAMREncoderL(); |
|
106 |
|
107 // configure AAC encoder |
|
108 void ConfigureAACEncoderL(); |
|
109 |
|
110 // set destination codec |
|
111 void SetDestCodecL(); |
|
112 |
|
113 // is codec available? |
|
114 TBool CheckIfCodecAvailableL(const TDesC8& aCodecFourCCString, const TUid& aCodecUId); |
|
115 |
|
116 protected: |
|
117 |
|
118 // target audio type |
|
119 TAudType iAudioType; |
|
120 |
|
121 // is encoder ready for processing |
|
122 TBool iReady; |
|
123 |
|
124 // Input buffer for raw data |
|
125 CMMFDataBuffer* iSourceInputBuffer; |
|
126 |
|
127 // Input buffer for encoder (alternative output buffer for decoder). |
|
128 CMMFDataBuffer* iDestInputBuffer; |
|
129 |
|
130 // Codec used in decoding input audio to PCM16 |
|
131 CMMFCodec* iDestCodec; |
|
132 |
|
133 // Samplerate to encode to. |
|
134 TInt iToSampleRate; |
|
135 // Number of channels in output and input |
|
136 TInt iToChannels; |
|
137 |
|
138 // target bitrate |
|
139 TInt iToBitRate; |
|
140 |
|
141 // output duration |
|
142 TInt iOutputFrameDurationMilli; |
|
143 |
|
144 // sometimes more than one AMR frame are written to the output with one call |
|
145 TInt iNumberOfFramesInOutputBuffer; |
|
146 |
|
147 // buffer for output |
|
148 HBufC8* iEncBuffer; |
|
149 |
|
150 }; |
|
151 |
|
152 #endif |