26
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2007 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: This class is used for storing and parsing properties
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <jdebug.h>
|
|
21 |
#include <mmf/plugin/mmfformatimplementationuids.hrh>
|
|
22 |
#include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
|
|
23 |
#include <mmf/common/mmfcontrollerpluginresolver.h>
|
|
24 |
#include "cmmaplayerproperties.h"
|
|
25 |
|
|
26 |
|
|
27 |
#include "tmmaparametervalidator.h"
|
|
28 |
|
|
29 |
// CONSTANTS
|
|
30 |
|
|
31 |
// AUDIO PARAMETERS
|
|
32 |
_LIT(KPropertyEncoding, "encoding");
|
|
33 |
_LIT(KPropertyEncodingPcm, "pcm"); // Wav
|
|
34 |
_LIT(KPropertyEncodingAmr, "amr"); // Amr
|
|
35 |
_LIT(KPropertyEncodingGsm, "gsm");
|
|
36 |
_LIT(KPropertyEncodingUlaw, "ulaw"); // Au
|
|
37 |
_LIT(KPropertyEncodingAlaw, "alaw");
|
|
38 |
_LIT(KPropertyEncodingRaw, "raw"); // Raw pcm
|
|
39 |
_LIT(KPropertyEncodingNone, ""); // empty string
|
|
40 |
|
|
41 |
_LIT(KContentTypeWav, "audio/wav");
|
|
42 |
_LIT(KContentTypeAu, "audio/au");
|
|
43 |
_LIT(KContentTypeAmr, "audio/amr");
|
|
44 |
_LIT(KContentTypeRaw, "audio/raw");
|
|
45 |
|
|
46 |
// Format used if not specified in locator
|
|
47 |
_LIT(KDefaultAudioRecordContentType, "audio/wav");
|
|
48 |
|
|
49 |
_LIT(KPropertyRate, "rate");
|
|
50 |
_LIT(KPropertyBits, "bits");
|
|
51 |
_LIT(KPropertyChannels, "channels");
|
|
52 |
|
|
53 |
_LIT(KPropertyEndian, "endian");
|
|
54 |
MMA_PARAMETER_STR(KPropertyEndianLittle, "little");
|
|
55 |
MMA_PARAMETER_STR(KPropertyEndianBig, "big");
|
|
56 |
MMA_PARAMETER_ARRAY(KValidEndianValues)
|
|
57 |
{
|
|
58 |
{
|
|
59 |
&KPropertyEndianLittle
|
|
60 |
}, {&KPropertyEndianBig}
|
|
61 |
};
|
|
62 |
|
|
63 |
_LIT(KPropertySigned, "signed");
|
|
64 |
MMA_PARAMETER_STR(KPropertySignedSigned, "signed");
|
|
65 |
MMA_PARAMETER_STR(KPropertySignedUnsigned, "unsigned");
|
|
66 |
MMA_PARAMETER_ARRAY(KValidSignedValues)
|
|
67 |
{
|
|
68 |
{
|
|
69 |
&KPropertySignedSigned
|
|
70 |
}, {&KPropertySignedUnsigned}
|
|
71 |
};
|
|
72 |
|
|
73 |
// VIDEO PARAMETERS
|
|
74 |
_LIT(KPropertyFps, "fps");
|
|
75 |
_LIT(KPropertyWidth, "width");
|
|
76 |
_LIT(KPropertyHeight, "height");
|
|
77 |
|
|
78 |
const TInt KSizeNotSet = -1;
|
|
79 |
|
|
80 |
// Format used if not specified in locator
|
|
81 |
_LIT(KDefaultVideoRecordContentType, "video/3gpp");
|
|
82 |
|
|
83 |
//IMAGE PARAMETERS
|
|
84 |
_LIT(KPropertyType, "type");
|
|
85 |
MMA_PARAMETER_STR(KPropertyJfif, "jfif");
|
|
86 |
MMA_PARAMETER_STR(KPropertyExif, "exif");
|
|
87 |
MMA_PARAMETER_ARRAY(KValidTypes)
|
|
88 |
{
|
|
89 |
{
|
|
90 |
&KPropertyJfif
|
|
91 |
}, {&KPropertyExif}
|
|
92 |
};
|
|
93 |
|
|
94 |
_LIT(KFormatPng, "png");
|
|
95 |
_LIT(KFormatJpg, "jpeg"); // not "jpg"
|
|
96 |
_LIT(KFormatGif, "gif");
|
|
97 |
_LIT(KFormatBmp, "bmp");
|
|
98 |
_LIT(KContentTypePng, "image/png");
|
|
99 |
_LIT(KContentTypeJpg, "image/jpeg");
|
|
100 |
_LIT(KContentTypeJpg2,"image/jpg");
|
|
101 |
_LIT(KContentTypeGif, "image/gif");
|
|
102 |
_LIT(KContentTypeBmp, "image/bmp");
|
|
103 |
|
|
104 |
_LIT(KPropertyColor, "colors");
|
|
105 |
MMA_PARAMETER_STR(KPropertyRGB888, "rgb888");
|
|
106 |
MMA_PARAMETER_STR(KPropertyRGB444, "rgb444");
|
|
107 |
MMA_PARAMETER_STR(KPropertyGray16, "gray16");
|
|
108 |
MMA_PARAMETER_STR(KPropertyGray8, "gray8");
|
|
109 |
|
|
110 |
_LIT(KPropertyQuality, "quality");
|
|
111 |
const TInt KDefaultQuality = 75; // digged out from ICL source
|
|
112 |
const TInt KDefaultBpp = 24;
|
|
113 |
const TInt KDefaultBpp444 = 12;
|
|
114 |
const TInt KDefaultBppGray16 = 16;
|
|
115 |
const TInt KDefaultBppGray8 = 8;
|
|
116 |
const TInt KNoUserDefinedQuality = -1;
|
|
117 |
const TReal32 KNoUserDefinedFps = -1;
|
|
118 |
|
|
119 |
// CMMAImageSettings container destructor
|
|
120 |
CMMAImageSettings::~CMMAImageSettings()
|
|
121 |
{
|
|
122 |
delete iMimeType;
|
|
123 |
delete iType;
|
|
124 |
delete iImageData;
|
|
125 |
}
|
|
126 |
|
|
127 |
CMMAAudioSettings::~CMMAAudioSettings()
|
|
128 |
{
|
|
129 |
delete iContentType;
|
|
130 |
}
|
|
131 |
|
|
132 |
CMMAAudioSettings *TMMAParameterValidator::ValidateAudioPropertiesL(const TDesC& aProperties)
|
|
133 |
{
|
|
134 |
CMMAAudioSettings* settings = new(ELeave) CMMAAudioSettings;
|
|
135 |
CleanupStack::PushL(settings);
|
|
136 |
|
|
137 |
CMMAParameterRuleSet* rules = CMMAParameterRuleSet::NewLC();
|
|
138 |
|
|
139 |
// "bits" must be between 0 - 24
|
|
140 |
TMMAParameterRuleInt bitsRule(KPropertyBits, 0, 24);
|
|
141 |
rules->AppendRuleL(&bitsRule);
|
|
142 |
|
|
143 |
// "rate" must be positive
|
|
144 |
TMMAParameterRuleInt rateRule(KPropertyRate, 1);
|
|
145 |
rules->AppendRuleL(&rateRule);
|
|
146 |
|
|
147 |
// "channels" must be 1 or 2
|
|
148 |
TMMAParameterRuleInt channelsRule(KPropertyChannels, 1, 2);
|
|
149 |
rules->AppendRuleL(&channelsRule);
|
|
150 |
|
|
151 |
// "signed" must be "signed" or "unsigned"
|
|
152 |
TMMAParameterRuleDes signedRule(KPropertySigned, KValidSignedValues,
|
|
153 |
MMA_PARAMETER_ARRAY_SIZE(KValidSignedValues));
|
|
154 |
rules->AppendRuleL(&signedRule);
|
|
155 |
|
|
156 |
// "endian" must be "little" or "big"
|
|
157 |
TMMAParameterRuleDes endianRule(KPropertyEndian, KValidEndianValues,
|
|
158 |
MMA_PARAMETER_ARRAY_SIZE(KValidEndianValues));
|
|
159 |
rules->AppendRuleL(&endianRule);
|
|
160 |
|
|
161 |
// "encoding" must be one of valid values
|
|
162 |
TMMAParameterRuleDes encodingRule(KPropertyEncoding);
|
|
163 |
rules->AppendRuleL(&encodingRule);
|
|
164 |
|
|
165 |
CMMAPlayerProperties* properties = CMMAPlayerProperties::NewL(aProperties, *rules);
|
|
166 |
CleanupStack::PushL(properties);
|
|
167 |
|
|
168 |
// validating properties
|
|
169 |
properties->ValidateL();
|
|
170 |
|
|
171 |
TInt bits = KDefaultBits;
|
|
172 |
properties->GetProperty(KPropertyBits, bits);
|
|
173 |
|
|
174 |
settings->iRate = KDefaultRate;
|
|
175 |
properties->GetProperty(KPropertyRate, settings->iRate);
|
|
176 |
|
|
177 |
settings->iChannels = KDefaultChannels;
|
|
178 |
properties->GetProperty(KPropertyChannels, settings->iChannels);
|
|
179 |
|
|
180 |
|
|
181 |
// Normally encoders are not streamable
|
|
182 |
settings->iStreamableFormat = EFalse;
|
|
183 |
|
|
184 |
// signed=signed/unsigned (default is unsigned for 8bit, signed for 16bit)
|
|
185 |
TBool dataSigned = EFalse;
|
|
186 |
if (properties->Compare(KPropertyBits, 16))
|
|
187 |
{
|
|
188 |
dataSigned = ETrue;
|
|
189 |
}
|
|
190 |
|
|
191 |
if (properties->Compare(KPropertySigned, KPropertySignedSigned()))
|
|
192 |
{
|
|
193 |
dataSigned = ETrue;
|
|
194 |
}
|
|
195 |
else if (properties->Compare(KPropertySigned, KPropertySignedUnsigned()))
|
|
196 |
{
|
|
197 |
dataSigned = EFalse;
|
|
198 |
}
|
|
199 |
|
|
200 |
// little by default
|
|
201 |
TBool endianLittle = ETrue;
|
|
202 |
if (properties->Compare(KPropertyEndian, KPropertyEndianBig()))
|
|
203 |
{
|
|
204 |
endianLittle = EFalse;
|
|
205 |
}
|
|
206 |
|
|
207 |
settings->iDataType = KMMFFourCCCodeNULL;
|
|
208 |
|
|
209 |
// encoding specific
|
|
210 |
|
|
211 |
TPtrC encoding(NULL, 0);
|
|
212 |
properties->GetProperty(KPropertyEncoding, encoding);
|
|
213 |
|
|
214 |
if ((encoding == KPropertyEncodingAmr()) ||
|
|
215 |
(encoding == KPropertyEncodingGsm()))
|
|
216 |
{
|
|
217 |
// AMR format
|
|
218 |
encoding.Set(KContentTypeAmr());
|
|
219 |
}
|
|
220 |
|
|
221 |
else if (encoding == KPropertyEncodingUlaw())
|
|
222 |
{
|
|
223 |
// AU format, ulaw codec
|
|
224 |
encoding.Set(KContentTypeAu());
|
|
225 |
settings->iDataType = KMMFFourCCCodeMuLAW;
|
|
226 |
}
|
|
227 |
|
|
228 |
else if (encoding == KPropertyEncodingAlaw())
|
|
229 |
{
|
|
230 |
// AU format, alaw codec
|
|
231 |
encoding.Set(KContentTypeAu());
|
|
232 |
settings->iDataType = KMMFFourCCCodeALAW;
|
|
233 |
}
|
|
234 |
|
|
235 |
else if (encoding == KPropertyEncodingPcm())
|
|
236 |
{
|
|
237 |
// wav format
|
|
238 |
encoding.Set(KContentTypeWav());
|
|
239 |
}
|
|
240 |
|
|
241 |
else if (encoding == KPropertyEncodingRaw())
|
|
242 |
{
|
|
243 |
// raw format, default codec
|
|
244 |
encoding.Set(KContentTypeRaw());
|
|
245 |
}
|
|
246 |
|
|
247 |
else if ((encoding == KPropertyEncodingNone())) // this is the default case
|
|
248 |
{
|
|
249 |
encoding.Set(KDefaultAudioRecordContentType());
|
|
250 |
}
|
|
251 |
|
|
252 |
settings->iContentType = encoding.AllocL();
|
|
253 |
|
|
254 |
|
|
255 |
// wav specific
|
|
256 |
if (*settings->iContentType == KContentTypeWav())
|
|
257 |
{
|
|
258 |
if (bits == 8)
|
|
259 |
{
|
|
260 |
settings->iDataType = KMMFFourCCCodePCMU8;
|
|
261 |
}
|
|
262 |
|
|
263 |
else if (bits == 16)
|
|
264 |
{
|
|
265 |
settings->iDataType = KMMFFourCCCodePCM16;
|
|
266 |
}
|
|
267 |
|
|
268 |
else if (bits != KDefaultBits)
|
|
269 |
{
|
|
270 |
User::Leave(KErrNotSupported);
|
|
271 |
}
|
|
272 |
}
|
|
273 |
|
|
274 |
// raw specific
|
|
275 |
if (*settings->iContentType == KContentTypeRaw())
|
|
276 |
{
|
|
277 |
if (bits == 8)
|
|
278 |
{
|
|
279 |
if (dataSigned)
|
|
280 |
{
|
|
281 |
settings->iDataType = KMMFFourCCCodePCM8;
|
|
282 |
}
|
|
283 |
else
|
|
284 |
{
|
|
285 |
settings->iDataType = KMMFFourCCCodePCMU8;
|
|
286 |
}
|
|
287 |
}
|
|
288 |
|
|
289 |
else if (bits == 16)
|
|
290 |
{
|
|
291 |
if (endianLittle)
|
|
292 |
{
|
|
293 |
if (dataSigned)
|
|
294 |
{
|
|
295 |
settings->iDataType = KMMFFourCCCodePCM16;
|
|
296 |
}
|
|
297 |
else
|
|
298 |
{
|
|
299 |
settings->iDataType = KMMFFourCCCodePCMU16;
|
|
300 |
}
|
|
301 |
}
|
|
302 |
else // Big endian
|
|
303 |
{
|
|
304 |
if (dataSigned)
|
|
305 |
{
|
|
306 |
settings->iDataType = KMMFFourCCCodePCM16B;
|
|
307 |
}
|
|
308 |
else
|
|
309 |
{
|
|
310 |
settings->iDataType = KMMFFourCCCodePCMU16B;
|
|
311 |
}
|
|
312 |
}
|
|
313 |
}
|
|
314 |
|
|
315 |
else if (bits != KDefaultBits) // bits not 8 or 16
|
|
316 |
{
|
|
317 |
User::Leave(KErrNotSupported);
|
|
318 |
}
|
|
319 |
|
|
320 |
settings->iEncoding = TUid::Uid(KMmfUidFormatRAWWrite);
|
|
321 |
settings->iController = TUid::Uid(KMmfUidControllerAudio);
|
|
322 |
}
|
|
323 |
|
|
324 |
|
|
325 |
CleanupStack::PopAndDestroy(2); // rules, properties
|
|
326 |
CleanupStack::Pop(settings);
|
|
327 |
return settings;
|
|
328 |
}
|
|
329 |
|
|
330 |
TMMAVideoSettings TMMAParameterValidator::ValidateVideoPropertiesL(const TDesC& aProperties)
|
|
331 |
{
|
|
332 |
CheckEncodingL(aProperties);
|
|
333 |
TMMAVideoSettings settings;
|
|
334 |
CMMAParameterRuleSet* rules = CMMAParameterRuleSet::NewLC();
|
|
335 |
|
|
336 |
// "fps" is real, taking it as string and validating later
|
|
337 |
TMMAParameterRuleDes fpsRule(KPropertyFps);
|
|
338 |
rules->AppendRuleL(&fpsRule);
|
|
339 |
|
|
340 |
// "width" must be positive
|
|
341 |
TMMAParameterRuleInt widthRule(KPropertyWidth, 1);
|
|
342 |
rules->AppendRuleL(&widthRule);
|
|
343 |
|
|
344 |
// "height" must be positive
|
|
345 |
TMMAParameterRuleInt heightRule(KPropertyHeight, 1);
|
|
346 |
rules->AppendRuleL(&heightRule);
|
|
347 |
|
|
348 |
// "encoding" can be anything in this point (actual validation will be done by MMF)
|
|
349 |
TMMAParameterRuleDes encodingRule(KPropertyEncoding);
|
|
350 |
rules->AppendRuleL(&encodingRule);
|
|
351 |
|
|
352 |
CMMAPlayerProperties* properties = CMMAPlayerProperties::NewL(aProperties, *rules);
|
|
353 |
CleanupStack::PushL(properties);
|
|
354 |
|
|
355 |
// validating properties
|
|
356 |
properties->ValidateL();
|
|
357 |
|
|
358 |
properties->GetProperty(KPropertyWidth, settings.iWidth = KSizeNotSet);
|
|
359 |
properties->GetProperty(KPropertyHeight, settings.iHeight = KSizeNotSet);
|
|
360 |
|
|
361 |
TPtrC fps;
|
|
362 |
settings.iFps = KNoUserDefinedFps;
|
|
363 |
if (properties->GetProperty(KPropertyFps, fps))
|
|
364 |
{
|
|
365 |
TLex lex(fps);
|
|
366 |
TReal32 fpsReal;
|
|
367 |
// try to get fps value from string
|
|
368 |
TInt err = lex.Val(fpsReal);
|
|
369 |
if (err == KErrNone)
|
|
370 |
{
|
|
371 |
// Check if there other characters after
|
|
372 |
// number ( 34xxx )
|
|
373 |
if (!lex.Eos() ||
|
|
374 |
(fpsReal <= 0))
|
|
375 |
{
|
|
376 |
User::Leave(KErrArgument);
|
|
377 |
}
|
|
378 |
else
|
|
379 |
{
|
|
380 |
settings.iFps = fpsReal;
|
|
381 |
}
|
|
382 |
}
|
|
383 |
else if (err == KErrNoMemory)
|
|
384 |
{
|
|
385 |
User::Leave(KErrNoMemory);
|
|
386 |
}
|
|
387 |
else
|
|
388 |
{
|
|
389 |
// value is not available
|
|
390 |
User::Leave(KErrArgument);
|
|
391 |
}
|
|
392 |
}
|
|
393 |
|
|
394 |
settings.iEncoding.Set(KDefaultVideoRecordContentType());
|
|
395 |
properties->GetProperty(KPropertyEncoding, settings.iEncoding);
|
|
396 |
|
|
397 |
CleanupStack::PopAndDestroy(2); // rules, properties
|
|
398 |
return settings;
|
|
399 |
}
|
|
400 |
|
|
401 |
CMMAImageSettings* TMMAParameterValidator::ValidateImagePropertiesL(const TDesC& aProperties)
|
|
402 |
{
|
|
403 |
CMMAImageSettings* settings = new(ELeave)CMMAImageSettings;
|
|
404 |
CleanupStack::PushL(settings);
|
|
405 |
|
|
406 |
CMMAParameterRuleSet* rules = CMMAParameterRuleSet::NewLC();
|
|
407 |
|
|
408 |
// "width" must be positive
|
|
409 |
TMMAParameterRuleInt widthRule(KPropertyWidth, 1);
|
|
410 |
rules->AppendRuleL(&widthRule);
|
|
411 |
|
|
412 |
// "height" must be positive
|
|
413 |
TMMAParameterRuleInt heightRule(KPropertyHeight, 1);
|
|
414 |
rules->AppendRuleL(&heightRule);
|
|
415 |
|
|
416 |
// "encoding" final validation is done with image encoder
|
|
417 |
TMMAParameterRuleDes encodingRule(KPropertyEncoding);
|
|
418 |
rules->AppendRuleL(&encodingRule);
|
|
419 |
|
|
420 |
// "color" can be anything in this point, it will be validated later
|
|
421 |
TMMAParameterRuleDes colorRule(KPropertyColor);
|
|
422 |
rules->AppendRuleL(&colorRule);
|
|
423 |
|
|
424 |
// "type" must be "jfif" or "exif"
|
|
425 |
TMMAParameterRuleDes typeRule(KPropertyType, KValidTypes,
|
|
426 |
MMA_PARAMETER_ARRAY_SIZE(KValidTypes));
|
|
427 |
rules->AppendRuleL(&typeRule);
|
|
428 |
|
|
429 |
// "quality" must be between 0 and 100
|
|
430 |
TMMAParameterRuleInt qualityRule(KPropertyQuality, 0, 100);
|
|
431 |
rules->AppendRuleL(&qualityRule);
|
|
432 |
|
|
433 |
CMMAPlayerProperties* properties = CMMAPlayerProperties::NewL(aProperties, *rules);
|
|
434 |
CleanupStack::PushL(properties);
|
|
435 |
|
|
436 |
// validating properties
|
|
437 |
properties->ValidateL();
|
|
438 |
|
|
439 |
properties->GetProperty(KPropertyWidth, settings->iWidth = KSizeNotSet);
|
|
440 |
properties->GetProperty(KPropertyHeight, settings->iHeight = KSizeNotSet);
|
|
441 |
|
|
442 |
// do not set quality if user has not defined it
|
|
443 |
TInt quality = KNoUserDefinedQuality;
|
|
444 |
properties->GetProperty(KPropertyQuality, quality);
|
|
445 |
|
|
446 |
TPtrC encoding;
|
|
447 |
if (properties->Compare(KPropertyEncoding, KFormatPng) ||
|
|
448 |
properties->Compare(KPropertyEncoding, KContentTypePng))
|
|
449 |
{ //PNG
|
|
450 |
settings->iMimeType = CreateHBufC8FromUnicodeL(KContentTypePng);
|
|
451 |
TPngEncodeData* imageData = new(ELeave)TPngEncodeData();
|
|
452 |
imageData->iBitsPerPixel = KDefaultBpp;
|
|
453 |
imageData->iColor = ETrue;
|
|
454 |
imageData->iPaletted = EFalse;
|
|
455 |
imageData->iLevel = TPngEncodeData::EDefaultCompression;
|
|
456 |
|
|
457 |
CleanupStack::PushL(imageData);
|
|
458 |
TPtrC color;
|
|
459 |
if (properties->Compare(KPropertyColor, KPropertyRGB888()))
|
|
460 |
{
|
|
461 |
// default
|
|
462 |
}
|
|
463 |
else if (properties->Compare(KPropertyColor, KPropertyRGB444()))
|
|
464 |
{
|
|
465 |
imageData->iBitsPerPixel = KDefaultBpp444;
|
|
466 |
}
|
|
467 |
else if (properties->Compare(KPropertyColor, KPropertyGray16()))
|
|
468 |
{
|
|
469 |
imageData->iBitsPerPixel = KDefaultBppGray16;
|
|
470 |
imageData->iColor = EFalse;
|
|
471 |
}
|
|
472 |
else if (properties->Compare(KPropertyColor, KPropertyGray8()))
|
|
473 |
{
|
|
474 |
imageData->iBitsPerPixel = KDefaultBppGray8;
|
|
475 |
imageData->iColor = EFalse;
|
|
476 |
}
|
|
477 |
else if (properties->GetProperty(KPropertyColor, color))
|
|
478 |
{
|
|
479 |
// not valid color parameter
|
|
480 |
User::Leave(KErrArgument);
|
|
481 |
}
|
|
482 |
settings->iImageData = CFrameImageData::NewL();
|
|
483 |
User::LeaveIfError(settings->iImageData->AppendFrameData(imageData));
|
|
484 |
// CFrameImageData took ownership of imageData
|
|
485 |
CleanupStack::Pop(imageData);
|
|
486 |
|
|
487 |
// png quality setting not supported, "type" is only for jpeg.
|
|
488 |
TPtrC tmp;
|
|
489 |
if (quality != KNoUserDefinedQuality ||
|
|
490 |
properties->GetProperty(KPropertyType, tmp)
|
|
491 |
)
|
|
492 |
{
|
|
493 |
User::Leave(KErrArgument);
|
|
494 |
}
|
|
495 |
}
|
|
496 |
else if (properties->Compare(KPropertyEncoding, KFormatJpg) ||
|
|
497 |
properties->Compare(KPropertyEncoding, KContentTypeJpg) ||
|
|
498 |
properties->Compare(KPropertyEncoding, KContentTypeJpg2))
|
|
499 |
{ // JPG
|
|
500 |
settings->iMimeType = CreateHBufC8FromUnicodeL(KContentTypeJpg);
|
|
501 |
if (properties->Compare(KPropertyType, KPropertyJfif()))
|
|
502 |
{
|
|
503 |
settings->iType = CreateHBufC8FromUnicodeL(KPropertyJfif());
|
|
504 |
}
|
|
505 |
else if (properties->Compare(KPropertyType, KPropertyExif()))
|
|
506 |
{
|
|
507 |
settings->iType = CreateHBufC8FromUnicodeL(KPropertyExif());
|
|
508 |
}
|
|
509 |
else
|
|
510 |
{
|
|
511 |
settings->iType = CreateHBufC8FromUnicodeL(KPropertyExif());
|
|
512 |
}
|
|
513 |
|
|
514 |
TJpegImageData* imageData = new(ELeave)TJpegImageData();
|
|
515 |
CleanupStack::PushL(imageData);
|
|
516 |
imageData->iQualityFactor = KDefaultQuality;
|
|
517 |
imageData->iSampleScheme = TJpegImageData::EColor444;
|
|
518 |
if (quality != KNoUserDefinedQuality)
|
|
519 |
{
|
|
520 |
imageData->iQualityFactor = quality;
|
|
521 |
}
|
|
522 |
settings->iImageData = CFrameImageData::NewL();
|
|
523 |
User::LeaveIfError(settings->iImageData->AppendImageData(imageData));
|
|
524 |
// CFrameImageData took ownership of imageData
|
|
525 |
CleanupStack::Pop(imageData);
|
|
526 |
|
|
527 |
TPtrC tmp;
|
|
528 |
// jpg encoders colors cannot be configured,
|
|
529 |
// notice that if there was "type" defined it must be "jfif"
|
|
530 |
// and encoder will check that anyway.
|
|
531 |
if (properties->GetProperty(KPropertyColor, tmp))
|
|
532 |
{
|
|
533 |
User::Leave(KErrArgument);
|
|
534 |
}
|
|
535 |
}
|
|
536 |
else if (properties->Compare(KPropertyEncoding, KFormatGif) ||
|
|
537 |
properties->Compare(KPropertyEncoding, KContentTypeGif))
|
|
538 |
{//GIF
|
|
539 |
settings->iMimeType = CreateHBufC8FromUnicodeL(KContentTypeGif);
|
|
540 |
TPtrC tmp;
|
|
541 |
// gif encoder is not configurable
|
|
542 |
if (properties->GetProperty(KPropertyColor, tmp) ||
|
|
543 |
properties->GetProperty(KPropertyType, tmp) ||
|
|
544 |
quality != KNoUserDefinedQuality)
|
|
545 |
{
|
|
546 |
User::Leave(KErrArgument);
|
|
547 |
}
|
|
548 |
}
|
|
549 |
else if (properties->Compare(KPropertyEncoding, KFormatBmp) ||
|
|
550 |
properties->Compare(KPropertyEncoding, KContentTypeBmp))
|
|
551 |
{//BMP
|
|
552 |
settings->iMimeType = CreateHBufC8FromUnicodeL(KContentTypeBmp);
|
|
553 |
TBmpImageData* imageData = new(ELeave)TBmpImageData();
|
|
554 |
CleanupStack::PushL(imageData);
|
|
555 |
imageData->iBitsPerPixel = KDefaultBpp;
|
|
556 |
TPtrC color;
|
|
557 |
if (properties->Compare(KPropertyColor, KPropertyRGB888()))
|
|
558 |
{
|
|
559 |
// default
|
|
560 |
}
|
|
561 |
else if (properties->Compare(KPropertyColor, KPropertyRGB444()))
|
|
562 |
{
|
|
563 |
imageData->iBitsPerPixel = KDefaultBpp444;
|
|
564 |
}
|
|
565 |
else if (properties->GetProperty(KPropertyColor, color))
|
|
566 |
{
|
|
567 |
// not valid color parameter
|
|
568 |
User::Leave(KErrArgument);
|
|
569 |
}
|
|
570 |
|
|
571 |
settings->iImageData = CFrameImageData::NewL();
|
|
572 |
User::LeaveIfError(settings->iImageData->AppendImageData(imageData));
|
|
573 |
// CFrameImageData took ownership of imageData
|
|
574 |
CleanupStack::Pop(imageData);
|
|
575 |
|
|
576 |
// quality not supported, "type" is only for jpg
|
|
577 |
TPtrC tmp;
|
|
578 |
if (quality != KNoUserDefinedQuality ||
|
|
579 |
properties->GetProperty(KPropertyType, tmp))
|
|
580 |
{
|
|
581 |
User::Leave(KErrArgument);
|
|
582 |
}
|
|
583 |
}
|
|
584 |
else if (properties->GetProperty(KPropertyEncoding, encoding))
|
|
585 |
{ // OTHER POSSIBLE TYPE
|
|
586 |
// trying to create encoder with only content/mime-type
|
|
587 |
settings->iMimeType = CreateHBufC8FromUnicodeL(encoding);
|
|
588 |
|
|
589 |
// No extra parameters, only content-type
|
|
590 |
TPtrC tmp;
|
|
591 |
if (properties->GetProperty(KPropertyColor, tmp) ||
|
|
592 |
properties->GetProperty(KPropertyType, tmp) ||
|
|
593 |
quality != KNoUserDefinedQuality)
|
|
594 |
{
|
|
595 |
User::Leave(KErrArgument);
|
|
596 |
}
|
|
597 |
}
|
|
598 |
else // default: we had empty properties string
|
|
599 |
{
|
|
600 |
settings->iMimeType = CreateHBufC8FromUnicodeL(KContentTypePng);
|
|
601 |
}
|
|
602 |
CleanupStack::PopAndDestroy(properties);
|
|
603 |
CleanupStack::PopAndDestroy(rules);
|
|
604 |
CleanupStack::Pop(settings);
|
|
605 |
return settings;
|
|
606 |
}
|
|
607 |
|
|
608 |
void TMMAParameterValidator::CheckEncodingL(const TDesC& aProperties)
|
|
609 |
{
|
|
610 |
TInt encodingPos = aProperties.Find(KPropertyEncoding);
|
|
611 |
// empty properties is valid and
|
|
612 |
// encoding must be first parameter and must exist every time
|
|
613 |
if ((aProperties.Length() > 0) &&
|
|
614 |
((encodingPos == KErrNotFound) ||
|
|
615 |
(encodingPos != 0)))
|
|
616 |
{
|
|
617 |
User::Leave(KErrArgument);
|
|
618 |
}
|
|
619 |
}
|
|
620 |
|
|
621 |
HBufC8* TMMAParameterValidator::CreateHBufC8FromUnicodeL(const TDesC& aDes)
|
|
622 |
{
|
|
623 |
HBufC8* tmp = HBufC8::NewL(aDes.Length());
|
|
624 |
tmp->Des().Copy(aDes);
|
|
625 |
return tmp;
|
|
626 |
}
|
|
627 |
|
|
628 |
// END OF FILE
|