|
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 |
|
21 #ifndef __VEDVIDEOCLIPGENERATOR_H__ |
|
22 #define __VEDVIDEOCLIPGENERATOR_H__ |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <fbs.h> |
|
26 |
|
27 #include "VedVideoClipInfo.h" |
|
28 |
|
29 class CVedMovie; |
|
30 class CVedVideoClip; |
|
31 class CVedVideoClipGenerator; |
|
32 |
|
33 |
|
34 /** |
|
35 * Observer for notifying that video clip frame has been completed. |
|
36 * |
|
37 * @see CVedVideoClipGenerator |
|
38 */ |
|
39 class MVedVideoClipGeneratorFrameObserver |
|
40 { |
|
41 public: |
|
42 /** |
|
43 * Called to notify that a video clip frame has been completed. |
|
44 * |
|
45 * @param aGenerator video clip generator |
|
46 * @param aError <code>KErrNone</code> if frame was |
|
47 * completed successfully; one of the system wide |
|
48 * error codes if generating frame failed |
|
49 * @param aFrame pointer to frame if it was completed successfully; |
|
50 * <code>NULL</code> if generating frame failed |
|
51 */ |
|
52 virtual void NotifyVideoClipGeneratorFrameCompleted(CVedVideoClipGenerator& aGenerator, |
|
53 TInt aError, |
|
54 CFbsBitmap* aFrame) = 0; |
|
55 }; |
|
56 |
|
57 |
|
58 /** |
|
59 * Abstract base class for video clip frame generators. Frame generators |
|
60 * can be used to create video clips from bitmaps generated by the application |
|
61 * (for example, by drawing with GDI). |
|
62 */ |
|
63 class CVedVideoClipGenerator : public CBase |
|
64 { |
|
65 public: |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 IMPORT_C virtual ~CVedVideoClipGenerator(); |
|
71 |
|
72 /** |
|
73 * Returns whether this generator has been inserted to a movie |
|
74 * or not. |
|
75 * |
|
76 * @return <code>ETrue</code>, if this generator has been |
|
77 * inserted; <code>EFalse</code>, otherwise |
|
78 */ |
|
79 IMPORT_C TBool IsInserted() const; |
|
80 |
|
81 |
|
82 /** |
|
83 * Returns the movie this generator is associated with. |
|
84 * Panics with <code>EVideoClipGeneratorNotInserted</code> |
|
85 * if this generator has not been inserted to a movie yet. |
|
86 * |
|
87 * @return movie |
|
88 */ |
|
89 IMPORT_C CVedMovie* Movie() const; |
|
90 |
|
91 /** |
|
92 * Returns the index of the video clip this generator is |
|
93 * associated with.Panics with <code>EVideoClipGeneratorNotInserted</code> |
|
94 * if this generator has not been inserted to a movie yet. |
|
95 * |
|
96 * @return video clip index |
|
97 */ |
|
98 IMPORT_C TInt VideoClipIndex() const; |
|
99 |
|
100 /** |
|
101 * Returns whether this generator is owned by the video clip |
|
102 * it is associated with (i.e., whether the video clip is responsible |
|
103 * for deleting this generator). Panics with |
|
104 * <code>EVideoClipGeneratorNotInserted</code> if this generator |
|
105 * has not been inserted to a movie yet. |
|
106 * |
|
107 * @return <code>ETrue</code>, if this generator is owned by |
|
108 * the video clip; <code>EFalse</code>, otherwise |
|
109 */ |
|
110 IMPORT_C TBool IsOwnedByVideoClip() const; |
|
111 |
|
112 /** |
|
113 * Returns the uid of the frame generator. The use of the uid is |
|
114 * entirely application specific. It can be used for example to |
|
115 * identify the frame generator type. The uid is not used in |
|
116 * any way by the video editor engine. |
|
117 * |
|
118 * @return uid of the frame generator |
|
119 */ |
|
120 virtual TUid Uid() const = 0; |
|
121 |
|
122 /** |
|
123 * Returns a descriptive name for the clip. |
|
124 * |
|
125 * @return descriptive name of the clip |
|
126 */ |
|
127 virtual TPtrC DescriptiveName() const = 0; |
|
128 |
|
129 /** |
|
130 * Returns the duration of the clip in microseconds. |
|
131 * |
|
132 * @return duration of the clip |
|
133 */ |
|
134 virtual TTimeIntervalMicroSeconds Duration() const = 0; |
|
135 |
|
136 |
|
137 /* Video frame property methods. */ |
|
138 |
|
139 /** |
|
140 * Returns the number of video frames in this clip. Panics if the |
|
141 * clip is not ready. |
|
142 * |
|
143 * @return number of video frames in this clip |
|
144 */ |
|
145 virtual TInt VideoFrameCount() const = 0; |
|
146 |
|
147 /** |
|
148 * Returns the start time of the video frame at the specified index. |
|
149 * Panics if the index is illegal or if the clip is not ready. |
|
150 * |
|
151 * @param aIndex index |
|
152 * |
|
153 * @return start time of the video frame at the specified index in microseconds |
|
154 */ |
|
155 virtual TTimeIntervalMicroSeconds VideoFrameStartTime(TInt aIndex) const = 0; |
|
156 |
|
157 /** |
|
158 * Returns the end time of the video frame at the specified index. |
|
159 * Panics if the index is illegal or the clip is not ready. |
|
160 * |
|
161 * @param aIndex index |
|
162 * |
|
163 * @return end time of the video frame at the specified index in microseconds |
|
164 */ |
|
165 virtual TTimeIntervalMicroSeconds VideoFrameEndTime(TInt aIndex) const = 0; |
|
166 |
|
167 /** |
|
168 * Returns the duration of the video frame at the specified index. |
|
169 * Panics if the index is illegal or the clip is not ready. |
|
170 * |
|
171 * @param aIndex index |
|
172 * |
|
173 * @return duration of the video frame at the specified index in microseconds |
|
174 */ |
|
175 virtual TTimeIntervalMicroSeconds VideoFrameDuration(TInt aIndex) const = 0; |
|
176 |
|
177 /** |
|
178 * Returns the complexity factor of the first video frame. The complexity factor |
|
179 * should be in the range between 0 to 1000. 0 means no variation at all (a |
|
180 * blank frame), 1000 means a highly complex frame. |
|
181 * |
|
182 * @see CalculateFrameComplexityFactor |
|
183 * |
|
184 * @return complexity factor, range 0...1000 |
|
185 */ |
|
186 virtual TInt VideoFirstFrameComplexityFactor() const = 0; |
|
187 |
|
188 |
|
189 /** |
|
190 * Returns the difference factor of the video frame at the specified |
|
191 * index. The difference factor describes how different the frame is |
|
192 * from the previous frame. The difference factor should be in the range between |
|
193 * 0 to 1000 (0 means that the frame is identical to the previous one, 1000 |
|
194 * means that the frame is completely different from the previous one.) |
|
195 * Panics if the index is illegal or the clip is not yet ready. |
|
196 * |
|
197 * @param aIndex index (starting from 1) |
|
198 * |
|
199 * @return difference factor, range 0...1000 |
|
200 */ |
|
201 virtual TInt VideoFrameDifferenceFactor(TInt aIndex) const = 0; |
|
202 |
|
203 /** |
|
204 * Returns the video frame index at the specified time. Panics if info is not yet |
|
205 * ready for reading or the time is illegal. |
|
206 * |
|
207 * @param aTime time |
|
208 * |
|
209 * @return video frame index at the specified time |
|
210 */ |
|
211 virtual TInt GetVideoFrameIndex(TTimeIntervalMicroSeconds aTime) const = 0; |
|
212 |
|
213 |
|
214 /* Frame methods. */ |
|
215 |
|
216 /** |
|
217 * Generates a bitmap of the given frame. The frame bitmap is scaled |
|
218 * to the specified resolution and converted to the specified display |
|
219 * mode. This method is asynchronous. The frame is generated in the |
|
220 * background and the observer is notified when the frame is complete. |
|
221 * This method panics if the resolution is illegal. |
|
222 * |
|
223 * Possible leave codes: |
|
224 * - <code>KErrNoMemory</code> if memory allocation fails |
|
225 * - <code>KErrNotSupported</code>, if the specified combination of |
|
226 * parameters is not supported |
|
227 * |
|
228 * @param aObserver observer to be notified when the frame is completed |
|
229 * @param aIndex index of frame, or KFrameIndexBestThumb to look for |
|
230 * the most suitable thumbnail frame. |
|
231 * @param aResolution resolution of the desired frame bitmap, or |
|
232 * <code>NULL</code> if the frame should be |
|
233 * in the original resolution |
|
234 * @param aDisplayMode desired display mode; or <code>ENone</code> if |
|
235 * any display mode is acceptable |
|
236 * @param aEnhance apply image enhancement algorithms to improve |
|
237 * frame quality; note that this may considerably |
|
238 * increase the processing time needed to prepare |
|
239 * the frame |
|
240 * @param aPriority priority of the frame generation |
|
241 */ |
|
242 virtual void GetFrameL(MVedVideoClipGeneratorFrameObserver& aObserver, |
|
243 TInt aIndex = KFrameIndexBestThumb, |
|
244 TSize* const aResolution = 0, |
|
245 TDisplayMode aDisplayMode = ENone, |
|
246 TBool aEnhance = EFalse, |
|
247 TInt aPriority = CActive::EPriorityIdle) = 0; |
|
248 |
|
249 /** |
|
250 * Cancels frame generation. If no frame is currently being |
|
251 * generated, the function does nothing. |
|
252 */ |
|
253 virtual void CancelFrame() = 0; |
|
254 |
|
255 protected: // constructors and methods |
|
256 |
|
257 /** |
|
258 * Constructor. |
|
259 */ |
|
260 IMPORT_C CVedVideoClipGenerator(); |
|
261 |
|
262 /** |
|
263 * Reports to the base class that the duration of the generated clip has |
|
264 * changed. This method should <emph>always</emph> be called when the |
|
265 * settings of the generated clip change so that the duration of the |
|
266 * clip is affected. |
|
267 */ |
|
268 IMPORT_C void ReportDurationChanged() const; |
|
269 |
|
270 /** |
|
271 * Reports to the base class that some settings of the generated clip have |
|
272 * changed but the duration of the clip has remained the same. |
|
273 * This method should <emph>always</emph> be called when any settings |
|
274 * of the generated clip change but the duration of the clip is not affected. |
|
275 */ |
|
276 IMPORT_C void ReportSettingsChanged() const; |
|
277 |
|
278 /** |
|
279 * Reports to the base class that descriptive name of the generated |
|
280 * clip has changed. This method should <emph>always</emph> be called |
|
281 * when the descriptive name of the generated clip has changed but no |
|
282 * other changes have occurred. |
|
283 */ |
|
284 IMPORT_C void ReportDescriptiveNameChanged() const; |
|
285 |
|
286 /** |
|
287 * Calculates the complexity of a frame. This method is meant for calculating |
|
288 * frame complexity factors returned by <code>VideoFirstFrameComplexityFactor</code> |
|
289 * method. |
|
290 * |
|
291 * @see VideoFirstFrameComplexityFactor |
|
292 * |
|
293 * @param aFrame frame to analyze |
|
294 * |
|
295 * @return complexity factor |
|
296 */ |
|
297 IMPORT_C TInt CalculateFrameComplexityFactor(CFbsBitmap* aFrame) const; |
|
298 |
|
299 private: // methods |
|
300 |
|
301 /** |
|
302 * Sets the video clip this generator is associated with and whether |
|
303 * the clip owns this generator or not. Note that these properties can |
|
304 * be set only once during the lifetime of a generator when the |
|
305 * generator is inserted to a movie. Panics with |
|
306 * <code>EVideoClipGeneratorAlreadyInserted</code> if the video clip |
|
307 * has already been set. |
|
308 * |
|
309 * @param aVideoClip video clip |
|
310 * @param aIsOwnedByVideoClip <code>ETrue</code>, if the clip is responsible |
|
311 * for deleting this generator; <code>EFalse</code>, |
|
312 * otherwise |
|
313 */ |
|
314 void SetVideoClip(CVedVideoClip& aVideoClip, TBool aIsOwnedByVideoClip); |
|
315 |
|
316 |
|
317 private: |
|
318 // Member variables |
|
319 |
|
320 CVedVideoClip* iVideoClip; |
|
321 TBool iIsOwnedByVideoClip; |
|
322 |
|
323 TInt iMaximumFramerate; |
|
324 |
|
325 friend class CVedMovieAddClipOperation; |
|
326 friend class CVideoEditorTest; |
|
327 |
|
328 }; |
|
329 |
|
330 #endif // __VEDVIDEOCLIPGENERATOR_H__ |
|
331 |