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 __VEDVIDEOCLIPINFOIMP_H__ |
|
22 #define __VEDVIDEOCLIPINFOIMP_H__ |
|
23 |
|
24 |
|
25 #include <e32base.h> |
|
26 |
|
27 #include "movieprocessor.h" |
|
28 #include "VedCommon.h" |
|
29 #include "VedVideoClipInfo.h" |
|
30 |
|
31 #include "AudObservers.h" |
|
32 |
|
33 /* |
|
34 * Forward declarations. |
|
35 */ |
|
36 class CFbsBitmap; // cannot include bitmap.h since video processor includes |
|
37 // this file and fails to compile due to a strange compiler error |
|
38 // "operator delete must return type void" if bitmap.h |
|
39 // is included |
|
40 |
|
41 class CVedVideoClipInfo; |
|
42 class TVedVideoFrameInfo; |
|
43 class CVedVideoClipInfoOperation; |
|
44 class CVedVideoClipFrameOperation; |
|
45 class CAudClipInfo; |
|
46 class CVedVideoClip; |
|
47 |
|
48 |
|
49 /** |
|
50 * Utility class for getting information about video clip files. |
|
51 */ |
|
52 class CVedVideoClipInfoImp : public CVedVideoClipInfo |
|
53 { |
|
54 public: |
|
55 |
|
56 static CVedVideoClipInfo* NewL(CAudClipInfo* aAudClipInfo, |
|
57 const TDesC& aFileName, MVedVideoClipInfoObserver& aObserver); |
|
58 /** |
|
59 * Destroys the object and releases all resources. |
|
60 */ |
|
61 ~CVedVideoClipInfoImp(); |
|
62 |
|
63 |
|
64 /* General property methods. */ |
|
65 |
|
66 |
|
67 TPtrC DescriptiveName() const; |
|
68 |
|
69 /** |
|
70 * Returns the file name of the clip. Panics if info |
|
71 * is not yet ready for reading. |
|
72 * |
|
73 * @return file name of the clip |
|
74 */ |
|
75 TPtrC FileName() const; |
|
76 |
|
77 CVedVideoClipGenerator* Generator() const; |
|
78 |
|
79 TVedVideoClipClass Class() const; |
|
80 |
|
81 /** |
|
82 * Returns the video format of the clip. Panics if info |
|
83 * is not yet ready for reading. |
|
84 * |
|
85 * @return video format of the clip |
|
86 */ |
|
87 TVedVideoFormat Format() const; |
|
88 |
|
89 /** |
|
90 * Returns the video type of the clip. Panics if info |
|
91 * is not yet ready for reading. |
|
92 * |
|
93 * @return video type of the clip |
|
94 */ |
|
95 TVedVideoType VideoType() const; |
|
96 |
|
97 /** |
|
98 * Returns the resolution of the clip. Panics if info |
|
99 * is not yet ready for reading. |
|
100 * |
|
101 * @return resolution of the clip |
|
102 */ |
|
103 TSize Resolution() const; |
|
104 |
|
105 /** |
|
106 * Returns whether this video clip has an audio track or not. |
|
107 * Panics if info is not yet ready for reading. |
|
108 * |
|
109 * @return <code>ETrue</code> if clip has an audio track; |
|
110 * <code>EFalse</code> otherwise |
|
111 */ |
|
112 TBool HasAudio() const; |
|
113 |
|
114 /** |
|
115 * Returns the audio type of the clip audio track. Panics if info |
|
116 * is not yet ready for reading. |
|
117 * |
|
118 * @return audio type of the clip audio track |
|
119 */ |
|
120 TVedAudioType AudioType() const; |
|
121 |
|
122 /** |
|
123 * Returns the channel mode of the audio if applicable. |
|
124 * |
|
125 * @return channel mode |
|
126 */ |
|
127 TVedAudioChannelMode AudioChannelMode() const; |
|
128 |
|
129 /** |
|
130 * Returns the sampling rate in kilohertz. |
|
131 * |
|
132 * @return sampling rate |
|
133 */ |
|
134 TInt AudioSamplingRate() const; |
|
135 |
|
136 /** |
|
137 * Returns the duration of the clip in microseconds. Panics if info |
|
138 * is not yet ready for reading. |
|
139 * |
|
140 * @return duration of the clip |
|
141 */ |
|
142 TTimeIntervalMicroSeconds Duration() const; |
|
143 |
|
144 |
|
145 /* Video frame property methods. */ |
|
146 |
|
147 /** |
|
148 * Returns the number of video frames in this clip. Panics if info |
|
149 * is not yet ready for reading. |
|
150 * |
|
151 * @return number of video frames in this clip |
|
152 */ |
|
153 TInt VideoFrameCount() const; |
|
154 |
|
155 /** |
|
156 * Generates video frame info that is needed in VideoFrame API functions. |
|
157 * |
|
158 * @return error code |
|
159 */ |
|
160 TInt GenerateVideoFrameInfoArrayL(); |
|
161 |
|
162 /** |
|
163 * Returns the start time of the video frame at the specified index. |
|
164 * Panics if info is not yet ready for reading or the index is illegal. |
|
165 * |
|
166 * @param aIndex index |
|
167 * |
|
168 * @return start time of the video frame at the specified index in microseconds |
|
169 */ |
|
170 TTimeIntervalMicroSeconds VideoFrameStartTimeL(TInt aIndex); |
|
171 |
|
172 /** |
|
173 * Returns the end time of the video frame at the specified index. |
|
174 * Panics if info is not yet ready for reading or the index is illegal. |
|
175 * |
|
176 * @param aIndex index |
|
177 * |
|
178 * @return end time of the video frame at the specified index in microseconds |
|
179 */ |
|
180 TTimeIntervalMicroSeconds VideoFrameEndTimeL(TInt aIndex); |
|
181 |
|
182 /** |
|
183 * Returns the duration of the video frame at the specified index. |
|
184 * Panics if info is not yet ready for reading or the index is illegal. |
|
185 * |
|
186 * @param aIndex index |
|
187 * |
|
188 * @return duration of the video frame at the specified index in microseconds |
|
189 */ |
|
190 TTimeIntervalMicroSeconds VideoFrameDurationL(TInt aIndex); |
|
191 |
|
192 /** |
|
193 * Returns the size of the video frame at the specified index. |
|
194 * Panics if info is not yet ready for reading or the index is illegal. |
|
195 * |
|
196 * @param aIndex index |
|
197 * |
|
198 * @return size of the video frame at the specified index in bytes |
|
199 */ |
|
200 TInt VideoFrameSizeL(TInt aIndex); |
|
201 |
|
202 /** |
|
203 * Returns whether the video frame at the specified index is an intra |
|
204 * frame or not. Panics if info is not yet ready for reading or |
|
205 * the index is illegal. |
|
206 * |
|
207 * @param aIndex index |
|
208 * |
|
209 * @return <code>ETrue</code>, if the video frame at the specified index is an |
|
210 * intra frame; <code>EFalse</code>, otherwise |
|
211 */ |
|
212 TBool VideoFrameIsIntraL(TInt aIndex); |
|
213 |
|
214 /** |
|
215 * Returns the video frame index at the specified time. Panics if info is not yet |
|
216 * ready for reading or the time is illegal. |
|
217 * |
|
218 * @param aTime time |
|
219 * |
|
220 * @return video frame index at the specified time |
|
221 */ |
|
222 TInt GetVideoFrameIndexL(TTimeIntervalMicroSeconds aTime); |
|
223 |
|
224 |
|
225 /* Frame methods. */ |
|
226 |
|
227 void GetFrameL(MVedVideoClipFrameObserver& aObserver, |
|
228 TInt aIndex, |
|
229 TSize* const aResolution, |
|
230 TDisplayMode aDisplayMode, |
|
231 TBool aEnhance, |
|
232 TInt aPriority); |
|
233 |
|
234 void CancelFrame(); |
|
235 |
|
236 void SetTranscodeFactor(TVedTranscodeFactor aFactor); |
|
237 |
|
238 TVedTranscodeFactor TranscodeFactor(); |
|
239 |
|
240 /** |
|
241 * Returns whether video clip is MMSCompatible. |
|
242 * |
|
243 * @return ETrue if compatible with MMS |
|
244 */ |
|
245 TBool IsMMSCompatible(); |
|
246 |
|
247 static CVedVideoClipInfo* NewL(CAudClipInfo* aAudClipInfo, |
|
248 RFile* aFileHandle, MVedVideoClipInfoObserver& aObserver); |
|
249 |
|
250 RFile* FileHandle() const; |
|
251 |
|
252 private: |
|
253 CVedVideoClipInfoImp(CAudClipInfo* aAudClipInfo); |
|
254 |
|
255 void ConstructL(const TDesC& aFileName, |
|
256 MVedVideoClipInfoObserver& aObserver); |
|
257 |
|
258 void ConstructL(RFile* aFileHandle, |
|
259 MVedVideoClipInfoObserver& aObserver); |
|
260 |
|
261 private: |
|
262 // Member variables |
|
263 |
|
264 // Get audio info operation. |
|
265 CVedVideoClipInfoOperation* iInfoOperation; |
|
266 // Flag to indicate then info is available |
|
267 TBool iReady; |
|
268 |
|
269 // Filename of the video clip. |
|
270 HBufC* iFileName; |
|
271 |
|
272 // File handle of the video clip |
|
273 RFile* iFileHandle; |
|
274 |
|
275 // Vídeo format. |
|
276 TVedVideoFormat iFormat; |
|
277 // Video type/codec. |
|
278 TVedVideoType iVideoType; |
|
279 // Resolution of video clip. |
|
280 TSize iResolution; |
|
281 // Duration of the video clip. |
|
282 TTimeIntervalMicroSeconds iDuration; |
|
283 // Frame count of video |
|
284 TInt iVideoFrameCount; |
|
285 // Array of frame information. |
|
286 TVedVideoFrameInfo* iVideoFrameInfoArray; |
|
287 |
|
288 // Operation to retrieve thumbnail of video clip. |
|
289 CVedVideoClipFrameOperation* iFrameOperation; |
|
290 |
|
291 // Transcode factor |
|
292 TVedTranscodeFactor iTimeFactor; |
|
293 |
|
294 // Is the frame info array ready |
|
295 TBool iVideoFrameInfoArrayReady; |
|
296 |
|
297 // Flag for audio clip info ownership |
|
298 TBool iAudClipInfoOwnedByVideoClipInfo; |
|
299 |
|
300 // Whether the video clip info is part of a video clip or just the info |
|
301 TBool iVideoClipIsStandalone; |
|
302 |
|
303 // Audio clip info. |
|
304 CAudClipInfo* iAudClipInfo; |
|
305 |
|
306 // These are got from iAudClipInfo |
|
307 |
|
308 // Audio type/codec. |
|
309 //TVedAudioType iAudioType; |
|
310 // Following members are only used for AAC audio |
|
311 // Channel mode |
|
312 //TVedAudioChannelMode iAudioChannelMode; |
|
313 // Sampling rate |
|
314 //TInt iAudioSamplingRate; |
|
315 |
|
316 friend class CVedVideoClipInfoOperation; |
|
317 friend class CVedVideoClipFrameOperation; |
|
318 friend class CVedVideoClipInfo; |
|
319 }; |
|
320 |
|
321 |
|
322 /** |
|
323 * Internal class for storing information about video frames. |
|
324 */ |
|
325 class TVedVideoFrameInfo |
|
326 { |
|
327 public: |
|
328 /** Frame start time in MILLISECONDS (not microseconds). */ |
|
329 TInt iStartTime; |
|
330 |
|
331 /** Frame size in bytes. */ |
|
332 TInt iSize; |
|
333 |
|
334 /** Frame information flags. */ |
|
335 TInt8 iFlags; |
|
336 }; |
|
337 |
|
338 #define KVedVideoFrameInfoFlagIntra (1 << 0) |
|
339 |
|
340 |
|
341 /** |
|
342 * Internal class for reading information from a video clip file. |
|
343 * Also implements a simple active object to notify the video clip info |
|
344 * observer when reading has been completed. |
|
345 */ |
|
346 class CVedVideoClipInfoOperation : public CActive, MAudClipInfoObserver |
|
347 { |
|
348 public: |
|
349 /* Static constructor */ |
|
350 static CVedVideoClipInfoOperation* NewL(CVedVideoClipInfoImp* aInfo, |
|
351 MVedVideoClipInfoObserver& aObserver); |
|
352 protected: |
|
353 /* |
|
354 * From CActive |
|
355 * Standard active object RunL |
|
356 */ |
|
357 void RunL(); |
|
358 |
|
359 /* |
|
360 * From CActive |
|
361 * Standard active object DoCancel |
|
362 */ |
|
363 void DoCancel(); |
|
364 |
|
365 private: |
|
366 /* Default constructor */ |
|
367 CVedVideoClipInfoOperation(CVedVideoClipInfoImp* aInfo, |
|
368 MVedVideoClipInfoObserver& aObserver); |
|
369 /* Standard Symbian OS two phased constructor */ |
|
370 void ConstructL(); |
|
371 /* Destructor */ |
|
372 ~CVedVideoClipInfoOperation(); |
|
373 |
|
374 private: // functions from base classes |
|
375 |
|
376 /* From MAudClipInfoObserver */ |
|
377 void NotifyClipInfoReady(CAudClipInfo& aInfo, TInt aError); |
|
378 private: |
|
379 // Class to contain video clip info. |
|
380 CVedVideoClipInfoImp* iInfo; |
|
381 // Observer of video clip info operation. |
|
382 MVedVideoClipInfoObserver* iObserver; |
|
383 // Error code from prosessor. |
|
384 TInt iMovieProcessorError; |
|
385 // This flag tells us whether we're reading the audio clip info |
|
386 TBool iGettingAudio; |
|
387 |
|
388 friend class CVedVideoClipInfoImp; |
|
389 }; |
|
390 |
|
391 /** |
|
392 * Internal class for generating a frame from a video clip file. |
|
393 */ |
|
394 class CVedVideoClipFrameOperation : public CActive |
|
395 { |
|
396 public: |
|
397 /* Static constructor */ |
|
398 static CVedVideoClipFrameOperation* NewL(CVedVideoClipInfoImp* iInfo); |
|
399 |
|
400 protected: |
|
401 /* |
|
402 * From CActive |
|
403 * Standard active object RunL |
|
404 */ |
|
405 void RunL(); |
|
406 |
|
407 /* |
|
408 * From CActive |
|
409 * Standard active object DoCancel |
|
410 */ |
|
411 void DoCancel(); |
|
412 |
|
413 private: |
|
414 /* Default constructor */ |
|
415 CVedVideoClipFrameOperation(CVedVideoClipInfoImp* iInfo); |
|
416 /* Standard Symbian OS two phased constructor */ |
|
417 void ConstructL(); |
|
418 /* Destructor */ |
|
419 ~CVedVideoClipFrameOperation(); |
|
420 |
|
421 /* |
|
422 * Start frame operation. |
|
423 * |
|
424 * @aparam aObserver Observer of thumbnail operation. |
|
425 * @aparam aIndex Index of frame that is converted to thumbnail. |
|
426 * @aparam aResolution Wanted resolution of thumbnail. |
|
427 * @aparam aPriority Priority of active object. |
|
428 */ |
|
429 void StartL(MVedVideoClipFrameObserver& aObserver, |
|
430 TInt aIndex, TSize* const aResolution, |
|
431 TDisplayMode aDisplayMode, TBool aEnhance, TInt aPriority); |
|
432 |
|
433 private: |
|
434 // Pointer to info class this thumbnail operation is part of. |
|
435 |
|
436 CVedVideoClipInfoImp* iInfo; |
|
437 // Index of the wanted frame. |
|
438 TInt iIndex; |
|
439 |
|
440 // Observer of the thumbnail operation. |
|
441 MVedVideoClipFrameObserver* iObserver; |
|
442 |
|
443 TVedTranscodeFactor iFactor; |
|
444 |
|
445 TBool iThumbRequestPending; |
|
446 |
|
447 CMovieProcessor* iProcessor; |
|
448 |
|
449 friend class CVedVideoClipInfoImp; |
|
450 }; |
|
451 |
|
452 #endif // __VEDVIDEOCLIPINFOIMP_H__ |
|
453 |
|