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