mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp
branchGCC_SURGE
changeset 36 6320e299b97a
parent 34 31d6e1ae5283
child 38 4269ca484c7b
equal deleted inserted replaced
25:2efdf657cbe0 36:6320e299b97a
    97             iSurfaceCreatedEventPublished(EFalse),
    97             iSurfaceCreatedEventPublished(EFalse),
    98             iOverflowPictureCounter(0),
    98             iOverflowPictureCounter(0),
    99             iVideoFrameBufSize(0),
    99             iVideoFrameBufSize(0),
   100             iResourceLost(EFalse),
   100             iResourceLost(EFalse),
   101             iRedrawDone(EFalse),
   101             iRedrawDone(EFalse),
       
   102 			iRedrawSurfaceInUse(EFalse),
   102             iVBMObserver(NULL),
   103             iVBMObserver(NULL),
   103             count(0),
   104             count(0),
   104             iSurfaceMask(surfaceHints::EAllowAllExternals),
   105             iSurfaceMask(surfaceHints::EAllowAllExternals),
   105             iSurfaceKey(TUid::Uid(surfaceHints::KSurfaceProtection)),
   106             iSurfaceKey(TUid::Uid(surfaceHints::KSurfaceProtection)),
   106             iVideoSurfaceObserver(NULL),
   107             iVideoSurfaceObserver(NULL),
   107             iVPObserver(NULL),
   108             iVPObserver(NULL),
   108             iPicSize(0,0),
   109             iPicSize(0,0),
       
   110 			iAspectRatioNum(1),
       
   111 			iAspectRatioDenom(1),
   109             iStepFrameCount(0),
   112             iStepFrameCount(0),
   110             iPlayRate(KDefPlayRate),
   113             iPlayRate(KDefPlayRate),
   111             iKeyFrameMode(EFalse),
   114             iKeyFrameMode(EFalse),
   112             iFPObserver(NULL)
   115             iFPObserver(NULL)
   113 {
   116 {
   177     if (iSurfaceHandler)
   180     if (iSurfaceHandler)
   178     {
   181     {
   179     	if(!iSurfaceId.IsNull())
   182     	if(!iSurfaceId.IsNull())
   180     	{
   183     	{
   181     		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this);
   184     		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this);
   182     		iWsSession.UnregisterSurface(0, iSurfaceId);
   185 			TInt numScreens = iWsSession.NumberOfScreens();
       
   186     		for(TInt i=0;i < numScreens;i++)
       
   187     		{
       
   188     			iWsSession.UnregisterSurface(i, iSurfaceId);
       
   189     		}
       
   190     		iWsSession.Flush();
   183         	iSurfaceHandler->DestroySurface(iSurfaceId);
   191         	iSurfaceHandler->DestroySurface(iSurfaceId);
   184     	}
   192     	}
   185         delete iSurfaceHandler;
   193         delete iSurfaceHandler;
   186         iSurfaceHandler = NULL;
   194         iSurfaceHandler = NULL;
   187     }
   195     }
   405 	         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); 
   413 	         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); 
   406 	         iTimeToPost = ESkipIt;
   414 	         iTimeToPost = ESkipIt;
   407 	    }
   415 	    }
   408 		if(!iFirstPictureUpdated)
   416 		if(!iFirstPictureUpdated)
   409 		{
   417 		{
   410 			iTimeToPost = EPostIt;
   418             if(iTimeToPost == EDelayIt)
       
   419             {
       
   420                 iTimeToPost = EPostIt;
       
   421             }
   411 		}
   422 		}
   412 		switch(iTimeToPost)
   423 		switch(iTimeToPost)
   413 		{
   424 		{
   414 			case EDelayIt:
   425 			case EDelayIt:
   415 			{
   426 			{
   439 				iCurrentPlaybackPosition = pic->iTimestamp;			
   450 				iCurrentPlaybackPosition = pic->iTimestamp;			
   440 			
   451 			
   441 				if(!iFirstPictureUpdated)
   452 				if(!iFirstPictureUpdated)
   442 				{
   453 				{
   443 					iFirstPictureUpdated = ETrue;
   454 					iFirstPictureUpdated = ETrue;
   444 					PublishSurfaceCreated();
   455                     if(!iSurfaceCreatedEventPublished)
       
   456                     {
       
   457                         PublishSurfaceCreated();
       
   458                     }
   445 				}
   459 				}
   446 			}
   460 			}
   447 			break;
   461 			break;
   448 			case ESkipIt:
   462 			case ESkipIt:
   449 			{
   463 			{
   846 
   860 
   847 void CNGAPostProcHwDevice::Redraw() 
   861 void CNGAPostProcHwDevice::Redraw() 
   848 { 
   862 { 
   849 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw ++"), this);
   863 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw ++"), this);
   850 	TInt err = KErrNone;
   864 	TInt err = KErrNone;
   851 	if(iResourceLost && !iRedrawDone)
   865 	if(iRedrawSurfaceInUse && !iRedrawDone)
   852 	{
   866 	{
   853         err = AddHints();
   867         err = AddHints();
   854         if (err != KErrNone)
   868         if (err != KErrNone)
   855         {
   869         {
   856             PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost -- failed to AddHints %d"), 
   870             PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw -- failed to AddHints %d"), 
   857                          this, err);
   871                          this, err);
   858             iProxy->MdvppFatalError(this, err);	
   872             iProxy->MdvppFatalError(this, err);	
   859             return;   
   873             return;   
   860         }
   874         }
   861         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw registering the temp surface"), this);
   875         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw registering the temp surface"), this);
   862 		err = RegisterSurface(iSurfaceId);
   876 		err = RegisterSurface(iSurfaceId);
   863 		if (err != KErrNone)
   877 		if (err != KErrNone)
   864 		{
   878 		{
   865 		   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost -- failed to Register Surface %d"), 
   879 		   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw -- failed to Register Surface %d"), 
   866 		   				this, err);
   880 		   				this, err);
   867 		   	iSurfaceHandler->DestroySurface(iSurfaceId);
   881 		   	iSurfaceHandler->DestroySurface(iSurfaceId);
   868 	   		iSurfaceId = TSurfaceId::CreateNullId();
   882 	   		iSurfaceId = TSurfaceId::CreateNullId();
   869 			iProxy->MdvppFatalError(this, err);	
   883 			iProxy->MdvppFatalError(this, err);	
   870 			return;   				
   884 			return;   				
   924     if (iPPState == EInitializing)
   938     if (iPPState == EInitializing)
   925     { 
   939     { 
   926 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition FAILED: Unexpected state"), this);
   940 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition FAILED: Unexpected state"), this);
   927         return;
   941         return;
   928     }
   942     }
   929     
   943     if (iPPState == EPaused)
       
   944     {	
       
   945         iFirstPictureUpdated = EFalse;
       
   946     }
   930     iCurrentPlaybackPosition = aPlaybackPosition;  
   947     iCurrentPlaybackPosition = aPlaybackPosition;  
   931     
   948     
   932     ReleaseInputQ();
   949     ReleaseInputQ();
   933 
   950 
   934    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition --"), this);
   951    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition --"), this);
  1402 		aCropRect = TRect(0, 0, iInfo().iSize.iWidth, iInfo().iSize.iHeight);
  1419 		aCropRect = TRect(0, 0, iInfo().iSize.iWidth, iInfo().iSize.iHeight);
  1403 		if((iPicSize.iWidth > 0) && (iPicSize.iHeight > 0))
  1420 		if((iPicSize.iWidth > 0) && (iPicSize.iHeight > 0))
  1404 		{
  1421 		{
  1405 			aCropRect.Intersection( iPicSize);
  1422 			aCropRect.Intersection( iPicSize);
  1406 		}
  1423 		}
  1407 	aPixelAspectRatio = TVideoAspectRatio(1,1);
  1424 	aPixelAspectRatio = TVideoAspectRatio(iAspectRatioNum,iAspectRatioDenom);
  1408 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL()--  \
  1425 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL()  \
  1409 		cropRectWidth = %d cropRectHeight = %d --"), this, aCropRect.Width(), aCropRect.Height());
  1426 		cropRectWidth = %d cropRectHeight = %d"), this, aCropRect.Width(), aCropRect.Height());
  1410 
  1427 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL()  \
       
  1428 		PAR Num = %d PAR Denom = %d"), this, aPixelAspectRatio.iNumerator, aPixelAspectRatio.iDenominator);
       
  1429 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() --"), this);
  1411 }
  1430 }
  1412 
  1431 
  1413 void CNGAPostProcHwDevice::MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId)
  1432 void CNGAPostProcHwDevice::MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId)
  1414 {
  1433 {
  1415 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this);
  1434 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this);
  1416 	if(!aSurfaceId.IsNull())
  1435 	if(!aSurfaceId.IsNull())
  1417 	{
  1436 	{
  1418 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId );
  1437 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId );
  1419 		iWsSession.UnregisterSurface(0, iSurfaceId);
  1438 		TInt numScreens = iWsSession.NumberOfScreens();
       
  1439 		for(TInt i=0;i < numScreens;i++)
       
  1440 		{
       
  1441 			iWsSession.UnregisterSurface(i, aSurfaceId);
       
  1442 		}
       
  1443 		iWsSession.Flush();
  1420 		iSurfaceHandler->DestroySurface(aSurfaceId);
  1444 		iSurfaceHandler->DestroySurface(aSurfaceId);
  1421 	}
  1445 		if(iSurfaceId == aSurfaceId)
  1422 		
  1446 		{
       
  1447 			iSurfaceCreatedEventPublished = EFalse;
       
  1448 			iSurfaceId = TSurfaceId::CreateNullId();
       
  1449 			iChunk.Close();
       
  1450 		}
       
  1451 	}
  1423 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
  1452 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
  1424 }
  1453 }
  1425 
  1454 
  1426 // === MMmfVideoPropertiesObserver ===
  1455 // === MMmfVideoPropertiesObserver ===
  1427     
  1456     
  1429 {
  1458 {
  1430 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties ++"), this);
  1459 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties ++"), this);
  1431 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties PAR \
  1460 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties PAR \
  1432 		iAspectRatioNum = %d, iAspectRatioDenom = %d"), this,
  1461 		iAspectRatioNum = %d, iAspectRatioDenom = %d"), this,
  1433 					 aYuvFormat.iAspectRatioNum,aYuvFormat.iAspectRatioDenom);
  1462 					 aYuvFormat.iAspectRatioNum,aYuvFormat.iAspectRatioDenom);
  1434 					 iPicSize = aPictureSize;
  1463 	iPicSize = aPictureSize;
       
  1464 	iAspectRatioNum = aYuvFormat.iAspectRatioNum;
       
  1465 	iAspectRatioDenom = aYuvFormat.iAspectRatioDenom;
  1435 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties Picture Size \
  1466 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties Picture Size \
  1436 		iWidth = %d, iHeight = %d, iSurfaceCreatedEventPublished = %d"), 
  1467 		iWidth = %d, iHeight = %d, iSurfaceCreatedEventPublished = %d"), 
  1437 		this, iPicSize.iWidth,iPicSize.iHeight, iSurfaceCreatedEventPublished?1:0);
  1468 		this, iPicSize.iWidth,iPicSize.iHeight, iSurfaceCreatedEventPublished?1:0);
  1438 			 
  1469 			 
  1439 	if(iVPObserver)
  1470 	if(iVPObserver)
  1458 		iRedrawDone = EFalse;
  1489 		iRedrawDone = EFalse;
  1459 		Pause();
  1490 		Pause();
  1460 		ReleaseInputQ();
  1491 		ReleaseInputQ();
  1461 		iSessionManager->CancelUpdate();
  1492 		iSessionManager->CancelUpdate();
  1462 		ReleaseProcessQ();
  1493 		ReleaseProcessQ();
  1463 		iVideoSurfaceObserver->MmvsoRemoveSurface();
  1494 		if(iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
       
  1495 		{
       
  1496 			PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost - Telling client to remove surface"), this);
       
  1497 			iVideoSurfaceObserver->MmvsoRemoveSurface();
       
  1498 			iSurfaceCreatedEventPublished = EFalse;
       
  1499 		}
  1464 	}
  1500 	}
  1465 	else if(iResourceLost && iRedrawDone)
  1501 	else if(iResourceLost && iRedrawDone)
  1466 	{
  1502 	{
  1467 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost ResourceLost happening \
  1503 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost ResourceLost happening \
  1468 					while Postprocessor is already in ResourceLoss state"), 
  1504 					while Postprocessor is already in ResourceLoss state"), 
  1504     
  1540     
  1505 }
  1541 }
  1506 
  1542 
  1507 void CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer)
  1543 void CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer)
  1508 {
  1544 {
  1509     PP_DEBUG(_L("CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface ++"), this);
  1545     PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface ++"), this);
  1510 	
  1546 	
  1511 	TSize 			surfaceSize; 
       
  1512     TUint8*         lPtr;
  1547     TUint8*         lPtr;
  1513     TInt 			offset;
  1548     TInt 			offset;
  1514     if(iPicSize.iWidth > iPicSize.iHeight)
  1549 
  1515     {
  1550     PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface -- Creating %d x %d surface"), this, iPicSize.iWidth, iPicSize.iHeight);
  1516     	surfaceSize.iWidth = iPicSize.iWidth;
       
  1517     	surfaceSize.iHeight = iPicSize.iWidth;
       
  1518     }
       
  1519     else
       
  1520     {
       
  1521     	surfaceSize.iWidth = iPicSize.iHeight;
       
  1522     	surfaceSize.iHeight = iPicSize.iHeight;
       
  1523     }
       
  1524 
  1551 
  1525    	TInt err = KErrNone;
  1552    	TInt err = KErrNone;
  1526 	SetSurfaceAttributes(surfaceSize, 1); 
  1553 	SetSurfaceAttributes(iPicSize, 1); 
  1527 	
  1554 	
  1528   	err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId);
  1555   	err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId);
  1529   	if (err != KErrNone)
  1556   	if (err != KErrNone)
  1530 	{
  1557 	{
  1531 	   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to create Surface %d"), 
  1558 	   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to create Surface %d"), 
  1532 	   				this, err);
  1559 	   				this, err);
  1533 		iProxy->MdvppFatalError(this, err);	   				
  1560 		iProxy->MdvppFatalError(this, err);	   				
  1534 	    return;
  1561 	    return;
  1535 	}
  1562 	}
       
  1563 
       
  1564 	err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
       
  1565 	if (err != KErrNone)
       
  1566 	{
       
  1567 	   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"), 
       
  1568 	   				this, err);
       
  1569 	   	iSurfaceHandler->DestroySurface(iSurfaceId);
       
  1570 	   	iSurfaceId = TSurfaceId::CreateNullId();
       
  1571 		iProxy->MdvppFatalError(this, err);	   				
       
  1572 	    return;
       
  1573 	}
       
  1574 
       
  1575 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \
       
  1576 		surfaceWidth = %d surfaceHeight = %d surfaceStride = %d"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iInfo().iStride);
       
  1577 
       
  1578 	TInt redrawBufferSize = aRedrawBuffer.Size();
       
  1579 	TInt surfaceSize = iInfo().iStride * iInfo().iSize.iHeight;
       
  1580 
       
  1581     PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface RedrawBuffer size= %d Surface size = %d"), this, redrawBufferSize, surfaceSize);
       
  1582 
       
  1583 	// Check whether redraw buffer will fit onto the surface.
       
  1584 	// If this check fails then we won't raise a fatal error - We just won't create the redraw surface
       
  1585 	if (redrawBufferSize > surfaceSize)
       
  1586 	{
       
  1587     	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface Redraw buffer size larger than surface size"), this);
       
  1588     	iSurfaceHandler->DestroySurface(iSurfaceId);
       
  1589 	   	iSurfaceId = TSurfaceId::CreateNullId();
       
  1590     	return;
       
  1591 	}
       
  1592 
  1536 	err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk);
  1593 	err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk);
  1537 	if (err != KErrNone)
  1594 	if (err != KErrNone)
  1538 	{
  1595 	{
  1539 	   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to map Surface %d"), 
  1596 	   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to map Surface %d"), 
  1540 	   				this, err);
  1597 	   				this, err);
  1541 	   	iSurfaceHandler->DestroySurface(iSurfaceId);
  1598 	   	iSurfaceHandler->DestroySurface(iSurfaceId);
  1542 	   	iSurfaceId = TSurfaceId::CreateNullId();
  1599 	   	iSurfaceId = TSurfaceId::CreateNullId();
  1543 		iProxy->MdvppFatalError(this, err);	   				
  1600 		iProxy->MdvppFatalError(this, err);	   				
  1544 	    return;
  1601 	    return;
  1545 	}
  1602 	}
  1546 	err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
       
  1547 	if (err != KErrNone)
       
  1548 	{
       
  1549 	   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"), 
       
  1550 	   				this, err);
       
  1551 	   	iSurfaceHandler->DestroySurface(iSurfaceId);
       
  1552 	   	iSurfaceId = TSurfaceId::CreateNullId();
       
  1553 		iProxy->MdvppFatalError(this, err);	   				
       
  1554 	    return;
       
  1555 	}
       
  1556 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \
       
  1557 		surfaceWidth = %d surfaceHeight = %d --"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight);
       
  1558 
  1603 
  1559     if((err = iSurfaceHandler->GetBufferOffset(iSurfaceId, 0, offset)) != KErrNone)
  1604     if((err = iSurfaceHandler->GetBufferOffset(iSurfaceId, 0, offset)) != KErrNone)
  1560     {
  1605     {
  1561     	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset query failed %d"), this, err);
  1606     	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset query failed %d"), this, err);
  1562     	iSurfaceHandler->DestroySurface(iSurfaceId);
  1607     	iSurfaceHandler->DestroySurface(iSurfaceId);
  1563 	   	iSurfaceId = TSurfaceId::CreateNullId();
  1608 	   	iSurfaceId = TSurfaceId::CreateNullId();
       
  1609 		iChunk.Close();
  1564     	iProxy->MdvppFatalError(this, err);
  1610     	iProxy->MdvppFatalError(this, err);
  1565     	return;
  1611     	return;
  1566     }
  1612     }
  1567     PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d aRedrawBuffer.Size()= %d  --"), this, offset, aRedrawBuffer.Size());
  1613 
  1568     
  1614     PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d"), this, offset);
       
  1615 
  1569 	lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset);
  1616 	lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset);
  1570 	memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), aRedrawBuffer.Size());
  1617 	memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), redrawBufferSize);
  1571 	
  1618 
       
  1619 	iRedrawSurfaceInUse = ETrue;
       
  1620 
       
  1621 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface(): New surface = 0x%x"), this, iSurfaceId);
       
  1622 
  1572     PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface error = %d --"), this, err);
  1623     PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface error = %d --"), this, err);
  1573 }
  1624 }
  1574 
  1625 
  1575 TInt CNGAPostProcHwDevice::SetupExternalSurface(const TSurfaceId &aSurfaceID)
  1626 TInt CNGAPostProcHwDevice::SetupExternalSurface(const TSurfaceId &aSurfaceID)
  1576 {
  1627 {
       
  1628 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface(): aSurfaceID = 0x%x"), this, aSurfaceID );
       
  1629 
  1577     TInt err = KErrNone;
  1630     TInt err = KErrNone;
  1578     
  1631     
  1579     if(!iSurfaceId.IsNull())
  1632     if(!iSurfaceId.IsNull())
  1580     {
  1633     {
  1581     	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface Cleaning ReDraw Surface"), this);
  1634 		if (iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
  1582 		iVideoSurfaceObserver->MmvsoRemoveSurface();
  1635 		{
       
  1636 			PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Telling client to remove old surface"), this);
       
  1637 			iVideoSurfaceObserver->MmvsoRemoveSurface();
       
  1638 			iSurfaceCreatedEventPublished = EFalse;
       
  1639 		}
       
  1640 		else
       
  1641 		{
       
  1642 			// We never told the client about the surface, so we must destroy it ourselves
       
  1643 			PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Destroying old surface"), this);
       
  1644 			TInt numScreens = iWsSession.NumberOfScreens();
       
  1645     		for(TInt i=0;i < numScreens;i++)
       
  1646     		{
       
  1647     			iWsSession.UnregisterSurface(i, iSurfaceId);
       
  1648     		}
       
  1649    			iWsSession.Flush();
       
  1650 			iSurfaceHandler->DestroySurface(iSurfaceId);
       
  1651 		}
       
  1652 
       
  1653 		iChunk.Close();
  1583 	}
  1654 	}
  1584     
  1655     
  1585     iSurfaceId            = aSurfaceID;
  1656     iSurfaceId            = aSurfaceID;
  1586     iUsingExternalSurface = ETrue;
  1657     iUsingExternalSurface = ETrue;
  1587     
  1658     iRedrawSurfaceInUse = EFalse;
  1588     
  1659 
  1589     // Create the surface handler if it doesn't exist.
  1660     // Create the surface handler if it doesn't exist.
  1590     if (!iSurfaceHandler)
  1661     if (!iSurfaceHandler)
  1591     {
  1662     {
  1592         TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL());
  1663         TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL());
  1593         if (err != KErrNone)
  1664         if (err != KErrNone)
  1774 				iSessionManager->PostPicture(iSurfaceId, GetID(pic), iInfo().iBuffers, ETrue); 
  1845 				iSessionManager->PostPicture(iSurfaceId, GetID(pic), iInfo().iBuffers, ETrue); 
  1775 				iCurrentPlaybackPosition = pic->iTimestamp;						 					
  1846 				iCurrentPlaybackPosition = pic->iTimestamp;						 					
  1776 				if(!iFirstPictureUpdated)
  1847 				if(!iFirstPictureUpdated)
  1777 				{
  1848 				{
  1778 					iFirstPictureUpdated = ETrue;
  1849 					iFirstPictureUpdated = ETrue;
  1779 					PublishSurfaceCreated();
  1850                     if(!iSurfaceCreatedEventPublished)
       
  1851                     {
       
  1852                         PublishSurfaceCreated();
       
  1853                     }
  1780 				}	
  1854 				}	
  1781 			}	// end of postit
  1855 			}	// end of postit
  1782 			break;
  1856 			break;
  1783 			case ESkipIt: 
  1857 			case ESkipIt: 
  1784 			{
  1858 			{
  2023 }
  2097 }
  2024 
  2098 
  2025 TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId)
  2099 TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId)
  2026 {
  2100 {
  2027 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId);
  2101 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId);
  2028 	return(iWsSession.RegisterSurface(0, aSurfaceId));
  2102 	TInt err = KErrNone;
       
  2103 	TInt numScreens = iWsSession.NumberOfScreens();
       
  2104 	for(TInt i=0; (i < numScreens && err == KErrNone); i++)
       
  2105 	{
       
  2106 		err = iWsSession.RegisterSurface(i, aSurfaceId);
       
  2107 	}	
       
  2108 	return(err);
  2029 }
  2109 }
  2030 
  2110 
  2031 TInt CNGAPostProcHwDevice::IsGceReady()
  2111 TInt CNGAPostProcHwDevice::IsGceReady()
  2032 {
  2112 {
  2033     if(iProcessQ.Count() >= KMaxBuffersGceCanHold)
  2113     if(iProcessQ.Count() >= KMaxBuffersGceCanHold)
  2247 TInt CNGAPostProcHwDevice::AddHints()
  2327 TInt CNGAPostProcHwDevice::AddHints()
  2248 {
  2328 {
  2249    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints iSurfaceMask 0x%08x ++"), this, iSurfaceMask);
  2329    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints iSurfaceMask 0x%08x ++"), this, iSurfaceMask);
  2250    TInt err = KErrNone;
  2330    TInt err = KErrNone;
  2251    iHint.Set(iSurfaceKey,iSurfaceMask,ETrue);
  2331    iHint.Set(iSurfaceKey,iSurfaceMask,ETrue);
       
  2332    err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
       
  2333    if(err == KErrAlreadyExists)
       
  2334    {
       
  2335 		err = KErrNone;
       
  2336 		err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
       
  2337    }
       
  2338    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
       
  2339    iHint.iKey.iUid = surfaceHints::KSurfaceContent;
       
  2340    iHint.iValue = surfaceHints::EVideoPlayback;
       
  2341    iHint.iMutable = ETrue;
  2252    err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
  2342    err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
  2253    if(err == KErrAlreadyExists)
  2343    if(err == KErrAlreadyExists)
  2254    {
  2344    {
  2255 		err = KErrNone;
  2345 		err = KErrNone;
  2256 		err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
  2346 		err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);