javauis/mmapi_akn/baseline/src.nga/cmmasurfacewindow.cpp
branchRCL_3
changeset 19 04becd199f91
child 25 9ac0a0a7da70
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This class implements MMMADisplayWindow functionality
       
    15 *               in graphics surface based displays for Helix engine.
       
    16 *
       
    17 */
       
    18 
       
    19 //  Include Files
       
    20 #include "jdebug.h"
       
    21 #include "cmmasurfacewindow.h"
       
    22 #include "cmmaplayer.h"
       
    23 
       
    24 // Used for iDisplay member
       
    25 #include "mmmadisplay.h"
       
    26 
       
    27 CMMASurfaceWindow* CMMASurfaceWindow::NewL(
       
    28     CMMAEventSource* aEventSource,
       
    29     CMMAPlayer* aPlayer)
       
    30 {
       
    31     CMMASurfaceWindow* self =
       
    32         new(ELeave) CMMASurfaceWindow(aEventSource,
       
    33                                       aPlayer);
       
    34     return self;
       
    35 }
       
    36 
       
    37 // Destructor (virtual by CBase)
       
    38 CMMASurfaceWindow::~CMMASurfaceWindow()
       
    39 {
       
    40     // It's not allowed to delete any nonsharable object here.
       
    41     // This must be done in Destroy().
       
    42     // If the iDisplay is set,
       
    43     // instance should be deleted by sending
       
    44     // event from UI to be received by MUiEventConsumer.
       
    45 }
       
    46 
       
    47 CMMASurfaceWindow::CMMASurfaceWindow(
       
    48     CMMAEventSource* aEventSource,
       
    49     CMMAPlayer* aPlayer):
       
    50         iEventSource(aEventSource),
       
    51         iPlayer(aPlayer),
       
    52         iVideoDisplayInitState(EUIResourcesAndSurfaceParametersNotSet)
       
    53 {
       
    54     // Empty rect until video size is known
       
    55     iContentRect.SetRect(0, 0, 0, 0);
       
    56     iParentRect.SetRect(0, 0, 0, 0);
       
    57     iRWindowRect.SetRect(0, 0, 0, 0);
       
    58 }
       
    59 
       
    60 void CMMASurfaceWindow::SetDestinationBitmapL(CFbsBitmap* /*aBitmap*/)
       
    61 {
       
    62     // Ignored, this window will not be used for actual drawing
       
    63 }
       
    64 
       
    65 void CMMASurfaceWindow::DrawFrameL(const CFbsBitmap* /*aBitmap*/)
       
    66 {
       
    67     // Ignored, this window will not be used for actual drawing
       
    68 }
       
    69 
       
    70 void CMMASurfaceWindow::SetDrawRectThread(const TRect& aRect)
       
    71 {
       
    72     DEBUG_INT2("MID::CMMASurfaceWindow::SetDrawRectThread TL %d %d",
       
    73                aRect.iTl.iX, aRect.iTl.iY);
       
    74     DEBUG_INT2("MID::CMMASurfaceWindow::SetDrawRectThread BR %d %d",
       
    75                aRect.iBr.iX, aRect.iBr.iY);
       
    76 
       
    77     iContentRect = aRect;
       
    78     TInt error = StaticRedrawVideo(*this);
       
    79     if (KErrNone != error)
       
    80     {
       
    81         DEBUG_INT("MID::CMMASurfaceWindow::SetDrawRectThread, StaticRedrawVideo error = %d", error);
       
    82     }
       
    83 }
       
    84 
       
    85 void CMMASurfaceWindow::SetRWindowRect(const TRect& aRect,
       
    86                                        MMMADisplay::TThreadType aThreadType)
       
    87 {
       
    88     DEBUG_INT2("MID::CMMASurfaceWindow::SetRWindowRect TL %d %d",
       
    89                aRect.iTl.iX, aRect.iTl.iY);
       
    90     DEBUG_INT2("MID::CMMASurfaceWindow::SetRWindowRect BR %d %d",
       
    91                aRect.iBr.iX, aRect.iBr.iY);
       
    92 
       
    93     if (iRWindowRect == aRect)
       
    94     {
       
    95         return;
       
    96     }
       
    97 
       
    98     iRWindowRect = aRect;
       
    99 
       
   100     if (MMMADisplay::EMmaThread == aThreadType)
       
   101     {
       
   102         if (iDisplay)
       
   103         {
       
   104             iDisplay->UIGetCallback(*this,
       
   105                                     CMMASurfaceWindow::ESetClipRect);
       
   106         }
       
   107     }
       
   108     else if (MMMADisplay::EUiThread == aThreadType)
       
   109     {
       
   110         TInt error = SetClipRect();
       
   111         if (KErrNone != error)
       
   112         {
       
   113             DEBUG_INT("MID::CMMASurfaceWindow::SetRWindowRect, error = %d", error);
       
   114         }
       
   115     }
       
   116 }
       
   117 
       
   118 TInt CMMASurfaceWindow::SetClipRect()
       
   119 {
       
   120     DEBUG("MID::CMMASurfaceWindow::SetClipRect");
       
   121 
       
   122     // CMediaClientVideoDisplay expects client to RemoveDisplayWindow
       
   123     // and AddDisplayWindow again everytime when RWindow rect changes
       
   124     if (iMediaClientVideoDisplay && iWindow)
       
   125     {
       
   126         iMediaClientVideoDisplay->RemoveDisplayWindow(*iWindow);
       
   127 
       
   128         TRect contentRect;
       
   129         if (iVisible)
       
   130         {
       
   131             contentRect = iContentRect;
       
   132         }
       
   133         else
       
   134         {
       
   135             TRect emptyRect(0,0,0,0);
       
   136             contentRect = emptyRect;
       
   137         }
       
   138 
       
   139         // align parent rect with respect to RWindow
       
   140         TRect relativeParentRect;
       
   141         relativeParentRect = iParentRect;
       
   142         relativeParentRect.Move(-iRWindowRect.iTl);
       
   143 
       
   144         // setting video draw rect and adjusting it to window
       
   145         TRect drawRect = contentRect;
       
   146         drawRect.Move(relativeParentRect.iTl);
       
   147 
       
   148         TRect clipRect(0,0,iRWindowRect.Width(),iRWindowRect.Height());
       
   149         TRAPD(error, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow,
       
   150                 clipRect, // new clip rect
       
   151                 iVideoCropRegion,
       
   152                 drawRect,  // video extent
       
   153                 0.0f, // ignore
       
   154                 0.0f, // ignore
       
   155                 EVideoRotationNone,
       
   156                 EAutoScaleBestFit,
       
   157                 EHorizontalAlignLeft,
       
   158                 EVerticalAlignTop,
       
   159                 (RWindow*)iWindow));
       
   160 
       
   161         return error;
       
   162     }
       
   163     return KErrNone;
       
   164 }
       
   165 
       
   166 void CMMASurfaceWindow::SetDrawRect(const TRect& aRect)
       
   167 {
       
   168     DEBUG_INT2("MID::CMMASurfaceWindow::SetDrawRect TL %d %d",
       
   169                aRect.iTl.iX, aRect.iTl.iY);
       
   170     DEBUG_INT2("MID::CMMASurfaceWindow::SetDrawRect BR %d %d",
       
   171                aRect.iBr.iX, aRect.iBr.iY);
       
   172 
       
   173     iContentRect = aRect;
       
   174     if (iDisplay)
       
   175     {
       
   176         iDisplay->UIGetCallback(*this,
       
   177                                 CMMASurfaceWindow::ESetDrawRect);
       
   178     }
       
   179 }
       
   180 
       
   181 TInt CMMASurfaceWindow::StaticRedrawVideo(CMMASurfaceWindow& aSurfaceWindow)
       
   182 {
       
   183     TRAPD(error, aSurfaceWindow.RedrawVideoL());
       
   184     return error;
       
   185 }
       
   186 
       
   187 void CMMASurfaceWindow::RedrawVideoL()
       
   188 {
       
   189     if (!iMediaClientVideoDisplay)
       
   190     {
       
   191         DEBUG("MID::CMMASurfaceWindow::RedrawVideoL: no MediaClientVideoDisplay set, aborting -");
       
   192         return;
       
   193     }
       
   194 
       
   195     if (iWindow)
       
   196     {
       
   197         TRect contentRect;
       
   198         if (iVisible)
       
   199         {
       
   200             contentRect = iContentRect;
       
   201         }
       
   202         else
       
   203         {
       
   204             TRect emptyRect(0,0,0,0);
       
   205             contentRect = emptyRect;
       
   206         }
       
   207 
       
   208         // align parent rect with respect to RWindow
       
   209         TRect relativeParentRect;
       
   210         relativeParentRect = iParentRect;
       
   211         relativeParentRect.Move(-iRWindowRect.iTl);
       
   212 
       
   213         // setting video draw rect and adjusting it to window
       
   214         TRect drawRect = contentRect;
       
   215         drawRect.Move(relativeParentRect.iTl);
       
   216 
       
   217         DEBUG_INT4("MID::CMMASurfaceWindow::RedrawVideoL: drawRect tl %d,%d br %d,%d",
       
   218                    drawRect.iTl.iX,drawRect.iTl.iY,drawRect.iBr.iX,drawRect.iBr.iY);
       
   219 
       
   220         iMediaClientVideoDisplay->SetVideoExtentL(*iWindow,
       
   221                 drawRect,
       
   222                 iVideoCropRegion);
       
   223 
       
   224         DEBUG("MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows()");
       
   225 
       
   226         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
       
   227         ((RWindow*)iWindow)->Invalidate();
       
   228     }
       
   229 }
       
   230 
       
   231 const TRect& CMMASurfaceWindow::DrawRect()
       
   232 {
       
   233     return iContentRect;
       
   234 }
       
   235 
       
   236 TSize CMMASurfaceWindow::WindowSize()
       
   237 {
       
   238     return iParentRect.Size();
       
   239 }
       
   240 
       
   241 void CMMASurfaceWindow::SetPosition(const TPoint& aPosition)
       
   242 {
       
   243     SetDrawRectThread(TRect(aPosition, iContentRect.Size()));
       
   244 }
       
   245 
       
   246 TBool CMMASurfaceWindow::IsVisible() const
       
   247 {
       
   248     DEBUG_INT("MID::CMMASurfaceWindow::IsVisible %d ", iVisible);
       
   249     return iVisible;
       
   250 }
       
   251 
       
   252 void CMMASurfaceWindow::SetVisible(TBool aVisible, TBool aUseEventServer)
       
   253 {
       
   254     DEBUG_INT("MID::CMMASurfaceWindow::SetVisible aVisible %d", aVisible);
       
   255     RPointerArray< CMMAPlayer > players = iEventSource->Players();
       
   256 
       
   257     if (players.Find(iPlayer) != KErrNotFound)
       
   258     {
       
   259         DEBUG("MID::CMMASurfaceWindow::SetVisible : Player found");
       
   260         if (aVisible != iVisible)
       
   261         {
       
   262             DEBUG("MID::CMMASurfaceWindow::SetVisible: Changed visibility");
       
   263             iVisible = aVisible;
       
   264 
       
   265             if (aUseEventServer)
       
   266             {
       
   267                 TInt error = StaticRedrawVideo(*this);
       
   268                 if (KErrNone != error)
       
   269                 {
       
   270                     DEBUG_INT("MID::CMMASurfaceWindow::SetVisible, StaticRedrawVideo error = %d", error);
       
   271                 }
       
   272             }
       
   273             else // in MMA thread, so switch to UI thread
       
   274             {
       
   275                 if (iDisplay)
       
   276                 {
       
   277                     iDisplay->UIGetCallback(*this,
       
   278                                             CMMASurfaceWindow::ESetDrawRect);
       
   279                 }
       
   280             }
       
   281         }
       
   282     }
       
   283 }
       
   284 
       
   285 void CMMASurfaceWindow::SetWindowRect(const TRect& aRect,MMMADisplay::TThreadType /*aThreadType*/)
       
   286 {
       
   287     DEBUG_INT2("MID::CMMASurfaceWindow::SetWindowRect aRect TL %d %d",
       
   288                aRect.iTl.iX, aRect.iTl.iY);
       
   289     DEBUG_INT2("MID::CMMASurfaceWindow::SetWindowRect aRect BR %d %d",
       
   290                aRect.iBr.iX, aRect.iBr.iY);
       
   291 
       
   292     iParentRect = aRect;
       
   293 }
       
   294 
       
   295 void CMMASurfaceWindow::SetVideoCropRegion(const TRect& aRect)
       
   296 {
       
   297     // video size
       
   298     iVideoCropRegion = aRect;
       
   299 }
       
   300 
       
   301 const TRect& CMMASurfaceWindow::WindowRect()
       
   302 {
       
   303     return iParentRect;
       
   304 }
       
   305 
       
   306 void CMMASurfaceWindow::ContainerDestroyed()
       
   307 {
       
   308     // We are in UI thread context now.
       
   309     CleanVideoDisplay();
       
   310 }
       
   311 
       
   312 void CMMASurfaceWindow::SetDisplay(MMMADisplay *aDisplay)
       
   313 {
       
   314     DEBUG("MID::CMMASurfaceWindow::SetDisplay +");
       
   315 
       
   316     if (iDisplay != aDisplay)
       
   317     {
       
   318         if (iDisplay)
       
   319         {
       
   320             // Clear the resources created within the old Display
       
   321             iDisplay->UIGetCallback(
       
   322                 *this, CMMASurfaceWindow::ECleanVideoDisplay);
       
   323         }
       
   324 
       
   325         // Set the new Display
       
   326         iDisplay = aDisplay;
       
   327 
       
   328         if (iDisplay)
       
   329         {
       
   330             // Get a DSA resources for the new Display
       
   331             iDisplay->UIGetDSAResources(*this, MMMADisplay::EMmaThread);
       
   332         }
       
   333     }
       
   334 
       
   335     DEBUG("MID::CMMASurfaceWindow::SetDisplay -");
       
   336 }
       
   337 
       
   338 void CMMASurfaceWindow::ContainerSet()
       
   339 {
       
   340     // We are in UI thread now
       
   341 
       
   342     // Container was probably not set when
       
   343     // iDisplay was set,
       
   344     // we can now try get the DSA stuff again
       
   345     if (iDisplay)
       
   346     {
       
   347         // Get a DSA stuff for the new Display
       
   348         iDisplay->UIGetDSAResources(*this, MMMADisplay::EUiThread);
       
   349     }
       
   350 }
       
   351 
       
   352 void CMMASurfaceWindow::Destroy()
       
   353 {
       
   354     DEBUG("MID::CMMASurfaceWindow::Destroy");
       
   355     // Delete itself
       
   356     delete this;
       
   357 }
       
   358 
       
   359 void CMMASurfaceWindow::MdcDSAResourcesCallback(
       
   360     RWsSession &aWs,
       
   361     CWsScreenDevice &aScreenDevice,
       
   362     RWindowBase &aWindow)
       
   363 {
       
   364     DEBUG("MID::CMMASurfaceWindow::MdcDSAResourcesCallback");
       
   365 
       
   366     // We are in UI thread context now.
       
   367     iWs = &aWs;
       
   368     iScreenDevice = &aScreenDevice;
       
   369     iWindow = &aWindow;
       
   370 
       
   371     switch (iVideoDisplayInitState)
       
   372     {
       
   373     case EUIResourcesAndSurfaceParametersNotSet:
       
   374     {
       
   375         iVideoDisplayInitState =
       
   376             EUIResourcesSetAndSurfaceParametersNotSet;
       
   377     }
       
   378     break;
       
   379     case ESurfaceParametersSetAndUIResourcesNotSet:
       
   380     {
       
   381         iVideoDisplayInitState =
       
   382             EUIResourcesAndSurfaceParametersSet;
       
   383     }
       
   384     break;
       
   385     // can not occur
       
   386     case EUIResourcesSetAndSurfaceParametersNotSet:
       
   387     case EUIResourcesAndSurfaceParametersSet:
       
   388     default:
       
   389     {
       
   390         __ASSERT_DEBUG(EFalse, User::Invariant());
       
   391     }
       
   392     break;
       
   393     }
       
   394 
       
   395     if (iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet)
       
   396     {
       
   397         TRAPD(error, InitVideoDisplayL());
       
   398         if (KErrNone != error)
       
   399         {
       
   400             DEBUG_INT("MID::CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
       
   401         }
       
   402     }
       
   403 }
       
   404 
       
   405 void CMMASurfaceWindow::MdcUICallback(TInt aCallbackId)
       
   406 {
       
   407     // We are in UI thread context now.
       
   408     DEBUG_INT("MID::CMMASurfaceWindow::MdcUICallback CallbackId = %d", aCallbackId);
       
   409 
       
   410     TInt error = KErrNone;
       
   411     switch (aCallbackId)
       
   412     {
       
   413     case ESetClipRect:
       
   414     {
       
   415         error = SetClipRect();
       
   416         DEBUG_INT("MID::CMMASurfaceWindow::MdcUICallback,SetClipRect error = %d", error);
       
   417     }
       
   418     break;
       
   419     case ERemoveSurface:
       
   420     {
       
   421         DoRemoveSurface();
       
   422     }
       
   423     break;
       
   424     case ESetDrawRect:
       
   425     {
       
   426         error = StaticRedrawVideo(*this);
       
   427         DEBUG_INT("MID::CMMASurfaceWindow::MdcUICallback,StaticRedrawVideo error = %d", error);
       
   428     }
       
   429     break;
       
   430     case EInitVideoDisplay:
       
   431     {
       
   432         TRAP(error, InitVideoDisplayL());
       
   433         DEBUG_INT("MID::CMMASurfaceWindow::MdcUICallback,InitVideoDisplayL error = %d", error);
       
   434     }
       
   435     break;
       
   436     case ESetChangedSurfaceParameters:
       
   437     {
       
   438         DoSetChangedSurfaceParameters();
       
   439     }
       
   440     break;
       
   441     case EResetSurfaceParameters:
       
   442     {
       
   443         DoResetSurfaceParameters();
       
   444     }
       
   445     break;
       
   446     case ECleanVideoDisplay:
       
   447     {
       
   448         CleanVideoDisplay();
       
   449     }
       
   450     break;
       
   451     case EDestroyWindow:
       
   452     {
       
   453         Destroy();
       
   454     }
       
   455     break;
       
   456     default:
       
   457     {
       
   458         __ASSERT_DEBUG(EFalse, User::Invariant());
       
   459     }
       
   460     break;
       
   461     }
       
   462 }
       
   463 
       
   464 void CMMASurfaceWindow::SetSurfaceParameters(const TSurfaceId& aSurfaceId,
       
   465         const TRect& aCropRect,
       
   466         const TVideoAspectRatio& aPixelAspectRatio)
       
   467 {
       
   468     iSurfaceId = aSurfaceId;
       
   469     iCropRect = aCropRect;
       
   470     iPixelAspectRatio = aPixelAspectRatio;
       
   471 
       
   472     switch (iVideoDisplayInitState)
       
   473     {
       
   474     case EUIResourcesAndSurfaceParametersNotSet:
       
   475     {
       
   476         iVideoDisplayInitState =
       
   477             ESurfaceParametersSetAndUIResourcesNotSet;
       
   478     }
       
   479     break;
       
   480     case EUIResourcesSetAndSurfaceParametersNotSet:
       
   481     {
       
   482         iVideoDisplayInitState =
       
   483             EUIResourcesAndSurfaceParametersSet;
       
   484     }
       
   485     break;
       
   486     // control reaches below two switch cases when
       
   487     // playback is looped using setLoopCount() in java.
       
   488     case ESurfaceParametersSetAndUIResourcesNotSet:
       
   489     {
       
   490     }
       
   491     break;
       
   492     // update surface parameters and return with out calling
       
   493     // InitVideoDisplayL again.
       
   494     case EUIResourcesAndSurfaceParametersSet:
       
   495     {
       
   496         iDisplay->UIGetCallback(*this, CMMASurfaceWindow::EResetSurfaceParameters);
       
   497         return;
       
   498     }
       
   499     // break; not reachable
       
   500     default: // can not occur
       
   501     {
       
   502         __ASSERT_DEBUG(EFalse, User::Invariant());
       
   503     }
       
   504     break;
       
   505     }
       
   506 
       
   507     if (iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet)
       
   508     {
       
   509         iDisplay->UIGetCallback(*this, CMMASurfaceWindow::EInitVideoDisplay);
       
   510     }
       
   511 }
       
   512 
       
   513 void CMMASurfaceWindow::SetChangedSurfaceParameters(const TSurfaceId& aSurfaceId,
       
   514         const TRect& aCropRect,
       
   515         const TVideoAspectRatio& aPixelAspectRatio)
       
   516 {
       
   517     iSurfaceId = aSurfaceId;
       
   518     iCropRect = aCropRect;
       
   519     iPixelAspectRatio = aPixelAspectRatio;
       
   520 
       
   521     if (iDisplay)
       
   522     {
       
   523         iDisplay->UIGetCallback(*this, CMMASurfaceWindow::ESetChangedSurfaceParameters);
       
   524     }
       
   525 }
       
   526 
       
   527 void CMMASurfaceWindow::RemoveSurface()
       
   528 {
       
   529     if (iDisplay)
       
   530     {
       
   531         iDisplay->UIGetCallback(*this,
       
   532                                 CMMASurfaceWindow::ERemoveSurface);
       
   533     }
       
   534 }
       
   535 
       
   536 void CMMASurfaceWindow::DoRemoveSurface()
       
   537 {
       
   538     if (iMediaClientVideoDisplay)
       
   539     {
       
   540         iMediaClientVideoDisplay->RemoveSurface();
       
   541         DEBUG("MID::CMMASurfaceWindow::DoRemoveSurface, Surface Removed");
       
   542     }
       
   543 }
       
   544 
       
   545 void CMMASurfaceWindow::DoResetSurfaceParameters()
       
   546 {
       
   547     __ASSERT_DEBUG((iMediaClientVideoDisplay != NULL), User::Invariant());
       
   548 
       
   549     if (iMediaClientVideoDisplay)
       
   550     {
       
   551         TInt error = iMediaClientVideoDisplay->SurfaceCreated(iSurfaceId,
       
   552                      iCropRect,
       
   553                      iPixelAspectRatio,
       
   554                      iVideoCropRegion);
       
   555 
       
   556         DEBUG_INT("MID::CMMASurfaceWindow::DoResetSurfaceParameters,SurfaceCreated error = %d", error);
       
   557 
       
   558         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
       
   559     }
       
   560 }
       
   561 
       
   562 void CMMASurfaceWindow::DoSetChangedSurfaceParameters()
       
   563 {
       
   564     if (iMediaClientVideoDisplay)
       
   565     {
       
   566         TInt error = iMediaClientVideoDisplay->SurfaceParametersChanged(iSurfaceId,
       
   567                      iCropRect,
       
   568                      iPixelAspectRatio);
       
   569 
       
   570         DEBUG_INT("MID::CMMASurfaceWindow::DoSetChangedSurfaceParameters,SurfaceParametersChanged, error = %d", error);
       
   571 
       
   572         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
       
   573     }
       
   574 }
       
   575 
       
   576 void CMMASurfaceWindow::InitVideoDisplayL()
       
   577 {
       
   578     if (iVideoDisplayInitState != EUIResourcesAndSurfaceParametersSet)
       
   579     {
       
   580         User::Leave(KErrNotReady);
       
   581     }
       
   582 
       
   583     // check that this is the first time we are creating instance.
       
   584     if (iMediaClientVideoDisplay)
       
   585     {
       
   586         __ASSERT_DEBUG(EFalse, User::Invariant());
       
   587     }
       
   588 
       
   589     iMediaClientVideoDisplay =
       
   590         CMediaClientVideoDisplay::NewL(iScreenDevice->GetScreenNumber(),
       
   591                                        iSurfaceId,
       
   592                                        iCropRect,
       
   593                                        iPixelAspectRatio);
       
   594 
       
   595     TInt error = iMediaClientVideoDisplay->SurfaceCreated(iSurfaceId,
       
   596                  iCropRect,
       
   597                  iPixelAspectRatio,
       
   598                  iVideoCropRegion);
       
   599 
       
   600     DEBUG_INT("MID::CMMASurfaceWindow::InitVideoDisplayL error = %d", error);
       
   601     User::LeaveIfError(error);
       
   602 
       
   603     TRect contentRect;
       
   604     if (iVisible)
       
   605     {
       
   606         contentRect = iContentRect;
       
   607     }
       
   608     else
       
   609     {
       
   610         TRect emptyRect(0,0,0,0);
       
   611         contentRect = emptyRect;
       
   612     }
       
   613 
       
   614     // align parent rect with respect to RWindow
       
   615     TRect relativeParentRect;
       
   616     relativeParentRect = iParentRect;
       
   617     relativeParentRect.Move(-iRWindowRect.iTl);
       
   618 
       
   619     // setting video draw rect and adjusting it to window
       
   620     TRect drawRect = contentRect;
       
   621     drawRect.Move(relativeParentRect.iTl);
       
   622 
       
   623     TRect clipRect(0,0,iRWindowRect.Width(),iRWindowRect.Height());
       
   624     iMediaClientVideoDisplay->AddDisplayWindowL(iWindow,
       
   625             clipRect,
       
   626             iVideoCropRegion,
       
   627             drawRect,  // video extent
       
   628             0.0f, // ignore
       
   629             0.0f, // ignore
       
   630             EVideoRotationNone,
       
   631             EAutoScaleBestFit,
       
   632             EHorizontalAlignLeft,
       
   633             EVerticalAlignTop,
       
   634             (RWindow*)iWindow);
       
   635 
       
   636     DEBUG("MID::CMMASurfaceWindow::InitVideoDisplayL -");
       
   637 }
       
   638 
       
   639 void CMMASurfaceWindow::CleanVideoDisplay()
       
   640 {
       
   641     DEBUG("MID::CMMASurfaceWindow::CleanVideoDisplay +");
       
   642 
       
   643     SetVisible(EFalse, ETrue);
       
   644     if (iMediaClientVideoDisplay)
       
   645     {
       
   646         if (iWindow)
       
   647         {
       
   648             iMediaClientVideoDisplay->RemoveDisplayWindow(*iWindow);
       
   649         }
       
   650         iMediaClientVideoDisplay->RemoveSurface();
       
   651         delete iMediaClientVideoDisplay;
       
   652 
       
   653         iMediaClientVideoDisplay = NULL;
       
   654         iWindow = NULL;
       
   655         iScreenDevice = NULL;
       
   656         iWs = NULL;
       
   657     }
       
   658 
       
   659     DEBUG("MID::CMMASurfaceWindow::CleanVideoDisplay -");
       
   660 }
       
   661 
       
   662 //  END OF FILE