|
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: Implement the operation: GetInterdenpendentPropDesc |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cmediamtpdataprovidergetinterdependentpropdesc.h" |
|
20 #include "mediamtpdataproviderconst.h" |
|
21 #include "mmmtpdplogger.h" |
|
22 #include "tobjectdescription.h" |
|
23 #include "mmmtpdpdefs.h" |
|
24 #include "mmmtpdpconfig.h" |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CMediaMtpDataProviderGetInterDependentPropDesc::NewL |
|
28 // Two-phase construction method |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 MMmRequestProcessor* CMediaMtpDataProviderGetInterDependentPropDesc::NewL( MMTPDataProviderFramework& aFramework, |
|
32 MMTPConnection& aConnection, |
|
33 MMmMtpDpConfig& aDpConfig ) |
|
34 { |
|
35 CMediaMtpDataProviderGetInterDependentPropDesc* self = |
|
36 new ( ELeave ) CMediaMtpDataProviderGetInterDependentPropDesc( aFramework, |
|
37 aConnection ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CMediaDpMtpGetInterDependentPropDesc::ConstructL |
|
46 // Two-phase construction method |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CMediaMtpDataProviderGetInterDependentPropDesc::ConstructL() |
|
50 { |
|
51 |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CMediaMtpDataProviderGetInterDependentPropDesc::~CMediaMtpDataProviderGetInterDependentPropDesc |
|
56 // Destructor |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CMediaMtpDataProviderGetInterDependentPropDesc::~CMediaMtpDataProviderGetInterDependentPropDesc() |
|
60 { |
|
61 delete iDataset; |
|
62 delete iProperties; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CMTPGetInterDependentPropDesc::CMTPGetInterDependentPropDesc |
|
67 // Standard c++ constructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CMediaMtpDataProviderGetInterDependentPropDesc::CMediaMtpDataProviderGetInterDependentPropDesc( MMTPDataProviderFramework& aFramework, |
|
71 MMTPConnection& aConnection ) : |
|
72 CRequestProcessor( aFramework, aConnection, 0, NULL ) |
|
73 { |
|
74 PRINT( _L( "Operation: GetInterdependentPropDesc(0x9807)" ) ); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CMediaMtpDataProviderGetInterDependentPropDesc::CheckRequestL |
|
79 // Verify the reqeust and returns it |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 TMTPResponseCode CMediaMtpDataProviderGetInterDependentPropDesc::CheckRequestL() |
|
83 { |
|
84 TMTPResponseCode responseCode = CRequestProcessor::CheckRequestL(); |
|
85 iFormatCode = Request().Uint32( TMTPTypeRequest::ERequestParameter1 ); |
|
86 |
|
87 if ( EMTPRespCodeOK == responseCode ) |
|
88 { |
|
89 TInt count = sizeof( KMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 ); |
|
90 |
|
91 responseCode = EMTPRespCodeInvalidObjectFormatCode; |
|
92 |
|
93 for ( TInt i = 0; i < count; i++ ) |
|
94 { |
|
95 if ( iFormatCode == KMediaMtpDataProviderSupportedFormats[i] ) |
|
96 { |
|
97 responseCode = EMTPRespCodeOK; |
|
98 break; |
|
99 } |
|
100 } |
|
101 } |
|
102 |
|
103 return responseCode; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CMediaMtpDataProviderGetInterDependentPropDesc::ServiceL |
|
108 // service a request at request phase |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CMediaMtpDataProviderGetInterDependentPropDesc::ServiceL() |
|
112 { |
|
113 PRINT( _L( "MM MTP => CMediaMtpDataProviderGetInterDependentPropDesc::ServiceL" ) ); |
|
114 |
|
115 // Clear the data set. |
|
116 delete iDataset; |
|
117 iDataset = NULL; |
|
118 iDataset = CMTPTypeInterdependentPropDesc::NewL(); |
|
119 |
|
120 TBool audioWaveCodecSupported = EFalse; |
|
121 TBool audioBitRateSupported = EFalse; |
|
122 TBool videoFourCcCodecSupported = EFalse; |
|
123 TBool videoBitRateSupported = EFalse; |
|
124 |
|
125 switch ( iFormatCode ) |
|
126 { |
|
127 case EMTPFormatCodeWMA: |
|
128 case EMTPFormatCodeMP3: |
|
129 case EMTPFormatCodeAAC: |
|
130 case EMTPFormatCodeWAV: |
|
131 { |
|
132 TInt count = sizeof( KMmMtpDpSupportedPropMandatoryAudio ) / sizeof( TUint16 ); |
|
133 |
|
134 for ( TInt i = 0; i < count; i++ ) |
|
135 { |
|
136 switch ( KMmMtpDpSupportedPropMandatoryAudio[i] ) |
|
137 { |
|
138 case EMTPObjectPropCodeAudioWAVECodec: |
|
139 audioWaveCodecSupported = ETrue; |
|
140 break; |
|
141 case EMTPObjectPropCodeAudioBitRate: |
|
142 audioBitRateSupported = ETrue; |
|
143 break; |
|
144 default: |
|
145 PRINT( _L( "MM MTP <> CMediaMtpDataProviderGetInterDependentPropDesc::ServiceL default" ) ); |
|
146 // do nothing |
|
147 break; |
|
148 } |
|
149 } |
|
150 } |
|
151 break; |
|
152 |
|
153 case EMTPFormatCodeMP4Container: |
|
154 { |
|
155 TInt count = sizeof( KMmMtpDpSupportedPropMandatoryAudio ) / sizeof( TUint16 ); |
|
156 |
|
157 for ( TInt i = 0; i < count; i++ ) |
|
158 { |
|
159 switch ( KMmMtpDpSupportedPropMandatoryAudio[i] ) |
|
160 { |
|
161 case EMTPObjectPropCodeAudioWAVECodec: |
|
162 audioWaveCodecSupported = ETrue; |
|
163 break; |
|
164 case EMTPObjectPropCodeAudioBitRate: |
|
165 audioBitRateSupported = ETrue; |
|
166 break; |
|
167 default: |
|
168 // do nothing |
|
169 break; |
|
170 } |
|
171 } |
|
172 } |
|
173 break; |
|
174 |
|
175 case EMTPFormatCode3GPContainer: |
|
176 { |
|
177 TInt count = sizeof( KMmMtpDpSupportedPropMandatoryAudio ) / sizeof( TUint16 ); |
|
178 |
|
179 for ( TInt i = 0; i < count; i++ ) |
|
180 { |
|
181 switch ( KMmMtpDpSupportedPropMandatoryAudio[i] ) |
|
182 { |
|
183 case EMTPObjectPropCodeAudioWAVECodec: |
|
184 audioWaveCodecSupported = ETrue; |
|
185 break; |
|
186 case EMTPObjectPropCodeAudioBitRate: |
|
187 audioBitRateSupported = ETrue; |
|
188 break; |
|
189 default: |
|
190 // do nothing |
|
191 break; |
|
192 } |
|
193 } |
|
194 } |
|
195 break; |
|
196 |
|
197 case EMTPFormatCodeWMV: |
|
198 case EMTPFormatCodeASF: |
|
199 { |
|
200 TInt count = sizeof( KMmMtpDpSupportedPropMandatoryWMV ) / sizeof( TUint16 ); |
|
201 |
|
202 for ( TInt i = 0; i < count; i++ ) |
|
203 { |
|
204 switch (KMmMtpDpSupportedPropMandatoryWMV[i] ) |
|
205 { |
|
206 case EMTPObjectPropCodeAudioWAVECodec: |
|
207 audioWaveCodecSupported = ETrue; |
|
208 break; |
|
209 case EMTPObjectPropCodeAudioBitRate: |
|
210 audioBitRateSupported = ETrue; |
|
211 break; |
|
212 case EMTPObjectPropCodeVideoFourCCCodec: |
|
213 videoFourCcCodecSupported = ETrue; |
|
214 break; |
|
215 case EMTPObjectPropCodeVideoBitRate: |
|
216 videoBitRateSupported = ETrue; |
|
217 break; |
|
218 default: |
|
219 // do nothing |
|
220 break; |
|
221 } |
|
222 } |
|
223 } |
|
224 break; |
|
225 |
|
226 default: |
|
227 { |
|
228 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetInterDependentPropDesc::ServiceL leave because of invalid formatcode = 0x%x" ), iFormatCode ); |
|
229 User::Leave( KErrNotSupported ); |
|
230 } |
|
231 break; |
|
232 } |
|
233 |
|
234 if ( audioWaveCodecSupported && audioBitRateSupported ) |
|
235 { |
|
236 if ( videoFourCcCodecSupported && videoBitRateSupported ) |
|
237 { |
|
238 iProperties = CMTPTypeInterdependentProperties::NewL(); |
|
239 ServiceVideoFourCCCodecL(); |
|
240 ServiceVideoBitrateL(); |
|
241 iDataset->AppendL( iProperties ); |
|
242 // CleanupStack::Pop(); |
|
243 iProperties = NULL; |
|
244 } |
|
245 |
|
246 iProperties = CMTPTypeInterdependentProperties::NewL(); |
|
247 ServiceAudioWaveCodecL(); |
|
248 ServiceAudioBitrateL(); |
|
249 iDataset->AppendL( iProperties ); |
|
250 // CleanupStack::Pop(); |
|
251 iProperties = NULL; |
|
252 } |
|
253 |
|
254 // Send the dataset. |
|
255 SendDataL( *iDataset ); |
|
256 PRINT( _L( "MM MTP <= CMediaMtpDataProviderGetInterDependentPropDesc::ServiceL" ) ); |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CMediaMtpDataProviderGetInterDependentPropDesc::ServiceAudioWaveCodecL |
|
261 // |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CMediaMtpDataProviderGetInterDependentPropDesc::ServiceAudioWaveCodecL() |
|
265 { |
|
266 CMTPTypeObjectPropDescEnumerationForm* form = |
|
267 CMTPTypeObjectPropDescEnumerationForm::NewLC( EMTPTypeUINT32 ); |
|
268 |
|
269 switch( iFormatCode ) |
|
270 { |
|
271 case EMTPFormatCodeWMA: |
|
272 case EMTPFormatCodeWMV: |
|
273 case EMTPFormatCodeASF: |
|
274 form->AppendSupportedValueL( TMTPTypeUint32( EMTPAudioWAVECodecWMA ) ); |
|
275 break; |
|
276 |
|
277 case EMTPFormatCodeMP3: |
|
278 form->AppendSupportedValueL( TMTPTypeUint32( EMTPAudioWAVECodecMP3 ) ); |
|
279 break; |
|
280 |
|
281 case EMTPFormatCodeMP4Container: |
|
282 case EMTPFormatCode3GPContainer: |
|
283 case EMTPFormatCodeAAC: |
|
284 form->AppendSupportedValueL( TMTPTypeUint32( EMTPAudioWAVECodecAAC ) ); |
|
285 break; |
|
286 |
|
287 case EMTPFormatCodeWAV: |
|
288 form->AppendSupportedValueL( TMTPTypeUint32( EMTPAudioWAVECodecPCM ) ); |
|
289 break; |
|
290 |
|
291 default: |
|
292 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetInterDependentPropDesc::ServiceAudioWaveCodecL leave because of invalid formatcode = 0x%x" ), iFormatCode ); |
|
293 User::Leave( KErrNotSupported ); |
|
294 break; |
|
295 } |
|
296 |
|
297 CMTPTypeObjectPropDesc::TPropertyInfo propInfo; |
|
298 propInfo.iDataType = EMTPTypeUINT32; |
|
299 propInfo.iFormFlag = CMTPTypeObjectPropDesc::EEnumerationForm; |
|
300 propInfo.iGetSet = CMTPTypeObjectPropDesc::EReadWrite; |
|
301 SetFormForResponseL( EMTPObjectPropCodeAudioWAVECodec, propInfo, form ); |
|
302 CleanupStack::PopAndDestroy( form ); |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CMediaMtpDataProviderGetInterDependentPropDesc::ServiceAudioBitrateL |
|
307 // |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void CMediaMtpDataProviderGetInterDependentPropDesc::ServiceAudioBitrateL() |
|
311 { |
|
312 switch( iFormatCode ) |
|
313 { |
|
314 case EMTPFormatCodeWMA: |
|
315 case EMTPFormatCodeWMV: |
|
316 case EMTPFormatCodeASF: |
|
317 ServiceRangeFormDescriptionL( EMTPObjectPropCodeAudioBitRate, |
|
318 EMTPWMAMinBitrate, |
|
319 EMTPWMAMaxBitrate, |
|
320 EMTPAudioBitrateStep ); |
|
321 break; |
|
322 |
|
323 case EMTPFormatCodeMP3: |
|
324 ServiceRangeFormDescriptionL( EMTPObjectPropCodeAudioBitRate, |
|
325 EMTPMP3MinBitrate, |
|
326 EMTPMP3MaxBitrate, |
|
327 EMTPAudioBitrateStep ); |
|
328 break; |
|
329 |
|
330 case EMTPFormatCodeAAC: |
|
331 ServiceRangeFormDescriptionL( EMTPObjectPropCodeAudioBitRate, |
|
332 EMTPAACMinBitrate, |
|
333 EMTPAACMaxBitrate, |
|
334 EMTPAudioBitrateStep ); |
|
335 break; |
|
336 |
|
337 case EMTPFormatCodeWAV: |
|
338 ServiceRangeFormDescriptionL( EMTPObjectPropCodeAudioBitRate, |
|
339 EMTPPCMMinBitrate, |
|
340 EMTPPCMMaxBitrate, |
|
341 EMTPAudioBitrateStep ); |
|
342 break; |
|
343 |
|
344 case EMTPFormatCodeMP4Container: |
|
345 case EMTPFormatCode3GPContainer: |
|
346 ServiceRangeFormDescriptionL( EMTPObjectPropCodeAudioBitRate, |
|
347 EMTPAACPlusMinBitrate, |
|
348 EMTPAACPlusMaxBitrate, |
|
349 EMTPAudioBitrateStep ); |
|
350 break; |
|
351 |
|
352 default: |
|
353 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetInterDependentPropDesc::ServiceAudioBitrateL leave because of invalid formatcode = 0x%x" ), iFormatCode ); |
|
354 User::Leave( KErrNotSupported ); |
|
355 break; |
|
356 } |
|
357 } |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // CMediaMtpDataProviderGetInterDependentPropDesc::ServiceVideoFourCCCodecL |
|
361 // Create Description and create new ObjectPropDesc |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 void CMediaMtpDataProviderGetInterDependentPropDesc::ServiceVideoFourCCCodecL() |
|
365 { |
|
366 switch( iFormatCode ) |
|
367 { |
|
368 case EMTPFormatCodeWMV: |
|
369 case EMTPFormatCodeASF: |
|
370 { |
|
371 CMTPTypeObjectPropDescEnumerationForm* form = |
|
372 CMTPTypeObjectPropDescEnumerationForm::NewL( EMTPTypeUINT32 ); |
|
373 CleanupStack::PushL( form ); // + form |
|
374 |
|
375 TUint32 values[] = |
|
376 { |
|
377 EMTPVideoFourCCCodecWMV3 |
|
378 }; |
|
379 |
|
380 TInt numValues = sizeof ( values ) / sizeof ( values[0] ) ; |
|
381 for ( TInt i = 0; i < numValues; i++ ) |
|
382 { |
|
383 TMTPTypeUint32 data( values[i] ); |
|
384 form->AppendSupportedValueL( data ); |
|
385 } |
|
386 // TODO: |
|
387 CMTPTypeObjectPropDesc::TPropertyInfo propInfo; |
|
388 propInfo.iDataType = EMTPTypeUINT32; |
|
389 propInfo.iFormFlag = CMTPTypeObjectPropDesc::EEnumerationForm; |
|
390 propInfo.iGetSet = CMTPTypeObjectPropDesc::EReadWrite; |
|
391 SetFormForResponseL( EMTPObjectPropCodeVideoFourCCCodec, propInfo, form ); |
|
392 CleanupStack::PopAndDestroy( form ); // - form |
|
393 } |
|
394 break; |
|
395 |
|
396 default: |
|
397 { |
|
398 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetInterDependentPropDesc::ServiceVideoFourCCCodecL leave because of invalid formatcode = 0x%x" ), iFormatCode ); |
|
399 User::Leave( KErrNotSupported ); |
|
400 } |
|
401 break; |
|
402 } |
|
403 } |
|
404 |
|
405 void CMediaMtpDataProviderGetInterDependentPropDesc::ServiceVideoBitrateL() |
|
406 { |
|
407 switch( iFormatCode ) |
|
408 { |
|
409 case EMTPFormatCodeWMV: |
|
410 case EMTPFormatCodeASF: |
|
411 ServiceRangeFormDescriptionL( EMTPObjectPropCodeVideoBitRate, |
|
412 EMTPWMVMinBitrate, |
|
413 EMTPWMVMaxBitrate, |
|
414 EMTPVideoBitrateStep, |
|
415 ETrue ); |
|
416 break; |
|
417 |
|
418 default: |
|
419 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetInterDependentPropDesc::ServiceVideoBitrateL leave because of invalid formatcode = 0x%x" ), iFormatCode ); |
|
420 User::Leave( KErrNotSupported ); |
|
421 break; |
|
422 } |
|
423 } |
|
424 |
|
425 void CMediaMtpDataProviderGetInterDependentPropDesc::ServiceRangeFormDescriptionL( TUint16 aPropCode, |
|
426 TUint32 aMinValue, |
|
427 TUint32 aMaxValue, |
|
428 TUint32 aStepValue, |
|
429 TBool aIsReadOnly ) |
|
430 { |
|
431 CMTPTypeObjectPropDescRangeForm* form = |
|
432 CMTPTypeObjectPropDescRangeForm::NewLC( EMTPTypeUINT32 ); // + form |
|
433 |
|
434 // Set expected values |
|
435 form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EMinimumValue, aMinValue ); |
|
436 form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EMaximumValue, aMaxValue ); |
|
437 form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EStepSize, aStepValue ); |
|
438 |
|
439 CMTPTypeObjectPropDesc::TPropertyInfo propInfo; |
|
440 propInfo.iDataType = EMTPTypeUINT32; |
|
441 propInfo.iFormFlag = CMTPTypeObjectPropDesc::ERangeForm; |
|
442 propInfo.iGetSet = !aIsReadOnly; |
|
443 SetFormForResponseL( aPropCode, propInfo, form ); |
|
444 CleanupStack::PopAndDestroy( form ); // - form |
|
445 } |
|
446 |
|
447 void CMediaMtpDataProviderGetInterDependentPropDesc::SetFormForResponseL( TUint16 aPropertyCode, |
|
448 CMTPTypeObjectPropDesc::TPropertyInfo& aPropInfo, |
|
449 const MMTPType* aForm ) |
|
450 { |
|
451 CMTPTypeObjectPropDesc* propertyDesc = CMTPTypeObjectPropDesc::NewLC( aPropertyCode, |
|
452 aPropInfo, |
|
453 aForm ); |
|
454 // Set group code |
|
455 propertyDesc->SetUint32L( CMTPTypeObjectPropDesc::EGroupCode, EGroupCodeMediaDB ); |
|
456 |
|
457 iProperties->AppendL( propertyDesc ); |
|
458 CleanupStack::Pop( propertyDesc ); |
|
459 } |
|
460 |
|
461 // end of file |