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 * Video decoder client. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef CTRVIDEODECODERCLIENT_H |
|
23 #define CTRVIDEODECODERCLIENT_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <devvideoplay.h> |
|
28 #include <devvideobase.h> |
|
29 #include <devvideostandardcustominterfaces.h> |
|
30 |
|
31 #include "ctrcommon.h" |
|
32 |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class MTRDevVideoClientObserver; |
|
36 class CCMRMediaBuffer; |
|
37 |
|
38 |
|
39 /** |
|
40 * Video decoder client |
|
41 * @lib TRANSCODER.LIB |
|
42 */ |
|
43 NONSHARABLE_CLASS(CTRVideoDecoderClient) : public CBase, public MMMFDevVideoPlayObserver, public MMmfVideoResourceObserver |
|
44 |
|
45 { |
|
46 public: // Constuctor / destructor |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 */ |
|
51 static CTRVideoDecoderClient* NewL(MTRDevVideoClientObserver& aObserver); |
|
52 |
|
53 /** |
|
54 * Destructor. |
|
55 */ |
|
56 ~CTRVideoDecoderClient(); |
|
57 |
|
58 // Information methods |
|
59 /** |
|
60 * Checks codec support by MIME type |
|
61 * @param aFormat MIME type |
|
62 * @param aShortFormat MIME type (short version) |
|
63 * @param aUid Uid of the codec to check |
|
64 * @param aFallbackUid Fallback Uid incase the first one is not found |
|
65 * @return TBool value: ETrue - givemn MIME type is supported; EFalse - no support; |
|
66 */ |
|
67 TBool SupportsCodec(const TDesC8& aFormat, const TDesC8& aShortFormat, TInt aUid, TInt aFallbackUid); |
|
68 |
|
69 /** |
|
70 * Gets codec info |
|
71 * @param none |
|
72 * @return none |
|
73 */ |
|
74 void GetCodecInfoL(); |
|
75 |
|
76 /** |
|
77 * Sets codec parameters |
|
78 * @param aCodecType Codec type |
|
79 * @param aCodecLevel Codec level |
|
80 * @param aInputFormat Input video format |
|
81 * @param aOutputFormat Output video format |
|
82 * @return none |
|
83 */ |
|
84 void SetCodecParametersL(TInt aCodecType, TInt aCodecLevel, const TTRVideoFormat& aInputFormat, |
|
85 const TTRVideoFormat& aOutputFormat); |
|
86 |
|
87 /** |
|
88 * From MMMFDevVideoPlayObserver. Notifies the client that one or more new empty input buffers are available |
|
89 * @param none |
|
90 * @return none |
|
91 */ |
|
92 void MdvpoNewBuffers(); |
|
93 |
|
94 /** |
|
95 * From MMMFDevVideoPlayObserver. Returns a used input video picture back to the caller |
|
96 * @param aPicture Video picture |
|
97 * @return none |
|
98 */ |
|
99 void MdvpoReturnPicture(TVideoPicture *aPicture); |
|
100 |
|
101 /** |
|
102 * From MMMFDevVideoPlayObserver. Delivers supplemental information from a coded data unit |
|
103 * @param aData Data, aTimestamp TimeStamp info, aPictureId Picture Id |
|
104 * @return none |
|
105 */ |
|
106 void MdvpoSupplementalInformation(const TDesC8 &aData, const TTimeIntervalMicroSeconds &aTimestamp, |
|
107 const TPictureId &aPictureId); |
|
108 |
|
109 /** |
|
110 * From MMMFDevVideoPlayObserver. Back channel information from the decoder, indicating a picture loss |
|
111 * without specifying the lost picture |
|
112 * @param none |
|
113 * @return none |
|
114 */ |
|
115 void MdvpoPictureLoss(); |
|
116 |
|
117 /** |
|
118 * From MMMFDevVideoPlayObserver. Back channel information from the decoder, indicating the pictures that have been lost |
|
119 * @param aPictures Array with picture Ids |
|
120 * @return none |
|
121 */ |
|
122 void MdvpoPictureLoss(const TArray< TPictureId > &aPictures); |
|
123 |
|
124 /** |
|
125 * From MMMFDevVideoPlayObserver. Back channel information from the decoder, indicating the loss of consecutive |
|
126 * macroblocks in raster scan order |
|
127 * @param aFirstMacroblock First macroblock, aNumMacroblocks, Number of macroblocks, aPicture PictureId |
|
128 * @return none |
|
129 */ |
|
130 void MdvpoSliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId &aPicture); |
|
131 |
|
132 /** |
|
133 * From MMMFDevVideoPlayObserver. Back channel information from the decoder, indicating a reference picture |
|
134 * selection request |
|
135 * @param aSelectionData Selection data |
|
136 * @return none |
|
137 */ |
|
138 void MdvpoReferencePictureSelection(const TDesC8 &aSelectionData); |
|
139 |
|
140 /** |
|
141 * From MMMFDevVideoPlayObserver. Called when a timed snapshot request has been completed |
|
142 * @param aError Error, aPictureData Picture data, aPresentationTimestamp Presentation timestamp, aPictureId picture Id |
|
143 * @return |
|
144 */ |
|
145 void MdvpoTimedSnapshotComplete(TInt aError, TPictureData *aPictureData, |
|
146 const TTimeIntervalMicroSeconds &aPresentationTimestamp, const TPictureId &aPictureId); |
|
147 |
|
148 /** |
|
149 * From MMMFDevVideoPlayObserver. Notifies the client that one or more new output pictures are available |
|
150 * @param none |
|
151 * @return none |
|
152 */ |
|
153 void MdvpoNewPictures(); |
|
154 |
|
155 /** |
|
156 * From MMMFDevVideoPlayObserver. Reports a fatal decoding or playback error |
|
157 * @param aError Rin-time error |
|
158 * @return none |
|
159 */ |
|
160 void MdvpoFatalError(TInt aError); |
|
161 |
|
162 /** |
|
163 * From MMMFDevVideoPlayObserver. Reports that DevVideoPlay initialization has completed |
|
164 * @param aError Init error status |
|
165 * @return none |
|
166 */ |
|
167 void MdvpoInitComplete(TInt aError); |
|
168 |
|
169 /** |
|
170 * From MMMFDevVideoPlayObserver. Reports that the input video stream end has been reached and all pictures |
|
171 * have been processed |
|
172 * @param none |
|
173 * @return none |
|
174 */ |
|
175 void MdvpoStreamEnd(); |
|
176 |
|
177 /** |
|
178 * Returns used videopicture |
|
179 * @param aPicture Video picture |
|
180 * @return none |
|
181 */ |
|
182 void ReturnPicture(TVideoPicture* aPicture); |
|
183 |
|
184 /** |
|
185 * Starts decoding |
|
186 * @param none |
|
187 * @return none |
|
188 */ |
|
189 void StartL(); |
|
190 |
|
191 /** |
|
192 * Stops decoding synchronously |
|
193 * @param none |
|
194 * @return none |
|
195 */ |
|
196 void StopL(); |
|
197 |
|
198 /** |
|
199 * Stops decoding asynchronously |
|
200 * @param none |
|
201 * @return none |
|
202 */ |
|
203 void AsyncStopL(); |
|
204 |
|
205 /** |
|
206 * Pauses decoding |
|
207 * @param none |
|
208 * @return none |
|
209 */ |
|
210 void Pause(); |
|
211 |
|
212 /** |
|
213 * Resumes decoding |
|
214 * @param none |
|
215 * @return none |
|
216 */ |
|
217 void ResumeL(); |
|
218 |
|
219 /** |
|
220 * Checks codec info |
|
221 * @param aUid Decoder Uid |
|
222 * @return TBool ETrue - accelerated codec; EFalse - non-accelerated codec |
|
223 */ |
|
224 TBool CheckCodecInfoL(TUid aUid); |
|
225 |
|
226 /** |
|
227 * Initialize decoder client |
|
228 * @param none |
|
229 * @return none |
|
230 */ |
|
231 void InitializeL(); |
|
232 |
|
233 /** |
|
234 * Select decoder |
|
235 * @param none |
|
236 * @return none |
|
237 */ |
|
238 void SelectDecoderL(); |
|
239 |
|
240 /** |
|
241 * Send buffer |
|
242 * @param aBuffer Media buffer |
|
243 * @return none |
|
244 */ |
|
245 void SendBufferL(CCMRMediaBuffer* aBuffer); |
|
246 |
|
247 /** |
|
248 * Write coded buffer |
|
249 * @param aBuffer Media buffer |
|
250 * @return none |
|
251 */ |
|
252 void WriteCodedBufferL(CCMRMediaBuffer* aBuffer); |
|
253 |
|
254 /** |
|
255 * Returns a time estimate on long it takes to decode one frame with the current settings |
|
256 * @param aInput Input video format |
|
257 * @param aCodecType EH263 or EMpeg4 |
|
258 * @return TReal time estimate in seconds |
|
259 */ |
|
260 TReal EstimateDecodeFrameTimeL(const TTRVideoFormat& aInput, TInt aCodecType); |
|
261 |
|
262 /** |
|
263 * Checks if decoder supports scaling and enables scaling if supported. |
|
264 * Disables scaling if aInputSize is equal to aOutputSize or scaling is not supported. |
|
265 * @param aInputSize Source picture size |
|
266 * @param aOutputSize Decoded picture size |
|
267 * @return TBool ETrue if scaling is supported, EFalse otherwise |
|
268 */ |
|
269 TBool SetDecoderScaling(TSize& aInputSize, TSize& aOutputSize); |
|
270 |
|
271 /** |
|
272 * Enable / Disable resource observer |
|
273 * @param aEnable ETrue: Observer is enabled, EFalse observer is disabled |
|
274 * @return none |
|
275 */ |
|
276 void EnableResourceObserver(TBool aEnable); |
|
277 |
|
278 /** |
|
279 * From MMmfVideoResourceObserver. Indicates that a media device has lost its resources |
|
280 * @param aMediaDevice UID for the media device that lost resources |
|
281 * @return none |
|
282 */ |
|
283 void MmvroResourcesLost(TUid aMediaDevice); |
|
284 |
|
285 /** |
|
286 * From MMmfVideoResourceObserver. Indicates that a media device has regained its resources |
|
287 * @param aMediaDevice UID for the media device that regained resources |
|
288 * @return none |
|
289 */ |
|
290 void MmvroResourcesRestored(TUid aMediaDevice); |
|
291 |
|
292 private: |
|
293 /** |
|
294 * C++ default constructor. |
|
295 */ |
|
296 CTRVideoDecoderClient(MTRDevVideoClientObserver& aObserver); |
|
297 |
|
298 /** |
|
299 * Symbian 2nd phase constructor, can leave |
|
300 */ |
|
301 void ConstructL(); |
|
302 |
|
303 private: |
|
304 // Observer |
|
305 MTRDevVideoClientObserver& iObserver; |
|
306 |
|
307 // DevVideoPlay |
|
308 CMMFDevVideoPlay* iDevVideoPlay; |
|
309 |
|
310 // Decoder mime type |
|
311 TBuf8<256> iMimeType; |
|
312 |
|
313 // Short version mime type |
|
314 TBuf8<256> iShortMimeType; |
|
315 |
|
316 // Uncompressed format |
|
317 TUncompressedVideoFormat iUncompressedFormat; |
|
318 |
|
319 // Compressed format |
|
320 CCompressedVideoFormat* iCompresedFormat; |
|
321 |
|
322 // HwDevice Uid |
|
323 THwDeviceId iHwDeviceId; |
|
324 |
|
325 // Video coded input buffer |
|
326 TVideoInputBuffer* iInputBuffer; |
|
327 |
|
328 // Decoded picture |
|
329 TVideoPicture* iDecodedPicture; |
|
330 |
|
331 // Uid of the selected codec |
|
332 TUid iUid; |
|
333 |
|
334 // Fallback codec to use if the first one doesn't work |
|
335 TUid iFallbackUid; |
|
336 |
|
337 // Coded buffer |
|
338 CCMRMediaBuffer* iCodedBuffer; |
|
339 |
|
340 // Codec type |
|
341 TInt iCodecType; |
|
342 |
|
343 // Codec level |
|
344 TInt iCodecLevel; |
|
345 |
|
346 // Buffer options |
|
347 CMMFDevVideoPlay::TBufferOptions iBufferOptions; |
|
348 |
|
349 // Fatal error code |
|
350 TInt iFatalError; |
|
351 |
|
352 // Input format |
|
353 TTRVideoFormat iInputFormat; |
|
354 |
|
355 // Output format |
|
356 TTRVideoFormat iOutputFormat; |
|
357 |
|
358 // Data unit type |
|
359 TVideoDataUnitType iDataUnitType; |
|
360 |
|
361 // Stop |
|
362 TBool iStop; |
|
363 |
|
364 // Pause |
|
365 TBool iPause; |
|
366 |
|
367 // Last ts |
|
368 TTimeIntervalMicroSeconds iLastTimestamp; |
|
369 |
|
370 // If selected decoder is accelerated or not |
|
371 TBool iAcceleratedCodecSelected; |
|
372 |
|
373 // If scaling is used or not |
|
374 TBool iScalingInUse; |
|
375 |
|
376 // Decoded picture size if scaling is used |
|
377 TSize iScaledOutputSize; |
|
378 |
|
379 // If deblocking should be used when scaling |
|
380 TBool iScalingWithDeblocking; |
|
381 |
|
382 // Video resource handler custom interface |
|
383 MMmfVideoResourceHandler* iVideoResourceHandlerCI; |
|
384 }; |
|
385 |
|
386 |
|
387 |
|
388 #endif // CTRVIDEODECODERCLIENT_H |
|