upnpavcontroller/upnpavcontrollerhelper/src/upnpdlnautility.cpp
changeset 0 7f85d04be362
child 38 5360b7ddc251
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 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:      Utility for working with files in upnp context
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <e32std.h>
       
    25 
       
    26 #include "upnpdlnautility.h"
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // LITERALS
       
    31 // Video mimetypes that can be played on device
       
    32 _LIT8( KVideoMp4, "video/mp4" );
       
    33 _LIT8( KVideo3Gpp, "video/3gpp" );
       
    34 
       
    35 // Audio mimetypes that can be played on device
       
    36 _LIT8( KAudioMpeg, "audio/mpeg" );
       
    37 _LIT8( KAudioWma, "audio/x-ms-wma" );
       
    38 _LIT8( KAudio3Gpp, "audio/3gpp" );
       
    39 _LIT8( KAudioMp4, "audio/mp4" );
       
    40 _LIT8( KAudioAdts, "audio/vnd.dlna.adts" );
       
    41 _LIT8( KAudioWav, "audio/x-wav" );
       
    42 _LIT8( KAudioXAac, "audio/x-aac" );
       
    43 _LIT8( KAudioAac, "audio/aac" );
       
    44 _LIT8( KAudioM4a, "audio/x-m4a" );
       
    45 
       
    46 // Image mimetypes that can be played on device
       
    47 _LIT8( KImageJpeg, "image/jpeg" );
       
    48 _LIT8( KImagePng, "image/png" );
       
    49 _LIT8( KImageGif, "image/gif" );
       
    50 _LIT8( KImageBmp, "image/bmp" );
       
    51 
       
    52 // Video profiles that can be played on device
       
    53 _LIT8( KAvcMp4BlCif15Aac520, "AVC_MP4_BL_CIF15_AAC_520" );
       
    54 _LIT8( KMpeg4H2633gppP3L10Amr, "MPEG4_H263_3GPP_P3_L10_AMR" ); 
       
    55 _LIT8( KMpeg4P23gppSpL0bAmr, "MPEG4_P2_3GPP_SP_L0B_AMR" ); 
       
    56 _LIT8( KMpeg4P2Mp4AspAac, "MPEG4_P2_MP4_ASP_AAC" ); 
       
    57 _LIT8( KMpeg4P2Mp4AspHeaac, "MPEG4_P2_MP4_ASP_HEAAC" ); 
       
    58 _LIT8( KMpeg4P2Mp4AspL4SoAac, "MPEG4_P2_MP4_ASP_L4_SO_AAC" ); 
       
    59 _LIT8( KMpeg4P2Mp4AspL4SoHeaac, "MPEG4_P2_MP4_ASP_L4_SO_HEAAC" ); 
       
    60 _LIT8( KMpeg4P2Mp4SpVgaAac, "MPEG4_P2_MP4_SP_VGA_AAC" ); 
       
    61 _LIT8( KMpeg4P2Mp4SpVgaHeaac, "MPEG4_P2_MP4_SP_VGA_HEAAC" ); 
       
    62 _LIT8( KMpeg4P2Mp4SpL2Aac, "MPEG4_P2_MP4_SP_L2_AAC" ); 
       
    63 _LIT8( KMpeg4P2Mp4spAac, "MPEG4_P2_MP4_SP_AAC" );
       
    64 
       
    65 _LIT8( KMpeg4P23gppSpL0bAac, "MPEG4_P2_3GPP_SP_L0B_AAC");
       
    66 _LIT8( KAvcMp4BlCif15Aac, "AVC_MP4_BL_CIF15_AAC" ); 
       
    67 _LIT8( KAvcMp4BlCif15AacLtp, "AVC_MP4_BL_CIF15_AAC_LTP" ); 
       
    68 _LIT8( KAvcMp4BlCif15AacLtp520, "AVC_MP4_BL_CIF15_AAC_LTP_520" ); 
       
    69 _LIT8( KAvcMp4BlCif30Aac940, "AVC_MP4_BL_CIF30_AAC_940" ); 
       
    70 _LIT8( KAvcMp4BlL12Cif15Heaac, "AVC_MP4_BL_L12_CIF15_HEAAC" );
       
    71 _LIT8( KAvcTSBlCif15Aac, "AVC_TS_BL_CIF15_AAC" );
       
    72 
       
    73 // Audio profiles that can be played on device
       
    74 _LIT8( KAacIso, "AAC_ISO" ); 
       
    75 _LIT8( KAacIso320, "AAC_ISO_320" );
       
    76 _LIT8( KAacAdts, "AAC_ADTS" ); 
       
    77 _LIT8( KAacAdts320, "AAC_ADTS_320" ); 
       
    78 _LIT8( KAacMult5Iso, "AAC_MULT5_ISO" );
       
    79 _LIT8( KHeaacL2Iso, "HEAAC_L2_ISO" ); 
       
    80 _LIT8( KHeaacL2Iso320, "HEAAC_L2_ISO_320" ); 
       
    81 _LIT8( KHeaacL2Adts, "HEAAC_L2_ADTS" ); 
       
    82 _LIT8( KHeaacL2Adts320, "HEAAC_L2_ADTS_320" ); 
       
    83 _LIT8( KHeaacMuLt5Iso, "HEAAC_MULT5_ISO" ); 
       
    84 _LIT8( KHeaacL3ADTS, "HEAAC_L3_ADTS" ); 
       
    85 _LIT8( KAmr3gpp, "AMR_3GPP" ); 
       
    86 _LIT8( KAmrWbplus, "AMR_WBplus" ); 
       
    87 _LIT8( KMp3, "MP3" );
       
    88 _LIT8( KMp3x, "MP3X" ); 
       
    89 _LIT8( KWmaBase, "WMABASE" );
       
    90 _LIT8( KWmaFull, "WMAFULL" );
       
    91 
       
    92 // Image profiles that can be played on device
       
    93 _LIT8( KJpegLrg, "JPEG_LRG" ); 
       
    94 _LIT8( KJpegMed, "JPEG_MED" ); 
       
    95 _LIT8( KJpegSm, "JPEG_SM" );
       
    96 _LIT8( KPngLrg, "PNG_LRG" );
       
    97 _LIT8( KJpegLrgIco, "JPEG_LRG_ICO" );
       
    98 _LIT8( KJpegSmIco, "JPEG_SM_ICO" );
       
    99 _LIT8( KJpegTn, "JPEG_TN" );
       
   100 _LIT8( KPngTn, "PNG_TN" );
       
   101 _LIT8( KPngSmIco, "PNG_SM_ICO" );
       
   102 _LIT8( KPngLrgIco, "PNG_LRG_ICO" );
       
   103 
       
   104 
       
   105 // ============================ LOCAL FUNCTIONS =============================
       
   106 
       
   107 // --------------------------------------------------------------------------
       
   108 // UPnPDlnaUtility::GetSupportedProfilesL
       
   109 // Returns Supported dlna profiles, Only player mode supported.
       
   110 // --------------------------------------------------------------------------
       
   111 EXPORT_C CDesC8Array& UPnPDlnaUtility::GetSupportedProfilesL( 
       
   112     const TDlnaMode aMode )
       
   113     {
       
   114     CDesC8Array* array = new (ELeave) CDesC8ArrayFlat( 10 );
       
   115     CleanupStack::PushL( array );
       
   116     // At the m
       
   117     switch( aMode )
       
   118         {         
       
   119         case EDMPMode:
       
   120             {
       
   121             // Video profiles that can be played on device
       
   122             array->AppendL( KAvcMp4BlCif15Aac520() );
       
   123             array->AppendL( KMpeg4H2633gppP3L10Amr() );
       
   124             array->AppendL( KMpeg4P23gppSpL0bAmr() );
       
   125             array->AppendL( KMpeg4P2Mp4AspAac() );
       
   126             array->AppendL( KMpeg4P2Mp4AspHeaac() );
       
   127             array->AppendL( KMpeg4P2Mp4AspL4SoAac() );
       
   128             array->AppendL( KMpeg4P2Mp4AspL4SoHeaac() );
       
   129             array->AppendL( KMpeg4P2Mp4SpVgaAac() );
       
   130             array->AppendL( KMpeg4P2Mp4AspL4SoHeaac() );
       
   131             array->AppendL( KMpeg4P2Mp4SpVgaAac() );
       
   132             array->AppendL( KMpeg4P2Mp4SpVgaHeaac() );
       
   133             array->AppendL( KMpeg4P2Mp4SpL2Aac() );
       
   134             array->AppendL( KMpeg4P2Mp4spAac() );
       
   135             
       
   136             array->AppendL( KMpeg4P23gppSpL0bAac() );
       
   137             array->AppendL( KAvcMp4BlCif15Aac() );
       
   138             array->AppendL( KAvcMp4BlCif15AacLtp() );
       
   139             array->AppendL( KAvcMp4BlCif15AacLtp520() );
       
   140             array->AppendL( KAvcMp4BlCif30Aac940() );
       
   141             array->AppendL( KAvcMp4BlL12Cif15Heaac() );
       
   142             array->AppendL( KAvcTSBlCif15Aac() );            
       
   143             
       
   144             // Audio profiles that can be played on device
       
   145             array->AppendL( KAacIso() );
       
   146             array->AppendL( KAacIso320() );
       
   147             array->AppendL( KAacAdts() );
       
   148             array->AppendL( KAacAdts320() );
       
   149             array->AppendL( KAacMult5Iso() );
       
   150             array->AppendL( KHeaacL2Iso() );
       
   151             array->AppendL( KHeaacL2Iso320() );
       
   152             array->AppendL( KHeaacL2Adts() );
       
   153             array->AppendL( KHeaacL2Adts320() );
       
   154             array->AppendL( KAmr3gpp() );
       
   155             array->AppendL( KAmrWbplus() );
       
   156             array->AppendL( KMp3() );
       
   157             array->AppendL( KMp3x() );
       
   158             array->AppendL( KWmaBase() );
       
   159             array->AppendL( KWmaFull() );
       
   160             
       
   161             // Image profiles that can be played on device
       
   162             array->AppendL( KJpegLrg() );
       
   163             array->AppendL( KJpegMed() );
       
   164             array->AppendL( KJpegSm() );            
       
   165             array->AppendL( KPngLrg() ); //fix for EFCG-7E2DKU            
       
   166             array->AppendL( KJpegLrgIco() );
       
   167             array->AppendL( KJpegSmIco() );
       
   168             array->AppendL( KJpegTn() );
       
   169             array->AppendL( KPngTn() );
       
   170             array->AppendL( KPngSmIco() );
       
   171             array->AppendL( KPngLrgIco() );
       
   172 
       
   173             break;
       
   174             }
       
   175         case EDMSMode:
       
   176         case EDMUMode:      
       
   177         case EDMDMode:    
       
   178         default:            
       
   179             {
       
   180             User::Leave( KErrNotSupported );
       
   181             break;
       
   182             }             
       
   183         }
       
   184     CleanupStack::Pop( array );        
       
   185     return *array;        
       
   186     }
       
   187     
       
   188 // --------------------------------------------------------------------------
       
   189 // UPnPDlnaUtility::IsSupportedMimeType
       
   190 // Returns ETrue if aMime is such a mime type for which playback on device 
       
   191 // might be supported.
       
   192 // -------------------------------------------------------------------------- 
       
   193 EXPORT_C TBool UPnPDlnaUtility::IsSupportedMimeType( const TDesC8& aMime ) 
       
   194     {
       
   195     TBool retval = EFalse;
       
   196     
       
   197     if ( aMime.Compare( KVideoMp4() ) == 0 ) 
       
   198         {
       
   199         retval = ETrue;
       
   200         }
       
   201     else if ( aMime.Compare( KVideo3Gpp() ) == 0 )
       
   202         {
       
   203         retval = ETrue;
       
   204         }
       
   205     else if ( aMime.Compare( KAudioMpeg() ) == 0 )
       
   206         {
       
   207         retval = ETrue;
       
   208         }
       
   209     else if ( aMime.Compare( KAudioWma() ) == 0 )
       
   210         {
       
   211         retval = ETrue;
       
   212         }
       
   213     else if ( aMime.Compare( KAudio3Gpp() ) == 0 )
       
   214         {
       
   215         retval = ETrue;
       
   216         }
       
   217     else if ( aMime.Compare( KAudioMp4() ) == 0 )
       
   218         {
       
   219         retval = ETrue;
       
   220         }
       
   221     else if ( aMime.Compare( KAudioAdts() ) == 0 )
       
   222         {
       
   223         retval = ETrue;
       
   224         }
       
   225     else if ( aMime.Compare( KImageJpeg() ) == 0 )
       
   226         {
       
   227         retval = ETrue;
       
   228         }
       
   229     else if ( aMime.Compare( KImagePng() ) == 0 )
       
   230         {
       
   231         retval = ETrue;
       
   232         } 
       
   233     else if ( aMime.Compare ( KAudioWav() ) == 0 ) 
       
   234         {
       
   235         retval = ETrue;
       
   236         }
       
   237     else if ( aMime.Compare ( KAudioXAac() ) == 0 ) 
       
   238         {
       
   239         retval = ETrue;
       
   240         }
       
   241     else if ( aMime.Compare ( KAudioAac() ) == 0 ) 
       
   242         {
       
   243         retval = ETrue;
       
   244         }
       
   245     else if ( aMime.Compare ( KAudioM4a() ) == 0 ) 
       
   246         {
       
   247         retval = ETrue;
       
   248         }
       
   249     else if ( aMime.Compare ( KImageGif() ) == 0 ) 
       
   250         {
       
   251         retval = ETrue;
       
   252         }
       
   253     else if ( aMime.Compare ( KImageBmp() ) == 0 ) 
       
   254         {
       
   255         retval = ETrue;
       
   256         }
       
   257 
       
   258     return retval;
       
   259     }
       
   260     
       
   261 // --------------------------------------------------------------------------
       
   262 // UPnPDlnaUtility::IsSupportedDlnaProfile
       
   263 // Returns ETrue if aProfile is such a DLNA profile for which playback on 
       
   264 // device might be supported.
       
   265 // -------------------------------------------------------------------------- 
       
   266 EXPORT_C TBool UPnPDlnaUtility::IsSupportedDlnaProfile( 
       
   267     const TDesC8& aProfile ) 
       
   268     {
       
   269     TBool retval = EFalse;
       
   270     
       
   271     if ( aProfile.Compare( KAvcMp4BlCif15Aac520() ) == 0 ) 
       
   272         {
       
   273         retval = ETrue;
       
   274         }
       
   275     else if ( aProfile.Compare( KMpeg4H2633gppP3L10Amr() ) == 0 )
       
   276         {
       
   277         retval = ETrue;
       
   278         }
       
   279     else if ( aProfile.Compare( KMpeg4P23gppSpL0bAmr() ) == 0 )
       
   280         {
       
   281         retval = ETrue;
       
   282         }
       
   283     else if ( aProfile.Compare( KMpeg4P2Mp4AspAac() ) == 0 )
       
   284         {
       
   285         retval = ETrue;
       
   286         }
       
   287     else if ( aProfile.Compare( KMpeg4P2Mp4AspHeaac() ) == 0 )
       
   288         {
       
   289         retval = ETrue;
       
   290         }
       
   291     else if ( aProfile.Compare( KMpeg4P2Mp4AspL4SoAac() ) == 0 )
       
   292         {
       
   293         retval = ETrue;
       
   294         }
       
   295     else if ( aProfile.Compare( KMpeg4P2Mp4AspL4SoHeaac() ) == 0 )
       
   296         {
       
   297         retval = ETrue;
       
   298         }
       
   299     else if ( aProfile.Compare( KMpeg4P2Mp4SpVgaAac() ) == 0 )
       
   300         {
       
   301         retval = ETrue;
       
   302         }
       
   303     else if ( aProfile.Compare( KMpeg4P2Mp4SpVgaHeaac() ) == 0 )
       
   304         {
       
   305         retval = ETrue;
       
   306         }
       
   307     else if ( aProfile.Compare( KMpeg4P2Mp4SpL2Aac() ) == 0 )
       
   308         {
       
   309         retval = ETrue;
       
   310         }
       
   311     else if ( aProfile.Compare( KMpeg4P2Mp4spAac() ) == 0 )
       
   312         {
       
   313         retval = ETrue;
       
   314         }
       
   315     else if( aProfile.Compare( KMpeg4P23gppSpL0bAac() ) == 0 )
       
   316         {
       
   317         retval = ETrue;
       
   318         }
       
   319     else if ( aProfile.Compare( KAvcMp4BlCif15Aac() ) == 0 )
       
   320         {
       
   321         retval = ETrue;
       
   322         }
       
   323     else if ( aProfile.Compare( KAvcMp4BlCif15AacLtp() ) == 0 )
       
   324         {
       
   325         retval = ETrue;
       
   326         }
       
   327     else if ( aProfile.Compare( KAvcMp4BlCif15AacLtp520() ) == 0 )
       
   328         {
       
   329         retval = ETrue;
       
   330         }
       
   331     else if ( aProfile.Compare( KAvcMp4BlCif30Aac940() ) == 0 )
       
   332         {
       
   333         retval = ETrue;
       
   334         }
       
   335     else if ( aProfile.Compare( KAvcMp4BlL12Cif15Heaac() ) == 0 )
       
   336         {
       
   337         retval = ETrue;
       
   338         }
       
   339     else if ( aProfile.Compare( KAvcTSBlCif15Aac() ) == 0 )
       
   340         {
       
   341         retval = ETrue;
       
   342         }
       
   343      
       
   344     else if ( aProfile.Compare( KAacIso() ) == 0 )
       
   345         {
       
   346         retval = ETrue;
       
   347         }
       
   348     else if ( aProfile.Compare( KAacIso320() ) == 0 )
       
   349         {
       
   350         retval = ETrue;
       
   351         }
       
   352     else if ( aProfile.Compare( KAacAdts() ) == 0 )
       
   353         {
       
   354         retval = ETrue;
       
   355         }
       
   356     else if ( aProfile.Compare( KAacAdts320() ) == 0 )
       
   357         {
       
   358         retval = ETrue;
       
   359         }
       
   360     else if ( aProfile.Compare( KAacMult5Iso() ) == 0 ) 
       
   361         {
       
   362         retval = ETrue;
       
   363         }
       
   364     else if ( aProfile.Compare( KHeaacL2Iso() ) == 0 )
       
   365         {
       
   366         retval = ETrue;
       
   367         }
       
   368     else if ( aProfile.Compare( KHeaacL2Iso320() ) == 0 )
       
   369         {
       
   370         retval = ETrue;
       
   371         }
       
   372     else if ( aProfile.Compare( KHeaacL2Adts() ) == 0 )
       
   373         {
       
   374         retval = ETrue;
       
   375         }
       
   376     else if ( aProfile.Compare( KHeaacL2Adts320() ) == 0 )
       
   377         {
       
   378         retval = ETrue;
       
   379         }
       
   380 	else if ( aProfile.Compare( KHeaacMuLt5Iso() ) == 0 )
       
   381         {
       
   382         retval = ETrue;
       
   383         }
       
   384 	else if ( aProfile.Compare( KHeaacL3ADTS() ) == 0 )
       
   385         {
       
   386         retval = ETrue;
       
   387         }
       
   388     else if ( aProfile.Compare( KAmr3gpp() ) == 0 )
       
   389         {
       
   390         retval = ETrue;
       
   391         }
       
   392     else if ( aProfile.Compare( KAmrWbplus() ) == 0 )
       
   393         {
       
   394         retval = ETrue;
       
   395         }
       
   396     else if ( aProfile.Compare( KMp3() ) == 0 )
       
   397         {
       
   398         retval = ETrue;
       
   399         }
       
   400     else if ( aProfile.Compare( KMp3x() ) == 0 )
       
   401         {
       
   402         retval = ETrue;
       
   403         }
       
   404     else if ( aProfile.Compare( KWmaBase() ) == 0 )
       
   405         {
       
   406         retval = ETrue;
       
   407         }
       
   408     else if ( aProfile.Compare( KWmaFull() ) == 0 )
       
   409         {
       
   410         retval = ETrue;
       
   411         }
       
   412 
       
   413     else if ( aProfile.Compare( KJpegLrg() ) == 0 )
       
   414         {
       
   415         retval = ETrue;
       
   416         }
       
   417     else if ( aProfile.Compare( KJpegMed() ) == 0 )
       
   418         {
       
   419         retval = ETrue;
       
   420         }
       
   421     else if ( aProfile.Compare( KJpegSm() ) == 0 )
       
   422         {
       
   423         retval = ETrue;
       
   424         }
       
   425     else if ( aProfile.Compare( KPngLrg() ) == 0 )
       
   426         {
       
   427         retval = ETrue;
       
   428         }
       
   429     else if ( aProfile.Compare( KJpegLrgIco() ) == 0 )
       
   430         {
       
   431         retval = ETrue;
       
   432         }
       
   433     else if ( aProfile.Compare( KJpegSmIco() ) == 0 )
       
   434         {
       
   435         retval = ETrue;
       
   436         }
       
   437     else if ( aProfile.Compare( KJpegTn() ) == 0 )
       
   438         {
       
   439         retval = ETrue;
       
   440         }
       
   441     else if ( aProfile.Compare( KPngTn() ) == 0 )
       
   442         {
       
   443         retval = ETrue;
       
   444         }
       
   445     else if ( aProfile.Compare( KPngSmIco() ) == 0 )
       
   446         {
       
   447         retval = ETrue;
       
   448         }
       
   449     else if ( aProfile.Compare( KPngLrgIco() ) == 0 )
       
   450         {
       
   451         retval = ETrue;
       
   452         }
       
   453 
       
   454     return retval;    
       
   455     }
       
   456 
       
   457 // End of file
       
   458