|
1 /* |
|
2 * Copyright (c) 2008-2010 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: Implementation of Dynamic Configuration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "camvideotime.h" |
|
20 |
|
21 const TReal KMetaDataCoeff = 1.03; // Coefficient to estimate metadata amount |
|
22 const TUint KCamCMaxClipDurationInSecs = 5400; // Maximun video clip duration in seconds |
|
23 const TReal KCMRAvgVideoBitRateScaler = 0.9; |
|
24 const TUint KDiskSafetyLimit = 400000; // Amount of free disk space to leave unused |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // TCamVideoTime::TCamVideoTime |
|
28 // |
|
29 // Constructor |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 TCamVideoTime::TCamVideoTime( TInt64 aDiskSpace, |
|
33 TInt64 aCriticalLimit, |
|
34 TInt aVideoBitRate, |
|
35 TInt aAudioBitRate, |
|
36 TInt64 aSizeLimit, |
|
37 TBool aMuteAudio, |
|
38 TReal aBitrateScaler ) |
|
39 { |
|
40 |
|
41 // Video bitrate scaler - if not given, use default |
|
42 TReal scaler = KCMRAvgVideoBitRateScaler; |
|
43 if( aBitrateScaler != 0 ) |
|
44 { |
|
45 scaler = aBitrateScaler; |
|
46 } |
|
47 |
|
48 // Init bitrates |
|
49 iVideoAverageBitRate = static_cast<TInt>( aVideoBitRate * scaler ); |
|
50 iAudioAverageBitRate = aAudioBitRate; |
|
51 |
|
52 if( aMuteAudio ) |
|
53 { |
|
54 iAudioAverageBitRate = 0; |
|
55 } |
|
56 |
|
57 // Calculate available disk space, taking into account safety limit |
|
58 // and disk critical level limit |
|
59 iAvailableSpaceAtStart = aDiskSpace - KDiskSafetyLimit - aCriticalLimit; |
|
60 if( iAvailableSpaceAtStart <= 0 ) |
|
61 { |
|
62 iAvailableSpaceAtStart = 0; |
|
63 } |
|
64 |
|
65 // File size limit |
|
66 iSizeLimit = aSizeLimit; |
|
67 } |
|
68 |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // TCamVideoTime::GetRemainingTimeL - from CamC3GPDataSinkImp.cpp |
|
73 // |
|
74 // Return the estimated remaining time for the recording in microseconds. |
|
75 // This method takes into account the file size and disk full restrictions. |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 TTimeIntervalMicroSeconds TCamVideoTime::GetRemainingTimeL() |
|
79 { |
|
80 TTimeIntervalMicroSeconds remaining; |
|
81 TInt64 availableSpace; |
|
82 TBool remainingFromSizeLimit = EFalse; |
|
83 |
|
84 if (iSizeLimit && ( (TInt64)iSizeLimit < iAvailableSpaceAtStart ) ) |
|
85 { |
|
86 // use sizelimit as available space. |
|
87 remainingFromSizeLimit = ETrue; |
|
88 } |
|
89 |
|
90 // Use average audio/video bitrates to estimate remaining time |
|
91 TUint averageBitRate; |
|
92 TUint averageByteRate; |
|
93 |
|
94 averageBitRate = (TUint)((iVideoAverageBitRate + iAudioAverageBitRate) * KMetaDataCoeff); |
|
95 averageByteRate = averageBitRate / 8; |
|
96 |
|
97 if (remainingFromSizeLimit) |
|
98 { |
|
99 availableSpace = iSizeLimit; |
|
100 } |
|
101 else |
|
102 { |
|
103 availableSpace = iAvailableSpaceAtStart; |
|
104 } |
|
105 |
|
106 if (availableSpace <= 0) |
|
107 { |
|
108 remaining = 0; |
|
109 } |
|
110 else |
|
111 { |
|
112 remaining = availableSpace * 1000000 / averageByteRate; // 1000000 is for conversion between microseconds and seconds |
|
113 |
|
114 if ( (remaining.Int64()) > (TInt64(KCamCMaxClipDurationInSecs)*1000000) ) |
|
115 { |
|
116 remaining = (TInt64(KCamCMaxClipDurationInSecs)*1000000); |
|
117 } |
|
118 } |
|
119 |
|
120 if ( remaining <= TInt64(0) ) |
|
121 { |
|
122 remaining = 0; |
|
123 } |
|
124 return remaining; |
|
125 } |
|
126 |
|
127 // End of file |