|
1 /* |
|
2 * Copyright (c) 2006 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: TNE Video Clip Info Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __TNEVIDEOCLIPINFOIMP_H__ |
|
22 #define __TNEVIDEOCLIPINFOIMP_H__ |
|
23 |
|
24 |
|
25 #include <e32base.h> |
|
26 |
|
27 #include "TNEProcessor.h" |
|
28 |
|
29 #include <TNEVideoClipInfo.h> |
|
30 |
|
31 |
|
32 /* |
|
33 * Forward declarations. |
|
34 */ |
|
35 // cannot include bitmap.h since video processor includes |
|
36 // this file and fails to compile due to a strange compiler error |
|
37 // "operator delete must return type void" if bitmap.h |
|
38 // is included |
|
39 class CFbsBitmap; |
|
40 |
|
41 class CTNEVideoClipInfo; |
|
42 class CTNEVideoClipInfoOperation; |
|
43 class CTNEVideoClipThumbOperation; |
|
44 |
|
45 |
|
46 /** |
|
47 * class for getting information about video clip files and generating thumbnails. |
|
48 */ |
|
49 class CTNEVideoClipInfoImp : public CTNEVideoClipInfo |
|
50 { |
|
51 public: |
|
52 |
|
53 static CTNEVideoClipInfo* NewL(const RFile& aFileHandle, |
|
54 MTNEVideoClipInfoObserver& aObserver); |
|
55 /** |
|
56 * Destroys the object and releases all resources. |
|
57 */ |
|
58 ~CTNEVideoClipInfoImp(); |
|
59 |
|
60 |
|
61 /* General property methods. */ |
|
62 |
|
63 /** |
|
64 * Returns the file name of the clip. Panics if there is no file |
|
65 * associated with this clip or info is not yet ready for reading. |
|
66 * |
|
67 * @return file name of the clip |
|
68 */ |
|
69 TPtrC FileName() const; |
|
70 |
|
71 /** |
|
72 * Returns the resolution clip. Panics if the |
|
73 * info is not yet ready for reading. |
|
74 * |
|
75 * @return TSize of the clip |
|
76 */ |
|
77 TSize GetResolution() const; |
|
78 |
|
79 /* Thumb methods. */ |
|
80 |
|
81 /** |
|
82 * Returns the number of video frames in this clip. Panics if info |
|
83 * is not yet ready for reading. |
|
84 * |
|
85 * @return number of video frames in this clip |
|
86 */ |
|
87 TInt VideoFrameCount() const; |
|
88 |
|
89 /* Thumbnail methods. */ |
|
90 |
|
91 /** |
|
92 * Generates a bitmap of the given frame from video clip. |
|
93 * The frame bitmap is scaled to the specified resolution and converted |
|
94 * to the specified display mode. This method is asynchronous. The frame |
|
95 * is generated in background and the observer is notified when the frame |
|
96 * is complete. This method panics if info is not yet ready for reading or |
|
97 * the resolution is illegal. |
|
98 * |
|
99 * Possible leave codes: |
|
100 * - <code>KErrNoMemory</code> if memory allocation fails |
|
101 * - <code>KErrNotSupported</code>, if the specified combination of |
|
102 * parameters is not supported |
|
103 * |
|
104 * @param aObserver observer to be notified when the frame is completed |
|
105 * @param aIndex index of frame, or KFrameIndexBestThumb to look for |
|
106 * most suitable thumbnail frame. |
|
107 * @param aResolution resolution of the desired frame bitmap, or |
|
108 * <code>NULL</code> if the frame should be |
|
109 * in the original resolution |
|
110 * @param aDisplayMode desired display mode; or <code>ENone</code> if |
|
111 * any display mode is acceptable |
|
112 * @param aEnhance apply image enhancement algorithms to improve |
|
113 * frame quality; note that this may considerably |
|
114 * increase the processing time needed to prepare |
|
115 * the frame |
|
116 * @param aPriority priority of the frame generation |
|
117 */ |
|
118 |
|
119 void GetThumbL(MTNEVideoClipThumbObserver& aObserver, |
|
120 TInt aIndex, |
|
121 TSize* const aResolution, |
|
122 TDisplayMode aDisplayMode, |
|
123 TBool aEnhance, |
|
124 TInt aPriority); |
|
125 |
|
126 /** |
|
127 * Cancels Thumbnail generation. If no thumb is currently being |
|
128 * generated, the function does nothing. |
|
129 */ |
|
130 void CancelThumb(); |
|
131 |
|
132 |
|
133 private: |
|
134 CTNEVideoClipInfoImp(); |
|
135 |
|
136 /** |
|
137 * Constructor for CTNEVideoClipInfoImp using RFile handle. |
|
138 */ |
|
139 void ConstructL(const RFile& aFileHandle, |
|
140 MTNEVideoClipInfoObserver& aObserver); |
|
141 |
|
142 /** |
|
143 * Constructor for CTNEVideoClipInfoImp using file name. |
|
144 */ |
|
145 void ConstructL(const TDesC& aFileName, |
|
146 MTNEVideoClipInfoObserver& aObserver); |
|
147 private: |
|
148 // Member variables |
|
149 |
|
150 // Get video info operation. |
|
151 CTNEVideoClipInfoOperation* iInfoOperation; |
|
152 |
|
153 // Flag to indicate then info is available |
|
154 TBool iReady; |
|
155 |
|
156 // Duplicate RFile handle for the video clip |
|
157 RFile iFileHandle; |
|
158 |
|
159 // Vídeo format. |
|
160 TTNEVideoFormat iFormat; |
|
161 |
|
162 // Video type/codec. |
|
163 TTNEVideoType iVideoType; |
|
164 |
|
165 // Resolution of video clip. |
|
166 TSize iResolution; |
|
167 |
|
168 // Frame count of video |
|
169 TInt iVideoFrameCount; |
|
170 |
|
171 // Operation to retrieve thumbnail of video clip. |
|
172 CTNEVideoClipThumbOperation* iThumbOperation; |
|
173 |
|
174 // These are for supporting TNE requests which send filename |
|
175 // internally we open a RFile handle to the file. |
|
176 RFs* iFs; |
|
177 |
|
178 friend class CTNEVideoClipInfoOperation; |
|
179 friend class CTNEVideoClipThumbOperation; |
|
180 friend class CTNEVideoClipInfo; |
|
181 }; |
|
182 |
|
183 |
|
184 |
|
185 /** |
|
186 * Internal class for reading information from a video clip file. |
|
187 * Also implements a simple active object to notify the video clip info |
|
188 * observer when reading has been completed. |
|
189 */ |
|
190 class CTNEVideoClipInfoOperation : public CActive |
|
191 { |
|
192 public: |
|
193 /* Static constructor */ |
|
194 static CTNEVideoClipInfoOperation* NewL(CTNEVideoClipInfoImp* aInfo, |
|
195 MTNEVideoClipInfoObserver& aObserver); |
|
196 protected: |
|
197 /* |
|
198 * From CActive |
|
199 * Standard active object RunL |
|
200 */ |
|
201 void RunL(); |
|
202 |
|
203 /* |
|
204 * From CActive |
|
205 * Standard active object DoCancel |
|
206 */ |
|
207 void DoCancel(); |
|
208 |
|
209 private: |
|
210 /* Default constructor */ |
|
211 CTNEVideoClipInfoOperation(CTNEVideoClipInfoImp* aInfo, |
|
212 MTNEVideoClipInfoObserver& aObserver); |
|
213 /* Standard Symbian OS two phased constructor */ |
|
214 void ConstructL(); |
|
215 /* Destructor */ |
|
216 ~CTNEVideoClipInfoOperation(); |
|
217 |
|
218 private: |
|
219 // Class to contain video clip info. |
|
220 CTNEVideoClipInfoImp* iInfo; |
|
221 |
|
222 // Observer of video clip info operation. |
|
223 MTNEVideoClipInfoObserver* iObserver; |
|
224 |
|
225 // Error code from TNEprosessor. |
|
226 TInt iTNEProcessorError; |
|
227 |
|
228 friend class CTNEVideoClipInfoImp; |
|
229 }; |
|
230 |
|
231 /** |
|
232 * Internal class for generating a thumb from a video clip file. |
|
233 */ |
|
234 class CTNEVideoClipThumbOperation : public CActive |
|
235 { |
|
236 public: |
|
237 /* Static constructor */ |
|
238 static CTNEVideoClipThumbOperation* NewL(CTNEVideoClipInfoImp* iInfo); |
|
239 |
|
240 protected: |
|
241 /* |
|
242 * From CActive |
|
243 * Standard active object RunL |
|
244 */ |
|
245 void RunL(); |
|
246 |
|
247 /* |
|
248 * From CActive |
|
249 * Standard active object DoCancel |
|
250 */ |
|
251 void DoCancel(); |
|
252 |
|
253 private: |
|
254 /* Default constructor */ |
|
255 CTNEVideoClipThumbOperation(CTNEVideoClipInfoImp* iInfo); |
|
256 /* Standard Symbian OS two phased constructor */ |
|
257 void ConstructL(); |
|
258 /* Destructor */ |
|
259 ~CTNEVideoClipThumbOperation(); |
|
260 |
|
261 /* |
|
262 * Start thumb operation. |
|
263 * |
|
264 * @aparam aObserver Observer of thumbnail operation. |
|
265 * @aparam aIndex Index of frame that is converted to thumbnail. |
|
266 * @aparam aResolution Wanted resolution of thumbnail. |
|
267 * @aparam aPriority Priority of active object. |
|
268 */ |
|
269 void StartL(MTNEVideoClipThumbObserver& aObserver, |
|
270 TInt aIndex, TSize* const aResolution, |
|
271 TDisplayMode aDisplayMode, TBool aEnhance, TInt aPriority); |
|
272 |
|
273 private: |
|
274 // Pointer to info class this thumbnail operation is part of. |
|
275 |
|
276 CTNEVideoClipInfoImp* iInfo; |
|
277 |
|
278 // Index of the wanted frame. |
|
279 TInt iIndex; |
|
280 |
|
281 // Observer of the thumbnail operation. |
|
282 MTNEVideoClipThumbObserver* iObserver; |
|
283 |
|
284 TBool iThumbRequestPending; |
|
285 |
|
286 CTNEProcessor* iTNEProcessor; |
|
287 |
|
288 friend class CTNEVideoClipInfoImp; |
|
289 }; |
|
290 |
|
291 #endif // __TNEVIDEOCLIPINFOIMP_H__ |
|
292 |