|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include "log.h" |
|
24 #include <openmax/il/common/omxilclientclockport.h> |
|
25 #include <openmax/il/common/omxilconfigmanager.h> |
|
26 #include <openmax/il/common/omxilspecversion.h> |
|
27 #include <openmax/il/loader/omxilsymbiancomponentif.h> |
|
28 |
|
29 #include "omxilmicsource.h" |
|
30 #include "omxilmicsource.hrh" |
|
31 #include "omxilmicsourceconst.h" |
|
32 #include "omxilmicsourceapb0port.h" |
|
33 #include "omxilmicsourceprocessingfunction.h" |
|
34 |
|
35 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidSymbianOmxILMicSource); |
|
36 |
|
37 // Component Entry Point |
|
38 OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE aComponent) |
|
39 { |
|
40 // This method should be called as a result of a OMX_GetHandle call. Let's |
|
41 // return something that is consistent with the return codes allowed for |
|
42 // that API call. |
|
43 return COmxILComponent::SymbianErrorToGetHandleError(COmxILMicSource::CreateComponent(aComponent)); |
|
44 } |
|
45 |
|
46 |
|
47 TInt |
|
48 COmxILMicSource::CreateComponent(OMX_HANDLETYPE aComponent) |
|
49 { |
|
50 DEBUG_PRINTF(_L8("COmxILMicSource::CreateComponent")); |
|
51 |
|
52 COmxILMicSource* self = new COmxILMicSource(); |
|
53 |
|
54 if (!self) |
|
55 { |
|
56 return KErrNoMemory; |
|
57 } |
|
58 |
|
59 TRAPD(err, self->ConstructL(aComponent)); |
|
60 if (err != KErrNone) |
|
61 { |
|
62 delete self; |
|
63 } |
|
64 return err; |
|
65 |
|
66 } |
|
67 |
|
68 void |
|
69 COmxILMicSource::ConstructL(OMX_HANDLETYPE aComponent) |
|
70 { |
|
71 DEBUG_PRINTF(_L8("COmxILMicSource::ConstructL")); |
|
72 |
|
73 // STEP 1: Initialize the data received from the IL Core |
|
74 COmxILComponent::ConstructL(aComponent); |
|
75 |
|
76 // STEP 2: Create the call backs manager... |
|
77 MOmxILCallbackNotificationIf* callbackNotificationIf=CreateCallbackManagerL(COmxILComponent::EOutofContext); |
|
78 |
|
79 // STEP 3: Create the audio capturer-specific Processing Function... |
|
80 // Create the clock port first |
|
81 COmxILClientClockPort*opb0Port = ConstructOPB0PortL(); |
|
82 CleanupStack::PushL(opb0Port); |
|
83 |
|
84 COmxILProcessingFunction* pProcessingFunction = |
|
85 COmxILMicSourceProcessingFunction::NewL(*callbackNotificationIf, *opb0Port); |
|
86 RegisterProcessingFunction(pProcessingFunction); |
|
87 |
|
88 // STEP 4: Create Port manager... |
|
89 CreatePortManagerL(COmxILComponent::ENonBufferSharingPortManager, |
|
90 iOmxILVersion, // Component's OMX Version |
|
91 1, // The number of audio ports in this component |
|
92 0, // The starting audio port index |
|
93 0, // The number of image ports in this component |
|
94 0, // The starting image port index |
|
95 0, // The number of video ports in this component |
|
96 0, // The starting video port index |
|
97 1, // The number of other ports in this component |
|
98 1 // The starting other port index |
|
99 ); |
|
100 |
|
101 // STEP 5: Create audio capturer component port |
|
102 COmxILMicSourceAPB0Port* apb0Port = ConstructAPB0PortL(); |
|
103 CleanupStack::PushL(apb0Port); |
|
104 |
|
105 // .. and add them to the port manager... |
|
106 User::LeaveIfError(AddPort(apb0Port, OMX_DirOutput)); |
|
107 CleanupStack::Pop(); |
|
108 User::LeaveIfError(AddPort(opb0Port, OMX_DirInput)); |
|
109 CleanupStack::Pop(); |
|
110 |
|
111 // STEP 6: Create the non-port related configuration manager... |
|
112 RPointerArray<TDesC8> componentRoles; |
|
113 CleanupClosePushL(componentRoles); |
|
114 componentRoles.AppendL(&KSymbianOmxILMicSourceRole()); |
|
115 |
|
116 COmxILConfigManager* pConfigManager = COmxILConfigManager::NewL( |
|
117 KSymbianOmxILMicSourceName, |
|
118 TOmxILVersion(KMicSourceComponentVersionMajor, |
|
119 KMicSourceComponentVersionMinor, |
|
120 KMicSourceComponentVersionRevision, |
|
121 KMicSourceComponentVersionStep), |
|
122 componentRoles); |
|
123 RegisterConfigurationManager(pConfigManager); |
|
124 |
|
125 CleanupStack::PopAndDestroy(); // componentRoles |
|
126 |
|
127 // And finally, let's get everything started |
|
128 InitComponentL(); |
|
129 |
|
130 } |
|
131 |
|
132 COmxILMicSource::COmxILMicSource() |
|
133 : |
|
134 iOmxILVersion(TOmxILSpecVersion()) |
|
135 { |
|
136 DEBUG_PRINTF(_L8("COmxILMicSource::COmxILMicSource")); |
|
137 } |
|
138 |
|
139 COmxILMicSource::~COmxILMicSource() |
|
140 { |
|
141 DEBUG_PRINTF(_L8("COmxILMicSource::~COmxILMicSource")); |
|
142 } |
|
143 |
|
144 COmxILMicSourceAPB0Port* |
|
145 COmxILMicSource::ConstructAPB0PortL() const |
|
146 { |
|
147 DEBUG_PRINTF(_L8("COmxILMicSource::ConstructAPB0PortL")); |
|
148 |
|
149 RArray<OMX_AUDIO_CODINGTYPE> supportedAudioFormats; |
|
150 CleanupClosePushL(supportedAudioFormats); |
|
151 supportedAudioFormats.AppendL(OMX_AUDIO_CodingPCM); |
|
152 |
|
153 OMX_AUDIO_PARAM_PCMMODETYPE paramPcmModeType; |
|
154 paramPcmModeType.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE); |
|
155 paramPcmModeType.nVersion = iOmxILVersion; |
|
156 paramPcmModeType.nPortIndex = KMICSOURCE_APB0PORT_INDEX; |
|
157 |
|
158 static_cast<COmxILMicSourceProcessingFunction*>(GetProcessingFunction())->FillParamPCMModeType(paramPcmModeType); |
|
159 |
|
160 OMX_AUDIO_CONFIG_VOLUMETYPE configAudioVolume; |
|
161 configAudioVolume.nSize = sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE); |
|
162 configAudioVolume.nVersion = iOmxILVersion; |
|
163 configAudioVolume.nPortIndex = KMICSOURCE_APB0PORT_INDEX; |
|
164 configAudioVolume.bLinear = OMX_TRUE; |
|
165 configAudioVolume.sVolume.nValue = static_cast<COmxILMicSourceProcessingFunction*>(GetProcessingFunction())->GetVolume(); |
|
166 configAudioVolume.sVolume.nMin = KMICSOURCE_VOLUME_MIN; |
|
167 configAudioVolume.sVolume.nMax = KMICSOURCE_VOLUME_MAX; |
|
168 |
|
169 OMX_AUDIO_CONFIG_MUTETYPE configAudioMute; |
|
170 configAudioMute.nSize = sizeof(OMX_AUDIO_CONFIG_MUTETYPE); |
|
171 configAudioMute.nVersion = iOmxILVersion; |
|
172 configAudioMute.nPortIndex = KMICSOURCE_APB0PORT_INDEX; |
|
173 configAudioMute.bMute = OMX_FALSE; |
|
174 |
|
175 COmxILMicSourceAPB0Port* apb0Port = COmxILMicSourceAPB0Port::NewL( |
|
176 TOmxILCommonPortData( |
|
177 iOmxILVersion, // OMX specification version information |
|
178 KMICSOURCE_APB0PORT_INDEX, // Port number the structure applies to |
|
179 OMX_DirOutput, // Direction of this port |
|
180 KMICSOURCE_PCMPORT_BUFFERCOUNT_MIN, // The minimum number of buffers this port requires |
|
181 KMICSOURCE_PCMPORT_BUFFERSIZE_MIN, // Minimum size, in bytes, for buffers to be used for this port |
|
182 OMX_PortDomainAudio, // Domain of the port |
|
183 OMX_FALSE, // Buffers contiguous requirement (true or false) |
|
184 0, // Buffer aligment requirements |
|
185 OMX_BufferSupplyOutput, // supplier preference when tunneling between two ports |
|
186 0), |
|
187 supportedAudioFormats, |
|
188 paramPcmModeType, |
|
189 configAudioVolume, |
|
190 configAudioMute, |
|
191 static_cast<COmxILMicSourceProcessingFunction&>(*(GetProcessingFunction())) |
|
192 ); |
|
193 |
|
194 CleanupStack::PopAndDestroy(&supportedAudioFormats); |
|
195 return apb0Port; |
|
196 } |
|
197 |
|
198 COmxILClientClockPort* |
|
199 COmxILMicSource::ConstructOPB0PortL() const |
|
200 { |
|
201 DEBUG_PRINTF(_L8("COmxILMicSource::ConstructOPB0PortL")); |
|
202 |
|
203 TOmxILCommonPortData portData( |
|
204 iOmxILVersion, |
|
205 KMICSOURCE_OPB0PORT_INDEX, // port index |
|
206 OMX_DirInput, |
|
207 KMICSOURCE_CLOCKPORT_BUFFERCOUNT_MIN,// minimum number of buffers |
|
208 sizeof(OMX_TIME_MEDIATIMETYPE), // minimum buffer size, in bytes |
|
209 OMX_PortDomainOther, |
|
210 OMX_FALSE, // do not need contigious buffers |
|
211 0, // byte alignment |
|
212 OMX_BufferSupplyUnspecified, |
|
213 COmxILPort::KBufferMarkPropagationPortNotNeeded |
|
214 ); |
|
215 |
|
216 // TODO: Clean up the code below. The supportedOtherFormats variable has been added in order to make |
|
217 // this component compilable during integration from the MM projectintegration branch . |
|
218 RArray<OMX_OTHER_FORMATTYPE> supportedOtherFormats; |
|
219 CleanupClosePushL(supportedOtherFormats); |
|
220 supportedOtherFormats.AppendL(OMX_OTHER_FormatTime); |
|
221 COmxILClientClockPort* aClientClockPort = COmxILClientClockPort::NewL(portData, supportedOtherFormats); |
|
222 CleanupStack::PopAndDestroy(&supportedOtherFormats); |
|
223 |
|
224 return aClientClockPort; |
|
225 } |