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 * Movie processor interface class. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __MOVIEPROCESSOR_H__ |
|
23 #define __MOVIEPROCESSOR_H__ |
|
24 |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <e32std.h> |
|
28 #include <gdi.h> |
|
29 |
|
30 #include "VedCommon.h" |
|
31 |
|
32 /* |
|
33 * Forward declarations. |
|
34 */ |
|
35 |
|
36 class CVedMovie; |
|
37 class CVedMovieImp; |
|
38 class CVedAudioClip; |
|
39 class TVedVideoFrameInfo; |
|
40 class TVideoProcessorAudioData; |
|
41 class CMovieProcessorImpl; |
|
42 |
|
43 class MVedMovieProcessingObserver; |
|
44 |
|
45 /** |
|
46 * Movie processor. |
|
47 */ |
|
48 class CMovieProcessor : public CBase |
|
49 { |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Constructors for instantiating new movie processors. |
|
54 * Should reserve as little resources as possible at this point. |
|
55 */ |
|
56 static CMovieProcessor* NewL(); |
|
57 static CMovieProcessor* NewLC(); |
|
58 |
|
59 /** |
|
60 * Destructor can be called at any time (i.e., also in the middle of a processing operation). |
|
61 * Should release all allocated resources, including releasing all allocated memory and |
|
62 * *deleting* all output files that are currently being processed but not yet completed. |
|
63 */ |
|
64 virtual ~CMovieProcessor(); |
|
65 |
|
66 /** |
|
67 * Read the header from the specified video clip file and return its properties. |
|
68 * The file should be opened with EFileShareReadersOnly share mode. |
|
69 * |
|
70 * Possible leave codes: |
|
71 * - <code>KErrNoMemory</code> if memory allocation fails |
|
72 * - <code>KErrNotFound</code> if there is no file with the specified name |
|
73 * in the specified directory (but the directory exists) |
|
74 * - <code>KErrPathNotFound</code> if the specified directory |
|
75 * does not exist |
|
76 * - <code>KErrUnknown</code> if the specified file is of unknown format |
|
77 * |
|
78 * @param aFileName name of the file to read |
|
79 * @aFileHandle handle of the file to read |
|
80 * @param aVideoFormat for returning the video format |
|
81 * @param aVideoType for returning the video type |
|
82 * @param aResolution for returning the resolution |
|
83 * @param aAudioType for returning the audio type |
|
84 * @param aDuration for returning the duration |
|
85 * @param aVideoFrameCount for returning the number of video frames |
|
86 * @param aSamplingRate for returning the sampling rate |
|
87 * @param aChannelMode for returning the channel mode |
|
88 */ |
|
89 void GetVideoClipPropertiesL(const TDesC& aFileName, |
|
90 RFile* aFileHandle, |
|
91 TVedVideoFormat& aFormat, |
|
92 TVedVideoType& aVideoType, |
|
93 TSize& aResolution, |
|
94 TVedAudioType& aAudioType, |
|
95 TTimeIntervalMicroSeconds& aDuration, |
|
96 TInt& aVideoFrameCount, |
|
97 TInt& aSamplingRate, |
|
98 TVedAudioChannelMode& aChannelMode); |
|
99 |
|
100 /** |
|
101 * Read video frame information from the specified video clip file and fills array of info for |
|
102 * all frames in video.The file should be opened with EFileShareReadersOnly share mode. Video processor |
|
103 * should not free the video frame info array after it has passed it on as a return value |
|
104 * of this function. Returned array should be allocated with User::AllocL() and should be |
|
105 * freed by the caller of this method with User::Free(). |
|
106 * |
|
107 * Possible leave codes: |
|
108 * - <code>KErrNoMemory</code> if memory allocation fails |
|
109 * - <code>KErrNotFound</code> if there is no file with the specified name |
|
110 * in the specified directory (but the directory exists) |
|
111 * - <code>KErrPathNotFound</code> if the specified directory |
|
112 * does not exist |
|
113 * - <code>KErrUnknown</code> if the specified file is of unknown format |
|
114 * |
|
115 * @param aFileName name of the file to read |
|
116 * @param aFileHandle handle of the file to read |
|
117 * @param aVideoFrameInfoArray Array for video frame parameters |
|
118 */ |
|
119 void GenerateVideoFrameInfoArrayL(const TDesC& aFileName, RFile* aFileHandle, TVedVideoFrameInfo*& aVideoFrameInfoArray); |
|
120 |
|
121 /** |
|
122 * Returns an estimate of the total size of the specified movie. |
|
123 * |
|
124 * @return size estimate in bytes |
|
125 */ |
|
126 TInt GetMovieSizeEstimateL(const CVedMovie* aMovie); |
|
127 |
|
128 /** |
|
129 * Calculate movie size estimate for MMS |
|
130 * |
|
131 * @param aMovie Movie object |
|
132 * @param aTargetSize Maximum size allowed |
|
133 * @param aStartTime Time of the first frame included in the MMS output |
|
134 * @param aEndTime Time of the last frame included in the MMS output |
|
135 * @return Error code |
|
136 */ |
|
137 TInt GetMovieSizeEstimateForMMSL(const CVedMovie* aMovie, TInt aTargetSize, |
|
138 TTimeIntervalMicroSeconds aStartTime, TTimeIntervalMicroSeconds& aEndTime); |
|
139 |
|
140 /** |
|
141 * Do all initializations necessary to start generating a thumbnail, e.g. open files, |
|
142 * allocate memory. The video clip file should be opened with EFileShareReadersOnly |
|
143 * share mode. The thumbnail should be scaled to the specified resolution and |
|
144 * converted to the specified display mode. If this method leaves, destructor should be called to free |
|
145 * allocated resources. |
|
146 * |
|
147 * Possible leave codes: |
|
148 * - <code>KErrNoMemory</code> if memory allocation fails |
|
149 * - <code>KErrNotFound</code> if there is no file with the specified name |
|
150 * in the specified directory (but the directory exists) |
|
151 * - <code>KErrPathNotFound</code> if the specified directory |
|
152 * does not exist |
|
153 * - <code>KErrUnknown</code> if the specified file is of unknown format |
|
154 * - <code>KErrNotSupported</code> if the specified combination of parameters |
|
155 * is not supported |
|
156 * |
|
157 * @param aFileName name of the file to generate thumbnail from |
|
158 * @param aFileHandle handle of the file to generate thumbnail from |
|
159 * @param aIndex Frame index for selecting the thumbnail frame |
|
160 * -1 means the best thumbnail is retrieved |
|
161 * @param aResolution resolution of the desired thumbnail bitmap, or |
|
162 * <code>NULL</code> if the thumbnail should be |
|
163 * in the original resolution |
|
164 * @param aDisplayMode desired display mode; or <code>ENone</code> if |
|
165 * any display mode is acceptable |
|
166 * @param aEnhance apply image enhancement algorithms to improve |
|
167 * thumbnail quality; note that this may considerably |
|
168 * increase the processing time needed to prepare |
|
169 * the thumbnail |
|
170 */ |
|
171 void StartThumbL(const TDesC& aFileName, RFile* aFileHandle, TInt aIndex, TSize aResolution, |
|
172 TDisplayMode aDisplayMode, TBool aEnhance); |
|
173 |
|
174 /** |
|
175 * Starts thumbnail generation. Thumbnail generation is an asynchronous operation, |
|
176 * and its completion is informed to the caller via Active object request completion; |
|
177 * the iStatus member of the caller is passed as a parameter to this method. |
|
178 * |
|
179 * This method may leave if an error occurs in initiating the thumbnail generation. |
|
180 * If this method leaves, destructor should be called to free allocated resources. |
|
181 * |
|
182 * @param aStatus Reference to caller's iStatus member variable |
|
183 * @param aFactor Pointer to a TVedTranscodeFactor structure, which is updated by this method |
|
184 * |
|
185 * @return |
|
186 * |
|
187 */ |
|
188 void ProcessThumbL(TRequestStatus &aStatus, TVedTranscodeFactor* aFactor); |
|
189 |
|
190 /** |
|
191 * Method for retrieving the completed thumbnail bitmap. |
|
192 * |
|
193 * Video processor should not free the CFbsBitmap instance after it has passed it on |
|
194 * as a return value of this function |
|
195 * |
|
196 */ |
|
197 void FetchThumb(CFbsBitmap*& aThumb); |
|
198 |
|
199 /** |
|
200 * Do all initializations necessary to start processing a movie, e.g. open files and |
|
201 * allocate memory. After initialization, processing is started and the observer |
|
202 * is notified. The source video and audio files should be opened with |
|
203 * EFileShareReadersOnly share mode. If this method leaves, destructor should be called |
|
204 * to free allocated resources. |
|
205 * |
|
206 * Possible leave codes: |
|
207 * . |
|
208 * |
|
209 * @param aMovie movie to process |
|
210 * @param aFilename output file name |
|
211 * @param aFilename output file handle |
|
212 */ |
|
213 void StartMovieL(CVedMovieImp* aMovie, const TDesC& aFileName, RFile* aFileHandle, |
|
214 MVedMovieProcessingObserver *aObserver); |
|
215 |
|
216 /** |
|
217 * Cancels the processing of a movie. The processor is reseted to an idle state. |
|
218 * The user must call StartMovieL again after this to start processing again. |
|
219 * |
|
220 * Possible leave codes: |
|
221 * . |
|
222 * |
|
223 */ |
|
224 void CancelProcessingL(); |
|
225 |
|
226 /** |
|
227 * Sets the maximum size for the movie |
|
228 * |
|
229 * @param aLimit Maximum size in bytes |
|
230 */ |
|
231 void SetMovieSizeLimit(TInt aLimit); |
|
232 |
|
233 |
|
234 protected: |
|
235 CMovieProcessor(); |
|
236 |
|
237 void ConstructL(); |
|
238 |
|
239 private: |
|
240 TInt iThumbProgress; |
|
241 TInt iMovieProgress; |
|
242 RPointerArray<TVideoProcessorAudioData> iAudioDataArray; |
|
243 CMovieProcessorImpl* iMovieProcessor; |
|
244 }; |
|
245 |
|
246 |
|
247 #endif // __MEDIAPROCESSOR_H__ |
|
248 |
|