|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __VEDQUALITYSETTINGSAPI_INL__ |
|
21 #define __VEDQUALITYSETTINGSAPI_INL__ |
|
22 |
|
23 #include "vedqualitysettingsvariation.h" |
|
24 |
|
25 |
|
26 inline TInt TVideoQualitySelector::NumberOfQualityLevels() |
|
27 { |
|
28 return ENumberOfQualitySets; |
|
29 } |
|
30 |
|
31 inline void TVideoQualitySelector::GetVideoQualitySetL( SVideoQualitySet& aSet, TInt aLevel, TBool aAspectRatioWide ) |
|
32 { |
|
33 if ( !aAspectRatioWide ) |
|
34 { |
|
35 GetVideoQualitySetL( aSet, aLevel ); |
|
36 } |
|
37 else |
|
38 { |
|
39 // NOT READY |
|
40 TInt nrOfWideSets = ENumberOfWideQualitySets; |
|
41 if ( nrOfWideSets == 0 ) |
|
42 { |
|
43 User::Leave( KErrNotSupported ); |
|
44 } |
|
45 |
|
46 switch ( aLevel ) |
|
47 { |
|
48 case EVideoQualityMMS : |
|
49 { |
|
50 aSet = KVideoQualitySetsWide[EQualityLow]; |
|
51 } |
|
52 break; |
|
53 case EVideoQualityNormal : |
|
54 { |
|
55 if ( nrOfWideSets > 1 ) |
|
56 { |
|
57 aSet = KVideoQualitySetsWide[EQualityMedium]; |
|
58 } |
|
59 else |
|
60 { |
|
61 aSet = KVideoQualitySetsWide[EQualityLow]; |
|
62 } |
|
63 } |
|
64 break; |
|
65 case EVideoQualityHigh : |
|
66 { |
|
67 if ( nrOfWideSets > 2 ) |
|
68 { |
|
69 aSet = KVideoQualitySetsWide[EQualityHigh]; |
|
70 } |
|
71 else if ( nrOfWideSets > 1 ) |
|
72 { |
|
73 aSet = KVideoQualitySetsWide[EQualityMedium]; |
|
74 } |
|
75 else |
|
76 { |
|
77 aSet = KVideoQualitySetsWide[EQualityLow]; |
|
78 } |
|
79 } |
|
80 break; |
|
81 default: |
|
82 aSet = KVideoQualitySetsWide[EQualityLow]; |
|
83 } |
|
84 } |
|
85 } |
|
86 |
|
87 |
|
88 inline void TVideoQualitySelector::GetVideoQualitySetL( SVideoQualitySet& aSet, TInt aLevel ) |
|
89 { |
|
90 |
|
91 switch ( aLevel ) |
|
92 { |
|
93 case EVideoQualityMMS : |
|
94 { |
|
95 aSet = KVideoQualitySets[EQualityLow]; |
|
96 } |
|
97 break; |
|
98 case EVideoQualityNormal : |
|
99 { |
|
100 aSet = KVideoQualitySets[EQualityMedium]; |
|
101 } |
|
102 break; |
|
103 case EVideoQualityHigh : |
|
104 { |
|
105 aSet = KVideoQualitySets[EQualityHigh]; |
|
106 } |
|
107 break; |
|
108 default: |
|
109 if ( (aLevel > EVideoQualityHigh) || (aLevel < EVideoQualityMin) ) |
|
110 { |
|
111 User::Leave( KErrArgument ); |
|
112 } |
|
113 TInt moreSetsThanNominal = ENumberOfQualitySets - ENumberOfNominalLevels; |
|
114 if ( moreSetsThanNominal ) |
|
115 { |
|
116 // there are also qualities in-between the nominal levels |
|
117 if ( aLevel < EVideoQualityMMS ) |
|
118 { |
|
119 // even lower than the default MMS; no more than 1 step granularity there (atm) |
|
120 aSet = KVideoQualitySets[EQualityLegacy]; |
|
121 } |
|
122 else if ( aLevel < EQualityMedium ) |
|
123 { |
|
124 // between Low and Medium |
|
125 TInt nrSetsBetweenMediumAndLow = EQualityMedium - EQualityLow - 1; |
|
126 if ( nrSetsBetweenMediumAndLow > 0 ) |
|
127 { |
|
128 // no better granularity yet |
|
129 aSet = KVideoQualitySets[EQualityMedium-1]; |
|
130 } |
|
131 else |
|
132 { |
|
133 // there are no specified quality in that range, give medium |
|
134 aSet = KVideoQualitySets[EQualityMedium]; |
|
135 } |
|
136 } |
|
137 else |
|
138 { |
|
139 // between Medium and High |
|
140 TInt nrSetsBetweenHighAndMedium = EQualityHigh - EQualityMedium - 1; |
|
141 if ( nrSetsBetweenHighAndMedium > 0 ) |
|
142 { |
|
143 // no better granularity yet |
|
144 aSet = KVideoQualitySets[EQualityHigh-1]; |
|
145 } |
|
146 else |
|
147 { |
|
148 // there are no specified quality in that range, give medium |
|
149 aSet = KVideoQualitySets[EQualityMedium]; |
|
150 } |
|
151 } |
|
152 } |
|
153 else |
|
154 { |
|
155 // round to the closest nominal level |
|
156 aSet = KVideoQualitySets[(aLevel-(EVideoQualityNominalGranularity/2))/EVideoQualityNominalGranularity]; |
|
157 } |
|
158 } |
|
159 } |
|
160 |
|
161 inline void TVideoQualitySelector::GetVideoQualitySetL( SVideoQualitySet& aSet, const TSize& aVideoResolution ) |
|
162 { |
|
163 // go through the qualities until a match is found. If several matches, pick the 1st one |
|
164 TInt candidate = -1; |
|
165 TInt i; |
|
166 for ( i = ENumberOfQualitySets-1; i >= 0; i-- ) // searches from up to down to find higher quality first |
|
167 { |
|
168 if ( (KVideoQualitySets[i].iVideoWidth == aVideoResolution.iWidth) && (KVideoQualitySets[i].iVideoHeight == aVideoResolution.iHeight) ) |
|
169 { |
|
170 // we've found a set which matches with the requested size |
|
171 candidate = i; |
|
172 if ( (i == EQualityLow) || (i == EQualityMedium) || (i == EQualityHigh) ) |
|
173 { |
|
174 // we've found a set which matches also with preferred qualities |
|
175 break; |
|
176 } |
|
177 } |
|
178 } |
|
179 if ( candidate >= 0 ) |
|
180 { |
|
181 aSet = KVideoQualitySets[candidate]; |
|
182 } |
|
183 else |
|
184 { |
|
185 User::Leave( KErrNotSupported ); |
|
186 } |
|
187 } |
|
188 |
|
189 inline void TVideoQualitySelector::GetVideoQualitySetL( SVideoQualitySet& aSet, const TPtrC8& aVideoCodecMimeType ) |
|
190 { |
|
191 TPtrC8 settingsMimeType; |
|
192 |
|
193 TInt i; |
|
194 for ( i = ENumberOfQualitySets-1; i >= 0; i-- ) // searches from up to down to find higher quality first |
|
195 { |
|
196 settingsMimeType.Set(TPtrC8(KVideoQualitySets[i].iVideoCodecMimeType)); |
|
197 if ( settingsMimeType.MatchF( (const TDesC8& )aVideoCodecMimeType ) != KErrNotFound ) |
|
198 { |
|
199 // found |
|
200 aSet = KVideoQualitySets[i]; |
|
201 return; |
|
202 } |
|
203 } |
|
204 User::Leave( KErrNotSupported ); |
|
205 } |
|
206 |
|
207 #endif |