|
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 Decoder wrapper |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef TNEDECODERWRAP_H |
|
22 #define TNEDECODERWRAP_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <devvideoplay.h> |
|
27 #include <devvideobase.h> |
|
28 #include "ctrcommon.h" // @@ YHK Check do we need this |
|
29 |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class MTRDevVideoClientObserver; |
|
33 class TVideoBuffer; |
|
34 |
|
35 // Observer class for thumbnail generation |
|
36 class MThumbnailObserver |
|
37 { |
|
38 public: |
|
39 virtual void MNotifyThumbnailReady(TInt aError) = 0; |
|
40 virtual void MPictureFromDecoder (TVideoPicture* aPicture) = 0; |
|
41 virtual void MReturnCodedBuffer(TVideoBuffer* aBuffer) = 0; |
|
42 virtual void MSendEncodedBuffer() = 0; |
|
43 }; |
|
44 |
|
45 |
|
46 /** |
|
47 * TNE decoder wrap |
|
48 * @lib TNE.LIB |
|
49 */ |
|
50 NONSHARABLE_CLASS(CTNEDecoderWrap) : public CBase, public MMMFDevVideoPlayObserver |
|
51 { |
|
52 public: // Constuctor / destructor |
|
53 |
|
54 /** |
|
55 * Two-phased constructor. |
|
56 */ |
|
57 static CTNEDecoderWrap* NewL(MThumbnailObserver* aObserver); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 ~CTNEDecoderWrap(); |
|
63 |
|
64 // Information methods |
|
65 /** |
|
66 * Checks codec support by MIME type |
|
67 * @param aFormat MIME type |
|
68 * @param aShortFormat MIME type (short version) |
|
69 * @return TBool value: ETrue - givemn MIME type is supported; EFalse - no support; |
|
70 */ |
|
71 TBool SupportsCodec(const TDesC8& aFormat, const TDesC8& aShortFormat); |
|
72 |
|
73 /** |
|
74 * Gets codec info |
|
75 * @param none |
|
76 * @return none |
|
77 */ |
|
78 void GetCodecInfoL(); |
|
79 |
|
80 /** |
|
81 * Sets codec parameters |
|
82 * @param aCodecLevel Codec level, aFormat video format, aOutputFormat Output video format |
|
83 * @return none |
|
84 */ |
|
85 void SetDecoderParametersL(TInt aCodecLevel, const TTRVideoFormat& aFormat); |
|
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 * Checks decoder info |
|
207 * @param aUid Decoder Uid |
|
208 * @return TBool ETrue - accelerated codec; EFalse - non-accelerated codec |
|
209 */ |
|
210 TBool CheckDecoderInfoL(TUid aUid); |
|
211 |
|
212 /** |
|
213 * Initialize decoder client |
|
214 * @param none |
|
215 * @return none |
|
216 */ |
|
217 void InitializeL(); |
|
218 |
|
219 /** |
|
220 * Select decoder |
|
221 * @param none |
|
222 * @return none |
|
223 */ |
|
224 void SelectDecoderL(); |
|
225 |
|
226 /** |
|
227 * Send buffer |
|
228 * @param aBuffer Media buffer |
|
229 * @return none |
|
230 */ |
|
231 void SendBufferL(TVideoBuffer* aBuffer); |
|
232 |
|
233 /** |
|
234 * Write coded buffer |
|
235 * @param aBuffer Media buffer |
|
236 * @return none |
|
237 */ |
|
238 void WriteCodedBufferL(TVideoBuffer* aBuffer); |
|
239 |
|
240 /** |
|
241 * Write coded buffer |
|
242 * @param aBuffer Media buffer |
|
243 * @return none |
|
244 */ |
|
245 |
|
246 TUint GetNumInputFreeBuffers(); |
|
247 |
|
248 private: |
|
249 /** |
|
250 * C++ default constructor. |
|
251 */ |
|
252 CTNEDecoderWrap(MThumbnailObserver* aObserver); |
|
253 |
|
254 /** |
|
255 * Symbian 2nd phase constructor, can leave |
|
256 */ |
|
257 void ConstructL(); |
|
258 |
|
259 private: |
|
260 // Observer |
|
261 MThumbnailObserver* iObserver; |
|
262 |
|
263 // DevVideoPlay |
|
264 CMMFDevVideoPlay* iDevVideoPlay; |
|
265 |
|
266 // Decoder mime type |
|
267 TBuf8<256> iMimeType; |
|
268 |
|
269 // Short version mime type |
|
270 TBuf8<256> iShortMimeType; |
|
271 |
|
272 // Uncompressed format |
|
273 TUncompressedVideoFormat iUncompressedFormat; |
|
274 |
|
275 // Compressed format |
|
276 CCompressedVideoFormat* iCompresedFormat; |
|
277 |
|
278 // HwDevice Uid |
|
279 THwDeviceId iHwDeviceId; |
|
280 |
|
281 // Video coded input buffer |
|
282 TVideoInputBuffer* iInputBuffer; |
|
283 |
|
284 // Decoded picture |
|
285 TVideoPicture* iDecodedPicture; |
|
286 |
|
287 // Uid |
|
288 TUid iUid; |
|
289 |
|
290 // Coded buffer |
|
291 TVideoBuffer* iCodedBuffer; |
|
292 |
|
293 // Codec level |
|
294 TInt iCodecLevel; |
|
295 |
|
296 // Decoders to check |
|
297 RArray<TUid> iCheckDecoders; |
|
298 |
|
299 // array of Accelerated Decoders |
|
300 RArray<TUid> iAcceleratedDecoders; |
|
301 |
|
302 // Buffer options |
|
303 CMMFDevVideoPlay::TBufferOptions iBufferOptions; |
|
304 |
|
305 // Fatal error code |
|
306 TInt iFatalError; |
|
307 |
|
308 // decoder format |
|
309 TTRVideoFormat iFormat; |
|
310 |
|
311 // Data unit type |
|
312 TVideoDataUnitType iDataUnitType; |
|
313 |
|
314 // Stop |
|
315 TBool iStop; |
|
316 |
|
317 TInt iState; |
|
318 |
|
319 // Last ts |
|
320 TTimeIntervalMicroSeconds iLastTimestamp; |
|
321 |
|
322 // support for AVC |
|
323 |
|
324 //clock source |
|
325 CSystemClockSource* iClockSource; |
|
326 |
|
327 // keep track of frame sequence number |
|
328 TInt iInputFrameNum; |
|
329 |
|
330 }; |
|
331 |
|
332 |
|
333 /** |
|
334 * Buffer class used in TNEProcessor |
|
335 * |
|
336 */ |
|
337 class TVideoBuffer : public CBase |
|
338 { |
|
339 |
|
340 public: // Constants |
|
341 |
|
342 // Buffer type |
|
343 enum TBufferType |
|
344 { |
|
345 EAudioAMRNB = 0, |
|
346 EAudioAMRWB, |
|
347 EVideoH263, |
|
348 EVideoMPEG4, |
|
349 EVideoMPEG4DecSpecInfo, |
|
350 EAudioQCELP13, |
|
351 EAudioDecSpecInfo, |
|
352 EAudioMPEG4AAC |
|
353 }; |
|
354 |
|
355 public: // Constructors and destructor |
|
356 |
|
357 /** |
|
358 * C++ constructors. The 1st creates a buffer to be initialized later with Set, |
|
359 * and the 2nd one initializes it already here |
|
360 */ |
|
361 |
|
362 inline TVideoBuffer() {} |
|
363 |
|
364 inline TVideoBuffer(const TPtrC8& aBuffer, |
|
365 const TBufferType aType, |
|
366 const TInt aSize, |
|
367 const TBool aRandomAccessPoint, |
|
368 const TTimeIntervalMicroSeconds& aTimeStamp) |
|
369 : iType(aType), iSize(aSize), iRandomAccessPoint(aRandomAccessPoint), iTimeStamp(aTimeStamp), iPtr(aBuffer) {} |
|
370 |
|
371 /** |
|
372 * Destructor. |
|
373 */ |
|
374 inline ~TVideoBuffer() {} |
|
375 |
|
376 public: // New functions |
|
377 |
|
378 /** |
|
379 * Set the buffer parameters. This enables reusing the buffer |
|
380 * @since 3.2 |
|
381 * @param const TPtrC8& aBuffer Data buffer |
|
382 * @param const TBufferType aType Buffer type |
|
383 * @param const TInt aSize Buffer size (in bytes) |
|
384 * @param const TBool aRandomAccessPoint ETrue if buffer has a video random access point |
|
385 * @param const TTimeIntervalMicroSeconds& aTimeStamp Timestamp of the buffer |
|
386 * @return void |
|
387 */ |
|
388 inline void Set(const TPtrC8& aBuffer, |
|
389 const TBufferType aType, |
|
390 const TInt aSize, |
|
391 const TBool aRandomAccessPoint, |
|
392 const TTimeIntervalMicroSeconds& aTimeStamp) |
|
393 { |
|
394 iType = aType; |
|
395 iSize = aSize; |
|
396 iRandomAccessPoint = aRandomAccessPoint; |
|
397 iTimeStamp = aTimeStamp; |
|
398 iPtr.Set(aBuffer); |
|
399 } |
|
400 |
|
401 /** |
|
402 * Return the data pointer |
|
403 * @since 3.2 |
|
404 * @return TPtrC8 pointer |
|
405 */ |
|
406 inline TPtrC8 Data() const { return iPtr; } |
|
407 |
|
408 /** |
|
409 * Return buffer type |
|
410 * @since 3.2 |
|
411 * @return TInt Error code |
|
412 */ |
|
413 inline TBufferType Type() const { return iType; } |
|
414 |
|
415 /** |
|
416 * Write Return buffer size |
|
417 * @since 3.2 |
|
418 * @return TInt Error code |
|
419 */ |
|
420 inline TInt BufferSize() const { return iSize; } |
|
421 |
|
422 /** |
|
423 * Query whether this buffer contains a frame that can be used as a random-access point |
|
424 * @since 3.2 |
|
425 * @return TBool ETrue if this is a random access point |
|
426 */ |
|
427 inline TBool RandomAccessPoint() const { return iRandomAccessPoint; } |
|
428 |
|
429 /** |
|
430 * Write a buffer to sink |
|
431 * @since 3.2 |
|
432 * @return TTimeIntervalMicroSeconds Timestamp |
|
433 */ |
|
434 inline TTimeIntervalMicroSeconds TimeStamp() const { return iTimeStamp; } |
|
435 |
|
436 private: // Data |
|
437 |
|
438 // media type |
|
439 TBufferType iType; |
|
440 |
|
441 // media buffer size in bytes |
|
442 TInt iSize; |
|
443 |
|
444 // ETrue if the media contained in this buffer |
|
445 // can be used as random access point in playback |
|
446 TBool iRandomAccessPoint; |
|
447 |
|
448 // time stamp in microseconds counting from the beginning of rec. |
|
449 TTimeIntervalMicroSeconds iTimeStamp; |
|
450 |
|
451 // descriptor for returning the data pointer |
|
452 TPtrC8 iPtr; |
|
453 }; |
|
454 |
|
455 |
|
456 |
|
457 #endif // TNEDECODERWRAP_H |