os/mm/mmdevicefw/mdf/src/video/decoderadapter/mdfvideodecodehwdeviceadapter.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <mmf/devvideo/devvideopuconfig.h>
sl@0
    17
#include "mdfvideodecodehwdeviceadapter.h"
sl@0
    18
#include "displaymodeutils.h"
sl@0
    19
sl@0
    20
#if defined (SYMBIAN_MDFVIDEODECODERHWDEVICE_DEBUG)
sl@0
    21
#define DEBUG_PRINT RDebug::Print
sl@0
    22
#else
sl@0
    23
#define DEBUG_PRINT
sl@0
    24
#endif // defined (SYMBIAN_MDFVIDEODECODERHWDEVICE_DEBUG)
sl@0
    25
sl@0
    26
const TInt KOutputFormatsArraySize = 3;
sl@0
    27
const TInt KTenFPS = 10;
sl@0
    28
const TInt KOneSecond = 1000000;
sl@0
    29
const TInt KInputBufferSize = 8192;
sl@0
    30
sl@0
    31
_LIT(KDevVideoHwDeviceDecoderPanicCategory, "DevVideoHwDeviceDecoder");
sl@0
    32
void DevVideoHwDeviceDecoderPanic(TInt aReason)
sl@0
    33
	{
sl@0
    34
	User::Panic(KDevVideoHwDeviceDecoderPanicCategory, aReason);
sl@0
    35
	}
sl@0
    36
	
sl@0
    37
/* 
sl@0
    38
 Constructs a new instance of CMdfVideoDecodeHwDeviceAdapter.
sl@0
    39
 @return    "CMdfVideoDecodeHwDeviceAdapter*"
sl@0
    40
            A pointer to the newly constructed HwDevice
sl@0
    41
 */
sl@0
    42
CMdfVideoDecodeHwDeviceAdapter* CMdfVideoDecodeHwDeviceAdapter::NewL()
sl@0
    43
	{
sl@0
    44
	CMdfVideoDecodeHwDeviceAdapter* self = new (ELeave) CMdfVideoDecodeHwDeviceAdapter;
sl@0
    45
	CleanupStack::PushL(self);
sl@0
    46
	self->ConstructL();
sl@0
    47
	CleanupStack::Pop(self);
sl@0
    48
	return self;	
sl@0
    49
	}
sl@0
    50
sl@0
    51
/*
sl@0
    52
 Default constructor
sl@0
    53
*/
sl@0
    54
CMdfVideoDecodeHwDeviceAdapter::CMdfVideoDecodeHwDeviceAdapter()
sl@0
    55
	{
sl@0
    56
	}
sl@0
    57
	
sl@0
    58
void CMdfVideoDecodeHwDeviceAdapter::ConstructL()
sl@0
    59
	{
sl@0
    60
	// system clock without HAL
sl@0
    61
	TInt64 tt64;
sl@0
    62
	TTime ttime;
sl@0
    63
	ttime.HomeTime();
sl@0
    64
	tt64 = ttime.Int64();
sl@0
    65
	iSystemClock = tt64;
sl@0
    66
sl@0
    67
	// reset picture format
sl@0
    68
	iFormat.iDataFormat = (TImageDataFormat)0;
sl@0
    69
	
sl@0
    70
	// Load the PU Loader plugin
sl@0
    71
	iPuLoader = static_cast<CMdfPuLoader*>
sl@0
    72
		(REComSession::CreateImplementationL(TUid::Uid(KUidPuLoaderImplementation), iPuLoaderDtorKey));	
sl@0
    73
	iState = EProcessingUnitLoaderLoaded;
sl@0
    74
	}
sl@0
    75
sl@0
    76
/*
sl@0
    77
 Default destructor
sl@0
    78
*/
sl@0
    79
CMdfVideoDecodeHwDeviceAdapter::~CMdfVideoDecodeHwDeviceAdapter()
sl@0
    80
	{
sl@0
    81
	DEBUG_PRINT(_L("HwDevice: Destroying"));
sl@0
    82
	// stop playing if necessary
sl@0
    83
	Stop();
sl@0
    84
	
sl@0
    85
	delete iPlayerEngine;
sl@0
    86
	delete iScreenDeviceGc;
sl@0
    87
sl@0
    88
	// destroy the buffer manager
sl@0
    89
	delete iBufferManager;
sl@0
    90
	// destroy the picture header
sl@0
    91
	delete iPictureHeader;	
sl@0
    92
	
sl@0
    93
		// Unload the DecoderPU
sl@0
    94
	if (iDecoderPU)
sl@0
    95
		{
sl@0
    96
		iPuLoader->UnloadProcessingUnit(iDecoderPU);
sl@0
    97
		}
sl@0
    98
		
sl@0
    99
	delete iPuLoader;	
sl@0
   100
	delete iPuData;
sl@0
   101
	delete iManufacturer;
sl@0
   102
	REComSession::DestroyedImplementation(iPuLoaderDtorKey);			
sl@0
   103
sl@0
   104
	iInputVidFormats.ResetAndDestroy(); // will destroy contents as well
sl@0
   105
	iOutputVidFormats.Close();
sl@0
   106
	iPictureRates.Close();
sl@0
   107
sl@0
   108
	DEBUG_PRINT(_L("HwDevice: Destroyed"));
sl@0
   109
	}
sl@0
   110
sl@0
   111
/*
sl@0
   112
 @see CMMFVideoHwDevice::CustomInterface()
sl@0
   113
 */
sl@0
   114
TAny* CMdfVideoDecodeHwDeviceAdapter::CustomInterface(TUid aInterface)
sl@0
   115
	{
sl@0
   116
	if (aInterface.iUid == KUidDevVideoHwDeviceAdapterSetup)
sl@0
   117
		{
sl@0
   118
		return static_cast<MDevVideoHwDeviceAdapterSetup*>(this);
sl@0
   119
		}
sl@0
   120
	return NULL;
sl@0
   121
	}
sl@0
   122
sl@0
   123
/*
sl@0
   124
 @see CMMFVideoPlayHwDevice::PostProcessorInfoLC()
sl@0
   125
 */
sl@0
   126
CPostProcessorInfo* CMdfVideoDecodeHwDeviceAdapter::PostProcessorInfoLC()
sl@0
   127
	{
sl@0
   128
	// post processor info will be obtained from the post processor plugin, if any
sl@0
   129
	return NULL;
sl@0
   130
	}
sl@0
   131
sl@0
   132
/*
sl@0
   133
 @see CMMFVideoPlayHwDevice::GetOutputFormatListL()
sl@0
   134
 */
sl@0
   135
void CMdfVideoDecodeHwDeviceAdapter::GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats)
sl@0
   136
	{
sl@0
   137
	// TUncompressedVideoFormats is a union - therefore using hard initialisation
sl@0
   138
	iOutputVidFormats.Reset();
sl@0
   139
	TUncompressedVideoFormat outputFormats[KOutputFormatsArraySize];
sl@0
   140
	
sl@0
   141
	outputFormats[0].iDataFormat = ERgbRawData;
sl@0
   142
	outputFormats[0].iRgbFormat = ERgb16bit565;
sl@0
   143
	iOutputVidFormats.AppendL(outputFormats[0]);
sl@0
   144
	aFormats.AppendL(outputFormats[0]);
sl@0
   145
	
sl@0
   146
	outputFormats[1].iDataFormat = ERgbFbsBitmap;
sl@0
   147
	outputFormats[1].iRgbFormat = EFbsBitmapColor16M;
sl@0
   148
	iOutputVidFormats.AppendL(outputFormats[1]);
sl@0
   149
	aFormats.AppendL(outputFormats[1]);
sl@0
   150
	
sl@0
   151
	outputFormats[2].iDataFormat = EYuvRawData;
sl@0
   152
	iOutputVidFormats.AppendL(outputFormats[2]);
sl@0
   153
	aFormats.AppendL(outputFormats[2]);
sl@0
   154
	}
sl@0
   155
sl@0
   156
/*
sl@0
   157
 @see CMMFVideoPlayHwDevice::SetOutputFormatL()
sl@0
   158
 */
sl@0
   159
void CMdfVideoDecodeHwDeviceAdapter::SetOutputFormatL(const TUncompressedVideoFormat& aFormat)
sl@0
   160
	{
sl@0
   161
	// check size and format are supported
sl@0
   162
	if(iOutputVidFormats.Count() == 0) 
sl@0
   163
		{
sl@0
   164
		User::Leave(KErrNotReady);
sl@0
   165
		}
sl@0
   166
	if(!iOutputVidFormats.Find(aFormat)) 
sl@0
   167
		{
sl@0
   168
		User::Leave(KErrNotSupported);
sl@0
   169
		}
sl@0
   170
	
sl@0
   171
	iFormat = aFormat;
sl@0
   172
	TDevVideoPlayPuConfig decodeConfig;
sl@0
   173
	decodeConfig.iImageFormat = iFormat;		
sl@0
   174
	decodeConfig.iInputBufferSize = KInputBufferSize;	
sl@0
   175
	TPuConfigVideoPlayback puConfig(decodeConfig);
sl@0
   176
sl@0
   177
	User::LeaveIfError(iDecoderPU->Configure(puConfig));
sl@0
   178
	}
sl@0
   179
sl@0
   180
/*
sl@0
   181
 @see CMMFVideoPlayHwDevice::SetClockSource()
sl@0
   182
 */
sl@0
   183
void CMdfVideoDecodeHwDeviceAdapter::SetClockSource(MMMFClockSource* aClock)
sl@0
   184
	{
sl@0
   185
	iClockSource = aClock;
sl@0
   186
	}
sl@0
   187
sl@0
   188
/*
sl@0
   189
 @see CMMFVideoPlayHwDevice::SetVideoDestScreenL()
sl@0
   190
 */
sl@0
   191
void CMdfVideoDecodeHwDeviceAdapter::SetVideoDestScreenL(TBool aScreen)
sl@0
   192
	{
sl@0
   193
	if(aScreen) 
sl@0
   194
		{
sl@0
   195
		// NB we expect the output format to have been set before this is called
sl@0
   196
		if(!iFormat.iDataFormat) 
sl@0
   197
			{
sl@0
   198
			User::Leave(KErrNotReady);
sl@0
   199
			}
sl@0
   200
	
sl@0
   201
		// we support only bitmaps for DSA, not raw data
sl@0
   202
		if(iFormat.iDataFormat != ERgbFbsBitmap) 
sl@0
   203
			{
sl@0
   204
			User::Leave(KErrNotSupported);
sl@0
   205
			}
sl@0
   206
		}
sl@0
   207
	
sl@0
   208
	// ETrue = use DSA
sl@0
   209
	iDSAEnabled = aScreen;
sl@0
   210
	}
sl@0
   211
sl@0
   212
/*
sl@0
   213
 @see CMMFVideoPlayHwDevice::SetPostProcessTypesL()
sl@0
   214
 */
sl@0
   215
void CMdfVideoDecodeHwDeviceAdapter::SetPostProcessTypesL(TUint32 /* aPostProcCombination */)
sl@0
   216
	{
sl@0
   217
	// the decoder is not configurable
sl@0
   218
	User::Leave(KErrNotSupported);
sl@0
   219
	}
sl@0
   220
sl@0
   221
/*
sl@0
   222
 @see CMMFVideoPlayHwDevice::SetInputCropOptionsL()
sl@0
   223
 */
sl@0
   224
void CMdfVideoDecodeHwDeviceAdapter::SetInputCropOptionsL(const TRect& /* aRect */)
sl@0
   225
	{
sl@0
   226
	// the decoder is not configurable
sl@0
   227
	User::Leave(KErrNotSupported);
sl@0
   228
	}
sl@0
   229
sl@0
   230
/*
sl@0
   231
 @see CMMFVideoPlayHwDevice::SetYuvToRgbOptionsL()
sl@0
   232
 */
sl@0
   233
void CMdfVideoDecodeHwDeviceAdapter::SetYuvToRgbOptionsL(const TYuvToRgbOptions& /* aOptions */, const TYuvFormat& /* aYuvFormat */, TRgbFormat /* aRgbFormat */)
sl@0
   234
	{
sl@0
   235
	// the decoder is not configurable
sl@0
   236
	User::Leave(KErrNotSupported);
sl@0
   237
	}
sl@0
   238
sl@0
   239
/*
sl@0
   240
 @see CMMFVideoPlayHwDevice::SetYuvToRgbOptionsL()
sl@0
   241
 */
sl@0
   242
void CMdfVideoDecodeHwDeviceAdapter::SetYuvToRgbOptionsL(const TYuvToRgbOptions& /* aOptions */)
sl@0
   243
	{
sl@0
   244
	// the decoder is not configurable
sl@0
   245
	User::Leave(KErrNotSupported);
sl@0
   246
	}
sl@0
   247
sl@0
   248
/*
sl@0
   249
 @see CMMFVideoPlayHwDevice::SetRotateOptionsL()
sl@0
   250
 */
sl@0
   251
void CMdfVideoDecodeHwDeviceAdapter::SetRotateOptionsL(TRotationType /* aRotationType */)
sl@0
   252
	{
sl@0
   253
	// the decoder is not configurable
sl@0
   254
	User::Leave(KErrNotSupported);
sl@0
   255
	}
sl@0
   256
sl@0
   257
/*
sl@0
   258
 @see CMMFVideoPlayHwDevice::SetScaleOptionsL()
sl@0
   259
 */
sl@0
   260
void CMdfVideoDecodeHwDeviceAdapter::SetScaleOptionsL(const TSize& /* aTargetSize */, TBool /* aAntiAliasFiltering */)
sl@0
   261
	{
sl@0
   262
	// the decoder is not configurable
sl@0
   263
	User::Leave(KErrNotSupported);
sl@0
   264
	}
sl@0
   265
sl@0
   266
/*
sl@0
   267
 @see CMMFVideoPlayHwDevice::SetOutputCropOptionsL()
sl@0
   268
 */
sl@0
   269
void CMdfVideoDecodeHwDeviceAdapter::SetOutputCropOptionsL(const TRect& /* aRect */)
sl@0
   270
	{
sl@0
   271
	// the decoder is not configurable
sl@0
   272
	User::Leave(KErrNotSupported);
sl@0
   273
	}
sl@0
   274
sl@0
   275
/*
sl@0
   276
 @see CMMFVideoPlayHwDevice::SetPostProcSpecificOptionsL()
sl@0
   277
 */
sl@0
   278
void CMdfVideoDecodeHwDeviceAdapter::SetPostProcSpecificOptionsL(const TDesC8& /* aOptions */)
sl@0
   279
	{
sl@0
   280
	// the decoder is not configurable
sl@0
   281
	User::Leave(KErrNotSupported);
sl@0
   282
	}
sl@0
   283
sl@0
   284
/*
sl@0
   285
 @see CMMFVideoPlayHwDevice::Initialize()
sl@0
   286
 */
sl@0
   287
void CMdfVideoDecodeHwDeviceAdapter::Initialize()
sl@0
   288
	{
sl@0
   289
	__ASSERT_ALWAYS(iProxy, DevVideoHwDeviceDecoderPanic(0));
sl@0
   290
sl@0
   291
	TRAPD(err, InitializeL());
sl@0
   292
	if(err == KErrNone && !iPUInitialized)
sl@0
   293
		{
sl@0
   294
		err = KErrNotSupported;		
sl@0
   295
		}	
sl@0
   296
	iProxy->MdvppInitializeComplete(this, err);
sl@0
   297
	}
sl@0
   298
sl@0
   299
// private method : body of Initialize()
sl@0
   300
void CMdfVideoDecodeHwDeviceAdapter::InitializeL()
sl@0
   301
	{
sl@0
   302
	// pre-check format
sl@0
   303
	switch(iFormat.iDataFormat) 
sl@0
   304
		{
sl@0
   305
		case 0:
sl@0
   306
			User::Leave(KErrNotReady);
sl@0
   307
			break;
sl@0
   308
		case ERgbRawData:
sl@0
   309
		case ERgbFbsBitmap:
sl@0
   310
		case EYuvRawData:
sl@0
   311
			break;
sl@0
   312
		default:
sl@0
   313
			User::Leave(KErrNotSupported);
sl@0
   314
			break;
sl@0
   315
		}
sl@0
   316
		
sl@0
   317
	// create and initialise the buffer manager
sl@0
   318
	iBufferManager = CMdfVideoDecoderBufferManager::NewL();
sl@0
   319
sl@0
   320
	iBufferManager->Init(iFormat);
sl@0
   321
	iBufferManager->SetFrameSize(iFrameSize);
sl@0
   322
	
sl@0
   323
	DEBUG_PRINT(_L("HwDevice: Buffer Manager initialized"));
sl@0
   324
sl@0
   325
	// The actual frame rate will come from the VOL headers.
sl@0
   326
	iFrameRate = KTenFPS;
sl@0
   327
	
sl@0
   328
	// reset the player flags
sl@0
   329
	iPrimed = EFalse;
sl@0
   330
	iInputBufferWaiting = EFalse;	
sl@0
   331
	iInputEnd = EFalse;
sl@0
   332
	
sl@0
   333
	// create the player engine
sl@0
   334
	iPlayerEngine = CMdfVideoPlayerEngine::NewL(*this);
sl@0
   335
sl@0
   336
	RPointerArray<MMdfInputPort> inputPorts;
sl@0
   337
	// Get ports and set observers
sl@0
   338
	User::LeaveIfError(iDecoderPU->GetInputPorts(inputPorts));
sl@0
   339
	if (inputPorts.Count()==0)
sl@0
   340
		{
sl@0
   341
		inputPorts.Close();
sl@0
   342
		User::Leave(KErrNotFound);
sl@0
   343
		}
sl@0
   344
	iDecoderPUInputPort = inputPorts[0];
sl@0
   345
	iDecoderPUInputPort->MipSetObserver(*this);
sl@0
   346
	inputPorts.Close();
sl@0
   347
sl@0
   348
	RPointerArray<MMdfOutputPort> outputPorts;
sl@0
   349
	User::LeaveIfError(iDecoderPU->GetOutputPorts(outputPorts));
sl@0
   350
	if (outputPorts.Count()==0)
sl@0
   351
		{
sl@0
   352
		outputPorts.Close();
sl@0
   353
		User::Leave(KErrNotFound);
sl@0
   354
		}
sl@0
   355
	iDecoderPUOutputPort = outputPorts[0];
sl@0
   356
	iDecoderPUOutputPort->MopSetObserver(*this);
sl@0
   357
	outputPorts.Close();
sl@0
   358
		
sl@0
   359
	iState = EProcessingUnitLoaded;
sl@0
   360
sl@0
   361
	DEBUG_PRINT(_L("HwDevice: Decoder Processing Unit Loaded"));
sl@0
   362
	
sl@0
   363
	// Create the buffers that are associated with the input and output ports
sl@0
   364
	iInputBuffer = &iBufferManager->CreateDataBufferL(iDecoderPUInputPort->MipBufferSize());
sl@0
   365
	iPUInputBuffer = *iInputBuffer;
sl@0
   366
	User::LeaveIfError(iDecoderPUInputPort->MipUseBuffer(*iPUInputBuffer));		
sl@0
   367
	
sl@0
   368
	CVideoFrameBuffer& frameBuffer = iBufferManager->CreateFrameBufferL(TMMFDisplayModeUtils::DisplayMode(iFormat.iRgbFormat));
sl@0
   369
	User::LeaveIfError(iDecoderPUOutputPort->MopUseBuffer(frameBuffer));
sl@0
   370
	
sl@0
   371
	// VD: should not move the set up of the state after sending the Initialize() calls???
sl@0
   372
	iState = EProcessingUnitInitializing;
sl@0
   373
sl@0
   374
	// async call, that calls back to InitializeComplete()
sl@0
   375
	iDecoderPU->Initialize();	
sl@0
   376
		
sl@0
   377
	DEBUG_PRINT(_L("HwDevice: Initialized OK"));
sl@0
   378
	}
sl@0
   379
sl@0
   380
/*
sl@0
   381
 @see CMMFVideoPlayHwDevice::StartDirectScreenAccessL()
sl@0
   382
 */
sl@0
   383
void CMdfVideoDecodeHwDeviceAdapter::StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& aScreenDevice, const TRegion& aClipRegion)
sl@0
   384
	{
sl@0
   385
	// ensure SetVideoDestScreenL() has been called
sl@0
   386
	if(!iDSAEnabled)
sl@0
   387
		{
sl@0
   388
		User::Leave(KErrNotReady);
sl@0
   389
		}
sl@0
   390
	
sl@0
   391
	DEBUG_PRINT(_L("HwDevice: Starting DSA"));
sl@0
   392
sl@0
   393
	iDSAStarted = ETrue;
sl@0
   394
sl@0
   395
	// the CDirectScreenAccess must be created by the client app.
sl@0
   396
	// the CFbsScreenDevice (only) is passed across...
sl@0
   397
	// we need to blit the bitmap into it, i.e. we need to create our own GC
sl@0
   398
	if(!iScreenDevice) 
sl@0
   399
		{		
sl@0
   400
		User::LeaveIfError(aScreenDevice.CreateContext(iScreenDeviceGc));
sl@0
   401
		iScreenDevice = &aScreenDevice;
sl@0
   402
		iScreenDeviceRect = aVideoRect;
sl@0
   403
		iScreenDeviceGc->SetClippingRegion(aClipRegion);
sl@0
   404
		}
sl@0
   405
	}
sl@0
   406
sl@0
   407
/*
sl@0
   408
 @see CMMFVideoPlayHwDevice::SetScreenClipRegion()
sl@0
   409
 */
sl@0
   410
void CMdfVideoDecodeHwDeviceAdapter::SetScreenClipRegion(const TRegion& aRegion)
sl@0
   411
	{
sl@0
   412
	__ASSERT_ALWAYS(iScreenDeviceGc, DevVideoHwDeviceDecoderPanic(0));
sl@0
   413
sl@0
   414
	iScreenDeviceGc->SetClippingRegion(aRegion);
sl@0
   415
	}
sl@0
   416
sl@0
   417
/*
sl@0
   418
 @see CMMFVideoPlayHwDevice::SetPauseOnClipFail()
sl@0
   419
 */
sl@0
   420
void CMdfVideoDecodeHwDeviceAdapter::SetPauseOnClipFail(TBool /* aPause */)
sl@0
   421
	{
sl@0
   422
	// not implemented - will pause by default
sl@0
   423
	}
sl@0
   424
sl@0
   425
/*
sl@0
   426
 @see CMMFVideoPlayHwDevice::AbortDirectScreenAccess()
sl@0
   427
 */
sl@0
   428
void CMdfVideoDecodeHwDeviceAdapter::AbortDirectScreenAccess()
sl@0
   429
	{
sl@0
   430
	DEBUG_PRINT(_L("HwDevice: Stopping DSA"));
sl@0
   431
	iDSAStarted = EFalse;
sl@0
   432
	}
sl@0
   433
sl@0
   434
/*
sl@0
   435
 @see CMMFVideoPlayHwDevice::IsPlaying()
sl@0
   436
 */
sl@0
   437
TBool CMdfVideoDecodeHwDeviceAdapter::IsPlaying()
sl@0
   438
	{
sl@0
   439
	return (iState == EProcessingUnitExecuting ? ETrue : EFalse);
sl@0
   440
	}
sl@0
   441
sl@0
   442
/*
sl@0
   443
 @see CMMFVideoPlayHwDevice::Redraw()
sl@0
   444
 */
sl@0
   445
void CMdfVideoDecodeHwDeviceAdapter::Redraw()
sl@0
   446
	{
sl@0
   447
	if(iDSAStarted) 
sl@0
   448
		{
sl@0
   449
		DisplayLastFrameDirect(); 
sl@0
   450
		}
sl@0
   451
	}
sl@0
   452
sl@0
   453
/*
sl@0
   454
 @see CMMFVideoPlayHwDevice::Start()
sl@0
   455
 */
sl@0
   456
void CMdfVideoDecodeHwDeviceAdapter::Start()
sl@0
   457
	{
sl@0
   458
	__ASSERT_ALWAYS(iPlayerEngine, DevVideoHwDeviceDecoderPanic(0));
sl@0
   459
	__ASSERT_ALWAYS(iDecoderPU, DevVideoHwDeviceDecoderPanic(0));
sl@0
   460
	
sl@0
   461
	if(iState != EProcessingUnitExecuting)
sl@0
   462
		{		
sl@0
   463
		CVideoFrameBuffer* frameBuffer = NULL;
sl@0
   464
		TRAPD(err, frameBuffer = &iBufferManager->GetEmptyFrameBufferL(ETrue));
sl@0
   465
		if (err != KErrNone)
sl@0
   466
			{
sl@0
   467
			iProxy->MdvppFatalError(this, err);
sl@0
   468
			return;
sl@0
   469
			}
sl@0
   470
		
sl@0
   471
		iDecoderPUOutputPort->MopReadData(*frameBuffer);
sl@0
   472
		
sl@0
   473
		iDecoderPU->Execute();
sl@0
   474
		TProcessingUnitState puState = iDecoderPU->State();
sl@0
   475
		if(puState == EProcessingUnitInvalid) 
sl@0
   476
			{
sl@0
   477
			return;	
sl@0
   478
			}
sl@0
   479
		iState = EProcessingUnitExecuting;
sl@0
   480
sl@0
   481
		// if we are using raw decoding, then play as fast as we can,
sl@0
   482
		// otherwise use the actual frame rate
sl@0
   483
		TInt playerFrameRate;
sl@0
   484
		if(iSynchronize) 
sl@0
   485
			{
sl@0
   486
			playerFrameRate = TInt(iFrameRate);
sl@0
   487
			}
sl@0
   488
		else 
sl@0
   489
			{
sl@0
   490
			playerFrameRate = CMdfVideoPlayerEngine::KUnsynchronized;
sl@0
   491
			}
sl@0
   492
		TRAP(err, iPlayerEngine->StartL(playerFrameRate));			
sl@0
   493
		if(err != KErrNone) 
sl@0
   494
			{
sl@0
   495
			// the player failed to start. this is a fatal error
sl@0
   496
			iProxy->MdvppFatalError(this, err);
sl@0
   497
			}
sl@0
   498
		else 
sl@0
   499
			{			
sl@0
   500
			iProxy->MdvppNewBuffers();
sl@0
   501
			}
sl@0
   502
		}
sl@0
   503
	}
sl@0
   504
sl@0
   505
/*
sl@0
   506
 @see CMMFVideoPlayHwDevice::Stop()
sl@0
   507
 */
sl@0
   508
void CMdfVideoDecodeHwDeviceAdapter::Stop()
sl@0
   509
	{
sl@0
   510
	if(iState == EProcessingUnitExecuting)
sl@0
   511
		{
sl@0
   512
		iPlayerEngine->Stop();
sl@0
   513
		iDecoderPU->Stop();		
sl@0
   514
		iState = EProcessingUnitIdle;
sl@0
   515
		}
sl@0
   516
	}
sl@0
   517
sl@0
   518
/*
sl@0
   519
 @see CMMFVideoPlayHwDevice::Pause()
sl@0
   520
 */
sl@0
   521
void CMdfVideoDecodeHwDeviceAdapter::Pause()
sl@0
   522
	{
sl@0
   523
	Stop();
sl@0
   524
	}
sl@0
   525
sl@0
   526
/*
sl@0
   527
 @see CMMFVideoPlayHwDevice::Resume()
sl@0
   528
 */
sl@0
   529
void CMdfVideoDecodeHwDeviceAdapter::Resume()
sl@0
   530
	{
sl@0
   531
	Start();
sl@0
   532
	}
sl@0
   533
sl@0
   534
/*
sl@0
   535
 @see CMMFVideoPlayHwDevice::SetPosition()
sl@0
   536
 */
sl@0
   537
void CMdfVideoDecodeHwDeviceAdapter::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
sl@0
   538
	{
sl@0
   539
	TPuConfigTimestamp timeStamp(aPlaybackPosition);
sl@0
   540
	// we have no way report a failure here, and it is not a fatal error so any error is ignored
sl@0
   541
	iDecoderPU->Configure(timeStamp);
sl@0
   542
	}
sl@0
   543
/*
sl@0
   544
 @see CMMFVideoPlayHwDevice::FreezePicture()
sl@0
   545
 */
sl@0
   546
void CMdfVideoDecodeHwDeviceAdapter::FreezePicture(const TTimeIntervalMicroSeconds& /* aTimestamp */)
sl@0
   547
	{
sl@0
   548
	// not supported; we have no presentation timestamps
sl@0
   549
	// however should not cause a fatal error
sl@0
   550
	}
sl@0
   551
sl@0
   552
/*
sl@0
   553
 @see CMMFVideoPlayHwDevice::ReleaseFreeze()
sl@0
   554
 */
sl@0
   555
void CMdfVideoDecodeHwDeviceAdapter::ReleaseFreeze(const TTimeIntervalMicroSeconds& /* aTimestamp */)
sl@0
   556
	{
sl@0
   557
	// not supported; we have no presentation timestamps
sl@0
   558
	// however should not cause a fatal error
sl@0
   559
	}
sl@0
   560
sl@0
   561
/*
sl@0
   562
 @see CMMFVideoPlayHwDevice::PlaybackPosition()
sl@0
   563
 */
sl@0
   564
TTimeIntervalMicroSeconds CMdfVideoDecodeHwDeviceAdapter::PlaybackPosition()
sl@0
   565
	{
sl@0
   566
	if(iFrameRate == 0.0) 
sl@0
   567
		{
sl@0
   568
		return 0;
sl@0
   569
		}
sl@0
   570
	// this is the total number of pictures displayed or discarded
sl@0
   571
	// NB it is NOT equivalent to the number of pictures decoded, as the
sl@0
   572
	// player may be running a few frames behind the decoder	
sl@0
   573
	return ((iPictureCounters.iPicturesDisplayed + iPictureCounters.iPicturesSkipped) * (KOneSecond / (TInt)iFrameRate));
sl@0
   574
	}
sl@0
   575
sl@0
   576
/*
sl@0
   577
 @see CMMFVideoPlayHwDevice::PictureBufferBytes()
sl@0
   578
 */
sl@0
   579
TUint CMdfVideoDecodeHwDeviceAdapter::PictureBufferBytes()
sl@0
   580
	{
sl@0
   581
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
   582
	
sl@0
   583
	return (iBufferManager->FrameBufferSize() * iBufferManager->MaxFrameBuffers());
sl@0
   584
	}
sl@0
   585
sl@0
   586
/*
sl@0
   587
 @see CMMFVideoPlayHwDevice::GetPictureCounters()
sl@0
   588
 */
sl@0
   589
void CMdfVideoDecodeHwDeviceAdapter::GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters)
sl@0
   590
	{
sl@0
   591
	aCounters = iPictureCounters;
sl@0
   592
	}
sl@0
   593
sl@0
   594
/*
sl@0
   595
 @see CMMFVideoPlayHwDevice::SetComplexityLevel()
sl@0
   596
 */
sl@0
   597
void CMdfVideoDecodeHwDeviceAdapter::SetComplexityLevel(TUint /* aLevel */)
sl@0
   598
	{
sl@0
   599
	// separate complexity levels are not available; ignored
sl@0
   600
	}
sl@0
   601
sl@0
   602
/*
sl@0
   603
 @see CMMFVideoPlayHwDevice::NumComplexityLevels()
sl@0
   604
 */
sl@0
   605
TUint CMdfVideoDecodeHwDeviceAdapter::NumComplexityLevels()
sl@0
   606
	{
sl@0
   607
	// separate complexity levels are not available; return 1
sl@0
   608
	return 1;
sl@0
   609
	}
sl@0
   610
sl@0
   611
/*
sl@0
   612
 @see CMMFVideoPlayHwDevice::GetComplexityLevelInfo()
sl@0
   613
 */
sl@0
   614
void CMdfVideoDecodeHwDeviceAdapter::GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo)
sl@0
   615
	{
sl@0
   616
	// ignore call if aLevel is not 0
sl@0
   617
	if(aLevel == 0) 
sl@0
   618
		{
sl@0
   619
		aInfo = iComplexityLevelInfo;
sl@0
   620
		}
sl@0
   621
	}
sl@0
   622
sl@0
   623
/*
sl@0
   624
 @see CMMFVideoPlayHwDevice::ReturnPicture()
sl@0
   625
 */
sl@0
   626
void CMdfVideoDecodeHwDeviceAdapter::ReturnPicture(TVideoPicture* aPicture)
sl@0
   627
	{
sl@0
   628
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
   629
sl@0
   630
	// return the frame buffer that has been emptied
sl@0
   631
	TRAPD(err, iBufferManager->ReturnFrameBufferL(*aPicture, CVideoFrameBuffer::EEmptied));
sl@0
   632
	if (err == KErrNone)
sl@0
   633
		{
sl@0
   634
		if (!iLastFrameBufferReceived)
sl@0
   635
			{
sl@0
   636
			
sl@0
   637
			// request the next empty frame buffer
sl@0
   638
			CVideoFrameBuffer* frameBuffer = NULL;
sl@0
   639
			TRAP(err, frameBuffer = &iBufferManager->GetEmptyFrameBufferL(ETrue));
sl@0
   640
			if (err == KErrNone)
sl@0
   641
				{
sl@0
   642
				CMMFBuffer* buffer = *frameBuffer;
sl@0
   643
				iDecoderPUOutputPort->MopReadData(*buffer);
sl@0
   644
				}
sl@0
   645
			}
sl@0
   646
		// DoPostPictureNotify() will handle MdvppStreamEnd()	
sl@0
   647
		}
sl@0
   648
	else
sl@0
   649
		{
sl@0
   650
		iProxy->MdvppFatalError(this, err);
sl@0
   651
		}
sl@0
   652
	ASSERT(err == KErrNone);
sl@0
   653
	DoPostPictureNotify();
sl@0
   654
	}
sl@0
   655
sl@0
   656
/*
sl@0
   657
 @see CMMFVideoPlayHwDevice::GetSnapshotL()
sl@0
   658
 */
sl@0
   659
TBool CMdfVideoDecodeHwDeviceAdapter::GetSnapshotL(TPictureData& /*aPictureData*/, const TUncompressedVideoFormat& /*aFormat*/)
sl@0
   660
	{
sl@0
   661
	// not supported - no presentation timestamps
sl@0
   662
	User::Leave(KErrNotSupported);
sl@0
   663
	return EFalse;
sl@0
   664
	}
sl@0
   665
sl@0
   666
/*
sl@0
   667
 @see CMMFVideoPlayHwDevice::GetTimedSnapshotL()
sl@0
   668
 */
sl@0
   669
void CMdfVideoDecodeHwDeviceAdapter::GetTimedSnapshotL(TPictureData* /*aPictureData*/, const TUncompressedVideoFormat& /*aFormat*/, const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/)
sl@0
   670
	{
sl@0
   671
	// this method should be called on the post processor not on the decoder
sl@0
   672
	// ending up here is a programming error and hence a PANIC condition
sl@0
   673
	DevVideoHwDeviceDecoderPanic(0);
sl@0
   674
	}
sl@0
   675
sl@0
   676
/*
sl@0
   677
 @see CMMFVideoPlayHwDevice::GetTimedSnapshotL()
sl@0
   678
 */
sl@0
   679
void CMdfVideoDecodeHwDeviceAdapter::GetTimedSnapshotL(TPictureData* /*aPictureData*/, const TUncompressedVideoFormat& /*aFormat*/, const TPictureId& /*aPictureId*/)
sl@0
   680
	{
sl@0
   681
	// this method should be called on the post processor not on the decoder
sl@0
   682
	// ending up here is a programming error and hence a PANIC condition
sl@0
   683
	DevVideoHwDeviceDecoderPanic(0);
sl@0
   684
	}
sl@0
   685
sl@0
   686
/*
sl@0
   687
 @see CMMFVideoPlayHwDevice::CancelTimedSnapshot()
sl@0
   688
 */
sl@0
   689
void CMdfVideoDecodeHwDeviceAdapter::CancelTimedSnapshot()
sl@0
   690
	{
sl@0
   691
	// this method should be called on the post processor not on the decoder
sl@0
   692
	// ending up here is a programming error and hence a PANIC condition
sl@0
   693
	DevVideoHwDeviceDecoderPanic(0);
sl@0
   694
	}
sl@0
   695
sl@0
   696
/*
sl@0
   697
 @see CMMFVideoPlayHwDevice::GetSupportedSnapshotFormatsL()
sl@0
   698
 */
sl@0
   699
void CMdfVideoDecodeHwDeviceAdapter::GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& /*aFormats*/)
sl@0
   700
	{
sl@0
   701
	// this method should be called on the post processor not on the decoder
sl@0
   702
	// ending up here is a programming error and hence a PANIC condition
sl@0
   703
	DevVideoHwDeviceDecoderPanic(0);
sl@0
   704
	}
sl@0
   705
sl@0
   706
/*
sl@0
   707
 @see CMMFVideoPlayHwDevice::InputEnd()
sl@0
   708
 */
sl@0
   709
void CMdfVideoDecodeHwDeviceAdapter::InputEnd()
sl@0
   710
	{
sl@0
   711
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
   712
sl@0
   713
	DEBUG_PRINT(_L("HwDevice: Input end"));
sl@0
   714
	
sl@0
   715
	iInputEnd = ETrue;
sl@0
   716
sl@0
   717
	// if there isn't an outstanding write to the PU, write
sl@0
   718
	// an empty buffer	
sl@0
   719
	if(!iWriteRequestOutstanding) 
sl@0
   720
		{
sl@0
   721
		SendLastBuffer();
sl@0
   722
		}
sl@0
   723
	}
sl@0
   724
sl@0
   725
/*
sl@0
   726
 @see CMMFVideoDecodeHwDevice::VideoDecoderInfoLC()
sl@0
   727
 */
sl@0
   728
CVideoDecoderInfo* CMdfVideoDecodeHwDeviceAdapter::VideoDecoderInfoLC()
sl@0
   729
	{
sl@0
   730
	// this is a complicated structure, ensure all fields are
sl@0
   731
	// filled with some valid value
sl@0
   732
	
sl@0
   733
	//if PU is not loaded panic
sl@0
   734
	if(iPuData == NULL)	
sl@0
   735
		{
sl@0
   736
		DevVideoHwDeviceDecoderPanic(KErrNotReady);	
sl@0
   737
		}
sl@0
   738
	// supported formats array
sl@0
   739
	iInputVidFormats.Reset();
sl@0
   740
	CCompressedVideoFormat* vidCV = NULL;
sl@0
   741
	vidCV = CCompressedVideoFormat::NewL(iPuData->InputDataType() , KNullDesC8);
sl@0
   742
	CleanupStack::PushL(vidCV);
sl@0
   743
	iInputVidFormats.AppendL(vidCV);
sl@0
   744
	CleanupStack::Pop(vidCV);	// CCompressedVideo object is destroyed in destructor
sl@0
   745
	
sl@0
   746
sl@0
   747
	// construct the video decoder info object
sl@0
   748
	CVideoDecoderInfo* vInfo = CVideoDecoderInfo::NewL(
sl@0
   749
		iPuUid, 
sl@0
   750
		*iManufacturer,
sl@0
   751
		KNullDesC,
sl@0
   752
		TVersion(KVideoDecoderInfoVersionMaj, KVideoDecoderInfoVersionMin, KVideoDecoderInfoVersionBuild),
sl@0
   753
		iInputVidFormats.Array(),
sl@0
   754
		EFalse, // not accelerated
sl@0
   755
		ETrue, // supports direct screen access
sl@0
   756
		iMaxPictureSize, 
sl@0
   757
		KMaxTUint32, // max bitrate supported
sl@0
   758
		iPuData->MaxPictureRates().Array(),
sl@0
   759
		EFalse, // picture loss not supported,
sl@0
   760
		EFalse, // slice loss not supported,
sl@0
   761
		KVideoDecoderInfoCSInfo,
sl@0
   762
		KVideoDecoderInfoISInfo );
sl@0
   763
sl@0
   764
	CleanupStack::PushL(vInfo);
sl@0
   765
	return vInfo;
sl@0
   766
	}
sl@0
   767
sl@0
   768
sl@0
   769
/*
sl@0
   770
 @see CMMFVideoDecodeHwDevice::GetHeaderInformationL()
sl@0
   771
 */
sl@0
   772
 
sl@0
   773
TVideoPictureHeader* CMdfVideoDecodeHwDeviceAdapter::GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TVideoInputBuffer* aDataUnit)
sl@0
   774
	{
sl@0
   775
	// NB this may be called EITHER before OR after the decoder is initialized.
sl@0
   776
	// ensure at least that SetOutputFormatL() has been called before this, 
sl@0
   777
	// as the decoder requires it to be able to initialize.
sl@0
   778
	
sl@0
   779
	__ASSERT_ALWAYS(iFormat.iDataFormat, DevVideoHwDeviceDecoderPanic(0));
sl@0
   780
	
sl@0
   781
	TDevVideoHeaderPuConfig header;
sl@0
   782
	header.iDataUnitType = aDataUnitType;
sl@0
   783
	header.iDataUnitEncapsulation = aEncapsulation;
sl@0
   784
	header.iHeaderData.Set(aDataUnit->iData.Ptr(),aDataUnit->iData.Size());
sl@0
   785
	
sl@0
   786
	TPuConfigVideoHeader headerConfig(header);
sl@0
   787
	
sl@0
   788
	// Configure the decoder with the Header Information
sl@0
   789
	User::LeaveIfError(iDecoderPU->Configure(headerConfig));
sl@0
   790
	
sl@0
   791
	// retrieve the picture information from the config structure
sl@0
   792
	
sl@0
   793
	TPuConfigVideoPictureHeader pict; 
sl@0
   794
	User::LeaveIfError(iDecoderPU->GetConfig(pict));
sl@0
   795
	
sl@0
   796
	delete iPictureHeader;
sl@0
   797
	iPictureHeader = NULL;
sl@0
   798
	// Create a new header from the returned data
sl@0
   799
	iPictureHeader = new (ELeave)TVideoPictureHeader(
sl@0
   800
							*TPuConfigVideoPictureHeader::GetStructure(pict));
sl@0
   801
	iFrameSize = iPictureHeader->iSizeInMemory;
sl@0
   802
	return iPictureHeader;
sl@0
   803
	
sl@0
   804
	}
sl@0
   805
sl@0
   806
/*
sl@0
   807
 @see CMMFVideoDecodeHwDevice::ConfigureDecoderL()
sl@0
   808
 */
sl@0
   809
void CMdfVideoDecodeHwDeviceAdapter::ConfigureDecoderL(const TVideoPictureHeader& /* aVideoPictureHeader */)
sl@0
   810
	{
sl@0
   811
	// there is nothing configurable
sl@0
   812
	User::Leave(KErrNotSupported);
sl@0
   813
	}
sl@0
   814
sl@0
   815
/*
sl@0
   816
 @see CMMFVideoDecodeHwDevice::ReturnHeader()
sl@0
   817
 */
sl@0
   818
void CMdfVideoDecodeHwDeviceAdapter::ReturnHeader(TVideoPictureHeader* aHeader)
sl@0
   819
	{
sl@0
   820
	if(aHeader == iPictureHeader) // only free our created header
sl@0
   821
		{
sl@0
   822
		delete iPictureHeader;
sl@0
   823
		iPictureHeader = NULL;	
sl@0
   824
		}
sl@0
   825
	}
sl@0
   826
sl@0
   827
/*
sl@0
   828
 @see CMMFVideoDecodeHwDevice::SetInputFormatL()
sl@0
   829
 */
sl@0
   830
void CMdfVideoDecodeHwDeviceAdapter::SetInputFormatL(const CCompressedVideoFormat& aFormat, TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TBool aDataInOrder)
sl@0
   831
	{
sl@0
   832
	// EDuCodedPicture, EDuElementaryStream, aDataInOrder == ETrue
sl@0
   833
	if(aFormat.MimeType() != iPuData->InputDataType()) 
sl@0
   834
		{
sl@0
   835
		User::Leave(KErrNotSupported);	
sl@0
   836
		}
sl@0
   837
	if(aDataUnitType != EDuCodedPicture) 
sl@0
   838
		{
sl@0
   839
		User::Leave(KErrNotSupported);	
sl@0
   840
		}
sl@0
   841
	if(aEncapsulation != EDuElementaryStream) 
sl@0
   842
		{
sl@0
   843
		User::Leave(KErrNotSupported);	
sl@0
   844
		}
sl@0
   845
	if(!aDataInOrder) 
sl@0
   846
		{
sl@0
   847
		User::Leave(KErrNotSupported);	
sl@0
   848
		}
sl@0
   849
	}
sl@0
   850
sl@0
   851
/*
sl@0
   852
 @see CMMFVideoDecodeHwDevice::SynchronizeDecoding()
sl@0
   853
 */
sl@0
   854
void CMdfVideoDecodeHwDeviceAdapter::SynchronizeDecoding(TBool aSynchronize)
sl@0
   855
	{
sl@0
   856
	iSynchronize = aSynchronize;
sl@0
   857
	}
sl@0
   858
sl@0
   859
/*
sl@0
   860
 @see CMMFVideoDecodeHwDevice::SetBufferOptionsL()
sl@0
   861
 */
sl@0
   862
void CMdfVideoDecodeHwDeviceAdapter::SetBufferOptionsL(const CMMFDevVideoPlay::TBufferOptions& aOptions)
sl@0
   863
	{
sl@0
   864
	// check values are within the constraints of this device
sl@0
   865
	if(aOptions.iPreDecoderBufferPeriod != 0) 
sl@0
   866
		{
sl@0
   867
		User::Leave(KErrNotSupported);
sl@0
   868
		}
sl@0
   869
	if(aOptions.iMaxPostDecodeBufferSize != 0) 
sl@0
   870
		{
sl@0
   871
		User::Leave(KErrNotSupported);
sl@0
   872
		}
sl@0
   873
	if(aOptions.iPreDecoderBufferPeriod != 0) 
sl@0
   874
		{
sl@0
   875
		User::Leave(KErrNotSupported);
sl@0
   876
		}
sl@0
   877
	if(aOptions.iPostDecoderBufferPeriod != 0) 
sl@0
   878
		{
sl@0
   879
		User::Leave(KErrNotSupported);
sl@0
   880
		}
sl@0
   881
	if(aOptions.iMaxInputBufferSize > KVideoDecoderMaxDataBufferSize) 
sl@0
   882
		{
sl@0
   883
		User::Leave(KErrNotSupported);
sl@0
   884
		}
sl@0
   885
	if(aOptions.iMinNumInputBuffers > 1) 
sl@0
   886
		{
sl@0
   887
		User::Leave(KErrNotSupported);
sl@0
   888
		}
sl@0
   889
	// input is OK; write it
sl@0
   890
	iBufferOptions = aOptions;	
sl@0
   891
	}
sl@0
   892
sl@0
   893
/*
sl@0
   894
 @see CMMFVideoDecodeHwDevice::GetBufferOptions()
sl@0
   895
 */
sl@0
   896
void CMdfVideoDecodeHwDeviceAdapter::GetBufferOptions(CMMFDevVideoPlay::TBufferOptions& aOptions)
sl@0
   897
	{
sl@0
   898
	aOptions = iBufferOptions;	
sl@0
   899
	}
sl@0
   900
sl@0
   901
/*
sl@0
   902
 @see CMMFVideoDecodeHwDevice::SetHrdVbvSpec()
sl@0
   903
 */
sl@0
   904
void CMdfVideoDecodeHwDeviceAdapter::SetHrdVbvSpec(THrdVbvSpecification /* aHrdVbvSpec */, const TDesC8& /* aHrdVbvParams */)
sl@0
   905
	{
sl@0
   906
	// the decoder is not configurable
sl@0
   907
	// however this should not cause a fatal error
sl@0
   908
	}
sl@0
   909
sl@0
   910
/*
sl@0
   911
 @see CMMFVideoDecodeHwDevice::SetOutputDevice()
sl@0
   912
 */
sl@0
   913
void CMdfVideoDecodeHwDeviceAdapter::SetOutputDevice(CMMFVideoPostProcHwDevice* aDevice)
sl@0
   914
	{
sl@0
   915
	// we allow output to be sent to a post-processor,
sl@0
   916
	// even though this plugin doesn not itself provide one
sl@0
   917
	iPostProcOutputDevice = aDevice;
sl@0
   918
	}
sl@0
   919
sl@0
   920
/*
sl@0
   921
 @see CMMFVideoDecodeHwDevice::DecodingPosition()
sl@0
   922
 */
sl@0
   923
TTimeIntervalMicroSeconds CMdfVideoDecodeHwDeviceAdapter::DecodingPosition()
sl@0
   924
	{
sl@0
   925
	if(iFrameRate == 0.0) 
sl@0
   926
		{
sl@0
   927
		return 0;
sl@0
   928
		}
sl@0
   929
	// this is the total number of pictures decoded	
sl@0
   930
	return (iPictureCounters.iPicturesDecoded * (KOneSecond / (TInt)iFrameRate));
sl@0
   931
	}
sl@0
   932
sl@0
   933
/*
sl@0
   934
 @see CMMFVideoDecodeHwDevice::PreDecoderBufferBytes()
sl@0
   935
 */
sl@0
   936
TUint CMdfVideoDecodeHwDeviceAdapter::PreDecoderBufferBytes()
sl@0
   937
	{
sl@0
   938
	return 0;
sl@0
   939
	}
sl@0
   940
sl@0
   941
/*
sl@0
   942
 @see CMMFVideoDecodeHwDevice::GetBitstreamCounters()
sl@0
   943
 */
sl@0
   944
void CMdfVideoDecodeHwDeviceAdapter::GetBitstreamCounters(CMMFDevVideoPlay::TBitstreamCounters& aCounters)
sl@0
   945
	{
sl@0
   946
	aCounters = iBitstreamCounters;
sl@0
   947
	}
sl@0
   948
sl@0
   949
/*
sl@0
   950
 @see CMMFVideoDecodeHwDevice::NumFreeBuffers()
sl@0
   951
 */
sl@0
   952
TUint CMdfVideoDecodeHwDeviceAdapter::NumFreeBuffers()
sl@0
   953
	{
sl@0
   954
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
   955
sl@0
   956
	if(!FrameBufferAvailable()) 
sl@0
   957
		{
sl@0
   958
		// if there are too many output buffers waiting, we refuse an input buffer
sl@0
   959
		// until some output buffers have been processed.
sl@0
   960
		return 0;
sl@0
   961
		}
sl@0
   962
	else 
sl@0
   963
		{
sl@0
   964
		return (iBufferManager->DataBuffersAvailable());
sl@0
   965
		}
sl@0
   966
	}
sl@0
   967
sl@0
   968
/*
sl@0
   969
 @see CMMFVideoDecodeHwDevice::GetBufferL()
sl@0
   970
 
sl@0
   971
 This will return a buffer of the requested size, within min/max constraints
sl@0
   972
 */
sl@0
   973
TVideoInputBuffer* CMdfVideoDecodeHwDeviceAdapter::GetBufferL(TUint /* aBufferSize */)
sl@0
   974
	{
sl@0
   975
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
   976
sl@0
   977
	TVideoInputBuffer& buf = iBufferManager->GetDataBufferL();
sl@0
   978
	return &buf;
sl@0
   979
	}
sl@0
   980
sl@0
   981
/*
sl@0
   982
 @see CMMFVideoDecodeHwDevice::WriteCodedDataL()
sl@0
   983
 */
sl@0
   984
void CMdfVideoDecodeHwDeviceAdapter::WriteCodedDataL(TVideoInputBuffer* aInputBuffer)
sl@0
   985
	{
sl@0
   986
	// Leave on null input buffer
sl@0
   987
	if(!aInputBuffer) 
sl@0
   988
		{
sl@0
   989
		User::Leave(KErrArgument);
sl@0
   990
		}
sl@0
   991
		
sl@0
   992
	// increment received buffer count
sl@0
   993
	iBitstreamCounters.iTotalPackets++;
sl@0
   994
	
sl@0
   995
	CMMFDataBuffer* dataBuffer = static_cast<CMMFDataBuffer*>(iPUInputBuffer);
sl@0
   996
	dataBuffer->Data().SetLength(aInputBuffer->iData.Length());
sl@0
   997
	dataBuffer->SetPosition(0);
sl@0
   998
	iDecoderPUInputPort->MipWriteData(*iPUInputBuffer);
sl@0
   999
	iWriteRequestOutstanding = ETrue;	
sl@0
  1000
	}
sl@0
  1001
	
sl@0
  1002
/*
sl@0
  1003
 @see CMMFVideoPlayHwDevice::CommitL()
sl@0
  1004
 */
sl@0
  1005
void CMdfVideoDecodeHwDeviceAdapter::CommitL()
sl@0
  1006
	{
sl@0
  1007
	// the decoder is not configurable
sl@0
  1008
	User::Leave(KErrNotSupported);
sl@0
  1009
	}
sl@0
  1010
	
sl@0
  1011
/*
sl@0
  1012
 @see CMMFVideoPlayHwDevice::Revert()
sl@0
  1013
 */
sl@0
  1014
void CMdfVideoDecodeHwDeviceAdapter::Revert()
sl@0
  1015
	{
sl@0
  1016
	// the decoder is not configurable
sl@0
  1017
	// however this should not cause a fatal error
sl@0
  1018
	}
sl@0
  1019
sl@0
  1020
void CMdfVideoDecodeHwDeviceAdapter::SetProxy(MMMFDevVideoPlayProxy& aProxy)
sl@0
  1021
	{
sl@0
  1022
	ASSERT(!iProxy);
sl@0
  1023
	iProxy = &aProxy;
sl@0
  1024
	}
sl@0
  1025
	
sl@0
  1026
sl@0
  1027
/*
sl@0
  1028
 @see MMdfDecoderHwDeviceObserver::FrameBufferAvailable()
sl@0
  1029
 */
sl@0
  1030
TBool CMdfVideoDecodeHwDeviceAdapter::FrameBufferAvailable() const
sl@0
  1031
	{
sl@0
  1032
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1033
sl@0
  1034
	return (iBufferManager->EmptyFrameBuffersAvailable() > 0);
sl@0
  1035
	}
sl@0
  1036
sl@0
  1037
/*
sl@0
  1038
 @see MMdfVideoPlayerHwDeviceObserver::Time()
sl@0
  1039
 */
sl@0
  1040
TUint CMdfVideoDecodeHwDeviceAdapter::Time() const 
sl@0
  1041
	{
sl@0
  1042
	
sl@0
  1043
	if(iClockSource) 
sl@0
  1044
		{
sl@0
  1045
		return iClockSource->Time().Int64();
sl@0
  1046
		}
sl@0
  1047
	else 
sl@0
  1048
		{
sl@0
  1049
		// system clock without HAL
sl@0
  1050
		TInt64 tt64;
sl@0
  1051
		TTime ttime;
sl@0
  1052
		ttime.HomeTime();
sl@0
  1053
		tt64 = ttime.Int64();
sl@0
  1054
		return (tt64 - iSystemClock);
sl@0
  1055
		}
sl@0
  1056
	}
sl@0
  1057
sl@0
  1058
/*
sl@0
  1059
 @see MMdfVideoPlayerHwDeviceObserver::DisplayFrame()
sl@0
  1060
 */
sl@0
  1061
void CMdfVideoDecodeHwDeviceAdapter::DisplayFrame()
sl@0
  1062
	{
sl@0
  1063
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1064
sl@0
  1065
	CVideoFrameBuffer* frameBuffer = NULL;
sl@0
  1066
	TRAPD(err, frameBuffer = &iBufferManager->GetFilledFrameBufferL(EFalse));
sl@0
  1067
	if(err != KErrNone) 
sl@0
  1068
		{
sl@0
  1069
		// the buffer manager has failed
sl@0
  1070
		DEBUG_PRINT(_L("HwDevice: Buffer Manager failed"));
sl@0
  1071
		iProxy->MdvppFatalError(this, err);
sl@0
  1072
		}
sl@0
  1073
	else	
sl@0
  1074
		{
sl@0
  1075
		// is this the last buffer?
sl@0
  1076
		iLastFrameBufferReceived = frameBuffer->LastBuffer();
sl@0
  1077
		
sl@0
  1078
		TVideoPicture& thePicture = *frameBuffer;
sl@0
  1079
		
sl@0
  1080
		// increment picture counter
sl@0
  1081
		CMMFBuffer& theBuffer = *frameBuffer;
sl@0
  1082
		if(theBuffer.BufferSize()) 
sl@0
  1083
			{
sl@0
  1084
			iPictureCounters.iPicturesDisplayed++;
sl@0
  1085
			}
sl@0
  1086
sl@0
  1087
		iDisplayPictureAvailable = EFalse;
sl@0
  1088
		
sl@0
  1089
		// send it to post-processor output, DSA, or the client
sl@0
  1090
		if(iPostProcOutputDevice) 
sl@0
  1091
			{
sl@0
  1092
			TRAP(err, iPostProcOutputDevice->WritePictureL(&thePicture));
sl@0
  1093
			}
sl@0
  1094
		else if(iDSAStarted) 
sl@0
  1095
			{
sl@0
  1096
			DisplayFrameDirect(&thePicture);
sl@0
  1097
			TRAP(err, iBufferManager->ReturnFrameBufferL(thePicture, CVideoFrameBuffer::EEmptied));
sl@0
  1098
		
sl@0
  1099
			if (!iLastFrameBufferReceived)
sl@0
  1100
				{
sl@0
  1101
				CVideoFrameBuffer* frameBuffer = NULL;
sl@0
  1102
				TRAP(err, frameBuffer = &iBufferManager->GetEmptyFrameBufferL(ETrue));
sl@0
  1103
				if (err == KErrNone)
sl@0
  1104
					{
sl@0
  1105
					iDecoderPUOutputPort->MopReadData(*frameBuffer);
sl@0
  1106
					}
sl@0
  1107
				else 
sl@0
  1108
					{
sl@0
  1109
					iProxy->MdvppFatalError(this, err);		
sl@0
  1110
					return;
sl@0
  1111
					}
sl@0
  1112
				}
sl@0
  1113
			// DoPostPictureNotify() will handle MdvppStreamEnd()	
sl@0
  1114
			// NB we need to notify the client here as there will be no callback
sl@0
  1115
			DoPostPictureNotify(); 
sl@0
  1116
			}
sl@0
  1117
		else 
sl@0
  1118
			{
sl@0
  1119
			iProxy->MdvppNewPicture(&thePicture);
sl@0
  1120
			}
sl@0
  1121
		}
sl@0
  1122
	}
sl@0
  1123
sl@0
  1124
/*
sl@0
  1125
 @see MMdfVideoPlayerHwDeviceObserver::DiscardFrame()
sl@0
  1126
 */
sl@0
  1127
void CMdfVideoDecodeHwDeviceAdapter::DiscardFrame()
sl@0
  1128
	{
sl@0
  1129
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1130
sl@0
  1131
	CVideoFrameBuffer* frameBuffer = NULL;
sl@0
  1132
	TVideoPicture* thePicture = NULL;
sl@0
  1133
	TRAPD(err, frameBuffer = &iBufferManager->GetFilledFrameBufferL(EFalse));
sl@0
  1134
	if(err != KErrNone) 
sl@0
  1135
		{
sl@0
  1136
		// the buffer manager has failed
sl@0
  1137
		DEBUG_PRINT(_L("HwDevice: Buffer Manager failed"));
sl@0
  1138
		iProxy->MdvppFatalError(this, err);
sl@0
  1139
		}
sl@0
  1140
	else	
sl@0
  1141
		{
sl@0
  1142
		thePicture = *frameBuffer;
sl@0
  1143
sl@0
  1144
		// increment picture counter
sl@0
  1145
		CMMFBuffer& theBuffer = *frameBuffer;
sl@0
  1146
		if(theBuffer.BufferSize()) 
sl@0
  1147
			{
sl@0
  1148
			iPictureCounters.iPicturesSkipped++;	
sl@0
  1149
			}
sl@0
  1150
sl@0
  1151
		iDisplayPictureAvailable = EFalse;
sl@0
  1152
sl@0
  1153
		// this should never leave, as thePicture has been given to us by 
sl@0
  1154
		// iBufferManager to start with.
sl@0
  1155
		TRAP(err, iBufferManager->ReturnFrameBufferL(*thePicture, CVideoFrameBuffer::EEmptied));
sl@0
  1156
		if (err != KErrNone)
sl@0
  1157
			{			
sl@0
  1158
			DEBUG_PRINT(_L("HwDevice: ReturnFrameBufferL failed"));
sl@0
  1159
			iProxy->MdvppFatalError(this, err);
sl@0
  1160
			}		
sl@0
  1161
sl@0
  1162
		TRAP(err, frameBuffer = &iBufferManager->GetEmptyFrameBufferL(ETrue));
sl@0
  1163
		if (err == KErrNone)
sl@0
  1164
			{
sl@0
  1165
			iDecoderPUOutputPort->MopReadData(*frameBuffer);
sl@0
  1166
			}
sl@0
  1167
	
sl@0
  1168
		// NB we need to notify the client here as there will be no callback
sl@0
  1169
		DoPostPictureNotify(); 
sl@0
  1170
		}
sl@0
  1171
	}
sl@0
  1172
sl@0
  1173
/*
sl@0
  1174
 @see MMdfVideoPlayerHwDeviceObserver::FrameAvailable()
sl@0
  1175
 */
sl@0
  1176
TBool CMdfVideoDecodeHwDeviceAdapter::FrameAvailable() const
sl@0
  1177
	{
sl@0
  1178
	return iDisplayPictureAvailable;
sl@0
  1179
	}
sl@0
  1180
	
sl@0
  1181
/*
sl@0
  1182
 @see MMdfInputPortObserver::MipoWriteDataComplete()
sl@0
  1183
 */
sl@0
  1184
void CMdfVideoDecodeHwDeviceAdapter::MipoWriteDataComplete(const MMdfInputPort* aInputPort,
sl@0
  1185
		CMMFBuffer* /* aBuffer */, TInt aErrorCode)
sl@0
  1186
	{
sl@0
  1187
	iWriteRequestOutstanding = EFalse;
sl@0
  1188
	__ASSERT_ALWAYS(aInputPort == iDecoderPUInputPort, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1189
	if (aErrorCode != KErrNone)
sl@0
  1190
		{
sl@0
  1191
		iProxy->MdvppFatalError(this, aErrorCode);
sl@0
  1192
		return;
sl@0
  1193
		}
sl@0
  1194
	// Return the data buffer, the position tells us how much data
sl@0
  1195
	// was used	
sl@0
  1196
	if (!iInputEnd)
sl@0
  1197
		{
sl@0
  1198
		TRAPD(err, iBufferManager->ReturnDataBufferL(*iInputBuffer));
sl@0
  1199
		if(err == KErrNone)
sl@0
  1200
			{
sl@0
  1201
			iProxy->MdvppNewBuffers();
sl@0
  1202
			}	
sl@0
  1203
		else
sl@0
  1204
			{
sl@0
  1205
			iProxy->MdvppFatalError(this, err);
sl@0
  1206
			}
sl@0
  1207
		}
sl@0
  1208
	else
sl@0
  1209
		{
sl@0
  1210
		// Send an empty buffer to the decoder to signal the
sl@0
  1211
		// end of the stream
sl@0
  1212
		SendLastBuffer();
sl@0
  1213
		}
sl@0
  1214
	}
sl@0
  1215
	
sl@0
  1216
/*
sl@0
  1217
 @see MMdfInputPortObserver::MipoStopComplete()
sl@0
  1218
 */		
sl@0
  1219
void CMdfVideoDecodeHwDeviceAdapter::MipoDisconnectTunnelComplete(const MMdfInputPort* /* aInputPort */,
sl@0
  1220
	TInt /* aErrorCode */)
sl@0
  1221
	{	
sl@0
  1222
	}
sl@0
  1223
	
sl@0
  1224
/*
sl@0
  1225
 @see MMdfInputPortObserver::MipoRestartComplete()
sl@0
  1226
 */		
sl@0
  1227
void CMdfVideoDecodeHwDeviceAdapter::MipoRestartTunnelComplete(const MMdfInputPort* /* aInputPort */,
sl@0
  1228
	TInt /* aErrorCode */)
sl@0
  1229
	{	
sl@0
  1230
	}
sl@0
  1231
	
sl@0
  1232
/*
sl@0
  1233
 @see MMdfOutputPortObserver::MopoReadDataComplete()
sl@0
  1234
 */
sl@0
  1235
void CMdfVideoDecodeHwDeviceAdapter::MopoReadDataComplete(const MMdfOutputPort* aOutputPort,
sl@0
  1236
	CMMFBuffer* aBuffer, TInt aErrorCode)	
sl@0
  1237
	{
sl@0
  1238
	if(aErrorCode != KErrNone)
sl@0
  1239
		{
sl@0
  1240
		iProxy->MdvppFatalError(this, aErrorCode);
sl@0
  1241
		return;
sl@0
  1242
		}
sl@0
  1243
	
sl@0
  1244
	if(aOutputPort != iDecoderPUOutputPort)
sl@0
  1245
		{
sl@0
  1246
		iProxy->MdvppFatalError(this, KErrArgument);
sl@0
  1247
		return;
sl@0
  1248
		}
sl@0
  1249
		
sl@0
  1250
	// increment iPicturesDecoded
sl@0
  1251
	if(aBuffer->BufferSize())
sl@0
  1252
		{
sl@0
  1253
		iPictureCounters.iPicturesDecoded++; 
sl@0
  1254
		}
sl@0
  1255
sl@0
  1256
	iDisplayPictureAvailable = ETrue;
sl@0
  1257
	
sl@0
  1258
	TRAPD(err, iBufferManager->ReturnFrameBufferL(aBuffer, CVideoFrameBuffer::EFilled, aBuffer->LastBuffer()));
sl@0
  1259
	if(err != KErrNone)
sl@0
  1260
		{
sl@0
  1261
		iProxy->MdvppFatalError(this, err);
sl@0
  1262
		}			
sl@0
  1263
	}
sl@0
  1264
sl@0
  1265
/*
sl@0
  1266
 @see MMdfOutputPortObserver::MopoStopComplete()
sl@0
  1267
 */	
sl@0
  1268
void CMdfVideoDecodeHwDeviceAdapter::MopoDisconnectTunnelComplete(const MMdfOutputPort* /* aOutputPort */,
sl@0
  1269
	TInt /* aErrorCode */)
sl@0
  1270
	{	
sl@0
  1271
	}
sl@0
  1272
sl@0
  1273
/*
sl@0
  1274
 @see MMdfOutputPortObserver::MopoRestartComplete()
sl@0
  1275
 */	
sl@0
  1276
void CMdfVideoDecodeHwDeviceAdapter::MopoRestartTunnelComplete(const MMdfOutputPort* /* aOutputPort */,
sl@0
  1277
	TInt /* aErrorCode */)
sl@0
  1278
	{	
sl@0
  1279
	}
sl@0
  1280
	
sl@0
  1281
/*
sl@0
  1282
 @see MMdfProcessingUnitObserver::InitializeComplete()
sl@0
  1283
 */	
sl@0
  1284
void CMdfVideoDecodeHwDeviceAdapter::InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode)
sl@0
  1285
	{
sl@0
  1286
	__ASSERT_ALWAYS(aPu == iDecoderPU, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1287
	
sl@0
  1288
	if(aErrorCode != KErrNone)
sl@0
  1289
		{
sl@0
  1290
		iProxy->MdvppFatalError(this, aErrorCode);
sl@0
  1291
		return;
sl@0
  1292
		}
sl@0
  1293
			
sl@0
  1294
	iPUInitialized = ETrue;	
sl@0
  1295
	}
sl@0
  1296
	
sl@0
  1297
/*
sl@0
  1298
 @see MMdfProcessingUnitObserver::ExecuteComplete()
sl@0
  1299
 */	
sl@0
  1300
void CMdfVideoDecodeHwDeviceAdapter::ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode)
sl@0
  1301
	{
sl@0
  1302
	__ASSERT_ALWAYS(aPu == iDecoderPU, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1303
	
sl@0
  1304
	if(aErrorCode != KErrNone)
sl@0
  1305
		{
sl@0
  1306
		iProxy->MdvppFatalError(this, aErrorCode);
sl@0
  1307
		return;
sl@0
  1308
		}	
sl@0
  1309
	
sl@0
  1310
	if (iState == EProcessingUnitExecuting)
sl@0
  1311
		{
sl@0
  1312
		DEBUG_PRINT(_L("HwDevice: 3() - Stream end"));
sl@0
  1313
		iProxy->MdvppStreamEnd();
sl@0
  1314
		iState = EProcessingUnitIdle;
sl@0
  1315
		}			
sl@0
  1316
	}	
sl@0
  1317
sl@0
  1318
// private method - DoPostPictureNotify
sl@0
  1319
void CMdfVideoDecodeHwDeviceAdapter::DoPostPictureNotify()
sl@0
  1320
	{
sl@0
  1321
	__ASSERT_ALWAYS(iBufferManager, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1322
sl@0
  1323
	DEBUG_PRINT(_L("HwDevice: PostPictureNotify"));
sl@0
  1324
	// notify the client that an input buffer is available if we weren't able to
sl@0
  1325
	// do it before
sl@0
  1326
	if(iInputBufferWaiting && iBufferManager->DataBuffersAvailable()) 
sl@0
  1327
		{
sl@0
  1328
		iInputBufferWaiting = EFalse;
sl@0
  1329
		iProxy->MdvppNewBuffers();
sl@0
  1330
		}
sl@0
  1331
	
sl@0
  1332
	// at this point, if there are no frames left, the input buffer is free
sl@0
  1333
	// and InputEnd() has been called, then we have finished.
sl@0
  1334
	if(iInputEnd && !iBufferManager->FilledFrameBuffersAvailable() && iBufferManager->DataBuffersAvailable()) 
sl@0
  1335
		{
sl@0
  1336
		iLastFrameBufferReceived = ETrue;
sl@0
  1337
		}
sl@0
  1338
		
sl@0
  1339
	// NB iLastFrameBufferReceived may have been set beforehand
sl@0
  1340
	if(iLastFrameBufferReceived)
sl@0
  1341
		{
sl@0
  1342
		DEBUG_PRINT(_L("HwDevice: Stream end"));
sl@0
  1343
		iProxy->MdvppStreamEnd();
sl@0
  1344
		}
sl@0
  1345
	}
sl@0
  1346
sl@0
  1347
// private method - display the frame using direct screen access
sl@0
  1348
void CMdfVideoDecodeHwDeviceAdapter::DisplayFrameDirect(TVideoPicture* aPicture) 
sl@0
  1349
	{
sl@0
  1350
	__ASSERT_ALWAYS(iScreenDevice, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1351
	
sl@0
  1352
	DEBUG_PRINT(_L("HwDevice: Displaying frame using DSA"));
sl@0
  1353
	// draw into our GC
sl@0
  1354
	// NB this will only work if the picture is a CFbsBitmap
sl@0
  1355
	CFbsBitmap* theBitmap = aPicture->iData.iRgbBitmap;
sl@0
  1356
	iScreenDeviceGc->DrawBitmap(iScreenDeviceRect, theBitmap);
sl@0
  1357
	iScreenDevice->Update();	
sl@0
  1358
	}
sl@0
  1359
	
sl@0
  1360
// private method - display the last frame using direct screen access
sl@0
  1361
void CMdfVideoDecodeHwDeviceAdapter::DisplayLastFrameDirect() 
sl@0
  1362
	{
sl@0
  1363
	__ASSERT_ALWAYS(iScreenDevice, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1364
sl@0
  1365
	DEBUG_PRINT(_L("HwDevice: Redrawing last frame using DSA"));
sl@0
  1366
	// redraw
sl@0
  1367
	// NB this will only work if the picture is a CFbsBitmap
sl@0
  1368
	const TPictureData* lastFrame = NULL;
sl@0
  1369
	TRAPD(err, lastFrame = &iBufferManager->LastPictureL());
sl@0
  1370
	if(!err) 
sl@0
  1371
		{
sl@0
  1372
		CFbsBitmap* theBitmap = lastFrame->iRgbBitmap;
sl@0
  1373
		iScreenDeviceGc->DrawBitmap(iScreenDeviceRect, theBitmap);
sl@0
  1374
		iScreenDevice->Update();
sl@0
  1375
		}
sl@0
  1376
	}
sl@0
  1377
sl@0
  1378
void CMdfVideoDecodeHwDeviceAdapter::LoadProcessingUnitL(const CImplementationInformation& aImplInfo)
sl@0
  1379
	{
sl@0
  1380
	__ASSERT_ALWAYS(iPuLoader, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1381
	iPuUid = aImplInfo.ImplementationUid();
sl@0
  1382
	iDecoderPU = iPuLoader->LoadProcessingUnitL(*this, iPuUid);	
sl@0
  1383
	// store the opaque data associated with this PU so we can extract information about 
sl@0
  1384
	// the PU later
sl@0
  1385
	iPuData = CCodecApiVideoOpaqueData::NewL(aImplInfo.OpaqueData());
sl@0
  1386
	iManufacturer = HBufC::NewL(iPuData->Manufacturer().Length());
sl@0
  1387
	iManufacturer->Des().Copy(iPuData->Manufacturer());
sl@0
  1388
	iMaxPictureSize = iPuData->MaxPictureSize();
sl@0
  1389
	}
sl@0
  1390
sl@0
  1391
void CMdfVideoDecodeHwDeviceAdapter::SendLastBuffer()
sl@0
  1392
	{
sl@0
  1393
	__ASSERT_ALWAYS(iPUInputBuffer, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1394
	__ASSERT_ALWAYS(iDecoderPUInputPort, DevVideoHwDeviceDecoderPanic(0));
sl@0
  1395
	// Send an empty buffer to the decoder to signal the
sl@0
  1396
	// end of the stream
sl@0
  1397
	iPUInputBuffer->SetLastBuffer(ETrue);
sl@0
  1398
	CMMFDataBuffer* dataBuffer = static_cast<CMMFDataBuffer*>(iPUInputBuffer);
sl@0
  1399
	dataBuffer->Data().SetLength(0);
sl@0
  1400
	dataBuffer->SetPosition(0);
sl@0
  1401
	iDecoderPUInputPort->MipWriteData(*iPUInputBuffer);	
sl@0
  1402
	}