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 __CPROCMP3INFILEHANDLER_H__ |
|
21 #define __CPROCMP3INFILEHANDLER_H__ |
|
22 |
|
23 /*-- System Headers. --*/ |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 /*-- Project Headers. --*/ |
|
28 #include "AudCommon.h" |
|
29 #include "ProcFrameHandler.h" |
|
30 #include "ProcInFileHandler.h" |
|
31 #include "Logfile.h" |
|
32 |
|
33 #include "defines.h" |
|
34 |
|
35 #include "Mp3API.h" |
|
36 |
|
37 #include "ProcDecoder.h" |
|
38 //#include "mpif.h" |
|
39 |
|
40 |
|
41 |
|
42 /** |
|
43 * File handler class for accessing MP3 content. |
|
44 * |
|
45 * @author Juha Ojanperä |
|
46 */ |
|
47 class CProcMP3InFileHandler: public CProcInFileHandler |
|
48 { |
|
49 public: |
|
50 |
|
51 /* |
|
52 * Constructors & destructor |
|
53 */ |
|
54 |
|
55 static CProcMP3InFileHandler* NewL(const TDesC& aFileName, RFile* aFileHandle, |
|
56 CAudClip* aClip, TInt aReadBufferSize, |
|
57 TInt aTargetSampleRate = 0, |
|
58 TChannelMode aChannelMode = EAudSingleChannel); |
|
59 |
|
60 static CProcMP3InFileHandler* NewLC(const TDesC& aFileName, RFile* aFileHandle, |
|
61 CAudClip* aClip, TInt aReadBufferSize, |
|
62 TInt aTargetSampleRate = 0, |
|
63 TChannelMode aChannelMode = EAudSingleChannel); |
|
64 |
|
65 virtual ~CProcMP3InFileHandler(); |
|
66 |
|
67 |
|
68 // From CProcInFileHandler -----------------> |
|
69 void GetPropertiesL(TAudFileProperties* aProperties); |
|
70 |
|
71 TBool SeekAudioFrame(TInt32 aTime); |
|
72 |
|
73 TBool SeekCutInFrame(); |
|
74 |
|
75 virtual TBool GetDurationL(TInt32& aTime, TInt& aFrameAmount); |
|
76 |
|
77 virtual TBool SetNormalizingGainL(const CProcFrameHandler* aFrameHandler); |
|
78 |
|
79 //<----------------------------------------- |
|
80 |
|
81 |
|
82 private: |
|
83 |
|
84 // constructL |
|
85 void ConstructL(const TDesC& aFileName, RFile* aFileHandle, CAudClip* aClip, |
|
86 TInt aReadBufferSize, TInt aTargetSampleRate = 0, |
|
87 TChannelMode aChannelMode = EAudSingleChannel); |
|
88 |
|
89 // C++ constructor |
|
90 CProcMP3InFileHandler(); |
|
91 |
|
92 TBool GetEncAudioFrameL(HBufC8*& aFrame, TInt& aSize, TInt32& aTime); |
|
93 |
|
94 // gets one Mp3 frame |
|
95 int16 GetMP3Frame(uint8 *dataBytes, int16 bufSize, TMpFrameState *frState, uint8 syncStatus); |
|
96 |
|
97 // gets bitrate |
|
98 int16 GetMP3Bitrate(void); |
|
99 |
|
100 // check that file is valid mp3 |
|
101 TBool Validate(TDes8& aDes); |
|
102 |
|
103 // seek for frame sync codes |
|
104 TInt SeekSync(TDes8& aDes, TInt aBufPos); |
|
105 |
|
106 // get info for a single frame |
|
107 TInt FrameInfo(const TUint8* aBuf,TInt aBufLen,TInt& aBitRate); |
|
108 |
|
109 // get ID3 header length |
|
110 TInt ID3HeaderLength(TDes8& aDes, TInt aPosition); |
|
111 |
|
112 private: |
|
113 |
|
114 /*-- MP3 file format handle. --*/ |
|
115 TMpTransportHandle *mp3FileFormat; |
|
116 |
|
117 /*-- Legal MP3 file? --*/ |
|
118 uint8 isValidMP3; |
|
119 |
|
120 /*-- Input buffer; start of frame is seached from here. --*/ |
|
121 uint8 *mp3HeaderBytes; |
|
122 |
|
123 CLogFile *mp3Log; |
|
124 |
|
125 /*-- Free format flag. --*/ |
|
126 uint8 isFreeFormatMP3; |
|
127 |
|
128 |
|
129 // a handle to mp3 editing class in MP3AACManipLib |
|
130 CMp3Edit* iMp3Edit; |
|
131 |
|
132 /*-- VBR bitrate flag; ETrue indicates VBR file, EFalse constant. --*/ |
|
133 uint8 isVbrMP3; |
|
134 |
|
135 }; |
|
136 |
|
137 #endif /*-- __CPROCMP3INFILEHANDLER_H__ --*/ |
|