|
1 /* |
|
2 * Copyright (c) 2006 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: Play controller for AAC audio formats. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "AACAudioPlayControllerPlugin.h" |
|
21 #include "AACAudioPlayControllerPlugin.hrh" |
|
22 #include "AACAudioPlayControllerDecoderBuilder.h" |
|
23 #include "AACAudioPlayControllerResource.h" |
|
24 #include "DevSoundAudioOutput.h" |
|
25 #include "FileAudioOutput.h" |
|
26 #include "DebugMacros.h" |
|
27 |
|
28 |
|
29 // only EAACPlusAudioControllerUtility support AAC optimization |
|
30 //#ifdef __AAC_PLUS_DECODER_PLUGIN |
|
31 #include "EAACPlusAudioControllerUtility.h" |
|
32 /* |
|
33 #else |
|
34 #include "AACAudioControllerUtility.h" |
|
35 #endif |
|
36 */ |
|
37 |
|
38 // CONSTANTS |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CAACAudioPlayControllerPlugin::CAACAudioPlayControllerPlugin |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CAACAudioPlayControllerPlugin::CAACAudioPlayControllerPlugin() |
|
47 : iDecoderBuilder(NULL) |
|
48 { |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CAACAudioPlayControllerPlugin::ConstructL |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CAACAudioPlayControllerPlugin::ConstructL() |
|
56 { |
|
57 CAdvancedAudioPlayController::ConstructL(); |
|
58 |
|
59 iAudioResource = CAACAudioPlayControllerResource::NewL(); |
|
60 TAapProperties aapProperties = iAudioResource->PropertiesL(); |
|
61 iSharedBufferMaxNum = aapProperties.iSharedBufferMaxNum; |
|
62 iSharedBufferMaxSize = aapProperties.iSharedBufferMaxSize; |
|
63 iMetaDataSupport = aapProperties.iMetaDataSupport; |
|
64 |
|
65 iAudioUtility = CEAACPlusAudioControllerUtility::NewL(); |
|
66 iDecoderBuilder = CAACAudioPlayControllerDecoderBuilder::NewL(); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CAACAudioPlayControllerPlugin::NewL |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CAACAudioPlayControllerPlugin* CAACAudioPlayControllerPlugin::NewL() |
|
74 { |
|
75 DP0(_L("CAACAudioPlayControllerPlugin::NewL")); |
|
76 |
|
77 CAACAudioPlayControllerPlugin* self = new(ELeave) CAACAudioPlayControllerPlugin; |
|
78 CleanupStack::PushL(self); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop(self); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // Destructor |
|
85 CAACAudioPlayControllerPlugin::~CAACAudioPlayControllerPlugin() |
|
86 { |
|
87 DP0(_L("CAACAudioPlayControllerPlugin::~CAACAudioPlayControllerPlugin")); |
|
88 |
|
89 if (iIsDRMProtected) |
|
90 { |
|
91 delete iDataSource; |
|
92 } |
|
93 |
|
94 if ((iState != EStopped) && (iState != EInitializing) && iAudioOutput) |
|
95 { |
|
96 TRAPD(err, iAudioOutput->StopL()); |
|
97 err = err; |
|
98 } |
|
99 |
|
100 delete iDecoderBuilder; |
|
101 delete iAudioUtility; |
|
102 delete iAudioResource; |
|
103 delete iAudioOutput; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CAACAudioPlayControllerPlugin::DoAddDataSourceL |
|
108 // Initialization of Clip properties. We build a table needed for positioning. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CAACAudioPlayControllerPlugin::DoAddDataSourceL() |
|
112 { |
|
113 DP0(_L("CAACAudioPlayControllerPlugin::DoAddDataSourceL")); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CAACAudioPlayControllerPlugin::DoAddDataSinkL |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CAACAudioPlayControllerPlugin::DoAddDataSinkL() |
|
121 { |
|
122 DP0(_L("CAACAudioPlayControllerPlugin::DoAddDataSinkL")); |
|
123 |
|
124 if (iDataSink->DataSinkType() == KUidMmfAudioOutput) |
|
125 { |
|
126 iAudioOutput = CDevSoundAudioOutput::NewL(iPrioritySettings, *this, *iMMFDevSound); |
|
127 iDecoderType = KAACDecoder; |
|
128 } |
|
129 else if (iDataSink->DataSinkType() == KUidMmfFileSink) |
|
130 { |
|
131 iAudioOutput = CFileAudioOutput::NewL(*iDataSink, iPrioritySettings, *this); |
|
132 iDecoderType = KAACConverter; |
|
133 } |
|
134 else |
|
135 { |
|
136 User::Leave(KErrNotSupported); |
|
137 } |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CAACAudioPlayControllerPlugin::DoReadHeaderL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CAACAudioPlayControllerPlugin::DoReadHeaderL(CMMFDataBuffer* aBuffer) |
|
145 { // update this to handle multiple buffers of header |
|
146 DP0(_L("CAACAudioPlayControllerPlugin::DoReadHeaderL")); |
|
147 |
|
148 iAudioUtility->ScanHeaderL(aBuffer); |
|
149 |
|
150 iHeaderOffset = iAudioUtility->HeaderOffset(); |
|
151 iSyncOffset = iAudioUtility->SyncOffset(); |
|
152 iSampleRate = iAudioUtility->SampleRate(); |
|
153 iSinkSampleRate = iSampleRate; // Default same as source |
|
154 iChannels = iAudioUtility->Channels(); |
|
155 // iSinkNumChannels = iAudioUtility->ChannelsOut(); |
|
156 iDataType = TFourCC(' ','E','A','C'); |
|
157 |
|
158 if (!(iChannels == 0 || iChannels == 1 || iChannels == 2)) |
|
159 { |
|
160 User::Leave(KErrNotSupported); |
|
161 } |
|
162 } |
|
163 |
|
164 CAdvancedAudioDecoder* CAACAudioPlayControllerPlugin::BuildDecoderL() |
|
165 { |
|
166 return iDecoderBuilder->BuildDecoderL(iDecoderType); |
|
167 } |
|
168 |
|
169 |
|
170 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
171 |
|
172 // Exported proxy for instantiation method resolution |
|
173 // Define the interface UIDs |
|
174 const TImplementationProxy ImplementationTable[] = |
|
175 { |
|
176 IMPLEMENTATION_PROXY_ENTRY(KUIDAACPlayControllerPluginImplementation, CAACAudioPlayControllerPlugin::NewL) |
|
177 }; |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // ImplementationGroupProxy |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
184 TInt& aTableCount) |
|
185 { |
|
186 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
187 return ImplementationTable; |
|
188 } |
|
189 |
|
190 // End of file |