|
1 /* |
|
2 * Copyright (c) 2004 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: Recognizer for AAC files. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <f32file.h> |
|
22 #include <barsread.h> |
|
23 #include <implementationproxy.h> |
|
24 #include "AACAudioPlayControllerRecognizer.h" |
|
25 |
|
26 // LOCAL CONSTANTS AND MACROS |
|
27 const TUid KUidMimeAacRecognizer = {0x101FAF96}; |
|
28 const TInt KExtLength = 4; |
|
29 |
|
30 _LIT(KDotAac, ".aac"); |
|
31 _LIT8(KAacMimeType, "audio/aac"); |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CAACAudioPlayControllerRecognizer::CAACAudioPlayControllerRecognizer() |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // Call base constructor with the recognizer's UID and confidence level |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CAACAudioPlayControllerRecognizer::CAACAudioPlayControllerRecognizer() |
|
43 : CApaDataRecognizerType(KUidMimeAacRecognizer, CApaDataRecognizerType::EHigh) |
|
44 { |
|
45 // Set the number of data (MIME) types supported by this recognizer. |
|
46 iCountDataTypes = 1; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CAACAudioPlayControllerRecognizer::ConstructL() |
|
51 // Symbian 2nd phase constructor can leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CAACAudioPlayControllerRecognizer::ConstructL() |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CAACAudioPlayControllerRecognizer::NewL() |
|
60 // Two-phased constructor. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CAACAudioPlayControllerRecognizer* CAACAudioPlayControllerRecognizer::NewL() |
|
64 { |
|
65 #ifdef _DEBUG |
|
66 RDebug::Print(_L("CAACAudioPlayControllerRecognizer::NewL")); |
|
67 #endif |
|
68 CAACAudioPlayControllerRecognizer* self = new (ELeave) CAACAudioPlayControllerRecognizer(); |
|
69 CleanupStack::PushL(self); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop(self); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // Destructor |
|
76 CAACAudioPlayControllerRecognizer::~CAACAudioPlayControllerRecognizer() |
|
77 { |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CAACAudioPlayControllerRecognizer::SupportedDataTypeL |
|
82 // Return the MimeType of the DataType depending on |
|
83 // mime type of the file |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 TDataType CAACAudioPlayControllerRecognizer::SupportedDataTypeL( |
|
87 TInt aIndex ) const |
|
88 { |
|
89 #ifdef _DEBUG |
|
90 RDebug::Print(_L("CAACAudioPlayControllerRecognizer::SupportedDataTypeL [%d]"), aIndex); |
|
91 #endif |
|
92 TDataType dataType; |
|
93 switch ( aIndex ) |
|
94 { |
|
95 case 0: |
|
96 dataType = TDataType(KAacMimeType); |
|
97 break; |
|
98 default: |
|
99 User::Leave(KErrArgument); |
|
100 break; |
|
101 } |
|
102 return dataType; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CAACAudioPlayControllerRecognizer::PreferredBufSize() |
|
107 // Return the supposed minimum buffer size we need to |
|
108 // successfully recognize the data |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 TUint CAACAudioPlayControllerRecognizer::PreferredBufSize() |
|
112 { |
|
113 return 0; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CAACAudioPlayControllerRecognizer::DoRecognizeL |
|
118 // Attempt to recognize the data |
|
119 // this recognizer only attempts to match the data and/or file suffix |
|
120 // |
|
121 // NB if the file is not recognized, this function should NOT leave : |
|
122 // it should instead set iConfidence = ENotRecognized and return |
|
123 // the function should only leave if there is an out-of-memory condition |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CAACAudioPlayControllerRecognizer::DoRecognizeL( |
|
127 const TDesC& aName, |
|
128 const TDesC8& /*aBuffer*/ ) |
|
129 { |
|
130 #ifdef _DEBUG |
|
131 RDebug::Print(_L("CAACAudioPlayControllerRecognizer::DoRecognizeL: ")); |
|
132 RDebug::RawPrint(aName); |
|
133 RDebug::Print(_L(" ")); |
|
134 #endif |
|
135 // assume match will fail |
|
136 iConfidence = CApaDataRecognizerType::ENotRecognized; |
|
137 if ( aName.Length() < KExtLength ) |
|
138 { |
|
139 #ifdef _DEBUG |
|
140 RDebug::Print(_L("CAACAudioPlayControllerRecognizer::DoRecognizeL - Ext not present")); |
|
141 #endif |
|
142 return; |
|
143 } |
|
144 |
|
145 if ( aName.Right( KDotAac.iTypeLength ).CompareF(KDotAac) == 0 ) |
|
146 { |
|
147 #ifdef _DEBUG |
|
148 RDebug::Print(_L("CAACAudioPlayControllerRecognizer::DoRecognizeL - Possible match!")); |
|
149 #endif |
|
150 iDataType = TDataType(KAacMimeType); |
|
151 iConfidence = EProbable; |
|
152 } |
|
153 } |
|
154 |
|
155 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CApaDataRecognizerType* CreateRecognizerL() |
|
159 // Used to create an instance of a CApaDataRecognizerType-derived class |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 CApaDataRecognizerType* CAACAudioPlayControllerRecognizer::CreateRecognizerL() |
|
163 { |
|
164 return new (ELeave) CAACAudioPlayControllerRecognizer (); |
|
165 } |
|
166 |
|
167 const TImplementationProxy ImplementationTable[] = |
|
168 { |
|
169 IMPLEMENTATION_PROXY_ENTRY(0x101FAFD7, CAACAudioPlayControllerRecognizer::CreateRecognizerL) |
|
170 }; |
|
171 |
|
172 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
173 { |
|
174 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
175 return ImplementationTable; |
|
176 } |
|
177 |
|
178 // End of file |