camerauis/cameraxui/cxengine/src/cxequalitypresetssymbian.cpp
changeset 29 699651f2666f
parent 21 fa6d9f75d6a6
child 37 64817133cd1d
equal deleted inserted replaced
24:2094593137f5 29:699651f2666f
    15 * Description:
    15 * Description:
    16 * Implementation file for CxeQualityPresetsSymbian class
    16 * Implementation file for CxeQualityPresetsSymbian class
    17 *
    17 *
    18 */
    18 */
    19 
    19 
       
    20 #include <algorithm>
    20 #include <e32std.h> // For Symbian types used in mmsenginedomaincrkeys.h
    21 #include <e32std.h> // For Symbian types used in mmsenginedomaincrkeys.h
    21 #include <MmsEngineDomainCRKeys.h>
    22 #include <MmsEngineDomainCRKeys.h>
    22 
    23 
    23 #include "cxutils.h"
    24 #include "cxutils.h"
    24 #include "cxenamespace.h"
    25 #include "cxenamespace.h"
    33 
    34 
    34 // constants
    35 // constants
    35 namespace
    36 namespace
    36 {
    37 {
    37     // Display IDs for cameras, used when requesting data from ICM
    38     // Display IDs for cameras, used when requesting data from ICM
    38     const int   PRIMARY_CAMERA_DISPLAY_ID   = 2;
    39     const int    PRIMARY_CAMERA_DISPLAY_ID   = 2;
    39     const int   SECONDARY_CAMERA_DISPLAY_ID = 3;
    40     const int    SECONDARY_CAMERA_DISPLAY_ID = 3;
    40 
    41 
    41     const int   ONE_MILLION    = 1000000;
    42     const int    ONE_MILLION    = 1000000;
    42     const qreal ASPECT_16_BY_9 = (16/9.0);
    43     const qreal  ASPECT_16_BY_9 = (16/9.0);
    43     const qreal DELTA_ERROR    = 0.20;
    44     const qreal  DELTA_ERROR    = 0.20;
    44 
    45 
    45     // ICM "camcorderVisible" parameter value below this means sharing aka mms quality.
    46     // ICM "camcorderVisible" parameter value below this means sharing aka mms quality.
    46     const int   MMS_QUALITY_CAMCORDERVISIBLE_LIMIT = 200;
    47     const int    MMS_QUALITY_CAMCORDERVISIBLE_LIMIT = 200;
       
    48 
       
    49     // Average video bit rate scaler
       
    50     const qreal  VIDEO_AVG_BITRATE_SCALER = 0.9;
       
    51     // Coefficient to estimate video metadata amount
       
    52     const qreal  VIDEO_METADATA_COEFF = 1.03;
       
    53     // Maximum video clip duration in seconds for all qualities
       
    54     const qint64 VIDEO_MAX_DURATION = 5400;
    47 }
    55 }
    48 
    56 
    49 
    57 
    50 /* !
    58 /* !
    51 * Intializes ImagingConfigManager
    59 * Intializes ImagingConfigManager
    96         return presetList;
   104         return presetList;
    97     }
   105     }
    98     int totalLevels = mIcm->NumberOfImageQualityLevels();
   106     int totalLevels = mIcm->NumberOfImageQualityLevels();
    99 
   107 
   100     CX_DEBUG(("Total image quality levels = %d", totalLevels));
   108     CX_DEBUG(("Total image quality levels = %d", totalLevels));
   101     CArrayFixFlat<TUint>* levels= new CArrayFixFlat<TUint>(totalLevels);
   109     CArrayFixFlat<TUint>* levels = new CArrayFixFlat<TUint>(totalLevels);
   102 
   110 
   103     // Get camera display id based on camera index
   111     // Get camera display id based on camera index
   104     int displayId = cameraId == Cxe::SecondaryCameraIndex
   112     int displayId = cameraId == Cxe::SecondaryCameraIndex
   105                   ? SECONDARY_CAMERA_DISPLAY_ID : PRIMARY_CAMERA_DISPLAY_ID;
   113                   ? SECONDARY_CAMERA_DISPLAY_ID : PRIMARY_CAMERA_DISPLAY_ID;
   106 
   114 
   233 /*!
   241 /*!
   234 * Creates a new video preset based on TVideoQualitySet values from ICM.
   242 * Creates a new video preset based on TVideoQualitySet values from ICM.
   235 */
   243 */
   236 CxeVideoDetails CxeQualityPresetsSymbian::createVideoPreset(TVideoQualitySet set)
   244 CxeVideoDetails CxeQualityPresetsSymbian::createVideoPreset(TVideoQualitySet set)
   237 {
   245 {
       
   246     CX_DEBUG_ENTER_FUNCTION();
   238     CxeVideoDetails newPreset;
   247     CxeVideoDetails newPreset;
   239     // set setting values from quality set
   248     // set setting values from quality set
   240     newPreset.mWidth = set.iVideoWidth;
   249     newPreset.mWidth = set.iVideoWidth;
   241     newPreset.mHeight = set.iVideoHeight;
   250     newPreset.mHeight = set.iVideoHeight;
   242 
   251 
   270     fourCC.Append('\0');
   279     fourCC.Append('\0');
   271 
   280 
   272     // set audiotype
   281     // set audiotype
   273     newPreset.mAudioType = toString(fourCCBuf);
   282     newPreset.mAudioType = toString(fourCCBuf);
   274 
   283 
       
   284     CX_DEBUG_EXIT_FUNCTION();
   275     return newPreset;
   285     return newPreset;
   276 }
   286 }
   277 
   287 
   278 
   288 
   279 /*!
   289 /*!
   337     }
   347     }
   338 
   348 
   339     return mpxCountString;
   349     return mpxCountString;
   340 
   350 
   341 
   351 
       
   352 }
       
   353 
       
   354 /*!
       
   355 * Get the available recording time with given video quality details and disk space.
       
   356 * @param details Video quality details to use in calculation.
       
   357 * @param space Available disk space to use in calculation.
       
   358 * @return Available recording time estimate in seconds.
       
   359 */
       
   360 int CxeQualityPresetsSymbian::recordingTimeAvailable(const CxeVideoDetails& details, qint64 space)
       
   361 {
       
   362     CX_DEBUG_ENTER_FUNCTION();
       
   363     int time(0);
       
   364 
       
   365     // Maximum clip size may be limited for mms quality.
       
   366     // If mMaximumSizeInBytes == 0, no limit is specified.
       
   367     if (details.mMaximumSizeInBytes > 0 && details.mMaximumSizeInBytes < space) {
       
   368         space = details.mMaximumSizeInBytes;
       
   369     }
       
   370 
       
   371     // Use average audio/video bitrates to estimate remaining time
       
   372     qreal scaler(avgVideoBitRateScaler());
       
   373     if (scaler == 0) {
       
   374         // video bit rate scaler is 0, use the constant value
       
   375         scaler = VIDEO_AVG_BITRATE_SCALER;
       
   376     }
       
   377 
       
   378     int muteSetting = 0; // audio enabled
       
   379     mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting);
       
   380 
       
   381     int avgVideoBitRate = (details.mVideoBitRate * scaler);
       
   382     int avgAudioBitRate = (muteSetting == 1) ? 0 : details.mAudioBitRate;
       
   383 
       
   384     quint32 averageBitRate = (quint32)((avgVideoBitRate + avgAudioBitRate) * VIDEO_METADATA_COEFF);
       
   385     quint32 averageByteRate = averageBitRate / 8;
       
   386 
       
   387     // 0 <= Remaining time <= KCamCMaxClipDurationInSecs
       
   388     qint64 remaining = std::max(qint64(0), space/averageByteRate);
       
   389     time = std::min(remaining, VIDEO_MAX_DURATION);
       
   390 
       
   391     CX_DEBUG(( "remaining time from algorithm: %d", time ));
       
   392     CX_DEBUG_EXIT_FUNCTION();
       
   393     return time;
   342 }
   394 }
   343 
   395 
   344 
   396 
   345 /*!
   397 /*!
   346 Operator to sort values in ascending order.
   398 Operator to sort values in ascending order.