|
1 /* |
|
2 * Copyright (c) 2009 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: Telephony Multimedia Service |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MP3CODEC_H__ |
|
20 #define __MP3CODEC_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <E32Base.h> |
|
24 |
|
25 // CONSTANTS |
|
26 |
|
27 // DATA TYPES |
|
28 |
|
29 // FORWARD DECLARATION |
|
30 class CMp3ToPcmDecoderImpl; |
|
31 |
|
32 // CLASS DEFINITIONS |
|
33 /* |
|
34 ----------------------------------------------------------------------------- |
|
35 |
|
36 TMp3DecParams |
|
37 |
|
38 MP3 decoding parameters. |
|
39 |
|
40 @since 2.1 |
|
41 |
|
42 ----------------------------------------------------------------------------- |
|
43 */ |
|
44 class TMp3DecParams |
|
45 { |
|
46 public: |
|
47 inline TMp3DecParams(); |
|
48 public: |
|
49 TInt iStereoToMono; // stereo to mono switch (TRUE or default FALSE) |
|
50 TInt iLeftRight; // decode left or right channel (1 left, 2 right, 0 default all) |
|
51 TInt iDecimFactor; // decimation factor (2, 4 or default 1) |
|
52 TInt iConcealment; // error concealment level (0 none, default 1) |
|
53 TInt iSampleLength; // resolution of PCM samples (default 16 bits) |
|
54 TInt iSamplingFrequency; //Output sampling frequency |
|
55 }; |
|
56 |
|
57 TMp3DecParams::TMp3DecParams() : |
|
58 iStereoToMono(0), iLeftRight(0), iDecimFactor(1), iConcealment(1), iSampleLength(16), iSamplingFrequency(0) {} |
|
59 |
|
60 |
|
61 |
|
62 /* |
|
63 ----------------------------------------------------------------------------- |
|
64 |
|
65 TMp3FrameInfo |
|
66 |
|
67 MP3 frame info struct. |
|
68 |
|
69 @since 2.1 |
|
70 |
|
71 ----------------------------------------------------------------------------- |
|
72 */ |
|
73 class TMp3FrameInfo |
|
74 { |
|
75 public: |
|
76 inline TMp3FrameInfo(); |
|
77 public: |
|
78 IMPORT_C static TInt MinFrameSize(); |
|
79 IMPORT_C static TInt MaxFrameSize(); |
|
80 IMPORT_C static TInt MaxFrameSamples(); |
|
81 IMPORT_C static TInt MaxChannels(); |
|
82 IMPORT_C static TInt MaxAncillaryBits(); |
|
83 IMPORT_C static TInt FrameHeaderSize(); |
|
84 IMPORT_C static TInt FrameSize(const TMp3FrameInfo& aInfo); |
|
85 public: |
|
86 TInt iId; // id of algorithm (1 MPEG-1, 0 MPEG-2) |
|
87 TInt iLayer; // layer number (1, 2, 3 or 4) |
|
88 TInt iErrorProtection; // err prot flag (TRUE or FALSE, TRUE if err protected) |
|
89 TInt iBitrate; // bitrate (kbit/s) |
|
90 TInt iSamplingRate; // sampling frequency (Hz) |
|
91 TInt iPadding; // padding flag (TRUE or FALSE, TRUE if p slot exists) |
|
92 TInt iPrivateBit; // bit for private use |
|
93 TInt iMode; // audio mode (0 stereo, 1 jstereo, 2 dual, 3 mono) |
|
94 TInt iChannels; // number of audio channels (1 for mono, otherwise 2) |
|
95 TInt iCopyright; // copyright flag (TRUE or FALSE, TRUE if copyrighted) |
|
96 TInt iOrigCopy; // original flag (TRUE or FALSE, TRUE if original) |
|
97 TInt iFrameSize; // size of encoded frame (bytes) |
|
98 TInt iFrameSamples; // length of decoded frame (samples per channel) |
|
99 public: |
|
100 TInt iSamplingRateOut; // sampling frequency after conversion(s) (Hz) |
|
101 TInt iChannelsOut; // number of audio channels after conversion(s) (1 or 2) |
|
102 TInt iFrameSamplesOut; // length of decoded frame after conversion(s) (samples per channel) |
|
103 }; |
|
104 |
|
105 TMp3FrameInfo::TMp3FrameInfo() {} |
|
106 |
|
107 |
|
108 |
|
109 /* |
|
110 ----------------------------------------------------------------------------- |
|
111 |
|
112 CMp3ToPcmDecoder |
|
113 |
|
114 Low level MP3 decoding API. |
|
115 |
|
116 @since 2.1 |
|
117 |
|
118 ----------------------------------------------------------------------------- |
|
119 */ |
|
120 class CMp3ToPcmDecoder : public CBase |
|
121 { |
|
122 protected: |
|
123 IMPORT_C CMp3ToPcmDecoder(); |
|
124 IMPORT_C void ConstructL(); |
|
125 |
|
126 public: |
|
127 IMPORT_C static CMp3ToPcmDecoder* NewL(const TMp3DecParams& aConf); |
|
128 IMPORT_C virtual ~CMp3ToPcmDecoder(); |
|
129 IMPORT_C void Reset(); |
|
130 IMPORT_C void Reset(const TMp3DecParams& aConf); |
|
131 IMPORT_C static TInt FrameInfo(const TUint8* aBuf, TInt aBufLen, TMp3FrameInfo& aInfo); |
|
132 IMPORT_C static TInt FrameInfo(const TUint8* aBuf, TInt aBufLen, TMp3FrameInfo& aInfo, const TMp3DecParams& aConf); |
|
133 IMPORT_C static TInt SeekSync(const TUint8* aBuf, TInt aBufLen); |
|
134 IMPORT_C TInt Decode(TUint8* aSrc, TInt& aSrcUsed, TUint8* aDst, TInt& aDstLen, TInt aMuteFlag); |
|
135 IMPORT_C TInt Decode(TUint8* aSrc, TInt& aSrcUsed, TUint8* aDst1, TUint8* aDst2, TUint8* aDst3, TInt& aDstLen1, TInt& aDstLen2, TInt& aDstLen3, TInt aMuteFlag); |
|
136 private: |
|
137 CMp3ToPcmDecoderImpl* iState; |
|
138 }; |
|
139 |
|
140 #endif //__MP3CODEC_H__ |
|
141 //----------------------------------------------------------------------------- |
|
142 // End of File |
|
143 //----------------------------------------------------------------------------- |