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 #ifndef __CPROCADTSINFILEHANDLER_H__ |
|
21 #define __CPROCADTSINFILEHANDLER_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 #include "AudCommon.h" |
|
26 #include "ProcConstants.h" |
|
27 #include "ProcInFileHandler.h" |
|
28 #include "AACConstants.h" |
|
29 #include "ProcDecoder.h" |
|
30 |
|
31 |
|
32 |
|
33 class CProcADTSInFileHandler: public CProcInFileHandler |
|
34 { |
|
35 |
|
36 public: |
|
37 |
|
38 static CProcADTSInFileHandler* NewL(const TDesC& aFileName, |
|
39 RFile* aFileHandle, |
|
40 CAudClip* aClip, TInt aReadBufferSize, |
|
41 TInt aTargetSampleRate = 0, |
|
42 TChannelMode aChannelMode = EAudSingleChannel); |
|
43 |
|
44 static CProcADTSInFileHandler* NewLC(const TDesC& aFileName, |
|
45 RFile* aFileHandle, |
|
46 CAudClip* aClip, TInt aReadBufferSize, |
|
47 TInt aTargetSampleRate = 0, |
|
48 TChannelMode aChannelMode = EAudSingleChannel); |
|
49 |
|
50 |
|
51 // From base class |
|
52 |
|
53 void GetPropertiesL(TAudFileProperties* aProperties); |
|
54 |
|
55 /** |
|
56 * Seeks a certain audio frame for reading |
|
57 * |
|
58 * Possible leave codes: |
|
59 * |
|
60 * @param aTime time from the beginning of file in milliseconds |
|
61 * |
|
62 * @return ETrue if successful |
|
63 * EFalse if beyond the file |
|
64 */ |
|
65 TBool SeekAudioFrame(TInt32 aTime); |
|
66 |
|
67 |
|
68 /** |
|
69 * Seeks a cut in audio frame for reading |
|
70 * |
|
71 * Possible leave codes: |
|
72 * |
|
73 * |
|
74 * @return ETrue if successful |
|
75 * |
|
76 */ |
|
77 TBool SeekCutInFrame(); |
|
78 |
|
79 /** |
|
80 * |
|
81 * Sets the normalizing gain |
|
82 * |
|
83 * @param aFrameHandler AAC frame handler |
|
84 * |
|
85 * @return ETrue if successful |
|
86 */ |
|
87 TBool SetNormalizingGainL(const CProcFrameHandler* aFrameHandler); |
|
88 |
|
89 /* |
|
90 * Fills in aac info |
|
91 * |
|
92 * @param aAACInfo aac info |
|
93 * |
|
94 * @return ETrue if successful |
|
95 */ |
|
96 TBool GetInfoForFrameHandler(TAACFrameHandlerInfo& aAACInfo); |
|
97 |
|
98 |
|
99 /** |
|
100 * Generates decoder specific information for MP4/3GP files |
|
101 * |
|
102 * The caller is responsible for releasing aDecSpecInfo |
|
103 * |
|
104 * @param aBytes decoder specific info |
|
105 * @param aBufferSize max size of decSpecInfo |
|
106 * |
|
107 * @return ETrue if info was generated |
|
108 * EFalse if info was not generated (no need to release aFrame) |
|
109 */ |
|
110 TBool ReadAudioDecoderSpecificInfoL(HBufC8*& aBytes, TInt aBufferSize); |
|
111 |
|
112 |
|
113 ~CProcADTSInFileHandler(); |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 private: |
|
119 |
|
120 // constructL |
|
121 void ConstructL(const TDesC& aFileName, RFile* aFileHandle, CAudClip* aClip, TInt aReadBufferSize, |
|
122 TInt aTargetSampleRate = 0, TChannelMode aChannelMode = EAudSingleChannel); |
|
123 |
|
124 virtual TBool GetEncAudioFrameL(HBufC8*& aFrame, TInt& aSize, TInt32& aTime); |
|
125 |
|
126 // C++ constructor |
|
127 CProcADTSInFileHandler(); |
|
128 |
|
129 // Find the first AAC frame |
|
130 // There might be some stuff in the file before audio data (e.g. ID3 header) |
|
131 TBool FindFirstAACFrame(); |
|
132 |
|
133 // calculates the frame length based of 4th, 5th and 6th byte of ADTS header |
|
134 TUint CalculateAACFrameLength(TUint8 byte4, TUint8 byte5, TUint8 byte6); |
|
135 |
|
136 // fills in fields of aProperties based on ADTS header |
|
137 TBool ReadHeaderInformation(TAudFileProperties* aProperties); |
|
138 |
|
139 // fills in the rest of the fields |
|
140 TBool ReadOtherInformationL(TAudFileProperties* aProperties); |
|
141 |
|
142 private: |
|
143 |
|
144 // info for frame handler |
|
145 TAACFrameHandlerInfo* iFrameInfo; |
|
146 |
|
147 // MP4 decoder specific info |
|
148 HBufC8* iMP4DecSpecInfo; |
|
149 |
|
150 // offset of the first ADTS frame in a file |
|
151 TUint32 iFirstFrame; |
|
152 |
|
153 // flag to indicate whether the file can be parsed |
|
154 TBool iSupportedFile; |
|
155 |
|
156 // remainder if audio duration can't be handled accurately in TInt milliseconds, depends on sampling rate |
|
157 TReal iAACFrameLenRemainderMilli; |
|
158 |
|
159 }; |
|
160 |
|
161 #endif |
|