|
1 /* |
|
2 * Copyright (c) 2009 Aricent and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "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 * Aricent - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * This is a source file, which is required for Mp4DecHwDevice. |
|
16 * |
|
17 */ |
|
18 |
|
19 //User includes |
|
20 #include "arimpeg4aspdechwdevice.h" |
|
21 #include "aristatemachine.h" |
|
22 #include "ariprint.h" |
|
23 |
|
24 //manufacturer name |
|
25 _LIT( KManufacturer, "Aricent" ); |
|
26 |
|
27 _LIT( KIdentifier, "MPEG4/H263 Video Decoder" ); |
|
28 |
|
29 //supported mime types for mp4 |
|
30 _LIT8( KMPEG4SupportedMimeType, "video/mp4v-es" ); |
|
31 // profile level 0 |
|
32 _LIT8( KMPEG4SupportedProfileLevel_0, "video/mp4v-es; profile-level-id=8" ); |
|
33 // profile level 0b / 11 |
|
34 _LIT8( KMPEG4SupportedProfileLevel_0b, "video/mp4v-es; profile-level-id=9" ); |
|
35 // profile level 1 |
|
36 _LIT8( KMPEG4SupportedProfileLevel_1, "video/mp4v-es; profile-level-id=1" ); |
|
37 // profile level 2 |
|
38 _LIT8( KMPEG4SupportedProfileLevel_2, "video/mp4v-es; profile-level-id=2" ); |
|
39 // profile level 3 |
|
40 _LIT8( KMPEG4SupportedProfileLevel_3, "video/mp4v-es; profile-level-id=3" ); |
|
41 // profile level 4 |
|
42 _LIT8( KMPEG4SupportedProfileLevel_4, "video/mp4v-es; profile-level-id=4" ); |
|
43 // profile level 5 |
|
44 _LIT8( KMPEG4SupportedProfileLevel_5, "video/mp4v-es; profile-level-id=5" ); |
|
45 |
|
46 //supported mime types for h263 |
|
47 _LIT8( KH263SupportedMimeType, "video/h263-2000" ); |
|
48 _LIT8( KH26398SupportedMimeType, "video/h263-1998" ); |
|
49 |
|
50 // h263 profile level 10 |
|
51 _LIT8( KH263SupportedProfileLevel_10, "video/h263-2000;profile=0;level=10" ); |
|
52 // h263 profile level 20 |
|
53 _LIT8( KH263SupportedProfileLevel_20, "video/h263-2000;profile=0;level=20" ); |
|
54 // h263 profile level 30 |
|
55 _LIT8( KH263SupportedProfileLevel_30, "video/h263-2000;profile=0;level=30" ); |
|
56 // h263 profile level 45 |
|
57 _LIT8( KH263SupportedProfileLevel_45, "video/h263-2000;profile=0;level=45" ); |
|
58 |
|
59 |
|
60 //--------------------------------------------------------------------------- |
|
61 //1st phase constructor of CAriMpeg4aspdecHwDevice |
|
62 //--------------------------------------------------------------------------- |
|
63 // |
|
64 CMMFVideoDecodeHwDevice* CAriMpeg4aspdecHwDevice::NewL() |
|
65 { |
|
66 PRINT_ENTRY; |
|
67 CAriMpeg4aspdecHwDevice* self = new ( ELeave ) CAriMpeg4aspdecHwDevice; |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 CleanupStack::Pop( self ); |
|
71 PRINT_EXIT; |
|
72 return self; |
|
73 } |
|
74 |
|
75 |
|
76 //--------------------------------------------------------------------------- |
|
77 //Destructor |
|
78 //--------------------------------------------------------------------------- |
|
79 // |
|
80 CAriMpeg4aspdecHwDevice::~CAriMpeg4aspdecHwDevice() |
|
81 { |
|
82 PRINT_ENTRY; |
|
83 delete iInputFormat; |
|
84 delete iEngine; |
|
85 delete iCodec; |
|
86 delete iState; |
|
87 |
|
88 delete iVideoPictureHeader; |
|
89 |
|
90 // This is required becoz user may say exit before start at that point |
|
91 // OutputFreeBuffer is not created |
|
92 if ( iOutputFreeBuffer ) |
|
93 { |
|
94 for ( TInt i = 0 ; i < KMaxOutputBuffers; i++ ) |
|
95 { |
|
96 if ( ( iOutputFreeBuffer + i )->iHeader ) |
|
97 { |
|
98 delete ( iOutputFreeBuffer + i )->iHeader; |
|
99 } |
|
100 if ( ( iOutputFreeBuffer + i )->iData.iRawData ) |
|
101 { |
|
102 delete |
|
103 ( TUint8* )( iOutputFreeBuffer + i )->iData.iRawData->Ptr(); |
|
104 } |
|
105 if ( ( iOutputFreeBuffer + i )->iData.iRawData ) |
|
106 { |
|
107 delete ( iOutputFreeBuffer + i )->iData.iRawData; |
|
108 } |
|
109 } |
|
110 delete [] iOutputFreeBuffer; |
|
111 } |
|
112 |
|
113 if ( iInputFreeBuffers ) |
|
114 { |
|
115 TInt i; |
|
116 for ( i = 0 ; i < TInt( iBufferOptions.iMinNumInputBuffers ); i++ ) |
|
117 { |
|
118 delete [] ( TUint8* )iInputFreeBuffers[i].iData.Ptr(); |
|
119 delete iInputFreeBuffers[i].iUser; |
|
120 } |
|
121 delete [] iInputFreeBuffers; |
|
122 } |
|
123 |
|
124 if ( iCustomBufferOptions ) |
|
125 { |
|
126 delete iCustomBufferOptions; |
|
127 } |
|
128 iOutputFreeBufferQueue.Close(); |
|
129 iInputFreeBufferQueue.Close(); |
|
130 |
|
131 iMaxPictureRates.Reset(); |
|
132 iMaxPictureRates.Close(); |
|
133 iSupportedFormats.Reset(); |
|
134 iSupportedFormats.Close(); |
|
135 |
|
136 iOutputDevice = NULL; |
|
137 iMMFDevVideoPlayProxy = NULL; |
|
138 iCustomBufferHandle = NULL; |
|
139 PRINT_EXIT; |
|
140 } |
|
141 //--------------------------------------------------------------------------- |
|
142 //Retrieves a custom interface to the device. |
|
143 //--------------------------------------------------------------------------- |
|
144 // |
|
145 TAny* CAriMpeg4aspdecHwDevice::CustomInterface( TUid /*aInterface*/ ) |
|
146 { |
|
147 PRINT_ENTRY; |
|
148 PRINT_EXIT; |
|
149 |
|
150 return NULL; |
|
151 } |
|
152 |
|
153 |
|
154 //--------------------------------------------------------------------------- |
|
155 //Retrieves decoder information about this hardware device. The device |
|
156 //creates a CVideoDecoderInfo structure, fills it with correct data, |
|
157 //pushes it to the cleanup stack and returns it. The client will delete the |
|
158 //object when it is no longer needed. |
|
159 //--------------------------------------------------------------------------- |
|
160 // |
|
161 CVideoDecoderInfo* CAriMpeg4aspdecHwDevice::VideoDecoderInfoLC() |
|
162 { |
|
163 PRINT_ENTRY; |
|
164 for ( TUint i = 0; i < KDecoderInfoCount; i++ ) |
|
165 { |
|
166 // construct the video types for iVidTypes |
|
167 CCompressedVideoFormat* format = NULL; |
|
168 TPtrC8 mimeType = KDecoderInfoMimeArray[i]; |
|
169 format = CCompressedVideoFormat::NewL( mimeType ); |
|
170 CleanupStack::PushL(format); |
|
171 TInt status = iSupportedFormats.Append( format ); |
|
172 if ( status != KErrNone ) |
|
173 { |
|
174 PRINT_MSG( LEVEL_LOW, ( " Format support is not done, retval of " |
|
175 "append = %d \n", status ) ); |
|
176 } |
|
177 CleanupStack::Pop( format ); |
|
178 |
|
179 // max picture rates |
|
180 TPictureRateAndSize pictureRateAndSize; |
|
181 pictureRateAndSize.iPictureSize = TSize( KMaxFrameWidth, |
|
182 KMaxFrameHeight ); |
|
183 pictureRateAndSize.iPictureRate = KPicRate; |
|
184 status = iMaxPictureRates.Append(pictureRateAndSize); |
|
185 if ( status != KErrNone ) |
|
186 { |
|
187 PRINT_MSG( LEVEL_LOW, ( " error in appendng picturerates = %d \n", |
|
188 status ) ); |
|
189 } |
|
190 } |
|
191 |
|
192 TUint maxBitRate = KMaxBitRate; |
|
193 |
|
194 CVideoDecoderInfo* videoDecoderInfo = CVideoDecoderInfo::NewL( |
|
195 KUidMp4H263DecoderHwDevice, |
|
196 KManufacturer, |
|
197 KIdentifier, |
|
198 TVersion( 1, 0, 0 ), |
|
199 iSupportedFormats.Array(), |
|
200 EFalse, |
|
201 EFalse, |
|
202 TSize( KMaxFrameWidth, KMaxFrameHeight ), |
|
203 maxBitRate, |
|
204 iMaxPictureRates.Array(), |
|
205 ETrue, |
|
206 ETrue ); |
|
207 |
|
208 CleanupStack::PushL( videoDecoderInfo ); |
|
209 |
|
210 PRINT_MSG( LEVEL_LOW, ( "Closing maxPictureRates&supportedFormats\n" ) ); |
|
211 |
|
212 PRINT_EXIT; |
|
213 |
|
214 return videoDecoderInfo; |
|
215 } |
|
216 |
|
217 //--------------------------------------------------------------------------- |
|
218 //Reads header information from a coded data unit. |
|
219 //--------------------------------------------------------------------------- |
|
220 // |
|
221 TVideoPictureHeader* CAriMpeg4aspdecHwDevice::GetHeaderInformationL( |
|
222 TVideoDataUnitType /*aDataUnitType*/, |
|
223 TVideoDataUnitEncapsulation aEncapsulation, |
|
224 TVideoInputBuffer* aDataUnit ) |
|
225 { |
|
226 PRINT_ENTRY; |
|
227 if ( !aDataUnit ) |
|
228 { |
|
229 PRINT_ERR( "Input argument is not proper, aDataUnit is null \n" ); |
|
230 User::Leave( KErrArgument ); |
|
231 } |
|
232 |
|
233 if ( aEncapsulation != EDuElementaryStream ) |
|
234 { |
|
235 PRINT_ERR( "aEncapsulation is not supported type \n" ); |
|
236 User::Leave( KErrNotSupported ); |
|
237 } |
|
238 |
|
239 iVideoPictureHeader = new ( ELeave ) TVideoPictureHeader; |
|
240 |
|
241 TRAPD( err, CAriMpeg4aspdecWrapper::GetHeaderInfoL( *aDataUnit, |
|
242 *iVideoPictureHeader ) ); |
|
243 |
|
244 if ( err == KErrNone ) |
|
245 { |
|
246 PRINT_EXIT; |
|
247 return ( iVideoPictureHeader ); |
|
248 } |
|
249 delete iVideoPictureHeader; |
|
250 iVideoPictureHeader = NULL; |
|
251 |
|
252 switch ( err ) |
|
253 { |
|
254 case KErrCorrupt: |
|
255 case KErrNoMemory: |
|
256 case KErrArgument: |
|
257 case KErrNotSupported: |
|
258 { |
|
259 PRINT_ERR( "GetHeaderInfoL is returned with error \n" ); |
|
260 User::Leave( err ); |
|
261 break; |
|
262 } |
|
263 case KErrUnderflow: |
|
264 { |
|
265 PRINT_ERR( "GetHeaderInfoL returnd with error KErrUnderflow\n" ); |
|
266 break; |
|
267 } |
|
268 default: |
|
269 { |
|
270 PRINT_ERR( "GetHeaderInfoL is returned with error \n" ); |
|
271 User::Leave( KErrGeneral ); |
|
272 } |
|
273 }; |
|
274 |
|
275 PRINT_EXIT; |
|
276 return NULL; |
|
277 } |
|
278 |
|
279 //--------------------------------------------------------------------------- |
|
280 //Returns a header from GetHeaderInformationL() back to the decoder so that |
|
281 //the memory can be freed. |
|
282 //--------------------------------------------------------------------------- |
|
283 // |
|
284 void CAriMpeg4aspdecHwDevice::ReturnHeader( TVideoPictureHeader* aHeader ) |
|
285 { |
|
286 PRINT_ENTRY; |
|
287 if ( !iState->IsInitialized() ) |
|
288 { |
|
289 if ( iVideoPictureHeader == aHeader ) |
|
290 { |
|
291 delete iVideoPictureHeader; |
|
292 iVideoPictureHeader = NULL; |
|
293 } |
|
294 else |
|
295 { |
|
296 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrArgument ); |
|
297 } |
|
298 } |
|
299 else |
|
300 { |
|
301 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
302 } |
|
303 PRINT_EXIT; |
|
304 } |
|
305 |
|
306 //--------------------------------------------------------------------------- |
|
307 //Sets the device input format to a compressed video format. |
|
308 //--------------------------------------------------------------------------- |
|
309 // |
|
310 void CAriMpeg4aspdecHwDevice::SetInputFormatL( |
|
311 const CCompressedVideoFormat& aFormat, |
|
312 TVideoDataUnitType aDataUnitType, |
|
313 TVideoDataUnitEncapsulation aEncapsulation, |
|
314 TBool aDataInOrder ) |
|
315 { |
|
316 PRINT_ENTRY; |
|
317 if ( !iState->IsInitialized() ) |
|
318 { |
|
319 if ( ( !aDataInOrder ) || |
|
320 ( aEncapsulation == EDuGenericPayload ) || |
|
321 ( aEncapsulation == EDuRtpPayload ) || |
|
322 ( aDataUnitType == EDuArbitraryStreamSection ) ) |
|
323 User::Leave( KErrNotSupported ); |
|
324 |
|
325 if ( ( aFormat.MimeType().FindF( KMPEG4SupportedMimeType ) != |
|
326 KErrNotFound ) || |
|
327 ( aFormat.MimeType().FindF( KH263SupportedMimeType ) != |
|
328 KErrNotFound ) || |
|
329 ( aFormat.MimeType().FindF( KH26398SupportedMimeType ) != |
|
330 KErrNotFound ) ) |
|
331 |
|
332 { |
|
333 iInputFormat = CCompressedVideoFormat::NewL( aFormat ); |
|
334 iDataUnitType = aDataUnitType; |
|
335 iEncapsulation = aEncapsulation; |
|
336 } |
|
337 else |
|
338 { |
|
339 PRINT_ERR( "aFormat is not supported \n" ); |
|
340 User::Leave( KErrNotSupported ); |
|
341 } |
|
342 } |
|
343 else |
|
344 { |
|
345 PRINT_ERR( "istate is not initialized yet\n" ); |
|
346 User::Leave( KErrNotReady ); |
|
347 } |
|
348 PRINT_EXIT; |
|
349 } |
|
350 |
|
351 //--------------------------------------------------------------------------- |
|
352 //Sets whether decoding should be synchronized to the current clock source, |
|
353 //if any, or if pictures should instead be decoded as soon as possible. |
|
354 //If decoding is synchronized, decoding timestamps are used if available, |
|
355 //presentation timestamps are used if not. When decoding is not synchronized, |
|
356 //pictures are decoded as soon as source data is available for them, and the |
|
357 //decoder has a free output buffer. If a clock source is not available, |
|
358 //decoding will not be synchronized. |
|
359 //--------------------------------------------------------------------------- |
|
360 // |
|
361 void CAriMpeg4aspdecHwDevice::SynchronizeDecoding( TBool /*aSynchronize*/ ) |
|
362 { |
|
363 PRINT_ENTRY; |
|
364 PRINT_EXIT; |
|
365 return; |
|
366 } |
|
367 |
|
368 |
|
369 //--------------------------------------------------------------------------- |
|
370 //Sets the Buffer Options as specified by the client. |
|
371 //--------------------------------------------------------------------------- |
|
372 // |
|
373 void CAriMpeg4aspdecHwDevice::SetBufferOptionsL( |
|
374 const CMMFDevVideoPlay::TBufferOptions& aOptions ) |
|
375 { |
|
376 PRINT_ENTRY; |
|
377 if ( !iState->IsInitialized() ) |
|
378 { |
|
379 TTimeIntervalMicroSeconds zerotime( 0 ); |
|
380 if ( ( aOptions.iMinNumInputBuffers < KMinInputBuffers ) || |
|
381 ( aOptions.iPreDecodeBufferSize != 0 ) || |
|
382 ( aOptions.iMaxPostDecodeBufferSize != 0 ) || |
|
383 ( aOptions.iPreDecoderBufferPeriod != zerotime ) || |
|
384 ( aOptions.iPostDecoderBufferPeriod != zerotime ) ) |
|
385 { |
|
386 User::Leave( KErrArgument ); |
|
387 } |
|
388 |
|
389 if ( ( aOptions.iMinNumInputBuffers > KMaxInputBuffers ) || |
|
390 ( aOptions.iMaxInputBufferSize > KMaxInputBufferSize ) ) |
|
391 { |
|
392 User::Leave( KErrNotSupported ); |
|
393 } |
|
394 |
|
395 iBufferOptions = aOptions; |
|
396 } |
|
397 else |
|
398 { |
|
399 PRINT_ERR( "istate is not initialized yet\n" ); |
|
400 User::Leave( KErrNotReady ); |
|
401 } |
|
402 |
|
403 PRINT_EXIT; |
|
404 } |
|
405 |
|
406 //--------------------------------------------------------------------------- |
|
407 //Gets the video decoder buffer options actually in use. |
|
408 //--------------------------------------------------------------------------- |
|
409 // |
|
410 void CAriMpeg4aspdecHwDevice::GetBufferOptions( |
|
411 CMMFDevVideoPlay::TBufferOptions& aOptions ) |
|
412 { |
|
413 PRINT_ENTRY; |
|
414 if ( !iState->IsInitialized() ) |
|
415 { |
|
416 aOptions = iBufferOptions; |
|
417 } |
|
418 else |
|
419 { |
|
420 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
421 } |
|
422 |
|
423 PRINT_EXIT; |
|
424 } |
|
425 |
|
426 //--------------------------------------------------------------------------- |
|
427 //Indicates which HRD/VBV specification is fulfilled in the input stream and |
|
428 //any related parameters. |
|
429 //--------------------------------------------------------------------------- |
|
430 // |
|
431 void CAriMpeg4aspdecHwDevice::SetHrdVbvSpec( |
|
432 THrdVbvSpecification /*aHrdVbvSpec*/, |
|
433 const TDesC8& /*aHrdVbvParams*/ ) |
|
434 { |
|
435 PRINT_ENTRY; |
|
436 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
437 PRINT_EXIT; |
|
438 } |
|
439 |
|
440 //--------------------------------------------------------------------------- |
|
441 //Sets the output post-processor device to use. |
|
442 //--------------------------------------------------------------------------- |
|
443 // |
|
444 void CAriMpeg4aspdecHwDevice::SetOutputDevice( |
|
445 CMMFVideoPostProcHwDevice* aDevice ) |
|
446 { |
|
447 PRINT_ENTRY; |
|
448 if ( !iState->IsInitialized() ) |
|
449 { |
|
450 if ( !aDevice ) |
|
451 { |
|
452 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrArgument ); |
|
453 } |
|
454 else |
|
455 { |
|
456 iOutputDevice = aDevice; |
|
457 |
|
458 // checks whether customBuffer supported by o/p device |
|
459 iCustomBufferHandle = |
|
460 ( MMmfVideoBufferManagement* )( iOutputDevice->CustomInterface( |
|
461 KMmfVideoBuffermanagementUid ) ); |
|
462 } |
|
463 } |
|
464 else |
|
465 { |
|
466 PRINT_ERR( "istate is not initialized yet, " |
|
467 "calling MdvppFatalError on iMMFDevVideoPlayProxy\n" ); |
|
468 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
469 } |
|
470 |
|
471 PRINT_EXIT; |
|
472 } |
|
473 |
|
474 //--------------------------------------------------------------------------- |
|
475 //Returns the current decoding position, i.e. |
|
476 //the timestamp for the most recently decoded picture. |
|
477 //--------------------------------------------------------------------------- |
|
478 // |
|
479 TTimeIntervalMicroSeconds CAriMpeg4aspdecHwDevice::DecodingPosition() |
|
480 { |
|
481 PRINT_ENTRY; |
|
482 if ( iState->IsInitialized() ) |
|
483 { |
|
484 PRINT_EXIT; |
|
485 return iDecodingPosition; |
|
486 } |
|
487 else |
|
488 { |
|
489 PRINT_ERR( "iState is not initialised, calling MdvppFatalError\n" ); |
|
490 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
491 PRINT_EXIT; |
|
492 return ( TTimeIntervalMicroSeconds( 0 ) ); |
|
493 } |
|
494 } |
|
495 |
|
496 //--------------------------------------------------------------------------- |
|
497 //Returns the current pre-decoder buffer size. |
|
498 //--------------------------------------------------------------------------- |
|
499 // |
|
500 TUint CAriMpeg4aspdecHwDevice::PreDecoderBufferBytes() |
|
501 { |
|
502 PRINT_ENTRY; |
|
503 if ( !( iState->IsInitialized() ) ) |
|
504 { |
|
505 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
506 PRINT_EXIT; |
|
507 return ( 0 ); |
|
508 } |
|
509 |
|
510 PRINT_EXIT; |
|
511 return 0; |
|
512 } |
|
513 |
|
514 //--------------------------------------------------------------------------- |
|
515 //Reads various counters related to the received input bitstream |
|
516 //and coded data units. |
|
517 //--------------------------------------------------------------------------- |
|
518 // |
|
519 void CAriMpeg4aspdecHwDevice::GetBitstreamCounters( |
|
520 CMMFDevVideoPlay::TBitstreamCounters& aCounters ) |
|
521 { |
|
522 PRINT_ENTRY; |
|
523 if ( iState->IsInitialized() ) |
|
524 { |
|
525 aCounters = iBitstreamCounters; |
|
526 //Reset the counters to Zero |
|
527 iBitstreamCounters.iLostPackets = 0; |
|
528 iBitstreamCounters.iTotalPackets = 0; |
|
529 } |
|
530 else |
|
531 { |
|
532 PRINT_ERR( "iState is not initialised, calling MdvppFatalError\n" ); |
|
533 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
534 } |
|
535 PRINT_EXIT; |
|
536 } |
|
537 |
|
538 //--------------------------------------------------------------------------- |
|
539 //Retrieves the number of free input buffers the decoder has available |
|
540 //--------------------------------------------------------------------------- |
|
541 // |
|
542 TUint CAriMpeg4aspdecHwDevice::NumFreeBuffers() |
|
543 { |
|
544 PRINT_ENTRY; |
|
545 if ( iState->IsInitialized() ) |
|
546 { |
|
547 if ( iNumberOfInputBuffersAllocated == 0 ) |
|
548 { |
|
549 PRINT_EXIT; |
|
550 return ( iBufferOptions.iMinNumInputBuffers ); |
|
551 } |
|
552 else |
|
553 { |
|
554 PRINT_EXIT; |
|
555 return ( iInputFreeBufferQueue.Count() ); |
|
556 } |
|
557 } |
|
558 else |
|
559 { |
|
560 PRINT_ERR( "iState is not initialised, calling MdvppFatalError\n" ); |
|
561 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
562 PRINT_EXIT; |
|
563 return( KErrNone ); |
|
564 } |
|
565 } |
|
566 |
|
567 //--------------------------------------------------------------------------- |
|
568 //Returns an input buffer of size aBufferSize. If no buffer is available |
|
569 //then NULL is returned. |
|
570 //--------------------------------------------------------------------------- |
|
571 // |
|
572 TVideoInputBuffer* CAriMpeg4aspdecHwDevice::GetBufferL( TUint aBufferSize ) |
|
573 { |
|
574 PRINT_ENTRY; |
|
575 if ( !( iState->IsInitialized() ) ) |
|
576 { |
|
577 PRINT_ERR( "istate is not initialized yet\n" ); |
|
578 User::Leave( KErrNotReady ); |
|
579 } |
|
580 |
|
581 if ( iState->IsInputEndPending() ) |
|
582 { |
|
583 PRINT_ERR( "input is pending\n" ); |
|
584 User::Leave( KErrNotReady ); |
|
585 } |
|
586 |
|
587 if ( aBufferSize > iBufferOptions.iMaxInputBufferSize ) |
|
588 { |
|
589 PRINT_ERR( "aBufferSize is more than the allowed size\n" ); |
|
590 PRINT_MSG( LEVEL_HIGH, ( "reqBufSize = %d, maxAllowedBufSize = %d", |
|
591 aBufferSize, iBufferOptions.iMaxInputBufferSize ) ); |
|
592 User::Leave( KErrArgument ); |
|
593 } |
|
594 |
|
595 TVideoInputBuffer *inBuffer = NULL; |
|
596 |
|
597 if ( iNumberOfInputBuffersAllocated == |
|
598 iBufferOptions.iMinNumInputBuffers ) |
|
599 { |
|
600 if ( iInputFreeBufferQueue.Count() ) |
|
601 { |
|
602 // Reallocate the input buffer if needed |
|
603 PRINT_MSG( LEVEL_HIGH, ( "Reallocate input buffer if needed" ) ); |
|
604 CreateInputBufferL( aBufferSize, ETrue ); |
|
605 inBuffer = iInputFreeBufferQueue[0]; |
|
606 iInputFreeBufferQueue.Remove( 0 ); |
|
607 } |
|
608 else |
|
609 { |
|
610 PRINT_ERR( "No input free buffers available \n" ); |
|
611 return NULL; |
|
612 } |
|
613 } |
|
614 else if ( iNumberOfInputBuffersAllocated < |
|
615 iBufferOptions.iMinNumInputBuffers ) |
|
616 { |
|
617 // Allocate new buffer of the requested size |
|
618 //PRINT_ERR( "CreateInputBufferL returned EFALSE\n" ); |
|
619 CreateInputBufferL( aBufferSize, EFalse ); |
|
620 |
|
621 // remove the last created buffer |
|
622 inBuffer = iInputFreeBufferQueue[ iInputFreeBufferQueue.Count() - 1]; |
|
623 |
|
624 iInputFreeBufferQueue.Remove( iInputFreeBufferQueue.Count() - 1 ); |
|
625 } |
|
626 else |
|
627 { |
|
628 PRINT_ERR( "iNumberOfInputBuffersAllocated is less " |
|
629 " iBufferOptions.iMinNumInputBuffers\n" ); |
|
630 User::Leave( KErrGeneral ); |
|
631 } |
|
632 |
|
633 PRINT_EXIT; |
|
634 return inBuffer; |
|
635 } |
|
636 |
|
637 //--------------------------------------------------------------------------- |
|
638 //Called by DevVideoPlay to write the coded data. |
|
639 //Writes a piece of coded video data to the decoder. The data buffer must |
|
640 //be retrieved from the decoder with GetBufferL().. |
|
641 //--------------------------------------------------------------------------- |
|
642 // |
|
643 void CAriMpeg4aspdecHwDevice::WriteCodedDataL( TVideoInputBuffer* aBuffer ) |
|
644 { |
|
645 PRINT_ENTRY; |
|
646 if ( !iState->IsInitialized() ) |
|
647 { |
|
648 PRINT_ERR( "istate is not initialized yet \n" ); |
|
649 User::Leave( KErrNotReady ); |
|
650 } |
|
651 |
|
652 if ( !aBuffer ) |
|
653 { |
|
654 PRINT_ERR( "aBuffer is null \n" ); |
|
655 User::Leave( KErrArgument ); |
|
656 } |
|
657 |
|
658 if ( aBuffer->iData.Length() == 0 ) |
|
659 { |
|
660 PRINT_ERR( "length of aBuffer is zero \n" ); |
|
661 User::Leave( KErrArgument ); |
|
662 } |
|
663 |
|
664 if ( iState->IsInputEndPending() ) |
|
665 { |
|
666 PRINT_ERR( "IsInputEndPending is true \n" ); |
|
667 User::Leave( KErrEof ); |
|
668 } |
|
669 |
|
670 if ( ( iDataUnitType == EDuSeveralSegments ) || |
|
671 ( iDataUnitType == EDuVideoSegment ) ) |
|
672 { |
|
673 iBitstreamCounters.iTotalPackets++; |
|
674 } |
|
675 |
|
676 // if custom interface is supported by o/p device get all the buffers |
|
677 // and add it to Engine |
|
678 if ( !iOutputBuffersCreated ) |
|
679 { |
|
680 // Set Stream information |
|
681 if ( !iDecoderConfigured ) |
|
682 { |
|
683 iCodec->ConfigDecoderL( &( aBuffer->iData ) ); |
|
684 // set input & output formats to Codec |
|
685 iCodec->SetFormatsL( iDataUnitType, iOutputFormat ); |
|
686 iDecoderConfigured = ETrue; |
|
687 } |
|
688 |
|
689 if ( !iCustomBufferHandle ) |
|
690 { |
|
691 // Get o/p buffer length for creation |
|
692 iOutputBufferSize = iCodec->GetOutputBufferLength(); |
|
693 CreateOutputBuffersL(); |
|
694 } |
|
695 iOutputBuffersCreated = ETrue; |
|
696 } |
|
697 |
|
698 // add all the o/p buffers to engine |
|
699 if ( !iBufferAdded ) |
|
700 { |
|
701 if ( iCustomBufferHandle ) |
|
702 { |
|
703 TVideoPicture* videoPicture = NULL; |
|
704 for ( TInt i = 0; |
|
705 i < TInt( iCustomBufferOptions->iNumInputBuffers ); |
|
706 i++ ) |
|
707 { |
|
708 videoPicture = iCustomBufferHandle->MmvbmGetBufferL( |
|
709 iCustomBufferOptions->iBufferSize ); |
|
710 if ( videoPicture ) |
|
711 { |
|
712 TRAPD( lErr, videoPicture->iHeader = |
|
713 new ( ELeave ) TVideoPictureHeader ) ; |
|
714 if ( lErr != KErrNone ) |
|
715 { |
|
716 iCustomBufferHandle->MmvbmReleaseBuffer( |
|
717 videoPicture ); |
|
718 iMMFDevVideoPlayProxy->MdvppFatalError( this, |
|
719 KErrArgument ); |
|
720 } |
|
721 else |
|
722 { |
|
723 iEngine->AddOutput( videoPicture ); |
|
724 } |
|
725 } |
|
726 else |
|
727 { |
|
728 break; |
|
729 } |
|
730 } |
|
731 } |
|
732 else |
|
733 { |
|
734 for ( TInt i = 0; i < iOutputFreeBufferQueue.Count(); i++ ) |
|
735 { |
|
736 iEngine->AddOutput( iOutputFreeBufferQueue[0] ); |
|
737 iOutputFreeBufferQueue.Remove( 0 ); |
|
738 } |
|
739 } |
|
740 iBufferAdded = ETrue; |
|
741 } |
|
742 |
|
743 iPictureCounters.iTotalPictures++; |
|
744 iFilledBufferCounter++; |
|
745 TInt err = iEngine->AddInput( aBuffer ); |
|
746 PRINT_MSG( LEVEL_LOW, ( "WriteCodedDataL, addinput err = %d", err ) ); |
|
747 PRINT_EXIT; |
|
748 } |
|
749 |
|
750 |
|
751 #ifdef SYMBIAN_MDF_API_V2 |
|
752 //--------------------------------------------------------------------------- |
|
753 //Configures the Mpeg4/H263 decoder by passing the required header |
|
754 //information for the stream that is getting decoded. The header |
|
755 //structurespecific to the Decoder is passed as iOptional member. |
|
756 //--------------------------------------------------------------------------- |
|
757 // |
|
758 void CAriMpeg4aspdecHwDevice::ConfigureDecoderL( |
|
759 const TVideoPictureHeader& aVideoPictureHeader ) |
|
760 { |
|
761 PRINT_ENTRY; |
|
762 if ( iState->IsInitialized() ) |
|
763 { |
|
764 PRINT_ERR( "iState is already initialised \n" ); |
|
765 User::Leave( KErrNotReady ); |
|
766 } |
|
767 |
|
768 TInt level = aVideoPictureHeader.iLevel; |
|
769 PRINT_MSG( LEVEL_LOW, ( "ConfigureDecoderL,level = %d \n", level ) ); |
|
770 if ( aVideoPictureHeader.iOptional ) |
|
771 { |
|
772 // Mpeg-4 |
|
773 switch ( level ) |
|
774 { |
|
775 case 0: |
|
776 case KMP4Level11: //level 0b |
|
777 case KMP4Level1: |
|
778 case KMP4Level2: |
|
779 case KMP4Level3: |
|
780 case KMP4Level4: |
|
781 case KMP4Level5: |
|
782 case -1: |
|
783 break; |
|
784 default: |
|
785 { |
|
786 PRINT_ERR( "level is not supported \n" ); |
|
787 User::Leave( KErrNotSupported ); |
|
788 } |
|
789 } |
|
790 } |
|
791 else |
|
792 { |
|
793 // H.263 |
|
794 switch ( level ) |
|
795 { |
|
796 case KH263Level10: |
|
797 case KH263Level20: |
|
798 case KH263Level30: |
|
799 case KH263Level45: |
|
800 case -1: |
|
801 break; |
|
802 default: |
|
803 { |
|
804 PRINT_ERR( "level is not supported \n" ); |
|
805 User::Leave( KErrNotSupported ); |
|
806 } |
|
807 } |
|
808 } |
|
809 |
|
810 // Create Codec and configure the decoder |
|
811 iCodec = CAriMpeg4aspdecWrapper::NewL( this ); |
|
812 |
|
813 // configure the decoder in case of mpeg-4 otherwise ie in |
|
814 // case of h.263 wait till the first call of WriteCodedDataL() |
|
815 if ( aVideoPictureHeader.iOptional ) |
|
816 { |
|
817 iCodec->ConfigDecoderL( aVideoPictureHeader.iOptional ); |
|
818 iDecoderConfigured = ETrue; |
|
819 } |
|
820 iConfigureDecoderCalled = ETrue; |
|
821 |
|
822 PRINT_EXIT; |
|
823 } |
|
824 #endif |
|
825 |
|
826 //--------------------------------------------------------------------------- |
|
827 //Retrieves post-processing information about this hardware device. |
|
828 //The device creates a CPostProcessorInfo structure, fills it with correct |
|
829 //data, pushes it to the cleanup stack and returns it. The client will |
|
830 //delete the object when it is no longer needed. |
|
831 //--------------------------------------------------------------------------- |
|
832 // |
|
833 CPostProcessorInfo* CAriMpeg4aspdecHwDevice::PostProcessorInfoLC() |
|
834 { |
|
835 PRINT_ENTRY; |
|
836 //Aricent decoder does not support any post processing functionality |
|
837 RArray<TUncompressedVideoFormat> supportedFormats; |
|
838 CleanupClosePushL( supportedFormats ); |
|
839 |
|
840 RArray<TUint32> supportedCombinations; |
|
841 CleanupClosePushL( supportedCombinations ); |
|
842 |
|
843 TYuvToRgbCapabilities yuvToRgbCapabilities; |
|
844 RArray<TScaleFactor> supportedScaleFactors; |
|
845 CleanupClosePushL( supportedScaleFactors ); |
|
846 |
|
847 yuvToRgbCapabilities.iSamplingPatterns = 0; |
|
848 yuvToRgbCapabilities.iCoefficients = 0; |
|
849 yuvToRgbCapabilities.iRgbFormats = 0; |
|
850 yuvToRgbCapabilities.iLightnessControl = EFalse; |
|
851 yuvToRgbCapabilities.iSaturationControl = EFalse; |
|
852 yuvToRgbCapabilities.iContrastControl = EFalse; |
|
853 yuvToRgbCapabilities.iGammaCorrection = EFalse; |
|
854 yuvToRgbCapabilities.iDitherTypes = 0; |
|
855 |
|
856 |
|
857 CPostProcessorInfo* info = CPostProcessorInfo::NewL( |
|
858 KUidMp4H263DecoderHwDevice, |
|
859 KManufacturer, |
|
860 KIdentifier, |
|
861 TVersion( 1, 0, 0 ), |
|
862 supportedFormats.Array(), |
|
863 supportedCombinations.Array(), |
|
864 //Accelerated or not |
|
865 EFalse, |
|
866 //supports DSA |
|
867 EFalse, |
|
868 yuvToRgbCapabilities, |
|
869 //supported rotations |
|
870 ERotateNone, |
|
871 //supports Arbitrary scaling |
|
872 EFalse, |
|
873 supportedScaleFactors.Array(), |
|
874 //supports antialiased scaling |
|
875 EFalse ); |
|
876 |
|
877 CleanupStack::PushL( info ); |
|
878 CleanupStack::Pop( &supportedScaleFactors ); |
|
879 supportedScaleFactors.Close(); |
|
880 CleanupStack::Pop( &supportedCombinations ); |
|
881 supportedCombinations.Close(); |
|
882 CleanupStack::Pop( &supportedFormats ); |
|
883 supportedFormats.Close(); |
|
884 |
|
885 PRINT_EXIT; |
|
886 return info; |
|
887 } |
|
888 |
|
889 //--------------------------------------------------------------------------- |
|
890 //Retrieves the list of the output formats that the device supports. |
|
891 //The list can depend on the device source format, and therefore |
|
892 //SetSourceFormatL() must be called before calling this method. |
|
893 //--------------------------------------------------------------------------- |
|
894 // |
|
895 void CAriMpeg4aspdecHwDevice::GetOutputFormatListL( |
|
896 RArray<TUncompressedVideoFormat>& aFormats ) |
|
897 { |
|
898 PRINT_ENTRY; |
|
899 if ( iState->IsInitialized() ) |
|
900 { |
|
901 PRINT_ERR( "iState is already initialised \n" ); |
|
902 User::Leave( KErrNotReady ); |
|
903 } |
|
904 |
|
905 if ( !iInputFormat ) |
|
906 { |
|
907 //Input format should be set before calling this function, as output |
|
908 // format is decided based on input format |
|
909 PRINT_ERR( "iInputFormat is not set yet \n" ); |
|
910 User::Leave( KErrNotReady ); |
|
911 } |
|
912 |
|
913 TUncompressedVideoFormat format; |
|
914 format.iDataFormat = EYuvRawData; |
|
915 format.iYuvFormat.iYuv2RgbMatrix = NULL; |
|
916 format.iYuvFormat.iRgb2YuvMatrix = NULL; |
|
917 format.iYuvFormat.iAspectRatioNum = 1; |
|
918 format.iYuvFormat.iAspectRatioDenom = 1; |
|
919 |
|
920 aFormats.Reset(); |
|
921 |
|
922 //The following formats are supported by both H.263 and Mpeg-4 |
|
923 |
|
924 //YUV 420 Chroma0 Planar |
|
925 format.iYuvFormat.iCoefficients = EYuvBt601Range0; |
|
926 format.iYuvFormat.iPattern = EYuv420Chroma1; |
|
927 format.iYuvFormat.iDataLayout = EYuvDataPlanar; |
|
928 aFormats.Append( format ); |
|
929 |
|
930 //YUV 422 Chroma LE Interleaved |
|
931 format.iYuvFormat.iPattern = EYuv422Chroma1; |
|
932 format.iYuvFormat.iDataLayout = EYuvDataInterleavedLE; |
|
933 aFormats.Append( format ); |
|
934 |
|
935 //YUV 422 Chroma BE Interleaved |
|
936 format.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; |
|
937 aFormats.Append( format ); |
|
938 |
|
939 //The following formats are only supported by Mpeg-4 |
|
940 if ( iInputFormat->MimeType().FindF( KMPEG4SupportedMimeType ) != |
|
941 KErrNotFound ) |
|
942 { |
|
943 //BT 601.5 Full Range |
|
944 // YUV 420 Chroma0 Planar |
|
945 format.iYuvFormat.iCoefficients = EYuvBt601Range1; |
|
946 format.iYuvFormat.iPattern = EYuv420Chroma1; |
|
947 format.iYuvFormat.iDataLayout = EYuvDataPlanar; |
|
948 aFormats.Append( format ); |
|
949 |
|
950 //YUV 422 Chroma LE Interleaved |
|
951 format.iYuvFormat.iPattern = EYuv422Chroma1; |
|
952 format.iYuvFormat.iDataLayout = EYuvDataInterleavedLE; |
|
953 aFormats.Append( format ); |
|
954 |
|
955 //YUV 422 Chroma BE Interleaved |
|
956 format.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; |
|
957 aFormats.Append( format ); |
|
958 |
|
959 //BT 709 Reduced Range |
|
960 // YUV 420 Chroma0 Planar |
|
961 format.iYuvFormat.iCoefficients = EYuvBt709Range0; |
|
962 format.iYuvFormat.iPattern = EYuv420Chroma1; |
|
963 format.iYuvFormat.iDataLayout = EYuvDataPlanar; |
|
964 aFormats.Append( format ); |
|
965 |
|
966 //YUV 422 Chroma LE Interleaved |
|
967 format.iYuvFormat.iPattern = EYuv422Chroma1; |
|
968 format.iYuvFormat.iDataLayout = EYuvDataInterleavedLE; |
|
969 aFormats.Append( format ); |
|
970 |
|
971 //YUV 422 Chroma BE Interleaved |
|
972 format.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; |
|
973 aFormats.Append( format ); |
|
974 |
|
975 //BT 709 Full Range |
|
976 // YUV 420 Chroma0 Planar |
|
977 format.iYuvFormat.iCoefficients = EYuvBt709Range1; |
|
978 format.iYuvFormat.iPattern = EYuv420Chroma1; |
|
979 format.iYuvFormat.iDataLayout = EYuvDataPlanar; |
|
980 aFormats.Append( format ); |
|
981 |
|
982 //YUV 422 Chroma LE Interleaved |
|
983 format.iYuvFormat.iPattern = EYuv422Chroma1; |
|
984 format.iYuvFormat.iDataLayout = EYuvDataInterleavedLE; |
|
985 aFormats.Append( format ); |
|
986 |
|
987 //YUV 422 Chroma BE Interleaved |
|
988 format.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; |
|
989 aFormats.Append( format ); |
|
990 } |
|
991 PRINT_EXIT; |
|
992 } |
|
993 |
|
994 //--------------------------------------------------------------------------- |
|
995 // Sets the device output format. |
|
996 //--------------------------------------------------------------------------- |
|
997 // |
|
998 void CAriMpeg4aspdecHwDevice::SetOutputFormatL( |
|
999 const TUncompressedVideoFormat &aFormat ) |
|
1000 { |
|
1001 PRINT_ENTRY; |
|
1002 if ( iState->IsInitialized() ) |
|
1003 { |
|
1004 PRINT_ERR( "istate is already initialised \n" ); |
|
1005 User::Leave( KErrNotReady ); |
|
1006 } |
|
1007 |
|
1008 if ( !iInputFormat ) |
|
1009 { |
|
1010 //Input format should be set before calling this function, as output |
|
1011 // format is decided based on input format |
|
1012 PRINT_ERR( "iInputFormat is not set yet \n" ); |
|
1013 User::Leave( KErrNotReady ); |
|
1014 } |
|
1015 |
|
1016 // check whether output format is supported or not.if not supported leave |
|
1017 RArray<TUncompressedVideoFormat> formats; |
|
1018 CleanupClosePushL( formats ); |
|
1019 GetOutputFormatListL( formats ); |
|
1020 |
|
1021 TBool flag = EFalse; |
|
1022 |
|
1023 for ( TInt i = 0; i < formats.Count(); i++ ) |
|
1024 { |
|
1025 if ( aFormat == formats[i] ) |
|
1026 { |
|
1027 flag = ETrue; |
|
1028 break; |
|
1029 } |
|
1030 } |
|
1031 CleanupStack::Pop ( &formats ); |
|
1032 formats.Close(); |
|
1033 |
|
1034 if ( !flag ) |
|
1035 { |
|
1036 PRINT_ERR( "outputformat is not supported \n" ); |
|
1037 User::Leave( KErrNotSupported ); |
|
1038 } |
|
1039 |
|
1040 iOutputFormat = aFormat; |
|
1041 PRINT_EXIT; |
|
1042 } |
|
1043 |
|
1044 //--------------------------------------------------------------------------- |
|
1045 // Sets the clock source to use for video timing. |
|
1046 //--------------------------------------------------------------------------- |
|
1047 // |
|
1048 void CAriMpeg4aspdecHwDevice::SetClockSource( MMMFClockSource* /*aClock*/ ) |
|
1049 { |
|
1050 PRINT_ENTRY; |
|
1051 if ( iState->IsInitialized() ) |
|
1052 { |
|
1053 PRINT_ERR( "iState is initialised,calling MdvppFatalError \n" ); |
|
1054 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1055 } |
|
1056 |
|
1057 PRINT_EXIT; |
|
1058 return; |
|
1059 } |
|
1060 |
|
1061 //--------------------------------------------------------------------------- |
|
1062 // Sets the device video output destination. |
|
1063 //--------------------------------------------------------------------------- |
|
1064 // |
|
1065 void CAriMpeg4aspdecHwDevice::SetVideoDestScreenL( TBool aScreen ) |
|
1066 { |
|
1067 PRINT_ENTRY; |
|
1068 if ( !iState->IsInitialized() ) |
|
1069 { |
|
1070 if ( aScreen ) |
|
1071 { |
|
1072 PRINT_ERR( "KErrNotSupported \n" ); |
|
1073 User::Leave( KErrNotSupported ); |
|
1074 } |
|
1075 } |
|
1076 else |
|
1077 { |
|
1078 PRINT_ERR( "KErrNotSupported \n" ); |
|
1079 User::Leave( KErrNotReady ); |
|
1080 } |
|
1081 PRINT_EXIT; |
|
1082 } |
|
1083 |
|
1084 //--------------------------------------------------------------------------- |
|
1085 // Sets the post-processing types to be used. |
|
1086 //--------------------------------------------------------------------------- |
|
1087 // |
|
1088 void CAriMpeg4aspdecHwDevice::SetPostProcessTypesL( |
|
1089 TUint32 /*aPostProcCombination*/ ) |
|
1090 { |
|
1091 PRINT_ENTRY; |
|
1092 PRINT_ERR( "KErrNotSupported API\n" ); |
|
1093 PRINT_EXIT; |
|
1094 User::Leave( KErrNotSupported ); |
|
1095 } |
|
1096 |
|
1097 //--------------------------------------------------------------------------- |
|
1098 // Sets post-processing options for input (pan-scan ) cropping. |
|
1099 //--------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CAriMpeg4aspdecHwDevice::SetInputCropOptionsL( const TRect& /*aRect*/ ) |
|
1102 { |
|
1103 PRINT_ENTRY; |
|
1104 PRINT_ERR( "KErrNotSupported API\n" ); |
|
1105 PRINT_EXIT; |
|
1106 User::Leave( KErrNotSupported ); |
|
1107 } |
|
1108 |
|
1109 //--------------------------------------------------------------------------- |
|
1110 // Sets post-processing options for YUV to RGB color space conversion |
|
1111 //--------------------------------------------------------------------------- |
|
1112 // |
|
1113 void CAriMpeg4aspdecHwDevice::SetYuvToRgbOptionsL( |
|
1114 const TYuvToRgbOptions& /*aOptions*/, |
|
1115 const TYuvFormat& /*aYuvFormat*/, |
|
1116 TRgbFormat /*aRgbFormat*/ ) |
|
1117 { |
|
1118 PRINT_ENTRY; |
|
1119 PRINT_ERR( "KErrNotSupported API\n" ); |
|
1120 PRINT_EXIT; |
|
1121 User::Leave( KErrNotSupported ); |
|
1122 } |
|
1123 |
|
1124 //--------------------------------------------------------------------------- |
|
1125 // Sets post-processing options for YUV to RGB color space conversion. Uses |
|
1126 //the device input and output formats. |
|
1127 //--------------------------------------------------------------------------- |
|
1128 // |
|
1129 void CAriMpeg4aspdecHwDevice::SetYuvToRgbOptionsL( |
|
1130 const TYuvToRgbOptions& /*aOptions*/ ) |
|
1131 { |
|
1132 PRINT_ENTRY; |
|
1133 PRINT_ERR( "KErrNotSupported API\n" ); |
|
1134 PRINT_EXIT; |
|
1135 User::Leave( KErrNotSupported ); |
|
1136 } |
|
1137 |
|
1138 //--------------------------------------------------------------------------- |
|
1139 // Sets post-processing options for rotation. SetPostProcessTypesL() must be |
|
1140 //called before this method is used. |
|
1141 //--------------------------------------------------------------------------- |
|
1142 // |
|
1143 void CAriMpeg4aspdecHwDevice::SetRotateOptionsL( |
|
1144 TRotationType /*aRotationType*/ ) |
|
1145 { |
|
1146 PRINT_ENTRY; |
|
1147 PRINT_ERR( "KErrNotSupported API\n" ); |
|
1148 PRINT_EXIT; |
|
1149 User::Leave( KErrNotSupported ); |
|
1150 } |
|
1151 |
|
1152 //--------------------------------------------------------------------------- |
|
1153 //Sets post-processing options for scaling. SetPostProcessTypesL() must be |
|
1154 //called before this method is used. |
|
1155 //--------------------------------------------------------------------------- |
|
1156 // |
|
1157 void CAriMpeg4aspdecHwDevice::SetScaleOptionsL( const TSize& /*aTargetSize*/, |
|
1158 TBool /*aAntiAliasFiltering*/ ) |
|
1159 { |
|
1160 PRINT_ENTRY; |
|
1161 PRINT_ERR( "KErrNotSupported API\n" ); |
|
1162 PRINT_EXIT; |
|
1163 User::Leave( KErrNotSupported ); |
|
1164 } |
|
1165 |
|
1166 //--------------------------------------------------------------------------- |
|
1167 //Sets post-processing options for output cropping. |
|
1168 //--------------------------------------------------------------------------- |
|
1169 // |
|
1170 void CAriMpeg4aspdecHwDevice::SetOutputCropOptionsL( const TRect& /*aRect*/ ) |
|
1171 { |
|
1172 PRINT_ENTRY; |
|
1173 PRINT_ERR( "KErrNotSupported API\n" ); |
|
1174 PRINT_EXIT; |
|
1175 User::Leave( KErrNotSupported ); |
|
1176 } |
|
1177 |
|
1178 //--------------------------------------------------------------------------- |
|
1179 //Sets post-processing plug-in specific options. |
|
1180 //--------------------------------------------------------------------------- |
|
1181 // |
|
1182 void CAriMpeg4aspdecHwDevice::SetPostProcSpecificOptionsL( |
|
1183 const TDesC8& /*aOptions*/ ) |
|
1184 { |
|
1185 PRINT_ENTRY; |
|
1186 PRINT_ERR( "KErrNotSupported API\n" ); |
|
1187 PRINT_EXIT; |
|
1188 User::Leave( KErrNotSupported ); |
|
1189 } |
|
1190 |
|
1191 //--------------------------------------------------------------------------- |
|
1192 //Initializes the device. This method is asynchronous, the device calls |
|
1193 //MdvppInitializeComplete() of MMFVideoPlayProxy after initialization has |
|
1194 //completed. After this method has successfully completed, further |
|
1195 //configuration changes are not possible except where separately noted. |
|
1196 //--------------------------------------------------------------------------- |
|
1197 // |
|
1198 void CAriMpeg4aspdecHwDevice::Initialize() |
|
1199 { |
|
1200 PRINT_ENTRY; |
|
1201 if ( !iState->IsTransitionValid( CStateMachine::EInitializeCommand ) ) |
|
1202 { |
|
1203 PRINT_ERR( "state is not valid in statemachine \n" ); |
|
1204 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, KErrNotReady ); |
|
1205 return; |
|
1206 } |
|
1207 |
|
1208 TRAPD( err, iInputFreeBuffers = |
|
1209 new ( ELeave ) TVideoInputBuffer[iBufferOptions.iMinNumInputBuffers] ); |
|
1210 if ( err ) |
|
1211 { |
|
1212 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err ); |
|
1213 PRINT_ERR( "creation of iInputFreeBuffers returned error\n" ); |
|
1214 return; |
|
1215 } |
|
1216 |
|
1217 iPictureCounters.iPicturesDisplayed = 0; |
|
1218 iPictureCounters.iPicturesSkipped = 0; |
|
1219 iPictureCounters.iTotalPictures = 0; |
|
1220 iPictureCounters.iPicturesDecoded = 0; |
|
1221 |
|
1222 iBitstreamCounters.iLostPackets = 0; |
|
1223 iBitstreamCounters.iTotalPackets = 0; |
|
1224 |
|
1225 // if custom interface is supported then enable the interface |
|
1226 if ( iCustomBufferHandle ) |
|
1227 { |
|
1228 |
|
1229 TRAP( err, iCustomBufferOptions = |
|
1230 new ( ELeave ) MMmfVideoBufferManagement::TBufferOptions ); |
|
1231 |
|
1232 if ( err != KErrNone ) |
|
1233 { |
|
1234 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err ); |
|
1235 PRINT_ERR( "creation of iCustomBuffeOptions returned error \n" ); |
|
1236 return; |
|
1237 } |
|
1238 |
|
1239 iCustomBufferOptions->iNumInputBuffers = KMaxOutputBuffers + 1; |
|
1240 iCustomBufferOptions->iBufferSize = TSize( KMaxFrameWidth, |
|
1241 KMaxFrameHeight ); |
|
1242 |
|
1243 iCustomBufferHandle->MmvbmSetObserver( |
|
1244 ( MMmfVideoBufferManagementObserver * )this ); |
|
1245 |
|
1246 iCustomBufferHandle->MmvbmEnable( ETrue ); |
|
1247 |
|
1248 TRAP( err, |
|
1249 iCustomBufferHandle->MmvbmSetBufferOptionsL( |
|
1250 *iCustomBufferOptions ) ); |
|
1251 |
|
1252 if ( err != KErrNone ) |
|
1253 { |
|
1254 PRINT_ERR( "iCustomBufferHandle->MmvbmSetBufferOptionsL \n" ); |
|
1255 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err ); |
|
1256 return; |
|
1257 } |
|
1258 } |
|
1259 |
|
1260 if ( !iConfigureDecoderCalled ) |
|
1261 { |
|
1262 TRAP( err, iCodec = CAriMpeg4aspdecWrapper::NewL( this ) ); |
|
1263 if ( err != KErrNone ) |
|
1264 { |
|
1265 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err ); |
|
1266 PRINT_ERR( "CCodecInterface::NewL returned error \n" ); |
|
1267 return; |
|
1268 } |
|
1269 } |
|
1270 |
|
1271 // Engine Creation |
|
1272 TRAP( err, iEngine = CBaseEngine::NewL( |
|
1273 this, ( MBaseCodec* )iCodec, EFalse ) ); |
|
1274 if ( err != KErrNone ) |
|
1275 { |
|
1276 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err ); |
|
1277 PRINT_ERR( "CBaseEngine::NewL returned error \n" ); |
|
1278 return; |
|
1279 } |
|
1280 |
|
1281 // set input & output formats to Codec |
|
1282 if ( iConfigureDecoderCalled ) |
|
1283 { |
|
1284 TRAP( err, iCodec->SetFormatsL( iDataUnitType, iOutputFormat ) ); |
|
1285 if ( err != KErrNone ) |
|
1286 { |
|
1287 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err ); |
|
1288 PRINT_ERR( "iCodec->SetFormatsL returned error \n" ); |
|
1289 return; |
|
1290 } |
|
1291 } |
|
1292 |
|
1293 err = iState->Transit( CStateMachine::EInitializeCommand ); |
|
1294 if ( err ) |
|
1295 { |
|
1296 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, err ); |
|
1297 PRINT_ERR( "state is not set to initialised \n" ); |
|
1298 return; |
|
1299 } |
|
1300 |
|
1301 iMMFDevVideoPlayProxy->MdvppInitializeComplete( this, KErrNone ); |
|
1302 |
|
1303 PRINT_EXIT; |
|
1304 } |
|
1305 |
|
1306 //--------------------------------------------------------------------------- |
|
1307 //Commit all changes since the last CommitL(), Revert() or Initialize() |
|
1308 //to the hardware device. This only applies to methods which can be called |
|
1309 //both before AND after DevVideoPlay has been initialized. |
|
1310 //--------------------------------------------------------------------------- |
|
1311 // |
|
1312 void CAriMpeg4aspdecHwDevice::CommitL() |
|
1313 { |
|
1314 PRINT_ENTRY; |
|
1315 if ( !( iState->IsInitialized() ) ) |
|
1316 { |
|
1317 PRINT_ERR( "istate is not initialised yet \n" ); |
|
1318 User::Leave( KErrNotReady ); |
|
1319 } |
|
1320 PRINT_EXIT; |
|
1321 return; |
|
1322 } |
|
1323 |
|
1324 //--------------------------------------------------------------------------- |
|
1325 //Revert all changes since the last CommitL(), Revert() or Initialize() back |
|
1326 //to their previous settings. This only applies to methods which can be |
|
1327 //called both before AND after DevVideoPlay has been initialized.. |
|
1328 //--------------------------------------------------------------------------- |
|
1329 // |
|
1330 void CAriMpeg4aspdecHwDevice::Revert() |
|
1331 { |
|
1332 PRINT_ENTRY; |
|
1333 if ( !( iState->IsInitialized() ) ) |
|
1334 { |
|
1335 PRINT_ERR( "istate is not initialised yet \n" ); |
|
1336 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1337 } |
|
1338 PRINT_EXIT; |
|
1339 return; |
|
1340 } |
|
1341 |
|
1342 //--------------------------------------------------------------------------- |
|
1343 //Not Supported. |
|
1344 //--------------------------------------------------------------------------- |
|
1345 // |
|
1346 void CAriMpeg4aspdecHwDevice::StartDirectScreenAccessL( |
|
1347 const TRect& /*aVideoRect*/, |
|
1348 CFbsScreenDevice& /*aScreenDevice*/, |
|
1349 const TRegion& /*aClipRegion*/ ) |
|
1350 { |
|
1351 PRINT_ENTRY; |
|
1352 PRINT_ERR( "Not supported API \n" ); |
|
1353 PRINT_EXIT; |
|
1354 User::Leave( KErrNotSupported ); |
|
1355 } |
|
1356 |
|
1357 //--------------------------------------------------------------------------- |
|
1358 //Not Supported. |
|
1359 //--------------------------------------------------------------------------- |
|
1360 // |
|
1361 void CAriMpeg4aspdecHwDevice::SetScreenClipRegion( const TRegion& /*aRegion*/ ) |
|
1362 { |
|
1363 PRINT_ENTRY; |
|
1364 PRINT_ERR( "Not supported API \n" ); |
|
1365 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1366 PRINT_EXIT; |
|
1367 return; |
|
1368 } |
|
1369 |
|
1370 //--------------------------------------------------------------------------- |
|
1371 //Not Supported. |
|
1372 //--------------------------------------------------------------------------- |
|
1373 // |
|
1374 void CAriMpeg4aspdecHwDevice::SetPauseOnClipFail( TBool /*aPause*/ ) |
|
1375 { |
|
1376 PRINT_ENTRY; |
|
1377 PRINT_ERR( "Not supported API \n" ); |
|
1378 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1379 PRINT_EXIT; |
|
1380 return; |
|
1381 } |
|
1382 |
|
1383 //--------------------------------------------------------------------------- |
|
1384 //Not Supported. |
|
1385 //--------------------------------------------------------------------------- |
|
1386 // |
|
1387 void CAriMpeg4aspdecHwDevice::AbortDirectScreenAccess() |
|
1388 { |
|
1389 PRINT_ENTRY; |
|
1390 PRINT_ERR( "Not supported API \n" ); |
|
1391 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1392 PRINT_EXIT; |
|
1393 return; |
|
1394 } |
|
1395 |
|
1396 //--------------------------------------------------------------------------- |
|
1397 //Indicates whether playback is proceeding. This method can be used to check |
|
1398 //whether playback was paused or not in response to a new clipping region |
|
1399 //or DSA abort |
|
1400 //--------------------------------------------------------------------------- |
|
1401 // |
|
1402 TBool CAriMpeg4aspdecHwDevice::IsPlaying() |
|
1403 { |
|
1404 PRINT_ENTRY; |
|
1405 if ( !( iState->IsInitialized() ) ) |
|
1406 { |
|
1407 PRINT_ERR( "istate is not initialised yet \n" ); |
|
1408 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1409 } |
|
1410 PRINT_EXIT; |
|
1411 return ( iState->IsStarted() ); |
|
1412 } |
|
1413 |
|
1414 //--------------------------------------------------------------------------- |
|
1415 //Not Supported. |
|
1416 //--------------------------------------------------------------------------- |
|
1417 // |
|
1418 void CAriMpeg4aspdecHwDevice::Redraw() |
|
1419 { |
|
1420 PRINT_ENTRY; |
|
1421 PRINT_ERR( "Not supported API \n" ); |
|
1422 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1423 PRINT_EXIT; |
|
1424 return; |
|
1425 } |
|
1426 |
|
1427 //--------------------------------------------------------------------------- |
|
1428 //Starts video playback, including decoding, post-processing, and rendering. |
|
1429 //Playback will proceed until it has been stopped or paused, or the end of |
|
1430 //the bitstream is reached. |
|
1431 //--------------------------------------------------------------------------- |
|
1432 // |
|
1433 void CAriMpeg4aspdecHwDevice::Start() |
|
1434 { |
|
1435 PRINT_ENTRY; |
|
1436 if ( iState->IsPlaying() ) |
|
1437 { |
|
1438 PRINT_EXIT; |
|
1439 PRINT_ERR( "already in playing state \n" ); |
|
1440 return; |
|
1441 } |
|
1442 if ( !iState->IsTransitionValid( CStateMachine::EStartCommand ) ) |
|
1443 { |
|
1444 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1445 } |
|
1446 |
|
1447 iDecodingPosition = TTimeIntervalMicroSeconds( 0 ); |
|
1448 iEngine->Start(); |
|
1449 |
|
1450 TInt error = iState->Transit( CStateMachine::EStartCommand ); |
|
1451 if ( error != KErrNone ) |
|
1452 { |
|
1453 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1454 } |
|
1455 PRINT_EXIT; |
|
1456 } |
|
1457 |
|
1458 //--------------------------------------------------------------------------- |
|
1459 //Stops video playback. No new pictures will be decoded, post-processed, |
|
1460 //or rendered. |
|
1461 //--------------------------------------------------------------------------- |
|
1462 // |
|
1463 void CAriMpeg4aspdecHwDevice::Stop() |
|
1464 { |
|
1465 PRINT_ENTRY; |
|
1466 if ( iState->IsStopped() ) |
|
1467 { |
|
1468 PRINT_EXIT; |
|
1469 PRINT_ERR( "already in stopped state \n" ); |
|
1470 return; |
|
1471 } |
|
1472 if ( !iState->IsTransitionValid( CStateMachine::EStopCommand ) ) |
|
1473 { |
|
1474 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1475 } |
|
1476 |
|
1477 iPictureNumber = 0; |
|
1478 // Stop & Reset the Engine |
|
1479 iEngine->Stop(); |
|
1480 iEngine->Reset(); |
|
1481 iBufferAdded = EFalse; |
|
1482 iFilledBufferCounter = 0; |
|
1483 iInputEndCalled = EFalse; |
|
1484 iNoLastOut = EFalse; |
|
1485 iInputBufferConsumedCounter = 0; |
|
1486 TInt error = iState->Transit( CStateMachine::EStopCommand ); |
|
1487 if ( error != KErrNone ) |
|
1488 { |
|
1489 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1490 } |
|
1491 PRINT_EXIT; |
|
1492 } |
|
1493 |
|
1494 //--------------------------------------------------------------------------- |
|
1495 //Pauses video playback, including decoding, post-processing, and rendering. |
|
1496 //No pictures will be decoded, post-processed, or rendered until playback has |
|
1497 //been resumed. |
|
1498 //--------------------------------------------------------------------------- |
|
1499 // |
|
1500 void CAriMpeg4aspdecHwDevice::Pause() |
|
1501 { |
|
1502 PRINT_ENTRY; |
|
1503 if ( iState->IsPaused() ) |
|
1504 { |
|
1505 PRINT_EXIT; |
|
1506 PRINT_ERR( "already in paused state \n" ); |
|
1507 return; |
|
1508 } |
|
1509 |
|
1510 if ( !iState->IsTransitionValid( CStateMachine::EPauseCommand ) ) |
|
1511 { |
|
1512 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1513 } |
|
1514 |
|
1515 //Stop the Engine |
|
1516 iEngine->Stop(); |
|
1517 |
|
1518 TInt error = iState->Transit( CStateMachine::EPauseCommand ); |
|
1519 if ( error != KErrNone ) |
|
1520 { |
|
1521 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1522 } |
|
1523 |
|
1524 PRINT_EXIT; |
|
1525 } |
|
1526 |
|
1527 //--------------------------------------------------------------------------- |
|
1528 //Resumes video playback after a pause. |
|
1529 //--------------------------------------------------------------------------- |
|
1530 // |
|
1531 void CAriMpeg4aspdecHwDevice::Resume() |
|
1532 { |
|
1533 PRINT_ENTRY; |
|
1534 if ( iState->IsPlaying() ) |
|
1535 { |
|
1536 PRINT_EXIT; |
|
1537 PRINT_ERR( "already in playing state \n" ); |
|
1538 return; |
|
1539 } |
|
1540 |
|
1541 if ( !iState->IsTransitionValid( CStateMachine::EResumeCommand ) ) |
|
1542 { |
|
1543 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1544 } |
|
1545 |
|
1546 // Start The Engine |
|
1547 iEngine->Start(); |
|
1548 |
|
1549 TInt error = iState->Transit( CStateMachine::EResumeCommand ); |
|
1550 if ( error != KErrNone ) |
|
1551 { |
|
1552 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1553 } |
|
1554 PRINT_EXIT; |
|
1555 } |
|
1556 |
|
1557 //--------------------------------------------------------------------------- |
|
1558 //Changes to a new decoding and playback position,used for randomly accessing |
|
1559 //(seeking)the input stream. The position change flushes all input and output |
|
1560 //buffers. Pre-decoder and post-decoder buffering are handled as if a new |
|
1561 //bitstream was being decoded. If the device still has buffered pictures that |
|
1562 //precede the new playback position, they will be discarded. If playback is |
|
1563 //synchronized to a clock source, the client is responsible for setting the |
|
1564 //clock source to the new position.. |
|
1565 //--------------------------------------------------------------------------- |
|
1566 // |
|
1567 void CAriMpeg4aspdecHwDevice::SetPosition( |
|
1568 const TTimeIntervalMicroSeconds& aPlaybackPosition ) |
|
1569 { |
|
1570 PRINT_ENTRY; |
|
1571 //Start Decoding from new position |
|
1572 if ( iState->IsInitialized() ) |
|
1573 { |
|
1574 iEngine->Stop(); |
|
1575 iEngine->Reset(); |
|
1576 iDecodingPosition = aPlaybackPosition; |
|
1577 iBufferAdded = EFalse; |
|
1578 iEngine->Start(); |
|
1579 } |
|
1580 else |
|
1581 { |
|
1582 PRINT_ERR( "istate is not initialised yet\n" ); |
|
1583 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1584 } |
|
1585 PRINT_EXIT; |
|
1586 } |
|
1587 |
|
1588 //--------------------------------------------------------------------------- |
|
1589 //Not Supported. |
|
1590 //--------------------------------------------------------------------------- |
|
1591 // |
|
1592 void CAriMpeg4aspdecHwDevice::FreezePicture( |
|
1593 const TTimeIntervalMicroSeconds& /*aTimestamp*/ ) |
|
1594 { |
|
1595 PRINT_ENTRY; |
|
1596 PRINT_ERR( "not supported API \n" ); |
|
1597 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1598 PRINT_EXIT; |
|
1599 return; |
|
1600 } |
|
1601 |
|
1602 //--------------------------------------------------------------------------- |
|
1603 //Not Supported. |
|
1604 //--------------------------------------------------------------------------- |
|
1605 // |
|
1606 void CAriMpeg4aspdecHwDevice::ReleaseFreeze( |
|
1607 const TTimeIntervalMicroSeconds& /*aTimestamp*/ ) |
|
1608 { |
|
1609 PRINT_ENTRY; |
|
1610 PRINT_ERR( "not supported API \n" ); |
|
1611 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1612 PRINT_EXIT; |
|
1613 return; |
|
1614 } |
|
1615 |
|
1616 //--------------------------------------------------------------------------- |
|
1617 //Returns the current playback position, i.e. the timestamp for the most |
|
1618 //recently displayed or virtually displayed picture. If the device output |
|
1619 //is written to another device, the most recent output picture is used |
|
1620 //--------------------------------------------------------------------------- |
|
1621 // |
|
1622 TTimeIntervalMicroSeconds CAriMpeg4aspdecHwDevice::PlaybackPosition() |
|
1623 { |
|
1624 PRINT_ENTRY; |
|
1625 // In Decoder case decoding position is same as playback position |
|
1626 if ( !( iState->IsInitialized() ) ) |
|
1627 { |
|
1628 PRINT_ERR( "iState is not initialised \n" ); |
|
1629 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1630 } |
|
1631 PRINT_EXIT; |
|
1632 return iDecodingPosition; |
|
1633 } |
|
1634 |
|
1635 //--------------------------------------------------------------------------- |
|
1636 //Returns the total amount of memory allocated for uncompressed pictures. |
|
1637 //--------------------------------------------------------------------------- |
|
1638 // |
|
1639 TUint CAriMpeg4aspdecHwDevice::PictureBufferBytes() |
|
1640 { |
|
1641 PRINT_ENTRY; |
|
1642 if ( !( iState->IsInitialized() ) ) |
|
1643 { |
|
1644 PRINT_ERR( "iState is not initialised yet \n" ); |
|
1645 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1646 } |
|
1647 PRINT_EXIT; |
|
1648 return( KMaxOutputBuffers * iOutputBufferSize ); |
|
1649 } |
|
1650 |
|
1651 //--------------------------------------------------------------------------- |
|
1652 //Reads various counters related to decoded pictures. |
|
1653 //--------------------------------------------------------------------------- |
|
1654 // |
|
1655 void CAriMpeg4aspdecHwDevice::GetPictureCounters( |
|
1656 CMMFDevVideoPlay::TPictureCounters& aCounters ) |
|
1657 { |
|
1658 PRINT_ENTRY; |
|
1659 if ( !( iState->IsInitialized() ) ) |
|
1660 { |
|
1661 PRINT_ERR( "iState is not initialised yet\n" ); |
|
1662 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1663 } |
|
1664 |
|
1665 aCounters = iPictureCounters; |
|
1666 |
|
1667 //Reset the counters to Zero |
|
1668 iPictureCounters.iPicturesDisplayed = 0; |
|
1669 iPictureCounters.iPicturesSkipped = 0; |
|
1670 iPictureCounters.iTotalPictures = 0; |
|
1671 iPictureCounters.iPicturesDecoded = 0; |
|
1672 |
|
1673 PRINT_EXIT; |
|
1674 } |
|
1675 |
|
1676 //--------------------------------------------------------------------------- |
|
1677 //Not supported API. |
|
1678 //--------------------------------------------------------------------------- |
|
1679 // |
|
1680 void CAriMpeg4aspdecHwDevice::SetComplexityLevel( TUint /*aLevel*/ ) |
|
1681 { |
|
1682 PRINT_ENTRY; |
|
1683 PRINT_ERR( "not supported API\n" ); |
|
1684 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1685 PRINT_EXIT; |
|
1686 } |
|
1687 |
|
1688 //--------------------------------------------------------------------------- |
|
1689 //Not supported API. |
|
1690 //--------------------------------------------------------------------------- |
|
1691 // |
|
1692 TUint CAriMpeg4aspdecHwDevice::NumComplexityLevels() |
|
1693 { |
|
1694 PRINT_ENTRY; |
|
1695 PRINT_ERR( "not supported API\n" ); |
|
1696 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1697 PRINT_EXIT; |
|
1698 return 0; |
|
1699 } |
|
1700 |
|
1701 //--------------------------------------------------------------------------- |
|
1702 //Not supported API. |
|
1703 //--------------------------------------------------------------------------- |
|
1704 // |
|
1705 void CAriMpeg4aspdecHwDevice::GetComplexityLevelInfo( TUint /*aLevel*/, |
|
1706 CMMFDevVideoPlay::TComplexityLevelInfo& /*aInfo*/ ) |
|
1707 { |
|
1708 PRINT_ENTRY; |
|
1709 PRINT_ERR( "not supported API\n" ); |
|
1710 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1711 PRINT_EXIT; |
|
1712 } |
|
1713 |
|
1714 //--------------------------------------------------------------------------- |
|
1715 //Called by the Post Proc hwdevice when a picture is displayed on the screen. |
|
1716 //Returns a picture back to the device. |
|
1717 //--------------------------------------------------------------------------- |
|
1718 // |
|
1719 void CAriMpeg4aspdecHwDevice::ReturnPicture( TVideoPicture* aPicture ) |
|
1720 { |
|
1721 PRINT_ENTRY; |
|
1722 if ( !( iState->IsInitialized() ) ) |
|
1723 { |
|
1724 PRINT_ERR( "iState is not initialised yet\n" ); |
|
1725 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1726 } |
|
1727 |
|
1728 if ( iCustomBufferHandle ) |
|
1729 { |
|
1730 delete aPicture->iHeader ; |
|
1731 aPicture->iHeader = NULL ; |
|
1732 } |
|
1733 else |
|
1734 { |
|
1735 // add to engine if state is not stopped |
|
1736 if ( iState->IsStopped() ) |
|
1737 { |
|
1738 iOutputFreeBufferQueue.Append( aPicture ); |
|
1739 } |
|
1740 else |
|
1741 { |
|
1742 iEngine->AddOutput( aPicture ); |
|
1743 } |
|
1744 } |
|
1745 PRINT_EXIT; |
|
1746 } |
|
1747 |
|
1748 //--------------------------------------------------------------------------- |
|
1749 //Not supported API. |
|
1750 //--------------------------------------------------------------------------- |
|
1751 // |
|
1752 TBool CAriMpeg4aspdecHwDevice::GetSnapshotL( TPictureData& /*aPictureData*/, |
|
1753 const TUncompressedVideoFormat& /*aFormat*/ ) |
|
1754 { |
|
1755 PRINT_ENTRY; |
|
1756 PRINT_ERR( "not supported API\n" ); |
|
1757 PRINT_EXIT; |
|
1758 User::Leave( KErrNotSupported ); |
|
1759 return( KErrNone ); |
|
1760 } |
|
1761 |
|
1762 //--------------------------------------------------------------------------- |
|
1763 //Not supported API. |
|
1764 //--------------------------------------------------------------------------- |
|
1765 // |
|
1766 void CAriMpeg4aspdecHwDevice::GetTimedSnapshotL( TPictureData* /*aPictureData*/, |
|
1767 const TUncompressedVideoFormat& /*aFormat*/, |
|
1768 const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/ ) |
|
1769 { |
|
1770 PRINT_ENTRY; |
|
1771 PRINT_ERR( "not supported API\n" ); |
|
1772 PRINT_EXIT; |
|
1773 //Should take it from Post Proc HwDevice |
|
1774 User::Leave( KErrNotSupported ); |
|
1775 } |
|
1776 |
|
1777 //--------------------------------------------------------------------------- |
|
1778 //Not supported API. |
|
1779 //--------------------------------------------------------------------------- |
|
1780 // |
|
1781 void CAriMpeg4aspdecHwDevice::GetTimedSnapshotL( TPictureData* /*aPictureData*/, |
|
1782 const TUncompressedVideoFormat& /*aFormat*/, |
|
1783 const TPictureId& /*aPictureId*/ ) |
|
1784 { |
|
1785 PRINT_ENTRY; |
|
1786 PRINT_ERR( "not supported API\n" ); |
|
1787 PRINT_EXIT; |
|
1788 //Should take it from Post Proc HwDevice |
|
1789 User::Leave( KErrNotSupported ); |
|
1790 } |
|
1791 |
|
1792 //--------------------------------------------------------------------------- |
|
1793 //Not supported API. |
|
1794 //--------------------------------------------------------------------------- |
|
1795 // |
|
1796 void CAriMpeg4aspdecHwDevice::CancelTimedSnapshot() |
|
1797 { |
|
1798 PRINT_ENTRY; |
|
1799 PRINT_ERR( "not supported API\n" ); |
|
1800 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotSupported ); |
|
1801 PRINT_EXIT; |
|
1802 return; |
|
1803 } |
|
1804 |
|
1805 |
|
1806 //--------------------------------------------------------------------------- |
|
1807 //Not supported API. |
|
1808 //--------------------------------------------------------------------------- |
|
1809 // |
|
1810 void CAriMpeg4aspdecHwDevice::GetSupportedSnapshotFormatsL( |
|
1811 RArray<TUncompressedVideoFormat>& /*aFormats*/ ) |
|
1812 { |
|
1813 PRINT_ENTRY; |
|
1814 PRINT_ERR( "not supported API\n" ); |
|
1815 PRINT_EXIT; |
|
1816 User::Leave( KErrNotSupported ); |
|
1817 } |
|
1818 |
|
1819 //--------------------------------------------------------------------------- |
|
1820 //sets the Flag iInputEndCalled to ETrue |
|
1821 //Notifies the hardware device that the end of input data has been reached |
|
1822 //and no more input data will be written |
|
1823 //--------------------------------------------------------------------------- |
|
1824 // |
|
1825 void CAriMpeg4aspdecHwDevice::InputEnd() |
|
1826 { |
|
1827 PRINT_ENTRY; |
|
1828 if ( !( iState->IsTransitionValid( CStateMachine::EInputEndCommand ) ) ) |
|
1829 { |
|
1830 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1831 } |
|
1832 |
|
1833 iInputEndCalled = ETrue; |
|
1834 |
|
1835 if ( ( iFilledBufferCounter - iInputBufferConsumedCounter ) == 1 ) |
|
1836 { |
|
1837 GetLastFrame(); |
|
1838 Stop(); |
|
1839 iMMFDevVideoPlayProxy->MdvppStreamEnd(); |
|
1840 PRINT_EXIT; |
|
1841 return; |
|
1842 } |
|
1843 |
|
1844 TInt error = iState->Transit( CStateMachine::EInputEndCommand ); |
|
1845 |
|
1846 if ( error != KErrNone ) |
|
1847 { |
|
1848 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
1849 } |
|
1850 |
|
1851 PRINT_EXIT; |
|
1852 } |
|
1853 |
|
1854 //--------------------------------------------------------------------------- |
|
1855 //Notifies the Hw Device that input buffer is free |
|
1856 //--------------------------------------------------------------------------- |
|
1857 // |
|
1858 TInt CAriMpeg4aspdecHwDevice::InputBufferConsumed ( TAny* aInp, TInt aError ) |
|
1859 { |
|
1860 PRINT_ENTRY; |
|
1861 |
|
1862 if ( aInp ) |
|
1863 { |
|
1864 iInputFreeBufferQueue.Append( REINTERPRET_CAST( TVideoInputBuffer*, |
|
1865 aInp ) ); |
|
1866 |
|
1867 //call back to clinet |
|
1868 if ( ( aError != KErrCancel ) && ( !iInputEndCalled ) ) |
|
1869 iMMFDevVideoPlayProxy->MdvppNewBuffers(); |
|
1870 } |
|
1871 if ( iInputEndCalled && iNoLastOut ) |
|
1872 { |
|
1873 HandleInputEndInStopping(); |
|
1874 iMMFDevVideoPlayProxy->MdvppStreamEnd(); |
|
1875 } |
|
1876 |
|
1877 PRINT_EXIT; |
|
1878 return ( KErrNone ); |
|
1879 } |
|
1880 |
|
1881 //--------------------------------------------------------------------------- |
|
1882 //Notifies the Hw Device that out buffer has decoded data |
|
1883 //--------------------------------------------------------------------------- |
|
1884 // |
|
1885 TInt CAriMpeg4aspdecHwDevice::OutputBufferReady ( TAny* aOut, TInt aError ) |
|
1886 { |
|
1887 PRINT_ENTRY; |
|
1888 if ( aError == KErrNone ) |
|
1889 { |
|
1890 iPictureNumber++; |
|
1891 // call back information regarding slice and picture loss |
|
1892 |
|
1893 SliceAndPictureLoss(); |
|
1894 |
|
1895 //Decoded Buffer is available |
|
1896 TVideoPicture* videoPicture = REINTERPRET_CAST( TVideoPicture*, |
|
1897 aOut ); |
|
1898 |
|
1899 videoPicture->iHeader->iPictureNumber = iPictureNumber; |
|
1900 |
|
1901 iFilledBufferCounter--; |
|
1902 |
|
1903 iPictureCounters.iPicturesDecoded++; |
|
1904 iPictureCounters.iPicturesDisplayed++; |
|
1905 |
|
1906 iDecodingPosition = videoPicture->iTimestamp; |
|
1907 |
|
1908 if ( !iOutputDevice ) |
|
1909 { |
|
1910 iMMFDevVideoPlayProxy->MdvppNewPicture( videoPicture ); |
|
1911 |
|
1912 if ( iInputEndCalled && |
|
1913 ( ( iFilledBufferCounter - iInputBufferConsumedCounter ) |
|
1914 == 1 ) |
|
1915 ) |
|
1916 { |
|
1917 GetLastFrame(); |
|
1918 Stop(); |
|
1919 PRINT_ERR( "calling streamend\n" ); |
|
1920 iMMFDevVideoPlayProxy->MdvppStreamEnd(); |
|
1921 } |
|
1922 PRINT_EXIT; |
|
1923 return( KErrNone ); |
|
1924 } |
|
1925 else |
|
1926 { |
|
1927 TRAPD( error, iOutputDevice->WritePictureL( videoPicture ) ); |
|
1928 |
|
1929 if ( error == KErrNone ) |
|
1930 { |
|
1931 if ( iInputEndCalled && |
|
1932 ( ( iFilledBufferCounter - iInputBufferConsumedCounter ) |
|
1933 == 1 ) ) |
|
1934 { |
|
1935 GetLastFrame(); |
|
1936 HandleInputEndInStopping(); |
|
1937 PRINT_ERR( "calling streamend\n" ); |
|
1938 iMMFDevVideoPlayProxy->MdvppStreamEnd(); |
|
1939 } |
|
1940 } |
|
1941 else if ( error ) // KErrArgument, KErrNotReady |
|
1942 { |
|
1943 iPictureCounters.iPicturesDisplayed--; |
|
1944 // Currently not handled |
|
1945 } |
|
1946 } |
|
1947 } |
|
1948 |
|
1949 else if ( aError == KErrCancel ) |
|
1950 { |
|
1951 // Add buffers to output free buffer queue if cutombuffer is not set |
|
1952 if ( !iCustomBufferHandle ) |
|
1953 { |
|
1954 iOutputFreeBufferQueue.Append( REINTERPRET_CAST( TVideoPicture*, |
|
1955 aOut ) ); |
|
1956 } |
|
1957 else |
|
1958 { |
|
1959 |
|
1960 delete ( ( TVideoPicture* )aOut )->iHeader; |
|
1961 ( ( TVideoPicture* )aOut )->iHeader = NULL; |
|
1962 |
|
1963 // release the buffer |
|
1964 iCustomBufferHandle->MmvbmReleaseBuffer( REINTERPRET_CAST( |
|
1965 TVideoPicture*, aOut ) ); |
|
1966 } |
|
1967 |
|
1968 } |
|
1969 |
|
1970 else // other errors |
|
1971 { |
|
1972 // currently not handled |
|
1973 } |
|
1974 |
|
1975 PRINT_EXIT; |
|
1976 return ( KErrNone ); |
|
1977 } |
|
1978 |
|
1979 //--------------------------------------------------------------------------- |
|
1980 //Notifies the hw devcie that Error has occured in PE |
|
1981 //--------------------------------------------------------------------------- |
|
1982 // |
|
1983 void CAriMpeg4aspdecHwDevice::FatalErrorFromProcessEngine ( TInt aError ) |
|
1984 { |
|
1985 PRINT_ENTRY; |
|
1986 PRINT_ERR( "not supported API\n" ); |
|
1987 iMMFDevVideoPlayProxy->MdvppFatalError( this, aError ); |
|
1988 PRINT_EXIT; |
|
1989 } |
|
1990 //--------------------------------------------------------------------------- |
|
1991 //Callback to indicate the command has been processed |
|
1992 //--------------------------------------------------------------------------- |
|
1993 // |
|
1994 void CAriMpeg4aspdecHwDevice::CommandProcessed ( TInt aCmd, TAny* aCmdData, |
|
1995 TInt aError ) |
|
1996 { |
|
1997 PRINT_ENTRY; |
|
1998 PRINT_EXIT; |
|
1999 } |
|
2000 |
|
2001 //--------------------------------------------------------------------------- |
|
2002 //Call back from output device, indicates buffers availability |
|
2003 //--------------------------------------------------------------------------- |
|
2004 // |
|
2005 void CAriMpeg4aspdecHwDevice::MmvbmoNewBuffers() |
|
2006 { |
|
2007 PRINT_ENTRY; |
|
2008 TVideoPicture* videoPicture = NULL; |
|
2009 |
|
2010 TRAPD( err, videoPicture = iCustomBufferHandle->MmvbmGetBufferL( |
|
2011 iCustomBufferOptions->iBufferSize ) ); |
|
2012 |
|
2013 if ( err != KErrNone ) |
|
2014 { |
|
2015 PRINT_ERR( "iCustomBufferHandle->MmvbmGetBufferL returned error\n" ); |
|
2016 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrArgument ); |
|
2017 } |
|
2018 if ( videoPicture ) |
|
2019 { |
|
2020 if ( videoPicture->iHeader ) |
|
2021 { |
|
2022 delete videoPicture->iHeader; |
|
2023 videoPicture->iHeader = NULL; |
|
2024 } |
|
2025 |
|
2026 TRAPD( err1, videoPicture->iHeader = |
|
2027 new ( ELeave ) TVideoPictureHeader ) ; |
|
2028 |
|
2029 if ( err1 != KErrNone ) |
|
2030 { |
|
2031 iCustomBufferHandle->MmvbmReleaseBuffer( videoPicture ) ; |
|
2032 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrArgument ); |
|
2033 } |
|
2034 else |
|
2035 { |
|
2036 iEngine->AddOutput( videoPicture ); |
|
2037 } |
|
2038 } |
|
2039 PRINT_EXIT; |
|
2040 } |
|
2041 |
|
2042 //--------------------------------------------------------------------------- |
|
2043 //Callback from output device. |
|
2044 //--------------------------------------------------------------------------- |
|
2045 // |
|
2046 void CAriMpeg4aspdecHwDevice::MmvbmoReleaseBuffers() |
|
2047 { |
|
2048 PRINT_ENTRY; |
|
2049 iEngine->Stop(); |
|
2050 iEngine->Reset(); |
|
2051 PRINT_EXIT; |
|
2052 } |
|
2053 |
|
2054 |
|
2055 |
|
2056 //--------------------------------------------------------------------------- |
|
2057 //Call back from the codec wrapper when there is new config information. |
|
2058 //--------------------------------------------------------------------------- |
|
2059 // |
|
2060 void CAriMpeg4aspdecHwDevice::NewConfigFound() |
|
2061 { |
|
2062 PRINT_ENTRY; |
|
2063 |
|
2064 /* Reset the all the output buffers added to the ProcessEngine. |
|
2065 * Create them again if custom buffers are not used. |
|
2066 */ |
|
2067 while ( iEngine->NumOutputBuffers() ) |
|
2068 OutputBufferReady ( iEngine->FetchOutputBuffer(), KErrCancel ); |
|
2069 |
|
2070 iOutputBuffersCreated = EFalse; |
|
2071 iBufferAdded = EFalse; |
|
2072 |
|
2073 PRINT_EXIT; |
|
2074 } |
|
2075 |
|
2076 //--------------------------------------------------------------------------- |
|
2077 //Call back from the codec wrapper when EInputConsumed for Not yet get I frame |
|
2078 //--------------------------------------------------------------------------- |
|
2079 // |
|
2080 void CAriMpeg4aspdecHwDevice::EInputConsumed() |
|
2081 { |
|
2082 PRINT_ENTRY; |
|
2083 |
|
2084 iInputBufferConsumedCounter++; |
|
2085 |
|
2086 if ( iInputEndCalled && ( iFilledBufferCounter == |
|
2087 ( iInputBufferConsumedCounter + 1 ) ) ) |
|
2088 { |
|
2089 iNoLastOut = ETrue; |
|
2090 } |
|
2091 |
|
2092 PRINT_EXIT; |
|
2093 } |
|
2094 //--------------------------------------------------------------------------- |
|
2095 //Set the proxy implementation to be used. Called just |
|
2096 //after the object is constructed |
|
2097 //--------------------------------------------------------------------------- |
|
2098 // |
|
2099 void CAriMpeg4aspdecHwDevice::SetProxy( MMMFDevVideoPlayProxy& aProxy ) |
|
2100 { |
|
2101 PRINT_ENTRY; |
|
2102 iMMFDevVideoPlayProxy = &aProxy; |
|
2103 PRINT_EXIT; |
|
2104 } |
|
2105 |
|
2106 |
|
2107 //--------------------------------------------------------------------------- |
|
2108 //Default constructor of CAriMpeg4aspdecHwDevice |
|
2109 //--------------------------------------------------------------------------- |
|
2110 // |
|
2111 CAriMpeg4aspdecHwDevice::CAriMpeg4aspdecHwDevice() |
|
2112 :iInputFreeBuffers( NULL ), |
|
2113 iOutputDevice( NULL ), |
|
2114 iMMFDevVideoPlayProxy( NULL ), |
|
2115 iState( NULL ), |
|
2116 iVideoPictureHeader( NULL ), |
|
2117 iDecodingPosition( TTimeIntervalMicroSeconds( 0 ) ), |
|
2118 iInputFormat( NULL ), |
|
2119 iCodec( NULL ), |
|
2120 iEngine( NULL ), |
|
2121 iInputEndCalled( EFalse ), |
|
2122 iOutputFreeBuffer( NULL ), |
|
2123 iFilledBufferCounter( 0 ), |
|
2124 iDataUnitType( EDuCodedPicture ), |
|
2125 iEncapsulation( EDuElementaryStream ), |
|
2126 iOutputBufferSize( 0 ), |
|
2127 iOutputBuffersCreated( EFalse ), |
|
2128 iPictureNumber( 0 ), |
|
2129 iNumberOfInputBuffersAllocated( 0 ), |
|
2130 iCustomBufferHandle( NULL ), |
|
2131 iCustomBufferOptions( NULL ), |
|
2132 iBufferAdded( EFalse ), |
|
2133 iConfigureDecoderCalled( EFalse ), |
|
2134 iDecoderConfigured( EFalse ), |
|
2135 iInputBufferConsumedCounter( 0 ), |
|
2136 iNoLastOut( EFalse ) |
|
2137 { |
|
2138 PRINT_ENTRY; |
|
2139 iBufferOptions.iPreDecodeBufferSize = 0; |
|
2140 iBufferOptions.iMaxPostDecodeBufferSize = 0; |
|
2141 iBufferOptions.iPreDecoderBufferPeriod = 0; |
|
2142 iBufferOptions.iPostDecoderBufferPeriod = 0; |
|
2143 iBufferOptions.iMinNumInputBuffers = KMaxInputBuffers; |
|
2144 iBufferOptions.iMaxInputBufferSize = KMaxInputBufferSize; |
|
2145 |
|
2146 |
|
2147 // Initializing iOutputFormat with one of the combination supported by |
|
2148 // Mpeg-4/H.263 hwdevice |
|
2149 |
|
2150 iOutputFormat.iDataFormat = EYuvRawData; |
|
2151 // For H.263 it is always Bt 601.5 reduced range |
|
2152 // For Mpeg-4 input stream contains this information |
|
2153 iOutputFormat.iYuvFormat.iCoefficients = EYuvBt601Range0; |
|
2154 // The input stream format ( H.263 & Mpeg-4 ) comes in Chroma1 format and |
|
2155 //so output is also decoded into Chroma1 format |
|
2156 iOutputFormat.iYuvFormat.iPattern = EYuv420Chroma1; |
|
2157 iOutputFormat.iYuvFormat.iDataLayout = EYuvDataPlanar; |
|
2158 iOutputFormat.iYuvFormat.iYuv2RgbMatrix = NULL; |
|
2159 iOutputFormat.iYuvFormat.iRgb2YuvMatrix = NULL; |
|
2160 iOutputFormat.iYuvFormat.iAspectRatioNum = 1; |
|
2161 iOutputFormat.iYuvFormat.iAspectRatioDenom = 1; |
|
2162 PRINT_EXIT; |
|
2163 } |
|
2164 |
|
2165 |
|
2166 //--------------------------------------------------------------------------- |
|
2167 //This is the 2nd phase constructor |
|
2168 //--------------------------------------------------------------------------- |
|
2169 // |
|
2170 void CAriMpeg4aspdecHwDevice::ConstructL() |
|
2171 { |
|
2172 PRINT_ENTRY; |
|
2173 iState = CStateMachine::NewL(); |
|
2174 PRINT_EXIT; |
|
2175 } |
|
2176 |
|
2177 //--------------------------------------------------------------------------- |
|
2178 //Module to create output data |
|
2179 //--------------------------------------------------------------------------- |
|
2180 // |
|
2181 void CAriMpeg4aspdecHwDevice::CreateOutputBuffersL() |
|
2182 { |
|
2183 PRINT_ENTRY; |
|
2184 if ( iOutputFreeBuffer ) |
|
2185 { |
|
2186 for ( TInt i = 0 ; i < KMaxOutputBuffers; i++ ) |
|
2187 { |
|
2188 if ( ( iOutputFreeBuffer + i )->iHeader ) |
|
2189 { |
|
2190 delete ( iOutputFreeBuffer + i )->iHeader; |
|
2191 } |
|
2192 if ( ( iOutputFreeBuffer + i )->iData.iRawData ) |
|
2193 { |
|
2194 delete |
|
2195 ( TUint8* )( iOutputFreeBuffer + i )->iData.iRawData->Ptr(); |
|
2196 } |
|
2197 if ( ( iOutputFreeBuffer + i )->iData.iRawData ) |
|
2198 { |
|
2199 delete ( iOutputFreeBuffer + i )->iData.iRawData; |
|
2200 } |
|
2201 } |
|
2202 delete [] iOutputFreeBuffer; |
|
2203 } |
|
2204 for ( TInt i = 0; i < iOutputFreeBufferQueue.Count(); i++ ) |
|
2205 { |
|
2206 iOutputFreeBufferQueue.Remove( 0 ); |
|
2207 } |
|
2208 // Create the output Buffer( s ) and buffers to engine |
|
2209 iOutputFreeBuffer = new ( ELeave ) TVideoPicture[KMaxOutputBuffers]; |
|
2210 TInt i; |
|
2211 for ( i = 0 ; i < KMaxOutputBuffers; i++ ) |
|
2212 { |
|
2213 ( iOutputFreeBuffer + i )->iData.iRawData = NULL; |
|
2214 ( iOutputFreeBuffer + i )->iHeader = NULL; |
|
2215 } |
|
2216 |
|
2217 for ( i = 0 ; i < KMaxOutputBuffers; i++ ) |
|
2218 { |
|
2219 TUint8* ptr; |
|
2220 TPtr8* temp; |
|
2221 |
|
2222 ptr = new ( ELeave ) TUint8[iOutputBufferSize]; |
|
2223 CleanupStack::PushL( ptr ); |
|
2224 temp = new ( ELeave ) TPtr8( ptr, 0, iOutputBufferSize ); |
|
2225 CleanupStack::Pop( ptr ); |
|
2226 |
|
2227 ( iOutputFreeBuffer + i )->iData.iRawData = temp; |
|
2228 ( iOutputFreeBuffer + i )->iHeader = |
|
2229 new ( ELeave ) TVideoPictureHeader; |
|
2230 |
|
2231 //Add o/p buffer( s ) to the Queue |
|
2232 iEngine->AddOutput( ( iOutputFreeBuffer + i ) ); |
|
2233 } |
|
2234 iBufferAdded = ETrue; |
|
2235 PRINT_EXIT; |
|
2236 } |
|
2237 |
|
2238 |
|
2239 //--------------------------------------------------------------------------- |
|
2240 //Gives callbacks to client regarding slice and picture loss |
|
2241 //--------------------------------------------------------------------------- |
|
2242 // |
|
2243 void CAriMpeg4aspdecHwDevice::SliceAndPictureLoss() |
|
2244 { |
|
2245 PRINT_ENTRY; |
|
2246 TUint firstMacroblock; |
|
2247 TUint numMacroblocks; |
|
2248 TPictureId pictureId; |
|
2249 pictureId.iIdType = TPictureId::EPictureNumber; |
|
2250 |
|
2251 // call back to client regading picture loss |
|
2252 if ( ( iCodec->GetPictureLossInfo() ) >= KMaxAllowPicLoss ) |
|
2253 { |
|
2254 PRINT_MSG( LEVEL_LOW, ( "Mpeg4aspdecHwDevice::SliceAndPictureLoss, " |
|
2255 " calling callback regading picture loss" ) ); |
|
2256 iMMFDevVideoPlayProxy->MdvppPictureLoss(); |
|
2257 } |
|
2258 |
|
2259 PRINT_MSG( LEVEL_LOW, ( "CAriMpeg4aspdecHwDevice::SliceAndPictureLoss, " |
|
2260 " calling callback regarding slice loss" ) ); |
|
2261 // call back to clinet regarding slice loss |
|
2262 iCodec->GetSliceLossInfo( firstMacroblock, numMacroblocks ); |
|
2263 |
|
2264 if ( ( firstMacroblock != 0 ) || ( numMacroblocks != 0 ) ) |
|
2265 iMMFDevVideoPlayProxy->MdvppSliceLoss( firstMacroblock, |
|
2266 numMacroblocks, |
|
2267 pictureId ); |
|
2268 |
|
2269 PRINT_EXIT; |
|
2270 } |
|
2271 |
|
2272 |
|
2273 //--------------------------------------------------------------------------- |
|
2274 //Creates one input Buffer |
|
2275 //--------------------------------------------------------------------------- |
|
2276 // |
|
2277 void CAriMpeg4aspdecHwDevice::CreateInputBufferL( TUint aBufferSize, |
|
2278 TBool aReallocate ) |
|
2279 { |
|
2280 PRINT_ENTRY; |
|
2281 |
|
2282 if ( !aReallocate ) |
|
2283 { |
|
2284 PRINT_MSG( LEVEL_LOW, ( "CreateInputBufferL 1++" ) ); |
|
2285 // Create the Buffer and add it to Queue |
|
2286 TUint8* ptr = new ( ELeave ) TUint8[aBufferSize]; |
|
2287 PRINT_MSG( LEVEL_LOW, ( "CreateInputBufferL 2++" ) ); |
|
2288 TInt* lastBufferFlag = new ( ELeave ) TInt[sizeof( TInt )]; |
|
2289 PRINT_MSG( LEVEL_LOW, ( "CreateInputBufferL 3++" ) ); |
|
2290 iInputFreeBuffers[iNumberOfInputBuffersAllocated].iData.Set( ptr, |
|
2291 0, |
|
2292 TInt( aBufferSize ) ); |
|
2293 iInputFreeBuffers[iNumberOfInputBuffersAllocated].iUser = |
|
2294 REINTERPRET_CAST( TAny*, lastBufferFlag ); |
|
2295 iInputFreeBufferQueue.Append( |
|
2296 iInputFreeBuffers + iNumberOfInputBuffersAllocated ); |
|
2297 iNumberOfInputBuffersAllocated++; |
|
2298 PRINT_MSG( LEVEL_LOW, ( "CreateInputBufferL 4++" ) ); |
|
2299 } |
|
2300 |
|
2301 else // input buffers are already created and do reallocation here |
|
2302 { |
|
2303 PRINT_MSG( LEVEL_LOW, ( "CreateInputBufferL 5++" ) ); |
|
2304 TVideoInputBuffer* inBuffer = iInputFreeBufferQueue[0]; |
|
2305 // check the size of the current with the size |
|
2306 //of the buffer present in i/p Q |
|
2307 if ( aBufferSize > TUint( inBuffer->iData.MaxLength() ) ) |
|
2308 { |
|
2309 PRINT_MSG( LEVEL_LOW, ( "CreateInputBufferL 6++" ) ); |
|
2310 // delete the previous buffer |
|
2311 delete [] ( TUint8* )inBuffer->iData.Ptr(); |
|
2312 PRINT_MSG( LEVEL_LOW, ( "CreateInputBufferL 7++" ) ); |
|
2313 delete inBuffer->iUser; |
|
2314 |
|
2315 // reallocate the buffer |
|
2316 TUint8* ptr = new ( ELeave ) TUint8[aBufferSize]; |
|
2317 PRINT_MSG( LEVEL_LOW, ( "CreateInputBufferL 8++" ) ); |
|
2318 //delete inBuffer->iUser; |
|
2319 TInt* lastBufferFlag = new ( ELeave ) TInt[sizeof( TInt )]; |
|
2320 inBuffer->iData.Set( ptr, 0, TInt( aBufferSize ) ); |
|
2321 inBuffer->iUser = REINTERPRET_CAST( TAny*, lastBufferFlag ); |
|
2322 } |
|
2323 } |
|
2324 |
|
2325 PRINT_EXIT; |
|
2326 } |
|
2327 |
|
2328 //--------------------------------------------------------------------------- |
|
2329 //When InputEnd is called while the hw device in Stopping State. |
|
2330 //--------------------------------------------------------------------------- |
|
2331 // |
|
2332 void CAriMpeg4aspdecHwDevice::HandleInputEndInStopping() |
|
2333 { |
|
2334 PRINT_ENTRY; |
|
2335 if ( iState->IsInputEndPending() ) |
|
2336 { |
|
2337 iPictureNumber = 0; |
|
2338 // Stop & Reset the Engine |
|
2339 iEngine->Stop(); |
|
2340 iBufferAdded = EFalse; |
|
2341 iFilledBufferCounter = 0; |
|
2342 iInputEndCalled = EFalse; |
|
2343 iInputBufferConsumedCounter = 0; |
|
2344 iNoLastOut = EFalse; |
|
2345 TInt error = iState->Transit( CStateMachine::EStopCommand ); |
|
2346 if ( error != KErrNone ) |
|
2347 { |
|
2348 iMMFDevVideoPlayProxy->MdvppFatalError( this, KErrNotReady ); |
|
2349 } |
|
2350 } |
|
2351 PRINT_EXIT; |
|
2352 } |
|
2353 |
|
2354 //--------------------------------------------------------------------------- |
|
2355 //Gets the last frame of the sequence. |
|
2356 //--------------------------------------------------------------------------- |
|
2357 // |
|
2358 void CAriMpeg4aspdecHwDevice::GetLastFrame() |
|
2359 { |
|
2360 PRINT_ENTRY; |
|
2361 TInt err = KErrNone; |
|
2362 |
|
2363 if ( ( iEngine->NumOutputBuffers() ) > 0 ) |
|
2364 { |
|
2365 TVideoPicture* lVideoPicture = |
|
2366 ( TVideoPicture* )( iEngine->FetchOutputBuffer() ); |
|
2367 err = iCodec->GetLastFrame( lVideoPicture ); |
|
2368 |
|
2369 if ( err == KErrNone ) |
|
2370 { |
|
2371 lVideoPicture->iHeader->iPictureNumber = iPictureNumber; |
|
2372 |
|
2373 iPictureCounters.iPicturesDecoded++; |
|
2374 iPictureCounters.iPicturesDisplayed++; |
|
2375 |
|
2376 iDecodingPosition = lVideoPicture->iTimestamp; |
|
2377 |
|
2378 if ( !iOutputDevice ) |
|
2379 { |
|
2380 iMMFDevVideoPlayProxy->MdvppNewPicture( lVideoPicture ); |
|
2381 } |
|
2382 else |
|
2383 { |
|
2384 TRAPD( error, |
|
2385 iOutputDevice->WritePictureL( lVideoPicture ) ); |
|
2386 if ( error != KErrNone ) |
|
2387 { |
|
2388 iPictureCounters.iPicturesDisplayed--; |
|
2389 // Currently not handled |
|
2390 } |
|
2391 } |
|
2392 } |
|
2393 else |
|
2394 { |
|
2395 //Add the output buffer back to ProcessEngine |
|
2396 iEngine->AddOutput( lVideoPicture ); |
|
2397 } |
|
2398 } |
|
2399 PRINT_EXIT; |
|
2400 } |
|
2401 |
|
2402 const TImplementationProxy ImplementationTable[] = |
|
2403 { |
|
2404 IMPLEMENTATION_PROXY_ENTRY( KUidMp4DecoderHwDeviceImplUid, |
|
2405 CAriMpeg4aspdecHwDevice::NewL ) |
|
2406 }; |
|
2407 |
|
2408 |
|
2409 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
2410 TInt& aTableCount ) |
|
2411 { |
|
2412 PRINT_ENTRY; |
|
2413 aTableCount = |
|
2414 sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
2415 PRINT_EXIT; |
|
2416 return ImplementationTable; |
|
2417 } |