camerauis/cameraapp/generic/common/src/CamVideoQualityLevel.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Stores video qulaity leve linformation read from resource file*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <utf.h>         // CnvUtfConverter
       
    22 #include "CameraVariant.hrh"
       
    23 
       
    24  
       
    25 #include "CamSettings.hrh"
       
    26 #include "CamSettingsInternal.hrh"
       
    27 #include "CamVideoQualityLevel.h"
       
    28 #include "camlogging.h"
       
    29 #include "CamUtility.h"
       
    30 
       
    31 
       
    32 const TInt KQualityMaxStringLength = 64;
       
    33 
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS ===============================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CCamVideoQualityLevel::CCamVideoQualityLevel
       
    39 // C++ default constructor can NOT contain any code, that
       
    40 // might leave.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CCamVideoQualityLevel::CCamVideoQualityLevel()
       
    44     {
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CCamVideoQualityLevel::ConstructFromResourceL
       
    49 // Symbian 2nd phase constructor can leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CCamVideoQualityLevel::ConstructFromResourceL( TResourceReader& aReader )
       
    53     {
       
    54     // read identifier for this quality level
       
    55     iQualityLevel = aReader.ReadInt16();
       
    56     // read resolution
       
    57     iVideoResolution = TVideoResolution(aReader.ReadInt16());
       
    58     // read frame rate
       
    59     iVideoFrameRate = aReader.ReadReal64();
       
    60     // read video bitrate
       
    61     iVideoBitRate = aReader.ReadInt32();
       
    62     // read audio bitrate
       
    63     iAudioBitRate = aReader.ReadInt32();
       
    64     // read mime type
       
    65     iVideoMimeType = ReadHBufC8L( aReader );
       
    66     // read preferred supplier
       
    67     iPreferredSupplier = aReader.ReadHBufC16L();
       
    68     // read video codec
       
    69     iVideoCodec = ReadHBufC8L( aReader );
       
    70     // read audio codec
       
    71     iAudioCodec = ReadHBufC8L( aReader );
       
    72     // read file type
       
    73     iVideoFileType = aReader.ReadInt16();
       
    74     // read length
       
    75     iVideoLength = aReader.ReadInt16();
       
    76     
       
    77     // if sharing quality - check the flags
       
    78 /*    if ( iQualityLevel == ECamVideoQualitySharing )
       
    79         {
       
    80         // sharing should be subqcif
       
    81         if ( aVariantFlags & KCamCrQualityVideoSharingIsSubQCIF )
       
    82             {
       
    83             iVideoResolution = ECamVideoResolutionSubQCIF;
       
    84             }
       
    85         }  */
       
    86     }
       
    87     
       
    88 // -----------------------------------------------------------------------------
       
    89 // CCamVideoQualityLevel::ConstructL
       
    90 // Symbian 2nd phase constructor can leave.
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void CCamVideoQualityLevel::ConstructL( TVideoQualitySettings& aSettings )
       
    94     {
       
    95     // read identifier for this quality level
       
    96     iQualityLevel = aSettings.iQualityLevel;
       
    97     // read resolution
       
    98     iVideoResolution = TVideoResolution(aSettings.iVideoResolution);
       
    99     // read frame rate
       
   100     iVideoFrameRate = aSettings.iVideoFrameRate;
       
   101     // read video bitrate
       
   102     iVideoBitRate = aSettings.iVideoBitRate;
       
   103     // read audio bitrate
       
   104     iAudioBitRate = aSettings.iAudioBitRate;
       
   105 
       
   106     // read mime type    
       
   107     iVideoMimeType = HBufC8::NewL( KQualityMaxStringLength );
       
   108     iVideoMimeType->Des().Copy(aSettings.iVideoMimeType);
       
   109 
       
   110     // read preferred supplier
       
   111     iPreferredSupplier = HBufC::NewL( KQualityMaxStringLength ) ;
       
   112     iPreferredSupplier->Des().Copy( aSettings.iPreferredSupplier); 
       
   113 
       
   114     // read video codec
       
   115     iVideoCodec = HBufC8::NewL( KQualityMaxStringLength );
       
   116     iVideoCodec->Des().Copy( aSettings.iVideoCodec );
       
   117     // read audio codec
       
   118     iAudioCodec = HBufC8::NewL( KQualityMaxStringLength );
       
   119     iAudioCodec->Des().Copy( aSettings.iAudioCodec );
       
   120 
       
   121     // read file type*
       
   122     iVideoFileType = aSettings.iVideoFileType;
       
   123     // read length
       
   124     iVideoLength = aSettings.iVideoLength;
       
   125 
       
   126     // if sharing quality - check the flags
       
   127 /*    if ( iQualityLevel == ECamVideoQualitySharing )
       
   128         {
       
   129         // sharing should be subqcif
       
   130         if ( aVariantFlags & KCamCrQualityVideoSharingIsSubQCIF )
       
   131             {
       
   132             iVideoResolution = ECamVideoResolutionSubQCIF;
       
   133             }
       
   134         }*/
       
   135     }
       
   136 
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CCamVideoQualityLevel::NewL
       
   140 // Two-phased constructor.
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 CCamVideoQualityLevel* CCamVideoQualityLevel::NewL( TResourceReader& aReader )
       
   144     {
       
   145     CCamVideoQualityLevel* self = new( ELeave ) CCamVideoQualityLevel;
       
   146     
       
   147     CleanupStack::PushL( self );
       
   148     self->ConstructFromResourceL( aReader );
       
   149     CleanupStack::Pop();
       
   150 
       
   151     return self;
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CCamVideoQualityLevel::NewL
       
   156 // Two-phased constructor.
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 CCamVideoQualityLevel* CCamVideoQualityLevel::NewL( TVideoQualitySettings& aSettings )
       
   160     {
       
   161     CCamVideoQualityLevel* self = new( ELeave ) CCamVideoQualityLevel;
       
   162     CleanupStack::PushL( self );
       
   163     self->ConstructL( aSettings );
       
   164     CleanupStack::Pop();
       
   165 
       
   166     return self;
       
   167     }
       
   168     
       
   169 // Destructor
       
   170 CCamVideoQualityLevel::~CCamVideoQualityLevel()
       
   171   {
       
   172   PRINT( _L("Camera => ~CCamVideoQualityLevel" ));
       
   173   delete iVideoMimeType;
       
   174   delete iPreferredSupplier;
       
   175   delete iVideoCodec;
       
   176   delete iAudioCodec;
       
   177   PRINT( _L("Camera <= ~CCamVideoQualityLevel" )); 
       
   178   }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CCamVideoQualityLevel::VideoResolution
       
   182 // Return video resolution associated with this quality level
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TVideoResolution CCamVideoQualityLevel::VideoResolution()
       
   186     {
       
   187     return iVideoResolution;
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CCamVideoQualityLevel::FrameRate
       
   192 // Return video frame rate associated with this quality level
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 TReal CCamVideoQualityLevel::FrameRate()
       
   196     {
       
   197     return iVideoFrameRate;
       
   198     }
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 // CCamVideoQualityLevel::VideoBitRate
       
   202 // Return video bitrate associated with this quality level
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 TInt CCamVideoQualityLevel::VideoBitRate()
       
   206     {
       
   207     return iVideoBitRate;
       
   208     }
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // CCamVideoQualityLevel::AudioBitRate
       
   212 // Return audio bitrate associated with this quality level identifier
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 TInt CCamVideoQualityLevel::AudioBitRate()
       
   216     {
       
   217     return iAudioBitRate;
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CCamVideoQualityLevel::VideoMimeType
       
   222 // Return mime type required associated with this video quality level
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 TPtrC8 CCamVideoQualityLevel::VideoMimeType()
       
   226     {
       
   227     return *iVideoMimeType;
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CCamVideoQualityLevel::PreferredSupplier
       
   232 // Return preferred supplier value associated with this video quality level
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 TPtrC CCamVideoQualityLevel::PreferredSupplier()
       
   236     {
       
   237     return *iPreferredSupplier;
       
   238     }
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // CCamVideoQualityLevel::VideoFileType
       
   242 // Return video codec associated with this video quality level
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 TPtrC8 CCamVideoQualityLevel::VideoFileType()
       
   246     {
       
   247     return *iVideoCodec;
       
   248     }
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // CCamVideoQualityLevel::AudioType
       
   252 // Return audio codec associated with this video quality level
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 TPtrC8 CCamVideoQualityLevel::AudioType()
       
   256     {
       
   257     return *iAudioCodec;
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CCamVideoQualityLevel::VideoType
       
   262 // Return file type identier associated with this video quality level
       
   263 // either Mpeg4 or 3GP
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 TInt CCamVideoQualityLevel::VideoType()
       
   267     {
       
   268     return iVideoFileType;
       
   269     }
       
   270 
       
   271 // -----------------------------------------------------------------------------
       
   272 // CCamVideoQualityLevel::VideoLength
       
   273 // Return length associated with this video quality level
       
   274 // either max or short
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 TInt CCamVideoQualityLevel::VideoLength()
       
   278     {
       
   279     return iVideoLength;
       
   280     }
       
   281 
       
   282 // -----------------------------------------------------------------------------
       
   283 // CCamVideoQualityLevel::VideoQuality
       
   284 // Return video quality level
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 TInt CCamVideoQualityLevel::VideoQuality()
       
   288     {
       
   289     return iQualityLevel;
       
   290     }
       
   291     
       
   292 // ---------------------------------------------------------------------------
       
   293 // CCamVideoQualityLevel::ReadHBufC8L
       
   294 // Reads an LTEXT element from resources and returns
       
   295 // it as HBufC8.
       
   296 // ---------------------------------------------------------------------------
       
   297 //
       
   298 HBufC8* CCamVideoQualityLevel::ReadHBufC8L( TResourceReader& aReader ) const
       
   299     {
       
   300     HBufC* tempBuf = NULL;
       
   301     tempBuf = aReader.ReadHBufCL();
       
   302     if ( !tempBuf )
       
   303         {
       
   304         return NULL;
       
   305         }
       
   306 
       
   307     CleanupStack::PushL( tempBuf );
       
   308 
       
   309     // Assume aSource only contains 7-bit ASCII characters.
       
   310     // (ie. length of the string in UTF-8 is equal to the number of
       
   311     // characters)
       
   312     HBufC8* res = HBufC8::NewLC( tempBuf->Length() );
       
   313     TPtr8 resPtr( res->Des() );
       
   314     TPtr16 sourcePtr( tempBuf->Des() );
       
   315     CnvUtfConverter::ConvertFromUnicodeToUtf8( resPtr, sourcePtr );
       
   316     CleanupStack::Pop(); // res
       
   317     CleanupStack::PopAndDestroy(); // tempBuf
       
   318     return res;
       
   319     }
       
   320 
       
   321 
       
   322 //  End of File