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