|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * Resolves the MMS conformance for a Media Info object or a MIME type. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> // CBase |
|
25 |
|
26 #include <centralrepository.h> // link against centralrepository.lib |
|
27 #include <MmsEngineInternalCRKeys.h> // for Central Repository keys |
|
28 #include <mmsversion.h> |
|
29 #include <messaginginternalcrkeys.h> // for Central Repository keys, Messaging Uis. |
|
30 |
|
31 #include <charconv.h> |
|
32 |
|
33 // Features |
|
34 #include <featmgr.h> |
|
35 #include <bldvariant.hrh> |
|
36 #include <messagingvariant.hrh> |
|
37 |
|
38 // FW Declaration missing from "FileProtectionResolver.h"! Remove when fixed! |
|
39 class RFile; |
|
40 #include <fileprotectionresolver.h> |
|
41 |
|
42 #include "MmsConformance.h" |
|
43 |
|
44 #include "MsgMedia.hrh" |
|
45 #include "MsgMediaPanic.h" |
|
46 #include "MsgMediaInfo.h" |
|
47 #include "MsgImageInfo.h" |
|
48 #include "MsgAudioInfo.h" |
|
49 #include "MsgTextInfo.h" |
|
50 #include "MsgVideoInfo.h" |
|
51 #include "MsgMimeTypes.h" |
|
52 |
|
53 // EXTERNAL DATA STRUCTURES |
|
54 |
|
55 // EXTERNAL FUNCTION PROTOTYPES |
|
56 |
|
57 // CONSTANTS |
|
58 |
|
59 |
|
60 const TInt KDefaultMaxSendSize = 3 * 102400; |
|
61 |
|
62 // Not in use currently: |
|
63 /* |
|
64 * const TInt KMmsVideoBitRateLimit = 64000; |
|
65 * const TReal32 KMmsVideoFrameRateLimit = 15; |
|
66 */ |
|
67 |
|
68 // MACROS |
|
69 |
|
70 // LOCAL CONSTANTS AND MACROS |
|
71 |
|
72 // MODULE DATA STRUCTURES |
|
73 |
|
74 // LOCAL FUNCTION PROTOTYPES |
|
75 |
|
76 // FORWARD DECLARATIONS |
|
77 |
|
78 // ============================ MEMBER FUNCTIONS =============================== |
|
79 |
|
80 |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // Factory |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 EXPORT_C CMmsConformance* CMmsConformance::NewLC() |
|
87 { |
|
88 CMmsConformance* self = new ( ELeave ) CMmsConformance(); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // Factory |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 EXPORT_C CMmsConformance* CMmsConformance::NewL() |
|
99 { |
|
100 CMmsConformance* self = NewLC(); |
|
101 CleanupStack::Pop( self ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // C++ constructor |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 CMmsConformance::CMmsConformance() : |
|
110 iMmsVersion( KMmsDefaultVersion ) |
|
111 { |
|
112 iResolverFlags |= ECheckCharacterSet; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // Destructor |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 CMmsConformance::~CMmsConformance() |
|
120 { |
|
121 iMediaInfo = NULL; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // 2nd phase constructor |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CMmsConformance::ConstructL() |
|
129 { |
|
130 FeatureManager::InitializeLibL(); |
|
131 if ( FeatureManager::FeatureSupported( KFeatureIdDrmFull ) ) |
|
132 { |
|
133 iResolverFlags |= EDrmFeatureFull; |
|
134 } |
|
135 FeatureManager::UnInitializeLib(); |
|
136 |
|
137 // TODO: Change to use MMS engine flag on this |
|
138 // NOTE: From MmsConformance point of view "free" and "warning" modes are just like |
|
139 iMaxSendSize = KDefaultMaxSendSize; |
|
140 |
|
141 CRepository* repository = CRepository::NewL( KCRUidMmsEngine ); |
|
142 TInt maxSendSize = 0; |
|
143 TInt err = repository->Get( KMmsEngineMaximumSendSize, maxSendSize ); |
|
144 if ( !err ) |
|
145 { |
|
146 iMaxSendSize = maxSendSize; |
|
147 } |
|
148 TInt imgWidth = 0; |
|
149 TInt imgHeight = 0; |
|
150 err = repository->Get( KMmsEngineImageWidth, imgWidth ); |
|
151 if ( !err ) |
|
152 { |
|
153 err = repository->Get( KMmsEngineImageHeight, imgHeight ); |
|
154 } |
|
155 if ( !err ) |
|
156 { |
|
157 iSettingsImageSize.iWidth = imgWidth; |
|
158 iSettingsImageSize.iHeight = imgHeight; |
|
159 } |
|
160 TInt mmsVersion = KMmsDefaultVersion; |
|
161 err = repository->Get( KMmsOmaEncapsulationVersion, mmsVersion ); |
|
162 if ( !err ) |
|
163 { |
|
164 iMmsVersion = (TUint8)mmsVersion; |
|
165 } |
|
166 |
|
167 TInt creationMode = 0; |
|
168 repository->Get( KMmsEngineCreationMode, creationMode ); |
|
169 if ( creationMode == 0 ) |
|
170 { |
|
171 iResolverFlags |= ECreationModeRestricted; |
|
172 } |
|
173 delete repository; |
|
174 repository = NULL; |
|
175 |
|
176 // Read Local Variation flags |
|
177 TInt featureBitmask = 0; |
|
178 repository = CRepository::NewL( KCRUidMuiuVariation ); |
|
179 repository->Get( KMuiuMmsFeatures, featureBitmask ); |
|
180 if ( featureBitmask & KMmsFeatureId3gpp2MediaSupport ) |
|
181 { |
|
182 iResolverFlags |= EMms3gpp2Mode; |
|
183 } |
|
184 if ( featureBitmask & KMmsFeatureIdUserCreationMode ) |
|
185 { |
|
186 iResolverFlags |= ECreationModeUserChangeable; |
|
187 } |
|
188 delete repository; |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CMmsConformance::DoResolveFileL |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 EXPORT_C TBool CMmsConformance::IsConformantMime( const TPtrC8& aMimeType ) |
|
196 { |
|
197 LocalFuncPtr funcPtr = ResolveFunction( aMimeType ); |
|
198 return ( funcPtr != ResolveNonconformantAttachment ); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CMmsConformance::DoResolveFileL |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 EXPORT_C TMmsConformance CMmsConformance::MediaConformance( CMsgMediaInfo& aMediaInfo ) |
|
206 { |
|
207 iMediaInfo = &aMediaInfo; |
|
208 iConformance.iConfClass = EMmsClassUnclassified; |
|
209 iConformance.iConfStatus = EMmsConfOk; |
|
210 iConformance.iCanAdapt = EFalse; |
|
211 |
|
212 CheckDRMStatus(); |
|
213 |
|
214 if ( iMediaInfo->Corrupt() ) |
|
215 { |
|
216 iConformance.iConfStatus |= EMmsConfNokCorrupt; |
|
217 } |
|
218 |
|
219 LocalFuncPtr funcPtr = ResolveFunction( iMediaInfo->MimeType() ); |
|
220 (this->*funcPtr)(); |
|
221 |
|
222 // "Free mode only" media is not supported in restricted mode. |
|
223 if ( ( iResolverFlags & ECreationModeRestricted ) && |
|
224 ( iConformance.iConfStatus & EMmsConfNokFreeModeOnly ) ) |
|
225 { |
|
226 iConformance.iConfStatus |= EMmsConfNokNotSupported; |
|
227 } |
|
228 |
|
229 return iConformance; |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CMmsConformance::ConformanceVersionL |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 EXPORT_C TUint8 CMmsConformance::ConformanceVersionL() |
|
237 { |
|
238 CRepository* repository = CRepository::NewL( KCRUidMmsEngine ); |
|
239 CleanupStack::PushL( repository ); |
|
240 |
|
241 TInt result = KMmsDefaultVersion; |
|
242 User::LeaveIfError( repository->Get( KMmsOmaEncapsulationVersion, result ) ); |
|
243 |
|
244 CleanupStack::PopAndDestroy( repository ); |
|
245 |
|
246 return (TUint8)result; |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CMmsConformance::CheckDRMStatus |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 void CMmsConformance::CheckDRMStatus() |
|
254 { |
|
255 if ( iMediaInfo->Protection() & EFileProtSuperDistributable ) |
|
256 { |
|
257 if ( iResolverFlags & EDrmFeatureFull ) |
|
258 { |
|
259 if ( iMmsVersion <= KMmsVersion12 ) |
|
260 { |
|
261 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
262 } |
|
263 // else -> allowed also in Restricted mode since OMA MMS 1.3 |
|
264 } |
|
265 else |
|
266 { |
|
267 // super distribution not supported |
|
268 iConformance.iConfStatus |= EMmsConfNokDRM; |
|
269 } |
|
270 } |
|
271 else if ( iMediaInfo->Protection() & ( EFileProtClosedContent | EFileProtForwardLocked ) ) |
|
272 { |
|
273 iConformance.iConfStatus |= EMmsConfNokDRM; |
|
274 } |
|
275 } |
|
276 |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CMmsConformance::ResolveFunction |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 LocalFuncPtr CMmsConformance::ResolveFunction( const TPtrC8& aMimeType ) |
|
283 { |
|
284 LocalFuncPtr funcPtr = NULL; |
|
285 //Resolve conf. status according to recognized MIME type |
|
286 if ( aMimeType.CompareF( KMsgMimeTextPlain ) == 0 ) |
|
287 { |
|
288 funcPtr = CMmsConformance::ResolveTextPlain; |
|
289 } |
|
290 else if ( iMmsVersion > KMmsVersion12 && |
|
291 aMimeType.CompareF( KMsgMimeTextXhtml ) == 0 ) |
|
292 { |
|
293 funcPtr = ResolveTextXhtml; |
|
294 } |
|
295 else if ( aMimeType.CompareF( KMsgMimeAudioAmr ) == 0 ) |
|
296 { |
|
297 funcPtr = ResolveAudioAmr; |
|
298 } |
|
299 else if ( aMimeType.CompareF( KMsgMimeAudioSpMidi ) == 0 ) |
|
300 { |
|
301 funcPtr = ResolveAudioSpMidi; |
|
302 } |
|
303 else if ( aMimeType.CompareF( KMsgMimeImageJpeg ) == 0 ) |
|
304 { |
|
305 funcPtr = ResolveImageJpeg; |
|
306 } |
|
307 else if ( aMimeType.CompareF( KMsgMimeImageGif ) == 0 ) |
|
308 { |
|
309 funcPtr = ResolveImageGif; |
|
310 } |
|
311 else if ( aMimeType.CompareF( KMsgMimeImageWbmp ) == 0 ) |
|
312 { |
|
313 funcPtr = ResolveImageWbmp; |
|
314 } |
|
315 else if ( aMimeType.CompareF( KMsgMimeImagePng ) == 0 ) |
|
316 { |
|
317 funcPtr = ResolveImagePng; |
|
318 } |
|
319 else if (!( iResolverFlags & EMms3gpp2Mode ) && |
|
320 ( aMimeType.CompareF( KMsgMimeVideo3gpp ) == 0 ) ) |
|
321 { |
|
322 funcPtr = ResolveVideo3gpp; |
|
323 } |
|
324 else if ( ( iResolverFlags & EMms3gpp2Mode ) && |
|
325 ( aMimeType.CompareF( KMsgMimeVideo3gpp2 ) == 0 ) ) |
|
326 { |
|
327 funcPtr = ResolveVideo3gpp2; |
|
328 } |
|
329 else if ( aMimeType.CompareF( KMsgMimeVCard ) == 0 || |
|
330 aMimeType.CompareF( KMsgMimeVCal ) == 0 ) |
|
331 { |
|
332 funcPtr = ResolveAttachment; |
|
333 } |
|
334 else |
|
335 { |
|
336 funcPtr = ResolveNonconformantAttachment; |
|
337 } |
|
338 return funcPtr; |
|
339 } |
|
340 |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CMmsConformance::ResolveTextPlain |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CMmsConformance::ResolveTextPlain() |
|
347 { |
|
348 if ( iMediaInfo->MediaType() == EMsgMediaText ) |
|
349 { |
|
350 if ( CheckFileSize() ) |
|
351 { |
|
352 if ( iResolverFlags & ECheckCharacterSet ) |
|
353 { |
|
354 CMsgTextInfo* info = static_cast<CMsgTextInfo*>( iMediaInfo ); |
|
355 if ( !( info->CharacterSet() == KCharacterSetIdentifierUtf8 || |
|
356 info->CharacterSet() == KCharacterSetIdentifierAscii ) ) |
|
357 { |
|
358 iConformance.iConfClass = EMmsClassUnclassified; |
|
359 iConformance.iConfStatus |= EMmsConfNokConversionNeeded; |
|
360 } |
|
361 } |
|
362 if ( iMediaInfo->Protection() == EFileProtNoProtection ) |
|
363 { |
|
364 // Conversion of protected files is forbidden! |
|
365 iConformance.iCanAdapt = ETrue; |
|
366 } |
|
367 } |
|
368 } |
|
369 else |
|
370 { |
|
371 // Not initialized as "Text" media file. |
|
372 // Maybe corrupted file |
|
373 iConformance.iConfClass = EMmsClassUnclassified; |
|
374 iConformance.iConfStatus |= EMmsConfNokCorrupt; |
|
375 } |
|
376 } |
|
377 |
|
378 // ----------------------------------------------------------------------------- |
|
379 // CMmsConformance::ResolveTextXhtml |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 void CMmsConformance::ResolveTextXhtml() |
|
383 { |
|
384 CheckFileSize(); |
|
385 } |
|
386 |
|
387 // ----------------------------------------------------------------------------- |
|
388 // CMmsConformance::ResolveAudioAmr |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 void CMmsConformance::ResolveAudioAmr() |
|
392 { |
|
393 if ( iMediaInfo->MediaType() == EMsgMediaAudio ) |
|
394 { |
|
395 if ( CheckFileSize() ) |
|
396 { |
|
397 if ( !iMediaInfo->Parsed() ) |
|
398 { |
|
399 iConformance.iConfClass = EMmsClassUnclassified; |
|
400 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
401 } |
|
402 else if ( iConformance.iConfClass == EMmsClassText ) |
|
403 { |
|
404 // Text class set by CheckFileSize |
|
405 // -> Move to image basic |
|
406 iConformance.iConfClass = EMmsClassImageBasic; |
|
407 } |
|
408 } |
|
409 } |
|
410 else |
|
411 { |
|
412 // Not initialized as "Audio" media file. |
|
413 // Maybe corrupted file |
|
414 iConformance.iConfClass = EMmsClassUnclassified; |
|
415 iConformance.iConfStatus |= EMmsConfNokCorrupt; |
|
416 } |
|
417 } |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // CMmsConformance::ResolveAudioSpMidi |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 void CMmsConformance::ResolveAudioSpMidi() |
|
424 { |
|
425 if ( iMediaInfo->MediaType() == EMsgMediaAudio ) |
|
426 { |
|
427 if ( CheckFileSize() ) |
|
428 { |
|
429 if ( !iMediaInfo->Parsed() ) |
|
430 { |
|
431 iConformance.iConfClass = EMmsClassUnclassified; |
|
432 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
433 } |
|
434 else if ( iConformance.iConfClass == EMmsClassText ) |
|
435 { |
|
436 // Text class set by CheckFileSize |
|
437 // -> Move to image rich |
|
438 iConformance.iConfClass = EMmsClassImageRich; |
|
439 } |
|
440 } |
|
441 } |
|
442 else |
|
443 { |
|
444 // Not initialized as "Audio" media file. |
|
445 // Maybe corrupted file |
|
446 iConformance.iConfClass = EMmsClassUnclassified; |
|
447 iConformance.iConfStatus |= EMmsConfNokCorrupt; |
|
448 } |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CMmsConformance::ResolveImageJpeg |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 void CMmsConformance::ResolveImageJpeg() |
|
456 { |
|
457 CheckImageSize(); |
|
458 if ( iMediaInfo->Protection() == EFileProtNoProtection ) |
|
459 { |
|
460 // Scaling (or "compressing") of Jpeg files |
|
461 // is always possible (unless DRM protected). |
|
462 iConformance.iCanAdapt = ETrue; |
|
463 } |
|
464 |
|
465 // TODO: |
|
466 // |
|
467 // Baseline check in restricted mode only? |
|
468 // |
|
469 //if ( CheckImageSize() ) |
|
470 // { |
|
471 // if ( !IsBaselineJpeg() ) |
|
472 // { |
|
473 // iConformance.iConfClass = EMmsClassUnclassified; |
|
474 // iConformance.iConfStatus |= EMmsConfNokConversionNeeded; |
|
475 // } |
|
476 // } |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CMmsConformance::ResolveImageGif |
|
481 // ----------------------------------------------------------------------------- |
|
482 // |
|
483 void CMmsConformance::ResolveImageGif() |
|
484 { |
|
485 if ( CheckImageSize() ) |
|
486 { |
|
487 CMsgImageInfo* info = static_cast<CMsgImageInfo*>( iMediaInfo ); |
|
488 if ( info->IsAnimation() || info->IsTransparent() ) |
|
489 { |
|
490 // Cannot scale animated nor transparent gifs |
|
491 iConformance.iCanAdapt = EFalse; |
|
492 } |
|
493 } |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // CMmsConformance::ResolveImageWbmp |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 void CMmsConformance::ResolveImageWbmp() |
|
501 { |
|
502 CheckImageSize(); |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // CMmsConformance::ResolveImagePng |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 void CMmsConformance::ResolveImagePng() |
|
510 { |
|
511 CheckImageSize(); |
|
512 iConformance.iConfClass = EMmsClassUnclassified; |
|
513 iConformance.iConfStatus |= EMmsConfNokConversionNeeded; |
|
514 if ( iMediaInfo->Protection() == EFileProtNoProtection ) |
|
515 { |
|
516 // Conversion of protected files is forbidden! |
|
517 iConformance.iCanAdapt = ETrue; |
|
518 } |
|
519 } |
|
520 |
|
521 // ----------------------------------------------------------------------------- |
|
522 // CMmsConformance::ResolveVideo3gpp |
|
523 // ----------------------------------------------------------------------------- |
|
524 // |
|
525 void CMmsConformance::ResolveVideo3gpp() |
|
526 { |
|
527 if ( iMediaInfo->MediaType() == EMsgMediaVideo ) |
|
528 { |
|
529 if ( CheckFileSize() ) |
|
530 { |
|
531 if ( !iMediaInfo->Parsed() ) |
|
532 { |
|
533 iConformance.iConfClass = EMmsClassUnclassified; |
|
534 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
535 } |
|
536 else if ( iConformance.iConfClass == EMmsClassText || |
|
537 iConformance.iConfClass == EMmsClassImageBasic || |
|
538 iConformance.iConfClass == EMmsClassImageRich ) |
|
539 { |
|
540 iConformance.iConfClass = EMmsClassVideoBasic; |
|
541 } |
|
542 |
|
543 CMsgVideoInfo* info = static_cast<CMsgVideoInfo*>( iMediaInfo ); |
|
544 |
|
545 // TODO: Check that video codec is H.263? |
|
546 // TODO: Check that audio codec is AMR? |
|
547 |
|
548 // TODO: Really check bit rate & frame rate? |
|
549 // -> Camcorder video clips fail because |
|
550 // of these checks! |
|
551 |
|
552 TSize QCIFSize( KMmsQCIFSizeWidth, KMmsQCIFSizeHeight ); |
|
553 TSize SubQCIFSize( KMmsSubQCIFSizeWidth, KMmsSubQCIFSizeHeight ); |
|
554 |
|
555 if ( ( ( info->Dimensions() != QCIFSize ) && |
|
556 ( info->Dimensions() != SubQCIFSize ) ) ) |
|
557 { |
|
558 iConformance.iConfClass = EMmsClassUnclassified; |
|
559 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
560 } |
|
561 /* |
|
562 if ( ( ( info->Dimensions() != QCIFSize ) && |
|
563 ( info->Dimensions() != SubQCIFSize ) ) || |
|
564 info->VideoBitRate() > KMmsVideoBitRateLimit || |
|
565 info->VideoFrameRate() >= KMmsVideoFrameRateLimit ) |
|
566 { |
|
567 iConformance.iConfClass = EMmsClassUnclassified; |
|
568 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
569 } |
|
570 */ |
|
571 } |
|
572 } |
|
573 else |
|
574 { |
|
575 // Not initialized as "Video" media file. |
|
576 // Maybe corrupted file |
|
577 iConformance.iConfClass = EMmsClassUnclassified; |
|
578 iConformance.iConfStatus |= EMmsConfNokCorrupt; |
|
579 } |
|
580 } |
|
581 |
|
582 // ----------------------------------------------------------------------------- |
|
583 // CMmsConformance::ResolveVideo3gpp2 |
|
584 // ----------------------------------------------------------------------------- |
|
585 // |
|
586 void CMmsConformance::ResolveVideo3gpp2() |
|
587 { |
|
588 if ( iMediaInfo->MediaType() == EMsgMediaVideo ) |
|
589 { |
|
590 if ( CheckFileSize() ) |
|
591 { |
|
592 if ( !iMediaInfo->Parsed() ) |
|
593 { |
|
594 iConformance.iConfClass = EMmsClassUnclassified; |
|
595 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
596 } |
|
597 else if ( iConformance.iConfClass == EMmsClassText || |
|
598 iConformance.iConfClass == EMmsClassImageBasic || |
|
599 iConformance.iConfClass == EMmsClassImageRich ) |
|
600 { |
|
601 iConformance.iConfClass = EMmsClassVideoBasic; |
|
602 } |
|
603 |
|
604 CMsgVideoInfo* info = static_cast<CMsgVideoInfo*>( iMediaInfo ); |
|
605 |
|
606 // TODO: Check that video codec is H.263 or MPEG4 |
|
607 // TODO: Check that audio codec is AMR |
|
608 |
|
609 // TODO: Really check bit rate & frame rate? |
|
610 // -> Camcorder video clips fail because |
|
611 // of these checks! |
|
612 |
|
613 TSize QCIFSize( KMmsQCIFSizeWidth, KMmsQCIFSizeHeight ); |
|
614 TSize SubQCIFSize( KMmsSubQCIFSizeWidth, KMmsSubQCIFSizeHeight ); |
|
615 |
|
616 if ( ( ( info->Dimensions() != QCIFSize ) && |
|
617 ( info->Dimensions() != SubQCIFSize ) ) ) |
|
618 { |
|
619 iConformance.iConfClass = EMmsClassUnclassified; |
|
620 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
621 } |
|
622 /* |
|
623 if ( ( ( info->Dimensions() != QCIFSize ) && |
|
624 ( info->Dimensions() != SubQCIFSize ) ) || |
|
625 info->VideoBitRate() > KMmsVideoBitRateLimit || |
|
626 info->VideoFrameRate() >= KMmsVideoFrameRateLimit ) |
|
627 { |
|
628 iConformance.iConfClass = EMmsClassUnclassified; |
|
629 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
630 } |
|
631 */ |
|
632 } |
|
633 } |
|
634 else |
|
635 { |
|
636 // Not initialized as "Video" media file. |
|
637 // Maybe corrupted file |
|
638 iConformance.iConfClass = EMmsClassUnclassified; |
|
639 iConformance.iConfStatus |= EMmsConfNokCorrupt; |
|
640 } |
|
641 } |
|
642 |
|
643 // ----------------------------------------------------------------------------- |
|
644 // CMmsConformance::ResolveAttachment |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 void CMmsConformance::ResolveAttachment() |
|
648 { |
|
649 CheckFileSize(); |
|
650 } |
|
651 |
|
652 // ----------------------------------------------------------------------------- |
|
653 // CMmsConformance::ResolveNonconformantAttachment |
|
654 // ----------------------------------------------------------------------------- |
|
655 // |
|
656 void CMmsConformance::ResolveNonconformantAttachment() |
|
657 { |
|
658 ResolveAttachment(); |
|
659 iConformance.iConfClass = EMmsClassUnclassified; |
|
660 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
661 } |
|
662 |
|
663 // ----------------------------------------------------------------------------- |
|
664 // CMmsConformance::CheckFileSize |
|
665 // ----------------------------------------------------------------------------- |
|
666 // |
|
667 TBool CMmsConformance::CheckFileSize() |
|
668 { |
|
669 __ASSERT_DEBUG( iMediaInfo, MsgMediaPanic( EMsgMediaNullPointer ) ); |
|
670 |
|
671 if ( iMediaInfo->FileSize() <= KClassMaxSizeText ) |
|
672 { |
|
673 iConformance.iConfClass = EMmsClassText; |
|
674 } |
|
675 else if ( iMediaInfo->FileSize() <= KClassMaxSizeImageRich ) |
|
676 { |
|
677 iConformance.iConfClass = EMmsClassImageRich; |
|
678 } |
|
679 else if ( iMediaInfo->FileSize() <= KClassMaxSizeVideoRich ) |
|
680 { |
|
681 iConformance.iConfClass = EMmsClassVideoRich; |
|
682 } |
|
683 else if ( iMmsVersion > KMmsVersion12 && |
|
684 iMediaInfo->FileSize() <= KClassMaxSizeMegapixel ) |
|
685 { |
|
686 iConformance.iConfClass = EMmsClassMegapixel; |
|
687 } |
|
688 else |
|
689 { |
|
690 iConformance.iConfClass = EMmsClassUnclassified; |
|
691 iConformance.iConfStatus |= EMmsConfNokTooBig; |
|
692 } |
|
693 |
|
694 // "iMaxSendSize == 0" means "unlimited". |
|
695 if ( !iMaxSendSize || TUint32( iMediaInfo->FileSize() ) <= iMaxSendSize ) |
|
696 { |
|
697 if ( iConformance.iConfClass == EMmsClassUnclassified ) |
|
698 { |
|
699 // iMaxSendSize was larger than KVideoRichClassMaxSize |
|
700 // -> Allowed in free mode |
|
701 iConformance.iConfStatus &= ~EMmsConfNokTooBig; |
|
702 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
703 } |
|
704 return ETrue; |
|
705 } |
|
706 else |
|
707 { |
|
708 iConformance.iConfStatus |= EMmsConfNokTooBig; |
|
709 return EFalse; |
|
710 } |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // CMmsConformance::CheckImageSize |
|
715 // ----------------------------------------------------------------------------- |
|
716 // |
|
717 TBool CMmsConformance::CheckImageSize() |
|
718 { |
|
719 __ASSERT_DEBUG( iMediaInfo, MsgMediaPanic( EMsgMediaNullPointer ) ); |
|
720 |
|
721 |
|
722 if ( iMediaInfo->MediaType() == EMsgMediaImage ) |
|
723 { |
|
724 CheckFileSize(); //ignore return value |
|
725 |
|
726 if ( !iMediaInfo->Parsed() ) |
|
727 { |
|
728 // TODO: OMA MMS 1.3: |
|
729 // What about DRM superdistribution?! Should be allowed, but |
|
730 // we don't know the image dimensions! |
|
731 iConformance.iConfClass = EMmsClassUnclassified; |
|
732 iConformance.iConfStatus |= EMmsConfNokFreeModeOnly; |
|
733 return EFalse; |
|
734 } |
|
735 |
|
736 // Check whether scaling is possible |
|
737 CMsgImageInfo* info = static_cast<CMsgImageInfo*>( iMediaInfo ); |
|
738 TSize imageSize = info->Dimensions(); |
|
739 if ( LargerThanImageSizeSetting( imageSize ) ) |
|
740 { |
|
741 iConformance.iCanAdapt = ETrue; |
|
742 } |
|
743 |
|
744 TMmsConfClass classByResolution = ClassByImageResolution( imageSize ); |
|
745 if ( iConformance.iConfClass < classByResolution ) |
|
746 { |
|
747 iConformance.iConfClass = classByResolution; |
|
748 } |
|
749 if ( classByResolution == EMmsClassUnclassified ) |
|
750 { |
|
751 iConformance.iConfClass = EMmsClassUnclassified; |
|
752 iConformance.iConfStatus |= EMmsConfNokScalingNeeded; |
|
753 } |
|
754 if ( iMediaInfo->Protection() != EFileProtNoProtection ) |
|
755 { |
|
756 // Scaling of protected files is forbidden! |
|
757 iConformance.iCanAdapt = EFalse; |
|
758 } |
|
759 return ETrue; |
|
760 } |
|
761 else |
|
762 { |
|
763 // Not initialized as "Image" media file. |
|
764 // Maybe corrupted file |
|
765 iConformance.iConfClass = EMmsClassUnclassified; |
|
766 iConformance.iConfStatus |= EMmsConfNokCorrupt; |
|
767 return EFalse; |
|
768 } |
|
769 } |
|
770 |
|
771 // ----------------------------------------------------------------------------- |
|
772 // CMmsConformance::ClassByImageResolution |
|
773 // ----------------------------------------------------------------------------- |
|
774 // |
|
775 TMmsConfClass CMmsConformance::ClassByImageResolution( TSize aImageSize ) |
|
776 { |
|
777 if ( aImageSize.iWidth <= KImageBasicWidth && |
|
778 aImageSize.iHeight <= KImageBasicHeight ) |
|
779 { |
|
780 return EMmsClassImageBasic; |
|
781 } |
|
782 else if ( aImageSize.iWidth <= KImageRichWidth && |
|
783 aImageSize.iHeight <= KImageRichHeight ) |
|
784 { |
|
785 return EMmsClassImageRich; |
|
786 } |
|
787 else if ( iMmsVersion > KMmsVersion12 && |
|
788 aImageSize.iWidth <= KImageMegapixelWidth && |
|
789 aImageSize.iHeight <= KImageMegapixelHeight ) |
|
790 { |
|
791 return EMmsClassMegapixel; |
|
792 } |
|
793 else |
|
794 { |
|
795 return EMmsClassUnclassified; |
|
796 } |
|
797 } |
|
798 |
|
799 |
|
800 // End of File |